Added a second row of tabs to the Edit tab: Questions, Categories, Import, Export, Settings

Added phpdoc header to some files
Improved language string and help file for decimal digits on grades
This commit is contained in:
gustav_delius 2006-02-09 13:57:22 +00:00
parent 4eedc50cbc
commit c4adc2c493
7 changed files with 195 additions and 40 deletions

View file

@ -1,5 +1,13 @@
<?php // $Id$
// Allows a teacher to create, edit and delete categories
/**
* Allows a teacher to create, edit and delete categories
*
* @version $Id$
* @author Martin Dougiamas and many others.
* {@link http://moodle.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package quiz
*/
require_once("../../config.php");
require_once("locallib.php");
@ -34,8 +42,25 @@
error("Only teachers authorized to edit the course '{$course->fullname}' can use this page!");
}
/// Header:
if (isset($SESSION->modform->instance) and $quiz = get_record('quiz', 'id', $SESSION->modform->instance)) {
$strupdatemodule = isteacheredit($course->id)
? update_module_button($SESSION->modform->cmid, $course->id, get_string('modulename', 'quiz'))
: "";
print_header_simple(get_string('editcategories', 'quiz'), '',
"<a href=\"index.php?id=$course->id\">".get_string('modulenameplural', 'quiz').'</a>'.
" -> <a href=\"view.php?q=$quiz->id\">".format_string($quiz->name).'</a>'.
' -> '.get_string('editcategories', 'quiz'),
"", "", true, $strupdatemodule);
$currenttab = 'edit';
$mode = 'categories';
include('tabs.php');
} else {
print_header_simple(get_string('editcategories', 'quiz'), '',
"<a href=\"index.php?id=$course->id\">".get_string('modulenameplural', 'quiz').'</a>'.
'-> <a href="edit.php">'.get_string('editquestions', 'quiz').'</a>'.
' -> '.get_string('editcategories', 'quiz'));
}
$qcobject = new quiz_category_object();

View file

@ -240,7 +240,7 @@
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("decimalpoints", "quiz") ?>:</b></td>
<td align="right"><b><?php print_string("decimaldigits", "quiz") ?>:</b></td>
<td>
<?php
unset($options);
@ -249,7 +249,7 @@
$options[2] = '2';
$options[3] = '3';
choose_from_menu ($options, "decimalpoints", $form->decimalpoints, "", "", "");
helpbutton("decimalpoints", get_string("decimalpoints","quiz"), "quiz");
helpbutton("decimalpoints", get_string("decimaldigits","quiz"), "quiz");
?>
</td>
<td align="center">

View file

@ -405,6 +405,7 @@ if (self.name == 'editquestion') {
true, $strupdatemodule);
$currenttab = 'edit';
$mode = 'editq';
$quiz = &$modform;
include('tabs.php');
@ -457,6 +458,7 @@ if (self.name == 'editquestion') {
"", "", true, $strupdatemodule);
$currenttab = 'edit';
$mode = 'editq';
$quiz = &$modform;
include('tabs.php');

View file

