小テスト)1ページに1問表示の問題を正解したら次へ(Part2)

小テスト)1ページに1問表示の問題を正解したら次へ(Part2)

- Hitomi Ikefuji の投稿
返信数: 2

表題と同じ質問(小テスト)1ページに1問表示の問題を正解したら次へ)が既存であって、私もそのような状況を作りたくって、チャレンジしたのですが、うまくいきませんでした。

環境の問題なのか、やり方の問題なのか、それ以外の問題なのか、わからずに、質問をさせて頂きました。

環境:

Moodle3.4.1

php7.1


やったこと。

・解答にあった「修正対象プログラム:mod/quiz/renderer.php」

を入れ替えました。

質問にあった修正はしていません。(テーマが変わると、変わってしまうように感じたので)


ちなみに、これが実行された場合、ほかの小テスト1ページ複数問表示のページも正解するまで、「次へ」が消えたりするのでしょうか?

それであれば、ちょっと困るので、それであれば、行わないのですが。

教えていただければ幸いです。

Hitomi Ikefuji への返信

Re: 小テスト)1ページに1問表示の問題を正解したら次へ(Part2)

- Mitsuhiro Yoshida の投稿
画像 Developers 画像 Particularly helpful Moodlers 画像 Translators

参考にされたページはMoodle 3.1.1用のプログラム修正のため、現在お使いのMoodle3.4.1に適用したとしても正常には動作しません。

> ちなみに、これが実行された場合、ほかの小テスト1ページ複数問表示のページも正解するまで、「次へ」が消えたりするのでしょうか?

はい、小テスト設定ページの「問題の挙動」セクションで「問題動作」が「アダプティブモード」または「アダプティブモード (ペナルティなし)」の場合のみ、1ページに表示された問題すべてに正解するまで「次へ」が消えます。

下記プログラム修正ではいかがでしょうか。

修正対象プログラム:
mod/quiz/renderer.php

修正箇所:
488行目

[ 修正前 ]
        // Print all the questions.
        foreach ($slots as $slot) {
            $output .= $attemptobj->render_question($slot, false, $this,
                    $attemptobj->attempt_url($slot, $page), $this);
        }

        $navmethod = $attemptobj->get_quiz()->navmethod;
        $output .= $this->attempt_navigation_buttons($page, $attemptobj->is_last_page($page), $navmethod);

[ 修正後 ]
        // Print all the questions.
        $displayoptions = $attemptobj->get_display_options(true);
        $incorrectcount = 0;

        foreach ($slots as $slot) {
            $output .= $attemptobj->render_question($slot, false, $this,
                    $attemptobj->attempt_url($slot, $page), $this);
            $current_correctness = $attemptobj->get_question_status($slot, $displayoptions->correctness);
            if ($current_correctness != get_string('correct', 'quiz')) {
                $incorrectcount += 1;
            }
        }

        $navmethod = $attemptobj->get_quiz()->navmethod;
//        $output .= $this->attempt_navigation_buttons($page, $attemptobj->is_last_page($page), $navmethod);

        $preferredbehaviour = $attemptobj->get_quiz()->preferredbehaviour;
        if ($preferredbehaviour == 'adaptive' || $preferredbehaviour == 'adaptivenopenalty') {
            if ($incorrectcount == 0) {
                $output .= $this->attempt_navigation_buttons($page, $attemptobj->is_last_page($page), $navmethod);
            }
        } else {
            $output .= $this->attempt_navigation_buttons($page, $attemptobj->is_last_page($page), $navmethod);
        }

評点平均: お役立ち度: ★★★★★★★ (1)
Mitsuhiro Yoshida への返信

Re: 小テスト)1ページに1問表示の問題を正解したら次へ(Part2)

- Hitomi Ikefuji の投稿

大変、参考になりました。

>「問題動作」が「アダプティブモード」または「アダプティブモード (ペナルティなし)」の場合のみ、1ページに表示された問題すべてに正解するまで「次へ」が消えます。

とのことだったので、私のとっても理想的だったので、変更を試みました。


ところが、ご指摘いただいたプログラムをそのまま入れると、エラーが出て、

「,」が余計だ

と言っているのは分かりました。


そこで、再度、書いていただいた修正対象プログラムの修正箇所を読んで、訂正させていただきました。

私が入れているMoodleでは、対象ヵ所が、

一部異なっていたので、その部分を消して修正してみました。


修正対象プログラム:

mod/quiz/renderer.php


修正対象プログラム:

mod/quiz/renderer.php


修正箇所:

行数不明(最初の文字で検索したため。スミマセン)


[ 修正前 ] (書いて下さったプログラムと違ったところを消しました)

      // Print all the questions.

        foreach ($slots as $slot) {

            $output .= $attemptobj->render_question($slot, false, $this,

                    $attemptobj->attempt_url($slot, $page), $this);

        }

 $navmethod = $attemptobj->get_quiz()->navmethod;

        $output .= $this->attempt_navigation_buttons($page, $attemptobj->is_last_page($page), $navmethod);




[ 修正後 ]

        // Print all the questions.

        $displayoptions = $attemptobj->get_display_options(true);

        $incorrectcount = 0;


        foreach ($slots as $slot) {

            $output .= $attemptobj->render_question($slot, false, $this,

                    $attemptobj->attempt_url($slot, $page), $this);

            $current_correctness =

$attemptobj->get_question_status($slot, $displayoptions->correctness);

            if ($current_correctness != get_string('correct',

'quiz')) {

                $incorrectcount += 1;

            }

        }


        $navmethod = $attemptobj->get_quiz()->navmethod;

//        $output .= $this->attempt_navigation_buttons($page, $attemptobj->is_last_page($page), $navmethod);


        $preferredbehaviour =

$attemptobj->get_quiz()->preferredbehaviour;

        if ($preferredbehaviour == 'adaptive' || $preferredbehaviour

== 'adaptivenopenalty') {

            if ($incorrectcount == 0) {

                $output .=

$this->attempt_navigation_buttons($page, $attemptobj->is_last_page($page),

$navmethod);

            }

        } else {

            $output .= $this->attempt_navigation_buttons($page,

$attemptobj->is_last_page($page), $navmethod);

        }


-------------


以上です。

おかげで、理想どおりになりました。

ただ、また、バージョンアップした場合、プログラムを変更しなくてはいけないと思うので、また、ご指導いただければと思います。

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