]> git.mjollnir.org Git - moodle.git/commitdiff
SC#277. Merged from MOODLE_16_STABLE.
authortjhunt <tjhunt>
Tue, 18 Jul 2006 13:33:45 +0000 (13:33 +0000)
committertjhunt <tjhunt>
Tue, 18 Jul 2006 13:33:45 +0000 (13:33 +0000)
lang/en_utf8/quiz.php
question/export.php
question/format.php
question/format/qti2/format.php

index 52fbdb5e4de7235542f77c2840e4a30ff49fd480..9c1998cc25c6ee2522c4092eb1f14c9ddd5fd9cf 100644 (file)
@@ -131,7 +131,7 @@ $string['description'] = 'Description';
 $string['discrimination'] = 'Discrim. Index';
 $string['displayoptions'] = 'Display options';
 $string['download'] = 'Click to download the exported category file';
-$string['downloadextra'] = '(file is also stored in the course files in the /quiz folder)';
+$string['downloadextra'] = '(file is also stored in the course files in the /backupdata/quiz folder)';
 $string['duplicateresponse'] = 'This submission has been ignored because you gave an equivalent answer earlier.';
 $string['eachattemptbuildsonthelast'] = 'Each attempt builds on the last';
 $string['editcategories'] = 'Edit categories';
index 70bc39a870b7d403a94f8ac01f8e5122d059e072..a6893390cbb4cb8d1464c26560a66f712488302e 100644 (file)
         // link to download the finished file
         $file_ext = $qformat->export_file_extension();
         $download_str = get_string( 'download', 'quiz' );
-        $quizexportdir = get_string( 'exportfilename', 'quiz' );
         $downloadextra_str = get_string( 'downloadextra','quiz' );
         if ($CFG->slasharguments) {
-          $efile = "{$CFG->wwwroot}/file.php/$course->id/$quizexportdir/$exportfilename".$file_ext."?forcedownload=1";
+          $efile = "{$CFG->wwwroot}/file.php/".$qformat->question_get_export_dir()."/$exportfilename".$file_ext."?forcedownload=1";
         }
         else {
-          $efile = "{$CFG->wwwroot}/file.php?file=/$course->id/$quizexportdir/$exportfilename".$file_ext."&forcedownload=1";
+          $efile = "{$CFG->wwwroot}/file.php?file=/".$qformat->question_get_export_dir()."/$exportfilename".$file_ext."&forcedownload=1";
         }
         echo "</p><center><a href=\"$efile\">$download_str</a></center></p>";
         echo "</p><center><font size=\"-1\">$downloadextra_str</font></center></p>";
index 6191333ed7d16c3804ddb6f80cacaa947e92252c..230959833d7240c8c5cdf9d5b4d6a753e2c5e6a4 100644 (file)
@@ -272,14 +272,10 @@ class qformat_default {
         global $CFG;
 
         // create a directory for the exports (if not already existing)
-        $dirname = get_string("exportfilename","quiz");
-        $courseid = $this->course->id;
-        $path = $CFG->dataroot.'/'.$courseid.'/'.$dirname;
-        if (!is_dir($path)) {
-            if (!mkdir($path, $CFG->directorypermissions)) {
-              error( get_string('cannotcreatepath','quiz',$path) );
-            }
+        if (! $export_dir = make_upload_directory($this->question_get_export_dir())) {
+              error( get_string('cannotcreatepath','quiz',$export_dir) );
         }
+        $path = $CFG->dataroot.'/'.$this->question_get_export_dir();
 
         // get the questions (from database) in this category
         // only get q's with no parents (no cloze subquestions specifically)
@@ -347,6 +343,12 @@ class qformat_default {
         return NULL;
     }
 
+    function question_get_export_dir() {
+        $dirname = get_string("exportfilename","quiz");
+        $path = $this->course->id.'/backupdata/'.$dirname; // backupdata is protected directory
+        return $path;
+    }
+
 }
 
 ?>
index ade71ebd8d63e71b2bb5b54d099c35dde85145e7..6c5c2e0ee58adb536d557b468f46e5cf97384187 100644 (file)
@@ -235,24 +235,14 @@ function handle_questions_media(&$questions, $path, $courseid) {
     function exportprocess($filename) {
 
         global $CFG;
+        $courseid = $this->course->id;
 
         // create a directory for the exports (if not already existing)
-        $dirname = get_string("exportfilename","quiz");
-        $courseid = $this->course->id;
-        $path = $CFG->dataroot.'/'.$courseid.'/'.$dirname;
-        if (!is_dir($path)) {
-            if (!mkdir($path, $CFG->directorypermissions)) {
-              error("Cannot create path: $path");
-            }
+        if (!$export_dir = make_upload_directory($this->question_get_export_dir().'/'.$filename)) {
+              error( get_string('cannotcreatepath','quiz',$export_dir) );
         }
-        // create directory for this particular IMS export, if not already existing
-        $path = $path."/".$filename;
-        if (!is_dir($path)) {
-            if (!mkdir($path, $CFG->directorypermissions)) {
-              error("Cannot create path: $path");
-            }
-        }
-  
+        $path = $CFG->dataroot.'/'.$this->question_get_export_dir().'/'.$filename;
+
         // get the questions (from database) in this category
         // $questions = get_records("question","category",$this->category->id);
         $questions = get_questions_category( $this->category );
@@ -281,6 +271,9 @@ function handle_questions_media(&$questions, $path, $courseid) {
         $smarty->error_reporting = 99;
         $expout = $smarty->fetch('imsmanifest.tpl');
         $filepath = $path.'/imsmanifest.xml';
+        if (empty($expout)) {
+            error("Unkown error - empty imsmanifest.xml");
+        }
         if (!$fh=fopen($filepath,"w")) {
             error("Cannot open for writing: $filepath");
         }
@@ -313,7 +306,7 @@ function handle_questions_media(&$questions, $path, $courseid) {
         zip_files( array($path), "$path.zip" );
 
        // remove the temporary directory
-       delDirContents( $path );
+               remove_dir( $path );
  
         return true;
     }
@@ -688,7 +681,7 @@ function xml_entitize(&$collection) {
             }
         }
         $smarty = new Smarty;
-        $smarty->template_dir = "{$CFG->dirroot}/mod/quiz/format/qti2/templates";
+        $smarty->template_dir = "{$CFG->dirroot}/question/format/qti2/templates";
         $smarty->compile_dir  = "$path";
         return $smarty;
     }