多肢選択問題での「n者択m」

Re: 多肢選択問題での「n者択m」

- T N の投稿
返信数: 0

Avoid partial gradingのみだと、不正解選択肢をいちいち負に設定しなければならず面倒だ、という指摘をユーザから受けたので、以下の様に

/moodle/question/type/multichoice/questiontype.php を編集してみました。すなわち、複数回答を許可した場合、0を負にし、和が1の場合のみ正解とする、ということです。これで、ユーザの要求をすべて満たすのかどうか、よくわかりませんが、「コードに対する変更点」を推測してみました。なお、行番号は、Moodle 2.0.2 に対応しています。

373     function grade_responses(&$question, &$state, $cmoptions) {
374         $state->raw_grade = 0;
375         if($question->options->single) {
376             $response = reset($state->responses);
377             if ($response) {
378                 $state->raw_grade = $question->options->answers[$response]->fraction;
379             }
380         } else {
381             foreach ($state->responses as $response) {
382                 if ($response) {
383 // Set to negative valuses
384                   if (((float) $question->options->answers[$response]->fraction) === 0.0) {
385                     (float) $question->options->answers[$response]->fraction = -0.0001;
386                   }
387                     $state->raw_grade += $question->options->answers[$response]->fraction;
388                 }
389             }
390         }
391 //  Avoid partial grading
392         if ($state->raw_grade != 1.0) { $state->raw_grade = 0; }

評点平均: お役立ち度: ★★★★★★★ (1)