2.6.1 "re-attempt quiz" button appearing, after student earned passing score

2.6.1 "re-attempt quiz" button appearing, after student earned passing score

ໂດຍ Wendi Daniels -
ຈຳນວນການຕອບກັບ: 3

So we have been trying to fix this and I am wondering if this is the problem:

In mod/quiz/view there is some script as follows:

// Determine wheter a start attempt button should be displayed.
$viewobj->quizhasquestions = (bool) quiz_clean_layout($quiz->questions, true);
$viewobj->preventmessages = array();
if (!$viewobj->quizhasquestions) {
    $viewobj->buttontext = '';

} else {
    if ($unfinished) {
        if ($canattempt) {
            $viewobj->buttontext = get_string('continueattemptquiz', 'quiz');
        } else if ($canpreview) {
            $viewobj->buttontext = get_string('continuepreview', 'quiz');
        }

    } else {
        if ($canattempt) {
            $viewobj->preventmessages = $viewobj->accessmanager->prevent_new_attempt(
                    $viewobj->numattempts, $viewobj->lastfinishedattempt);
            if ($viewobj->preventmessages) {
                $viewobj->buttontext = '';
            } else if ($viewobj->numattempts == 0) {
                $viewobj->buttontext = get_string('attemptquiznow', 'quiz');
            } else {
                $viewobj->buttontext = get_string('reattemptquiz', 'quiz');
            }

        } else if ($canpreview) {
            $viewobj->buttontext = get_string('previewquiznow', 'quiz');
        }
    }

I am thinking the solution is in the blue text. "attemptquiznow" is present if there are no previous attempts (numattempts==0). If I knew that I wanted everyone to have 2 attempts only, and I wanted that button to show up ONLY if they had not passed, how would I code for that?

ການຈັດອັນດັບສະເລ່ຍ: -
ໃນການຕອບກັບຫາ Wendi Daniels

Re: 2.6.1 "re-attempt quiz" button appearing, after student earned passing score

ໂດຍ Tim Hunt -
ຮູບພາບຂອງ Core developers ຮູບພາບຂອງ Documentation writers ຮູບພາບຂອງ Particularly helpful Moodlers ຮູບພາບຂອງ Peer reviewers ຮູບພາບຂອງ Plugin developers

Yes, that blue bit looks like the right bit to change.

At the moment, it is setting the message to "Attempt quiz" if this is the students first attempt, or "Re-attempt quiz" if they have already made one attempt.

Note that there is a quiz setting for the maximum number of attempts allowed, which you can set to 2. Enforcing that rule is done by the if ($viewobj->preventmessages) test.

What you want is,

if ($viewobj->preventmessages) {
    $viewobj->buttontext = '';
} else if ($viewobj->numattempts == 0) {
    $viewobj->buttontext = get_string('attemptquiznow', 'quiz');
} else if ($viewobj->mygrade / $quiz->grade >= 0.70) {
// Student has already got a good enough grade. Don't show them the reattempt button.
$viewobj->buttontext = '';
} else {
    $viewobj->buttontext = get_string('reattemptquiz', 'quiz');
}

That is, three lines added in the middle.

(By the way, I hope that:

1. You are trying out and developing these changes on a test Moodle site, not your real Moodle site, and only transferring the changes when you are don.

2. I hope you are making a not of what you have changed, so when the time comes to upgrade Moodle you can.)

ການຈັດອັນດັບສະເລ່ຍ: -
ໃນການຕອບກັບຫາ Tim Hunt

Re: 2.6.1 "re-attempt quiz" button appearing, after student earned passing score

ໂດຍ Wendi Daniels -

Thank you, Tim. Would it be a good idea to pass that on to the Moodle developers for the next version of Moodle?

ການຈັດອັນດັບສະເລ່ຍ: -
ໃນການຕອບກັບຫາ Wendi Daniels

Re: 2.6.1 "re-attempt quiz" button appearing, after student earned passing score

ໂດຍ Tim Hunt -
ຮູບພາບຂອງ Core developers ຮູບພາບຂອງ Documentation writers ຮູບພາບຂອງ Particularly helpful Moodlers ຮູບພາບຂອງ Peer reviewers ຮູບພາບຂອງ Plugin developers

Did that need a ກະພິບຕາ smiley? I am the (most relevant) Moodle developer for the quiz.

However, while the proposed code-change is OK as a quick hack to meet your needs, the hard-coded 0.7 means that it is not suitable for inclusion in standard Moodle.

ການຈັດອັນດັບສະເລ່ຍ: -