Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions mod/feedback/item/multichoice/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,16 @@ public function complete_form_element($item, $form) {
$separator = !empty($info->horizontal) ? ' ' : \html_writer::div('', 'w-100');
$tmpvalue = $form->get_item_value($item) ?? 0; // Used for element defaults, so must be a valid value (not null).

// @brainite
foreach ($options as $k => $v) {
if ($v[0] === '*') {
$options[$k] = substr($v, 1);
if ($tmpvalue === 0) {
$tmpvalue = $k;
}
}
}

// Subtypes:
// r = radio
// c = checkbox
Expand Down
3 changes: 3 additions & 0 deletions mod/feedback/item/multichoice/multichoice_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public function definition() {

$mform->addElement('static', 'hint', '', get_string('use_one_line_for_each_value', 'feedback'));

// @brainite
$mform->addElement('static', 'hint', '', 'Mark default choice with * at the start of the line.');

parent::definition();
$this->set_data($item);

Expand Down
3 changes: 2 additions & 1 deletion mod/quiz/classes/access_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,8 @@ public function make_review_link(stdClass $attempt, $nolongerused, renderer $out
$reviewoptions = display_options::make_from_quiz(
$this->quizobj->get_quiz(), $when);

if (!$reviewoptions->attempt) {
// @brainite
if (!$reviewoptions->attempt || !$nolongerused->attempt) {
return $output->no_review_message($this->quizobj->cannot_review_message($when, true, $attempt->timefinish));

} else {
Expand Down
3 changes: 2 additions & 1 deletion mod/quiz/classes/quiz_attempt.php
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,8 @@ public function get_display_options($reviewing) {
if (is_null($this->reviewoptions)) {
$this->reviewoptions = quiz_get_review_options($this->get_quiz(),
$this->attempt, $this->quizobj->get_context());
if ($this->is_own_preview()) {
// @brainite
if ($this->is_own_preview() && !($this->reviewoptions->never_preview ?? FALSE)) {
// It should always be possible for a teacher to review their
// own preview irrespective of the review options settings.
$this->reviewoptions->attempt = true;
Expand Down
6 changes: 6 additions & 0 deletions mod/quiz/classes/quiz_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,12 @@ public function summary_url($attemptid) {
* @return string an appropraite message.
*/
public function cannot_review_message($when, $short = false, ?int $attemptsubmittime = null) {
// @brainite
if ($short) {
return 'Review is currently unavailable.';
}
return 'You cannot currently review this quiz. Complete the requirements and/or come back later.';


if ($attemptsubmittime === null) {
debugging('It is recommended that you pass $attemptsubmittime to cannot_review_message', DEBUG_DEVELOPER);
Expand Down
12 changes: 7 additions & 5 deletions mod/quiz/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1060,9 +1060,10 @@ function quiz_process_options($quiz) {
if (empty($quiz->completionusegrade)) {
$quiz->completionpassgrade = 0;
}
if (empty($quiz->completionpassgrade)) {
$quiz->completionattemptsexhausted = 0;
}
// @brainite
// if (empty($quiz->completionpassgrade)) {
// $quiz->completionattemptsexhausted = 0;
// }
if (empty($quiz->completionminattemptsenabled)) {
$quiz->completionminattempts = 0;
}
Expand Down Expand Up @@ -2054,8 +2055,9 @@ function quiz_get_coursemodule_info($coursemodule) {
if ($coursemodule->completion == COMPLETION_TRACKING_AUTOMATIC) {
if ($quiz->completionattemptsexhausted) {
$result->customdata['customcompletionrules']['completionpassorattemptsexhausted'] = [
'completionpassgrade' => $coursemodule->completionpassgrade,
'completionattemptsexhausted' => $quiz->completionattemptsexhausted,
// @brainite
'completionpassgrade' => 1, // $coursemodule->completionpassgrade,
'completionattemptsexhausted' => 1, // $quiz->completionattemptsexhausted,
];
} else {
$result->customdata['customcompletionrules']['completionpassorattemptsexhausted'] = [];
Expand Down
23 changes: 22 additions & 1 deletion mod/quiz/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1228,8 +1228,29 @@ function quiz_get_review_options($quiz, $attempt, $context) {
$options->userinfoinhistory = $attempt->userid;

}
else {
// @brainite
//
// If they are not complete, then disallow the preview.
if (!$quiz->timeclose || time() < $quiz->timeclose) {
global $CFG;
require_once($CFG->libdir . '/modinfolib.php');
$cm = get_coursemodule_from_instance('quiz', $quiz->id);
$cm_info = \cm_info::create($cm);
if (isset($cm_info->customdata['customcompletionrules'])
&& isset($cm_info->customdata['customcompletionrules']['completionpassorattemptsexhausted'])
&& !empty($cm_info->customdata['customcompletionrules']['completionpassorattemptsexhausted'])) {
$completioninfo = new \completion_info($cm_info->get_course());
$customcompletion = new \mod_quiz\completion\custom_completion($cm_info, $attempt->userid, $completioninfo->get_core_completion_state($cm_info, $attempt->userid));
if ($customcompletion->get_state('completionpassorattemptsexhausted') === COMPLETION_INCOMPLETE) {
$options->attempt = question_display_options::HIDDEN;
$options->never_preview = TRUE;
}
}
}
}

return $options;
return $options;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions mod/quiz/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,9 @@ public function add_completiongrade_rules(): array {
['group' => 'cattempts', 'parentclass' => 'ms-4']
);
$completionpassgradeel = 'completionpassgrade' . $suffix;
$mform->hideIf($completionattemptsexhaustedel, $completionpassgradeel, 'notchecked');
$mform->hideIf($completionattemptsexhaustedel, $completionpassgradeel, 'notchecked');
// @brainite
// $mform->hideIf($completionattemptsexhaustedel, $completionpassgradeel, 'notchecked');
// $mform->hideIf($completionattemptsexhaustedel, $completionpassgradeel, 'notchecked');

return [$completionattemptsexhaustedel];
}
Expand Down