protected function standard_attempt_fields(MoodleQuickForm $mform) { $mform->addElement('select', 'attempts', get_string('reportattemptsfrom', 'quiz'), array(quiz_attempts_report::ENROLLED_WITH => get_string('reportuserswith', 'quiz'), quiz_attempts_report::ENROLLED_WITHOUT => get_string('reportuserswithout', 'quiz'), quiz_attempts_report::ENROLLED_ALL => get_string('reportuserswithorwithout', 'quiz'), quiz_attempts_report::ALL_WITH => get_string('reportusersall', 'quiz'))); $stategroup = array($mform->createElement('advcheckbox', 'stateinprogress', '', get_string('stateinprogress', 'quiz')), $mform->createElement('advcheckbox', 'stateoverdue', '', get_string('stateoverdue', 'quiz')), $mform->createElement('advcheckbox', 'statefinished', '', get_string('statefinished', 'quiz')), $mform->createElement('advcheckbox', 'stateabandoned', '', get_string('stateabandoned', 'quiz'))); $mform->addGroup($stategroup, 'stateoptions', get_string('reportattemptsthatare', 'quiz'), array(' '), false); $mform->setDefault('stateinprogress', 1); $mform->setDefault('stateoverdue', 1); $mform->setDefault('statefinished', 1); $mform->setDefault('stateabandoned', 1); $mform->disabledIf('stateinprogress', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT); $mform->disabledIf('stateoverdue', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT); $mform->disabledIf('statefinished', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT); $mform->disabledIf('stateabandoned', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT); if (quiz_report_can_filter_only_graded($this->_customdata['quiz'])) { $gm = html_writer::tag('span', quiz_get_grading_option_name($this->_customdata['quiz']->grademethod), array('class' => 'highlight')); $mform->addElement('advcheckbox', 'onlygraded', get_string('reportshowonly', 'quiz'), get_string('optonlygradedattempts', 'quiz_overview', $gm)); $mform->disabledIf('onlygraded', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT); $mform->disabledIf('onlygraded', 'statefinished', 'notchecked'); } }
function definition() { global $COURSE; $mform =& $this->_form; //------------------------------------------------------------------------------- $mform->addElement('header', 'preferencespage', get_string('preferencespage', 'quiz_overview')); $options = array(); if (!$this->_customdata['currentgroup']) { $options[QUIZ_REPORT_ATTEMPTS_ALL] = get_string('optallattempts', 'quiz_overview'); } if ($this->_customdata['currentgroup'] || $COURSE->id != SITEID) { $options[QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS] = get_string('optallstudents', 'quiz_overview', $COURSE->students); $options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH] = get_string('optattemptsonly', 'quiz_overview', $COURSE->students); $options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO] = get_string('optnoattemptsonly', 'quiz_overview', $COURSE->students); } $mform->addElement('select', 'attemptsmode', get_string('show', 'quiz_overview'), $options); if ($this->_customdata['qmsubselect']) { $gm = '<span class="highlight">' . quiz_get_grading_option_name($this->_customdata['quiz']->grademethod) . '</span>'; $mform->addElement('advcheckbox', 'qmfilter', get_string('show', 'quiz_overview'), get_string('optonlygradedattempts', 'quiz_overview', $gm), null, array(0, 1)); } //------------------------------------------------------------------------------- $mform->addElement('header', 'preferencesuser', get_string('preferencesuser', 'quiz_overview')); $mform->addElement('text', 'pagesize', get_string('pagesize', 'quiz_overview')); $mform->setType('pagesize', PARAM_INT); $mform->addElement('selectyesno', 'detailedmarks', get_string('showdetailedmarks', 'quiz_overview')); $this->add_action_buttons(false, get_string('preferencessave', 'quiz_overview')); }
function definition() { global $COURSE; $mform =& $this->_form; //------------------------------------------------------------------------------- $mform->addElement('header', 'preferencespage', get_string('preferencespage', 'quiz_overview')); if (!$this->_customdata['currentgroup']) { $studentsstring = get_string('participants'); } else { $a = new stdClass(); $a->coursestudent = get_string('participants'); $a->groupname = groups_get_group_name($this->_customdata['currentgroup']); if (20 < strlen($a->groupname)) { $studentsstring = get_string('studentingrouplong', 'quiz_overview', $a); } else { $studentsstring = get_string('studentingroup', 'quiz_overview', $a); } } $options = array(); if (!$this->_customdata['currentgroup']) { $options[QUIZ_REPORT_ATTEMPTS_ALL] = get_string('optallattempts', 'quiz_overview'); } if ($this->_customdata['currentgroup'] || $COURSE->id != SITEID) { $options[QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS] = get_string('optallstudents', 'quiz_overview', $studentsstring); $options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH] = get_string('optattemptsonly', 'quiz_overview', $studentsstring); $options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO] = get_string('optnoattemptsonly', 'quiz_overview', $studentsstring); } $mform->addElement('select', 'attemptsmode', get_string('show', 'quiz_overview'), $options); $showattemptsgrp = array(); if ($this->_customdata['qmsubselect']) { $gm = '<span class="highlight">' . quiz_get_grading_option_name($this->_customdata['quiz']->grademethod) . '</span>'; $showattemptsgrp[] =& $mform->createElement('advcheckbox', 'qmfilter', get_string('showattempts', 'quiz_overview'), get_string('optonlygradedattempts', 'quiz_overview', $gm), null, array(0, 1)); } if (has_capability('mod/quiz:regrade', $this->_customdata['context'])) { $showattemptsgrp[] =& $mform->createElement('advcheckbox', 'regradefilter', get_string('showattempts', 'quiz_overview'), get_string('optonlyregradedattempts', 'quiz_overview'), null, array(0, 1)); } if ($showattemptsgrp) { $mform->addGroup($showattemptsgrp, null, get_string('showattempts', 'quiz_overview'), '<br />', false); } //------------------------------------------------------------------------------- $mform->addElement('header', 'preferencesuser', get_string('preferencesuser', 'quiz_overview')); $mform->addElement('text', 'pagesize', get_string('pagesize', 'quiz_overview')); $mform->setType('pagesize', PARAM_INT); $mform->addElement('selectyesno', 'detailedmarks', get_string('showdetailedmarks', 'quiz_overview')); $mform->addElement('submit', 'submitbutton', get_string('preferencessave', 'quiz_overview')); }
protected function definition() { $mform = $this->_form; $mform->addElement('header', 'preferencespage', get_string('preferencespage', 'quiz_overview')); if (!$this->_customdata['currentgroup']) { $studentsstring = get_string('participants'); } else { $a = new stdClass(); $a->coursestudent = get_string('participants'); $a->groupname = groups_get_group_name($this->_customdata['currentgroup']); if (20 < strlen($a->groupname)) { $studentsstring = get_string('studentingrouplong', 'quiz_overview', $a); } else { $studentsstring = get_string('studentingroup', 'quiz_overview', $a); } } $options = array(); if (!$this->_customdata['currentgroup']) { $options[QUIZ_REPORT_ATTEMPTS_ALL] = get_string('optallattempts', 'quiz_overview'); } if ($this->_customdata['currentgroup'] || !is_inside_frontpage($this->_customdata['context'])) { $options[QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS] = get_string('optallstudents', 'quiz_overview', $studentsstring); $options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH] = get_string('optattemptsonly', 'quiz_overview', $studentsstring); $options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO] = get_string('optnoattemptsonly', 'quiz_overview', $studentsstring); } $mform->addElement('select', 'attemptsmode', get_string('show', 'quiz_overview'), $options); if ($this->_customdata['qmsubselect']) { $gm = '<span class="gradedattempt">' . quiz_get_grading_option_name($this->_customdata['quiz']->grademethod) . '</span>'; $mform->addElement('advcheckbox', 'qmfilter', get_string('showattempts', 'quiz_overview'), get_string('optonlygradedattempts', 'quiz_overview', $gm), null, array(0, 1)); } $colsgroup = array(); $colsgroup[] = $mform->createElement('advcheckbox', 'qtext', '', get_string('summaryofquestiontext', 'quiz_responses')); $colsgroup[] = $mform->createElement('advcheckbox', 'resp', '', get_string('summaryofresponse', 'quiz_responses')); $colsgroup[] = $mform->createElement('advcheckbox', 'right', '', get_string('summaryofrightanswer', 'quiz_responses')); $mform->addGroup($colsgroup, null, get_string('include', 'quiz_responses'), '<br />', false); $mform->addElement('header', 'preferencesuser', get_string('preferencesuser', 'quiz_overview')); $mform->addElement('text', 'pagesize', get_string('pagesize', 'quiz_overview')); $mform->setType('pagesize', PARAM_INT); $mform->addElement('submit', 'submitbutton', get_string('preferencessave', 'quiz_overview')); }
/** * Generates data pertaining to quiz results * * @param array $quiz Array containing quiz data * @param int $context The page context ID * @param int $cm The Course Module Id * @param mod_quiz_view_object $viewobj */ public function view_result_info($quiz, $context, $cm, $viewobj) { $output = ''; if (!$viewobj->numattempts && !$viewobj->gradecolumn && is_null($viewobj->mygrade)) { return $output; } $resultinfo = ''; if ($viewobj->overallstats) { if ($viewobj->moreattempts) { $a = new stdClass(); $a->method = quiz_get_grading_option_name($quiz->grademethod); $a->mygrade = quiz_format_grade($quiz, $viewobj->mygrade); $a->quizgrade = quiz_format_grade($quiz, $quiz->grade); $resultinfo .= $this->heading(get_string('gradesofar', 'quiz', $a), 2, 'main'); } else { $a = new stdClass(); $a->grade = quiz_format_grade($quiz, $viewobj->mygrade); $a->maxgrade = quiz_format_grade($quiz, $quiz->grade); $a = get_string('outofshort', 'quiz', $a); $resultinfo .= $this->heading(get_string('yourfinalgradeis', 'quiz', $a), 2, 'main'); } } if ($viewobj->mygradeoverridden) { $resultinfo .= html_writer::tag('p', get_string('overriddennotice', 'grades'), array('class' => 'overriddennotice'))."\n"; } if ($viewobj->gradebookfeedback) { $resultinfo .= $this->heading(get_string('comment', 'quiz'), 3, 'main'); $resultinfo .= '<p class="quizteacherfeedback">'.$viewobj->gradebookfeedback. "</p>\n"; } 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), array('class' => 'quizgradefeedback'))."\n"; } if ($resultinfo) { $output .= $this->box($resultinfo, 'generalbox', 'feedback'); } return $output; }
$viewobj->mygradeoverridden = $mygradeoverridden; $viewobj->gradebookfeedback = $gradebookfeedback; $viewobj->lastfinishedattempt = $lastfinishedattempt; $viewobj->canedit = has_capability('mod/quiz:manage', $context); $viewobj->editurl = new moodle_url('/mod/quiz/edit.php', array('cmid' => $cm->id)); $viewobj->backtocourseurl = new moodle_url('/course/view.php', array('id' => $course->id)); $viewobj->startattempturl = $quizobj->start_attempt_url(); $viewobj->startattemptwarning = $quizobj->confirm_start_attempt_message($unfinished); $viewobj->popuprequired = $accessmanager->attempt_must_be_in_popup(); $viewobj->popupoptions = $accessmanager->get_popup_options(); // Display information about this quiz. $viewobj->infomessages = $viewobj->accessmanager->describe_rules(); if ($quiz->attempts != 1) { $viewobj->infomessages[] = get_string('gradingmethod', 'quiz', quiz_get_grading_option_name($quiz->grademethod)); } // 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'); }
$viewobj->mygrade = $mygrade; $viewobj->moreattempts = $unfinished || !$accessmanager->is_finished($numattempts, $lastfinishedattempt); $viewobj->mygradeoverridden = $mygradeoverridden; $viewobj->gradebookfeedback = $gradebookfeedback; $viewobj->lastfinishedattempt = $lastfinishedattempt; $viewobj->canedit = has_capability('mod/quiz:manage', $context); $viewobj->editurl = new moodle_url('/mod/quiz/edit.php', array('cmid' => $cm->id)); $viewobj->backtocourseurl = new moodle_url('/course/view.php', array('id' => $course->id)); $viewobj->startattempturl = $quizobj->start_attempt_url(); $viewobj->startattemptwarning = $quizobj->confirm_start_attempt_message($unfinished); $viewobj->popuprequired = $accessmanager->attempt_must_be_in_popup(); $viewobj->popupoptions = $accessmanager->get_popup_options(); // Display information about this quiz. $viewobj->infomessages = $viewobj->accessmanager->describe_rules(); if ($quiz->attempts != 1) { $viewobj->infomessages[] = get_string('gradingmethod', 'quiz', quiz_get_grading_option_name($quiz->grademethod)); } // 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'); } }
/** * Create the standard checkbox for the 'include highest graded only' option. * * @param MoodleQuickForm $mform the form we are building. */ protected function create_qmfilter_checkbox(MoodleQuickForm $mform) { $gm = html_writer::tag('span', quiz_get_grading_option_name( $this->_customdata['quiz']->grademethod), array('class' => 'highlight')); return $mform->createElement('advcheckbox', 'qmfilter', get_string('showattempts', 'quiz_overview'), get_string('optonlygradedattempts', 'quiz_overview', $gm), null, array(0, 1)); }
function quiz_report_highlighting_grading_method($quiz, $qmsubselect, $qmfilter) { if ($quiz->attempts == 1) { return '<p>' . get_string('onlyoneattemptallowed', 'quiz_overview') . '</p>'; } else { if (!$qmsubselect) { return '<p>' . get_string('allattemptscontributetograde', 'quiz_overview') . '</p>'; } else { if ($qmfilter) { return '<p>' . get_string('showinggraded', 'quiz_overview') . '</p>'; } else { return '<p>' . get_string('showinggradedandungraded', 'quiz_overview', '<span class="gradedattempt">' . quiz_get_grading_option_name($quiz->grademethod) . '</span>') . '</p>'; } } } }