Skip to content

Non-counting questions#2450

Open
jooooosef wants to merge 20 commits into
e-valuation:mainfrom
jooooosef:iss2391
Open

Non-counting questions#2450
jooooosef wants to merge 20 commits into
e-valuation:mainfrom
jooooosef:iss2391

Conversation

@jooooosef

@jooooosef jooooosef commented May 26, 2025

Copy link
Copy Markdown
Collaborator

closes #2391
fixes #2539

TODO:

  • add tests

@jooooosef jooooosef marked this pull request as draft May 26, 2025 19:35
Comment thread evap/staff/templates/staff_questionnaire_form.html Outdated
Comment thread evap/student/templates/student_vote_questionnaire_group.html Outdated
@jooooosef jooooosef marked this pull request as ready for review June 17, 2025 09:11
@jooooosef jooooosef requested a review from richardebeling June 23, 2025 18:40

@richardebeling richardebeling left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looking pretty good, thanks :)

Comment thread evap/staff/templates/staff_questionnaire_form.html Outdated
Comment thread evap/evaluation/tests/test_models.py Outdated
Comment thread evap/evaluation/migrations/0149_question_counts_for_grade.py Outdated
Comment thread evap/evaluation/models.py Outdated
Comment thread evap/staff/forms.py
Comment thread evap/staff/templates/staff_questionnaire_form.html
Comment thread evap/student/templates/student_vote_questionnaire_group.html

@niklasmohrin niklasmohrin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

okay some more concerns; this is not an easy issue :^)

Comment thread evap/student/forms.py Outdated
Comment thread evap/student/templates/student_vote_questionnaire_group.html
Comment thread evap/staff/forms.py Outdated
Comment thread evap/evaluation/models.py Outdated
Comment thread evap/evaluation/tests/test_models.py Outdated
Comment thread evap/staff/templates/staff_questionnaire_form.html Outdated
Comment thread evap/results/tools.py
Comment thread evap/results/tools.py
@richardebeling richardebeling removed their request for review August 4, 2025 15:27
@jooooosef jooooosef force-pushed the iss2391 branch 2 times, most recently from 3eb3935 to 3f26948 Compare August 11, 2025 20:38
@janno42 janno42 force-pushed the main branch 2 times, most recently from 73e348c to 3577b6a Compare August 12, 2025 11:21
Comment thread evap/evaluation/migrations/0155_question_counts_for_grade.py Outdated
Comment thread evap/results/tests/test_tools.py Outdated
Comment thread evap/evaluation/tests/test_models.py Outdated
Comment thread evap/staff/forms.py Outdated
Comment thread evap/results/tools.py Outdated
Comment thread evap/staff/templates/staff_questionnaire_form.html Outdated
Comment thread evap/staff/templates/staff_questionnaire_form.html Outdated
Comment thread evap/staff/templates/staff_questionnaire_form.html Outdated
Comment thread evap/staff/templates/staff_questionnaire_form.html Outdated
Comment thread evap/staff/templates/staff_questionnaire_form.html Outdated
Comment thread evap/staff/forms.py Outdated
Comment thread evap/results/tests/test_tools.py Outdated
Comment thread evap/results/tools.py Outdated
Comment thread evap/staff/tests/test_forms.py Outdated
Comment thread evap/static/ts/src/staff-questionnaire-form.ts Outdated
Comment thread evap/static/ts/src/staff-questionnaire-form.ts Outdated
Comment thread evap/static/ts/src/staff-questionnaire-form.ts Outdated
Comment thread evap/static/ts/src/staff-questionnaire-form.ts Outdated
Comment thread evap/static/ts/src/staff-questionnaire-form.ts Outdated
Comment thread evap/static/ts/src/staff-questionnaire-form.ts Outdated
Comment thread evap/staff/templates/staff_questionnaire_form.html Outdated
@jooooosef jooooosef force-pushed the iss2391 branch 2 times, most recently from 77f11b9 to d360f52 Compare November 24, 2025 22:33
@jooooosef jooooosef requested a review from janno42 December 1, 2025 16:40

@niklasmohrin niklasmohrin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

great stuff, some clean up work but I think we are close to done :)

Comment thread evap/staff/tests/test_forms.py
Comment thread evap/staff/tests/test_live.py Outdated
Comment thread evap/staff/tests/test_live.py Outdated
Comment thread evap/staff/tests/test_live.py
Comment thread evap/staff/tests/test_views.py
Comment thread evap/static/ts/src/staff-questionnaire-form.ts Outdated
Comment thread evap/static/ts/src/staff-questionnaire-form.ts Outdated
Comment thread evap/static/ts/src/staff-questionnaire-form.ts Outdated
Comment thread evap/static/ts/src/staff-questionnaire-form.ts
Comment thread evap/static/ts/src/staff-questionnaire-form.ts Outdated
@richardebeling richardebeling removed their request for review May 25, 2026 12:17
@janno42 janno42 removed their request for review June 1, 2026 15:38

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The changes in this file seem to be 100% about "allows additional text answers", not about "counts_for_grade". Is this intended, or just a rebase f-up?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it is now only about the allows additional text answers, since we moved counts_for_grade into the QuestionAssignment (I think I originally wrote this). The first part (with test_locked_contributor_questionnaire) seems to be from the rebase.
But the part with the update_fields from the second test is new, I cant find anything testing that. So I think I would like to keep this part, I have removed the rest.

