mod_quiz / navigation MDL-20276 further polishing the quiz navigation structure.

This commit is contained in:
Tim Hunt
2010-08-04 16:31:54 +00:00
parent 7383c63398
commit eb02301a36
5 changed files with 51 additions and 27 deletions
+5
View File
@@ -53,6 +53,11 @@
if (empty($attemptobj->get_quiz()->showblocks)) {
$PAGE->blocks->show_only_fake_blocks();
}
} else {
$node = $PAGE->settingsnav->find('mod_quiz_preview', navigation_node::TYPE_SETTING);
if ($node) {
$node->make_active();
}
}
/// If the attempt is already closed, send them to the review page.
+24 -15
View File
@@ -112,16 +112,11 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
//these params are only passed from page request to request while we stay on
//this page otherwise they would go in question_edit_setup
$quiz_reordertool = optional_param('reordertool', 0, PARAM_BOOL);
$quiz_reordertool = optional_param('reordertool', -1, PARAM_BOOL);
$quiz_qbanktool = optional_param('qbanktool', -1, PARAM_BOOL);
list($thispageurl, $contexts, $cmid, $cm, $quiz, $pagevars) =
question_edit_setup('editq', '/mod/quiz/edit.php', true);
$url = new moodle_url($thispageurl);
if ($quiz_reordertool) {
$url->param('reordertool', $quiz_reordertool);
}
$PAGE->set_url($url);
$defaultcategoryobj = question_make_default_categories($contexts->all());
$defaultcategoryid = $defaultcategoryobj->id;
@@ -135,19 +130,23 @@ if ($quiz_qbanktool > -1) {
$quiz_qbanktool = get_user_preferences('quiz_qbanktool_open', 0);
}
if ($quiz_reordertool > -1) {
$thispageurl->param('reordertool', $quiz_reordertool);
set_user_preference('quiz_reordertab', $quiz_reordertool);
} else {
$quiz_reordertool = get_user_preferences('quiz_reordertab', 0);
}
//will be set further down in the code
$quizhasattempts = quiz_has_attempts($quiz->id);
if ($quiz_reordertool != 0) {
$thispageurl->param('reordertool', $quiz_reordertool);
}
$PAGE->set_url($thispageurl);
$PAGE->set_pagelayout('admin');
$strquizzes = get_string('modulenameplural', 'quiz');
$strquiz = get_string('modulename', 'quiz');
$streditingquestions = get_string('editquestions', 'quiz');
//this just does not work for at least finnish, where words are conjugated:
//$streditingquiz = get_string('editinga', 'moodle', $strquiz);
$streditingquiz = get_string('editingquiz', 'quiz');
$strorderingquiz = get_string('orderingquiz', 'quiz');
$pagetitle = $streditingquiz;
@@ -167,8 +166,6 @@ $questionbank->set_quiz_has_attempts($quizhasattempts);
add_to_log($cm->course, 'quiz', 'editquestions',
"view.php?id=$cm->id", "$quiz->id", $cm->id);
$PAGE->set_pagelayout('admin');
// You need mod/quiz:manage in addition to question capabilities to access this page.
require_capability('mod/quiz:manage', $contexts->lowest());
@@ -445,6 +442,10 @@ $PAGE->requires->skip_link_to('questionbank', get_string('skipto', 'access', ge
$PAGE->requires->skip_link_to('quizcontentsblock', get_string('skipto', 'access', get_string('questionsinthisquiz', 'quiz')));
$PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname);
$node = $PAGE->settingsnav->find('mod_quiz_edit', navigation_node::TYPE_SETTING);
if ($node) {
$node->make_active();
}
echo $OUTPUT->header();
// Initialise the JavaScript.
@@ -458,9 +459,17 @@ for ($pageiter = 1; $pageiter <= $numberoflisteners; $pageiter++) {
$PAGE->requires->data_for_js('quiz_edit_config', $quizeditconfig);
$PAGE->requires->js('/mod/quiz/edit.js');
if ($contexts->have_one_edit_tab_cap('editq') && $node = $PAGE->settingsnav->find('quizedit', navigation_node::TYPE_CONTAINER)) {
call_user_func_array('print_tabs', $node->get_tabs_array());
// Print the tabs to switch mode.
if ($quiz_reordertool) {
$currenttab = 'reorder';
} else {
$currenttab = 'edit';
}
$tabs = array(array(
new tabobject('edit', new moodle_url($thispageurl, array('reordertool' => 0)), $streditingquiz),
new tabobject('reorder', new moodle_url($thispageurl, array('reordertool' => 1)), $strorderingquiz),
));
print_tabs($tabs, $currenttab);
if ($quiz_qbanktool) {
$bankclass = '';
+8 -11
View File
@@ -1660,27 +1660,24 @@ function quiz_extend_settings_navigation($settings, $quiznode) {
require_once($CFG->libdir . '/questionlib.php');
if (has_capability('mod/quiz:manageoverrides', $PAGE->cm->context)) {
$overrides = $quiznode->add(get_string('settingsoverrides', 'quiz'), null, navigation_node::TYPE_CONTAINER, null, 'overrides');
$url = new moodle_url('/mod/quiz/overrides.php', array('cmid'=>$PAGE->cm->id));
$overrides->add(get_string('groupoverrides', 'quiz'), $url, navigation_node::TYPE_SETTING, null, 'groupoverrides');
$overrides->add(get_string('useroverrides', 'quiz'), new moodle_url($url, array('mode'=>'user')), navigation_node::TYPE_SETTING, null, 'useroverrides');
$quiznode->add(get_string('groupoverrides', 'quiz'), new moodle_url($url, array('mode'=>'group')),
navigation_node::TYPE_SETTING, null, 'groupoverrides');
$quiznode->add(get_string('useroverrides', 'quiz'), new moodle_url($url, array('mode'=>'user')),
navigation_node::TYPE_SETTING, null, 'useroverrides');
}
if (has_capability('mod/quiz:manage', $PAGE->cm->context)) {
$editnode = $quiznode->add(get_string('edit'), null, navigation_node::TYPE_CONTAINER, null, 'quizedit');
$url = new moodle_url('/mod/quiz/edit.php', array('cmid'=>$PAGE->cm->id));
$text = get_string("editinga", "moodle", get_string('modulename', 'quiz'));
$editnode->add($text, $url, navigation_node::TYPE_SETTING, null, 'edit', new pix_icon('t/edit', ''));
$url = new moodle_url('/mod/quiz/edit.php', array('cmid'=>$PAGE->cm->id, 'reordertool'=>'1'));
$editnode->add(get_string('orderandpaging','quiz'), $url, navigation_node::TYPE_SETTING, null, 'reorder', new pix_icon('t/edit', ''));
$quiznode->add($text, $url, navigation_node::TYPE_SETTING, null,
'mod_quiz_edit', new pix_icon('t/edit', ''));
}
if (has_capability('mod/quiz:preview', $PAGE->cm->context)) {
$url = new moodle_url('/mod/quiz/startattempt.php', array('cmid'=>$PAGE->cm->id, 'sesskey'=>sesskey()));
$quiznode->add(get_string('preview', 'quiz'), $url, navigation_node::TYPE_SETTING, null, 'preview', new pix_icon('t/preview', ''));
$quiznode->add(get_string('preview', 'quiz'), $url, navigation_node::TYPE_SETTING,
null, 'mod_quiz_preview', new pix_icon('t/preview', ''));
}
question_extend_settings_navigation($quiznode, $PAGE->cm->context)->trim_if_empty();
+6
View File
@@ -77,6 +77,12 @@
if ($attemptobj->is_preview_user() && $attemptobj->is_own_attempt()) {
// Normal blocks
$strreviewtitle = get_string('reviewofpreview', 'quiz');
$node = $PAGE->settingsnav->find('mod_quiz_preview', navigation_node::TYPE_SETTING);
if ($node) {
$node->make_active();
}
} else {
$strreviewtitle = get_string('reviewofattempt', 'quiz', $attemptobj->get_attempt_number());
if (empty($attemptobj->get_quiz()->showblocks) && !$attemptobj->is_preview_user()) {
+8 -1
View File
@@ -12,7 +12,7 @@ require_once($CFG->dirroot . '/mod/quiz/locallib.php');
$attemptid = required_param('attempt', PARAM_INT); // The attempt to summarise.
$PAGE->set_url('/mod/quiz/summary.php', array('attempt'=>$attemptid));
$PAGE->set_url('/mod/quiz/summary.php', array('attempt' => $attemptid));
$attemptobj = quiz_attempt::create($attemptid);
@@ -29,6 +29,13 @@ if ($attemptobj->is_finished()) {
redirect($attemptobj->review_url());
}
if ($attemptobj->is_preview_user()) {
$node = $PAGE->settingsnav->find('mod_quiz_preview', navigation_node::TYPE_SETTING);
if ($node) {
$node->make_active();
}
}
/// Check access.
$accessmanager = $attemptobj->get_access_manager(time());
$messages = $accessmanager->prevent_access();