version = eregi_replace('[^a-zA-Z0-9_-]', '',$scorm->version); $scorm->version = strtolower($scorm->version); // Just to be safe $lib_path=drupal_get_path('module', 'SCORM').'/datamodels/'.$scorm->version.'lib.php'; if (!file_exists($lib_path)) { $scorm->version = 'scorm_13'; $lib_path=drupal_get_path('module', 'SCORM').'/datamodels/'.$scorm->version.'lib.php'; } require_once($lib_path); $attempt = db_result(db_query("SELECT max(attempt) FROM {scorm_scoes_track} WHERE userid = %d and scormid= %d",$user->uid,$scorm->id)); if(empty($attempt)) $attempt=1; //TODO: Check is it newattempt? if (($attempt < $scorm->maxattempt) || ($scorm->maxattempt == 0)) { $attempt++; $mode = 'normal'; } $attemptstr = '&attempt=' . $attempt; if($scorm->version=='scorm_12') $result = scorm_get_toc12($scorm,'structurelist',$currentorg,$scoid,$mode,$attempt,true); else $result = scorm_get_toc($scorm,'structurelist',$currentorg,$scoid,$mode,$attempt,true); $sco = $result->sco; if (($mode == 'browse') && ($scorm->hidebrowse == 1)) { $mode = 'normal'; } if ($mode != 'browse') { if ($trackdata = scorm_get_tracks($sco->id,$attempt,$user->uid)) { if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) { $mode = 'review'; } else { $mode = 'normal'; } } else { $mode = 'normal'; } } $scoidstr = '&scoid='.$sco->id; $scoidpop = '&scoid='.$sco->id; $modestr = '&mode='.$mode; if ($mode == 'browse') { $modepop = '&mode='.$mode; } else { $modepop = ''; } $orgstr = '¤torg='.$currentorg; $SESSION->scorm_scoid = $sco->id; $SESSION->scorm_status = 'Not Initialized'; $SESSION->scorm_mode = $mode; $SESSION->scorm_attempt = $attempt; // // Print the page header // $bodyscript = ''; if ($scorm->popup == 1) { $bodyscript = 'onunload="main.close();"'; } //TODO: Complete //$navlinks[] = array('name' => format_string($scorm->name,true), 'link' => "view.php?id=$cm->id", 'type' => 'activityinstance'); //$navigation = build_navigation($navlinks); //$exitlink = ''.$strexit.' '; //$exitlink = ''; $exitlink =''; //$output.=$exitlink; /*print_header($pagetitle, $course->fullname, $navigation, '', '', true, $exitlink.update_module_button($cm->id, $course->id, $strscorm), '', false, $bodyscript);*/ drupal_add_js('api?id='.$cm->id.$scoidstr.$modestr.$attemptstr, 'core', 'header', FALSE, FALSE, FALSE); drupal_add_js(drupal_get_path('module', 'SCORM') . '/js/request.js', 'module'); drupal_add_js(drupal_get_path('module', 'SCORM') . '/js/rd.js', 'module'); drupal_add_js(array('mymodule' => array( 'scormid' => $scorm->id, 'url'=> $base_url.$base_path, 'cssLink' => $base_path . drupal_get_path('module', 'SCORM') . '/css/SCORM.css' )), 'setting'); drupal_add_js(drupal_get_path('module', 'SCORM') .'/js/feedback_popup.js', 'module'); //Add JS to inject CSS into SCORM iframe drupal_add_js(drupal_get_path('module', 'SCORM') .'/js/inject_css.js', 'module'); if (($sco->previd != 0) && ((!isset($sco->previous)) || ($sco->previous == 0))) { $scostr = '&scoid='.$sco->previd; $output.= ' \n"; } else { $output.= ' \n"; } if (($sco->nextid != 0) && ((!isset($sco->next)) || ($sco->next == 0))) { $scostr = '&scoid='.$sco->nextid; $output.= ' \n"; } else { $output.= ' \n"; } $output.='
'; $output.='
hidetoc == 2) || ($scorm->hidetoc == 1)) $output.='style="width:100%"'; //bugfix: popup cck divs r not closed if ($popup == 0) { $output.=">"; } else { $output.=">
"; } // This very big test check if is necessary the "scormtop" div if ( ($mode != 'normal') || // We are not in normal mode so review or browse text will displayed ( ($scorm->hidenav == 0) && // Teacher want to display navigation links ($scorm->hidetoc != 0) && // The buttons has not been displayed ( ( ($sco->previd != 0) && // This is not the first learning object of the package ((!isset($sco->previous)) || ($sco->previous == 0)) // Moodle must manage the previous link ) || ( ($sco->nextid != 0) && // This is not the last learning object of the package ((!isset($sco->next)) || ($sco->next == 0)) // Moodle must manage the next link ) ) ) || ($scorm->hidetoc == 2) // Teacher want to display toc in a small dropdown menu ) { $output.='
'; //TODO: Do we need these modes? $output.= $mode == 'browse' ? '
browsemode
\n"' : ''; $output.= $mode == 'review' ? '
reviewmode
\n"' : ''; if (($scorm->hidenav == 0) || ($scorm->hidetoc == 2) || ($scorm->hidetoc == 1)) { $output.='
'; $orgstr = '&currentorg='.$currentorg; if (($scorm->hidenav == 0) && ($sco->previd != 0) && (!isset($sco->previous) || $sco->previous == 0) && (($scorm->hidetoc == 2) || ($scorm->hidetoc == 1)) ) { // Print the prev LO button $scostr = '&scoid='.$sco->previd; $url=$base_path.$_GET['q'].'?id='.$cm->id.$orgstr.$modestr.$scostr; $output.='
'; $output.='
'; } if ($scorm->hidetoc == 2) { $output.= $result->tocmenu; } if (($scorm->hidenav == 0) && ($sco->nextid != 0) && (!isset($sco->next) || $sco->next == 0) && (($scorm->hidetoc == 2) || ($scorm->hidetoc == 1))) { // Print the next LO button $scostr = '&scoid='.$sco->nextid; $url=$base_path.$_GET['q'].'?id='.$cm->id.$orgstr.$modestr.$scostr; $output.='
'; $output.='
'; } $output.='
'; } $output.='
';// } // The end of the very big test $output.='
'; if ($result->prerequisites) { if ($popup == 0) { /* //Insert start time for viewing sco. $scorm_grades = db_fetch_object(db_query("SELECT * FROM {scorm_grades} WHERE scoid=%d AND userid=%d",$sco->id,$user->uid)); if(!$scorm_grades){ db_query("INSERT INTO {scorm_grades} (scormid,scoid,userid,starttime) VALUES(%d,%d,%d,%d)",$scorm->id,$sco->id,$user->uid,time()); } else { db_query("UPDATE {scorm_grades} SET starttime=%d WHERE scoid=%d and userid=%d",time(),$sco->id,$user->uid); }*/ $fullurl=$base_path."loadsco?id=".$cm->id.$scoidstr.$modestr; $output.= "\n"; } else { //TODO: Improve and test popup // Clean the name for the window as IE is fussy $name = ereg_replace("[^A-Za-z0-9]", "", $scorm->name); if (!$name) { $name = 'DefaultPlayerWindow'; } $name = 'scorm_'.$name; $output.=' '; //Added incase javascript popups are blocked $link = 'Click here to view SCORM'; //print_simple_box(get_string('popupblocked','scorm',$link),'center'); $output.=$link; return $output; } } /*else { print_simple_box(get_string('noprerequisites','scorm'),'center'); }*/ $output.='
'; if(variable_get('scorm_default_footer', SCORM_DEFAULT_FOOTER)) { $output.=$exitlink; } // if ($scorm->hidetoc == 0) { if(variable_get('scorm_default_footer', SCORM_DEFAULT_FOOTER)) { $output.='
'; if ($scorm->hidenav ==0){ $output.='
'; $output.='
'; $orgstr = '&currentorg='.$currentorg; if (($scorm->hidenav == 0) && ($sco->previd != 0) && (!isset($sco->previous) || $sco->previous == 0)) { // Print the prev LO button $scostr = '&scoid='.$sco->previd; $url=$base_path.$_GET['q'].'?id='.$cm->id.$orgstr.$modestr.$scostr; $output.=''; } if (($scorm->hidenav == 0) && ($sco->nextid != 0) && (!isset($sco->next) || $sco->next == 0)) { // Print the next LO button $scostr = '&scoid='.$sco->nextid; $url=$base_path.$_GET['q'].'?id='.$cm->id.$orgstr.$modestr.$scostr; $output.=''; } $output.='
';// tochead } $output.='
'; $output.= $result->toc; $output.='
'; //toctree and tocbox $class = ' class="toc"'; } else { $class = ' class="no-toc"'; } $output.=''; return $output; //print_footer('none'); }//End of function player function scorm_view_display ($scorm) { global $user; //if ($scorm->updatefreq == UPDATE_EVERYTIME){ // require_once($CFG->dirroot.'/mod/scorm/lib.php'); $scorm->instance = $scorm->id; //TODO: Scorm update //scorm_update_instance($scorm); //$organization = optional_param('organization', '', PARAM_INT); //print_simple_box_start('center',$boxwidth); //$output='
Contents
'; $organization = $scorm->launch; $result = db_query("SELECT * FROM {scorm_scoes} WHERE scorm= %d AND organization='' AND launch=''",$scorm->id); $orgs=mysql_num_rows($result); if ($orgs > 1) { $output.="
Organizations:"; while(db_fetch_object($result)){ //TODO: Multiple organizations } $output.="
"; } $orgidentifier = ''; if ($sco = scorm_get_sco($organization, SCO_ONLY)) { if (($sco->organization == '') && ($sco->launch == '')) { $orgidentifier = $sco->identifier; } else { $orgidentifier = $sco->organization; } } /* $orgidentifier = ''; if ($org = get_record('scorm_scoes','id',$organization)) { if (($org->organization == '') && ($org->launch == '')) { $orgidentifier = $org->identifier; } else { $orgidentifier = $org->organization; } }*/ $scorm->version = eregi_replace('[^a-zA-Z0-9_-]', '',$scorm->version); $scorm->version = strtolower($scorm->version); $lib_path=drupal_get_path('module', 'SCORM').'/datamodels/'.$scorm->version.'lib.php'; if (!file_exists($lib_path)) { $scorm->version = 'scorm_13'; $lib_path=drupal_get_path('module', 'SCORM').'/datamodels/'.$scorm->version.'lib.php'; } //TODO: Use Drupal functions require_once($lib_path); if($scorm->version=='scorm_12') $result = scorm_get_toc12($scorm,'structlist',$orgidentifier); else $result = scorm_get_toc($scorm,'structlist',$orgidentifier); //$result = scorm_get_toc($scorm,'structlist',$orgidentifier); $incomplete = $result->incomplete; $output.=$result->toc; //$output.= $result->toc; // print_simple_box_end(); /* $output.='
'; if (($incomplete === false) && (($result->attemptleft > 0)||($scorm->maxattempt == 0))) { $output.='
'; }*/ return $output; } function autoplay($scormid){ $firstsco = db_fetch_object(db_query("SELECT id,organization FROM {scorm_scoes} WHERE scorm= %d AND organization!=''",$scormid)); if($firstsco){ return $firstsco; } return $false; } ?>