// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
if (!defined('MOODLE_INTERNAL')) {
- die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
+ die('Direct access to this script is forbidden.'); // It must be included from a Moodle page.
}
require_once($CFG->dirroot.'/course/moodleform_mod.php');
class mod_scorm_mod_form extends moodleform_mod {
- function definition() {
+ public function definition() {
global $CFG, $COURSE, $OUTPUT;
- $cfg_scorm = get_config('scorm');
+ $cfgscorm = get_config('scorm');
$mform = $this->_form;
if (!$CFG->slasharguments) {
$mform->addElement('static', '', '', $OUTPUT->notification(get_string('slashargs', 'scorm'), 'notifyproblem'));
}
- //-------------------------------------------------------------------------------
+
$mform->addElement('header', 'general', get_string('general', 'form'));
// Name.
// Scorm types.
$scormtypes = array(SCORM_TYPE_LOCAL => get_string('typelocal', 'scorm'));
- if ($cfg_scorm->allowtypeexternal) {
+ if ($cfgscorm->allowtypeexternal) {
$scormtypes[SCORM_TYPE_EXTERNAL] = get_string('typeexternal', 'scorm');
}
- if ($cfg_scorm->allowtypelocalsync) {
+ if ($cfgscorm->allowtypelocalsync) {
$scormtypes[SCORM_TYPE_LOCALSYNC] = get_string('typelocalsync', 'scorm');
}
- if ($cfg_scorm->allowtypeexternalaicc) {
+ if ($cfgscorm->allowtypeexternalaicc) {
$scormtypes[SCORM_TYPE_AICCURL] = get_string('typeaiccurl', 'scorm');
}
// Update packages timing.
$mform->addElement('select', 'updatefreq', get_string('updatefreq', 'scorm'), scorm_get_updatefreq_array());
$mform->setType('updatefreq', PARAM_INT);
- $mform->setDefault('updatefreq', $cfg_scorm->updatefreq);
+ $mform->setDefault('updatefreq', $cfgscorm->updatefreq);
$mform->addHelpButton('updatefreq', 'updatefreq', 'scorm');
$mform->disabledIf('updatefreq', 'scormtype', 'eq', SCORM_TYPE_LOCAL);
} else {
// Framed / Popup Window.
$mform->addElement('select', 'popup', get_string('display', 'scorm'), scorm_get_popup_display_array());
- $mform->setDefault('popup', $cfg_scorm->popup);
- $mform->setAdvanced('popup', $cfg_scorm->popup_adv);
+ $mform->setDefault('popup', $cfgscorm->popup);
+ $mform->setAdvanced('popup', $cfgscorm->popup_adv);
// Width.
$mform->addElement('text', 'width', get_string('width', 'scorm'), 'maxlength="5" size="5"');
- $mform->setDefault('width', $cfg_scorm->framewidth);
+ $mform->setDefault('width', $cfgscorm->framewidth);
$mform->setType('width', PARAM_INT);
- $mform->setAdvanced('width', $cfg_scorm->framewidth_adv);
+ $mform->setAdvanced('width', $cfgscorm->framewidth_adv);
$mform->disabledIf('width', 'popup', 'eq', 0);
// Height.
$mform->addElement('text', 'height', get_string('height', 'scorm'), 'maxlength="5" size="5"');
- $mform->setDefault('height', $cfg_scorm->frameheight);
+ $mform->setDefault('height', $cfgscorm->frameheight);
$mform->setType('height', PARAM_INT);
- $mform->setAdvanced('height', $cfg_scorm->frameheight_adv);
+ $mform->setAdvanced('height', $cfgscorm->frameheight_adv);
$mform->disabledIf('height', 'popup', 'eq', 0);
// Window Options.
}
$mform->addGroup($winoptgrp, 'winoptgrp', get_string('options', 'scorm'), '<br />', false);
$mform->disabledIf('winoptgrp', 'popup', 'eq', 0);
- $mform->setAdvanced('winoptgrp', $cfg_scorm->winoptgrp_adv);
+ $mform->setAdvanced('winoptgrp', $cfgscorm->winoptgrp_adv);
// Skip view page.
$skipviewoptions = scorm_get_skip_view_array();
if ($COURSE->format == 'singleactivity') { // Remove option that would cause a constant redirect.
unset($skipviewoptions[SCORM_SKIPVIEW_ALWAYS]);
- if ($cfg_scorm->skipview == SCORM_SKIPVIEW_ALWAYS) {
- $cfg_scorm->skipview = SCORM_SKIPVIEW_FIRST;
+ if ($cfgscorm->skipview == SCORM_SKIPVIEW_ALWAYS) {
+ $cfgscorm->skipview = SCORM_SKIPVIEW_FIRST;
}
}
$mform->addElement('select', 'skipview', get_string('skipview', 'scorm'), $skipviewoptions);
$mform->addHelpButton('skipview', 'skipview', 'scorm');
- $mform->setDefault('skipview', $cfg_scorm->skipview);
- $mform->setAdvanced('skipview', $cfg_scorm->skipview_adv);
+ $mform->setDefault('skipview', $cfgscorm->skipview);
+ $mform->setAdvanced('skipview', $cfgscorm->skipview_adv);
// Hide Browse.
$mform->addElement('selectyesno', 'hidebrowse', get_string('hidebrowse', 'scorm'));
$mform->addHelpButton('hidebrowse', 'hidebrowse', 'scorm');
- $mform->setDefault('hidebrowse', $cfg_scorm->hidebrowse);
- $mform->setAdvanced('hidebrowse', $cfg_scorm->hidebrowse_adv);
+ $mform->setDefault('hidebrowse', $cfgscorm->hidebrowse);
+ $mform->setAdvanced('hidebrowse', $cfgscorm->hidebrowse_adv);
// Display course structure.
$mform->addElement('selectyesno', 'displaycoursestructure', get_string('displaycoursestructure', 'scorm'));
$mform->addHelpButton('displaycoursestructure', 'displaycoursestructure', 'scorm');
- $mform->setDefault('displaycoursestructure', $cfg_scorm->displaycoursestructure);
- $mform->setAdvanced('displaycoursestructure', $cfg_scorm->displaycoursestructure_adv);
+ $mform->setDefault('displaycoursestructure', $cfgscorm->displaycoursestructure);
+ $mform->setAdvanced('displaycoursestructure', $cfgscorm->displaycoursestructure_adv);
// Toc display.
$mform->addElement('select', 'hidetoc', get_string('hidetoc', 'scorm'), scorm_get_hidetoc_array());
$mform->addHelpButton('hidetoc', 'hidetoc', 'scorm');
- $mform->setDefault('hidetoc', $cfg_scorm->hidetoc);
- $mform->setAdvanced('hidetoc', $cfg_scorm->hidetoc_adv);
+ $mform->setDefault('hidetoc', $cfgscorm->hidetoc);
+ $mform->setAdvanced('hidetoc', $cfgscorm->hidetoc_adv);
$mform->disabledIf('hidetoc', 'scormtype', 'eq', SCORM_TYPE_AICCURL);
// Hide Navigation panel.
$mform->addElement('selectyesno', 'hidenav', get_string('hidenav', 'scorm'));
- $mform->setDefault('hidenav', $cfg_scorm->hidenav);
- $mform->setAdvanced('hidenav', $cfg_scorm->hidenav_adv);
+ $mform->setDefault('hidenav', $cfgscorm->hidenav);
+ $mform->setAdvanced('hidenav', $cfgscorm->hidenav_adv);
$mform->disabledIf('hidenav', 'hidetoc', 'noteq', 0);
// Display attempt status.
- $mform->addElement('select', 'displayattemptstatus', get_string('displayattemptstatus', 'scorm'), scorm_get_attemptstatus_array());
+ $mform->addElement('select', 'displayattemptstatus', get_string('displayattemptstatus', 'scorm'),
+ scorm_get_attemptstatus_array());
$mform->addHelpButton('displayattemptstatus', 'displayattemptstatus', 'scorm');
- $mform->setDefault('displayattemptstatus', $cfg_scorm->displayattemptstatus);
- $mform->setAdvanced('displayattemptstatus', $cfg_scorm->displayattemptstatus_adv);
+ $mform->setDefault('displayattemptstatus', $cfgscorm->displayattemptstatus);
+ $mform->setAdvanced('displayattemptstatus', $cfgscorm->displayattemptstatus_adv);
// Availability.
$mform->addElement('header', 'availability', get_string('availability'));
$mform->addElement('date_time_selector', 'timeopen', get_string("scormopen", "scorm"), array('optional' => true));
$mform->addElement('date_time_selector', 'timeclose', get_string("scormclose", "scorm"), array('optional' => true));
- //-------------------------------------------------------------------------------
// Grade Settings.
$mform->addElement('header', 'gradesettings', get_string('grade'));
// Grade Method.
$mform->addElement('select', 'grademethod', get_string('grademethod', 'scorm'), scorm_get_grade_method_array());
$mform->addHelpButton('grademethod', 'grademethod', 'scorm');
- $mform->setDefault('grademethod', $cfg_scorm->grademethod);
+ $mform->setDefault('grademethod', $cfgscorm->grademethod);
// Maximum Grade.
for ($i=0; $i<=100; $i++) {
$grades[$i] = "$i";
}
$mform->addElement('select', 'maxgrade', get_string('maximumgrade'), $grades);
- $mform->setDefault('maxgrade', $cfg_scorm->maxgrade);
+ $mform->setDefault('maxgrade', $cfgscorm->maxgrade);
$mform->disabledIf('maxgrade', 'grademethod', 'eq', GRADESCOES);
// Attempts management.
// Max Attempts.
$mform->addElement('select', 'maxattempt', get_string('maximumattempts', 'scorm'), scorm_get_attempts_array());
$mform->addHelpButton('maxattempt', 'maximumattempts', 'scorm');
- $mform->setDefault('maxattempt', $cfg_scorm->maxattempt);
+ $mform->setDefault('maxattempt', $cfgscorm->maxattempt);
// What Grade.
$mform->addElement('select', 'whatgrade', get_string('whatgrade', 'scorm'), scorm_get_what_grade_array());
$mform->disabledIf('whatgrade', 'maxattempt', 'eq', 1);
$mform->addHelpButton('whatgrade', 'whatgrade', 'scorm');
- $mform->setDefault('whatgrade', $cfg_scorm->whatgrade);
+ $mform->setDefault('whatgrade', $cfgscorm->whatgrade);
// Force new attempt.
$mform->addElement('selectyesno', 'forcenewattempt', get_string('forcenewattempt', 'scorm'));
$mform->addHelpButton('forcenewattempt', 'forcenewattempt', 'scorm');
- $mform->setDefault('forcenewattempt', $cfg_scorm->forcenewattempt);
+ $mform->setDefault('forcenewattempt', $cfgscorm->forcenewattempt);
// Last attempt lock - lock the enter button after the last available attempt has been made.
$mform->addElement('selectyesno', 'lastattemptlock', get_string('lastattemptlock', 'scorm'));
$mform->addHelpButton('lastattemptlock', 'lastattemptlock', 'scorm');
- $mform->setDefault('lastattemptlock', $cfg_scorm->lastattemptlock);
+ $mform->setDefault('lastattemptlock', $cfgscorm->lastattemptlock);
// Compatibility settings.
$mform->addElement('header', 'compatibilitysettingshdr', get_string('compatibilitysettings', 'scorm'));
// Force completed.
$mform->addElement('selectyesno', 'forcecompleted', get_string('forcecompleted', 'scorm'));
$mform->addHelpButton('forcecompleted', 'forcecompleted', 'scorm');
- $mform->setDefault('forcecompleted', $cfg_scorm->forcecompleted);
+ $mform->setDefault('forcecompleted', $cfgscorm->forcecompleted);
// Autocontinue.
$mform->addElement('selectyesno', 'auto', get_string('autocontinue', 'scorm'));
$mform->addHelpButton('auto', 'autocontinue', 'scorm');
- $mform->setDefault('auto', $cfg_scorm->auto);
+ $mform->setDefault('auto', $cfgscorm->auto);
- //-------------------------------------------------------------------------------
// Hidden Settings.
$mform->addElement('hidden', 'datadir', null);
$mform->setType('datadir', PARAM_RAW);
$mform->addElement('hidden', 'redirecturl', null);
$mform->setType('redirecturl', PARAM_RAW);
- //-------------------------------------------------------------------------------
$this->standard_coursemodule_elements();
- //-------------------------------------------------------------------------------
+
// Buttons.
$this->add_action_buttons();
}
- function data_preprocessing(&$default_values) {
+ public function data_preprocessing(&$defaultvalues) {
global $COURSE;
- if (isset($default_values['popup']) && ($default_values['popup'] == 1) && isset($default_values['options'])) {
- if (!empty($default_values['options'])) {
- $options = explode(',', $default_values['options']);
+ if (isset($defaultvalues['popup']) && ($defaultvalues['popup'] == 1) && isset($defaultvalues['options'])) {
+ if (!empty($defaultvalues['options'])) {
+ $options = explode(',', $defaultvalues['options']);
foreach ($options as $option) {
list($element, $value) = explode('=', $option);
$element = trim($element);
- $default_values[$element] = trim($value);
+ $defaultvalues[$element] = trim($value);
}
}
}
- if (isset($default_values['grademethod'])) {
- $default_values['grademethod'] = intval($default_values['grademethod']);
+ if (isset($defaultvalues['grademethod'])) {
+ $defaultvalues['grademethod'] = intval($defaultvalues['grademethod']);
}
- if (isset($default_values['width']) && (strpos($default_values['width'], '%') === false) && ($default_values['width'] <= 100)) {
- $default_values['width'] .= '%';
+ if (isset($defaultvalues['width']) && (strpos($defaultvalues['width'], '%') === false)
+ && ($defaultvalues['width'] <= 100)) {
+ $defaultvalues['width'] .= '%';
}
- if (isset($default_values['width']) && (strpos($default_values['height'], '%') === false) && ($default_values['height'] <= 100)) {
- $default_values['height'] .= '%';
+ if (isset($defaultvalues['width']) && (strpos($defaultvalues['height'], '%') === false)
+ && ($defaultvalues['height'] <= 100)) {
+ $defaultvalues['height'] .= '%';
}
$scorms = get_all_instances_in_course('scorm', $COURSE);
$coursescorm = current($scorms);
$draftitemid = file_get_submitted_draft_itemid('packagefile');
file_prepare_draft_area($draftitemid, $this->context->id, 'mod_scorm', 'package', 0);
- $default_values['packagefile'] = $draftitemid;
+ $defaultvalues['packagefile'] = $draftitemid;
- if (($COURSE->format == 'singleactivity') && ((count($scorms) == 0) || ($default_values['instance'] == $coursescorm->id))) {
- $default_values['redirect'] = 'yes';
- $default_values['redirecturl'] = '../course/view.php?id='.$default_values['course'];
+ if (($COURSE->format == 'singleactivity') && ((count($scorms) == 0) || ($defaultvalues['instance'] == $coursescorm->id))) {
+ $defaultvalues['redirect'] = 'yes';
+ $defaultvalues['redirecturl'] = '../course/view.php?id='.$defaultvalues['course'];
} else {
- $default_values['redirect'] = 'no';
- $default_values['redirecturl'] = '../mod/scorm/view.php?id='.$default_values['coursemodule'];
+ $defaultvalues['redirect'] = 'no';
+ $defaultvalues['redirecturl'] = '../mod/scorm/view.php?id='.$defaultvalues['coursemodule'];
}
- if (isset($default_values['version'])) {
- $default_values['pkgtype'] = (substr($default_values['version'], 0, 5) == 'SCORM') ? 'scorm':'aicc';
+ if (isset($defaultvalues['version'])) {
+ $defaultvalues['pkgtype'] = (substr($defaultvalues['version'], 0, 5) == 'SCORM') ? 'scorm':'aicc';
}
- if (isset($default_values['instance'])) {
- $default_values['datadir'] = $default_values['instance'];
+ if (isset($defaultvalues['instance'])) {
+ $defaultvalues['datadir'] = $defaultvalues['instance'];
}
- if (empty($default_values['timeopen'])) {
- $default_values['timeopen'] = 0;
+ if (empty($defaultvalues['timeopen'])) {
+ $defaultvalues['timeopen'] = 0;
}
- if (empty($default_values['timeclose'])) {
- $default_values['timeclose'] = 0;
+ if (empty($defaultvalues['timeclose'])) {
+ $defaultvalues['timeclose'] = 0;
}
// Set some completion default data.
- if (!empty($default_values['completionstatusrequired']) && !is_array($default_values['completionstatusrequired'])) {
+ if (!empty($defaultvalues['completionstatusrequired']) && !is_array($defaultvalues['completionstatusrequired'])) {
// Unpack values.
$cvalues = array();
foreach (scorm_status_options() as $key => $value) {
- if (($default_values['completionstatusrequired'] & $key) == $key) {
+ if (($defaultvalues['completionstatusrequired'] & $key) == $key) {
$cvalues[$key] = 1;
}
}
- $default_values['completionstatusrequired'] = $cvalues;
+ $defaultvalues['completionstatusrequired'] = $cvalues;
}
- if (!isset($default_values['completionscorerequired']) || !strlen($default_values['completionscorerequired'])) {
- $default_values['completionscoredisabled'] = 1;
+ if (!isset($defaultvalues['completionscorerequired']) || !strlen($defaultvalues['completionscorerequired'])) {
+ $defaultvalues['completionscoredisabled'] = 1;
}
}
- function validation($data, $files) {
+ public function validation($data, $files) {
global $CFG;
$errors = parent::validation($data, $files);
}
// Need to translate the "options" and "reference" field.
- function set_data($default_values) {
- $default_values = (array)$default_values;
+ public function set_data($defaultvalues) {
+ $defaultvalues = (array)$defaultvalues;
- if (isset($default_values['scormtype']) and isset($default_values['reference'])) {
- switch ($default_values['scormtype']) {
+ if (isset($defaultvalues['scormtype']) and isset($defaultvalues['reference'])) {
+ switch ($defaultvalues['scormtype']) {
case SCORM_TYPE_LOCALSYNC :
case SCORM_TYPE_EXTERNAL:
case SCORM_TYPE_AICCURL:
- $default_values['packageurl'] = $default_values['reference'];
+ $defaultvalues['packageurl'] = $defaultvalues['reference'];
}
}
- unset($default_values['reference']);
+ unset($defaultvalues['reference']);
- if (!empty($default_values['options'])) {
- $options = explode(',', $default_values['options']);
+ if (!empty($defaultvalues['options'])) {
+ $options = explode(',', $defaultvalues['options']);
foreach ($options as $option) {
$opt = explode('=', $option);
if (isset($opt[1])) {
- $default_values[$opt[0]] = $opt[1];
+ $defaultvalues[$opt[0]] = $opt[1];
}
}
}
- $this->data_preprocessing($default_values);
- parent::set_data($default_values);
+ $this->data_preprocessing($defaultvalues);
+ parent::set_data($defaultvalues);
}
- function add_completion_rules() {
+ public function add_completion_rules() {
$mform =& $this->_form;
$items = array();