mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
moved question sort order and paging params to be passed from page to page as get params instead of being saved in session var.
This commit is contained in:
parent
fcdb06c470
commit
b72ff47685
7 changed files with 268 additions and 248 deletions
|
@ -12,11 +12,16 @@
|
|||
require_once("editlib.php");
|
||||
require_once("category_class.php");
|
||||
|
||||
// get values from form
|
||||
|
||||
|
||||
list($thispageurl, $courseid, $cmid, $cm, $module, $pagevars) = question_edit_setup();
|
||||
|
||||
|
||||
// get values from form for actions on this page
|
||||
$param = new stdClass();
|
||||
|
||||
$id = required_param('courseid', PARAM_INT); // course id
|
||||
$param->page = optional_param('page', 1, PARAM_INT);
|
||||
$thispageurl->param('page', $param->page);
|
||||
|
||||
$param->moveup = optional_param('moveup', 0, PARAM_INT);
|
||||
$param->movedown = optional_param('movedown', 0, PARAM_INT);
|
||||
|
@ -33,35 +38,48 @@
|
|||
$param->edit = optional_param('edit', 0, PARAM_INT);
|
||||
$param->updateid = optional_param('updateid', 0, PARAM_INT);
|
||||
|
||||
if (! $course = get_record("course", "id", $id)) {
|
||||
if (! $course = get_record("course", "id", $courseid)) {
|
||||
error("Course ID is incorrect");
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
|
||||
require_login($course->id, false);
|
||||
require_capability('moodle/question:managecategory', $context);
|
||||
|
||||
$qcobject = new question_category_object($param->page);
|
||||
$qcobject = new question_category_object($param->page, $thispageurl);
|
||||
|
||||
$streditingcategories = get_string('editcategories', 'quiz');
|
||||
if ($qcobject->editlist->process_actions($param->left, $param->right, $param->moveup, $param->movedown)) {
|
||||
//processing of these actions is handled in the method and page redirects.
|
||||
} else if (isset($SESSION->modform->instance) and $quiz = get_record('quiz', 'id', $SESSION->modform->instance)) {
|
||||
} else if ($cm!==null) {
|
||||
// Page header
|
||||
// TODO: generalise this to any activity
|
||||
$strupdatemodule = has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id))
|
||||
? update_module_button($SESSION->modform->cmid, $course->id, get_string('modulename', 'quiz'))
|
||||
? update_module_button($cm->id, $course->id, get_string('modulename', $cm->modname))
|
||||
: "";
|
||||
print_header_simple(get_string('editcategories', 'quiz'), '',
|
||||
"<a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">".get_string('modulenameplural', 'quiz').'</a>'.
|
||||
" -> <a href=\"$CFG->wwwroot/mod/quiz/view.php?q=$quiz->id\">".format_string($quiz->name).'</a>'.
|
||||
' -> '.get_string('editcategories', 'quiz'),
|
||||
"", "", true, $strupdatemodule);
|
||||
$crumbs = array();
|
||||
$crumbs[] = array('name' => get_string('modulenameplural', $cm->modname),
|
||||
'link' => "$CFG->wwwroot/mod/{$cm->modname}/index.php?id=$course->id",
|
||||
'type' => 'activity');
|
||||
$crumbs[] = array('name' => format_string($module->name),
|
||||
'link' => "$CFG->wwwroot/mod/{$cm->modname}/view.php?cmid={$cm->id}",
|
||||
'type' => 'title');
|
||||
$crumbs[] = array('name' => $streditingcategories, 'link' => '', 'type' => 'title');
|
||||
$navigation = build_navigation($crumbs);
|
||||
print_header_simple($streditingcategories, '', $navigation, "", "", true, $strupdatemodule);
|
||||
|
||||
|
||||
$currenttab = 'edit';
|
||||
$mode = 'categories';
|
||||
include($CFG->dirroot.'/mod/quiz/tabs.php');
|
||||
${$cm->modname} = $module;
|
||||
include($CFG->dirroot."/mod/{$cm->modname}/tabs.php");
|
||||
} else {
|
||||
print_header_simple(get_string('editcategories', 'quiz'), '', get_string('editcategories', 'quiz'));
|
||||
// Print basic page layout.
|
||||
$crumbs = array();
|
||||
$crumbs[] = array('name' => $streditingcategories, 'link' => '', 'type' => 'title');
|
||||
$navigation = build_navigation($crumbs);
|
||||
|
||||
print_header_simple($streditingcategories, '', $navigation);
|
||||
|
||||
// print tabs
|
||||
$currenttab = 'categories';
|
||||
|
|
|
@ -13,15 +13,7 @@
|
|||
require_once("../config.php");
|
||||
require_once("editlib.php");
|
||||
|
||||
require_login();
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
// The optional parameter 'clean' allows us to clear module information,
|
||||
// guaranteeing a module-independent question bank editing interface
|
||||
if (optional_param('clean', false, PARAM_BOOL)) {
|
||||
unset($SESSION->modform);
|
||||
}
|
||||
list($thispageurl, $courseid, $cmid, $cm, $module, $pagevars) = question_edit_setup();
|
||||
|
||||
if (! $course = get_record("course", "id", $courseid)) {
|
||||
error("This course doesn't exist");
|
||||
|
@ -31,39 +23,40 @@
|
|||
|
||||
$SESSION->returnurl = $FULLME;
|
||||
|
||||
// Print basic page layout.
|
||||
$streditingquestions = get_string('editquestions', "quiz");
|
||||
|
||||
// TODO: generalise this to any activity
|
||||
$strquizzes = get_string('modulenameplural', 'quiz');
|
||||
$streditingquestions = get_string('editquestions', "quiz");
|
||||
if (isset($SESSION->modform->instance) and $quiz = get_record('quiz', 'id', $SESSION->modform->instance)) {
|
||||
if ($cm!==null) {
|
||||
$strupdatemodule = has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id))
|
||||
? update_module_button($SESSION->modform->cmid, $course->id, get_string('modulename', 'quiz'))
|
||||
? update_module_button($cm->id, $course->id, get_string('modulename', $cm->modname))
|
||||
: "";
|
||||
print_header_simple($streditingquestions, '',
|
||||
"<a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes</a>".
|
||||
" -> <a href=\"$CFG->wwwroot/mod/quiz/view.php?q={$SESSION->modform->instance}\">".format_string($SESSION->modform->name).'</a>'.
|
||||
" -> $streditingquestions",
|
||||
"", "", true, $strupdatemodule);
|
||||
$crumbs = array();
|
||||
$crumbs[] = array('name' => get_string('modulenameplural', $cm->modname), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/index.php?id=$course->id", 'type' => 'activity');
|
||||
$crumbs[] = array('name' => format_string($module->name), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/view.php?cmid={$cm->id}", 'type' => 'title');
|
||||
$crumbs[] = array('name' => $streditingquestions, 'link' => '', 'type' => 'title');
|
||||
$navigation = build_navigation($crumbs);
|
||||
print_header_simple($streditingquestions, '', $navigation, "", "", true, $strupdatemodule);
|
||||
|
||||
$currenttab = 'edit';
|
||||
$mode = 'questions';
|
||||
$quiz = &$SESSION->modform;
|
||||
include($CFG->dirroot.'/mod/quiz/tabs.php');
|
||||
${$cm->modname} = $module;
|
||||
include($CFG->dirroot."/mod/$cm->modname/tabs.php");
|
||||
} else {
|
||||
print_header_simple($streditingquestions, '',
|
||||
"$streditingquestions");
|
||||
|
||||
// Print basic page layout.
|
||||
$crumbs = array();
|
||||
$crumbs[] = array('name' => $streditingquestions, 'link' => '', 'type' => 'title');
|
||||
$navigation = build_navigation($crumbs);
|
||||
|
||||
print_header_simple($streditingquestions, '', $navigation);
|
||||
|
||||
// print tabs
|
||||
$currenttab = 'questions';
|
||||
include('tabs.php');
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo '<table class="boxaligncenter" border="0" cellpadding="2" cellspacing="0">';
|
||||
echo '<tr><td valign="top">';
|
||||
|
||||
include($CFG->dirroot.'/question/showbank.php');
|
||||
question_showbank($thispageurl, $cm, $pagevars['qpage'], $pagevars['qperpage'], $pagevars['qsortorder']);
|
||||
|
||||
echo '</td></tr>';
|
||||
echo '</table>';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php // $Id$
|
||||
/**
|
||||
* Functions used by showbank.php to show question editing interface
|
||||
* Functions used to show question editing interface
|
||||
*
|
||||
* TODO: currently the function question_list still provides controls specific
|
||||
* to the quiz module. This needs to be generalised.
|
||||
|
@ -269,20 +269,19 @@ function question_list($course, $pageurl, $categoryid, $cm = null,
|
|||
}
|
||||
}
|
||||
|
||||
print_paging_bar($totalnumber, $page, $perpage,
|
||||
"edit.php?courseid={$course->id}&perpage=$perpage&");
|
||||
print_paging_bar($totalnumber, $page, $perpage, $pageurl, 'qpage');
|
||||
|
||||
echo '<form method="post" action="edit.php">';
|
||||
echo '<fieldset class="invisiblefieldset" style="display: block;">';
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
echo $pageurl->hidden_params_out();
|
||||
echo $pageurl->hidden_params_out(array('qsortorder'));
|
||||
echo '<table id="categoryquestions" style="width: 100%"><tr>';
|
||||
echo "<th style=\"white-space:nowrap;\" class=\"header\" scope=\"col\">$straction</th>";
|
||||
|
||||
$sortoptions = array('name, qtype ASC' => get_string("sortalpha", "quiz"),
|
||||
'qtype, name ASC' => get_string("sorttypealpha", "quiz"),
|
||||
'id ASC' => get_string("sortage", "quiz"));
|
||||
$orderselect = choose_from_menu ($sortoptions, 'sortorder', $sortorder, false, 'this.form.submit();', '0', true);
|
||||
$orderselect = choose_from_menu ($sortoptions, 'qsortorder', $sortorder, false, 'this.form.submit();', '0', true);
|
||||
$orderselect .= '<noscript><div><input type="submit" value="'.get_string("sortsubmit", "quiz").'" /></div></noscript>';
|
||||
echo "<th style=\"white-space:nowrap; text-align: left;\" class=\"header\" scope=\"col\">$strquestionname $orderselect</th>
|
||||
<th style=\"white-space:nowrap; text-align: right;\" class=\"header\" scope=\"col\">$strtype</th>";
|
||||
|
@ -350,14 +349,13 @@ function question_list($course, $pageurl, $categoryid, $cm = null,
|
|||
}
|
||||
echo "</table>\n";
|
||||
|
||||
$paging = print_paging_bar($totalnumber, $page, $perpage,
|
||||
"edit.php?".$pageurl->get_query_string()."&perpage=$perpage&", 'page',
|
||||
$paging = print_paging_bar($totalnumber, $page, $perpage, $pageurl, 'qpage',
|
||||
false, true);
|
||||
if ($totalnumber > DEFAULT_QUESTIONS_PER_PAGE) {
|
||||
if ($perpage == DEFAULT_QUESTIONS_PER_PAGE) {
|
||||
$showall = '<a href="edit.php?'.$pageurl->get_query_string().'&perpage=1000">'.get_string('showall', 'moodle', $totalnumber).'</a>';
|
||||
$showall = '<a href="edit.php?'.$pageurl->get_query_string(array('qperpage'=>1000)).'">'.get_string('showall', 'moodle', $totalnumber).'</a>';
|
||||
} else {
|
||||
$showall = '<a href="edit.php?'.$pageurl->get_query_string().'&perpage=' . DEFAULT_QUESTIONS_PER_PAGE . '">'.get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE).'</a>';
|
||||
$showall = '<a href="edit.php?'.$pageurl->get_query_string(array('qperpage'=>DEFAULT_QUESTIONS_PER_PAGE)).'">'.get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE).'</a>';
|
||||
}
|
||||
if ($paging) {
|
||||
$paging = substr($paging, 0, strrpos($paging, '</div>'));
|
||||
|
@ -420,32 +418,9 @@ function question_list($course, $pageurl, $categoryid, $cm = null,
|
|||
* {@link http://maths.york.ac.uk/serving_maths}
|
||||
* @param moodle_url $pageurl object representing this pages url.
|
||||
*/
|
||||
function showbank($pageurl, $cm){
|
||||
function question_showbank($pageurl, $cm, $page, $perpage, $sortorder){
|
||||
global $SESSION, $COURSE;
|
||||
$page = optional_param('page', -1, PARAM_INT);
|
||||
$perpage = optional_param('perpage', -1, PARAM_INT);
|
||||
$sortorder = optional_param('sortorder', '');
|
||||
if (preg_match("/[';]/", $sortorder)) {
|
||||
error("Incorrect use of the parameter 'sortorder'");
|
||||
}
|
||||
|
||||
if ($page > -1) {
|
||||
$SESSION->questionpage = $page;
|
||||
} else {
|
||||
$page = isset($SESSION->questionpage) ? $SESSION->questionpage : 0;
|
||||
}
|
||||
|
||||
if ($perpage > -1) {
|
||||
$SESSION->questionperpage = $perpage;
|
||||
} else {
|
||||
$perpage = isset($SESSION->questionperpage) ? $SESSION->questionperpage : DEFAULT_QUESTIONS_PER_PAGE;
|
||||
}
|
||||
|
||||
if ($sortorder) {
|
||||
$SESSION->questionsortorder = $sortorder;
|
||||
} else {
|
||||
$sortorder = isset($SESSION->questionsortorder) ? $SESSION->questionsortorder : 'qtype, name ASC';
|
||||
}
|
||||
$SESSION->fromurl = $pageurl->out();
|
||||
|
||||
/// Now, check for commands on this page and modify variables as necessary
|
||||
|
@ -458,8 +433,8 @@ function showbank($pageurl, $cm){
|
|||
error(get_string('categorynoedit', 'quiz', $tocategory->name), $pageurl->out());
|
||||
}
|
||||
foreach ($_POST as $key => $value) { // Parse input for question ids
|
||||
if (substr($key, 0, 1) == "q") {
|
||||
$key = substr($key,1);
|
||||
if (preg_match('!q([0-9]+)!', $key, $matches)) {
|
||||
$key = $matches[1];
|
||||
if (!set_field('question', 'category', $tocategory->id, 'id', $key)) {
|
||||
error('Could not update category field');
|
||||
}
|
||||
|
@ -501,9 +476,8 @@ function showbank($pageurl, $cm){
|
|||
// an asterix in front of those that are in use
|
||||
$inuse = false; // set to true if at least one of the questions is in use
|
||||
foreach ($rawquestions as $key => $value) { // Parse input for question ids
|
||||
if (substr($key, 0, 1) == "q") {
|
||||
$key = substr($key,1);
|
||||
$questionlist .= $key.',';
|
||||
if (preg_match('!q([0-9]+)!', $key, $matches)) {
|
||||
$key = $matches[1]; $questionlist .= $key.',';
|
||||
if (record_exists('quiz_question_instances', 'question', $key) or
|
||||
record_exists('question_states', 'originalquestion', $key)) {
|
||||
$questionnames .= '* ';
|
||||
|
@ -586,4 +560,62 @@ function showbank($pageurl, $cm){
|
|||
|
||||
print_box_end();
|
||||
}
|
||||
/**
|
||||
* Common setup for all pages for editing questions.
|
||||
* @param boolean $requirecmid require cmid? default false
|
||||
* @param boolean $requirecourseid require courseid, if cmid is not given? default true
|
||||
* @return array $thispageurl, $courseid, $cmid, $cm, $module, $pagevars
|
||||
*/
|
||||
function question_edit_setup($requirecmid = false, $requirecourseid = true){
|
||||
$thispageurl = new moodle_url();
|
||||
if ($requirecmid){
|
||||
$cmid =required_param('cmid', PARAM_INT);
|
||||
} else {
|
||||
$cmid = optional_param('cmid', 0, PARAM_INT);
|
||||
}
|
||||
if ($cmid){
|
||||
list($module, $cm) = get_module_from_cmid($cmid);
|
||||
$courseid = $cm->course;
|
||||
$thispageurl->params(compact('cmid'));
|
||||
} else {
|
||||
$module = null;
|
||||
$cm = null;
|
||||
if ($requirecourseid){
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
} else {
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT);
|
||||
}
|
||||
if ($courseid){
|
||||
$thispageurl->params(compact('courseid'));
|
||||
}
|
||||
}
|
||||
|
||||
$pagevars['qpage'] = optional_param('qpage', -1, PARAM_INT);
|
||||
$pagevars['qperpage'] = optional_param('qperpage', -1, PARAM_INT);
|
||||
$pagevars['qsortorder'] = optional_param('qsortorder', '');
|
||||
|
||||
if (preg_match("/[';]/", $pagevars['qsortorder'])) {
|
||||
error("Incorrect use of the parameter 'qsortorder'");
|
||||
}
|
||||
|
||||
if ($pagevars['qpage'] > -1) {
|
||||
$thispageurl->param('qpage', $pagevars['qpage']);
|
||||
} else {
|
||||
$pagevars['qpage'] = 0;
|
||||
}
|
||||
|
||||
if ($pagevars['qperpage'] > -1) {
|
||||
$thispageurl->param('qperpage', $pagevars['qperpage']);
|
||||
} else {
|
||||
$pagevars['qperpage'] = DEFAULT_QUESTIONS_PER_PAGE;
|
||||
}
|
||||
|
||||
if ($pagevars['qsortorder']) {
|
||||
$thispageurl->param('qsortorder', $pagevars['qsortorder']);
|
||||
} else {
|
||||
$pagevars['qsortorder'] = 'qtype, name ASC';
|
||||
}
|
||||
return array($thispageurl, $courseid, $cmid, $cm, $module, $pagevars);
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
require_once("../config.php");
|
||||
require_once( "editlib.php" );
|
||||
|
||||
// get parameters
|
||||
list($thispageurl, $courseid, $cmid, $cm, $module, $pagevars) = question_edit_setup();
|
||||
|
||||
$categoryid = optional_param('category',0, PARAM_INT);
|
||||
$cattofile = optional_param('cattofile',0, PARAM_BOOL);
|
||||
$courseid = required_param('courseid',PARAM_INT);
|
||||
|
||||
$exportfilename = optional_param('exportfilename','',PARAM_FILE );
|
||||
$format = optional_param('format','', PARAM_FILE );
|
||||
|
||||
|
@ -41,7 +42,7 @@
|
|||
|
||||
if ($categoryid) { // update category in session variable
|
||||
$SESSION->questioncat = $categoryid;
|
||||
} else { // try to get category from modform
|
||||
} else { // try to get category from session
|
||||
if (isset($SESSION->questioncat)) {
|
||||
$categoryid = $SESSION->questioncat;
|
||||
}
|
||||
|
@ -73,20 +74,28 @@
|
|||
}
|
||||
|
||||
/// Header
|
||||
if (isset($SESSION->modform->instance) and $quiz = get_record('quiz', 'id', $SESSION->modform->instance)) {
|
||||
$strupdatemodule = has_capability('moodle/course:manageactivities', $context)
|
||||
? update_module_button($SESSION->modform->cmid, $course->id, $txt->modulename )
|
||||
if ($cm!==null) {
|
||||
$strupdatemodule = has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id))
|
||||
? update_module_button($cm->id, $course->id, get_string('modulename', $cm->modname))
|
||||
: "";
|
||||
print_header_simple($txt->exportquestions, '',
|
||||
"<a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">$txt->modulenameplural</a>".
|
||||
" -> <a href=\"$CFG->wwwroot/mod/quiz/view.php?q=$quiz->id\">".format_string($quiz->name).'</a>'.
|
||||
' -> '.$txt->exportquestions,
|
||||
"", "", true, $strupdatemodule);
|
||||
$crumbs = array();
|
||||
$crumbs[] = array('name' => get_string('modulenameplural', $cm->modname), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/index.php?id=$course->id", 'type' => 'activity');
|
||||
$crumbs[] = array('name' => format_string($module->name), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/view.php?cmid={$cm->id}", 'type' => 'title');
|
||||
$crumbs[] = array('name' => $txt->exportquestions, 'link' => '', 'type' => 'title');
|
||||
$navigation = build_navigation($crumbs);
|
||||
print_header_simple($txt->exportquestions, '', $navigation, "", "", true, $strupdatemodule);
|
||||
|
||||
$currenttab = 'edit';
|
||||
$mode = 'export';
|
||||
include($CFG->dirroot.'/mod/quiz/tabs.php');
|
||||
${$cm->modname} = $module;
|
||||
include($CFG->dirroot."/mod/$cm->modname/tabs.php");
|
||||
} else {
|
||||
print_header_simple($txt->exportquestions, '', $txt->exportquestions);
|
||||
// Print basic page layout.
|
||||
$crumbs = array();
|
||||
$crumbs[] = array('name' => $txt->exportquestions, 'link' => '', 'type' => 'title');
|
||||
$navigation = build_navigation($crumbs);
|
||||
|
||||
print_header_simple($txt->exportquestions, '', $navigation);
|
||||
// print tabs
|
||||
$currenttab = 'export';
|
||||
include('tabs.php');
|
||||
|
@ -116,15 +125,15 @@
|
|||
$qformat->setCattofile( $cattofile );
|
||||
|
||||
if (! $qformat->exportpreprocess()) { // Do anything before that we need to
|
||||
error( $txt->exporterror, "$CFG->wwwroot/question/export.php?courseid={$course->id}&category=$category->id");
|
||||
error( $txt->exporterror, $thispageurl->out(false, array('category'=>$category->id)));
|
||||
}
|
||||
|
||||
if (! $qformat->exportprocess()) { // Process the export data
|
||||
error( $txt->exporterror, "$CFG->wwwroot/question/export.php?courseid={$course->id}&category=$category->id");
|
||||
error( $txt->exporterror, $thispageurl->out(false, array('category'=>$category->id)));
|
||||
}
|
||||
|
||||
if (! $qformat->exportpostprocess()) { // In case anything needs to be done after
|
||||
error( $txt->exporterror, "$CFG->wwwroot/question/export.php?courseid={$course->id}&category=$category->id");
|
||||
error( $txt->exporterror, $thispageurl->out(false, array('category'=>$category->id)));
|
||||
}
|
||||
echo "<hr />";
|
||||
|
||||
|
@ -139,7 +148,7 @@
|
|||
echo "<p><div class=\"boxaligncenter\"><a href=\"$efile\">$txt->download</a></div></p>";
|
||||
echo "<p><div class=\"boxaligncenter\"><font size=\"-1\">$txt->downloadextra</font></div></p>";
|
||||
|
||||
print_continue("edit.php?courseid=$course->id");
|
||||
print_continue("edit.php?".$thispageurl->get_query_string());
|
||||
print_footer($course);
|
||||
exit;
|
||||
}
|
||||
|
@ -161,8 +170,7 @@
|
|||
<form enctype="multipart/form-data" method="post" action="export.php">
|
||||
<fieldset class="invisiblefieldset" style="display: block;">
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
|
||||
<input type="hidden" name="courseid" value="<?php echo $course->id; ?>" />
|
||||
|
||||
<?php echo $thispageurl->hidden_params_out(array(), 3); ?>
|
||||
<table cellpadding="5">
|
||||
<tr>
|
||||
<td align="right"><?php echo $txt->category; ?>:</td>
|
||||
|
|
|
@ -14,12 +14,13 @@
|
|||
require_once($CFG->libdir . '/uploadlib.php');
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
|
||||
list($thispageurl, $courseid, $cmid, $cm, $module, $pagevars) = question_edit_setup(false, false);
|
||||
|
||||
// get parameters
|
||||
$params = new stdClass;
|
||||
$params->choosefile = optional_param('choosefile','',PARAM_PATH);
|
||||
$categoryid = optional_param('category', 0, PARAM_INT);
|
||||
$catfromfile = optional_param('catfromfile', 0, PARAM_BOOL );
|
||||
$courseid = optional_param('courseid', 0, PARAM_INT);
|
||||
$format = optional_param('format','',PARAM_FILE);
|
||||
$params->matchgrades = optional_param('matchgrades','',PARAM_ALPHA);
|
||||
$params->stoponerror = optional_param('stoponerror', 0, PARAM_BOOL);
|
||||
|
@ -28,7 +29,6 @@
|
|||
$txt = new stdClass();
|
||||
$txt->category = get_string('category','quiz');
|
||||
$txt->choosefile = get_string('choosefile','quiz');
|
||||
$txt->editingquiz = get_string(isset($SESSION->modform->instance) ? "editingquiz" : "editquestions", "quiz");
|
||||
$txt->file = get_string('file');
|
||||
$txt->fileformat = get_string('fileformat','quiz');
|
||||
$txt->fromfile = get_string('fromfile','quiz');
|
||||
|
@ -58,7 +58,7 @@
|
|||
|
||||
if ($categoryid) { // update category in session variable
|
||||
$SESSION->questioncat = $categoryid;
|
||||
} else { // try to get category from modform
|
||||
} else { // try to get category from session
|
||||
if (isset($SESSION->questioncat)) {
|
||||
$categoryid = $SESSION->questioncat;
|
||||
}
|
||||
|
@ -94,20 +94,28 @@
|
|||
// PAGE HEADER
|
||||
//==========
|
||||
|
||||
if (isset($SESSION->modform->instance) and $quiz = get_record('quiz', 'id', $SESSION->modform->instance)) {
|
||||
$strupdatemodule = has_capability('moodle/course:manageactivities', $context)
|
||||
? update_module_button($SESSION->modform->cmid, $course->id, $txt->modulename)
|
||||
if ($cm!==null) {
|
||||
$strupdatemodule = has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id))
|
||||
? update_module_button($cm->id, $course->id, get_string('modulename', $cm->modname))
|
||||
: "";
|
||||
print_header_simple($txt->importquestions, '',
|
||||
"<a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">".$txt->modulenameplural.'</a>'.
|
||||
" -> <a href=\"$CFG->wwwroot/mod/quiz/view.php?q=$quiz->id\">".format_string($quiz->name).'</a>'.
|
||||
' -> '.$txt->importquestions,
|
||||
"", "", true, $strupdatemodule);
|
||||
$crumbs = array();
|
||||
$crumbs[] = array('name' => get_string('modulenameplural', $cm->modname), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/index.php?id=$course->id", 'type' => 'activity');
|
||||
$crumbs[] = array('name' => format_string($module->name), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/view.php?cmid={$cm->id}", 'type' => 'title');
|
||||
$crumbs[] = array('name' => $txt->importquestions, 'link' => '', 'type' => 'title');
|
||||
$navigation = build_navigation($crumbs);
|
||||
print_header_simple($txt->importquestions, '', $navigation, "", "", true, $strupdatemodule);
|
||||
|
||||
$currenttab = 'edit';
|
||||
$mode = 'import';
|
||||
include($CFG->dirroot.'/mod/quiz/tabs.php');
|
||||
${$cm->modname} = $module;
|
||||
include($CFG->dirroot."/mod/$cm->modname/tabs.php");
|
||||
} else {
|
||||
print_header_simple($txt->importquestions, '', $txt->importquestions);
|
||||
// Print basic page layout.
|
||||
$crumbs = array();
|
||||
$crumbs[] = array('name' => $txt->importquestions, 'link' => '', 'type' => 'title');
|
||||
$navigation = build_navigation($crumbs);
|
||||
|
||||
print_header_simple($txt->importquestions, '', $navigation);
|
||||
// print tabs
|
||||
$currenttab = 'import';
|
||||
include('tabs.php');
|
||||
|
@ -130,8 +138,7 @@
|
|||
else {
|
||||
notify($txt->uploadproblem);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// must be upload file
|
||||
if (empty($_FILES['newfile'])) {
|
||||
notify( $txt->uploadproblem );
|
||||
|
@ -168,24 +175,21 @@
|
|||
|
||||
// Do anything before that we need to
|
||||
if (! $qformat->importpreprocess()) {
|
||||
error( $txt->importerror ,
|
||||
"$CFG->wwwroot/question/import.php?courseid={$course->id}&category=$category->id");
|
||||
error( $txt->importerror, $thispageurl->out(false, array('category'=>$category->id)));
|
||||
}
|
||||
|
||||
// Process the uploaded file
|
||||
if (! $qformat->importprocess() ) {
|
||||
error( $txt->importerror ,
|
||||
"$CFG->wwwroot/question/import.php?courseid={$course->id}&category=$category->id");
|
||||
error( $txt->importerror, $thispageurl->out(false, array('category'=>$category->id)));
|
||||
}
|
||||
|
||||
// In case anything needs to be done after
|
||||
if (! $qformat->importpostprocess()) {
|
||||
error( $txt->importerror ,
|
||||
"$CFG->wwwroot/question/import.php?courseid={$course->id}&category=$category->id");
|
||||
error( $txt->importerror, $thispageurl->out(false, array('category'=>$category->id)));
|
||||
}
|
||||
|
||||
echo "<hr />";
|
||||
print_continue("edit.php?courseid=$course->id");
|
||||
print_continue("edit.php?".$thispageurl->get_query_string());
|
||||
print_footer($course);
|
||||
exit;
|
||||
}
|
||||
|
@ -210,6 +214,7 @@
|
|||
<form id="form" enctype="multipart/form-data" method="post" action="import.php">
|
||||
<fieldset class="invisiblefieldset" style="display: block;">
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
|
||||
<?php echo $thispageurl->hidden_params_out(array(), 3); ?>
|
||||
<?php print_simple_box_start("center"); ?>
|
||||
<table cellpadding="5">
|
||||
<tr>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue