MDL-16198
Blackboard V6+ can now handle the .dat file directly as an option to the .zip file Some changes needed to recover the original filename.
This commit is contained in:
@@ -15,6 +15,7 @@ class qformat_default {
|
||||
var $questions = array();
|
||||
var $course = NULL;
|
||||
var $filename = '';
|
||||
var $realfilename = '';
|
||||
var $matchgrades = 'error';
|
||||
var $catfromfile = 0;
|
||||
var $contextfromfile = 0;
|
||||
@@ -87,6 +88,15 @@ class qformat_default {
|
||||
function setFilename( $filename ) {
|
||||
$this->filename = $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the "real" filename
|
||||
* (this is what the user typed, regardless of wha happened next)
|
||||
* @param string realfilename name of file as typed by user
|
||||
*/
|
||||
function setRealfilename( $realfilename ) {
|
||||
$this->realfilename = $realfilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* set matchgrades
|
||||
|
||||
@@ -153,6 +153,16 @@ class qformat_blackboard_6 extends qformat_default {
|
||||
/// Returns complete file with an array, one item per line
|
||||
global $CFG;
|
||||
|
||||
// if the extension is .dat we just return that,
|
||||
// if .zip we unzip the file and get the data
|
||||
$ext = substr($this->realfilename, strpos($this->realfilename,'.'), strlen($this->realfilename)-1);
|
||||
if ($ext=='.dat') {
|
||||
if (!is_readable($filename)) {
|
||||
error("File is not readable");
|
||||
}
|
||||
return file($filename);
|
||||
}
|
||||
|
||||
$unique_code = time();
|
||||
$temp_dir = $CFG->dataroot."/temp/bbquiz_import/".$unique_code;
|
||||
$this->temp_dir = $temp_dir;
|
||||
@@ -313,6 +323,12 @@ function create_raw_question($quest) {
|
||||
case 'Fill in the Blank':
|
||||
// do nothing?
|
||||
break;
|
||||
case 'Fill in the Blank Plus':
|
||||
// do nothing?
|
||||
break;
|
||||
case 'Numeric':
|
||||
// do nothing?
|
||||
break;
|
||||
default:
|
||||
$bb_choices = $pblock['#']['response_lid'][0]['#']['render_choice'][0]['#']['flow_label'][0]['#']['response_label'];
|
||||
$choices = array();
|
||||
@@ -343,7 +359,7 @@ function create_raw_question($quest) {
|
||||
// there is a section called 'outcomes' that I don't know what to do with
|
||||
$resprocessing = $quest['#']['resprocessing'];
|
||||
$respconditions = $resprocessing[0]['#']['respcondition'];
|
||||
$reponses = array();
|
||||
$responses = array();
|
||||
if ($question->qtype == 'Matching') {
|
||||
$this->process_matching_responses($respconditions, $responses);
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
// or one from the filesarea.
|
||||
if (!empty($form->choosefile)) {
|
||||
$importfile = "{$CFG->dataroot}/{$COURSE->id}/{$form->choosefile}";
|
||||
$realfilename = $form->choosefile;
|
||||
if (file_exists($importfile)) {
|
||||
$fileisgood = true;
|
||||
} else {
|
||||
@@ -99,6 +100,7 @@
|
||||
}
|
||||
} else {
|
||||
// must be upload file
|
||||
$realfilename = $import_form->get_importfile_realname();
|
||||
if (!$importfile = $import_form->get_importfile_name()) {
|
||||
print_error('uploadproblem', 'moodle');
|
||||
}else {
|
||||
@@ -124,6 +126,7 @@
|
||||
$qformat->setContexts($contexts->having_one_edit_tab_cap('import'));
|
||||
$qformat->setCourse($COURSE);
|
||||
$qformat->setFilename($importfile);
|
||||
$qformat->setRealfilename($realfilename);
|
||||
$qformat->setMatchgrades($form->matchgrades);
|
||||
$qformat->setCatfromfile(!empty($form->catfromfile));
|
||||
$qformat->setContextfromfile(!empty($form->contextfromfile));
|
||||
|
||||
@@ -77,5 +77,14 @@ class question_import_form extends moodleform {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
function get_importfile_realname(){
|
||||
if ($this->is_submitted() and $this->is_validated()) {
|
||||
// return the temporary filename to process
|
||||
return $this->_upload_manager->files['newfile']['name'];
|
||||
}else{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user