File tree 1 file changed +11
-5
lines changed
web2py/applications/utility/models
1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -653,11 +653,17 @@ def choose_condition():
653
653
654
654
# Else, let's make a new one.
655
655
656
- # Choose a condition. We'll grab the next one in round-robin fashion.
657
- num_choices_made = db ((db .experimental_assignments .phase == request .phase )
658
- & (db .experimental_assignments .study == request .study )).count ()
659
- request .condition = condition_by_index (experimental_vars_vals (request .study ),
660
- num_choices_made )
656
+ # Choose a condition. First, give special conditions a shot
657
+ for probability , condition in options [request .task ]['special_conditions' ] or []:
658
+ if random .random () < probability :
659
+ request .condition = condition .copy ()
660
+ break
661
+ # If none of them match, grab the next condition in round-robin fashion.
662
+ else :
663
+ num_choices_made = db ((db .experimental_assignments .phase == request .phase )
664
+ & (db .experimental_assignments .study == request .study )).count ()
665
+ request .condition = condition_by_index (experimental_vars_vals (request .study ),
666
+ num_choices_made )
661
667
662
668
# Now add the singleton variables back into the condition... (need
663
669
# to make this more consistent between singleton option variables
You can’t perform that action at this time.
0 commit comments