MDL-41611 mod_quiz: Offer to return to course when supported

This commit is contained in:
Frederic Massart 2013-10-04 11:35:47 +08:00
parent 98e9e91505
commit eb665c34ef
3 changed files with 10 additions and 5 deletions

View File

@ -1,4 +1 @@
/* In mod_quiz hide "Back to course" button */
.format-singleactivity.path-mod-quiz .quizattempt .continuebutton {display:none;}
.format-singleactivity .tree_item.orphaned a {color:red;}

View File

@ -703,6 +703,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
* @return string HTML to output.
*/
public function view_page_buttons(mod_quiz_view_object $viewobj) {
global $CFG;
$output = '';
if (!$viewobj->quizhasquestions) {
@ -716,8 +717,9 @@ class mod_quiz_renderer extends plugin_renderer_base {
$viewobj->startattempturl, $viewobj->startattemptwarning,
$viewobj->popuprequired, $viewobj->popupoptions);
} else if ($viewobj->buttontext === '') {
// We should show a 'back to the course' button.
}
if ($viewobj->showbacktocourse) {
$output .= $this->single_button($viewobj->backtocourseurl,
get_string('backtocourse', 'quiz'), 'get',
array('class' => 'continuebutton'));
@ -1220,6 +1222,8 @@ class mod_quiz_view_object {
public $startattempturl;
/** @var moodle_url $startattempturl URL for any Back to the course button. */
public $backtocourseurl;
/** @var bool $showbacktocourse should we show a back to the course button? */
public $showbacktocourse;
/** @var bool whether the attempt must take place in a popup window. */
public $popuprequired;
/** @var array options to use for the popup window, if required. */

View File

@ -29,6 +29,7 @@ require_once(dirname(__FILE__) . '/../../config.php');
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->dirroot.'/mod/quiz/locallib.php');
require_once($CFG->libdir . '/completionlib.php');
require_once($CFG->dirroot . '/course/format/lib.php');
$id = optional_param('id', 0, PARAM_INT); // Course Module ID, or ...
$q = optional_param('q', 0, PARAM_INT); // Quiz ID.
@ -225,6 +226,9 @@ if (!$viewobj->quizhasquestions) {
}
}
$viewobj->showbacktocourse = ($viewobj->buttontext === '' &&
course_get_format($course)->has_view_page());
echo $OUTPUT->header();
if (isguestuser()) {