MDL-14741: use the default html editor, as chosen in the admin settings
[moodle.git] / mod / scorm / lib.php
CommitLineData
e4aa175a 1<?php // $Id$
2
e4aa175a 3/**
4* Given an object containing all the necessary data,
7cac0c4b 5* (defined by the form in mod_form.php) this function
e4aa175a 6* will create a new instance and return the id number
7* of the new instance.
8*
9* @param mixed $scorm Form data
10* @return int
11*/
23ab8e8d 12//require_once('locallib.php');
e4aa175a 13function scorm_add_instance($scorm) {
c18269c7 14 global $CFG, $DB;
a679d64d 15
16 require_once('locallib.php');
17
18 if (($packagedata = scorm_check_package($scorm)) != null) {
19 $scorm->pkgtype = $packagedata->pkgtype;
20 $scorm->datadir = $packagedata->datadir;
21 $scorm->launch = $packagedata->launch;
76ea4fb4 22 $scorm->parse = 1;
76ea4fb4 23
a679d64d 24 $scorm->timemodified = time();
25 if (!scorm_external_link($scorm->reference)) {
26 $scorm->md5hash = md5_file($CFG->dataroot.'/'.$scorm->course.'/'.$scorm->reference);
76ea4fb4 27 } else {
a679d64d 28 $scorm->dir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
29 $scorm->md5hash = md5_file($scorm->dir.$scorm->datadir.'/'.basename($scorm->reference));
76ea4fb4 30 }
a679d64d 31
e4aa175a 32 $scorm = scorm_option2text($scorm);
33 $scorm->width = str_replace('%','',$scorm->width);
34 $scorm->height = str_replace('%','',$scorm->height);
35
36 //sanitize submitted values a bit
37 $scorm->width = clean_param($scorm->width, PARAM_INT);
38 $scorm->height = clean_param($scorm->height, PARAM_INT);
b3659259 39
40 if (!isset($scorm->whatgrade)) {
41 $scorm->whatgrade = 0;
42 }
a30b6819 43 $scorm->grademethod = ($scorm->whatgrade * 10) + $scorm->grademethod;
e4aa175a 44
c18269c7 45 $id = $DB->insert_record('scorm', $scorm);
e4aa175a 46
8949f8df 47 if (scorm_external_link($scorm->reference) || ((basename($scorm->reference) != 'imsmanifest.xml') && ($scorm->reference[0] != '#'))) {
e4aa175a 48 // Rename temp scorm dir to scorm id
49 $scorm->dir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
50 rename($scorm->dir.$scorm->datadir,$scorm->dir.'/'.$id);
51 }
52
53 // Parse scorm manifest
5c1ac70c 54 if ($scorm->parse == 1) {
e4aa175a 55 $scorm->id = $id;
56 $scorm->launch = scorm_parse($scorm);
c18269c7 57 $DB->set_field('scorm', 'launch', $scorm->launch, array('id'=>$scorm->id));
e4aa175a 58 }
59
c18269c7 60 scorm_grade_item_update($scorm);
531fa830 61
e4aa175a 62 return $id;
a679d64d 63 } else {
7cac0c4b 64 print_error('badpackage','scorm');
e4aa175a 65 }
66}
67
68/**
69* Given an object containing all the necessary data,
7cac0c4b 70* (defined by the form in mod_form.php) this function
e4aa175a 71* will update an existing instance with new data.
72*
73* @param mixed $scorm Form data
74* @return int
75*/
76function scorm_update_instance($scorm) {
c18269c7 77 global $CFG, $DB;
e4aa175a 78
a679d64d 79 require_once('locallib.php');
76ea4fb4 80
23ab8e8d 81 $scorm->parse = 0;
a679d64d 82 if (($packagedata = scorm_check_package($scorm)) != null) {
83 $scorm->pkgtype = $packagedata->pkgtype;
84 if ($packagedata->launch == 0) {
85 $scorm->launch = $packagedata->launch;
86 $scorm->datadir = $packagedata->datadir;
76ea4fb4 87 $scorm->parse = 1;
a679d64d 88 if (!scorm_external_link($scorm->reference)) {
89 $scorm->md5hash = md5_file($CFG->dataroot.'/'.$scorm->course.'/'.$scorm->reference);
90 } else {
91 $scorm->dir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
92 $scorm->md5hash = md5_file($scorm->dir.$scorm->datadir.'/'.basename($scorm->reference));
93 }
76ea4fb4 94 }
95 }
96
e4aa175a 97 $scorm->timemodified = time();
98 $scorm->id = $scorm->instance;
bfe8c2f0 99
e4aa175a 100 $scorm = scorm_option2text($scorm);
101 $scorm->width = str_replace('%','',$scorm->width);
102 $scorm->height = str_replace('%','',$scorm->height);
103
b3659259 104 if (!isset($scorm->whatgrade)) {
105 $scorm->whatgrade = 0;
106 }
a30b6819 107 $scorm->grademethod = ($scorm->whatgrade * 10) + $scorm->grademethod;
108
e4aa175a 109 // Check if scorm manifest needs to be reparsed
5c1ac70c 110 if ($scorm->parse == 1) {
e4aa175a 111 $scorm->dir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
5c1ac70c 112 if (is_dir($scorm->dir.'/'.$scorm->id)) {
e4aa175a 113 scorm_delete_files($scorm->dir.'/'.$scorm->id);
5c1ac70c 114 }
115 if (isset($scorm->datadir) && ($scorm->datadir != $scorm->id) &&
8949f8df 116 (scorm_external_link($scorm->reference) || ((basename($scorm->reference) != 'imsmanifest.xml') && ($scorm->reference[0] != '#')))) {
e4aa175a 117 rename($scorm->dir.$scorm->datadir,$scorm->dir.'/'.$scorm->id);
118 }
a30b6819 119
e4aa175a 120 $scorm->launch = scorm_parse($scorm);
a9d22c84 121 } else {
c18269c7 122 $oldscorm = $DB->get_record('scorm', array('id'=>$scorm->id));
a9d22c84 123 $scorm->reference = $oldscorm->reference; // This fix a problem with Firefox when the teacher choose Cancel on overwrite question
e4aa175a 124 }
a9d22c84 125
c18269c7 126 if ($result = $DB->update_record('scorm', $scorm)) {
127 scorm_grade_item_update($scorm);
531fa830 128 }
129
130 return $result;
e4aa175a 131}
132
133/**
134* Given an ID of an instance of this module,
135* this function will permanently delete the instance
136* and any data that depends on it.
137*
138* @param int $id Scorm instance id
139* @return boolean
140*/
141function scorm_delete_instance($id) {
c18269c7 142 global $CFG, $DB;
e4aa175a 143
c18269c7 144 if (! $scorm = $DB->get_record('scorm', array('id'=>$id))) {
e4aa175a 145 return false;
146 }
147
148 $result = true;
149
2b3447c3 150 $scorm->dir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
151 if (is_dir($scorm->dir.'/'.$scorm->id)) {
152 // Delete any dependent files
153 require_once('locallib.php');
154 scorm_delete_files($scorm->dir.'/'.$scorm->id);
155 }
e4aa175a 156
157 // Delete any dependent records
c18269c7 158 if (! $DB->delete_records('scorm_scoes_track', array('scormid'=>$scorm->id))) {
e4aa175a 159 $result = false;
160 }
c18269c7 161 if ($scoes = $DB->get_records('scorm_scoes', array('scorm'=>$scorm->id))) {
b3659259 162 foreach ($scoes as $sco) {
c18269c7 163 if (! $DB->delete_records('scorm_scoes_data', array('scoid'=>$sco->id))) {
b3659259 164 $result = false;
165 }
166 }
c18269c7 167 $DB->delete_records('scorm_scoes', array('scorm'=>$scorm->id));
b3659259 168 } else {
e4aa175a 169 $result = false;
170 }
c18269c7 171 if (! $DB->delete_records('scorm', array('id'=>$scorm->id))) {
e4aa175a 172 $result = false;
173 }
a30b6819 174
c18269c7 175 /*if (! $DB->delete_records('scorm_sequencing_controlmode', array('scormid'=>$scorm->id))) {
e4aa175a 176 $result = false;
177 }
c18269c7 178 if (! $DB->delete_records('scorm_sequencing_rolluprules', array('scormid'=>$scorm->id))) {
e4aa175a 179 $result = false;
180 }
c18269c7 181 if (! $DB->delete_records('scorm_sequencing_rolluprule', array('scormid'=>$scorm->id))) {
e4aa175a 182 $result = false;
183 }
c18269c7 184 if (! $DB->delete_records('scorm_sequencing_rollupruleconditions', array('scormid'=>$scorm->id))) {
e4aa175a 185 $result = false;
186 }
c18269c7 187 if (! $DB->delete_records('scorm_sequencing_rolluprulecondition', array('scormid'=>$scorm->id))) {
e4aa175a 188 $result = false;
189 }
c18269c7 190 if (! $DB->delete_records('scorm_sequencing_rulecondition', array('scormid'=>$scorm->id))) {
e4aa175a 191 $result = false;
192 }
c18269c7 193 if (! $DB->delete_records('scorm_sequencing_ruleconditions', array('scormid'=>$scorm->id))) {
e4aa175a 194 $result = false;
531fa830 195 }*/
196
c18269c7 197 scorm_grade_item_delete($scorm);
531fa830 198
e4aa175a 199 return $result;
200}
201
202/**
203* Return a small object with summary information about what a
204* user has done with a given particular instance of this module
205* Used for user activity reports.
206*
207* @param int $course Course id
208* @param int $user User id
209* @param int $mod
210* @param int $scorm The scorm id
211* @return mixed
212*/
213function scorm_user_outline($course, $user, $mod, $scorm) {
531fa830 214 global $CFG;
a30b6819 215 require_once('locallib.php');
216
217 $return = scorm_grade_user($scorm, $user->id, true);
218
e4aa175a 219 return $return;
220}
221
222/**
223* Print a detailed representation of what a user has done with
224* a given particular instance of this module, for user activity reports.
225*
226* @param int $course Course id
227* @param int $user User id
228* @param int $mod
229* @param int $scorm The scorm id
230* @return boolean
231*/
232function scorm_user_complete($course, $user, $mod, $scorm) {
233 global $CFG;
234
235 $liststyle = 'structlist';
236 $scormpixdir = $CFG->modpixpath.'/scorm/pix';
237 $now = time();
238 $firstmodify = $now;
239 $lastmodify = 0;
240 $sometoreport = false;
241 $report = '';
242
243 if ($orgs = get_records_select('scorm_scoes',"scorm='$scorm->id' AND organization='' AND launch=''",'id','id,identifier,title')) {
244 if (count($orgs) <= 1) {
245 unset($orgs);
246 $orgs[]->identifier = '';
247 }
248 $report .= '<div class="mod-scorm">'."\n";
249 foreach ($orgs as $org) {
250 $organizationsql = '';
251 $currentorg = '';
252 if (!empty($org->identifier)) {
253 $report .= '<div class="orgtitle">'.$org->title.'</div>';
254 $currentorg = $org->identifier;
255 $organizationsql = "AND organization='$currentorg'";
256 }
257 $report .= "<ul id='0' class='$liststyle'>";
258 if ($scoes = get_records_select('scorm_scoes',"scorm='$scorm->id' $organizationsql order by id ASC")){
9fb2de4e 259 // drop keys so that we can access array sequentially
260 $scoes = array_values($scoes);
e4aa175a 261 $level=0;
262 $sublist=1;
263 $parents[$level]='/';
9fb2de4e 264 foreach ($scoes as $pos=>$sco) {
e4aa175a 265 if ($parents[$level]!=$sco->parent) {
266 if ($level>0 && $parents[$level-1]==$sco->parent) {
267 $report .= "\t\t</ul></li>\n";
268 $level--;
269 } else {
270 $i = $level;
271 $closelist = '';
272 while (($i > 0) && ($parents[$level] != $sco->parent)) {
273 $closelist .= "\t\t</ul></li>\n";
274 $i--;
275 }
276 if (($i == 0) && ($sco->parent != $currentorg)) {
277 $report .= "\t\t<li><ul id='$sublist' class='$liststyle'>\n";
278 $level++;
279 } else {
280 $report .= $closelist;
281 $level = $i;
282 }
283 $parents[$level]=$sco->parent;
284 }
285 }
286 $report .= "\t\t<li>";
9fb2de4e 287 if (isset($scoes[$pos+1])) {
288 $nextsco = $scoes[$pos+1];
289 } else {
290 $nextsco = false;
291 }
e4aa175a 292 if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
293 $sublist++;
294 } else {
7150b8ae 295 $report .= '<img src="'.$scormpixdir.'/spacer.gif" alt="" />';
e4aa175a 296 }
297
298 if ($sco->launch) {
299 require_once('locallib.php');
300 $score = '';
301 $totaltime = '';
302 if ($usertrack=scorm_get_tracks($sco->id,$user->id)) {
303 if ($usertrack->status == '') {
304 $usertrack->status = 'notattempted';
305 }
306 $strstatus = get_string($usertrack->status,'scorm');
307 $report .= "<img src='".$scormpixdir.'/'.$usertrack->status.".gif' alt='$strstatus' title='$strstatus' />";
308 if ($usertrack->timemodified != 0) {
309 if ($usertrack->timemodified > $lastmodify) {
310 $lastmodify = $usertrack->timemodified;
311 }
312 if ($usertrack->timemodified < $firstmodify) {
313 $firstmodify = $usertrack->timemodified;
314 }
315 }
316 } else {
317 if ($sco->scormtype == 'sco') {
318 $report .= '<img src="'.$scormpixdir.'/'.'notattempted.gif" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
319 } else {
320 $report .= '<img src="'.$scormpixdir.'/'.'asset.gif" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
321 }
322 }
323 $report .= "&nbsp;$sco->title $score$totaltime</li>\n";
324 if ($usertrack !== false) {
325 $sometoreport = true;
326 $report .= "\t\t\t<li><ul class='$liststyle'>\n";
327 foreach($usertrack as $element => $value) {
328 if (substr($element,0,3) == 'cmi') {
329 $report .= '<li>'.$element.' => '.$value.'</li>';
330 }
331 }
332 $report .= "\t\t\t</ul></li>\n";
333 }
334 } else {
335 $report .= "&nbsp;$sco->title</li>\n";
336 }
337 }
338 for ($i=0;$i<$level;$i++) {
339 $report .= "\t\t</ul></li>\n";
340 }
341 }
342 $report .= "\t</ul><br />\n";
343 }
344 $report .= "</div>\n";
345 }
346 if ($sometoreport) {
347 if ($firstmodify < $now) {
348 $timeago = format_time($now - $firstmodify);
349 echo get_string('firstaccess','scorm').': '.userdate($firstmodify).' ('.$timeago.")<br />\n";
350 }
351 if ($lastmodify > 0) {
352 $timeago = format_time($now - $lastmodify);
353 echo get_string('lastaccess','scorm').': '.userdate($lastmodify).' ('.$timeago.")<br />\n";
354 }
355 echo get_string('report','scorm').":<br />\n";
356 echo $report;
357 } else {
dabfd0ed 358 print_string('noactivity','scorm');
e4aa175a 359 }
360
361 return true;
362}
363
e4aa175a 364/**
365* Function to be run periodically according to the moodle cron
366* This function searches for things that need to be done, such
367* as sending out mail, toggling flags etc ...
368*
369* @return boolean
370*/
371function scorm_cron () {
372
373 global $CFG;
a679d64d 374
375 require_once('locallib.php');
376
377 $sitetimezone = $CFG->timezone;
378 /// Now see if there are any digest mails waiting to be sent, and if we should send them
bfe8c2f0 379 if (!isset($CFG->scorm_updatetimelast)) { // To catch the first time
380 set_config('scorm_updatetimelast', 0);
381 }
382
a679d64d 383 $timenow = time();
bfe8c2f0 384 $updatetime = usergetmidnight($timenow, $sitetimezone) + ($CFG->scorm_updatetime * 3600);
a679d64d 385
386 if ($CFG->scorm_updatetimelast < $updatetime and $timenow > $updatetime) {
387
bfe8c2f0 388 set_config('scorm_updatetimelast', $timenow);
e4aa175a 389
376c9c70 390 mtrace('Updating scorm packages which require daily update');//We are updating
bfe8c2f0 391
a679d64d 392 $scormsupdate = get_records('scorm','updatefreq',UPDATE_EVERYDAY);
393 if (!empty($scormsupdate)) {
394 foreach($scormsupdate as $scormupdate) {
395 $scormupdate->instance = $scormupdate->id;
396 $id = scorm_update_instance($scormupdate);
397 }
398 }
399 }
400
e4aa175a 401 return true;
402}
403
404/**
531fa830 405 * Return grade for given user or all users.
406 *
407 * @param int $scormid id of scorm
408 * @param int $userid optional user id, 0 means all users
409 * @return array array of grades, false if none
410 */
411function scorm_get_user_grades($scorm, $userid=0) {
e4aa175a 412 global $CFG;
531fa830 413 require_once('locallib.php');
414
415 $grades = array();
416 if (empty($userid)) {
417 if ($scousers = get_records_select('scorm_scoes_track', "scormid='$scorm->id' GROUP BY userid", "", "userid,null")) {
418 foreach ($scousers as $scouser) {
419 $grades[$scouser->userid] = new object();
420 $grades[$scouser->userid]->id = $scouser->userid;
421 $grades[$scouser->userid]->userid = $scouser->userid;
422 $grades[$scouser->userid]->rawgrade = scorm_grade_user($scorm, $scouser->userid);
423 }
424 } else {
425 return false;
426 }
e4aa175a 427
531fa830 428 } else {
429 if (!get_records_select('scorm_scoes_track', "scormid='$scorm->id' AND userid='$userid' GROUP BY userid", "", "userid,null")) {
430 return false; //no attempt yet
431 }
432 $grades[$userid] = new object();
433 $grades[$userid]->id = $userid;
434 $grades[$userid]->userid = $userid;
435 $grades[$userid]->rawgrade = scorm_grade_user($scorm, $userid);
e4aa175a 436 }
e4aa175a 437
531fa830 438 return $grades;
439}
440
441/**
442 * Update grades in central gradebook
443 *
444 * @param object $scorm null means all scormbases
445 * @param int $userid specific user only, 0 mean all
446 */
447function scorm_update_grades($scorm=null, $userid=0, $nullifnone=true) {
448 global $CFG;
449 if (!function_exists('grade_update')) { //workaround for buggy PHP versions
450 require_once($CFG->libdir.'/gradelib.php');
451 }
452
453 if ($scorm != null) {
454 if ($grades = scorm_get_user_grades($scorm, $userid)) {
50acc613 455 scorm_grade_item_update($scorm, $grades);
531fa830 456
457 } else if ($userid and $nullifnone) {
458 $grade = new object();
459 $grade->userid = $userid;
460 $grade->rawgrade = NULL;
eafb9d9e 461 scorm_grade_item_update($scorm, $grade);
462
463 } else {
464 scorm_grade_item_update($scorm);
e4aa175a 465 }
531fa830 466
e4aa175a 467 } else {
531fa830 468 $sql = "SELECT s.*, cm.idnumber as cmidnumber
469 FROM {$CFG->prefix}scorm s, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m
470 WHERE m.name='scorm' AND m.id=cm.module AND cm.instance=s.id";
471 if ($rs = get_recordset_sql($sql)) {
03cedd62 472 while ($scorm = rs_fetch_next_record($rs)) {
03cedd62 473 scorm_update_grades($scorm, 0, false);
531fa830 474 }
475 rs_close($rs);
476 }
e4aa175a 477 }
531fa830 478}
e4aa175a 479
531fa830 480/**
481 * Update/create grade item for given scorm
482 *
483 * @param object $scorm object with extra cmidnumber
0b5a80a1 484 * @param mixed optional array/object of grade(s); 'reset' means reset grades in gradebook
531fa830 485 * @return object grade_item
486 */
0b5a80a1 487function scorm_grade_item_update($scorm, $grades=NULL) {
531fa830 488 global $CFG;
489 if (!function_exists('grade_update')) { //workaround for buggy PHP versions
490 require_once($CFG->libdir.'/gradelib.php');
491 }
492
493 $params = array('itemname'=>$scorm->name, 'idnumber'=>$scorm->cmidnumber);
494
495 if (($scorm->grademethod % 10) == 0) { // GRADESCOES
496 if ($maxgrade = count_records_select('scorm_scoes',"scorm='$scorm->id' AND launch<>''")) {
497 $params['gradetype'] = GRADE_TYPE_VALUE;
498 $params['grademax'] = $maxgrade;
499 $params['grademin'] = 0;
500 } else {
501 $params['gradetype'] = GRADE_TYPE_NONE;
e4aa175a 502 }
531fa830 503 } else {
504 $params['gradetype'] = GRADE_TYPE_VALUE;
505 $params['grademax'] = $scorm->maxgrade;
506 $params['grademin'] = 0;
e4aa175a 507 }
531fa830 508
0b5a80a1 509 if ($grades === 'reset') {
510 $params['reset'] = true;
511 $grades = NULL;
512 }
513
514 return grade_update('mod/scorm', $scorm->course, 'mod', 'scorm', $scorm->id, 0, $grades, $params);
531fa830 515}
516
517/**
518 * Delete grade item for given scorm
519 *
520 * @param object $scorm object
521 * @return object grade_item
522 */
523function scorm_grade_item_delete($scorm) {
524 global $CFG;
525 require_once($CFG->libdir.'/gradelib.php');
526
527 return grade_update('mod/scorm', $scorm->course, 'mod', 'scorm', $scorm->id, 0, NULL, array('deleted'=>1));
e4aa175a 528}
529
530function scorm_get_view_actions() {
531 return array('pre-view','view','view all','report');
532}
533
534function scorm_get_post_actions() {
535 return array();
536}
537
e4aa175a 538function scorm_option2text($scorm) {
539 global $SCORM_POPUP_OPTIONS;
e4aa175a 540 if (isset($scorm->popup)) {
76ea4fb4 541 if ($scorm->popup == 1) {
e4aa175a 542 $optionlist = array();
543 foreach ($SCORM_POPUP_OPTIONS as $name => $option) {
544 if (isset($scorm->$name)) {
545 $optionlist[] = $name.'='.$scorm->$name;
546 } else {
547 $optionlist[] = $name.'=0';
548 }
549 }
550 $scorm->options = implode(',', $optionlist);
551 } else {
552 $scorm->options = '';
553 }
554 } else {
555 $scorm->popup = 0;
556 $scorm->options = '';
557 }
558 return $scorm;
559}
560
0b5a80a1 561/**
562 * Implementation of the function for printing the form elements that control
563 * whether the course reset functionality affects the scorm.
564 * @param $mform form passed by reference
565 */
566function scorm_reset_course_form_definition(&$mform) {
567 $mform->addElement('header', 'scormheader', get_string('modulenameplural', 'scorm'));
568 $mform->addElement('advcheckbox', 'reset_scorm', get_string('deleteallattempts','scorm'));
569}
570
571/**
572 * Course reset form defaults.
573 */
574function scorm_reset_course_form_defaults($course) {
575 return array('reset_scorm'=>1);
576}
577
578/**
579 * Removes all grades from gradebook
580 * @param int $courseid
581 * @param string optional type
582 */
583function scorm_reset_gradebook($courseid, $type='') {
584 global $CFG;
585
586 $sql = "SELECT s.*, cm.idnumber as cmidnumber, s.course as courseid
587 FROM {$CFG->prefix}scorm s, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m
588 WHERE m.name='scorm' AND m.id=cm.module AND cm.instance=s.id AND s.course=$courseid";
589
590 if ($scorms = get_records_sql($sql)) {
591 foreach ($scorms as $scorm) {
592 scorm_grade_item_update($scorm, 'reset');
593 }
594 }
595}
596
597/**
598 * Actual implementation of the rest coures functionality, delete all the
599 * scorm attempts for course $data->courseid.
600 * @param $data the data submitted from the reset course.
601 * @return array status array
602 */
603function scorm_reset_userdata($data) {
604 global $CFG;
605
606 $componentstr = get_string('modulenameplural', 'scorm');
607 $status = array();
608
609 if (!empty($data->reset_scorm)) {
610 $scormssql = "SELECT s.id
611 FROM {$CFG->prefix}scorm s
612 WHERE s.course={$data->courseid}";
613
614 delete_records_select('scorm_scoes_track', "scormid IN ($scormssql)");
615
616 // remove all grades from gradebook
617 if (empty($data->reset_gradebook_grades)) {
618 scorm_reset_gradebook($data->courseid);
619 }
620
621 $status[] = array('component'=>$componentstr, 'item'=>get_string('deleteallattempts', 'scorm'), 'error'=>false);
622 }
623
624 // no dates to shift here
625
626 return $status;
627}
628
5c1ac70c 629?>