.
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
require_once($CFG->dirroot.'/course/moodleform_mod.php');
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
class mod_scorm_mod_form extends moodleform_mod {
function definition() {
global $CFG, $COURSE, $OUTPUT;
$cfg_scorm = 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
$mform->addElement('text', 'name', get_string('name'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
} else {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
// Summary
$this->add_intro_editor(true);
// Scorm types
$scormtypes = array(SCORM_TYPE_LOCAL => get_string('typelocal', 'scorm'));
if ($cfg_scorm->allowtypeexternal) {
$scormtypes[SCORM_TYPE_EXTERNAL] = get_string('typeexternal', 'scorm');
}
if ($cfg_scorm->allowtypelocalsync) {
$scormtypes[SCORM_TYPE_LOCALSYNC] = get_string('typelocalsync', 'scorm');
}
if (!empty($CFG->repositoryactivate) and $cfg_scorm->allowtypeimsrepository) {
$scormtypes[SCORM_TYPE_IMSREPOSITORY] = get_string('typeimsrepository', 'scorm');
}
if ($cfg_scorm->allowtypeexternalaicc) {
$scormtypes[SCORM_TYPE_AICCURL] = get_string('typeaiccurl', 'scorm');
}
// Reference
if (count($scormtypes) > 1) {
$mform->addElement('select', 'scormtype', get_string('scormtype', 'scorm'), $scormtypes);
$mform->addHelpButton('scormtype', 'scormtype', 'scorm');
$mform->addElement('text', 'packageurl', get_string('packageurl', 'scorm'), array('size'=>60));
$mform->setType('packageurl', PARAM_RAW);
$mform->addHelpButton('packageurl', 'packageurl', 'scorm');
$mform->disabledIf('packageurl', 'scormtype', 'eq', SCORM_TYPE_LOCAL);
} else {
$mform->addElement('hidden', 'scormtype', SCORM_TYPE_LOCAL);
}
// New local package upload
$maxbytes = get_max_upload_file_size($CFG->maxbytes, $COURSE->maxbytes);
$mform->setMaxFileSize($maxbytes);
$mform->addElement('filepicker', 'packagefile', get_string('package', 'scorm'));
$mform->addHelpButton('packagefile', 'package', 'scorm');
$mform->disabledIf('packagefile', 'scormtype', 'noteq', SCORM_TYPE_LOCAL);
//-------------------------------------------------------------------------------
// Time restrictions
$mform->addElement('header', 'timerestricthdr', get_string('timerestrict', 'scorm'));
$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));
//-------------------------------------------------------------------------------
// display Settings
$mform->addElement('header', 'displaysettings', get_string('displaysettings', 'scorm'));
// 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);
// Width
$mform->addElement('text', 'width', get_string('width', 'scorm'), 'maxlength="5" size="5"');
$mform->setDefault('width', $cfg_scorm->framewidth);
$mform->setType('width', PARAM_INT);
$mform->setAdvanced('width', $cfg_scorm->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->setType('height', PARAM_INT);
$mform->setAdvanced('height', $cfg_scorm->frameheight_adv);
$mform->disabledIf('height', 'popup', 'eq', 0);
// Window Options
$winoptgrp = array();
foreach (scorm_get_popup_options_array() as $key => $value) {
$winoptgrp[] = &$mform->createElement('checkbox', $key, '', get_string($key, 'scorm'));
$mform->setDefault($key, $value);
}
$mform->addGroup($winoptgrp, 'winoptgrp', get_string('options', 'scorm'), '
', false);
$mform->disabledIf('winoptgrp', 'popup', 'eq', 0);
$mform->setAdvanced('winoptgrp', $cfg_scorm->winoptgrp_adv);
// Skip view page
$skipviewoptions = scorm_get_skip_view_array();
if ($COURSE->format == 'scorm') { // 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;
}
}
$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);
// 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);
// 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);
// 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);
// 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->disabledIf('hidenav', 'hidetoc', 'noteq', 0);
//-------------------------------------------------------------------------------
// grade Settings
$mform->addElement('header', 'gradesettings', get_string('gradesettings', 'scorm'));
// 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->setAdvanced('grademethod', $cfg_scorm->grademethod_adv);
// 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->disabledIf('maxgrade', 'grademethod', 'eq', GRADESCOES);
$mform->setAdvanced('maxgrade', $cfg_scorm->maxgrade_adv);
$mform->addElement('header', 'othersettings', get_string('othersettings', 'scorm'));
// Max Attempts
$mform->addElement('select', 'maxattempt', get_string('maximumattempts', 'scorm'), scorm_get_attempts_array());
$mform->addHelpButton('maxattempt', 'maximumattempts', 'scorm');
$mform->setDefault('maxattempt', $cfg_scorm->maxattempts);
$mform->setAdvanced('maxattempt', $cfg_scorm->maxattempts_adv);
// 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->setAdvanced('whatgrade', $cfg_scorm->whatgrade_adv);
// Display attempt status
$mform->addElement('selectyesno', 'displayattemptstatus', get_string('displayattemptstatus', 'scorm'));
$mform->addHelpButton('displayattemptstatus', 'displayattemptstatus', 'scorm');
$mform->setDefault('displayattemptstatus', $cfg_scorm->displayattemptstatus);
$mform->setAdvanced('displayattemptstatus', $cfg_scorm->displayattemptstatus_adv);
// Force completed
$mform->addElement('selectyesno', 'forcecompleted', get_string('forcecompleted', 'scorm'));
$mform->addHelpButton('forcecompleted', 'forcecompleted', 'scorm');
$mform->setDefault('forcecompleted', $cfg_scorm->forcecompleted);
$mform->setAdvanced('forcecompleted', $cfg_scorm->forcecompleted_adv);
// Force new attempt
$mform->addElement('selectyesno', 'forcenewattempt', get_string('forcenewattempt', 'scorm'));
$mform->addHelpButton('forcenewattempt', 'forcenewattempt', 'scorm');
$mform->setDefault('forcenewattempt', $cfg_scorm->forcenewattempt);
$mform->setAdvanced('forcenewattempt', $cfg_scorm->forcenewattempt_adv);
// 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->setAdvanced('lastattemptlock', $cfg_scorm->lastattemptlock_adv);
// Activation period
/* $mform->addElement('static', '', '' ,'