Permalink
Browse files

Brought in line with HEAD version to get rid of data_submitted() func…

…tion.

A bit of HTML cleaning up too. Fixes incompatibility with secureforms.
  • Loading branch information...
1 parent 4483596 commit b87c2adc76f00571d28630b33b8e24ae8c85df2c thepurpleblob committed Nov 4, 2005
Showing with 31 additions and 27 deletions.
  1. +1 −1 mod/quiz/editlib.php
  2. +30 −26 mod/quiz/export.php
@@ -509,7 +509,7 @@ function quiz_print_cat_question_list($course, $categoryid, $quizid,
helpbutton("import", $strimportquestions, "quiz");
echo ' | ';
}
- echo "<a href=\"export.php?category={$category->id}&amp;course={$course->id}\">$strexportquestions</a>";
+ echo "<a href=\"export.php?category={$category->id}&amp;courseid={$course->id}\">$strexportquestions</a>";
helpbutton("export", $strexportquestions, "quiz");
echo '</font></td></tr>';
View
@@ -4,10 +4,10 @@
require_once("../../config.php");
require_once("locallib.php");
- require_variable($category);
- $courseid = required_param('course',PARAM_INT);
- optional_variable($format);
-
+ $category = required_param('category',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!");
@@ -17,7 +17,7 @@
error("This category doesn't belong to a valid course!");
}
- if (! $course = get_record("course", "id", $courseid )) {
+ if (! $course = get_record("course", "id", $courseid)) {
error("Course does not exist!");
}
@@ -41,38 +41,40 @@
"<a href=\"$CFG->wwwroot/mod/$dirname/index.php?id=$course->id\">$strquizzes</a>".
" -> <a href=\"edit.php\">$streditingquiz</a> -> $strexportquestions");
- if ($form = data_submitted()) { /// Filename
+ if (!empty($format)) { /// Filename
- $form->format = clean_filename($form->format);
+ if (!confirm_sesskey()) {
+ echo( 'Sesskey error' );
+ }
- if (! is_readable("format/$form->format/format.php")) {
+ if (! is_readable("format/$format/format.php")) {
error('Format not known ('.clean_text($form->format).')');
}
require("format.php"); // Parent class
- require("format/$form->format/format.php");
+ require("format/$format/format.php");
- $classname = "quiz_format_$form->format";
- $format = new $classname();
+ $classname = "quiz_format_$format";
+ $quiz_format = new $classname();
- if (! $format->exportpreprocess($category, $course)) { // Do anything before that we need to
+ if (! $quiz_format->exportpreprocess($category, $course)) { // Do anything before that we need to
error("Error occurred during pre-processing!",
"$CFG->wwwroot/mod/quiz/export.php?category=$category->id");
}
- if (! $format->exportprocess($exportfilename)) { // Process the export data
+ if (! $quiz_format->exportprocess($exportfilename)) { // Process the export data
error("Error occurred during processing!",
"$CFG->wwwroot/mod/quiz/export.php?category=$category->id");
}
- if (! $format->exportpostprocess()) { // In case anything needs to be done after
+ if (! $quiz_format->exportpostprocess()) { // In case anything needs to be done after
error("Error occurred during post-processing!",
"$CFG->wwwroot/mod/quiz/export.php?category=$category->id");
}
echo "<hr />";
// link to download the finished file
- $file_ext = $format->export_file_extension();
+ $file_ext = $quiz_format->export_file_extension();
$download_str = get_string( 'download', 'quiz' );
$downloadextra_str = get_string( 'downloadextra','quiz' );
if ($CFG->slasharguments) {
@@ -99,42 +101,44 @@
$fileformatnames = get_import_export_formats( "export" );
// get filename
- if (!isset($exportfilename)) {
+ if (empty($exportfilename)) {
$exportfilename = default_export_filename($course, $category);
}
print_heading_with_help($strexportquestions, "export", "quiz");
print_simple_box_start("center");
- echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"export.php?course={$course->id}\">";
- echo "<table cellpadding=\"5\">";
+ echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"export.php\">\n";
+ echo "<input type=\"hidden\" name=\"sesskey\" value=\"" . sesskey() . "\" />\n";
+ echo "<table cellpadding=\"5\">\n";
- echo "<tr><td align=\"right\">";
+ echo "<tr><td align=\"right\">\n";
print_string("category", "quiz");
echo ":</td><td>";
- echo str_replace('&nbsp;', '', $categories[$category->id]) . " ($course->shortname)";
- echo "</td></tr>";
+ echo str_replace('&nbsp;', '', $category->name) . " ($categorycourse->shortname)";
+ echo "</td></tr>\n";
echo "<tr><td align=\"right\">";
print_string("fileformat", "quiz");
echo ":</td><td>";
choose_from_menu($fileformatnames, "format", "gift", "");
helpbutton("export", $strexportquestions, "quiz");
- echo "</td></tr>";
+ echo "</td></tr>\n";
echo "<tr><td align=\"right\">";
print_string("exportname", "quiz" );
echo ":</td><td>";
echo "<input type=\"text\" size=\"40\" name=\"exportfilename\" value=\"$exportfilename\" />";
- echo "</td></tr>";
+ 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>";
+ echo "</td></tr>\n";
- echo "</table>";
- echo "</form>";
+ echo "</table>\n";
+ echo "</form>\n";
print_simple_box_end();
print_footer($course);

0 comments on commit b87c2ad

Please sign in to comment.