See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 18 /** 19 * Sets up $userdata array and default values for SCORM 1.2 . 20 * 21 * @param stdClass $userdata an empty stdClass variable that should be set up with user values 22 * @param object $scorm package record 23 * @param string $scoid SCO Id 24 * @param string $attempt attempt number for the user 25 * @param string $mode scorm display mode type 26 * @return array The default values that should be used for SCORM 1.2 package 27 */ 28 function get_scorm_default (&$userdata, $scorm, $scoid, $attempt, $mode) { 29 global $USER; 30 31 $userdata->student_id = $USER->username; 32 if (empty(get_config('scorm', 'scormstandard'))) { 33 $userdata->student_name = fullname($USER); 34 } else { 35 $userdata->student_name = $USER->lastname .', '. $USER->firstname; 36 } 37 38 if ($usertrack = scorm_get_tracks($scoid, $USER->id, $attempt)) { 39 foreach ($usertrack as $key => $value) { 40 $userdata->$key = $value; 41 } 42 } else { 43 $userdata->status = ''; 44 $userdata->score_raw = ''; 45 } 46 47 if ($scodatas = scorm_get_sco($scoid, SCO_DATA)) { 48 foreach ($scodatas as $key => $value) { 49 $userdata->$key = $value; 50 } 51 } else { 52 throw new \moodle_exception('cannotfindsco', 'scorm'); 53 } 54 if (!$sco = scorm_get_sco($scoid)) { 55 throw new \moodle_exception('cannotfindsco', 'scorm'); 56 } 57 58 if (isset($userdata->status)) { 59 if ($userdata->status == '') { 60 $userdata->entry = 'ab-initio'; 61 } else { 62 if (isset($userdata->{'cmi.core.exit'}) && ($userdata->{'cmi.core.exit'} == 'suspend')) { 63 $userdata->entry = 'resume'; 64 } else { 65 $userdata->entry = ''; 66 } 67 } 68 } 69 70 $userdata->mode = 'normal'; 71 if (!empty($mode)) { 72 $userdata->mode = $mode; 73 } 74 if ($userdata->mode == 'normal') { 75 $userdata->credit = 'credit'; 76 } else { 77 $userdata->credit = 'no-credit'; 78 } 79 80 $def = array(); 81 $def['cmi.core.student_id'] = $userdata->student_id; 82 $def['cmi.core.student_name'] = $userdata->student_name; 83 $def['cmi.core.credit'] = $userdata->credit; 84 $def['cmi.core.entry'] = $userdata->entry; 85 $def['cmi.core.lesson_mode'] = $userdata->mode; 86 $def['cmi.launch_data'] = scorm_isset($userdata, 'datafromlms'); 87 $def['cmi.student_data.mastery_score'] = scorm_isset($userdata, 'masteryscore'); 88 $def['cmi.student_data.max_time_allowed'] = scorm_isset($userdata, 'maxtimeallowed'); 89 $def['cmi.student_data.time_limit_action'] = scorm_isset($userdata, 'timelimitaction'); 90 $def['cmi.core.total_time'] = scorm_isset($userdata, 'cmi.core.total_time', '00:00:00'); 91 92 // Now handle standard userdata items. 93 $def['cmi.core.lesson_location'] = scorm_isset($userdata, 'cmi.core.lesson_location'); 94 $def['cmi.core.lesson_status'] = scorm_isset($userdata, 'cmi.core.lesson_status'); 95 $def['cmi.core.score.raw'] = scorm_isset($userdata, 'cmi.core.score.raw'); 96 $def['cmi.core.score.max'] = scorm_isset($userdata, 'cmi.core.score.max'); 97 $def['cmi.core.score.min'] = scorm_isset($userdata, 'cmi.core.score.min'); 98 $def['cmi.core.exit'] = scorm_isset($userdata, 'cmi.core.exit'); 99 $def['cmi.suspend_data'] = scorm_isset($userdata, 'cmi.suspend_data'); 100 $def['cmi.comments'] = scorm_isset($userdata, 'cmi.comments'); 101 $def['cmi.student_preference.language'] = scorm_isset($userdata, 'cmi.student_preference.language'); 102 $def['cmi.student_preference.audio'] = scorm_isset($userdata, 'cmi.student_preference.audio', '0'); 103 $def['cmi.student_preference.speed'] = scorm_isset($userdata, 'cmi.student_preference.speed', '0'); 104 $def['cmi.student_preference.text'] = scorm_isset($userdata, 'cmi.student_preference.text', '0'); 105 return $def; 106 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body