diff --git a/backend/experiment/rules/toontjehoger_3_plink.py b/backend/experiment/rules/toontjehoger_3_plink.py index 1357f234b..823ad806c 100644 --- a/backend/experiment/rules/toontjehoger_3_plink.py +++ b/backend/experiment/rules/toontjehoger_3_plink.py @@ -171,21 +171,22 @@ def get_plink_round(self, session, present_score=False): ), config={'break_round_on': {'NOT': ['']}} )) + json_data = session.load_json_data() + if not json_data.get('extra_questions_intro_shown'): + # Extra questions intro: only show first time + # -------------------- + extra_questions_intro = Explainer( + instruction="Tussenronde", + steps=[ + Step("Jammer dat je de artiest en titel van dit nummer niet weet!"), + Step( + "Verdien extra punten door twee extra vragen over het nummer te beantwoorden."), + ], + button_label="Start" + ) + next_round.append(extra_questions_intro) - - # Extra questions intro - # -------------------- - extra_questions_intro = Explainer( - instruction="Tussenronde", - steps=[ - Step("Jammer dat je de artiest en titel van dit nummer niet weet!"), - Step( - "Verdien extra punten door twee extra vragen over het nummer te beantwoorden."), - ], - button_label="Start" - ) extra_rounds = [ - extra_questions_intro, self.get_era_question(session, section), self.get_emotion_question(session, section) ] @@ -213,8 +214,7 @@ def get_era_question(self, session, section): session, section=section, expected_response=section.group.split(';')[0] - ), - submits=False + ) ) return Trial(feedback_form=Form([question])) @@ -236,8 +236,7 @@ def get_emotion_question(self, session, section): session, section=section, expected_response=section.group.split(';')[1] - ), - submits=True + ) ) return Trial(feedback_form=Form([question])) @@ -249,6 +248,8 @@ def calculate_score(self, result, data): if result.question_key == 'plink': return self.SCORE_MAIN_CORRECT if result.expected_response == result.given_response else self.SCORE_MAIN_WRONG elif result.question_key == 'era': + result.session.save_json_data({'extra_questions_intro_shown': True}) + result.session.save() return self.SCORE_EXTRA_1_CORRECT if result.given_response == result.expected_response else self.SCORE_EXTRA_WRONG else: return self.SCORE_EXTRA_2_CORRECT if result.given_response == result.expected_response else self.SCORE_EXTRA_WRONG diff --git a/backend/result/utils.py b/backend/result/utils.py index 5ed579483..f95760c6a 100644 --- a/backend/result/utils.py +++ b/backend/result/utils.py @@ -88,6 +88,8 @@ def score_result(data, session): # Can be overridden by defining calculate_score in the rules file if result.session: score = session.experiment_rules().calculate_score(result, data) + # refresh session data in case anything was changed within calculate_score function + session.refresh_from_db() else: # this is a profile type result, i.e., it doesn't have a session: score = apply_scoring_rule(result, data)