@niklasmohrin niklasmohrin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very cool! I am pretty happy with the state of this and with what I was reading, good job. I have a handful of mostly nits, except for the typescript code which I think can use another touch.

I believe that our current plan is to make another release soon with the fixes for the recently discovered bugs, and I think it makes sense to hold this PR back until then, but after that I don't see anything in the way of merging.

Comment on lines +254 to +261
self.assertEqual(
additional_textanswers,
row.find_element(By.CSS_SELECTOR, "input[id$='-allows_additional_textanswers']").is_enabled(),
)
self.assertEqual(
counts_for_grade,
row.find_element(By.CSS_SELECTOR, "input[id$='-counts_for_grade']").is_enabled(),
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: we usually put the expected value second

Suggested change
self.assertEqual(
additional_textanswers,
row.find_element(By.CSS_SELECTOR, "input[id$='-allows_additional_textanswers']").is_enabled(),
)
self.assertEqual(
counts_for_grade,
row.find_element(By.CSS_SELECTOR, "input[id$='-counts_for_grade']").is_enabled(),
)
self.assertEqual(
row.find_element(By.CSS_SELECTOR, "input[id$='-allows_additional_textanswers']").is_enabled(),
additional_textanswers,
)
self.assertEqual(
row.find_element(By.CSS_SELECTOR, "input[id$='-counts_for_grade']").is_enabled(),
counts_for_grade,
)

Comment on lines +285 to +287
new_row = self.selenium.find_elements(By.CSS_SELECTOR, "#question_table tbody tr")[
-2
] # the last row is the add row button

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
new_row = self.selenium.find_elements(By.CSS_SELECTOR, "#question_table tbody tr")[
-2
] # the last row is the add row button
new_row = self.selenium.find_elements(By.CSS_SELECTOR, "#question_table tbody tr")[1]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice

Comment on lines +99 to +101

const staffQuestionnaireForm = new StaffQuestionnaireForm(document.getElementById("question_table"));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

there is trailing whitespace on the empty lines here

this.questionTable.addEventListener("change", this.handleQuestionTypeChange);
this.questionnaireTypeSelect.addEventListener("change", this.handleQuestionnaireTypeChange);

this.initialize();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would either inline this method, or not call it here and instead let the caller run this. We have this semi pattern, for example in the contact modal, that constructor just queries the DOM and a second method, in this case attach, must be called to activate the component. This would also include the addEventListener` above.

I don't have a strong opinion, we can do everything in the constructor (without the extra method), or we move the event listeners to initialize and rename this accordingly and let the caller call this second function too.

Comment thread evap/results/tools.py
assert not any(
isinstance(result, RatingResult) and result.counts_for_grade
for result in questionnaire_result.question_results
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this ever fails, we will be happy to have added a message like

Suggested change
)
), f"Dropout questionnaire {questionnaire_result.questionnaire.id} has results that count"

Comment thread evap/results/tools.py
for questionnaire_result in contribution_result.questionnaire_results:
if not questionnaire_result.questionnaire.is_dropout: # dropout questionnaires are not counted
grouped_results[contribution_result.contributor].extend(questionnaire_result.question_results)
if questionnaire_result.questionnaire.is_dropout: # dropout questionnaires are not counted

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if questionnaire_result.questionnaire.is_dropout: # dropout questionnaires are not counted
if questionnaire_result.questionnaire.is_dropout:

Comment thread evap/results/tools.py
]
),
# The weight of this contributors grade is supposed to represent the number of students the
# contributor interacted with, which we derive from the max answer count, independently of counts_for_grades.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
# contributor interacted with, which we derive from the max answer count, independently of counts_for_grades.
# contributor interacted with, which we derive from the max answer count, independently of counts_for_grade.

Comment on lines -459 to -460
calculated_grade = distribution_to_grade(calculate_average_distribution(self.evaluation))
self.assertAlmostEqual(calculated_grade, 1.5)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add the removed lines here back to the existing test?

Comment on lines +55 to +58
if (questionnaireType === QUESTIONNAIRE_TYPE_DROPOUT) {
checkboxes.forEach(checkbox => {
if (checkbox.classList.contains("counts-for-grade-checkbox")) {
this.disableAndUncheck(checkbox);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(out of scope for this PR)

@janno42 It would probably be a nice feature to add a tooltip to the disabled checkboxes that display the reason for why the checkbox is disabled ("Questions of a dropout questionnaire cannot count towards the evaluation's grade" or so)). I think this is slightly more complicated than "very small" or maybe even "small" because this typescript logic here has to interact with bootstrap tooltips and changing labels, and the knowledge of when things are disabled leaks out of this file, but it should be doable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Non-counting questions Cannot change question type and allows_additional_textanswers of text/heading questions simultaneously

5 participants