MDL-24474, fixed warning message from filepicker element, fixed missing packageurl when adding new scorm instance
This commit is contained in:
@@ -112,7 +112,8 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
|
||||
global $USER;
|
||||
|
||||
// make sure max one file is present and it is not too big
|
||||
if ($draftitemid = $submitValues[$this->_attributes['name']]) {
|
||||
if (!empty($submitValues[$this->_attributes['name']])) {
|
||||
$draftitemid = $submitValues[$this->_attributes['name']];
|
||||
$fs = get_file_storage();
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
if ($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id DESC', false)) {
|
||||
@@ -126,8 +127,10 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
|
||||
$file->delete();
|
||||
}
|
||||
}
|
||||
return array($this->_attributes['name'] => $submitValues[$this->_attributes['name']]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array($this->_attributes['name'] => $submitValues[$this->_attributes['name']]);
|
||||
}
|
||||
}
|
||||
|
||||
+16
-16
@@ -79,47 +79,47 @@ function scorm_add_instance($scorm, $mform=null) {
|
||||
$DB->set_field('course_modules', 'instance', $id, array('id'=>$cmid));
|
||||
|
||||
/// reload scorm instance
|
||||
$scorm = $DB->get_record('scorm', array('id'=>$id));
|
||||
$record = $DB->get_record('scorm', array('id'=>$id));
|
||||
|
||||
/// store the package and verify
|
||||
if ($scorm->scormtype === SCORM_TYPE_LOCAL) {
|
||||
if ($record->scormtype === SCORM_TYPE_LOCAL) {
|
||||
if ($mform) {
|
||||
$filename = $mform->get_new_filename('packagefile');
|
||||
if ($filename !== false) {
|
||||
$fs = get_file_storage();
|
||||
$fs->delete_area_files($context->id, 'mod_scorm', 'package');
|
||||
$mform->save_stored_file('packagefile', $context->id, 'mod_scorm', 'package', 0, '/', $filename);
|
||||
$scorm->reference = $filename;
|
||||
$record->reference = $filename;
|
||||
}
|
||||
}
|
||||
|
||||
} else if ($scorm->scormtype === SCORM_TYPE_LOCALSYNC) {
|
||||
$scorm->reference = $scorm->packageurl;
|
||||
} else if ($record->scormtype === SCORM_TYPE_LOCALSYNC) {
|
||||
$record->reference = $scorm->packageurl;
|
||||
|
||||
} else if ($scorm->scormtype === SCORM_TYPE_EXTERNAL) {
|
||||
$scorm->reference = $scorm->packageurl;
|
||||
} else if ($record->scormtype === SCORM_TYPE_EXTERNAL) {
|
||||
$record->reference = $scorm->packageurl;
|
||||
|
||||
} else if ($scorm->scormtype === SCORM_TYPE_IMSREPOSITORY) {
|
||||
$scorm->reference = $scorm->packageurl;
|
||||
} else if ($record->scormtype === SCORM_TYPE_IMSREPOSITORY) {
|
||||
$record->reference = $scorm->packageurl;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// save reference
|
||||
$DB->update_record('scorm', $scorm);
|
||||
$DB->update_record('scorm', $record);
|
||||
|
||||
|
||||
/// extra fields required in grade related functions
|
||||
$scorm->course = $courseid;
|
||||
$scorm->cmidnumber = $cmidnumber;
|
||||
$scorm->cmid = $cmid;
|
||||
$record->course = $courseid;
|
||||
$record->cmidnumber = $cmidnumber;
|
||||
$record->cmid = $cmid;
|
||||
|
||||
scorm_parse($scorm, true);
|
||||
scorm_parse($record, true);
|
||||
|
||||
scorm_grade_item_update($scorm);
|
||||
scorm_grade_item_update($record);
|
||||
|
||||
return $scorm->id;
|
||||
return $record->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -268,7 +268,7 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
$coursescorm = current($scorms);
|
||||
|
||||
$draftitemid = file_get_submitted_draft_itemid('packagefile');
|
||||
file_prepare_draft_area(&$draftitemid, $this->context->id, 'mod_scorm', 'package', 0);
|
||||
file_prepare_draft_area($draftitemid, $this->context->id, 'mod_scorm', 'package', 0);
|
||||
$default_values['packagefile'] = $draftitemid;
|
||||
|
||||
if (($COURSE->format == 'scorm') && ((count($scorms) == 0) || ($default_values['instance'] == $coursescorm->id))) {
|
||||
|
||||
Reference in New Issue
Block a user