From 1e3d6fd8044b9053e04ded59233f3c8756521d0c Mon Sep 17 00:00:00 2001 From: thepurpleblob Date: Thu, 9 Mar 2006 16:17:45 +0000 Subject: [PATCH] Fixed up some more links. Fixed up a bunch of hardcoded text. Added test for exporting category with no questions. --- question/export.php | 16 ++++++++-------- question/format.php | 26 +++++++++++++++----------- question/import.php | 18 +++++++++--------- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/question/export.php b/question/export.php index cf15092865..b75b56090b 100644 --- a/question/export.php +++ b/question/export.php @@ -33,13 +33,13 @@ } if (! $categorycourse = get_record("course", "id", $category->course)) { - error("This category doesn't belong to a valid course!"); + error( get_string('nocategory','quiz') ); } require_login($course->id, false); if (!isteacher($course->id)) { - error("Only the teacher can export quiz questions!"); + error( get_string('onlyteachersexport','quiz') ); } // ensure the files area exists for this course @@ -91,18 +91,18 @@ $qformat = new $classname(); if (! $qformat->exportpreprocess($category, $course)) { // Do anything before that we need to - error("Error occurred during pre-processing!", - "$CFG->wwwroot/question/export.php?category=$category->id"); + error( get_string('exporterror','quiz'), + "$CFG->wwwroot/question/export.php?courseid={$course->id}&category=$category->id"); } if (! $qformat->exportprocess($exportfilename)) { // Process the export data - error("Error occurred during processing!", - "$CFG->wwwroot/question/export.php?category=$category->id"); + error( get_string('exporterror','quiz'), + "$CFG->wwwroot/question/export.php?courseid={$course->id}&category=$category->id"); } if (! $qformat->exportpostprocess()) { // In case anything needs to be done after - error("Error occurred during post-processing!", - "$CFG->wwwroot/question/export.php?category=$category->id"); + error( get_string('exporterror','quiz'), + "$CFG->wwwroot/question/export.php?courseid={$course->id}&category=$category->id"); } echo "
"; diff --git a/question/format.php b/question/format.php index 5a8115579c..c00d6f12c0 100644 --- a/question/format.php +++ b/question/format.php @@ -41,16 +41,16 @@ class qformat_default { /// Processes a given file. There's probably little need to change this if (! $lines = $this->readdata($filename)) { - notify("File could not be read, or was empty"); + notify( get_string('cannotread','quiz') ); return false; } if (! $questions = $this->readquestions($lines)) { // Extract all the questions - notify("There are no questions in this file!"); + notify( get_string('noquestionsinfile','quiz') ); return false; } - notify("Importing ".count($questions)." questions"); + notify( get_string('importingquestions','quiz',count($questions)) ); $count = 0; @@ -64,7 +64,7 @@ class qformat_default { $question->version = 1; // Original version of this question if (!$question->id = insert_record("question", $question)) { - error("Could not insert new question!"); + error( get_string('cannotinsert','quiz') ); } $this->questionids[] = $question->id; @@ -158,7 +158,8 @@ class qformat_default { /// this format, this function converts it into a question /// object suitable for processing and insertion into Moodle. - echo "

This quiz format has not yet been completed!

"; + $formatnotimplemented = get_string( 'formatnotimplemented','quiz' ); + echo "

$formatnotimplemented

"; return NULL; } @@ -210,7 +211,7 @@ class qformat_default { $path = $CFG->dataroot.'/'.$courseid.'/'.$dirname; if (!is_dir($path)) { if (!mkdir($path, $CFG->directorypermissions)) { - error("Cannot create path: $path"); + error( get_string('cannotcreatepath','quiz',$path) ); } } @@ -218,9 +219,10 @@ class qformat_default { // only get q's with no parents (no cloze subquestions specifically) $questions = get_questions_category( $this->category, true ); - notify("Exporting questions."); + notify( get_string('exportingquestions','quiz') ); if (!count($questions)) { - return true; + notify( get_string('noquestions','quiz') ); + return false; } $count = 0; @@ -245,10 +247,10 @@ class qformat_default { // write file $filepath = $path."/".$filename . $this->export_file_extension(); if (!$fh=fopen($filepath,"w")) { - error("Cannot open for writing: $filepath"); + error( get_string('cannotopen','quiz',$filepath) ); } if (!fwrite($fh, $expout)) { - error("Cannot write exported questions to $filepath"); + error( get_string('cannotwrite','quiz',$filepath) ); } fclose($fh); @@ -265,7 +267,9 @@ class qformat_default { /// Turns a question object into textual output in the given format /// must be overidden - echo "

This quiz format has not yet been completed!

"; + // if not overidden, then this is an error. + $formatnotimplemented = get_string( 'formatnotimplemented','quiz' ); + echo "

$formatnotimplemented

"; return NULL; } diff --git a/question/import.php b/question/import.php index f00335c7ab..57a6998874 100644 --- a/question/import.php +++ b/question/import.php @@ -28,7 +28,7 @@ if ($courseid) { $category = get_default_question_category($courseid); } else { - error("No category specified"); + error( get_string('nocategory','quiz') ); } } @@ -43,7 +43,7 @@ require_login($course->id, false); if (!isteacheredit($course->id)) { - error("Only editing teachers can import quiz questions!"); + error( get_string('onlyteachersimport','quiz') ); } // ensure the files area exists for this course @@ -94,7 +94,7 @@ } else { // Valid file is found if (! is_readable("format/$format/format.php")) { - error("Format not known ($format)"); + error( get_string('formatnotfound','quiz', $format) ); } require("format.php"); // Parent class @@ -104,18 +104,18 @@ $qformat = new $classname(); if (! $qformat->importpreprocess($category,$course)) { // Do anything before that we need to - error("Error occurred during pre-processing!", - "$CFG->wwwroot/question/import.php?category=$category->id"); + error( get_string('importerror','quiz'), + "$CFG->wwwroot/question/import.php?courseid={$course->id}&category=$category->id"); } if (! $qformat->importprocess($_FILES['newfile']['tmp_name'])) { // Process the uploaded file - error("Error occurred during processing!", - "$CFG->wwwroot/question/import.php?category=$category->id"); + error( get_string('importerror','quiz'), + "$CFG->wwwroot/question/import.php?courseid={$course->id}&category=$category->id"); } if (! $qformat->importpostprocess()) { // In case anything needs to be done after - error("Error occurred during post-processing!", - "$CFG->wwwroot/question/import.php?category=$category->id"); + error( get_string('importerror','quiz'), + "$CFG->wwwroot/question/import.php?courseid={$course->id}&category=$category->id"); } echo "
"; -- 2.39.5