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

shuffleanswers aus Quiz-Einstellungen berücksichtigen #103

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

alexanderschmitz
Copy link
Contributor

@alexanderschmitz alexanderschmitz commented Mar 13, 2024

Ich hab das so ähnlich umgesetzt wie bei dem Multichoice Fragetypen. D.h. die shuffleanswers Flag wird in den Admin settings gesetzt und über die edit form in der Datenbank gespeichert.
Ich dachte, wenn ich mir schon Gedanken zu dem Thema mache, hat man später die Möglichkeit hier global diese Option zu setzen oder eventuell in der Options Form die Möglichkeit bieten.

Um das shuffleanswers aus dem Quiz Kontext zu laden, wird im renderer::formulation_and_controls() das Quiz abgefragt.

Closes #90

@alexanderschmitz alexanderschmitz force-pushed the feat/allowshuffle branch 2 times, most recently from b9b210a to 61e73df Compare March 18, 2024 13:55
@alexanderschmitz alexanderschmitz force-pushed the feat/allowshuffle branch 3 times, most recently from 59b0e5e to 7f1e1eb Compare March 25, 2024 07:35
- possibility to set allowshuffle in the admin settings
- overwrite allowshuffle with the quiz setting
@@ -92,6 +94,7 @@ public function start_attempt(question_attempt_step $step, $variant): void {
$this->scoringstate = null;

$this->ui = new question_ui_renderer($attempt->ui->content, $attempt->ui->placeholders);
$this->ui->shuffleanswers = $this->shuffleanswers;
Copy link
Contributor

Choose a reason for hiding this comment

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

Bitte im Konstruktor übergeben.


// Check if we are in a quiz context.
if ($this->page->context->contextlevel == CONTEXT_MODULE && $this->page->cm->modname == 'quiz') {
$quiz = $DB->get_record('quiz', ['id' => $this->page->cm->instance]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Die Information steckt doch bereits in $question->shuffleanswers!?

Copy link
Contributor Author

@alexanderschmitz alexanderschmitz Mar 25, 2024

Choose a reason for hiding this comment

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

Wird das $question->shuffleanswers denn automatisch überschrieben, wenn man in den Quiz Settings > Question Behaviour > Shuffle within questions ändert?

Copy link
Contributor

Choose a reason for hiding this comment

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

Wenn ich mir https://github.com/moodle/moodle/blob/main/question/engine/bank.php#L278 ansehe, dann scheint das ja gemacht zu werden. Da der Wert aber nur im Falle von "kein shuffle" gesetzt/überschrieben wird, müsstest du vermutlich vorher mittels isset prüfen, ob das Attribut überhaupt existiert.

// Whether the content of a qpy:shuffle-contents can be randomly shuffled.
$mform->addElement('hidden', 'shuffleanswers', get_config('qtype_questionpy', 'shuffleanswers'));
$mform->setType('shuffleanswers', PARAM_BOOL);

Copy link
Contributor

Choose a reason for hiding this comment

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

Bitte keine neuen Einstellungen einführen. Ob so eine Einstellung für das jeweilige Paket sinnvoll ist, müssen die Pakete selber wissen und in ihren Options definieren.

*/
protected function initialise_question_instance(question_definition $question, $questiondata) {
parent::initialise_question_instance($question, $questiondata);
$question->shuffleanswers = $questiondata->shuffleanswers;
Copy link
Contributor

Choose a reason for hiding this comment

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

Greifst du hier auf das richtige Attribut zu? Moodle schreibt ja in $questiondata->options->shuffleanswers.

@MHajoha
Copy link
Member

MHajoha commented Mar 28, 2024

Also das Moodle-Feature riecht für mich ganz stark nach einem schlecht durchdachten Nebengedanken. $allowshuffle wird nur auf false gesetzt, wenn die Frage geladen wird, um einen Attempt zu starten. Danach (wenn die Frage geladen wird, um einen attempt anzuzeigen, zu scoren, etc.) wird es gar nicht gesetzt, und ist deshalb per default true. Ich würde daher vorschlagen, den Wert aus initialise_question_instance bis in die question zu schleifen, dort aber in start_attempt eine qtvar zu setzen und danach in apply_attempt_state die qtvar zu laden und den gesetzten Wert nicht zu verwenden. Das funktioniert.

Datenbankzugriff oder Schema-Änderungen sind dann gar nicht notwendig, auch keine Änderungen an der options form.

@MHajoha
Copy link
Member

MHajoha commented Mar 28, 2024

Was die Nützlichkeit einer Plugin-weiten Einstellung betrifft bin ich noch etwas skeptisch. Hast du mal geschaut, wie sich das mit der Standard-Quiz-Einstellung (Quiz → General settings → Shuffle within questions) vergleicht?
grafik

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.

shuffleanswers aus Quiz-Einstellungen berücksichtigen
3 participants