[virtualcommons-developer] commit/vcweb: alllee: removing ready_participants integer field on Exper
Status: Beta
Brought to you by:
alllee
|
From: <com...@bi...> - 2013-03-20 07:05:32
|
1 new commit in vcweb: https://bitbucket.org/virtualcommons/vcweb/commits/d542e23263d1/ changeset: d542e23263d1 user: alllee date: 2013-03-20 08:05:17 summary: removing ready_participants integer field on Experiment, too easily corrupted since we can't verify when duplicate increments occur replacing with stored participant_ready data values and count calculations affected #: 5 files diff -r d6622ad4c638f361b16509f918c415a23475ff5b -r d542e23263d13375508d2d69e904e4e3739acb96 vcweb/boundaries/views.py --- a/vcweb/boundaries/views.py +++ b/vcweb/boundaries/views.py @@ -95,6 +95,7 @@ experiment_model_dict['groupData'] = group_data # round / experiment configuration data + experiment_model_dict['readyParticipants'] = experiment.ready_participants experiment_model_dict['participantsPerGroup'] = ec.max_group_size experiment_model_dict['regrowthRate'] = regrowth_rate experiment_model_dict['costOfLiving'] = cost_of_living diff -r d6622ad4c638f361b16509f918c415a23475ff5b -r d542e23263d13375508d2d69e904e4e3739acb96 vcweb/core/models.py --- a/vcweb/core/models.py +++ b/vcweb/core/models.py @@ -316,8 +316,6 @@ """ elapsed time in seconds for the current round. """ amqp_exchange_name = models.CharField(max_length=64, default="vcweb.default.exchange") - ready_participants = models.PositiveIntegerField(default=0, help_text=_("The number of participants ready to move on to the next round.")) - cached_round_sequence_number = None ''' used to cache the round configuration ''' @@ -520,11 +518,15 @@ return self.current_round.instructions @property + def ready_participants(self): + return ParticipantRoundDataValue.objects.filter(parameter=get_participant_ready_parameter(), round_data=self.current_round_data, boolean_value=True).count() + + @property def all_participants_ready(self): - return self.ready_participants >= self.participant_set.count() + return self.ready_participants == self.participant_set.count() def get_participant_experiment_relationship(self, participant): - return self.participant_relationship_set.get(participant=participant) + return self.participant_relationship_set.select_related('participant__user').get(participant=participant) def get_participant_group_relationship(self, participant): session_id = self.current_round.session_id @@ -770,7 +772,6 @@ self.create_round_data() self.current_round_elapsed_time = 0 self.current_round_start_time = datetime.now() - self.ready_participants = 0 self.save() self.log('Starting round') current_round_configuration = self.current_round diff -r d6622ad4c638f361b16509f918c415a23475ff5b -r d542e23263d13375508d2d69e904e4e3739acb96 vcweb/core/templates/experimenter/monitor.html --- a/vcweb/core/templates/experimenter/monitor.html +++ b/vcweb/core/templates/experimenter/monitor.html @@ -13,7 +13,7 @@ <div class='btn-toolbar'><div class='btn-group'><a class='btn btn-success' data-bind="css: { disabled: isRoundInProgress }" data-action='start_round' data-content='Starts the round.'><i class='icon-play'></i> start</a> - <a class='btn btn-success' data-bind='click: advanceToNextRound' data-action='advance_to_next_round' data-content='Advances to the next round and starts it.'><i class='icon-step-forward'></i> next round</a> + <a class='btn btn-success' data-bind='click: advanceToNextRound' data-action='advance_to_next_round' data-content='Advances to and starts the next round.'><i class='icon-step-forward'></i> next round</a><a class='btn btn-success' data-bind='click: refreshAllParticipants' data-content='Sends a page refresh to all connected participants.' ><i class='icon-refresh'></i> refresh participants</a></div></div> @@ -69,7 +69,7 @@ <li><a href='export/configuration.xml'><i class='icon-cog'></i>xml</a></li><li><a href='export/configuration.json'><i class='icon-pencil'></i>json</a></li></ul> - <a class='btn btn-info confirm-experiment-action' data-action='complete' data-content='Mark this experiment as completed and archive it.'><i class='icon-save'></i> archive</a> + <a class='btn btn-danger confirm-experiment-action' data-action='complete' data-content='Mark this experiment as completed and archive it.'><i class='icon-save'></i> archive</a></div></div><div class='span6'> diff -r d6622ad4c638f361b16509f918c415a23475ff5b -r d542e23263d13375508d2d69e904e4e3739acb96 vcweb/core/views.py --- a/vcweb/core/views.py +++ b/vcweb/core/views.py @@ -522,13 +522,11 @@ if valid_form: pgr = get_object_or_404(ParticipantGroupRelationship.objects.select_related('group__experiment'), pk=form.cleaned_data['participant_group_id']) experiment = pgr.group.experiment - prdv, created = ParticipantRoundDataValue.objects.get_or_create(participant_group_relationship=pgr, + prdv = ParticipantRoundDataValue.objects.get(participant_group_relationship=pgr, round_data=experiment.get_round_data(), parameter=get_participant_ready_parameter()) prdv.submitted = True prdv.boolean_value = True prdv.save() - experiment.ready_participants += 1 - experiment.save() return JsonResponse(dumps({'success': valid_form})) def handler500(request): diff -r d6622ad4c638f361b16509f918c415a23475ff5b -r d542e23263d13375508d2d69e904e4e3739acb96 vcweb/forestry/tests.py --- a/vcweb/forestry/tests.py +++ b/vcweb/forestry/tests.py @@ -246,7 +246,7 @@ participant_data_values = round_data.participant_data_value_set.filter(participant_group_relationship__participant=p) logger.debug("XXX: participant data values: %s", participant_data_values) self.assertEqual(participant_data_values.count(), 2) - pexpr = p.get_participant_experiment_relationship(e) + pexpr = e.get_participant_experiment_relationship(p) logger.debug("relationship %s" % pexpr) for dv in participant_data_values.filter(parameter__type='int'): logger.debug("verifying data value %s" % dv) Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |