Non-counting questions#2450
Conversation
richardebeling
left a comment
There was a problem hiding this comment.
Looking pretty good, thanks :)
7386f67 to
6b24166
Compare
niklasmohrin
left a comment
There was a problem hiding this comment.
okay some more concerns; this is not an easy issue :^)
3eb3935 to
3f26948
Compare
73e348c to
3577b6a
Compare
77f11b9 to
d360f52
Compare
niklasmohrin
left a comment
There was a problem hiding this comment.
great stuff, some clean up work but I think we are close to done :)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
matches the behaviour from the allows_additional_text_answer in QuestionForm
niklasmohrin
left a comment
There was a problem hiding this comment.
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.
| 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(), | ||
| ) |
There was a problem hiding this comment.
nit: we usually put the expected value second
| 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, | |
| ) |
| new_row = self.selenium.find_elements(By.CSS_SELECTOR, "#question_table tbody tr")[ | ||
| -2 | ||
| ] # the last row is the add row button |
There was a problem hiding this comment.
| 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] |
|
|
||
| const staffQuestionnaireForm = new StaffQuestionnaireForm(document.getElementById("question_table")); | ||
|
|
There was a problem hiding this comment.
there is trailing whitespace on the empty lines here
| this.questionTable.addEventListener("change", this.handleQuestionTypeChange); | ||
| this.questionnaireTypeSelect.addEventListener("change", this.handleQuestionnaireTypeChange); | ||
|
|
||
| this.initialize(); |
There was a problem hiding this comment.
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.
| assert not any( | ||
| isinstance(result, RatingResult) and result.counts_for_grade | ||
| for result in questionnaire_result.question_results | ||
| ) |
There was a problem hiding this comment.
If this ever fails, we will be happy to have added a message like
| ) | |
| ), f"Dropout questionnaire {questionnaire_result.questionnaire.id} has results that count" |
| 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 |
There was a problem hiding this comment.
| if questionnaire_result.questionnaire.is_dropout: # dropout questionnaires are not counted | |
| if questionnaire_result.questionnaire.is_dropout: |
| ] | ||
| ), | ||
| # 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. |
There was a problem hiding this comment.
| # 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. |
| calculated_grade = distribution_to_grade(calculate_average_distribution(self.evaluation)) | ||
| self.assertAlmostEqual(calculated_grade, 1.5) |
There was a problem hiding this comment.
Can you add the removed lines here back to the existing test?
| if (questionnaireType === QUESTIONNAIRE_TYPE_DROPOUT) { | ||
| checkboxes.forEach(checkbox => { | ||
| if (checkbox.classList.contains("counts-for-grade-checkbox")) { | ||
| this.disableAndUncheck(checkbox); |
There was a problem hiding this comment.
(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.
closes #2391
fixes #2539
TODO: