$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';
// 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>";
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)
return NULL;
}
+ function question_get_export_dir() {
+ $dirname = get_string("exportfilename","quiz");
+ $path = $this->course->id.'/backupdata/'.$dirname; // backupdata is protected directory
+ return $path;
+ }
+
}
?>
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 );
$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");
}
zip_files( array($path), "$path.zip" );
// remove the temporary directory
- delDirContents( $path );
+ remove_dir( $path );
return true;
}
}
}
$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;
}