mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-8946 - Fix a regression that broke question export.
This commit is contained in:
parent
b0abd2821b
commit
d187f66046
@ -555,6 +555,25 @@ function question_delete_course($course, $feedback=true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function questionbank_navigation_tabs(&$row, $context, $courseid) {
|
||||
global $CFG;
|
||||
if (has_capability('moodle/question:manage', $context)) {
|
||||
$row[] = new tabobject('questions', "$CFG->wwwroot/question/edit.php?courseid=$courseid", get_string('questions', 'quiz'), get_string('editquestions', "quiz"));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/question:managecategory', $context)) {
|
||||
$row[] = new tabobject('categories', "$CFG->wwwroot/question/category.php?id=$courseid", get_string('categories', 'quiz'), get_string('editqcats', 'quiz'));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/question:import', $context)) {
|
||||
$row[] = new tabobject('import', "$CFG->wwwroot/question/import.php?course=$courseid", get_string('import', 'quiz'), get_string('importquestions', 'quiz'));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/question:export', $context)) {
|
||||
$row[] = new tabobject('export', "$CFG->wwwroot/question/export.php?courseid=$courseid", get_string('export', 'quiz'), get_string('exportquestions', 'quiz'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Private function to factor common code out of get_question_options().
|
||||
*
|
||||
|
@ -83,26 +83,10 @@
|
||||
|
||||
$strquizzes = get_string('modulenameplural', 'quiz');
|
||||
$strquiz = get_string('modulename', 'quiz');
|
||||
$streditingquestions = get_string('editquestions', "quiz");
|
||||
$streditingquiz = get_string("editinga", "moodle", $strquiz);
|
||||
$strupdate = get_string('updatethis', 'moodle', $strquiz);
|
||||
$row[] = new tabobject('editq', "$CFG->wwwroot/mod/quiz/edit.php?quizid=$quiz->id", $strquiz, $streditingquiz);
|
||||
|
||||
if (has_capability('moodle/question:manage', $context)) {
|
||||
$row[] = new tabobject('questions', "$CFG->wwwroot/question/edit.php?courseid=$course->id", get_string('questions', 'quiz'), $streditingquestions);
|
||||
}
|
||||
|
||||
if (has_capability('moodle/question:managecategory', $context)) {
|
||||
$row[] = new tabobject('categories', "$CFG->wwwroot/question/category.php?id=$course->id", get_string('categories', 'quiz'), get_string('editqcats', 'quiz'));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/question:import', $context)) {
|
||||
$row[] = new tabobject('import', "$CFG->wwwroot/question/import.php?course=$course->id", get_string('import', 'quiz'), get_string('importquestions', 'quiz'));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/question:export', $context)) {
|
||||
$row[] = new tabobject('export', "$CFG->wwwroot/question/export.php?courseid=$course->id", get_string('export', 'quiz'), get_string('exportquestions', 'quiz'));
|
||||
}
|
||||
questionbank_navigation_tabs($row, $context, $course->id);
|
||||
$tabs[] = $row;
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ class question_category_object {
|
||||
|
||||
// wrap the table in a form and output it
|
||||
echo '<form action="category.php" method="post">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
echo '<fieldset class="invisiblefieldset" style="display: block">';
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />";
|
||||
echo '<input type="hidden" name="id" value="'. $this->course->id . '" />';
|
||||
echo '<input type="hidden" name="addcategory" value="true" />';
|
||||
|
@ -19,7 +19,7 @@
|
||||
$exportfilename = optional_param('exportfilename','',PARAM_FILE );
|
||||
$format = optional_param('format','', PARAM_FILE );
|
||||
|
||||
|
||||
|
||||
// get display strings
|
||||
$txt = new object;
|
||||
$txt->category = get_string('category','quiz');
|
||||
@ -32,32 +32,31 @@
|
||||
$txt->exportcategory = get_string('exportcategory','quiz');
|
||||
$txt->modulename = get_string('modulename','quiz');
|
||||
$txt->modulenameplural = get_string('modulenameplural','quiz');
|
||||
$txt->nocategory = get_string('nocategory','quiz');
|
||||
$txt->tofile = get_string('tofile','quiz');
|
||||
|
||||
|
||||
if (! $course = get_record("course", "id", $courseid)) {
|
||||
if (!$course = get_record("course", "id", $courseid)) {
|
||||
error("Course does not exist!");
|
||||
}
|
||||
|
||||
$showcatmenu = false;
|
||||
if ($categoryid) { // update category in session variable
|
||||
$SESSION->questioncat = $categoryid;
|
||||
} else { // try to get category from modform
|
||||
$showcatmenu = true; // will ensure that user can choose category
|
||||
if (isset($SESSION->questioncat)) {
|
||||
$categoryid = $SESSION->questioncat;
|
||||
}
|
||||
}
|
||||
|
||||
$category = get_default_question_category($courseid);
|
||||
|
||||
if (! $categorycourse = get_record("course", "id", $category->course)) {
|
||||
error( $txt->nocategory );
|
||||
if (!$category = get_record("question_categories", "id", $categoryid)) {
|
||||
$category = get_default_question_category($courseid);
|
||||
}
|
||||
|
||||
if (!$categorycourse = get_record("course", "id", $category->course)) {
|
||||
print_error('nocategory','quiz');
|
||||
}
|
||||
|
||||
require_login($course->id, false);
|
||||
|
||||
|
||||
// check role capability
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('moodle/question:export', $context);
|
||||
@ -95,8 +94,8 @@
|
||||
error( "Format not known ($format)" ); }
|
||||
|
||||
// load parent class for import/export
|
||||
require("format.php");
|
||||
|
||||
require("format.php");
|
||||
|
||||
// and then the class for the selected format
|
||||
require("format/$format/format.php");
|
||||
|
||||
@ -148,55 +147,49 @@
|
||||
}
|
||||
|
||||
print_heading_with_help($txt->exportquestions, 'export', 'quiz');
|
||||
print_simple_box_start('center');
|
||||
?>
|
||||
print_simple_box_start('center');
|
||||
?>
|
||||
|
||||
<form enctype="multipart/form-data" method="post" action="export.php">
|
||||
<fieldset class="invisiblefieldset">
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
|
||||
<input type="hidden" name="courseid" value="<?php echo $course->id; ?>" />
|
||||
|
||||
<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; ?>" />
|
||||
|
||||
<table cellpadding="5">
|
||||
<tr>
|
||||
<td align="right"><?php echo $txt->category; ?>:</td>
|
||||
<td>
|
||||
<?php
|
||||
if (!$showcatmenu) { // category already specified
|
||||
echo '<strong>'.question_category_coursename($category).'</strong> '; ?>
|
||||
<input type="hidden" name="category" value="<?php echo $category->id ?>" />
|
||||
<?php
|
||||
} else { // no category specified, let user choose
|
||||
question_category_select_menu($course->id, true, false, $category->id);
|
||||
}
|
||||
echo $txt->tofile; ?>
|
||||
<input name="cattofile" type="checkbox" />
|
||||
<?php helpbutton('exportcategory', $txt->exportcategory, 'quiz'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><?php echo $txt->fileformat; ?>:</td>
|
||||
<td>
|
||||
<?php choose_from_menu($fileformatnames, 'format', 'gift', '');
|
||||
helpbutton('export', $txt->exportquestions, 'quiz'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><?php echo $txt->exportname; ?>:</td>
|
||||
<td>
|
||||
<input type="text" size="40" name="exportfilename" value="<?php echo $exportfilename; ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" >
|
||||
<input type="submit" name="save" value="<?php echo $txt->exportquestions; ?>" />
|
||||
</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</form>
|
||||
<?php
|
||||
question_category_select_menu($course->id, true, false, $category->id);
|
||||
echo $txt->tofile; ?>
|
||||
<input name="cattofile" type="checkbox" />
|
||||
<?php helpbutton('exportcategory', $txt->exportcategory, 'quiz'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><?php echo $txt->fileformat; ?>:</td>
|
||||
<td>
|
||||
<?php choose_from_menu($fileformatnames, 'format', 'gift', '');
|
||||
helpbutton('export', $txt->exportquestions, 'quiz'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><?php echo $txt->exportname; ?>:</td>
|
||||
<td>
|
||||
<input type="text" size="40" name="exportfilename" value="<?php echo $exportfilename; ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" >
|
||||
<input type="submit" name="save" value="<?php echo $txt->exportquestions; ?>" />
|
||||
</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
|
||||
print_simple_box_end();
|
||||
print_footer($course);
|
||||
?>
|
||||
|
@ -43,7 +43,6 @@
|
||||
$txt->matchgradesnearest = get_string('matchgradesnearest','quiz');
|
||||
$txt->modulename = get_string('modulename','quiz');
|
||||
$txt->modulenameplural = get_string('modulenameplural','quiz');
|
||||
$txt->nocategory = get_string('nocategory','quiz');
|
||||
$txt->onlyteachersimport = get_string('onlyteachersimport','quiz');
|
||||
$txt->questions = get_string("questions", "quiz");
|
||||
$txt->quizzes = get_string('modulenameplural', 'quiz');
|
||||
@ -60,18 +59,17 @@
|
||||
if ($categoryid) { // update category in session variable
|
||||
$SESSION->questioncat = $categoryid;
|
||||
} else { // try to get category from modform
|
||||
$showcatmenu = true; // will ensure that user can choose category
|
||||
if (isset($SESSION->questioncat)) {
|
||||
$categoryid = $SESSION->questioncat;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $category = get_record("question_categories", "id", $categoryid)) {
|
||||
if (!$category = get_record("question_categories", "id", $categoryid)) {
|
||||
// if no valid category was given, use the default category
|
||||
if ($courseid) {
|
||||
$category = get_default_question_category($courseid);
|
||||
} else {
|
||||
error( $txt->nocategory );
|
||||
print_error('nocategory','quiz');
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,13 +77,14 @@
|
||||
$courseid = $category->course;
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", $courseid)) {
|
||||
if (!$course = get_record("course", "id", $courseid)) {
|
||||
error("Invalid course!");
|
||||
}
|
||||
|
||||
require_login($course->id, false);
|
||||
|
||||
require_capability('moodle/question:import', get_context_instance(CONTEXT_COURSE, $course->id));
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('moodle/question:import', $context);
|
||||
|
||||
// ensure the files area exists for this course
|
||||
make_upload_directory( "$course->id" );
|
||||
@ -96,7 +95,7 @@
|
||||
//==========
|
||||
|
||||
if (isset($SESSION->modform->instance) and $quiz = get_record('quiz', 'id', $SESSION->modform->instance)) {
|
||||
$strupdatemodule = has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id))
|
||||
$strupdatemodule = has_capability('moodle/course:manageactivities', $context)
|
||||
? update_module_button($SESSION->modform->cmid, $course->id, $txt->modulename)
|
||||
: "";
|
||||
print_header_simple($txt->importquestions, '',
|
||||
@ -209,7 +208,7 @@
|
||||
?>
|
||||
|
||||
<form id="form" enctype="multipart/form-data" method="post" action="import.php">
|
||||
<fieldset class="invisiblefieldset">
|
||||
<fieldset class="invisiblefieldset" style="display: block;">
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
|
||||
<?php print_simple_box_start("center"); ?>
|
||||
<table cellpadding="5">
|
||||
|
@ -141,8 +141,8 @@
|
||||
redirect("edit.php?courseid=$course->id");
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['cat'])) { /// coming from category selection drop-down menu
|
||||
$SESSION->questioncat = required_param('cat', PARAM_INT);
|
||||
if ($categoryid = optional_param('cat', 0, PARAM_INT)) { /// coming from category selection drop-down menu
|
||||
$SESSION->questioncat = $categoryid;
|
||||
$page = 0;
|
||||
$SESSION->questionpage = 0;
|
||||
}
|
||||
|
@ -16,16 +16,11 @@
|
||||
}
|
||||
|
||||
$tabs = array();
|
||||
$row = array();
|
||||
$inactive = array();
|
||||
|
||||
$row[] = new tabobject('questions', "$CFG->wwwroot/question/edit.php?courseid=$course->id", get_string('questions', 'quiz'), get_string('editquizquestions', 'quiz'));
|
||||
$row[] = new tabobject('categories', "$CFG->wwwroot/question/category.php?id=$course->id", get_string('categories', 'quiz'), get_string('editqcats', 'quiz'));
|
||||
$row[] = new tabobject('import', "$CFG->wwwroot/question/import.php?course=$course->id", get_string('import', 'quiz'), get_string('importquestions', 'quiz'));
|
||||
$row[] = new tabobject('export', "$CFG->wwwroot/question/export.php?courseid=$course->id", get_string('export', 'quiz'), get_string('exportquestions', 'quiz'));
|
||||
|
||||
$row = array();
|
||||
questionbank_navigation_tabs($row, $context, $course->id);
|
||||
$tabs[] = $row;
|
||||
|
||||
print_tabs($tabs, $currenttab, $inactive);
|
||||
print_tabs($tabs, $currenttab, array());
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user