Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove first_round methods from rules files #1224

Merged
merged 16 commits into from
Aug 26, 2024

Conversation

BeritJanssen
Copy link
Collaborator

@BeritJanssen BeritJanssen commented Aug 9, 2024

Working towards #973. I tested all block rules which don't inherit their next_round method from other rules classes, and fixed the issues I could find. What this branch also does is add a default_consent_file member to all rules classes, in prepration of #1211.

Copy link
Contributor

@drikusroor drikusroor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -27,7 +26,7 @@ class HBat(Base):
ID = 'H_BAT'
start_diff = 20

def next_round(self, session):
def next_round(self, session: Session):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the other rules (above here in the PR), I see you do a check for rounds passed to equal zero and then to return intro_explainer. Why not here? :-)

Copy link
Collaborator Author

@BeritJanssen BeritJanssen Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have some recurring practice views here, which is tracked by final_score. Another round of practice will still be preceded by the intro_explainer, even if we already have results for this session.

Comment on lines 48 to 50
questions = self.get_questionnaire(session)
if questions:
return questions
return [self.intro_explainer(), *questions]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to look this up because it looks kind of counter intuitive: If there are no questions in the questionnaire, return the final action / debriefing? Would it be an idea to rename this or the base method sometime in the future?

Either something like:

# backend/experiment/rules/rhythm_battery_final.py
open_questions = self.get_questionnaire(session)
        if open_questions:
            return [self.intro_explainer(), *open_questions]

or

# backend/experiment/rules/rhythm_battery_final.py
questions = self.get_questionnaire(session, unanswered=True)

# or
questions = self.get_unanswered_questionnaire(session)

Or at least update the method's docstring to make explicit that it returns open questions from a questionnaire and not all questions:

# backend/experiment/rules/base.py
def get_questionnaire(self, session, randomize=False, cutoff_index=None):
    ''' Get a list of open questions to be asked in succession for a given session'''

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines 22 to 35
explainer = Explainer(
instruction=_(
'General listening instructions:'),
steps=[
Step(_(
"To make sure that you can do the experiment as well as possible, please do it a quiet room with a stable internet connection."),
),
Step(_("Please use headphones, and turn off sound notifications from other devices and applications (e.g., e-mail, phone messages)."),
)],
step_numbers=True,
button_label=_('Ok')
)
actions.append(self.intro_explainer())
actions.append(explainer)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can also combine this explainer into the intro_explainer method, or not?

Copy link
Collaborator Author

@BeritJanssen BeritJanssen Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All other methods just return the one explainer object. I'm wondering whether it would be good to add and document / type this method to base.py, but then we would always have an Explainer in place unless we override.

first_round() and next_round() are required methods for the class.
next_round() is a required method for this class.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment even necessary? :D

Comment on lines -83 to -157

try {
const newSession = await createSession({ block, participant, playlist })
setSession(newSession);
return newSession;
}
catch (err) {
setError(`Could not create a session: ${err}`, err)
return;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you delete this, you might as well remove the (now unused) import and the createSession function from frontend/src/API.ts

Comment on lines -242 to +241
rules=Hooked.ID,
rules=RhythmBatteryIntro.ID,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooked expects a playlist to be present, RhythmBatteryIntro doesn't.

@@ -30,7 +30,7 @@ def get_practice_views(
previous_results = session.result_set.order_by('-created_at')
if not results_count:
# first practice trial
return trial_callback(session, trial_condition, difficulty)
return [intro_explainer, practice_explainer(), trial_callback(session, trial_condition, difficulty)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to look this up since it confused me a bit to find a variable named intro_explainer together with a function named practice_explainer. Can we perhaps rename practice_explainer to get_practice_explainer? While we're at it, perhaps it would be a good idea to rename all intro_explainer methods in the rules files to get_intro_explainer in the future?

@BeritJanssen BeritJanssen self-assigned this Aug 26, 2024
@BeritJanssen BeritJanssen merged commit b18afdc into develop Aug 26, 2024
15 checks passed
@BeritJanssen BeritJanssen deleted the feature/first_round_begone branch August 26, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants