Skip to content

Commit

Permalink
plink: only show extra question explainer once
Browse files Browse the repository at this point in the history
  • Loading branch information
BeritJanssen committed Nov 14, 2023
1 parent 20b099a commit ce825b1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
35 changes: 18 additions & 17 deletions backend/experiment/rules/toontjehoger_3_plink.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]
Expand Down Expand Up @@ -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]))
Expand All @@ -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]))
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions backend/result/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ce825b1

Please sign in to comment.