Spaces:
Running
The post-task battery runs once per block, adapted to each
Browse filesOne battery at the end asked about both blocks at once, which meant the
night-harvest items were on a page shown before that block existed in some
orders, and every other item was ambiguous about which half of the session it
meant. It now runs twice, after the block it asks about.
A fatigue slider between the two blocks, as well as before and after.
Each battery is framed to its block: NASA-TLX says which harvest to think
back to, the feelings items ask about earning for someone in the day and
about walking home while they lose in the night, motivation and effort carry
only that block's choices, task ratings name the block, strategy asks about
that block, and the belief check asks its own partner its own question, into
its own column so one cannot overwrite the other.
A day-only session is unchanged: the day battery keeps the stage names it was
registered with and sits where it always did, and the night battery is
skipped with the block itself. STAGE_ORDER gains the eight new stages, which
test_stage_order.py already verifies is complete.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Files changed (6)
40 unmodified lines4142434445464748495040 unmodified lines"Fatigue_pre", "HowToPlay", "Calibration", "Practice","Comprehension", "Ready", "Harvest1", "Break", "Harvest2","Night1", "Night2", "Night2b", "Night1b", "HarvestSpeed", "Uncertainty","NightWatchPractice", "NightWatch","QuestionnaireTransition", "Fatigue_post", "NASA_TLX", "Effort_impact","PostTask_Motivation", "PostTask_Effort2", "PostTask_TaskRating","PostTask_Belief", "PostTask_Hypothetical", "PostTask_Strategy","TriPM", "Demographics",]40 unmodified lines414243444546474849505152535455565740 unmodified lines"Fatigue_pre", "HowToPlay", "Calibration", "Practice","Comprehension", "Ready", "Harvest1", "Break", "Harvest2","Night1", "Night2", "Night2b", "Night1b", "HarvestSpeed", "Uncertainty","QuestionnaireTransition", "Fatigue_post", "NASA_TLX", "Effort_impact","PostTask_Motivation", "PostTask_Effort2", "PostTask_TaskRating","PostTask_Belief", "PostTask_Hypothetical", "PostTask_Strategy",# The night harvest and the battery that asks about it. Both sit after# the day task's questions, because each block is asked about once it has# been played rather than both at the end."NightWatchPractice", "NightWatch","Fatigue_night", "Night_NASA_TLX", "Night_Effort_impact","Night_PostTask_Motivation", "Night_PostTask_Effort2","Night_PostTask_TaskRating", "Night_PostTask_Belief","Night_PostTask_Strategy","TriPM", "Demographics",]
68 unmodified lines697071727374757677787980818283848586878889909168 unmodified linesparticipant id so the payment is reproducible, and participants are toldabout 20% of nights will be drawn.## After the game| Screen | What it asks ||---|---|| Harvest complete | All three purses, in credits and dollars. The night partner's line says what they **lost**, not what was earned for them. || Fatigue (post) | One slider. || NASA-TLX | Workload. || Feelings | How it felt earning for each party. || Motivation | Per choice type: work/rest for self, work/rest for partner, and three night-harvest items naming the night partner. || Effort | The same items, worded as effort. || Task ratings | Difficulty, interest. || Belief | Did they believe the day partner would receive, and the night partner would lose, the credits shown. || Hypothetical | One multiple choice. || Strategy | Free text. || TriPM | 58 items. The individual-difference measure H3 and H5 are tested against. || Demographics | Last. || Completed | Final screen with the purses and the payment reference code. |Every questionnaire page can be left blank. It asks "are you sure" andrecords which items were untouched, because the consent says participants68 unmodified lines6970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411568 unmodified linesparticipant id so the payment is reproducible, and participants are toldabout 20% of nights will be drawn.## After each blockThe battery runs **twice**, once per block, each time asking about the blockjust played. A day-only session sees only the first and in the order it wasregistered in.After the day task:| Screen | What it asks ||---|---|| Harvest complete | The day purses, in credits and dollars. || Fatigue | One slider. || Effort | How effortful each of the four levels felt, during the daytime harvest. || Feelings | How it felt earning for yourself and for the day partner. || Motivation | Work and rest, for self and for the day partner. || Effort | The same four, worded as effort. || About the task | Difficulty and interest, for the daytime harvest. || Belief | Did they believe the day partner would really receive the credits. || Hypothetical | One multiple choice. Asked once, here. || Strategy | Free text, about the daytime harvest. |After the night harvest, the same battery adapted:| Screen | What it asks ||---|---|| Fatigue | One slider. || Effort | The four levels again, during the Night Harvest. || Feelings | How it felt walking home with credits while the partner lost the larger amount, and how it felt harvesting their field instead. || Motivation | Rest, work, and the nights shown as a range. || Effort | The same three, worded as effort. || About the task | Difficulty and interest, for the Night Harvest. || Belief | Did they believe the night partner would really lose the credits shown. || Strategy | Free text, about the Night Harvest. |Then once, at the end:| Screen | What it asks ||---|---|| TriPM | 58 items. The individual-difference measure H3 and H5 are tested against. || Demographics | Last. || Completed | Final screen with all purses and the payment reference code. |Every questionnaire page can be left blank. It asks "are you sure" andrecords which items were untouched, because the consent says participants
1276 unmodified lines127712781279128012811282263 unmodified lines1546154715481549155015511552155315541555155615571558155915601561156215631276 unmodified linesUNCERTAINTY_STAGE = "Uncertainty"NIGHT_WATCH_STAGE = "NightWatch"NIGHT_WATCH_PRACTICE_STAGE = "NightWatchPractice"def night_watch_on():263 unmodified lines# when the link does not ask for it._harvest_speed_stage(),_uncertainty_stage(),_night_watch_practice_stage(),_night_watch_stage(),_fb("QuestionnaireTransition", credits_bridge_display),Q.fatigue_stage("post"),Q.nasa_tlx_stage(),Q.effort_impact_stage(),Q.motivation_stage(),Q.effort_exerted_stage(),Q.task_rating_stage(),Q.belief_stage(),Q.hypothetical_stage(),Q.strategy_stage(),# Demographics and the TriPM go LAST. Everything above asks about the# task the participant just did, and the belief check in particular is# worth asking while it is fresh; the trait measure is the longest1276 unmodified lines127712781279128012811282128312841285263 unmodified lines1549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811276 unmodified linesUNCERTAINTY_STAGE = "Uncertainty"NIGHT_WATCH_STAGE = "NightWatch"NIGHT_WATCH_PRACTICE_STAGE = "NightWatchPractice"#: The battery that asks about the night harvest. Skipped with the block#: itself: a day-only session must not be asked about a task it never saw.NIGHT_QUESTION_STAGES = frozenset(['Fatigue_night', 'Night_NASA_TLX', 'Night_Effort_impact', 'Night_PostTask_Motivation', 'Night_PostTask_Effort2', 'Night_PostTask_TaskRating', 'Night_PostTask_Belief', 'Night_PostTask_Strategy'])def night_watch_on():263 unmodified lines# when the link does not ask for it._harvest_speed_stage(),_uncertainty_stage(),# --- everything above is the DAY task and the optional legacy blocks;# the battery below asks about them, and a day-only session is in# exactly the order it was registered in._fb("QuestionnaireTransition", credits_bridge_display),Q.fatigue_stage("post"),Q.nasa_tlx_stage("day"),Q.effort_impact_stage("day"),Q.motivation_stage("day"),Q.effort_exerted_stage("day"),Q.task_rating_stage("day"),Q.belief_stage("day"),Q.hypothetical_stage(),Q.strategy_stage("day"),# --- the night harvest, and then the same battery adapted to it.# Asked here rather than folded into the one above, because that one# runs before this block exists and was asking about a task the# participant had not reached._night_watch_practice_stage(),_night_watch_stage(),Q.fatigue_stage("night"),Q.nasa_tlx_stage("night"),Q.effort_impact_stage("night"),Q.motivation_stage("night"),Q.effort_exerted_stage("night"),Q.task_rating_stage("night"),Q.belief_stage("night"),Q.strategy_stage("night"),# Demographics and the TriPM go LAST. Everything above asks about the# task the participant just did, and the belief check in particular is# worth asking while it is fresh; the trait measure is the longest
129 unmodified lines1301311321331341351361371381391401415 unmodified lines1471481491501511521531541551561571581592 unmodified lines1621631641651661671681691701711721731741751761771781791801811821831841851861871881897 unmodified lines19719819920020120220330 unmodified lines2342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483496 unmodified lines3563573583593603613623633643653663673684 unmodified lines37337437537637737837938038138238338452 unmodified lines4374384394404414424432 unmodified lines44644744844945045145210 unmodified lines463464465466467468469470471129 unmodified lines# ----------------------------------------------------------------------------# Fatigue# ----------------------------------------------------------------------------def fatigue_stage(when):async def _display(stage, container):# "post" no longer repeats "the task has finished" -- the dedicated# QuestionnaireTransition screen right before this one already says that.intro = ("One quick question first."if when == "post" else "Before we begin, one quick question.")res, _went_back = await _slider_battery(container, "How tired do you feel right now?", intro,[("fatigue", "How tired do you feel right now?")],5 unmodified lines# ----------------------------------------------------------------------------# NASA-TLX style effort ratings (uses the participant's calibrated levels)# ----------------------------------------------------------------------------def nasa_tlx_stage():async def _display(stage, container):th = TH.current_theme()v, t = th["verb"], th["target"]levels = D.effort_levels(app.storage.user.get("max_boxes", D.MAX_BOXES_FALLBACK))res, went_back = await _slider_battery(container, "Effort", f"Think back to {v}ing {t}.",# easiest and hardest levels by rank, not by name -- the names change# if the effort fractions are ever retuned, the ranks do not.[(f"effort_lvl{i + 1}",2 unmodified lines"Required no effort", "Required a lot of effort", allow_back=True)if went_back:_go_back_one_stage()return dict(measure="nasa_tlx_effort", went_back=True, **res)return dict(measure="nasa_tlx_effort", levels=levels, **res)return _fb("NASA_TLX", _display)# ----------------------------------------------------------------------------# Effort impact (self vs other)# ----------------------------------------------------------------------------def effort_impact_stage():async def _display(stage, container):rid = app.storage.user.get("random_id", "the other player")res, went_back = await _slider_battery(container, "Your feelings", "",[("impact_self", "How did you feel when you earned credits for YOU?"),("impact_other", f"How did you feel when you earned credits for your "f"partner ({rid}), the OTHER player?")],"Very bad", "Very good", allow_back=True)if went_back:_go_back_one_stage()return dict(measure="effort_impact", went_back=True, **res)return dict(measure="effort_impact", **res)return _fb("Effort_impact", _display)# ----------------------------------------------------------------------------7 unmodified linesreturn f"your partner ({rid})"def _choice_items(prefix, phrasing):"""One item per CHOICE the participant actually faced.Split by choice type (work / rest / raid) crossed with who was paid, rather30 unmodified linesphrasing("keep the night harvest in YOUR OWN pocket")))items.append((f"{prefix}_raid_leave",phrasing(f"leave the night harvest in the pocket of {p}")))# The night harvest, which is the whole of the SONA session's second half and# had no items at all. Named against ITS partner: these blocks are about# different people, and asking about the day partner here would attach the# rating to someone the participant never did this to.try:last_field = bool(E.night_watch_on())except Exception:last_field = Falseif last_field:pn = E.partner_label_plain("night")items.append((f"{prefix}_field_rest",phrasing(f"WALK OFF with a bagful at night, knowing "f"{pn} would lose the larger amount")))items.append((f"{prefix}_field_work",phrasing(f"BRING IN the field of {pn} at night, for one "f"credit less than walking off")))items.append((f"{prefix}_field_vague",phrasing(f"BRING IN their field on the nights when you "f"were shown a RANGE")))return itemsdef motivation_stage():async def _display(stage, container):res, went_back = await _slider_battery(container, "Motivation", "Think back to the task you just completed.",_choice_items("motiv", lambda what: f"How motivated were you to {what}?"),"Not at all motivated", "Extremely motivated", allow_back=True)if went_back:_go_back_one_stage()return dict(measure="post_motivation", went_back=True, **res)return dict(measure="post_motivation", **res)return _fb("PostTask_Motivation", _display)def effort_exerted_stage():async def _display(stage, container):res, went_back = await _slider_battery(container, "Effort", "",_choice_items("effort", lambda what: f"How much effort did it take to {what}?"),"Required no effort", "Required a lot of effort", allow_back=True)if went_back:_go_back_one_stage()return dict(measure="post_effort", went_back=True, **res)return dict(measure="post_effort", **res)return _fb("PostTask_Effort2", _display)def task_rating_stage():async def _display(stage, container):res, went_back = await _slider_battery(container, "About the task", "",[("task_difficulty", "How easy or difficult was the task?","Very easy", "Very difficult"),("task_interest", "How boring or interesting was the task?","Very boring", "Very interesting")], allow_back=True)if went_back:_go_back_one_stage()return dict(measure="post_task_rating", went_back=True, **res)return dict(measure="post_task_rating", **res)return _fb("PostTask_TaskRating", _display)def belief_stage():"""Manipulation check: did they believe the partner's payout was real?"""async def _display(stage, container):nicewebrl.clear_element(container)chosen = {"v": None}night_ans = {"v": None}result = {"went_back": False}done = asyncio.Event()import effort_stages as Etry:night = bool(E.night_watch_on())except Exception:night = Falsewith container.style("align-items:center; max-width:640px;"):ui.markdown("## Your Partners" if night else "## Your Partner")# Named only when there are two of them to tell apart.who = (f" (**{app.storage.user.get('random_id')}**)" if night else "")ui.markdown(f"During the daytime harvest, did you believe that the other "f"person{who} would really receive the credits you earned for "f"them?")radio = ui.radio({"Yes": "Yes", "No": "No"}).props("color=primary")with ui.row():ui.button("Back", on_click=lambda: (result.update(went_back=True), done.set())).props("outline")submit = ui.button("Submit")# The night harvest reverses the question: nothing was earned FOR# that partner, credits were taken FROM them. Asking only the day# task's version left the block's own manipulation check# unasked, and its exclusion criterion resting on a question# about a different person and the opposite direction of money.night_radio = Noneif night:ui.markdown("---")nid = (app.storage.user.get("random_id_night")or E.night_partner_id())# Asks about what is SHOWN, not about what the participant# pocketed. Phrasing it as the amount they walked off with# equates the two, and they are not equal: 2 against as much# as 20. That 1:1 reading is the one the task is built to# avoid, and this would have been the last thing a# participant read about the block.ui.markdown(f"During the Night Harvest, did you believe that the "f"other person (**{nid}**) would really lose the credits "f"shown on screen?")night_radio = ui.radio({"Yes": "Yes", "No": "No"}).props("color=primary")cont = ui.button("Continue", on_click=lambda: done.set())cont.set_visibility(False)6 unmodified lines# unanswered one through. This one silently did nothing when# Submit was pressed with a blank, which reads as a broken# button rather than as a requirement.missing = radio.value is None or (night and night_radio.value is None)if missing and not await _confirm_skip():returnchosen["v"] = radio.valueif night:night_ans["v"] = night_radio.valuenight_radio.disable()radio.disable(); submit.disable(); cont.set_visibility(True)submit.on_click(go)4 unmodified lines# already-submitted answer isn't discarded if this record happens# to be the last one written for this stage (same reasoning as the# slider-battery stages above).return dict(measure="belief_check", went_back=True,believed_partner_paid=chosen["v"],believed_night_partner_lost=night_ans["v"])return dict(measure="belief_check", believed_partner_paid=chosen["v"],believed_night_partner_lost=night_ans["v"])return _fb("PostTask_Belief", _display)# ----------------------------------------------------------------------------52 unmodified linesreturn _fb("PostTask_Hypothetical", _display)def strategy_stage():"""Free-text: what strategy did the participant use?"""async def _display(stage, container):nicewebrl.clear_element(container)2 unmodified linesth = TH.current_theme()with container.style("align-items:center; max-width:640px;"):ui.markdown("## Your strategy")ui.markdown(f"What strategy (or strategies) did you use during the {th['verb']}ing task?")text = ui.textarea().props("outlined autogrow").style("width:100%;")async def on_continue():10 unmodified lines_go_back_one_stage()# text.value is live-bound (no separate "commit" step like a submit# button), so whatever was already typed is safe to include here too.return dict(measure="strategy", went_back=True, strategy_text=(text.value or "").strip())return dict(measure="strategy", strategy_text=(text.value or "").strip())return _fb("PostTask_Strategy", _display)# ----------------------------------------------------------------------------129 unmodified lines1301311321331341351361371381391401411421431441451461471481491501511525 unmodified lines1581591601611621631641651661671681691701712 unmodified lines1741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152167 unmodified lines22422522622722822923030 unmodified lines2612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733746 unmodified lines3813823833843853863873883894 unmodified lines39439539639739839940040140240340452 unmodified lines4574584594604614624632 unmodified lines46646746846947047147247310 unmodified lines484485486487488489490491492493494129 unmodified lines# ----------------------------------------------------------------------------# Fatigue# ----------------------------------------------------------------------------#: Stage-name suffix and on-screen framing per block. A day-only session must#: keep the names it was registered with, so "day" adds nothing.BLOCK_SUFFIX = {"day": "", "night": "Night_"}def _block_frame(block):"""How to name the block on screen."""return "the Night Harvest" if block == "night" else "the daytime harvest"def fatigue_stage(when):"""`when` is "pre", "post" (after the day task) or "night"."""async def _display(stage, container):# "post" no longer repeats "the task has finished" -- the dedicated# QuestionnaireTransition screen right before this one already says that.intro = ("Before we begin, one quick question." if when == "pre"else "One quick question first.")res, _went_back = await _slider_battery(container, "How tired do you feel right now?", intro,[("fatigue", "How tired do you feel right now?")],5 unmodified lines# ----------------------------------------------------------------------------# NASA-TLX style effort ratings (uses the participant's calibrated levels)# ----------------------------------------------------------------------------def nasa_tlx_stage(block="day"):async def _display(stage, container):th = TH.current_theme()v, t = th["verb"], th["target"]levels = D.effort_levels(app.storage.user.get("max_boxes", D.MAX_BOXES_FALLBACK))res, went_back = await _slider_battery(container, "Effort",f"Think back to {v}ing {t} during {_block_frame(block)}.",# easiest and hardest levels by rank, not by name -- the names change# if the effort fractions are ever retuned, the ranks do not.[(f"effort_lvl{i + 1}",2 unmodified lines"Required no effort", "Required a lot of effort", allow_back=True)if went_back:_go_back_one_stage()return dict(measure="nasa_tlx_effort", block=block,went_back=True, **res)return dict(measure="nasa_tlx_effort", block=block, levels=levels, **res)return _fb(BLOCK_SUFFIX[block] + "NASA_TLX", _display)# ----------------------------------------------------------------------------# Effort impact (self vs other)# ----------------------------------------------------------------------------def effort_impact_stage(block="day"):async def _display(stage, container):import effort_stages as Eif block == "night":# Nothing was earned FOR this partner, so the day task's wording# describes a game that was not played here.nid = app.storage.user.get("random_id_night", "the other player")items = [("impact_night_take",f"How did you feel when you walked home with credits and "f"your partner ({nid}) lost the larger amount?"),("impact_night_work",f"How did you feel when you harvested their field and "f"your partner ({nid}) lost far less?")]else:rid = app.storage.user.get("random_id", "the other player")items = [("impact_self","How did you feel when you earned credits for YOU?"),("impact_other",f"How did you feel when you earned credits for your "f"partner ({rid}), the OTHER player?")]res, went_back = await _slider_battery(container, "Your feelings", "", items,"Very bad", "Very good", allow_back=True)if went_back:_go_back_one_stage()return dict(measure="effort_impact", block=block, went_back=True, **res)return dict(measure="effort_impact", block=block, **res)return _fb(BLOCK_SUFFIX[block] + "Effort_impact", _display)# ----------------------------------------------------------------------------7 unmodified linesreturn f"your partner ({rid})"def _choice_items(prefix, phrasing, block="day"):"""One item per CHOICE the participant actually faced.Split by choice type (work / rest / raid) crossed with who was paid, rather30 unmodified linesphrasing("keep the night harvest in YOUR OWN pocket")))items.append((f"{prefix}_raid_leave",phrasing(f"leave the night harvest in the pocket of {p}")))return itemsdef _night_choice_items(prefix, phrasing):"""The night harvest's own items, asked in its own battery after it.Separate from the day task's rather than appended to them: the two blocksare about different people and are now asked about at different points inthe session, so putting both sets on one page asked about a block theparticipant had not reached yet."""import effort_stages as Epn = E.partner_label_plain("night")return [(f"{prefix}_field_rest",phrasing(f"REST and walk home with credits, knowing {pn} would lose "f"the larger amount")),(f"{prefix}_field_work",phrasing(f"WORK on the field of {pn} for one credit less than "f"resting")),(f"{prefix}_field_vague",phrasing(f"WORK on their field on the nights when you were shown a "f"RANGE instead of an amount")),]def motivation_stage(block="day"):async def _display(stage, container):picker = _night_choice_items if block == "night" else _choice_itemsres, went_back = await _slider_battery(container, "Motivation",f"Think back to {_block_frame(block)}.",picker("motiv", lambda what: f"How motivated were you to {what}?"),"Not at all motivated", "Extremely motivated", allow_back=True)if went_back:_go_back_one_stage()return dict(measure="post_motivation", block=block, went_back=True, **res)return dict(measure="post_motivation", block=block, **res)return _fb(BLOCK_SUFFIX[block] + "PostTask_Motivation", _display)def effort_exerted_stage(block="day"):async def _display(stage, container):picker = _night_choice_items if block == "night" else _choice_itemsres, went_back = await _slider_battery(container, "Effort", f"During {_block_frame(block)}.",picker("effort", lambda what: f"How much effort did it take to {what}?"),"Required no effort", "Required a lot of effort", allow_back=True)if went_back:_go_back_one_stage()return dict(measure="post_effort", block=block, went_back=True, **res)return dict(measure="post_effort", block=block, **res)return _fb(BLOCK_SUFFIX[block] + "PostTask_Effort2", _display)def task_rating_stage(block="day"):async def _display(stage, container):where = _block_frame(block)res, went_back = await _slider_battery(container, "About the task", "",[("task_difficulty", f"How easy or difficult was {where}?","Very easy", "Very difficult"),("task_interest", f"How boring or interesting was {where}?","Very boring", "Very interesting")], allow_back=True)if went_back:_go_back_one_stage()return dict(measure="post_task_rating", block=block, went_back=True, **res)return dict(measure="post_task_rating", block=block, **res)return _fb(BLOCK_SUFFIX[block] + "PostTask_TaskRating", _display)def _belief_key(block):"""Distinct column names: the two answers mean different things, and oneoverwriting the other in the export would be silent."""return ("believed_night_partner_lost" if block == "night"else "believed_partner_paid")def belief_stage(block="day"):"""Manipulation check: did they believe the partner's payout was real?"""async def _display(stage, container):nicewebrl.clear_element(container)chosen = {"v": None}result = {"went_back": False}done = asyncio.Event()import effort_stages as Enight = (block == "night")with container.style("align-items:center; max-width:640px;"):ui.markdown("## Your Partner")# Each battery asks about its own block's partner. Asking both# on one page meant asking about a block the participant had not# reached yet, once the batteries were split.if night:nid = (app.storage.user.get("random_id_night")or E.night_partner_id())prompt = (f"During the Night Harvest, did you believe that "f"the other person (**{nid}**) would really lose "f"the credits shown on screen?")else:rid = app.storage.user.get("random_id", "Player 2")prompt = (f"During the daytime harvest, did you believe that "f"the other person (**{rid}**) would really receive "f"the credits you earned for them?")ui.markdown(prompt)radio = ui.radio({"Yes": "Yes", "No": "No"}).props("color=primary")with ui.row():ui.button("Back", on_click=lambda: (result.update(went_back=True), done.set())).props("outline")submit = ui.button("Submit")cont = ui.button("Continue", on_click=lambda: done.set())cont.set_visibility(False)6 unmodified lines# unanswered one through. This one silently did nothing when# Submit was pressed with a blank, which reads as a broken# button rather than as a requirement.if radio.value is None and not await _confirm_skip():returnchosen["v"] = radio.valueradio.disable(); submit.disable(); cont.set_visibility(True)submit.on_click(go)4 unmodified lines# already-submitted answer isn't discarded if this record happens# to be the last one written for this stage (same reasoning as the# slider-battery stages above).return dict(measure="belief_check", block=block, went_back=True,**{_belief_key(block): chosen["v"]})return dict(measure="belief_check", block=block,**{_belief_key(block): chosen["v"]})return _fb(BLOCK_SUFFIX[block] + "PostTask_Belief", _display)# ----------------------------------------------------------------------------52 unmodified linesreturn _fb("PostTask_Hypothetical", _display)def strategy_stage(block="day"):"""Free-text: what strategy did the participant use?"""async def _display(stage, container):nicewebrl.clear_element(container)2 unmodified linesth = TH.current_theme()with container.style("align-items:center; max-width:640px;"):ui.markdown("## Your strategy")ui.markdown(f"What strategy (or strategies) did you use during "f"{_block_frame(block)}?")text = ui.textarea().props("outlined autogrow").style("width:100%;")async def on_continue():10 unmodified lines_go_back_one_stage()# text.value is live-bound (no separate "commit" step like a submit# button), so whatever was already typed is safe to include here too.return dict(measure="strategy", block=block, went_back=True,strategy_text=(text.value or "").strip())return dict(measure="strategy", block=block,strategy_text=(text.value or "").strip())return _fb(BLOCK_SUFFIX[block] + "PostTask_Strategy", _display)# ----------------------------------------------------------------------------
177 unmodified lines178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217232 unmodified lines45045145245345445545645745845946046146246346446546646746846964 unmodified lines534535536177 unmodified linesassert 'if (t.nightWatch) {\n tip = "";' in js[j:j + 600]def test_the_post_task_items_cover_the_last_field(storage, monkeypatch):"""They did not. _choice_items built items for the day task and the twonight blocks only, so a SONA participant was asked how motivated they wereto raid a sleeping partner they never met, and asked nothing at all aboutthe block the study is about."""storage.update({"pid": "P1", "random_id": "P2-11111","random_id_night": "P2-33333", "night_watch": True})keys = [k for k, _ in Q._choice_items("motiv", lambda w: f"...{w}?")]assert any(k.endswith("_field_rest") for k in keys)assert any(k.endswith("_field_work") for k in keys)assert any(k.endswith("_field_vague") for k in keys)def test_the_last_field_items_name_its_own_partner(storage):"""The blocks are about different people. Attaching the rating to the daypartner would ask about something the participant never did to them."""storage.update({"pid": "P1", "random_id": "P2-11111","random_id_night": "P2-33333", "night_watch": True})text = " ".join(t for _, t in Q._choice_items("motiv", lambda w: w))field = [t for k, t in Q._choice_items("motiv", lambda w: w)if "_field_" in k or "bagful" in t or "BRING IN" in t]joined = " ".join(field)assert "P2-33333" in joinedassert "P2-11111" not in joineddef test_no_last_field_items_when_the_block_is_off(storage):"""An ordinary session must not be asked about a partner it never met,which is the bug being fixed, in the other direction."""storage.update({"pid": "P1", "random_id": "P2-11111"})keys = [k for k, _ in Q._choice_items("motiv", lambda w: w)]assert not any("_field_" in k for k in keys)def test_the_draw_percentage_describes_the_real_design(storage):"""It was computed from the block length actually being played, so a devlink with trials=6 drew all six and the slide read "about 100% of the232 unmodified linesreturn re.sub(r'"\s*\n\s*f?"', "", body)def test_the_belief_check_asks_about_the_night_partner_too():"""The one item asked whether the other person would RECEIVE the money youearned for them. That describes the opposite of the night harvest, wherecredits are taken from them, and with two partners it no longer saidwhich one. The prereg rests an exclusion criterion on this item."""body = _belief_source()assert "random_id_night" in bodyassert "really lose the credits shown on screen" in bodyassert "believed_night_partner_lost" in body# and it is only asked when the block ranassert "E.night_watch_on()" in bodyassert "if night:" in bodydef test_the_belief_items_are_requested_not_forced():"""The consent says participants are free to refrain from answering anyquestion. This page silently did nothing when Submit was pressed with a64 unmodified linessrc = f.read()i = src.index("if pause_at and i == pause_at:")assert "_mount_canvas(container, partner_id=random_id," in src[i:i + 420]177 unmodified lines178179180181182183232 unmodified lines41641741841942042164 unmodified lines486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536177 unmodified linesassert 'if (t.nightWatch) {\n tip = "";' in js[j:j + 600]def test_the_draw_percentage_describes_the_real_design(storage):"""It was computed from the block length actually being played, so a devlink with trials=6 drew all six and the slide read "about 100% of the232 unmodified linesreturn re.sub(r'"\s*\n\s*f?"', "", body)def test_the_belief_items_are_requested_not_forced():"""The consent says participants are free to refrain from answering anyquestion. This page silently did nothing when Submit was pressed with a64 unmodified linessrc = f.read()i = src.index("if pause_at and i == pause_at:")assert "_mount_canvas(container, partner_id=random_id," in src[i:i + 420]def test_the_night_battery_asks_about_the_night_block_only(storage):"""One battery asked about both blocks at the end. Now each block is askedabout once it has been played, so the day battery must not mention thenight harvest and the night battery must not re-ask the day task."""storage.update({"pid": "P1", "random_id": "P2-11111","random_id_night": "P2-33333"})keys = [k for k, _ in Q._night_choice_items("motiv", lambda w: w)]assert keys == ["motiv_field_rest", "motiv_field_work", "motiv_field_vague"]day_keys = [k for k, _ in Q._choice_items("motiv", lambda w: w)]assert not any("_field_" in k for k in day_keys), \"the day battery runs before the night block exists"def test_the_night_battery_names_the_night_partner(storage):storage.update({"pid": "P1", "random_id": "P2-11111","random_id_night": "P2-33333", "night_watch": True})text = " ".join(t for _, t in Q._night_choice_items("motiv", lambda w: w))assert "P2-33333" in textassert "P2-11111" not in textdef test_each_battery_asks_its_own_belief_question():"""Both questions on one page meant asking about a block the participanthad not reached. They are different columns too, so one cannot silentlyoverwrite the other."""body = _belief_source()assert "During the daytime harvest" in bodyassert "During the Night Harvest" in bodyassert "lose the credits shown on screen" in bodyassert Q._belief_key("day") == "believed_partner_paid"assert Q._belief_key("night") == "believed_night_partner_lost"def test_the_night_battery_is_skipped_with_the_block():"""A day-only session must not be asked about a task it never saw, and itmust keep the stage names it was registered with."""import effort_stages as E, web_appassert E.NIGHT_QUESTION_STAGES == web_app.NIGHT_QUESTION_SKIPnames = [s.name for s in E.build_experiment().stages]for n in E.NIGHT_QUESTION_STAGES:assert n in names, n# the day battery keeps its original, registered namesfor n in ("NASA_TLX", "Effort_impact", "PostTask_Motivation","PostTask_Effort2", "PostTask_TaskRating", "PostTask_Belief","PostTask_Strategy", "Fatigue_post"):assert n in names, n
232 unmodified lines233234235236237238304 unmodified lines543544545546547548232 unmodified lines"firefly": "FireflyForTwo", "boxes": "BoxesForTwo"}# dev/debug: ?dev=1&start=<point> skips every stage BEFORE that point.DEV_SKIP = {# The warm-up itself. Everything else jumps past it, so there was no way to# look at the screen that sets the effort reference without playing the304 unmodified linesdev_skip = dev_skip | {E.UNCERTAINTY_STAGE}if not E.night_watch_on():dev_skip = dev_skip | {E.NIGHT_WATCH_STAGE, E.NIGHT_WATCH_PRACTICE_STAGE}# Combined SONA study only: demographics and the TriPM describe the person,# not the task, so they run once -- for whichever of the two tasks the# participant finishes SECOND. Without this they would answer 58 TriPM items232 unmodified lines233234235236237238239240241242243304 unmodified lines548549550551552553554232 unmodified lines"firefly": "FireflyForTwo", "boxes": "BoxesForTwo"}# dev/debug: ?dev=1&start=<point> skips every stage BEFORE that point.#: Mirrors effort_stages.NIGHT_QUESTION_STAGES. Spelled out rather than#: imported because DEV_SKIP is built at import time, before effort_stages is#: available here.NIGHT_QUESTION_SKIP = frozenset(['Fatigue_night', 'Night_NASA_TLX', 'Night_Effort_impact', 'Night_PostTask_Motivation', 'Night_PostTask_Effort2', 'Night_PostTask_TaskRating', 'Night_PostTask_Belief', 'Night_PostTask_Strategy'])DEV_SKIP = {# The warm-up itself. Everything else jumps past it, so there was no way to# look at the screen that sets the effort reference without playing the304 unmodified linesdev_skip = dev_skip | {E.UNCERTAINTY_STAGE}if not E.night_watch_on():dev_skip = dev_skip | {E.NIGHT_WATCH_STAGE, E.NIGHT_WATCH_PRACTICE_STAGE}dev_skip = dev_skip | set(E.NIGHT_QUESTION_STAGES)# Combined SONA study only: demographics and the TriPM describe the person,# not the task, so they run once -- for whichever of the two tasks the# participant finishes SECOND. Without this they would answer 58 TriPM items