2009-11-04 11:58:30 +00:00
|
|
|
<?php
|
2011-02-10 20:44:47 +00:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2009-01-19 05:30:01 +00:00
|
|
|
|
2005-05-06 06:24:04 +00:00
|
|
|
/**
|
2007-11-07 15:20:57 +00:00
|
|
|
* Page to edit quizzes
|
|
|
|
*
|
|
|
|
* This page generally has two columns:
|
|
|
|
* The right column lists all available questions in a chosen category and
|
|
|
|
* allows them to be edited or more to be added. This column is only there if
|
|
|
|
* the quiz does not already have student attempts
|
|
|
|
* The left column lists all questions that have been added to the current quiz.
|
|
|
|
* The lecturer can add questions from the right hand list to the quiz or remove them
|
|
|
|
*
|
|
|
|
* The script also processes a number of actions:
|
|
|
|
* Actions affecting a quiz:
|
|
|
|
* up and down Changes the order of questions and page breaks
|
|
|
|
* addquestion Adds a single question to the quiz
|
|
|
|
* add Adds several selected questions to the quiz
|
|
|
|
* addrandom Adds a certain number of random questions to the quiz
|
|
|
|
* repaginate Re-paginates the quiz
|
|
|
|
* delete Removes a question from the quiz
|
|
|
|
* savechanges Saves the order and grades for questions in the quiz
|
|
|
|
*
|
2011-02-21 16:13:25 +00:00
|
|
|
* @package mod
|
2011-02-10 20:44:47 +00:00
|
|
|
* @subpackage quiz
|
2011-02-21 16:13:25 +00:00
|
|
|
* @copyright 1999 onwards Martin Dougiamas and others {@link http://moodle.com}
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
2011-02-10 20:44:47 +00:00
|
|
|
*/
|
|
|
|
|
2009-01-19 05:30:01 +00:00
|
|
|
|
2009-02-26 08:30:45 +00:00
|
|
|
require_once('../../config.php');
|
|
|
|
require_once($CFG->dirroot . '/mod/quiz/editlib.php');
|
2010-11-22 09:52:42 +00:00
|
|
|
require_once($CFG->dirroot . '/mod/quiz/addrandomform.php');
|
2009-02-26 08:30:45 +00:00
|
|
|
require_once($CFG->dirroot . '/question/category_class.php');
|
2008-11-20 06:59:11 +00:00
|
|
|
|
2011-02-10 20:44:47 +00:00
|
|
|
|
2008-11-20 06:59:11 +00:00
|
|
|
/**
|
|
|
|
* Callback function called from question_list() function
|
|
|
|
* (which is called from showbank())
|
|
|
|
* Displays button in form with checkboxes for each question.
|
|
|
|
*/
|
2009-02-26 08:30:45 +00:00
|
|
|
function module_specific_buttons($cmid, $cmoptions) {
|
2009-12-23 17:44:17 +00:00
|
|
|
global $OUTPUT;
|
2012-03-28 13:55:17 +01:00
|
|
|
$params = array(
|
|
|
|
'type' => 'submit',
|
|
|
|
'name' => 'add',
|
|
|
|
'value' => $OUTPUT->larrow() . ' ' . get_string('addtoquiz', 'quiz'),
|
|
|
|
);
|
2009-02-26 08:30:45 +00:00
|
|
|
if ($cmoptions->hasattempts) {
|
2012-03-28 13:55:17 +01:00
|
|
|
$params['disabled'] = 'disabled';
|
2009-02-26 08:30:45 +00:00
|
|
|
}
|
2012-03-28 13:55:17 +01:00
|
|
|
return html_writer::empty_tag('input', $params);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
2007-08-09 21:51:09 +00:00
|
|
|
|
2008-11-20 06:59:11 +00:00
|
|
|
/**
|
|
|
|
* Callback function called from question_list() function
|
|
|
|
* (which is called from showbank())
|
|
|
|
*/
|
2009-02-26 08:30:45 +00:00
|
|
|
function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmoptions) {
|
2011-02-10 20:44:47 +00:00
|
|
|
global $OUTPUT;
|
2008-11-20 06:59:11 +00:00
|
|
|
$out = '';
|
|
|
|
$catcontext = get_context_instance_by_id($category->contextid);
|
2009-02-26 08:30:45 +00:00
|
|
|
if (has_capability('moodle/question:useall', $catcontext)) {
|
|
|
|
if ($cmoptions->hasattempts) {
|
2010-11-22 09:52:42 +00:00
|
|
|
$disabled = ' disabled="disabled"';
|
2009-02-26 08:30:45 +00:00
|
|
|
} else {
|
|
|
|
$disabled = '';
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
2009-02-11 09:48:30 +00:00
|
|
|
$randomusablequestions =
|
2011-02-10 20:44:47 +00:00
|
|
|
question_bank::get_qtype('random')->get_available_questions_from_category(
|
|
|
|
$category->id, $recurse);
|
2008-11-20 06:59:11 +00:00
|
|
|
$maxrand = count($randomusablequestions);
|
|
|
|
if ($maxrand > 0) {
|
2009-02-26 08:30:45 +00:00
|
|
|
for ($i = 1; $i <= min(10, $maxrand); $i++) {
|
2008-11-20 06:59:11 +00:00
|
|
|
$randomcount[$i] = $i;
|
2007-05-07 16:57:23 +00:00
|
|
|
}
|
2009-02-26 08:30:45 +00:00
|
|
|
for ($i = 20; $i <= min(100, $maxrand); $i += 10) {
|
2008-11-20 06:59:11 +00:00
|
|
|
$randomcount[$i] = $i;
|
|
|
|
}
|
2010-11-22 09:52:42 +00:00
|
|
|
} else {
|
|
|
|
$randomcount[0] = 0;
|
|
|
|
$disabled = ' disabled="disabled"';
|
2007-05-07 16:57:23 +00:00
|
|
|
}
|
2010-11-22 09:52:42 +00:00
|
|
|
|
|
|
|
$out = '<strong><label for="menurandomcount">'.get_string('addrandomfromcategory', 'quiz').
|
|
|
|
'</label></strong><br />';
|
|
|
|
$attributes = array();
|
|
|
|
$attributes['disabled'] = $disabled ? 'disabled' : null;
|
|
|
|
$select = html_writer::select($randomcount, 'randomcount', '1', null, $attributes);
|
|
|
|
$out .= get_string('addrandom', 'quiz', $select);
|
|
|
|
$out .= '<input type="hidden" name="recurse" value="'.$recurse.'" />';
|
|
|
|
$out .= '<input type="hidden" name="categoryid" value="' . $category->id . '" />';
|
|
|
|
$out .= ' <input type="submit" name="addrandom" value="'.
|
|
|
|
get_string('addtoquiz', 'quiz').'"' . $disabled . ' />';
|
|
|
|
$out .= $OUTPUT->help_icon('addarandomquestion', 'quiz');
|
2007-08-09 21:51:09 +00:00
|
|
|
}
|
2008-11-20 06:59:11 +00:00
|
|
|
return $out;
|
|
|
|
}
|
2007-08-09 21:51:09 +00:00
|
|
|
|
2010-05-21 03:15:48 +00:00
|
|
|
//these params are only passed from page request to request while we stay on
|
|
|
|
//this page otherwise they would go in question_edit_setup
|
2010-08-04 16:31:54 +00:00
|
|
|
$quiz_reordertool = optional_param('reordertool', -1, PARAM_BOOL);
|
2010-05-21 03:15:48 +00:00
|
|
|
$quiz_qbanktool = optional_param('qbanktool', -1, PARAM_BOOL);
|
2011-02-11 17:36:02 +00:00
|
|
|
$scrollpos = optional_param('scrollpos', '', PARAM_INT);
|
2010-05-21 03:15:48 +00:00
|
|
|
|
2008-11-20 06:59:11 +00:00
|
|
|
list($thispageurl, $contexts, $cmid, $cm, $quiz, $pagevars) =
|
2010-04-12 13:31:42 +00:00
|
|
|
question_edit_setup('editq', '/mod/quiz/edit.php', true);
|
2011-02-10 20:44:47 +00:00
|
|
|
$quiz->questions = quiz_clean_layout($quiz->questions);
|
2008-11-20 06:59:11 +00:00
|
|
|
|
|
|
|
$defaultcategoryobj = question_make_default_categories($contexts->all());
|
2010-11-22 09:52:42 +00:00
|
|
|
$defaultcategory = $defaultcategoryobj->id . ',' . $defaultcategoryobj->contextid;
|
2009-02-26 08:30:45 +00:00
|
|
|
|
2008-11-20 06:59:11 +00:00
|
|
|
if ($quiz_qbanktool > -1) {
|
|
|
|
$thispageurl->param('qbanktool', $quiz_qbanktool);
|
2009-02-26 08:30:45 +00:00
|
|
|
set_user_preference('quiz_qbanktool_open', $quiz_qbanktool);
|
2008-11-20 06:59:11 +00:00
|
|
|
} else {
|
2009-02-26 08:30:45 +00:00
|
|
|
$quiz_qbanktool = get_user_preferences('quiz_qbanktool_open', 0);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
|
|
|
|
2010-08-04 16:31:54 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-03-28 13:55:17 +01:00
|
|
|
$canaddrandom = $contexts->have_cap('moodle/question:useall');
|
|
|
|
$canaddquestion = (bool) $contexts->having_add_and_use();
|
|
|
|
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
$quizhasattempts = quiz_has_attempts($quiz->id);
|
2008-11-20 06:59:11 +00:00
|
|
|
|
2010-08-04 16:31:54 +00:00
|
|
|
$PAGE->set_url($thispageurl);
|
2008-11-20 06:59:11 +00:00
|
|
|
|
2010-11-15 17:00:38 +00:00
|
|
|
$pagetitle = get_string('editingquiz', 'quiz');
|
2009-02-26 08:30:45 +00:00
|
|
|
if ($quiz_reordertool) {
|
2010-11-15 17:00:38 +00:00
|
|
|
$pagetitle = get_string('orderingquiz', 'quiz');
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
|
|
|
// Get the course object and related bits.
|
2009-02-26 08:30:45 +00:00
|
|
|
$course = $DB->get_record('course', array('id' => $quiz->course));
|
|
|
|
if (!$course) {
|
2008-11-20 06:59:11 +00:00
|
|
|
print_error('invalidcourseid', 'error');
|
|
|
|
}
|
|
|
|
|
2011-05-27 11:49:23 +01:00
|
|
|
$questionbank = new quiz_question_bank_view($contexts, $thispageurl, $course, $cm, $quiz);
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
$questionbank->set_quiz_has_attempts($quizhasattempts);
|
2009-01-22 05:38:18 +00:00
|
|
|
|
2008-11-20 06:59:11 +00:00
|
|
|
// Log this visit.
|
|
|
|
add_to_log($cm->course, 'quiz', 'editquestions',
|
2007-05-03 10:10:01 +00:00
|
|
|
"view.php?id=$cm->id", "$quiz->id", $cm->id);
|
2006-08-23 15:12:52 +00:00
|
|
|
|
2009-02-26 08:30:45 +00:00
|
|
|
// You need mod/quiz:manage in addition to question capabilities to access this page.
|
2008-11-20 06:59:11 +00:00
|
|
|
require_capability('mod/quiz:manage', $contexts->lowest());
|
2002-10-14 12:21:18 +00:00
|
|
|
|
2011-02-10 20:44:47 +00:00
|
|
|
if (empty($quiz->grades)) {
|
2008-11-20 06:59:11 +00:00
|
|
|
$quiz->grades = quiz_get_all_question_grades($quiz);
|
|
|
|
}
|
2006-03-12 21:17:42 +00:00
|
|
|
|
2009-02-27 08:45:05 +00:00
|
|
|
// Process commands ============================================================
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
if ($quiz->shufflequestions) {
|
|
|
|
// Strip page breaks before processing actions, so that re-ordering works
|
|
|
|
// as expected when shuffle questions is on.
|
|
|
|
$quiz->questions = quiz_repaginate($quiz->questions, 0);
|
|
|
|
}
|
2009-02-27 08:45:05 +00:00
|
|
|
|
|
|
|
// Get the list of question ids had their check-boxes ticked.
|
|
|
|
$selectedquestionids = array();
|
|
|
|
$params = (array) data_submitted();
|
|
|
|
foreach ($params as $key => $value) {
|
|
|
|
if (preg_match('!^s([0-9]+)$!', $key, $matches)) {
|
|
|
|
$selectedquestionids[] = $matches[1];
|
2002-10-14 09:07:13 +00:00
|
|
|
}
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
|
|
|
|
2011-02-11 17:36:02 +00:00
|
|
|
$afteractionurl = new moodle_url($thispageurl);
|
|
|
|
if ($scrollpos) {
|
|
|
|
$afteractionurl->param('scrollpos', $scrollpos);
|
|
|
|
}
|
2009-02-27 08:45:05 +00:00
|
|
|
if (($up = optional_param('up', false, PARAM_INT)) && confirm_sesskey()) {
|
|
|
|
$quiz->questions = quiz_move_question_up($quiz->questions, $up);
|
2011-02-10 20:44:47 +00:00
|
|
|
$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id));
|
|
|
|
quiz_delete_previews($quiz);
|
2011-02-11 17:36:02 +00:00
|
|
|
redirect($afteractionurl);
|
2009-02-27 08:45:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (($down = optional_param('down', false, PARAM_INT)) && confirm_sesskey()) {
|
|
|
|
$quiz->questions = quiz_move_question_down($quiz->questions, $down);
|
2011-02-10 20:44:47 +00:00
|
|
|
$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id));
|
|
|
|
quiz_delete_previews($quiz);
|
2011-02-11 17:36:02 +00:00
|
|
|
redirect($afteractionurl);
|
2009-02-27 08:45:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (optional_param('repaginate', false, PARAM_BOOL) && confirm_sesskey()) {
|
|
|
|
// Re-paginate the quiz
|
|
|
|
$questionsperpage = optional_param('questionsperpage', $quiz->questionsperpage, PARAM_INT);
|
|
|
|
$quiz->questions = quiz_repaginate($quiz->questions, $questionsperpage );
|
2011-02-10 20:44:47 +00:00
|
|
|
$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id));
|
|
|
|
quiz_delete_previews($quiz);
|
2011-02-11 17:36:02 +00:00
|
|
|
redirect($afteractionurl);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
2009-02-26 08:30:45 +00:00
|
|
|
|
|
|
|
if (($addquestion = optional_param('addquestion', 0, PARAM_INT)) && confirm_sesskey()) {
|
2011-05-12 00:30:25 +01:00
|
|
|
// Add a single question to the current quiz
|
2012-03-28 13:55:17 +01:00
|
|
|
quiz_require_question_use($addquestion);
|
2009-02-26 08:30:45 +00:00
|
|
|
$addonpage = optional_param('addonpage', 0, PARAM_INT);
|
2008-11-20 06:59:11 +00:00
|
|
|
quiz_add_quiz_question($addquestion, $quiz, $addonpage);
|
2009-02-27 08:45:05 +00:00
|
|
|
quiz_delete_previews($quiz);
|
2011-02-10 20:44:47 +00:00
|
|
|
quiz_update_sumgrades($quiz);
|
2010-05-01 08:23:28 +00:00
|
|
|
$thispageurl->param('lastchanged', $addquestion);
|
2011-02-11 17:36:02 +00:00
|
|
|
redirect($afteractionurl);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
|
|
|
|
2009-02-26 08:30:45 +00:00
|
|
|
if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) {
|
2011-05-12 00:30:25 +01:00
|
|
|
// Add selected questions to the current quiz
|
2008-11-20 06:59:11 +00:00
|
|
|
$rawdata = (array) data_submitted();
|
2011-02-10 20:44:47 +00:00
|
|
|
foreach ($rawdata as $key => $value) { // Parse input for question ids
|
2008-11-20 06:59:11 +00:00
|
|
|
if (preg_match('!^q([0-9]+)$!', $key, $matches)) {
|
|
|
|
$key = $matches[1];
|
2012-03-28 13:55:17 +01:00
|
|
|
quiz_require_question_use($key);
|
2008-11-20 06:59:11 +00:00
|
|
|
quiz_add_quiz_question($key, $quiz);
|
2005-03-05 12:55:26 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-27 08:45:05 +00:00
|
|
|
quiz_delete_previews($quiz);
|
2011-02-10 20:44:47 +00:00
|
|
|
quiz_update_sumgrades($quiz);
|
2011-02-11 17:36:02 +00:00
|
|
|
redirect($afteractionurl);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
|
|
|
|
2010-11-22 09:52:42 +00:00
|
|
|
if ((optional_param('addrandom', false, PARAM_BOOL)) && confirm_sesskey()) {
|
|
|
|
// Add random questions to the quiz
|
2008-11-20 06:59:11 +00:00
|
|
|
$recurse = optional_param('recurse', 0, PARAM_BOOL);
|
2009-02-26 08:30:45 +00:00
|
|
|
$addonpage = optional_param('addonpage', 0, PARAM_INT);
|
2010-11-22 09:52:42 +00:00
|
|
|
$categoryid = required_param('categoryid', PARAM_INT);
|
|
|
|
$randomcount = required_param('randomcount', PARAM_INT);
|
|
|
|
quiz_add_random_questions($quiz, $addonpage, $categoryid, $randomcount, $recurse);
|
2002-10-14 09:07:13 +00:00
|
|
|
|
2009-02-27 08:45:05 +00:00
|
|
|
quiz_delete_previews($quiz);
|
2011-02-10 20:44:47 +00:00
|
|
|
quiz_update_sumgrades($quiz);
|
2011-02-11 17:36:02 +00:00
|
|
|
redirect($afteractionurl);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
2009-02-26 08:30:45 +00:00
|
|
|
|
2011-05-12 00:30:25 +01:00
|
|
|
if (optional_param('addnewpagesafterselected', null, PARAM_CLEAN) &&
|
|
|
|
!empty($selectedquestionids) && confirm_sesskey()) {
|
2009-02-27 08:45:05 +00:00
|
|
|
foreach ($selectedquestionids as $questionid) {
|
|
|
|
$quiz->questions = quiz_add_page_break_after($quiz->questions, $questionid);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
2011-02-10 20:44:47 +00:00
|
|
|
$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id));
|
|
|
|
quiz_delete_previews($quiz);
|
2011-02-11 17:36:02 +00:00
|
|
|
redirect($afteractionurl);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
2007-08-09 21:51:09 +00:00
|
|
|
|
2009-02-26 08:30:45 +00:00
|
|
|
$addpage = optional_param('addpage', false, PARAM_INT);
|
2009-02-27 08:45:05 +00:00
|
|
|
if ($addpage !== false && confirm_sesskey()) {
|
|
|
|
$quiz->questions = quiz_add_page_break_at($quiz->questions, $addpage);
|
2011-02-10 20:44:47 +00:00
|
|
|
$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id));
|
|
|
|
quiz_delete_previews($quiz);
|
2011-02-11 17:36:02 +00:00
|
|
|
redirect($afteractionurl);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
2002-10-14 09:07:13 +00:00
|
|
|
|
2009-02-26 08:30:45 +00:00
|
|
|
$deleteemptypage = optional_param('deleteemptypage', false, PARAM_INT);
|
|
|
|
if (($deleteemptypage !== false) && confirm_sesskey()) {
|
2009-02-27 08:45:05 +00:00
|
|
|
$quiz->questions = quiz_delete_empty_page($quiz->questions, $deleteemptypage);
|
2011-02-10 20:44:47 +00:00
|
|
|
$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id));
|
|
|
|
quiz_delete_previews($quiz);
|
2011-02-11 17:36:02 +00:00
|
|
|
redirect($afteractionurl);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
2008-12-05 05:08:37 +00:00
|
|
|
|
2009-02-27 08:45:05 +00:00
|
|
|
$remove = optional_param('remove', false, PARAM_INT);
|
2012-03-28 13:55:17 +01:00
|
|
|
if ($remove && confirm_sesskey()) {
|
|
|
|
// Remove a question from the quiz.
|
|
|
|
// We require the user to have the 'use' capability on the question,
|
|
|
|
// so that then can add it back if they remove the wrong one by mistake.
|
|
|
|
quiz_require_question_use($remove);
|
2009-02-27 08:45:05 +00:00
|
|
|
quiz_remove_question($quiz, $remove);
|
|
|
|
quiz_delete_previews($quiz);
|
2012-01-11 16:21:47 +00:00
|
|
|
quiz_update_sumgrades($quiz);
|
2011-02-11 17:36:02 +00:00
|
|
|
redirect($afteractionurl);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
2005-05-06 06:24:04 +00:00
|
|
|
|
2011-05-12 00:30:25 +01:00
|
|
|
if (optional_param('quizdeleteselected', false, PARAM_BOOL) &&
|
|
|
|
!empty($selectedquestionids) && confirm_sesskey()) {
|
2009-02-27 08:45:05 +00:00
|
|
|
foreach ($selectedquestionids as $questionid) {
|
2012-03-28 13:55:17 +01:00
|
|
|
if (quiz_has_question_use($questionid)) {
|
|
|
|
quiz_remove_question($quiz, $questionid);
|
|
|
|
}
|
2005-02-05 21:03:04 +00:00
|
|
|
}
|
2009-02-27 08:45:05 +00:00
|
|
|
quiz_delete_previews($quiz);
|
2011-02-10 20:44:47 +00:00
|
|
|
quiz_update_sumgrades($quiz);
|
2011-02-11 17:36:02 +00:00
|
|
|
redirect($afteractionurl);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
|
|
|
|
2009-02-26 08:30:45 +00:00
|
|
|
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
|
2011-02-10 20:44:47 +00:00
|
|
|
$deletepreviews = false;
|
|
|
|
$recomputesummarks = false;
|
|
|
|
|
2009-02-26 08:30:45 +00:00
|
|
|
$oldquestions = explode(',', $quiz->questions); // the questions in the old order
|
2008-11-20 06:59:11 +00:00
|
|
|
$questions = array(); // for questions in the new order
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
$rawdata = (array) data_submitted();
|
2008-11-20 06:59:11 +00:00
|
|
|
$moveonpagequestions = array();
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
$moveselectedonpage = optional_param('moveselectedonpagetop', 0, PARAM_INT);
|
|
|
|
if (!$moveselectedonpage) {
|
|
|
|
$moveselectedonpage = optional_param('moveselectedonpagebottom', 0, PARAM_INT);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
2006-03-01 09:30:21 +00:00
|
|
|
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
foreach ($rawdata as $key => $value) {
|
2009-02-27 08:45:05 +00:00
|
|
|
if (preg_match('!^g([0-9]+)$!', $key, $matches)) {
|
2011-05-12 00:30:25 +01:00
|
|
|
// Parse input for question -> grades
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
$questionid = $matches[1];
|
2009-06-05 09:25:34 +00:00
|
|
|
$quiz->grades[$questionid] = clean_param($value, PARAM_FLOAT);
|
2011-02-10 20:44:47 +00:00
|
|
|
quiz_update_question_instance($quiz->grades[$questionid], $questionid, $quiz);
|
|
|
|
$deletepreviews = true;
|
|
|
|
$recomputesummarks = true;
|
2007-05-03 10:10:01 +00:00
|
|
|
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
} else if (preg_match('!^o(pg)?([0-9]+)$!', $key, $matches)) {
|
2011-05-12 00:30:25 +01:00
|
|
|
// Parse input for ordering info
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
$questionid = $matches[2];
|
|
|
|
// Make sure two questions don't overwrite each other. If we get a second
|
|
|
|
// question with the same position, shift the second one along to the next gap.
|
2009-06-05 09:25:34 +00:00
|
|
|
$value = clean_param($value, PARAM_INTEGER);
|
2008-11-20 06:59:11 +00:00
|
|
|
while (array_key_exists($value, $questions)) {
|
|
|
|
$value++;
|
|
|
|
}
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
if ($matches[1]) {
|
|
|
|
// This is a page-break entry.
|
|
|
|
$questions[$value] = 0;
|
|
|
|
} else {
|
|
|
|
$questions[$value] = $questionid;
|
|
|
|
}
|
2011-02-10 20:44:47 +00:00
|
|
|
$deletepreviews = true;
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-27 08:45:05 +00:00
|
|
|
|
2008-11-20 06:59:11 +00:00
|
|
|
// If ordering info was given, reorder the questions
|
|
|
|
if ($questions) {
|
|
|
|
ksort($questions);
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
$questions[] = 0;
|
|
|
|
$quiz->questions = implode(',', $questions);
|
2011-02-10 20:44:47 +00:00
|
|
|
$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id));
|
|
|
|
$deletepreviews = true;
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
2009-02-27 08:45:05 +00:00
|
|
|
|
2008-11-20 06:59:11 +00:00
|
|
|
//get a list of questions to move, later to be added in the appropriate
|
|
|
|
//place in the string
|
2009-02-27 08:45:05 +00:00
|
|
|
if ($moveselectedonpage) {
|
2009-02-26 08:30:45 +00:00
|
|
|
$questions = explode(',', $quiz->questions);
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
$newquestions = array();
|
|
|
|
//remove the questions from their original positions first
|
|
|
|
foreach ($questions as $questionid) {
|
|
|
|
if (!in_array($questionid, $selectedquestionids)) {
|
|
|
|
$newquestions[] = $questionid;
|
2008-11-21 17:08:36 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-26 08:30:45 +00:00
|
|
|
$questions = $newquestions;
|
|
|
|
|
2008-11-21 17:08:36 +00:00
|
|
|
//move to the end of the selected page
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
$pagebreakpositions = array_keys($questions, 0);
|
|
|
|
$numpages = count($pagebreakpositions);
|
2011-12-15 19:32:37 +00:00
|
|
|
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
// Ensure the target page number is in range.
|
2011-12-15 19:32:37 +00:00
|
|
|
for ($i = $moveselectedonpage; $i > $numpages; $i--) {
|
|
|
|
$questions[] = 0;
|
|
|
|
$pagebreakpositions[] = count($questions) - 1;
|
|
|
|
}
|
2009-02-26 08:30:45 +00:00
|
|
|
$moveselectedpos = $pagebreakpositions[$moveselectedonpage - 1];
|
2011-12-15 19:32:37 +00:00
|
|
|
|
|
|
|
// Do the move.
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
array_splice($questions, $moveselectedpos, 0, $selectedquestionids);
|
2009-02-26 08:30:45 +00:00
|
|
|
$quiz->questions = implode(',', $questions);
|
2011-12-15 19:32:37 +00:00
|
|
|
|
|
|
|
// Update the database.
|
2011-02-10 20:44:47 +00:00
|
|
|
$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id));
|
|
|
|
$deletepreviews = true;
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
|
2008-11-20 06:59:11 +00:00
|
|
|
// If rescaling is required save the new maximum
|
2009-06-05 09:25:34 +00:00
|
|
|
$maxgrade = optional_param('maxgrade', -1, PARAM_FLOAT);
|
2008-11-20 06:59:11 +00:00
|
|
|
if ($maxgrade >= 0) {
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
quiz_set_grade($maxgrade, $quiz);
|
2006-03-01 09:30:21 +00:00
|
|
|
}
|
2005-05-06 06:24:04 +00:00
|
|
|
|
2011-02-10 20:44:47 +00:00
|
|
|
if ($deletepreviews) {
|
|
|
|
quiz_delete_previews($quiz);
|
|
|
|
}
|
|
|
|
if ($recomputesummarks) {
|
|
|
|
quiz_update_sumgrades($quiz);
|
|
|
|
quiz_update_all_attempt_sumgrades($quiz);
|
|
|
|
quiz_update_all_final_grades($quiz);
|
|
|
|
quiz_update_grades($quiz, 0, true);
|
|
|
|
}
|
2011-02-11 17:36:02 +00:00
|
|
|
redirect($afteractionurl);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
2006-02-17 17:15:17 +00:00
|
|
|
|
2009-01-19 05:30:01 +00:00
|
|
|
$questionbank->process_actions($thispageurl, $cm);
|
2005-02-05 21:03:04 +00:00
|
|
|
|
2009-02-27 08:45:05 +00:00
|
|
|
// End of process commands =====================================================
|
2008-11-20 06:59:11 +00:00
|
|
|
|
2010-06-06 07:18:32 +00:00
|
|
|
$PAGE->requires->yui2_lib('container');
|
|
|
|
$PAGE->requires->yui2_lib('dragdrop');
|
2011-05-12 00:30:25 +01:00
|
|
|
$PAGE->requires->skip_link_to('questionbank',
|
|
|
|
get_string('skipto', 'access', get_string('questionbank', 'question')));
|
|
|
|
$PAGE->requires->skip_link_to('quizcontentsblock',
|
|
|
|
get_string('skipto', 'access', get_string('questionsinthisquiz', 'quiz')));
|
2009-09-08 01:57:28 +00:00
|
|
|
$PAGE->set_title($pagetitle);
|
2010-05-21 03:15:48 +00:00
|
|
|
$PAGE->set_heading($course->fullname);
|
2010-08-04 16:31:54 +00:00
|
|
|
$node = $PAGE->settingsnav->find('mod_quiz_edit', navigation_node::TYPE_SETTING);
|
|
|
|
if ($node) {
|
|
|
|
$node->make_active();
|
|
|
|
}
|
2009-09-08 01:57:28 +00:00
|
|
|
echo $OUTPUT->header();
|
2009-07-17 06:54:58 +00:00
|
|
|
|
2008-11-25 12:31:59 +00:00
|
|
|
// Initialise the JavaScript.
|
2011-02-21 18:10:19 +00:00
|
|
|
$quizeditconfig = new stdClass();
|
2010-01-17 09:50:55 +00:00
|
|
|
$quizeditconfig->url = $thispageurl->out(true, array('qbanktool' => '0'));
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
$quizeditconfig->dialoglisteners = array();
|
2008-11-25 12:31:59 +00:00
|
|
|
$numberoflisteners = max(quiz_number_of_pages($quiz->questions), 1);
|
|
|
|
for ($pageiter = 1; $pageiter <= $numberoflisteners; $pageiter++) {
|
|
|
|
$quizeditconfig->dialoglisteners[] = 'addrandomdialoglaunch_' . $pageiter;
|
|
|
|
}
|
ajaxlib/require_js: MDL-16693 $PAGE->requires->... deprecates require_js etc.
There is a new implementation of require_js in lib/deprecatedlib.php,
based on $PAGE->requires.
There were a few other recently introduced functions in lib/weblib.php,
namely print_js_call, print_delayed_js_call, print_js_config and
standard_js_config. These have been removed, since they were never in
a stable branch, and all the places that used them have been changed
to use the newer $PAGE->requires->... methods.
get_require_js_code is also gone, and the evil places that were calling
it, even though it is an internal function, have been fixed.
Also, I made some minor improvements to the code I committed yesterday
for MDL-16695.
All that remains is to update all the places in core code that are
still using require_js.
(This commit also fixes the problem where the admin tree would not
start with the right categories expanded.)
2009-06-12 12:13:07 +00:00
|
|
|
$PAGE->requires->data_for_js('quiz_edit_config', $quizeditconfig);
|
2011-02-11 17:36:02 +00:00
|
|
|
$PAGE->requires->js('/question/qengine.js');
|
2010-01-18 20:57:32 +00:00
|
|
|
$PAGE->requires->js('/mod/quiz/edit.js');
|
2011-02-11 17:36:02 +00:00
|
|
|
$PAGE->requires->js_init_call('quiz_edit_init');
|
2008-11-25 12:31:59 +00:00
|
|
|
|
2010-08-04 16:31:54 +00:00
|
|
|
// Print the tabs to switch mode.
|
|
|
|
if ($quiz_reordertool) {
|
|
|
|
$currenttab = 'reorder';
|
|
|
|
} else {
|
|
|
|
$currenttab = 'edit';
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
2010-08-04 16:31:54 +00:00
|
|
|
$tabs = array(array(
|
2011-05-12 00:30:25 +01:00
|
|
|
new tabobject('edit', new moodle_url($thispageurl,
|
|
|
|
array('reordertool' => 0)), get_string('editingquiz', 'quiz')),
|
|
|
|
new tabobject('reorder', new moodle_url($thispageurl,
|
|
|
|
array('reordertool' => 1)), get_string('orderingquiz', 'quiz')),
|
2010-08-04 16:31:54 +00:00
|
|
|
));
|
|
|
|
print_tabs($tabs, $currenttab);
|
2008-11-20 06:59:11 +00:00
|
|
|
|
2009-02-26 08:30:45 +00:00
|
|
|
if ($quiz_qbanktool) {
|
|
|
|
$bankclass = '';
|
|
|
|
$quizcontentsclass = '';
|
|
|
|
} else {
|
2009-09-21 16:53:45 +00:00
|
|
|
$bankclass = 'collapsed ';
|
2009-02-26 08:30:45 +00:00
|
|
|
$quizcontentsclass = 'quizwhenbankcollapsed';
|
|
|
|
}
|
2008-12-26 00:29:17 +00:00
|
|
|
|
2010-05-06 06:16:07 +00:00
|
|
|
echo '<div class="questionbankwindow ' . $bankclass . 'block">';
|
2009-09-21 16:53:45 +00:00
|
|
|
echo '<div class="header"><div class="title"><h2>';
|
|
|
|
echo get_string('questionbankcontents', 'quiz') .
|
2010-01-17 09:50:55 +00:00
|
|
|
' <a href="' . $thispageurl->out(true, array('qbanktool' => '1')) .
|
2009-09-21 16:53:45 +00:00
|
|
|
'" id="showbankcmd">[' . get_string('show').
|
|
|
|
']</a>
|
2010-01-17 09:50:55 +00:00
|
|
|
<a href="' . $thispageurl->out(true, array('qbanktool' => '0')) .
|
2009-09-21 16:53:45 +00:00
|
|
|
'" id="hidebankcmd">[' . get_string('hide').
|
|
|
|
']</a>';
|
|
|
|
echo '</h2></div></div><div class="content">';
|
|
|
|
|
2008-12-26 00:29:17 +00:00
|
|
|
echo '<span id="questionbank"></span>';
|
2008-11-22 11:29:20 +00:00
|
|
|
echo '<div class="container">';
|
2008-11-20 06:59:11 +00:00
|
|
|
echo '<div id="module" class="module">';
|
|
|
|
echo '<div class="bd">';
|
2009-01-21 07:21:43 +00:00
|
|
|
$questionbank->display('editq',
|
2008-11-20 06:59:11 +00:00
|
|
|
$pagevars['qpage'],
|
2011-08-04 13:53:02 +01:00
|
|
|
$pagevars['qperpage'],
|
2008-11-20 06:59:11 +00:00
|
|
|
$pagevars['cat'], $pagevars['recurse'], $pagevars['showhidden'],
|
2011-08-26 17:01:06 +01:00
|
|
|
$pagevars['qbshowtext']);
|
2009-02-26 08:30:45 +00:00
|
|
|
echo '</div>';
|
|
|
|
echo '</div>';
|
|
|
|
echo '</div>';
|
2009-06-29 08:17:31 +00:00
|
|
|
|
2009-09-21 16:53:45 +00:00
|
|
|
echo '</div></div>';
|
2008-11-20 06:59:11 +00:00
|
|
|
|
2009-02-26 08:30:45 +00:00
|
|
|
echo '<div class="quizcontents ' . $quizcontentsclass . '" id="quizcontentsblock">';
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
if ($quiz->shufflequestions) {
|
2009-02-26 08:30:45 +00:00
|
|
|
$repaginatingdisabledhtml = 'disabled="disabled"';
|
|
|
|
$repaginatingdisabled = true;
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
$quiz->questions = quiz_repaginate($quiz->questions, $quiz->questionsperpage);
|
2009-02-26 08:30:45 +00:00
|
|
|
} else {
|
|
|
|
$repaginatingdisabledhtml = '';
|
|
|
|
$repaginatingdisabled = false;
|
|
|
|
}
|
|
|
|
if ($quiz_reordertool) {
|
2011-05-12 00:30:25 +01:00
|
|
|
echo '<div class="repaginatecommand"><button id="repaginatecommand" ' .
|
|
|
|
$repaginatingdisabledhtml.'>'.
|
2009-02-26 08:30:45 +00:00
|
|
|
get_string('repaginatecommand', 'quiz').'...</button>';
|
2008-11-20 06:59:11 +00:00
|
|
|
echo '</div>';
|
|
|
|
}
|
2010-11-15 17:00:38 +00:00
|
|
|
|
|
|
|
if ($quiz_reordertool) {
|
|
|
|
echo $OUTPUT->heading_with_help(get_string('orderingquiz', 'quiz') . ': ' . $quiz->name,
|
|
|
|
'orderandpaging', 'quiz');
|
|
|
|
} else {
|
|
|
|
echo $OUTPUT->heading(get_string('editingquiz', 'quiz') . ': ' . $quiz->name, 2);
|
|
|
|
echo $OUTPUT->help_icon('editingquiz', 'quiz', get_string('basicideasofquiz', 'quiz'));
|
|
|
|
}
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
quiz_print_status_bar($quiz);
|
2008-11-20 06:59:11 +00:00
|
|
|
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
$tabindex = 0;
|
2012-01-11 16:21:47 +00:00
|
|
|
quiz_print_grading_form($quiz, $thispageurl, $tabindex);
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
|
|
|
|
$notifystrings = array();
|
|
|
|
if ($quizhasattempts) {
|
2010-07-28 15:08:34 +00:00
|
|
|
$reviewlink = quiz_attempt_summary_link_to_reports($quiz, $cm, $contexts->lowest());
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
$notifystrings[] = get_string('cannoteditafterattempts', 'quiz', $reviewlink);
|
2009-02-26 08:30:45 +00:00
|
|
|
}
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
if ($quiz->shufflequestions) {
|
2009-02-26 08:30:45 +00:00
|
|
|
$updateurl = new moodle_url("$CFG->wwwroot/course/mod.php",
|
|
|
|
array('return' => 'true', 'update' => $quiz->cmid, 'sesskey' => sesskey()));
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
$updatelink = '<a href="'.$updateurl->out().'">' . get_string('updatethis', '',
|
|
|
|
get_string('modulename', 'quiz')) . '</a>';
|
|
|
|
$notifystrings[] = get_string('shufflequestionsselected', 'quiz', $updatelink);
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
if (!empty($notifystrings)) {
|
2009-08-10 05:00:41 +00:00
|
|
|
echo $OUTPUT->box('<p>' . implode('</p><p>', $notifystrings) . '</p>', 'statusdisplay');
|
2008-11-20 06:59:11 +00:00
|
|
|
}
|
|
|
|
|
2009-02-26 08:30:45 +00:00
|
|
|
if ($quiz_reordertool) {
|
2010-11-22 09:52:42 +00:00
|
|
|
$perpage = array();
|
2008-11-20 06:59:11 +00:00
|
|
|
$perpage[0] = get_string('allinone', 'quiz');
|
2009-02-26 08:30:45 +00:00
|
|
|
for ($i = 1; $i <= 50; ++$i) {
|
2008-11-20 06:59:11 +00:00
|
|
|
$perpage[$i] = $i;
|
|
|
|
}
|
2009-02-26 08:30:45 +00:00
|
|
|
$gostring = get_string('go');
|
2008-11-20 06:59:11 +00:00
|
|
|
echo '<div id="repaginatedialog"><div class="hd">';
|
2009-02-26 08:30:45 +00:00
|
|
|
echo get_string('repaginatecommand', 'quiz');
|
2008-11-20 06:59:11 +00:00
|
|
|
echo '</div><div class="bd">';
|
|
|
|
echo '<form action="edit.php" method="post">';
|
|
|
|
echo '<fieldset class="invisiblefieldset">';
|
2010-01-17 09:06:55 +00:00
|
|
|
echo html_writer::input_hidden_params($thispageurl);
|
2009-01-02 10:36:25 +00:00
|
|
|
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
2008-11-20 06:59:11 +00:00
|
|
|
//YUI does not submit the value of the submit button so
|
|
|
|
//we need to add the value:
|
|
|
|
echo '<input type="hidden" name="repaginate" value="'.$gostring.'" />';
|
2010-02-11 10:03:28 +00:00
|
|
|
$attributes = array();
|
|
|
|
$attributes['disabled'] = $repaginatingdisabledhtml ? 'disabled' : null;
|
2011-05-12 00:30:25 +01:00
|
|
|
$select = html_writer::select(
|
|
|
|
$perpage, 'questionsperpage', $quiz->questionsperpage, null, $attributes);
|
2010-02-11 10:03:28 +00:00
|
|
|
print_string('repaginate', 'quiz', $select);
|
2008-11-20 06:59:11 +00:00
|
|
|
echo '<div class="quizquestionlistcontrols">';
|
2011-05-12 00:30:25 +01:00
|
|
|
echo ' <input type="submit" name="repaginate" value="'. $gostring . '" ' .
|
|
|
|
$repaginatingdisabledhtml.' />';
|
2008-11-20 06:59:11 +00:00
|
|
|
echo '</div></fieldset></form></div></div>';
|
|
|
|
}
|
|
|
|
|
2010-05-21 03:15:48 +00:00
|
|
|
if ($quiz_reordertool) {
|
|
|
|
echo '<div class="reorder">';
|
|
|
|
} else {
|
|
|
|
echo '<div class="editq">';
|
|
|
|
}
|
|
|
|
|
2012-03-28 13:55:17 +01:00
|
|
|
quiz_print_question_list($quiz, $thispageurl, true, $quiz_reordertool, $quiz_qbanktool,
|
|
|
|
$quizhasattempts, $defaultcategoryobj, $canaddquestion, $canaddrandom);
|
quiz editing: MDL-17454 first attemtp, and MDL-18554
This is a minimal fix for MDL-18554, I have just added a cancel button and made it work.
The more substantial part of this is MDL-17454, trying to make the quiz editing screen behave appropriately when shuffle questions is on. I am sure Olli will have opinions about this and want to change it further. Rought summary:
* When shufflequestions is off, never restrict manual paging, even if questionsperpage is set.
* When shuffle questions is on:
** Always display the quiz with the defined number of questions per page.
** Remove controls to add things except at the end of the quiz.
** Disable most of the order and paging tab, but still allow the question list to be reordered, in case that helps teachers track which questions they have added.
** Still allow questions to be reordered on the edit tab, but when moving the top question on a page up, reorder with the previous question, rather than moving to the previous page.
* Change the status bar, so that the yellow highlight is reserved for alert information. The more informative stuff is now plain, and moved to under the title. To my mind that associates it more closely with the quiz name. Also it moves Total of grades and Maximum grade closer together.
* JavaScript cleaned up. I learn more about YUI every day.
* Some PHP code clean ups that I forgot to commit separately before making substantive changes.
2009-03-17 09:51:34 +00:00
|
|
|
echo '</div>';
|
2008-12-05 05:08:37 +00:00
|
|
|
|
|
|
|
// Close <div class="quizcontents">:
|
2008-11-20 06:59:11 +00:00
|
|
|
echo '</div>';
|
|
|
|
|
2012-03-28 13:55:17 +01:00
|
|
|
if (!$quiz_reordertool && $canaddrandom) {
|
2010-11-22 09:52:42 +00:00
|
|
|
$randomform = new quiz_add_random_form(new moodle_url('/mod/quiz/addrandom.php'), $contexts);
|
|
|
|
$randomform->set_data(array(
|
|
|
|
'category' => $pagevars['cat'],
|
2011-08-24 15:31:56 +01:00
|
|
|
'returnurl' => $thispageurl->out_as_local_url(false),
|
2010-11-22 09:52:42 +00:00
|
|
|
'cmid' => $cm->id,
|
|
|
|
));
|
2008-11-20 06:59:11 +00:00
|
|
|
?>
|
2011-05-12 00:30:25 +01:00
|
|
|
<div id="randomquestiondialog">
|
|
|
|
<div class="hd"><?php print_string('addrandomquestiontoquiz', 'quiz', $quiz->name); ?>
|
|
|
|
<span id="pagenumber"><!-- JavaScript will insert the page number here. -->
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div class="bd"><?php
|
|
|
|
$randomform->display();
|
|
|
|
?></div>
|
|
|
|
</div>
|
2008-11-20 06:59:11 +00:00
|
|
|
<?php
|
|
|
|
}
|
2009-08-06 14:13:48 +00:00
|
|
|
echo $OUTPUT->footer();
|