@ -1,26 +1,42 @@
<?php // $Id$
// Import quiz questions into the given category
/**
* Export quiz questions into the given category
*
* @version $Id$
* @author Martin Dougiamas, Howard Miller, and many others.
* {@link http://moodle.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package quiz
*/
require_once("../../config.php");
require_once("locallib.php");
require_once("locallib.php"); // TODO: this should not need locallib.php
require_once('questionlib.php');
$category = required_param('category',PARAM_INT);
$categoryid = optional_param('category',0, PARAM_INT);
$courseid = required_param('courseid',PARAM_INT);
$format = optional_param('format','', PARAM_CLEANFILE );
$exportfilename = optional_param('exportfilename','',PARAM_CLEANFILE );
if (! $category = get_record("quiz_categories", "id", $category)) {
error("This wasn't a valid category!");
if (! $course = get_record("course", "id", $courseid)) {
error("Course does not exist!");
}
if (!$categoryid) { // need to get category from modform
$showcatmenu = true; // will ensure that user can choose category
if (isset($SESSION->modform)) {
$categoryid = $SESSION->modform->category;
}
}
if (! $category = get_record("quiz_categories", "id", $categoryid)) {
$category = quiz_get_default_category($courseid);
}
if (! $categorycourse = get_record("course", "id", $category->course)) {
error("This category doesn't belong to a valid course!");
}
if (! $course = get_record("course", "id", $courseid)) {
error("Course does not exist!");
}
require_login($course->id, false);
if (!isteacher($course->id)) {
@ -37,9 +53,27 @@
$streditingquiz = get_string(isset($SESSION->modform->instance) ? "editingquiz" : "editquestions", "quiz");
$dirname = get_string("exportfilename","quiz");
print_header_simple("$strexportquestions", "$strexportquestions",
"<a href=\"$CFG->wwwroot/mod/$dirname/index.php?id=$course->id\">$strquizzes</a>".
" -> <a href=\"edit.php\">$streditingquiz</a> -> $strexportquestions");
/// Header:
if (isset($SESSION->modform->instance) and $quiz = get_record('quiz', 'id', $SESSION->modform->instance)) {
$strupdatemodule = isteacheredit($course->id)
? update_module_button($SESSION->modform->cmid, $course->id, get_string('modulename', 'quiz'))
: "";
print_header_simple($strexportquestions, '',
"<a href=\"index.php?id=$course->id\">".get_string('modulenameplural', 'quiz').'</a>'.
" -> <a href=\"view.php?q=$quiz->id\">".format_string($quiz->name).'</a>'.
' -> '.$strexportquestions,
"", "", true, $strupdatemodule);
$currenttab = 'edit';
$mode = 'export';
include('tabs.php');
} else {
print_header_simple($strexportquestions, '',
"<a href=\"index.php?id=$course->id\">".get_string('modulenameplural', 'quiz').'</a>'.
'-> <a href="edit.php">'.get_string('editquestions', 'quiz').'</a>'.
' -> '.$strexportquestions);
}
if (!empty($format)) { /// Filename
@ -101,6 +135,20 @@
$exportfilename = default_export_filename($course, $category);
}
/// Get all the existing categories now
if (!$categories = get_records_select("quiz_categories", "course = '{$course->id}' OR publish = '1'", "parent, sortorder, name ASC")) {
error("Could not find any question categories!");
}
$categories = add_indented_names($categories);
foreach ($categories as $key => $cat) {
if ($catcourse = get_record("course", "id", $cat->course)) {
if ($cat->publish && $cat->course != $course->id) {
$cat->indentedname .= " ($catcourse->shortname)";
}
$catmenu[$cat->id] = $cat->indentedname;
}
}
print_heading_with_help($strexportquestions, "export", "quiz");
print_simple_box_start("center");
@ -111,7 +159,13 @@
echo "<tr><td align=\"right\">\n";
print_string("category", "quiz");
echo ":</td><td>";
echo str_replace('&nbsp;', '', $category->name) . " ($categorycourse->shortname)";
if (!$showcatmenu) { // category already specified
echo quiz_get_category_coursename($category);
echo " <input type=\"hidden\" name=\"category\" value=\"$category->id\" />";
} else { // no category specified, let user choose
choose_from_menu($catmenu, "category", $category->id, "");
}
//echo str_replace('&nbsp;', '', $category->name) . " ($categorycourse->shortname)";
echo "</td></tr>\n";
echo "<tr><td align=\"right\">";
@ -128,7 +182,6 @@
echo "</td></tr>\n";
echo "<tr><td align=\"center\" colspan=\"2\">";
echo " <input type=\"hidden\" name=\"category\" value=\"$category->id\" />";
echo " <input type=\"hidden\" name=\"courseid\" value=\"$course->id\" />";
echo " <input type=\"submit\" name=\"save\" value=\"".get_string("exportquestions","quiz")."\" />";
echo "</td></tr>\n";

View file

@ -1,14 +1,35 @@
<?php // $Id$
// Import quiz questions into the given category
/**
* Import quiz questions into the given category
*
* @version $Id$
* @author Martin Dougiamas, Howard Miller, and many others.
* {@link http://moodle.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package quiz
*/
require_once("../../config.php");
require_once("locallib.php");
require_once("locallib.php"); // TODO: this should not need locallib.php
require_once('questionlib.php');
$category = required_param('category', PARAM_INT);
$categoryid = optional_param('category', 0, PARAM_INT);
$courseid = optional_param('course', 0, PARAM_INT);
$format = optional_param('format','',PARAM_CLEANFILE);
if (! $category = get_record("quiz_categories", "id", $category)) {
error("This wasn't a valid category!");
if (!$categoryid) { // need to get category from modform
$showcatmenu = true; // will ensure that user can choose category
if (isset($SESSION->modform)) {
$categoryid = $SESSION->modform->category;
}
}
if (! $category = get_record("quiz_categories", "id", $categoryid)) {
if ($courseid) {
$category = quiz_get_default_category($courseid);
} else {
error("No category specified");
}
}
if (! $course = get_record("course", "id", $category->course)) {
@ -31,9 +52,28 @@
$strquizzes = get_string('modulenameplural', 'quiz');
$streditingquiz = get_string(isset($SESSION->modform->instance) ? "editingquiz" : "editquestions", "quiz");
print_header_simple("$strimportquestions", "$strimportquestions",
"<a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes</a>".
" -> <a href=\"edit.php\">$streditingquiz</a> -> $strimportquestions");
/// Header:
if (isset($SESSION->modform->instance) and $quiz = get_record('quiz', 'id', $SESSION->modform->instance)) {
$strupdatemodule = isteacheredit($course->id)
? update_module_button($SESSION->modform->cmid, $course->id, get_string('modulename', 'quiz'))
: "";
print_header_simple($strimportquestions, '',
"<a href=\"index.php?id=$course->id\">".get_string('modulenameplural', 'quiz').'</a>'.
" -> <a href=\"view.php?q=$quiz->id\">".format_string($quiz->name).'</a>'.
' -> '.$strimportquestions,
"", "", true, $strupdatemodule);
$currenttab = 'edit';
$mode = 'import';
include('tabs.php');
} else {
print_header_simple($strimportquestions, '',
"<a href=\"index.php?id=$course->id\">".get_string('modulenameplural', 'quiz').'</a>'.
'-> <a href="edit.php">'.get_string('editquestions', 'quiz').'</a>'.
' -> '.$strimportquestions);
}
if (!empty($format)) { /// Filename
@ -89,6 +129,20 @@
print_heading_with_help($strimportquestions, "import", "quiz");
/// Get all the existing categories now
if (!$categories = get_records_select("quiz_categories", "course = '{$course->id}' OR publish = '1'", "parent, sortorder, name ASC")) {
error("Could not find any question categories!");
}
$categories = add_indented_names($categories);
foreach ($categories as $key => $cat) {
if ($catcourse = get_record("course", "id", $cat->course)) {
if ($cat->publish && $cat->course != $course->id) {
$cat->indentedname .= " ($catcourse->shortname)";
}
$catmenu[$cat->id] = $cat->indentedname;
}
}
print_simple_box_start("center");
echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"import.php\">\n";
echo "<input type=\"hidden\" name=\"sesskey\" value=\"" . sesskey() . "\" />\n";
@ -97,8 +151,12 @@
echo "<tr><td align=\"right\">";
print_string("category", "quiz");
echo ":</td><td>";
// choose_from_menu($categories, "category", "$category->id", "");
echo quiz_get_category_coursename($category);
if (!showcatmenu) { // category already specified
echo quiz_get_category_coursename($category);
echo " <input type=\"hidden\" name=\"category\" value=\"$category->id\" />";
} else { // no category specified, let user choose
choose_from_menu($catmenu, "category", $category->id, "");
}
echo "</tr>\n";
echo "<tr><td align=\"right\">";
@ -114,7 +172,6 @@
require_once($CFG->dirroot.'/lib/uploadlib.php');
upload_print_form_fragment(1,array('newfile'),null,false,null,$course->maxbytes,0,false);
echo "</tr><tr><td>&nbsp;</td><td>";
echo " <input type=\"hidden\" name=\"category\" value=\"$category->id\" />";
echo " <input type=\"submit\" name=\"save\" value=\"".get_string("uploadthisfile")."\" />";
echo "</td></tr>\n";

View file

@ -306,7 +306,7 @@
<?php if (!$CFG->quiz_fix_decimalpoints) { ?>
<tr valign="top">
<td align="right"><b><?php print_string("decimalpoints", "quiz") ?>:</b></td>
<td align="right"><b><?php print_string("decimaldigits", "quiz") ?>:</b></td>
<td align="left">
<?php
unset($options);
@ -315,7 +315,7 @@
$options[2] = '2';
$options[3] = '3';
choose_from_menu($options, "decimalpoints", "$form->decimalpoints", "");
helpbutton("decimalpoints", get_string("decimalpoints","quiz"), "quiz");
helpbutton("decimalpoints", get_string("decimaldigits","quiz"), "quiz");
?>
</td>
</tr>
@ -558,7 +558,7 @@
<?php if ($CFG->quiz_fix_decimalpoints) { ?>
<tr valign="top">
<td align="right"><b><?php print_string("decimalpoints", "quiz") ?>:</b></td>
<td align="right"><b><?php print_string("decimaldigits", "quiz") ?>:</b></td>
<td align="left">
<?php
unset($options);
@ -567,7 +567,7 @@
$options[2] = '2';
$options[3] = '3';
choose_from_menu($options, "decimalpoints", "$form->decimalpoints", "");
helpbutton("decimalpoints", get_string("decimalpoints","quiz"), "quiz");
helpbutton("decimalpoints", get_string("decimaldigits","quiz"), "quiz");
?>
</td>
</tr>
@ -658,12 +658,8 @@
<input type="hidden" name="modulename" value="<?php p($form->modulename) ?>" />
<input type="hidden" name="instance" value="<?php p($form->instance) ?>" />
<input type="hidden" name="mode" value="<?php p($form->mode) ?>" />
<input type="submit" value="<?php print_string("savechanges") ?>" />
<!-- provide an additional button to edit questions -->
<?php if ($form->instance) { ?>
<input type="hidden" name="redirecturl" value="<?php p("$CFG->wwwroot/mod/quiz/edit.php?quizid=$form->instance") ?>" />
<input type="submit" name="redirect" value="<?php print_string('saveandedit', 'quiz') ?>" />
<?php } ?>
<input type="submit" name="redirect" value="<?php print_string("savechanges") ?>" />
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
</center>
</form>

View file

@ -1,4 +1,12 @@
<?php // $Id$
/**
* Sets up the tabs used by the quiz pages for teachers.
*
* @version $Id$
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package quiz
*/
/// This file to be included so we can assume config.php has already been included.
if (empty($quiz)) {
@ -22,11 +30,10 @@
$row[] = new tabobject('info', "view.php?q=$quiz->id", get_string('info', 'quiz'));
$row[] = new tabobject('reports', "report.php?q=$quiz->id", get_string('reports', 'quiz'));
$row[] = new tabobject('preview', "attempt.php?q=$quiz->id", get_string('preview', 'quiz'));
$row[] = new tabobject('preview', "attempt.php?q=$quiz->id", get_string('preview', 'quiz'), get_string('previewquiz', 'quiz', format_string($quiz->name)));
if (isteacheredit($course->id)) {
$row[] = new tabobject('edit', "edit.php?quizid=$quiz->id", get_string('editquiz', 'quiz'));
$row[] = new tabobject('edit', "edit.php?quizid=$quiz->id", get_string('edit'), get_string('editquizquestions', 'quiz'));
$row[] = new tabobject('manualgrading', "grading.php?quizid=$quiz->id", get_string("manualgrading", "quiz"));
//$row[] = new tabobject('update', "$CFG->wwwroot/course/mod.php?update=$cm->id&amp;sesskey=$USER->sesskey", get_string('updatethis', '', get_string('modulename', 'quiz')));
}
$tabs[] = $row;
@ -54,6 +61,21 @@
$tabs[] = $row;
}
if ($currenttab == 'edit' and isset($mode)) {
$inactive[] = 'edit';
$row = array();
$currenttab = $mode;
$row[] = new tabobject('editq', "edit.php?quizid=$quiz->id", get_string('questions', 'quiz'), get_string('editquizquestions', 'quiz'));
$row[] = new tabobject('categories', "category.php?id=$course->id", get_string('categories', 'quiz'), get_string('editqcats', 'quiz'));
$row[] = new tabobject('import', "import.php", get_string('import', 'quiz'), get_string('importquestions', 'quiz'));
$row[] = new tabobject('export', "export.php?courseid=$course->id", get_string('export', 'quiz'), get_string('exportquestions', 'quiz'));
$row[] = new tabobject('update', "$CFG->wwwroot/course/mod.php?update=$cm->id&amp;sesskey=$USER->sesskey", get_string('settings'), get_string('updatesettings'));
$tabs[] = $row;
}
print_tabs($tabs, $currenttab, $inactive);
?>