define('MOODLE_QUIZ_MACHT', 'match');
define('MOODLE_QUIZ_ESSAY', 'essay');
define('MOODLE_QUIZ_SHORTANSWER', 'shortanswer');
-
-?>
-
<?php
// This file is part of Moodle - http://moodle.org/
$string['categorycurrentuse'] = 'Use this category';
$string['categorydoesnotexist'] = 'This category does not exist';
$string['categoryinfo'] = 'Category info';
+$string['categorymove'] = 'The category \'{$a->name}\' contains {$a->count} questions (some of them may be old, hidden, questions that are still in use in some existing quizzes). Please choose another category to move them to.';
$string['categorymoveto'] = 'Save in category';
$string['categorynamecantbeblank'] = 'The category name cannot be blank.';
$string['clicktoflag'] = 'Click to flag this question';
$grade = get_string('outofshort', 'quiz', $a);
}
if ($alloptions->overallfeedback) {
- $feedback = quiz_feedback_for_grade($grades[$quiz->id], $quiz, $context, $cm);
+ $feedback = quiz_feedback_for_grade($grades[$quiz->id], $quiz, $context);
}
}
$data[] = $grade;
$string['category'] = 'Category';
$string['categoryadded'] = 'The category \'{$a}\' was added';
$string['categorydeleted'] = 'The category \'{$a}\' was deleted';
-$string['categorymove'] = 'The category \'{$a->name}\' contains {$a->count} questions (some of them may be old, hidden, questions that are still in use in some existing quizzes).<br />Please choose another category to move them to.';
-$string['categorymoveto'] = 'Move them to this category';
$string['categorynoedit'] = 'You do not have editing privileges in the category \'{$a}\'.';
$string['categoryupdated'] = 'The category was successfully updated';
$string['close'] = 'Close window';
MIN(attempt) AS firstattempt,
MAX(attempt) AS lastattempt
- FROM {quiz_attempts iquiza}
+ FROM {quiz_attempts} iquiza
WHERE
iquiza.timefinish <> 0 AND
return $output;
}
+ /**
+ * Renders the review question pop-up.
+ *
+ * @param quiz_attempt $attemptobj an instance of quiz_attempt.
+ * @param int $slot which question to display.
+ * @param int $seq which step of the question attempt to show. null = latest.
+ * @param mod_quiz_display_options $displayoptions instance of mod_quiz_display_options.
+ * @param array $summarydata contains all table data
+ * @return $output containing html data.
+ */
+ public function review_question_page(quiz_attempt $attemptobj, $slot, $seq,
+ mod_quiz_display_options $displayoptions, $summarydata) {
+
+ $output = '';
+ $output .= $this->header();
+ $output .= $this->review_summary_table($summarydata, 0);
+
+ if (!is_null($seq)) {
+ $output .= $attemptobj->render_question_at_step($slot, $seq, true, $this->page->url);
+ } else {
+ $output .= $attemptobj->render_question($slot, true, $this->page->url);
+ }
+
+ $output .= $this->close_window_button();
+ $output .= $this->footer();
+ return $output;
+ }
+
+ /**
+ * Renders the review question pop-up.
+ *
+ * @param string $message Why the review is not allowed.
+ * @return string html to output.
+ */
+ public function review_question_not_allowed($message) {
+ $output = '';
+ $output .= $this->header();
+ $output .= $this->notification($message);
+ $output .= $this->close_window_button();
+ $output .= $this->footer();
+ return $output;
+ }
+
/**
* Filters the summarydata array.
*
* @param int $page contains the current page number
*/
public function review_summary_table($summarydata, $page) {
- $summarydata = $this->filter_summary_table($summarydata,
- $page);
+ $summarydata = $this->filter_summary_table($summarydata, $page);
if (empty($summarydata)) {
return '';
}
if ($viewobj->feedbackcolumn && $attempt->timefinish > 0) {
if ($attemptoptions->overallfeedback) {
- $row[] = quiz_feedback_for_grade($attemptgrade, $quiz, $context, $cm);
+ $row[] = quiz_feedback_for_grade($attemptgrade, $quiz, $context);
} else {
$row[] = '';
}
if ($viewobj->feedbackcolumn) {
$resultinfo .= $this->heading(get_string('overallfeedback', 'quiz'), 3, 'main');
$resultinfo .= html_writer::tag('p',
- quiz_feedback_for_grade($viewobj->mygrade, $quiz, $context, $cm),
+ quiz_feedback_for_grade($viewobj->mygrade, $quiz, $context),
array('class' => 'quizgradefeedback')).'\n';
}
* @var int $lastfinishedattempt contains a pointer to the last attempt in the attempts array.
*/
public $lastfinishedattempt;
-}
\ No newline at end of file
+}
$timetaken = get_string('unfinished', 'quiz');
}
-// Print summary table about the whole attempt.
-// First we assemble all the rows that are appopriate to the current situation in
-// an array, then later we only output the table if there are any rows to show.
+// Prepare summary informat about the whole attempt.
$summarydata = array();
if (!$attemptobj->get_quiz()->showuserpicture && $attemptobj->get_userid() != $USER->id) {
// If showuserpicture is true, the picture is shown elsewhere, so don't repeat it.
$currenturl->param('step', $seq);
}
$PAGE->set_url($currenturl);
-$PAGE->set_pagelayout('popup');
$attemptobj = quiz_attempt::create($attemptid);
require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
$attemptobj->check_review_capability();
-echo $OUTPUT->header();
+$PAGE->set_pagelayout('popup');
+$output = $PAGE->get_renderer('mod_quiz');
// Check permissions.
if ($attemptobj->is_own_attempt()) {
if (!$attemptobj->is_finished()) {
- echo $OUTPUT->notification(get_string('cannotreviewopen', 'quiz'));
- echo $OUTPUT->close_window_button();
- echo $OUTPUT->footer();
+ echo $output->review_question_not_allowed(get_string('cannotreviewopen', 'quiz'));
die();
} else if (!$options->responses) {
$accessmanager = $attemptobj->get_access_manager(time());
- echo $OUTPUT->notification($accessmanager->cannot_review_message(
- $attemptobj->get_review_options()));
- echo $OUTPUT->close_window_button();
- echo $OUTPUT->footer();
+ echo $output->review_question_not_allowed(
+ $accessmanager->cannot_review_message($attemptobj->get_review_options()));
die();
}
throw new moodle_quiz_exception($attemptobj->get_quizobj(), 'noreviewattempt');
}
+// Prepare summary informat about this question attempt.
+$summarydata = array();
+
// Quiz name.
-$rows[] = '<tr><th scope="row" class="cell">' . get_string('modulename', 'quiz') .
- '</th><td class="cell">' . format_string($attemptobj->get_quiz_name()) . '</td></tr>';
+$summarydata['quizname'] = array(
+ 'title' => get_string('modulename', 'quiz'),
+ 'content' => format_string($attemptobj->get_quiz_name()),
+);
// Question name.
-$rows[] = '<tr><th scope="row" class="cell">' . get_string('question', 'quiz') .
- '</th><td class="cell">' . format_string(
- $attemptobj->get_question_name($slot)) . '</td></tr>';
+$summarydata['questionname'] = array(
+ 'title' => get_string('question', 'quiz'),
+ 'content' => $attemptobj->get_question_name($slot),
+);
// Other attempts at the quiz.
if ($attemptobj->has_capability('mod/quiz:viewreports')) {
$attemptlist = $attemptobj->links_to_other_attempts($baseurl);
if ($attemptlist) {
- $rows[] = '<tr><th scope="row" class="cell">' . get_string('attempts', 'quiz') .
- '</th><td class="cell">' . $attemptlist . '</td></tr>';
+ $summarydata['attemptlist'] = array(
+ 'title' => get_string('attempts', 'quiz'),
+ 'content' => $attemptlist,
+ );
}
}
// Timestamp of this action.
$timestamp = $attemptobj->get_question_action_time($slot);
if ($timestamp) {
- $rows[] = '<tr><th scope="row" class="cell">' . get_string('completedon', 'quiz') .
- '</th><td class="cell">' . userdate($timestamp) . '</td></tr>';
-}
-
-// Now output the summary table, if there are any rows to be shown.
-if (!empty($rows)) {
- echo '<table class="generaltable generalbox quizreviewsummary"><tbody>', "\n";
- echo implode("\n", $rows);
- echo "\n</tbody></table>\n";
-}
-
-// Print the question in the requested state.
-if (!is_null($seq)) {
- echo $attemptobj->render_question_at_step($slot, $seq, true, $currenturl);
-} else {
- echo $attemptobj->render_question($slot, true, $currenturl);
+ $summarydata['timestamp'] = array(
+ 'title' => get_string('completedon', 'quiz'),
+ 'content' => userdate($timestamp),
+ );
}
-// Finish the page
-echo $OUTPUT->footer();
+echo $output->review_question_page($attemptobj, $slot, $seq,
+ $attemptobj->get_display_options(true), $summarydata);
return parent::get_expected_data();
}
+ public function get_state_string($showcorrectness) {
+ $laststep = $this->qa->get_last_step();
+ if ($laststep->has_behaviour_var('_try')) {
+ $state = question_state::graded_state_for_fraction(
+ $laststep->get_behaviour_var('_rawfraction'));
+ return $state->default_string(true);
+ }
+
+ $state = $this->qa->get_state();
+ if ($state == question_state::$todo) {
+ return get_string('notcomplete', 'qbehaviour_adaptive');
+ } else {
+ return parent::get_state_string($showcorrectness);
+ }
+ }
+
public function get_right_answer_summary() {
return $this->question->get_right_answer_summary();
}
}
}
- public function get_state_string($showcorrectness) {
- $state = $this->qa->get_state();
-
- $laststep = $this->qa->get_last_step();
- if ($laststep->has_behaviour_var('_try')) {
- $state = question_state::graded_state_for_fraction(
- $laststep->get_behaviour_var('_rawfraction'));
- }
-
- return $state->default_string($showcorrectness);
- }
-
public function process_action(question_attempt_pending_step $pendingstep) {
if ($pendingstep->has_behaviour_var('comment')) {
return $this->process_comment($pendingstep);
$string['gradingdetails'] = 'Marks for this submission: {$a->raw}/{$a->max}.';
$string['gradingdetailsadjustment'] = 'With previous penalties this gives <strong>{$a->cur}/{$a->max}</strong>.';
$string['gradingdetailspenalty'] = 'This submission attracted a penalty of {$a}.';
+$string['notcomplete'] = 'Not complete';
$string['pluginname'] = 'Adaptive mode';
return parent::get_expected_data();
}
+ public function get_state_string($showcorrectness) {
+ $state = $this->qa->get_state();
+ if ($state == question_state::$todo) {
+ return get_string('notcomplete', 'qbehaviour_immediatefeedback');
+ } else {
+ return parent::get_state_string($showcorrectness);
+ }
+ }
+
public function get_right_answer_summary() {
return $this->question->get_right_answer_summary();
}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+$string['notcomplete'] = 'Not complete';
$string['pluginname'] = 'Immediate feedback';
public function get_per_answer_fields($mform, $label, $gradeoptions,
&$repeatedoptions, &$answersoption) {
- $repeated = array();
- $repeated[] = $mform->createElement('header', 'answerhdr', $label);
- $repeated[] = $mform->createElement('text', 'answer',
- get_string('answer', 'question'), array('size' => 50));
- $repeated[] = $mform->createElement('select', 'fraction',
- get_string('grade'), $gradeoptions);
- $repeated[] = $mform->createElement('editor', 'feedback',
- get_string('feedback', 'question'), null, $this->editoroptions);
- $repeatedoptions['answer']['type'] = PARAM_RAW;
- $repeatedoptions['fraction']['default'] = 0;
- $answersoption = 'answers';
-
- $mform->setType('answer', PARAM_NOTAGS);
+ $repeated = parent::get_per_answer_fields($mform, $label, $gradeoptions,
+ $repeatedoptions, $answersoption);
+
+ $repeated[1]->setLabel(get_string('correctanswerformula', 'qtype_calculated') . '=');
+ $repeatedoptions['tolerance']['default'] = 0.01;
$addrepeated = array();
- $addrepeated[] = $mform->createElement('text', 'tolerance',
- get_string('tolerance', 'qtype_calculated'));
$addrepeated[] = $mform->createElement('select', 'tolerancetype',
- get_string('tolerancetype', 'qtype_numerical'),
- $this->qtypeobj->tolerance_types());
- $repeatedoptions['tolerance']['type'] = PARAM_NUMBER;
- $repeatedoptions['tolerance']['default'] = 0.01;
+ get_string('tolerancetype', 'qtype_numerical'), $this->qtypeobj->tolerance_types());
$addrepeated[] = $mform->createElement('select', 'correctanswerlength',
get_string('correctanswershows', 'qtype_calculated'), range(0, 9));
);
$addrepeated[] = $mform->createElement('select', 'correctanswerformat',
get_string('correctanswershowsformat', 'qtype_calculated'), $answerlengthformats);
- array_splice($repeated, 3, 0, $addrepeated);
- $repeated[1]->setLabel(get_string('correctanswerformula', 'qtype_calculated') . ' = ');
+
+ array_splice($repeated, 4, 0, $addrepeated);
+
return $repeated;
}
parent::__construct($submiturl, $question, $category, $contexts, $formeditable);
}
- public function get_per_answer_fields($mform, $label, $gradeoptions,
- &$repeatedoptions, &$answersoption) {
- $repeated = parent::get_per_answer_fields($mform, $label, $gradeoptions,
- $repeatedoptions, $answersoption);
- $mform->setType('answer', PARAM_NOTAGS);
- $addrepeated = array();
- $addrepeated[] = $mform->createElement('text', 'tolerance',
- get_string('tolerance', 'qtype_calculated'));
- $repeatedoptions['tolerance']['type'] = PARAM_NUMBER;
- $repeatedoptions['tolerance']['default'] = 0.01;
- $addrepeated[] = $mform->createElement('select', 'tolerancetype',
- get_string('tolerancetype', 'qtype_numerical'), $this->qtypeobj->tolerance_types());
- $addrepeated[] = $mform->createElement('select', 'correctanswerlength',
- get_string('correctanswershows', 'qtype_calculated'), range(0, 9));
- $repeatedoptions['correctanswerlength']['default'] = 2;
-
- $answerlengthformats = array(
- '1' => get_string('decimalformat', 'qtype_numerical'),
- '2' => get_string('significantfiguresformat', 'qtype_calculated')
- );
- $addrepeated[] = $mform->createElement('select', 'correctanswerformat',
- get_string('correctanswershowsformat', 'qtype_calculated'), $answerlengthformats);
- array_splice($repeated, 3, 0, $addrepeated);
- $repeated[1]->setLabel(get_string('correctanswerformula', 'qtype_calculated').'=');
-
- return $repeated;
- }
-
/**
* Add question-type specific form fields.
*
get_string('decodeverifyquestiontext', 'qtype_multianswer'));
$mform->registerNoSubmitButton('analyzequestion');
if ($this->reload) {
- $mform->addElement('html', '<div class="ablock clearfix">');
- $mform->addElement('html', '<div class=" clearfix">');
for ($sub = 1; $sub <= $countsubquestions; $sub++) {
$this->editas[$sub] = 'unknown type';
} else if (optional_param('sub_'.$sub."_".'qtype', '', PARAM_RAW) != '') {
$this->editas[$sub] = optional_param('sub_'.$sub."_".'qtype', '', PARAM_RAW);
}
+
$storemess = '';
if (isset($this->savedquestiondisplay->options->questions[$sub]->qtype) &&
$this->savedquestiondisplay->options->questions[$sub]->qtype !=
$this->questiondisplay->options->questions[$sub]->qtype) {
$this->qtype_change = true;
- $storemess = "<font class=\"error\"> STORED QTYPE " .
- question_bank::get_qtype_name(
- $this->savedquestiondisplay->options->questions[$sub]->qtype).
- "</font >";
+ $storemess = ' ' . html_writer::tag('span', get_string(
+ 'storedqtype', 'qtype_multianswer', question_bank::get_qtype_name(
+ $this->savedquestiondisplay->options->questions[$sub]->qtype)),
+ array('class' => 'error'));
}
$mform->addElement('header', 'subhdr'.$sub, get_string('questionno', 'question',
$this->questiondisplay->options->questions[$sub]->qtype).$storemess);
$mform->addElement('static', 'sub_'.$sub."_".'questiontext',
- get_string('questiondefinition', 'qtype_multianswer'),
- array('cols' => 60, 'rows' => 3));
+ get_string('questiondefinition', 'qtype_multianswer'));
if (isset ($this->questiondisplay->options->questions[$sub]->questiontext)) {
$mform->setDefault('sub_'.$sub."_".'questiontext',
if ($this->questiondisplay->options->questions[$sub]->qtype == 'multichoice') {
$mform->addElement('static', 'sub_'.$sub."_".'layout',
- get_string('layout', 'qtype_multianswer'),
- array('cols' => 60, 'rows' => 1));
+ get_string('layout', 'qtype_multianswer'));
}
- foreach ($this->questiondisplay->options->questions[$sub]->answer as $key => $ans) {
+ foreach ($this->questiondisplay->options->questions[$sub]->answer as $key => $ans) {
$mform->addElement('static', 'sub_'.$sub."_".'answer['.$key.']',
- get_string('answer', 'question'), array('cols' => 60, 'rows' => 1));
+ get_string('answer', 'question'));
if ($this->questiondisplay->options->questions[$sub]->qtype == 'numerical' &&
$key == 0) {
$mform->addElement('static', 'sub_'.$sub."_".'feedback['.$key.']',
get_string('feedback', 'question'));
}
-
}
- $mform->addElement('html', '</div>');
+
$this->negative_diff = $countsavedsubquestions - $countsubquestions;
if (($this->negative_diff > 0) ||$this->qtype_change ||
($this->used_in_quiz && $this->negative_diff != 0)) {
get_string('questiontypechanged', 'qtype_multianswer')."</strong>",
get_string('questiontypechangedcomment', 'qtype_multianswer'));
}
- $mform->addElement('html', '</div>');
}
if ($this->used_in_quiz) {
if ($this->negative_diff < 0) {
$string['questiontypechanged'] = 'Question type changed';
$string['questiontypechangedcomment'] = 'At least one question type has been changed.<br \>Did you add, delete or move a question?<br \>Look ahead.';
$string['questionusedinquiz'] = 'This question is used in {$a->nb_of_quiz} quiz(s), total attempt(s) : {$a->nb_of_attempts} ';
+$string['storedqtype'] = 'Stored question type {$a}';
$string['subqresponse'] = 'part {$a->i}: {$a->response}';
$string['unknownquestiontypeofsubquestion'] = 'Unknown question type: {$a->type} of question part # {$a->sub}';
$string['warningquestionmodified'] = '<b>WARNING</b>';