New version with SCORM 2004 sequencing done by Pham Minh Duc

This commit is contained in:
bobopinna 2006-05-25 10:20:45 +00:00
parent be41c83691
commit 1a50a1f91e
21 changed files with 5696 additions and 3944 deletions

View File

@ -1,350 +1,351 @@
<?php
require_once('../../config.php');
require_once('locallib.php');
$command = required_param('command', PARAM_ALPHA);
$sessionid = required_param('session_id', PARAM_ALPHANUM);
$aiccdata = optional_param('aicc_data', '', PARAM_RAW);
require_login();
if (!empty($command) && confirm_sesskey($sessionid)) {
$command = strtolower($command);
if (isset($SESSION->scorm_scoid)) {
$scoid = $SESSION->scorm_scoid;
} else {
error('Invalid script call');
}
$mode = 'normal';
if (isset($SESSION->scorm_mode)) {
$mode = $SESSION->scorm_mode;
}
$status = 'Not Initialized';
if (isset($SESSION->scorm_status)) {
$status = $SESSION->scorm_status;
}
if (isset($SESSION->attempt)) {
$attempt = $SESSION->attempt;
} else {
$attempt = 1;
}
if ($sco = get_record('scorm_scoes','id',$scoid)) {
if (!$scorm = get_record('scorm','id',$sco->scorm)) {
error('Invalid script call');
}
} else {
error('Invalid script call');
}
if ($scorm = get_record('scorm','id',$sco->scorm)) {
switch ($command) {
case 'getparam':
if ($status == 'Not Initialized') {
$SESSION->scorm_status = 'Running';
$status = 'Running';
}
if ($status != 'Running') {
echo "error = 101\nerror_text = Terminated\n";
} else {
if ($usertrack=scorm_get_tracks($scoid,$USER->id,$attempt)) {
$userdata = $usertrack;
} else {
$userdata->status = '';
$userdata->score_raw = '';
}
$userdata->student_id = $USER->username;
$userdata->student_name = $USER->lastname .', '. $USER->firstname;
$userdata->mode = $mode;
if ($userdata->mode == 'normal') {
$userdata->credit = 'credit';
} else {
$userdata->credit = 'no-credit';
}
if ($sco = get_record('scorm_scoes','id',$scoid)) {
$userdata->course_id = $sco->identifier;
$userdata->datafromlms = $sco->datafromlms;
$userdata->masteryscore = $sco->masteryscore;
$userdata->maxtimeallowed = $sco->maxtimeallowed;
$userdata->timelimitaction = $sco->timelimitaction;
echo "error = 0\nerror_text = Successful\naicc_data=\n";
echo "[Core]\n";
echo 'Student_ID = '.$userdata->student_id."\n";
echo 'Student_Name = '.$userdata->student_name."\n";
if (isset($userdata->{'cmi.core.lesson_location'})) {
echo 'Lesson_Location = '.$userdata->{'cmi.core.lesson_location'}."\n";
} else {
echo 'Lesson_Location = '."\n";
}
echo 'Credit = '.$userdata->credit."\n";
if (isset($userdata->status)) {
if ($userdata->status == '') {
$userdata->entry = ', ab-initio';
} else {
if (isset($userdata->{'cmi.core.exit'}) && ($userdata->{'cmi.core.exit'} == 'suspend')) {
$userdata->entry = ', resume';
} else {
$userdata->entry = '';
}
}
}
if (isset($userdata->{'cmi.core.lesson_status'})) {
echo 'Lesson_Status = '.$userdata->{'cmi.core.lesson_status'}.$userdata->entry."\n";
$SESSION->scorm_lessonstatus = $userdata->{'cmi.core.lesson_status'};
} else {
echo 'Lesson_Status = not attempted'.$userdata->entry."\n";
$SESSION->scorm_lessonstatus = 'not attempted';
}
if (isset($userdata->{'cmi.core.score.raw'})) {
$max = '';
$min = '';
if (isset($userdata->{'cmi.core.score.max'}) && !empty($userdata->{'cmi.core.score.max'})) {
$max = ', '.$userdata->{'cmi.core.score.max'};
if (isset($userdata->{'cmi.core.score.min'}) && !empty($userdata->{'cmi.core.score.min'})) {
$min = ', '.$userdata->{'cmi.core.score.min'};
}
}
echo 'Score = '.$userdata->{'cmi.core.score.raw'}.$max.$min."\n";
} else {
echo 'Score = '."\n";
}
if (isset($userdata->{'cmi.core.total_time'})) {
echo 'Time = '.$userdata->{'cmi.core.total_time'}."\n";
} else {
echo 'Time = '.'00:00:00'."\n";
}
echo 'Lesson_Mode = '.$userdata->mode."\n";
if (isset($userdata->{'cmi.suspend_data'})) {
echo "[Core_Lesson]\n".$userdata->{'cmi.suspend_data'}."\n";
} else {
echo "[Core_Lesson]\n"."\n";
}
echo "[Core_Vendor]\n".$userdata->datafromlms."\n";
echo "[Evaluation]\nCourse_ID = {".$userdata->course_id."}\n";
echo "[Student_Data]\n";
echo 'Mastery_Score = '.$userdata->masteryscore."\n";
echo 'Max_Time_Allowed = '.$userdata->maxtimeallowed."\n";
echo 'Time_Limit_Action = '.$userdata->timelimitaction."\n";
} else {
error('Sco not found');
}
}
break;
case 'putparam':
if ($status == 'Running') {
if (!empty($aiccdata) && isstudent($scorm->course)) {
$initlessonstatus = 'not attempted';
$lessonstatus = 'not attempted';
if (isset($SESSION->scorm_lessonstatus)) {
$initlessonstatus = $SESSION->scorm_lessonstatus;
}
$score = '';
$datamodel['lesson_location'] = 'cmi.core.lesson_location';
$datamodel['lesson_status'] = 'cmi.core.lesson_status';
$datamodel['score'] = 'cmi.core.score.raw';
$datamodel['time'] = 'cmi.core.session_time';
$datamodel['[core_lesson]'] = 'cmi.suspend_data';
$datamodel['[comments]'] = 'cmi.comments';
$datarows = explode("\n",$aiccdata);
reset($datarows);
while ((list(,$datarow) = each($datarows)) !== false) {
if (($equal = strpos($datarow, '=')) !== false) {
$element = strtolower(trim(substr($datarow,0,$equal)));
$value = trim(substr($datarow,$equal+1));
if (isset($datamodel[$element])) {
$element = $datamodel[$element];
switch ($element) {
case 'cmi.core.lesson_location':
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
break;
case 'cmi.core.lesson_status':
$statuses = array(
'passed' => 'passed',
'completed' => 'completed',
'failed' => 'failed',
'incomplete' => 'incomplete',
'browsed' => 'browsed',
'not attempted' => 'not attempted',
'p' => 'passed',
'c' => 'completed',
'f' => 'failed',
'i' => 'incomplete',
'b' => 'browsed',
'n' => 'not attempted'
);
$exites = array(
'logout' => 'logout',
'time-out' => 'time-out',
'suspend' => 'suspend',
'l' => 'logout',
't' => 'time-out',
's' => 'suspend',
);
$values = explode(',',$value);
$value = '';
if (count($values) > 1) {
$value = trim(strtolower($values[1]));
if (isset($exites[$value])) {
$value = $exites[$value];
}
}
if (empty($value) || isset($exites[$value])) {
$subelement = 'cmi.core.exit';
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
}
$value = trim(strtolower($values[0]));
if (isset($statuses[$value]) && ($mode == 'normal')) {
$value = $statuses[$value];
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
$lessonstatus = $value;
break;
case 'cmi.core.score.raw':
$values = explode(',',$value);
if ((count($values) > 1) && ($values[1] >= $values[0]) && is_numeric($values[1])) {
$subelement = 'cmi.core.score.max';
$value = trim($values[1]);
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
if ((count($values) == 3) && ($values[2] <= $values[0]) && is_numeric($values[2])) {
$subelement = 'cmi.core.score.min';
$value = trim($values[2]);
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
}
}
$value = '';
if (is_numeric($values[0])) {
$value = trim($values[0]);
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
$score = $value;
break;
case 'cmi.core.session_time':
$SESSION->scorm_session_time = $value;
break;
}
}
} else {
if (isset($datamodel[strtolower(trim($datarow))])) {
$element = $datamodel[strtolower(trim($datarow))];
$value = '';
while ((($datarow = current($datarows)) !== false) && (substr($datarow,0,1) != '[')) {
$value .= scorm_utf8_to_entities(datarow);
next($datarows);
}
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
}
}
if (($mode == 'browse') && ($initlessonstatus == 'not attempted')){
$lessonstatus = 'browsed';
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, 'cmi.core.lesson_status', 'browsed');
}
if ($mode == 'normal') {
if ($lessonstatus == 'completed') {
if (!empty($sco->masteryscore) && !empty($score) && ($score >= $sco->masteryscore)) {
$lessonstatus = 'passed';
} else {
$lessonstatus = 'failed';
}
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, 'cmi.core.lesson_status', $lessonstatus);
}
}
}
echo "error = 0\nerror_text = Successful\n";
} else if ($status == 'Terminated') {
echo "error = 1\nerror_text = Terminated\n";
} else {
echo "error = 1\nerror_text = Not Initialized\n";
}
break;
case 'putcomments':
if ($status == 'Running') {
echo "error = 0\nerror_text = Successful\n";
} else if ($status == 'Terminated') {
echo "error = 1\nerror_text = Terminated\n";
} else {
echo "error = 1\nerror_text = Not Initialized\n";
}
break;
case 'putinteractions':
if ($status == 'Running') {
echo "error = 0\nerror_text = Successful\n";
} else if ($status == 'Terminated') {
echo "error = 1\nerror_text = Terminated\n";
} else {
echo "error = 1\nerror_text = Not Initialized\n";
}
break;
case 'putobjectives':
if ($status == 'Running') {
echo "error = 0\nerror_text = Successful\n";
} else if ($status == 'Terminated') {
echo "error = 1\nerror_text = Terminated\n";
} else {
echo "error = 1\nerror_text = Not Initialized\n";
}
break;
case 'putpath':
if ($status == 'Running') {
echo "error = 0\nerror_text = Successful\n";
} else if ($status == 'Terminated') {
echo "error = 1\nerror_text = Terminated\n";
} else {
echo "error = 1\nerror_text = Not Initialized\n";
}
break;
case 'putperformance':
if ($status == 'Running') {
echo "error = 0\nerror_text = Successful\n";
} else if ($status == 'Terminated') {
echo "error = 1\nerror_text = Terminated\n";
} else {
echo "error = 1\nerror_text = Not Initialized\n";
}
break;
case 'exitau':
if ($status == 'Running') {
if (isset($SESSION->scorm_session_time) && ($SESSION->scorm_session_time != '')) {
if ($track = get_record_select('scorm_scoes_track',"userid='$USER->id' AND scormid='$scorm->id' AND scoid='$sco->id' AND element='cmi.core.total_time'")) {
// Add session_time to total_time
$value = scorm_add_time($track->value, $SESSION->scorm_session_time);
$track->value = $value;
$track->timemodified = time();
$id = update_record('scorm_scoes_track',$track);
} else {
$track->userid = $USER->id;
$track->scormid = $scorm->id;
$track->scoid = $sco->id;
$track->element = 'cmi.core.total_time';
$track->value = $SESSION->scorm_session_time;
$track->timemodified = time();
$id = insert_record('scorm_scoes_track',$track);
}
}
$SESSION->scorm_status = 'Terminated';
$SESSION->scorm_session_time = '';
echo "error = 0\nerror_text = Successful\n";
} else if ($status == 'Terminated') {
echo "error = 1\nerror_text = Terminated\n";
} else {
echo "error = 1\nerror_text = Not Initialized\n";
}
break;
default:
echo "error = 1\nerror_text = Invalid Command\n";
break;
}
}
} else {
if (empty($command)) {
echo "error = 1\nerror_text = Invalid Command\n";
} else {
echo "error = 3\nerror_text = Invalid Session ID\n";
}
}
?>
<?php
require_once('../../config.php');
require_once('locallib.php');
require_once('sequencinglib.php');
$command = required_param('command', PARAM_ALPHA);
$sessionid = required_param('session_id', PARAM_ALPHANUM);
$aiccdata = optional_param('aicc_data', '', PARAM_RAW);
require_login();
if (!empty($command) && confirm_sesskey($sessionid)) {
$command = strtolower($command);
if (isset($SESSION->scorm_scoid)) {
$scoid = $SESSION->scorm_scoid;
} else {
error('Invalid script call');
}
$mode = 'normal';
if (isset($SESSION->scorm_mode)) {
$mode = $SESSION->scorm_mode;
}
$status = 'Not Initialized';
if (isset($SESSION->scorm_status)) {
$status = $SESSION->scorm_status;
}
if (isset($SESSION->attempt)) {
$attempt = $SESSION->attempt;
} else {
$attempt = 1;
}
if ($sco = get_record('scorm_scoes','id',$scoid)) {
if (!$scorm = get_record('scorm','id',$sco->scorm)) {
error('Invalid script call');
}
} else {
error('Invalid script call');
}
if ($scorm = get_record('scorm','id',$sco->scorm)) {
switch ($command) {
case 'getparam':
if ($status == 'Not Initialized') {
$SESSION->scorm_status = 'Running';
$status = 'Running';
}
if ($status != 'Running') {
echo "error = 101\nerror_text = Terminated\n";
} else {
if ($usertrack=scorm_get_tracks($scoid,$USER->id,$attempt)) {
$userdata = $usertrack;
} else {
$userdata->status = '';
$userdata->score_raw = '';
}
$userdata->student_id = $USER->username;
$userdata->student_name = $USER->lastname .', '. $USER->firstname;
$userdata->mode = $mode;
if ($userdata->mode == 'normal') {
$userdata->credit = 'credit';
} else {
$userdata->credit = 'no-credit';
}
if ($sco = get_record('scorm_scoes','id',$scoid)) {
$userdata->course_id = $sco->identifier;
$userdata->datafromlms = $sco->datafromlms;
$userdata->masteryscore = $sco->masteryscore;
$userdata->maxtimeallowed = $sco->maxtimeallowed;
$userdata->timelimitaction = $sco->timelimitaction;
echo "error = 0\nerror_text = Successful\naicc_data=\n";
echo "[Core]\n";
echo 'Student_ID = '.$userdata->student_id."\n";
echo 'Student_Name = '.$userdata->student_name."\n";
if (isset($userdata->{'cmi.core.lesson_location'})) {
echo 'Lesson_Location = '.$userdata->{'cmi.core.lesson_location'}."\n";
} else {
echo 'Lesson_Location = '."\n";
}
echo 'Credit = '.$userdata->credit."\n";
if (isset($userdata->status)) {
if ($userdata->status == '') {
$userdata->entry = ', ab-initio';
} else {
if (isset($userdata->{'cmi.core.exit'}) && ($userdata->{'cmi.core.exit'} == 'suspend')) {
$userdata->entry = ', resume';
} else {
$userdata->entry = '';
}
}
}
if (isset($userdata->{'cmi.core.lesson_status'})) {
echo 'Lesson_Status = '.$userdata->{'cmi.core.lesson_status'}.$userdata->entry."\n";
$SESSION->scorm_lessonstatus = $userdata->{'cmi.core.lesson_status'};
} else {
echo 'Lesson_Status = not attempted'.$userdata->entry."\n";
$SESSION->scorm_lessonstatus = 'not attempted';
}
if (isset($userdata->{'cmi.core.score.raw'})) {
$max = '';
$min = '';
if (isset($userdata->{'cmi.core.score.max'}) && !empty($userdata->{'cmi.core.score.max'})) {
$max = ', '.$userdata->{'cmi.core.score.max'};
if (isset($userdata->{'cmi.core.score.min'}) && !empty($userdata->{'cmi.core.score.min'})) {
$min = ', '.$userdata->{'cmi.core.score.min'};
}
}
echo 'Score = '.$userdata->{'cmi.core.score.raw'}.$max.$min."\n";
} else {
echo 'Score = '."\n";
}
if (isset($userdata->{'cmi.core.total_time'})) {
echo 'Time = '.$userdata->{'cmi.core.total_time'}."\n";
} else {
echo 'Time = '.'00:00:00'."\n";
}
echo 'Lesson_Mode = '.$userdata->mode."\n";
if (isset($userdata->{'cmi.suspend_data'})) {
echo "[Core_Lesson]\n".$userdata->{'cmi.suspend_data'}."\n";
} else {
echo "[Core_Lesson]\n"."\n";
}
echo "[Core_Vendor]\n".$userdata->datafromlms."\n";
echo "[Evaluation]\nCourse_ID = {".$userdata->course_id."}\n";
echo "[Student_Data]\n";
echo 'Mastery_Score = '.$userdata->masteryscore."\n";
echo 'Max_Time_Allowed = '.$userdata->maxtimeallowed."\n";
echo 'Time_Limit_Action = '.$userdata->timelimitaction."\n";
} else {
error('Sco not found');
}
}
break;
case 'putparam':
if ($status == 'Running') {
if (!empty($aiccdata) && isstudent($scorm->course)) {
$initlessonstatus = 'not attempted';
$lessonstatus = 'not attempted';
if (isset($SESSION->scorm_lessonstatus)) {
$initlessonstatus = $SESSION->scorm_lessonstatus;
}
$score = '';
$datamodel['lesson_location'] = 'cmi.core.lesson_location';
$datamodel['lesson_status'] = 'cmi.core.lesson_status';
$datamodel['score'] = 'cmi.core.score.raw';
$datamodel['time'] = 'cmi.core.session_time';
$datamodel['[core_lesson]'] = 'cmi.suspend_data';
$datamodel['[comments]'] = 'cmi.comments';
$datarows = explode("\n",$aiccdata);
reset($datarows);
while ((list(,$datarow) = each($datarows)) !== false) {
if (($equal = strpos($datarow, '=')) !== false) {
$element = strtolower(trim(substr($datarow,0,$equal)));
$value = trim(substr($datarow,$equal+1));
if (isset($datamodel[$element])) {
$element = $datamodel[$element];
switch ($element) {
case 'cmi.core.lesson_location':
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
break;
case 'cmi.core.lesson_status':
$statuses = array(
'passed' => 'passed',
'completed' => 'completed',
'failed' => 'failed',
'incomplete' => 'incomplete',
'browsed' => 'browsed',
'not attempted' => 'not attempted',
'p' => 'passed',
'c' => 'completed',
'f' => 'failed',
'i' => 'incomplete',
'b' => 'browsed',
'n' => 'not attempted'
);
$exites = array(
'logout' => 'logout',
'time-out' => 'time-out',
'suspend' => 'suspend',
'l' => 'logout',
't' => 'time-out',
's' => 'suspend',
);
$values = explode(',',$value);
$value = '';
if (count($values) > 1) {
$value = trim(strtolower($values[1]));
if (isset($exites[$value])) {
$value = $exites[$value];
}
}
if (empty($value) || isset($exites[$value])) {
$subelement = 'cmi.core.exit';
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
}
$value = trim(strtolower($values[0]));
if (isset($statuses[$value]) && ($mode == 'normal')) {
$value = $statuses[$value];
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
$lessonstatus = $value;
break;
case 'cmi.core.score.raw':
$values = explode(',',$value);
if ((count($values) > 1) && ($values[1] >= $values[0]) && is_numeric($values[1])) {
$subelement = 'cmi.core.score.max';
$value = trim($values[1]);
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
if ((count($values) == 3) && ($values[2] <= $values[0]) && is_numeric($values[2])) {
$subelement = 'cmi.core.score.min';
$value = trim($values[2]);
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
}
}
$value = '';
if (is_numeric($values[0])) {
$value = trim($values[0]);
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
$score = $value;
break;
case 'cmi.core.session_time':
$SESSION->scorm_session_time = $value;
break;
}
}
} else {
if (isset($datamodel[strtolower(trim($datarow))])) {
$element = $datamodel[strtolower(trim($datarow))];
$value = '';
while ((($datarow = current($datarows)) !== false) && (substr($datarow,0,1) != '[')) {
$value .= $datarow;
next($datarows);
}
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
}
}
if (($mode == 'browse') && ($initlessonstatus == 'not attempted')){
$lessonstatus = 'browsed';
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, 'cmi.core.lesson_status', 'browsed');
}
if ($mode == 'normal') {
if ($lessonstatus == 'completed') {
if (!empty($sco->masteryscore) && !empty($score) && ($score >= $sco->masteryscore)) {
$lessonstatus = 'passed';
} else {
$lessonstatus = 'failed';
}
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, 'cmi.core.lesson_status', $lessonstatus);
}
}
}
echo "error = 0\nerror_text = Successful\n";
} else if ($status == 'Terminated') {
echo "error = 1\nerror_text = Terminated\n";
} else {
echo "error = 1\nerror_text = Not Initialized\n";
}
break;
case 'putcomments':
if ($status == 'Running') {
echo "error = 0\nerror_text = Successful\n";
} else if ($status == 'Terminated') {
echo "error = 1\nerror_text = Terminated\n";
} else {
echo "error = 1\nerror_text = Not Initialized\n";
}
break;
case 'putinteractions':
if ($status == 'Running') {
echo "error = 0\nerror_text = Successful\n";
} else if ($status == 'Terminated') {
echo "error = 1\nerror_text = Terminated\n";
} else {
echo "error = 1\nerror_text = Not Initialized\n";
}
break;
case 'putobjectives':
if ($status == 'Running') {
echo "error = 0\nerror_text = Successful\n";
} else if ($status == 'Terminated') {
echo "error = 1\nerror_text = Terminated\n";
} else {
echo "error = 1\nerror_text = Not Initialized\n";
}
break;
case 'putpath':
if ($status == 'Running') {
echo "error = 0\nerror_text = Successful\n";
} else if ($status == 'Terminated') {
echo "error = 1\nerror_text = Terminated\n";
} else {
echo "error = 1\nerror_text = Not Initialized\n";
}
break;
case 'putperformance':
if ($status == 'Running') {
echo "error = 0\nerror_text = Successful\n";
} else if ($status == 'Terminated') {
echo "error = 1\nerror_text = Terminated\n";
} else {
echo "error = 1\nerror_text = Not Initialized\n";
}
break;
case 'exitau':
if ($status == 'Running') {
if (isset($SESSION->scorm_session_time) && ($SESSION->scorm_session_time != '')) {
if ($track = get_record_select('scorm_scoes_track',"userid='$USER->id' AND scormid='$scorm->id' AND scoid='$sco->id' AND element='cmi.core.total_time'")) {
// Add session_time to total_time
$value = scorm_add_time($track->value, $SESSION->scorm_session_time);
$track->value = $value;
$track->timemodified = time();
$id = update_record('scorm_scoes_track',$track);
} else {
$track->userid = $USER->id;
$track->scormid = $scorm->id;
$track->scoid = $sco->id;
$track->element = 'cmi.core.total_time';
$track->value = $SESSION->scorm_session_time;
$track->timemodified = time();
$id = insert_record('scorm_scoes_track',$track);
}
}
$SESSION->scorm_status = 'Terminated';
$SESSION->scorm_session_time = '';
echo "error = 0\nerror_text = Successful\n";
} else if ($status == 'Terminated') {
echo "error = 1\nerror_text = Terminated\n";
} else {
echo "error = 1\nerror_text = Not Initialized\n";
}
break;
default:
echo "error = 1\nerror_text = Invalid Command\n";
break;
}
}
} else {
if (empty($command)) {
echo "error = 1\nerror_text = Invalid Command\n";
} else {
echo "error = 3\nerror_text = Invalid Session ID\n";
}
}
?>

View File

@ -1,83 +1,84 @@
<?php
require_once("../../config.php");
require_once('locallib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
$scoid = required_param('scoid', PARAM_INT); // sco ID
$mode = optional_param('mode', '', PARAM_ALPHA); // navigation mode
$attempt = required_param('attempt', PARAM_INT); // new attempt
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
} else {
error('A required parameter is missing');
}
require_login($course->id, false, $cm);
if ($usertrack=scorm_get_tracks($scoid,$USER->id,$attempt)) {
$userdata = $usertrack;
} else {
$userdata->status = '';
$userdata->score_raw = '';
}
$userdata->student_id = addslashes($USER->username);
$userdata->student_name = addslashes($USER->lastname .', '. $USER->firstname);
$userdata->mode = 'normal';
if (isset($mode)) {
$userdata->mode = $mode;
}
if ($userdata->mode == 'normal') {
$userdata->credit = 'credit';
} else {
$userdata->credit = 'no-credit';
}
if ($sco = get_record('scorm_scoes','id',$scoid)) {
$userdata->datafromlms = $sco->datafromlms;
$userdata->masteryscore = $sco->masteryscore;
$userdata->maxtimeallowed = $sco->maxtimeallowed;
$userdata->timelimitaction = $sco->timelimitaction;
} else {
error('Sco not found');
}
switch ($scorm->version) {
case 'SCORM_1.2':
include_once ('datamodels/scorm1_2.js.php');
break;
case 'SCORM_1.3':
include_once ('datamodels/scorm1_3.js.php');
break;
case 'AICC':
include_once ('datamodels/aicc.js.php');
break;
default:
include_once ('datamodels/scorm1_2.js.php');
break;
}
?>
var errorCode = "0";
function underscore(str) {
return str.replace(/\./g,"__");
}
<?php
require_once("../../config.php");
require_once('locallib.php');
require_once('sequencinglib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
$scoid = required_param('scoid', PARAM_INT); // sco ID
$mode = optional_param('mode', '', PARAM_ALPHA); // navigation mode
$attempt = required_param('attempt', PARAM_INT); // new attempt
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
} else {
error('A required parameter is missing');
}
require_login($course->id, false, $cm);
if ($usertrack=scorm_get_tracks($scoid,$USER->id,$attempt)) {
$userdata = $usertrack;
} else {
$userdata->status = '';
$userdata->score_raw = '';
}
$userdata->student_id = addslashes($USER->username);
$userdata->student_name = addslashes($USER->lastname .', '. $USER->firstname);
$userdata->mode = 'normal';
if (isset($mode)) {
$userdata->mode = $mode;
}
if ($userdata->mode == 'normal') {
$userdata->credit = 'credit';
} else {
$userdata->credit = 'no-credit';
}
if ($sco = get_record('scorm_scoes','id',$scoid)) {
$userdata->datafromlms = $sco->datafromlms;
$userdata->masteryscore = $sco->masteryscore;
$userdata->maxtimeallowed = $sco->maxtimeallowed;
$userdata->timelimitaction = $sco->timelimitaction;
} else {
error('Sco not found');
}
switch ($scorm->version) {
case 'SCORM_1.2':
include_once ('datamodels/scorm1_2.js.php');
break;
case 'SCORM_1.3':
include_once ('datamodels/scorm1_3.js.php');
break;
case 'AICC':
include_once ('datamodels/aicc.js.php');
break;
default:
include_once ('datamodels/scorm1_2.js.php');
break;
}
?>
var errorCode = "0";
function underscore(str) {
return str.replace(/\./g,"__");
}

View File

@ -61,7 +61,6 @@
fwrite ($bf,full_tag("VERSION",4,false,$scorm->version));
fwrite ($bf,full_tag("MAXGRADE",4,false,$scorm->maxgrade));
fwrite ($bf,full_tag("GRADEMETHOD",4,false,$scorm->grademethod));
fwrite ($bf,full_tag("MAXATTEMPT",4,false,$scorm->maxattempt));
fwrite ($bf,full_tag("LAUNCH",4,false,$scorm->launch));
fwrite ($bf,full_tag("SUMMARY",4,false,$scorm->summary));
fwrite ($bf,full_tag("HIDEBROWSE",4,false,$scorm->hidebrowse));
@ -150,7 +149,6 @@
fwrite ($bf,full_tag("ID",6,false,$sco_track->id));
fwrite ($bf,full_tag("USERID",6,false,$sco_track->userid));
fwrite ($bf,full_tag("SCOID",6,false,$sco_track->scoid));
fwrite ($bf,full_tag("ATTEMPT",6,false,$sco_track->attempt));
fwrite ($bf,full_tag("ELEMENT",6,false,$sco_track->element));
fwrite ($bf,full_tag("VALUE",6,false,$sco_track->value));
//End sco track

113
mod/scorm/coefficientconfirm.php Executable file
View File

@ -0,0 +1,113 @@
<?php // $Id$
// This script uses installed report plugins to print quiz reports
require_once("../../config.php");
require_once('locallib.php');
require_once('sequencinglib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // SCORM ID
$b = optional_param('b', '', PARAM_INT); // SCO ID
$user = optional_param('user', '', PARAM_INT); // User ID
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else {
if (!empty($b)) {
if (! $sco = get_record("scorm_scoes", "id", $b)) {
error("Scorm activity is incorrect");
}
$a = $sco->scorm;
}
if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
}
}
require_login($course->id, false, $cm);
if (!isteacher($course->id)) {
error("You are not allowed to use this script");
}
add_to_log($course->id, "scorm", "report", "cofficientsetting.php?id=$cm->id", "$scorm->id");
/// Print the page header
if (empty($noheader)) {
if ($course->category) {
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
} else {
$navigation = '';
}
$strscorms = get_string("modulenameplural", "scorm");
$strscorm = get_string("modulename", "scorm");
$strreport = get_string("report", "scorm");
$strname = get_string('name');
$strcoefficient = get_string('coefficient',"scorm");
$strcoefficient = "Thiet lap he so";
if (empty($b)) {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
-> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a> -> $strcoefficient",
"", "", true);
} else {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
-> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>
-> <a href=\"report.php?id=$cm->id\">$strreport</a> -> $sco->title",
"", "", true);
}
print_heading(format_string($scorm->name));
}
$scormpixdir = $CFG->modpixpath.'/scorm/pix';
//Phan trinh bay chinh
?>
<?php
$examScoes = get_records_select('scorm_scoes', 'scorm ='.($scorm->id).' and minnormalizedmeasure > -1');
foreach ($examScoes as $examSco){
$newcoefficient = optional_param($examSco->id,'',PARAM_INT);
$sco = get_record('scorm_scoes','scorm',$scorm->id,'id',$examSco->id,'','');
$sco->score_coefficient = $newcoefficient;
$ketqua = update_record('scorm_scoes',$sco);
//echo "Cap nhat $examSco->id voi he so diem ".$newcoefficient."<br>";
}
if ($ketqua)
{
echo "".get_string('updatesuccess','scorm');
}
else
{
echo "".get_string('updatefail','scorm');
}
echo "<br><br><a href=coefficientsetting.php?id=$id>".get_string('back','scorm')."</a>"
?>
<?php
//ket thuc phan trinh bay chinh
if (empty($noheader)) {
print_footer($course);
}
?>

120
mod/scorm/coefficientsetting.php Executable file
View File

@ -0,0 +1,120 @@
<?php // $Id$
// This script uses installed report plugins to print quiz reports
require_once("../../config.php");
require_once('locallib.php');
require_once('sequencinglib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // SCORM ID
$b = optional_param('b', '', PARAM_INT); // SCO ID
$user = optional_param('user', '', PARAM_INT); // User ID
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else {
if (!empty($b)) {
if (! $sco = get_record("scorm_scoes", "id", $b)) {
error("Scorm activity is incorrect");
}
$a = $sco->scorm;
}
if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
}
}
require_login($course->id, false, $cm);
if (!isteacher($course->id)) {
error("You are not allowed to use this script");
}
add_to_log($course->id, "scorm", "report", "cofficientsetting.php?id=$cm->id", "$scorm->id");
/// Print the page header
if (empty($noheader)) {
if ($course->category) {
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
} else {
$navigation = '';
}
$strscorms = get_string("modulenameplural", "scorm");
$strscorm = get_string("modulename", "scorm");
$strreport = get_string("report", "scorm");
$strname = get_string('name');
$strcoefficient = get_string('coefficient','scorm');
if (empty($b)) {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
-> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a> -> $strcoefficient",
"", "", true);
} else {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
-> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>
-> <a href=\"report.php?id=$cm->id\">$strreport</a> -> $sco->title",
"", "", true);
}
print_heading(format_string($scorm->name));
}
$scormpixdir = $CFG->modpixpath.'/scorm/pix';
//Phan trinh bay chinh
?>
<script type="text/javascript">
function validate_form()
{
return true;
}
</script>
<form name="form" method="post" action="coefficientconfirm.php" onsubmit="return validate_form();" >
<table width="50%" border="0">
<tr>
<td class="scormtableheader"><?php echo(get_string('title','scorm')); ?></td>
<td class="scormtableheader"><?php echo(get_string('coefficient','scorm')); ?></td>
</tr>
<?php
$examScoes = get_records_select('scorm_scoes', 'scorm ='.($scorm->id).' and minnormalizedmeasure > -1');
if(!empty($examScoes))
{
foreach ($examScoes as $examSco){
echo "<tr><td>";
echo "$examSco->identifier.</td><td><input type='text' name='$examSco->id' class='scormtextbox' value=$examSco->score_coefficient /></td></tr><br>";
}
}
?>
</table>
<br>
<input type="hidden" name="id" value="<?php p($id) ?>" />
<input type="submit" value="<?php print_string('savechanges') ?>" />
</form>
<?php
//ket thuc phan trinh bay chinh
if (empty($noheader)) {
print_footer($course);
}
?>

View File

@ -1,54 +1,67 @@
<?php
require_once('../../config.php');
require_once('locallib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
$scoid = required_param('scoid', PARAM_INT); // sco ID
$attempt = required_param('attempt', PARAM_INT); // attempt number
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
} else {
error('A required parameter is missing');
}
require_login($course->id, false, $cm);
if (confirm_sesskey() && (!empty($scoid))) {
$result = true;
if (isstudent($course->id) || (isteacher($course->id) && !isadmin())) {
foreach ($_POST as $element => $value) {
if (substr($element,0,3) == 'cmi') {
$element = str_replace('__','.',$element);
$element = preg_replace('/_(\d+)/',".\$1",$element);
$result = scorm_insert_track($USER->id, $scorm->id, $scoid, $attempt, $element, $value) && $result;
}
}
}
if ($result) {
echo "true\n0";
} else {
echo "false\n101";
}
}
?>
<?php
require_once('../../config.php');
require_once('locallib.php');
require_once('sequencinglib.php');
//$f = "D:\\test.txt";
//@$ft = fopen($f,"a");
//fwrite($ft,"Bat dau ghi tron datamodel.php \n");
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
$scoid = required_param('scoid', PARAM_INT); // sco ID
// $attempt = required_param('attempt', PARAM_INT); // attempt number
$attempt = $USER->attempt;
//fwrite($ft,"\n --------Gia tri attempt thu duoc tu datamodel.php-------- : ".$attempt);
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
} else {
error('A required parameter is missing');
}
require_login($course->id, false, $cm);
if (confirm_sesskey() && (!empty($scoid))) {
//fwrite($ft," --Ghi du lieu--- \n");
$result = true;
if (isstudent($course->id) || (isteacher($course->id) && !isadmin())) {
foreach ($_POST as $element => $value) {
if (substr($element,0,3) == 'cmi') {
$element = str_replace('__','.',$element);
$element = preg_replace('/_(\d+)/',".\$1",$element);
$result = scorm_insert_track($USER->id, $scorm->id, $scoid, $attempt, $element, $value) && $result;
//fwrite($ft,"\n Ghi xong mot phan tu tai Datamodel.php-- ".$scoid);
}
}
}
if ($result) {
echo "true\n0";
//fwrite($ft,"Ghi thanh cong trong Datamodel.php-");
} else {
echo "false\n101";
//fwrite($ft,"Ghi that bai trong Datamodel.php-");
}
}
?>

View File

@ -1,94 +1,96 @@
<?php // $Id$
require_once("../../config.php");
$id = required_param('id', PARAM_INT); // course id
if (!empty($id)) {
if (! $course = get_record("course", "id", $id)) {
error("Course ID is incorrect");
}
} else {
error('A required parameter is missing');
}
require_course_login($course);
add_to_log($course->id, "scorm", "view all", "index.php?id=$course->id", "");
$strscorm = get_string("modulename", "scorm");
$strscorms = get_string("modulenameplural", "scorm");
$strweek = get_string("week");
$strtopic = get_string("topic");
$strname = get_string("name");
$strsummary = get_string("summary");
$strreport = get_string("report",'scorm');
$strlastmodified = get_string("lastmodified");
print_header_simple("$strscorms", "", "$strscorms",
"", "", true, "", navmenu($course));
if ($course->format == "weeks" or $course->format == "topics") {
$sortorder = "cw.section ASC";
} else {
$sortorder = "m.timemodified DESC";
}
if (! $scorms = get_all_instances_in_course("scorm", $course)) {
notice("There are no scorms", "../../course/view.php?id=$course->id");
exit;
}
if ($course->format == "weeks") {
$table->head = array ($strweek, $strname, $strsummary, $strreport);
$table->align = array ("center", "left", "left", "left");
} else if ($course->format == "topics") {
$table->head = array ($strtopic, $strname, $strsummary, $strreport);
$table->align = array ("center", "left", "left", "left");
} else {
$table->head = array ($strlastmodified, $strname, $strsummary, $strreport);
$table->align = array ("left", "left", "left", "left");
}
foreach ($scorms as $scorm) {
$tt = "";
if ($course->format == "weeks" or $course->format == "topics") {
if ($scorm->section) {
$tt = "$scorm->section";
}
} else {
$tt = userdate($scorm->timemodified);
}
$report = '&nbsp;';
if (isteacher($course->id)) {
$trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
if ($trackedusers->c > 0) {
$report = '<a href="report.php?a='.$scorm->id.'">'.get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
} else {
$report = get_string('noreports','scorm');
}
} else if (isstudent($course->id)) {
require_once('locallib.php');
$report = scorm_grade_user(get_records('scorm_scoes','scorm',$scorm->id), $USER->id, $scorm->grademethod);
}
if (!$scorm->visible) {
//Show dimmed if the mod is hidden
$table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name,true)."</a>",
format_text($scorm->summary), $report);
} else {
//Show normal if the mod is visible
$table->data[] = array ($tt, "<a href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name,true)."</a>",
format_text($scorm->summary), $report);
}
}
echo "<br />";
print_table($table);
print_footer($course);
?>
<?php // $Id$
require_once("../../config.php");
require_once('sequencinglib.php');
$id = required_param('id', PARAM_INT); // course id
if (!empty($id)) {
if (! $course = get_record("course", "id", $id)) {
error("Course ID is incorrect");
}
} else {
error('A required parameter is missing');
}
require_course_login($course);
add_to_log($course->id, "scorm", "view all", "index.php?id=$course->id", "");
$strscorm = get_string("modulename", "scorm");
$strscorms = get_string("modulenameplural", "scorm");
$strweek = get_string("week");
$strtopic = get_string("topic");
$strname = get_string("name");
$strsummary = get_string("summary");
$strreport = get_string("report",'scorm');
$strlastmodified = get_string("lastmodified");
print_header_simple("$strscorms", "", "$strscorms",
"", "", true, "", navmenu($course));
if ($course->format == "weeks" or $course->format == "topics") {
$sortorder = "cw.section ASC";
} else {
$sortorder = "m.timemodified DESC";
}
if (! $scorms = get_all_instances_in_course("scorm", $course)) {
notice("There are no scorms", "../../course/view.php?id=$course->id");
exit;
}
if ($course->format == "weeks") {
$table->head = array ($strweek, $strname, $strsummary, $strreport);
$table->align = array ("center", "left", "left", "left");
} else if ($course->format == "topics") {
$table->head = array ($strtopic, $strname, $strsummary, $strreport);
$table->align = array ("center", "left", "left", "left");
} else {
$table->head = array ($strlastmodified, $strname, $strsummary, $strreport);
$table->align = array ("left", "left", "left", "left");
}
foreach ($scorms as $scorm) {
$tt = "";
if ($course->format == "weeks" or $course->format == "topics") {
if ($scorm->section) {
$tt = "$scorm->section";
}
} else {
$tt = userdate($scorm->timemodified);
}
$report = '&nbsp;';
if (isteacher($course->id)) {
$trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
if ($trackedusers->c > 0) {
$reportshow = '<a href="report.php?a='.$scorm->id.'">'.get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
} else {
$reportshow = get_string('noreports','scorm');
}
} else if (isstudent($course->id)) {
require_once('locallib.php');
$report = scorm_grade_user_new(get_records('scorm_scoes','scorm',$scorm->id), $USER->id, $scorm->grademethod);
$sco_count = scorm_get_user_sco_count($scorm->id,$USER->id);
$reportshow = get_string('implement','scorm').$sco_count.get_string('lesson','scorm') ."<br><table width=".($report*100)."% bgcolor=#800000><tr><td height=15></td></tr></table>".get_string('scoreRate','scorm').": ".($report*100)."%"; }
if (!$scorm->visible) {
//Show dimmed if the mod is hidden
$table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name,true)."</a>",
format_text($scorm->summary),$reportshow);
} else {
//Show normal if the mod is visible
$table->data[] = array ($tt, "<a href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name,true)."</a>",
format_text($scorm->summary), $reportshow);
}
}
echo "<br />";
print_table($table);
print_footer($course);
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,110 +1,111 @@
<?php
require_once("../../config.php");
require_once('locallib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
$scoid = required_param('scoid', PARAM_INT); // sco ID
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
} else {
error('A required parameter is missing');
}
require_login($course->id, false, $cm);
if (!empty($scoid)) {
//
// Direct sco request
//
if ($sco = get_record("scorm_scoes","id",$scoid)) {
if ($sco->launch == '') {
// Search for the next launchable sco
if ($scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>'' AND id>".$sco->id,"id ASC")) {
$sco = current($scoes);
}
}
}
}
//
// If no sco was found get the first of SCORM package
//
if (!isset($sco)) {
$scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>''","id ASC");
$sco = current($scoes);
}
//
// Forge SCO URL
//
$connector = '';
$version = substr($scorm->version,0,4);
if (!empty($sco->parameters) || ($version == 'AICC')) {
if (stripos($sco->launch,'?') !== false) {
$connector = '&';
} else {
$connector = '?';
}
if (!empty($sco->parameters) && ($sco->parameters[0] == '?')) {
$sco->parameters = substr($sco->parameters,1);
}
}
if ($version == 'AICC') {
if (!empty($sco->parameters)) {
$sco->parameters = '&'. $sco->parameters;
}
$launcher = $sco->launch.$connector.'aicc_sid='.sesskey().'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$sco->parameters;
} else {
$launcher = $sco->launch.$connector.$sco->parameters;
}
if (scorm_external_link($sco->launch)) {
$result = $launcher;
} else {
if (basename($scorm->reference) == 'imsmanifest.xml') {
$basedir = dirname($scorm->reference);
} else {
$basedir = 'moddata/scorm/'.$scorm->id;
}
if ($CFG->slasharguments) {
$result = $CFG->wwwroot.'/file.php/'.$scorm->course.'/'.$basedir.'/'.$launcher;
} else {
$result = $CFG->wwwroot.'/file.php?file=/'.$scorm->course.'/'.$basedir.'/'.$launcher;
}
}
?>
<html>
<head>
<title>LoadSCO</title>
<script language="javascript" type="text/javascript">
<!--
setTimeout('document.location = "<?php echo $result ?>";',1000);
-->
</script>
<noscript>
<meta http-equiv="refresh" content="1;url=<?php echo $result ?>" />
</noscript>
</head>
<body>
&nbsp;
</body>
</html>
<?php
require_once("../../config.php");
require_once('locallib.php');
require_once('sequencinglib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
$scoid = required_param('scoid', PARAM_INT); // sco ID
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
} else {
error('A required parameter is missing');
}
require_login($course->id, false, $cm);
if (!empty($scoid)) {
//
// Dinh huong yeu cau cua SCO
//
if ($sco = get_record("scorm_scoes","id",$scoid)) {
if ($sco->launch == '') {
// Tim kiem SCO co the trien khai tiep theo
if ($scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>'' AND id>".$sco->id,"id ASC")) {
$sco = current($scoes);
}
}
}
}
//
// If no sco was found get the first of SCORM package
//
if (!isset($sco)) {
$scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>''","id ASC");
$sco = current($scoes);
}
//
// Forge SCO URL
//
$connector = '';
$version = substr($scorm->version,0,4);
if (!empty($sco->parameters) || ($version == 'AICC')) {
if (stripos($sco->launch,'?') !== false) {
$connector = '&';
} else {
$connector = '?';
}
if (!empty($sco->parameters) && ($sco->parameters[0] == '?')) {
$sco->parameters = substr($sco->parameters,1);
}
}
if ($version == 'AICC') {
if (!empty($sco->parameters)) {
$sco->parameters = '&'. $sco->parameters;
}
$launcher = $sco->launch.$connector.'aicc_sid='.sesskey().'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$sco->parameters;
} else {
$launcher = $sco->launch.$connector.$sco->parameters;
}
if (scorm_external_link($sco->launch)) {
$result = $launcher;
} else {
if (basename($scorm->reference) == 'imsmanifest.xml') {
$basedir = dirname($scorm->reference);
} else {
$basedir = 'moddata/scorm/'.$scorm->id;
}
if ($CFG->slasharguments) {
$result = $CFG->wwwroot.'/file.php/'.$scorm->course.'/'.$basedir.'/'.$launcher;
} else {
$result = $CFG->wwwroot.'/file.php?file=/'.$scorm->course.'/'.$basedir.'/'.$launcher;
}
}
?>
<html>
<head>
<title>LoadSCO</title>
<script language="javascript" type="text/javascript">
<!--
setTimeout('document.location = "<?php echo $result ?>";',1000);
-->
</script>
<noscript>
<meta http-equiv="refresh" content="1;url=<?php echo $result ?>" />
</noscript>
</head>
<body>
&nbsp;
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -1,426 +1,431 @@
<?php
require_once($CFG->dirroot.'/mod/scorm/lib.php');
if (!isset($form->name)) {
$form->name = '';
}
if (!isset($form->reference)) {
$form->reference = '';
}
if (!isset($form->summary)) {
$form->summary = '';
}
if (!isset($form->launch)) {
$form->launch = '';
}
if (!isset($form->auto)) {
$form->auto = '';
}
if (!isset($form->popup)) {
$form->popup = 0;
}
if (!isset($form->datadir)) {
$form->datadir = '';
}
if (!isset($form->maxgrade)) {
$form->maxgrade = '';
}
if (!isset($form->grademethod)) {
$form->grademethod = 0;
}
if (!isset($form->maxattempt)) {
$form->maxattempt = 1;
}
if (!isset($form->whatgrade)) {
$form->whatgrade = 0;
}
if (!isset($form->hidebrowse)) {
$form->hidebrowse = 0;
}
if (!isset($form->hidetoc)) {
$form->hidetoc = 0;
}
if (!isset($form->hidenav)) {
$form->hidenav = 0;
}
if (!isset($form->width)) {
$form->width = $CFG->scorm_framewidth;
}
if ((strpos($form->width,'%') === false) && ($form->width <= 100)) {
$form->width .= '%';
}
if (!isset($form->height)) {
$form->height = $CFG->scorm_frameheight;
}
if ((strpos($form->height,'%') === false) && ($form->height <= 100)) {
$form->height .= '%';
}
if (!isset($form->options) || empty($form->options)) {
$form->options = $stdoptions;
}
$options = explode(',',$form->options);
$window = new stdClass();
foreach ($options as $option) {
list($element,$value) = explode('=',$option);
$element = trim($element);
$window->$element = trim($value)==1?'checked':'';
}
$scormid = '';
if (!empty($form->instance)) {
$scormid = '&instance='.$form->instance;
}
$datadir = '';
if (!empty($form->datadir)) {
$datadir = '&datadir='.$form->datadir;
}
$sessionkey = '';
if (!empty($form->sesskey)) {
$sessionkey = '&sesskey='.$form->sesskey;
}
$strfilename = get_string('coursepacket', 'scorm');
$strchooseafile = get_string('chooseapacket', 'scorm');
$striframe = get_string('iframe', 'scorm');
$striframedisplay = get_string('iframedisplay', 'scorm');
$strnewwindow = get_string('popup', 'scorm');
$strnewwindowopen = get_string('popupopen', 'scorm');
$strheight = get_string('height', 'scorm');
$strwidth = get_string('width', 'scorm');
$strresizable = get_string('resizable', 'scorm');
$strscrollbars = get_string('scrollbars', 'scorm');
$strdirectories = get_string('directories', 'scorm');
$strlocation = get_string('location', 'scorm');
$strmenubar = get_string('menubar', 'scorm');
$strtoolbar = get_string('toolbar', 'scorm');
$strstatus = get_string('statusbar', 'scorm');
?>
<script type="text/javascript" src="<?php p($CFG->wwwroot) ?>/mod/scorm/request.js" ></script>
<script type="text/javascript">
function validate_scorm(theform,filename) {
var myRequest = NewHttpReq();
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/validate.php","id=<?php p($form->course) ?>&reference="+filename+"<?php echo $sessionkey.$scormid.$datadir ?>");
//alert(result);
results = result.split('\n');
result = '';
errorlogs = '';
datadir = '';
for (i=0;i<results.length;i++) {
element = results[i].split('=');
switch(element[0]) {
case 'result':
result = element[1];
break;
case 'launch':
launch = element[1];
break;
case 'datadir':
datadir = element[1];
break;
case 'pkgtype':
pkgtype = element[1];
break;
case 'errorlogs':
i++;
do {
errorlogs.concat(results[i]+'\n');
i++;
} while (i<results.lenght());
break;
}
}
if ((result == "found") || (result == "regular")) {
theform.datadir.value = datadir;
theform.pkgtype.value = pkgtype;
theform.launch.value = launch;
if (launch == 0) {
if ('<?php echo $scormid ?>' != '') {
return confirm('<?php print_string('trackingloose','scorm') ?>');
}
}
return true;
} else {
result = '<?php print_string('validation','scorm') ?>: '+ result + '\n';
if (errorlogs != '') {
result.concat('<?php print_string('errorlogs','scorm') ?>:\n'+errorlogs);
}
alert(result);
return false;
}
}
function checkscormform (whatcheck,checkvalue,whatset) {
if (whatcheck.options[whatcheck.selectedIndex].value == checkvalue) {
whatset.disabled = true;
} else {
whatset.disabled = false;
}
}
function showhide (id, set) {
divobj = document.getElementById(id);
butobj = document.getElementById(id+'button');
prefobj = document.getElementById(id+'pref');
if (set == true) {
if (prefobj.value == '1') {
divobj.style.display = 'block';
butobj.value = '<?php print_string('hidesettings') ?>';
} else {
divobj.style.display = 'none';
butobj.value = '<?php print_string('showsettings') ?>...';
}
} else {
if (prefobj.value == '1') {
divobj.style.display = 'none';
butobj.value = '<?php print_string('showsettings') ?>...';
prefobj.value = '0';
} else {
divobj.style.display = 'block';
butobj.value = '<?php print_string('hidesettings') ?>';
prefobj.value = '1';
}
}
}
</script>
<form name="form" method="post" action="mod.php" onsubmit="return validate_scorm(document.form,document.form.reference.value);">
<table cellpadding="5">
<tr valign="top">
<td align="right"><b><?php print_string('name') ?>:</b></td>
<td>
<input type="text" name="name" size="50" value="<?php p($form->name) ?>" alt="<?php print_string('name') ?>" />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('summary') ?>:</b><br />
<?php helpbutton('summary', get_string('summary'), 'scorm', true, true) ?>
</td>
<td>
<?php print_textarea($usehtmleditor, 10, 50, 680, 400, 'summary', $form->summary); ?>
</td>
</tr>
<tr valign="top">
<td align="right" nowrap="nowrap">
<b><?php echo $strfilename?>:</b>
</td>
<td>
<input name="reference" size="50" value="<?php echo $form->reference ?>" alt="<?php echo $strfilename ?>" />&nbsp;
<?php
button_to_popup_window ('/files/index.php?id='.$course->id.'&amp;choose=form.reference',
'coursefiles', $strchooseafile, 500, 750, $strchooseafile);
helpbutton('package', get_string('coursepacket', 'scorm'), 'scorm', true);
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('grademethod', 'scorm') ?>:</b></td>
<td>
<?php
choose_from_menu($SCORM_GRADE_METHOD, 'grademethod', (int) $form->grademethod, '','checkscormform(this,0,document.form.maxgrade);');
helpbutton('grademethod', get_string('grademethod','scorm'), 'scorm');
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('maximumgrade') ?>:</b></td>
<td>
<?php
for ($i=100; $i>=1; $i--) {
$grades[$i] = $i;
}
$disabled = $form->grademethod=='0';
choose_from_menu($grades, 'maxgrade', (int) $form->maxgrade, '','','0',false,$disabled);
helpbutton('maxgrade', get_string('maximumgrade'), 'scorm');
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('maximumattempts','scorm') ?>:</b></td>
<td>
<?php
for ($i=1; $i<=$CFG->scorm_maxattempts; $i++) {
if ($i == 1) {
$attempts[$i] = $i . ' ' . get_string('attempt','scorm');
} else {
$attempts[$i] = $i . ' ' . get_string('attempts','scorm');
}
}
choose_from_menu($attempts, 'maxattempt', (int) $form->maxattempt, get_string('nolimit','scorm'),'checkscormform(this,1,document.form.whatgrade);');
helpbutton('maxattempt', get_string('maximumattempts','scorm'), 'scorm');
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('whatgrade','scorm') ?>:</b></td>
<td>
<?php
$disabled = (int) $form->maxattempt === 1;
choose_from_menu($SCORM_WHAT_GRADE, 'whatgrade', (int) $form->whatgrade, '','','0',false,$disabled);
helpbutton('whatgrade', get_string('whatgrade','scorm'), 'scorm');
?>
</td>
</tr>
<tr><td colspan="2"><hr /></td></tr>
<tr>
<td align="right"><b><?php print_string('advanced', 'scorm') ?>:</b></td>
<td>
<input type="button" value="<?php print_string('hidesettings') ?>" id="advancedsettingsbutton" onclick="javascript: return showhide('advancedsettings');" />
<input type="hidden" name="advancedsettingspref" id="advancedsettingspref"
value="<?php echo get_user_preferences('scorm_advancedsettingspref', $CFG->scorm_advancedsettings); ?>" />
<?php helpbutton('advanced', get_string('advanced', 'scorm'), 'scorm', true) ?>
</td>
</tr>
<tr>
<td colspan="2">
<div id="advancedsettings">
<table align="center">
<tr>
<td align="right"><b><?php print_string('autocontinue','scorm') ?>:</b></td>
<td>
<?php
$options = array();
$options[0]=get_string('no');
$options[1]=get_string('yes');
choose_from_menu ($options, 'auto', (int) $form->auto,'');
helpbutton('autocontinue', get_string('autocontinue','scorm'), 'scorm', true);
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string('hidebrowse','scorm') ?>:</b></td>
<td>
<?php
$options = array();
$options[0]=get_string('no');
$options[1]=get_string('yes');
choose_from_menu ($options, 'hidebrowse', (int) $form->hidebrowse, '');
helpbutton('browsemode', get_string('hidebrowse','scorm'), 'scorm', true);
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string('hidetoc','scorm') ?>:</b></td>
<td>
<?php
$options = array();
$options[1]=get_string('hidden','scorm');
$options[0]=get_string('sided','scorm');
$options[2]=get_string('popupmenu','scorm');
choose_from_menu ($options, 'hidetoc', (int) $form->hidetoc, '');
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string('hidenav','scorm') ?>:</b></td>
<td>
<?php
$options = array();
$options[0]=get_string('no');
$options[1]=get_string('yes');
choose_from_menu ($options, 'hidenav', (int) $form->hidenav, '');
?>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string('window', 'scorm') ?>:</b></td>
<td>
<input type="button" value="<?php print_string('hidesettings') ?>" id="windowsettingsbutton" onclick="javascript: return showhide('windowsettings');" />
<input type="hidden" name="windowsettingspref" id="windowsettingspref"
value="<?php echo get_user_preferences('scorm_windowsettingspref', $CFG->scorm_windowsettings); ?>" />
<?php helpbutton('window', get_string('window', 'scorm'), 'scorm', true) ?>
</td>
</tr>
<tr>
<td colspan="2">
<div id="windowsettings">
<table align="center">
<tr valign="top">
<td>
<b><?php print_string('stagesize','scorm'); ?></b>
<?php helpbutton('size', get_string('stagesize', 'scorm'), 'scorm', true) ?><br />
<input name="width" type="text" size="4" value="<?php p($form->width) ?>" alt="<?php p($strwidth) ?>" />
<label for="width"><?php p($strwidth) ?></label><br />
<input name="height" type="text" size="4" value="<?php p($form->height) ?>" alt="<?php p($strheight) ?>" />
<label for="height"><?php p($strheight) ?></label>
</td>
</tr>
<tr valign="top">
<td>
<script type="text/javascript">
var popupitems = ["<?php echo implode('","',array_keys($SCORM_POPUP_OPTIONS)); ?>"];
</script>
<br /><b><?php print_string('display','scorm'); ?>:</b><br />
<input type="radio"
name="popup"
value="0" alt="<?php p($striframe) ?>"
<?php echo ($form->popup == 0) ? "checked=\"checked\"" : "" ?>
onclick="return lockoptions('form', 'popup[1]', popupitems);"
/>
<b title="<?php p($striframedisplay) ?>"><?php p($striframe) ?></b>
</td>
</tr>
<tr valign="top">
<td>
<input name="popup"
type="radio"
value="1"
alt="<?php p($strnewwindow)?>"
<?php echo ($form->popup == 1) ? 'checked="checked"' : '' ?>
onclick="return lockoptions('form', 'popup[1]', popupitems);"
/>
<b title="<?php p($strnewwindowopen) ?>"><?php p($strnewwindow) ?></b>
<blockquote>
<?php
foreach ($window as $name => $value) {
echo "<input name=\"h$name\" type=\"hidden\" value=\"0\"/>\n";
echo "<input name=\"$name\" type=\"checkbox\" value=\"1\" ".$window->$name." alt=\"$name\" />\n";
$stringname = "str$name";
echo $$stringname."<br />\n";
}
?>
<script type="text/javascript">
lockoptions('form','popup[1]', popupitems);
</script>
</blockquote>
</td>
</tr>
</table>
</div>
<script language="javascript" type="text/javascript">
showhide('advancedsettings', true);
showhide('windowsettings', true);
</script>
</td>
</tr>
</table>
<input type="hidden" name="datadir" value="<?php p($form->datadir) ?>" />
<input type="hidden" name="pkgtype" value="<?php p($form->pkgtype) ?>" />
<input type="hidden" name="launch" value="<?php p($form->launch) ?>" />
<?php
$scorms = get_all_instances_in_course('scorm', $course);
$coursescorm = current($scorms);
if (($course->format == 'scorm') && ((count($scorms) == 0) || ($form->instance == $coursescorm->id))) {
?>
<input type="hidden" name="redirect" value="yes" />
<input type="hidden" name="redirecturl" value="../course/view.php?id=<?php p($form->course) ?>" />
<?php
}
?>
<input type="hidden" name="course" value="<?php p($form->course) ?>" />
<input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" />
<input type="hidden" name="section" value="<?php p($form->section) ?>" />
<input type="hidden" name="module" value="<?php p($form->module) ?>" />
<input type="hidden" name="mode" value="<?php p($form->mode) ?>" />
<input type="hidden" name="coursemodule" value="<?php p($form->coursemodule) ?>" />
<input type="hidden" name="modulename" value="<?php p($form->modulename) ?>" />
<input type="hidden" name="instance" value="<?php p($form->instance) ?>" />
<center>
<input type="submit" value="<?php print_string('savechanges') ?>" />
<input type="button" name="cancel" value="<?php print_string('cancel') ?>" onclick="document.location='view.php?id=<?php echo $form->course ?>'" />
</center>
</form>
<?php
require_once($CFG->dirroot.'/mod/scorm/lib.php');
if (!isset($form->name)) {
$form->name = '';
}
if (!isset($form->reference)) {
$form->reference = '';
}
if (!isset($form->summary)) {
$form->summary = '';
}
if (!isset($form->launch)) {
$form->launch = '';
}
if (!isset($form->auto)) {
$form->auto = '';
}
if (!isset($form->popup)) {
$form->popup = 0;
}
if (!isset($form->datadir)) {
$form->datadir = '';
}
if (!isset($form->maxgrade)) {
$form->maxgrade = '';
}
if (!isset($form->grademethod)) {
$form->grademethod = 0;
}
if (!isset($form->maxattempt)) {
$form->maxattempt = 1;
}
if (!isset($form->whatgrade)) {
$form->whatgrade = 0;
}
if (!isset($form->hidebrowse)) {
$form->hidebrowse = 0;
}
if (!isset($form->hidetoc)) {
$form->hidetoc = 0;
}
if (!isset($form->hidenav)) {
$form->hidenav = 0;
}
if (!isset($form->width)) {
$form->width = $CFG->scorm_framewidth;
}
if ((strpos($form->width,'%') === false) && ($form->width <= 100)) {
$form->width .= '%';
}
if (!isset($form->height)) {
$form->height = $CFG->scorm_frameheight;
}
if ((strpos($form->height,'%') === false) && ($form->height <= 100)) {
$form->height .= '%';
}
if (!isset($form->options) || empty($form->options)) {
$form->options = $stdoptions;
}
$options = explode(',',$form->options);
$window = new stdClass();
foreach ($options as $option) {
list($element,$value) = explode('=',$option);
$element = trim($element);
$window->$element = trim($value)==1?'checked':'';
}
$scormid = '';
if (!empty($form->instance)) {
$scormid = '&instance='.$form->instance;
}
$datadir = '';
if (!empty($form->datadir)) {
$datadir = '&datadir='.$form->datadir;
}
$sessionkey = '';
if (!empty($form->sesskey)) {
$sessionkey = '&sesskey='.$form->sesskey;
}
$strfilename = get_string('coursepacket', 'scorm');
$strchooseafile = get_string('chooseapacket', 'scorm');
$striframe = get_string('iframe', 'scorm');
$striframedisplay = get_string('iframedisplay', 'scorm');
$strnewwindow = get_string('popup', 'scorm');
$strnewwindowopen = get_string('popupopen', 'scorm');
$strheight = get_string('height', 'scorm');
$strwidth = get_string('width', 'scorm');
$strresizable = get_string('resizable', 'scorm');
$strscrollbars = get_string('scrollbars', 'scorm');
$strdirectories = get_string('directories', 'scorm');
$strlocation = get_string('location', 'scorm');
$strmenubar = get_string('menubar', 'scorm');
$strtoolbar = get_string('toolbar', 'scorm');
$strstatus = get_string('statusbar', 'scorm');
?>
<script type="text/javascript" src="<?php p($CFG->wwwroot) ?>/mod/scorm/request.js" ></script>
<script type="text/javascript">
function validate_scorm(theform,filename) {
var myRequest = NewHttpReq();
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/validate.php","id=<?php p($form->course) ?>&reference="+filename+"<?php echo $sessionkey.$scormid.$datadir ?>");
alert("Scorm validating....");
results = result.split('\n');
result = '';
errorlogs = '';
datadir = '';
for (i=0;i<results.length;i++) {
element = results[i].split('=');
switch(element[0]) {
case 'result':
result = element[1];
break;
case 'launch':
launch = element[1];
break;
case 'datadir':
datadir = element[1];
break;
case 'pkgtype':
pkgtype = element[1];
break;
case 'errorlogs':
i++;
do {
errorlogs.concat(results[i]+'\n');
i++;
} while (i<results.lenght());
break;
}
}
if ((result == "found") || (result == "regular")) {
theform.datadir.value = datadir;
theform.pkgtype.value = pkgtype;
theform.launch.value = launch;
if (launch == 0) {
if ('<?php echo $scormid ?>' != '') {
return confirm('<?php print_string('trackingloose','scorm') ?>');
}
}
return true;
} else {
result = '<?php print_string('validation','scorm') ?>: '+ result + '\n';
if (errorlogs != '') {
result.concat('<?php print_string('errorlogs','scorm') ?>:\n'+errorlogs);
}
alert(result);
alert("Khong tuan chuan Scorm");
document.form.name.focus();
return false;
}
}
function checkscormform (whatcheck,checkvalue,whatset) {
if (whatcheck.options[whatcheck.selectedIndex].value == checkvalue) {
whatset.disabled = true;
} else {
whatset.disabled = false;
}
}
function showhide (id, set) {
divobj = document.getElementById(id);
butobj = document.getElementById(id+'button');
prefobj = document.getElementById(id+'pref');
if (set == true) {
if (prefobj.value == '1') {
divobj.style.display = 'block';
butobj.value = '<?php print_string('hidesettings') ?>';
} else {
divobj.style.display = 'none';
butobj.value = '<?php print_string('showsettings') ?>...';
}
} else {
if (prefobj.value == '1') {
divobj.style.display = 'none';
butobj.value = '<?php print_string('showsettings') ?>...';
prefobj.value = '0';
} else {
divobj.style.display = 'block';
butobj.value = '<?php print_string('hidesettings') ?>';
prefobj.value = '1';
}
}
}
</script>
<form name="form" method="post" action="mod.php?goto=" onsubmit="return validate_scorm(document.form,document.form.reference.value);">
<table cellpadding="5">
<tr valign="top">
<td align="right"><b><?php print_string('name') ?>:</b></td>
<td>
<input type="text" name="name" size="50" value="<?php p($form->name) ?>" alt="<?php print_string('name') ?>" />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('summary') ?>:</b><br />
<?php helpbutton('summary', get_string('summary'), 'scorm', true, true) ?>
</td>
<td>
<?php print_textarea($usehtmleditor, 10, 50, 680, 400, 'summary', $form->summary); ?>
</td>
</tr>
<tr valign="top">
<td align="right" nowrap="nowrap">
<b><?php echo $strfilename?>:</b>
</td>
<td>
<input name="reference" size="50" value="<?php echo $form->reference ?>" alt="<?php echo $strfilename ?>" />&nbsp;
<?php
button_to_popup_window ('/files/index.php?id='.$course->id.'&amp;choose=form.reference',
'coursefiles', $strchooseafile, 500, 750, $strchooseafile);
helpbutton('package', get_string('coursepacket', 'scorm'), 'scorm', true);
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('grademethod', 'scorm') ?>:</b></td>
<td>
<?php
choose_from_menu($SCORM_GRADE_METHOD, 'grademethod', (int) $form->grademethod, '','checkscormform(this,0,document.form.maxgrade);');
helpbutton('grademethod', get_string('grademethod','scorm'), 'scorm');
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('maximumgrade') ?>:</b></td>
<td>
<?php
for ($i=100; $i>=1; $i--) {
$grades[$i] = $i;
}
$disabled = $form->grademethod=='0';
choose_from_menu($grades, 'maxgrade', (int) $form->maxgrade, '','','0',false,$disabled);
helpbutton('maxgrade', get_string('maximumgrade'), 'scorm');
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('maximumattempts','scorm') ?>:</b></td>
<td>
<?php
for ($i=1; $i<=$CFG->scorm_maxattempts; $i++) {
if ($i == 1) {
$attempts[$i] = $i . ' ' . get_string('attempt','scorm');
} else {
$attempts[$i] = $i . ' ' . get_string('attempts','scorm');
}
}
choose_from_menu($attempts, 'maxattempt', (int) $form->maxattempt, get_string('nolimit','scorm'),'checkscormform(this,1,document.form.whatgrade);');
helpbutton('maxattempt', get_string('maximumattempts','scorm'), 'scorm');
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string('whatgrade','scorm') ?>:</b></td>
<td>
<?php
$disabled = (int) $form->maxattempt === 1;
choose_from_menu($SCORM_WHAT_GRADE, 'whatgrade', (int) $form->whatgrade, '','','0',false,$disabled);
helpbutton('whatgrade', get_string('whatgrade','scorm'), 'scorm');
?>
</td>
</tr>
<tr><td colspan="2"><hr /></td></tr>
<tr>
<td align="right"><b><?php print_string('advanced', 'scorm') ?>:</b></td>
<td>
<input type="button" value="<?php print_string('hidesettings') ?>" id="advancedsettingsbutton" onclick="javascript: return showhide('advancedsettings');" />
<input type="hidden" name="advancedsettingspref" id="advancedsettingspref"
value="<?php echo get_user_preferences('scorm_advancedsettingspref', $CFG->scorm_advancedsettings); ?>" />
<?php helpbutton('advanced', get_string('advanced', 'scorm'), 'scorm', true) ?>
</td>
</tr>
<tr>
<td colspan="2">
<div id="advancedsettings">
<table align="center">
<tr>
<td align="right"><b><?php print_string('autocontinue','scorm') ?>:</b></td>
<td>
<?php
$options = array();
$options[0]=get_string('no');
$options[1]=get_string('yes');
choose_from_menu ($options, 'auto', (int) $form->auto,'');
helpbutton('autocontinue', get_string('autocontinue','scorm'), 'scorm', true);
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string('hidebrowse','scorm') ?>:</b></td>
<td>
<?php
$options = array();
$options[0]=get_string('no');
$options[1]=get_string('yes');
choose_from_menu ($options, 'hidebrowse', (int) $form->hidebrowse, '');
helpbutton('browsemode', get_string('hidebrowse','scorm'), 'scorm', true);
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string('hidetoc','scorm') ?>:</b></td>
<td>
<?php
$options = array();
$options[1]=get_string('hidden','scorm');
$options[0]=get_string('sided','scorm');
$options[2]=get_string('popupmenu','scorm');
choose_from_menu ($options, 'hidetoc', (int) $form->hidetoc, '');
?>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string('hidenav','scorm') ?>:</b></td>
<td>
<?php
$options = array();
$options[0]=get_string('no');
$options[1]=get_string('yes');
choose_from_menu ($options, 'hidenav', (int) $form->hidenav, '');
?>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td align="right"><b><?php print_string('window', 'scorm') ?>:</b></td>
<td>
<input type="button" value="<?php print_string('hidesettings') ?>" id="windowsettingsbutton" onclick="javascript: return showhide('windowsettings');" />
<input type="hidden" name="windowsettingspref" id="windowsettingspref"
value="<?php echo get_user_preferences('scorm_windowsettingspref', $CFG->scorm_windowsettings); ?>" />
<?php helpbutton('window', get_string('window', 'scorm'), 'scorm', true) ?>
</td>
</tr>
<tr>
<td colspan="2">
<div id="windowsettings">
<table align="center">
<tr valign="top">
<td>
<b><?php print_string('stagesize','scorm'); ?></b>
<?php helpbutton('size', get_string('stagesize', 'scorm'), 'scorm', true) ?><br />
<input name="width" type="text" size="4" value="<?php p($form->width) ?>" alt="<?php p($strwidth) ?>" />
<label for="width"><?php p($strwidth) ?></label><br />
<input name="height" type="text" size="4" value="<?php p($form->height) ?>" alt="<?php p($strheight) ?>" />
<label for="height"><?php p($strheight) ?></label>
</td>
</tr>
<tr valign="top">
<td>
<script type="text/javascript">
var popupitems = ["<?php echo implode('","',array_keys($SCORM_POPUP_OPTIONS)); ?>"];
</script>
<br /><b><?php print_string('display','scorm'); ?>:</b><br />
<input type="radio"
name="popup"
value="0" alt="<?php p($striframe) ?>"
<?php echo ($form->popup == 0) ? "checked=\"checked\"" : "" ?>
onclick="return lockoptions('form', 'popup[1]', popupitems);"
/>
<b title="<?php p($striframedisplay) ?>"><?php p($striframe) ?></b>
</td>
</tr>
<tr valign="top">
<td>
<input name="popup"
type="radio"
value="1"
alt="<?php p($strnewwindow)?>"
<?php echo ($form->popup == 1) ? 'checked="checked"' : '' ?>
onclick="return lockoptions('form', 'popup[1]', popupitems);"
/>
<b title="<?php p($strnewwindowopen) ?>"><?php p($strnewwindow) ?></b>
<blockquote>
<?php
foreach ($window as $name => $value) {
echo "<input name=\"h$name\" type=\"hidden\" value=\"0\"/>\n";
echo "<input name=\"$name\" type=\"checkbox\" value=\"1\" ".$window->$name." alt=\"$name\" />\n";
$stringname = "str$name";
echo $$stringname."<br />\n";
}
?>
<script type="text/javascript">
lockoptions('form','popup[1]', popupitems);
</script>
</blockquote>
</td>
</tr>
</table>
</div>
<script language="javascript" type="text/javascript">
showhide('advancedsettings', true);
showhide('windowsettings', true);
</script>
</td>
</tr>
</table>
<input type="hidden" name="datadir" value="<?php p($form->datadir) ?>" />
<input type="hidden" name="pkgtype" value="<?php p($form->pkgtype) ?>" />
<input type="hidden" name="launch" value="<?php p($form->launch) ?>" />
<?php
$scorms = get_all_instances_in_course('scorm', $course);
$coursescorm = current($scorms);
if (($course->format == 'scorm') && ((count($scorms) == 0) || ($form->instance == $coursescorm->id))) {
?>
<input type="hidden" name="redirect" value="yes" />
<input type="hidden" name="redirecturl" value="../course/view.php?id=<?php p($form->course) ?>" />
<?php
}
?>
<input type="hidden" name="course" value="<?php p($form->course) ?>" />
<input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" />
<input type="hidden" name="section" value="<?php p($form->section) ?>" />
<input type="hidden" name="module" value="<?php p($form->module) ?>" />
<input type="hidden" name="mode" value="<?php p($form->mode) ?>" />
<input type="hidden" name="coursemodule" value="<?php p($form->coursemodule) ?>" />
<input type="hidden" name="modulename" value="<?php p($form->modulename) ?>" />
<input type="hidden" name="instance" value="<?php p($form->instance) ?>" />
<center>
<input type="submit" value="<?php print_string('savechanges') ?>"/>
<input type="button" name="cancel" value="<?php print_string('cancel') ?>" onclick="document.location='view.php?id=<?php echo $form->course ?>'" />
</center>
</form>

View File

@ -1,307 +1,436 @@
<?PHP // $Id$
/// This page prints a particular instance of aicc/scorm package
require_once('../../config.php');
require_once('locallib.php');
//
// Checkin' script parameters
//
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
$scoid = required_param('scoid', PARAM_INT); // sco ID
$mode = optional_param('mode', 'normal', PARAM_ALPHA); // navigation mode
$currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
$newattempt = optional_param('newattempt', 'off', PARAM_ALPHA); // the user request to start a new attempt
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
} else {
error('A required parameter is missing');
}
require_login($course->id, false, $cm);
$strscorms = get_string('modulenameplural', 'scorm');
$strscorm = get_string('modulename', 'scorm');
$strpopup = get_string('popup','scorm');
if ($course->category != 0) {
$navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
if ($scorms = get_all_instances_in_course('scorm', $course)) {
// The module SCORM activity with the least id is the course
$firstscorm = current($scorms);
if (!(($course->format == 'scorm') && ($firstscorm->id == $scorm->id))) {
$navigation .= "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
}
}
} else {
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
}
$pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
if (!$cm->visible and !isteacher($course->id)) {
print_header($pagetitle, "$course->fullname",
"$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
'', '', true, update_module_button($cm->id, $course->id, $strscorm), '', false);
notice(get_string("activityiscurrentlyhidden"));
}
//
// TOC processing
//
$attempt = scorm_get_last_attempt($scorm->id, $USER->id);
if (($newattempt=='on') && (($attempt < $scorm->maxattempt) || ($scorm->maxattempt == 0))) {
$attempt++;
}
$attemptstr = '&amp;attempt=' . $attempt;
$result = scorm_get_toc($USER,$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,$USER->id,$attempt)) {
if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) {
$mode = 'review';
} else {
$mode = 'normal';
}
}
}
add_to_log($course->id, 'scorm', 'view', "player.php?id=$cm->id&scoid=$sco->id", "$scorm->id");
$scoidstr = '&amp;scoid='.$sco->id;
$scoidpop = '&scoid='.$sco->id;
$modestr = '&amp;mode='.$mode;
if ($mode == 'browse') {
$modepop = '&mode='.$mode;
} else {
$modepop = '';
}
$orgstr = '&currentorg='.$currentorg;
$SESSION->scorm_scoid = $sco->id;
$SESSION->scorm_status = 'Not Initialized';
$SESSION->scorm_mode = $mode;
$SESSION->attempt = $attempt;
//
// Print the page header
//
$bodyscript = '';
if ($scorm->popup == 1) {
$bodyscript = 'onunload="main.close();"';
}
$exitlink = '(<a href="'.$CFG->wwwroot.'/course/view.php?id='.$cm->course.'">'.get_string('exit','scorm').'</a>)&nbsp;';
print_header($pagetitle, "$course->fullname",
"$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
'', '', true, $exitlink.update_module_button($cm->id, $course->id, $strscorm), '', false, $bodyscript);
if ($sco->scormtype == 'sco') {
?>
<script language="JavaScript" type="text/javascript" src="request.js"></script>
<script language="JavaScript" type="text/javascript" src="api.php?id=<?php echo $cm->id.$scoidstr.$modestr.$attemptstr ?>"></script>
<?php
}
if (($sco->previd != 0) && ($sco->previous == 0)) {
$scostr = '&scoid='.$sco->previd;
echo ' <script language="javascript">var prev="'.$CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr."\";</script>\n";
} else {
echo ' <script language="javascript">var prev="'.$CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id."\";</script>\n";
}
if (($sco->nextid != 0) && ($sco->next == 0)) {
$scostr = '&scoid='.$sco->nextid;
echo ' <script language="javascript">var next="'.$CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr."\";</script>\n";
} else {
echo ' <script language="javascript">var next="'.$CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id."\";</script>\n";
}
?>
<div id="scormpage">
<?php
if ($scorm->hidetoc == 0) {
?>
<div id="tocbox" class="generalbox">
<div id="tochead" class="header"><?php print_string('coursestruct','scorm') ?></div>
<div id="toctree">
<?php echo $result->toc; ?>
</div>
</div>
<?php
$class = ' class="toc"';
} else {
$class = ' class="no-toc"';
}
?>
<div id="scormbox"<?php echo $class ?>>
<?php
// 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
(
(
($sco->previd != 0) && // This is not the first learning object of the package
($sco->previous == 0) // Moodle must manage the previous link
) ||
(
($sco->nextid != 0) && // This is not the last learning object of the package
($sco->next == 0) // Moodle must manage the next link
)
)
) || ($scorm->hidetoc == 2) // Teacher want to display toc in a small popup menu
) {
?>
<div id="scormtop">
<?php echo $mode == 'browse' ? '<div id="scormmode" class="left">'.get_string('browsemode','scorm')."</div>\n" : ''; ?>
<?php echo $mode == 'review' ? '<div id="scormmode" class="left">'.get_string('reviewmode','scorm')."</div>\n" : ''; ?>
<?php
if (($scorm->hidenav == 0) || ($scorm->hidetoc == 2)) {
?>
<div id="scormnav" class="right">
<?php
$orgstr = '&amp;currentorg='.$currentorg;
if (($scorm->hidenav == 0) && ($sco->previd != 0) && ($sco->previous == 0)) {
/// Print the prev LO link
$scostr = '&amp;scoid='.$sco->previd;
$url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr;
echo '<a href="'.$url.'">&lt; '.get_string('prev','scorm').'</a>';
}
if ($scorm->hidetoc == 2) {
echo $result->tocmenu;
}
if (($scorm->hidenav == 0) && ($sco->nextid != 0) && ($sco->next == 0)) {
/// Print the next LO link
$scostr = '&amp;scoid='.$sco->nextid;
$url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr;
echo ' &nbsp;<a href="'.$url.'">'.get_string('next','scorm').' &gt;</a>';
}
?>
</div>
<?php
}
?>
</div>
<?php
} // The end of the very big test
?>
<div id="scormobject" class="right">
<noscript>
<div id="noscript">
<?php print_string('noscriptnoscorm','scorm'); // No Martin(i), No Party ;-) ?>
</div>
</noscript>
<?php
if ($result->prerequisites) {
if ($scorm->popup == 0) {
if (strpos('MSIE',$_SERVER['HTTP_USER_AGENT']) === false) {
/// Internet Explorer does not has full support to objects
?>
<iframe id="main"
width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>"
height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>"
src="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>">
</iframe>
<?php
} else {
?>
<object id="main"
class="scoframe"
width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>"
height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>"
data="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>"
type="text/html">
<?php print_string('noobjectsupport', 'scorm'); ?>
</object>
<?php
}
} else {
?>
<script lanuguage="javascript">
function openpopup(url,name,options,width,height) {
fullurl = "<?php echo $CFG->wwwroot.'/mod/scorm/' ?>" + url;
windowobj = window.open(fullurl,name,options);
if ((width==100) && (height==100)) {
// Fullscreen
windowobj.moveTo(0,0);
}
if (width<=100) {
width = Math.round(screen.availWidth * width / 100);
}
if (height<=100) {
height = Math.round(screen.availHeight * height / 100);
}
windowobj.resizeTo(width,height);
windowobj.focus();
return windowobj;
}
url = "loadSCO.php?id=<?php echo $cm->id.$scoidpop ?>";
width = <?php p($scorm->width) ?>;
height = <?php p($scorm->height) ?>;
var main = openpopup(url, "<?php p($scorm->name) ?>", "<?php p($scorm->options) ?>", width, height);
</script>
<noscript>
<?php
if (strpos('MSIE',$_SERVER['HTTP_USER_AGENT']) === false) {
/// Internet Explorer does not has full support to objects
?>
<iframe id="main"
width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>"
height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>"
src="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>">
</iframe>
<?php
} else {
?>
<object id="main"
class="scoframe"
width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>"
height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>"
data="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>"
type="text/html">
<?php print_string('noobjectsupport', 'scorm'); ?>
</object>
<?php
}
?>
</noscript>
<?php
}
} else {
print_simple_box(get_string('noprerequisites','scorm'),'center');
}
?>
</div> <!-- SCORM object -->
</div> <!-- SCORM box -->
</div> <!-- SCORM content -->
</div> <!-- Content -->
</div> <!-- Page -->
</body>
</html>
<?PHP // $Id$
/// This page prints a particular instance of aicc/scorm package
require_once('../../config.php');
require_once('locallib.php');
require_once('sequencinglib.php');
//
// Checkin' script parameters
//
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
$scoid = required_param('scoid', PARAM_INT); // sco ID
$mode = optional_param('mode', 'normal', PARAM_ALPHA); // navigation mode
$currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
$newattempt = optional_param('newattempt', 'off', PARAM_ALPHA); // the user request to start a new attempt
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
} else {
error('A required parameter is missing');
}
require_login($course->id, false, $cm);
//$f = "D:\\test.txt";
//@$ft = fopen($f,"a");
//fwrite($ft,"\n ++ Thong tin quyen set attempt ".$USER->setAttempt);
$strscorms = get_string('modulenameplural', 'scorm');
$strscorm = get_string('modulename', 'scorm');
$strpopup = get_string('popup','scorm');
$attempt = scorm_get_last_attempt($scorm->id,$USER->id);
//Kiem tra xem co phai la tiep tuc khong
if ($mode=='continue')
{
$scoid = scorm_get_suspendscoid($scorm->id,$USER->id);
$USER->setAttempt = 'set';
$mode = 'normal';
}
if (($mode == 'normal') && ($USER->setAttempt == 'notset')){
$attempt++;
$USER->setAttempt = 'set';
}
//Thuc hien Sequencing
if ($mode!='review')
{
$sequencingResult = scorm_sequecingrule_implement($scorm->id,$scoid,$USER->id);
//echo "<script language='JavaScript'>";
// echo "alert('Sequencing');";
//echo "<script>";
if (($sequencingResult->rule == 'pre') && ($sequencingResult->action == 'disabled')){
echo "<script language='JavaScript'>";
echo "alert('Disabling');";
echo "</script>";
}
if (($sequencingResult->rule == 'exit') && ($sequencingResult->action == 'exit')){
$exitscoid = get_sco_after_exit($scoid,$scorm->id);
//fwrite($ft,"\n ++ Thong tin exit sco la ".$exitscoid);
$orgstr = '&currentorg='.$currentorg;
$modepop = '&mode='.$mode;
$scostr = '&scoid='.$exitscoid;
echo "<script language='JavaScript'>";
echo "alert('Exiting');";
echo "location.href='".$CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr."';";
echo "</script>";
}
}
//Thiet lap attempt_status cho scoid
scorm_set_attempt($scoid,$USER->id);
//Ket thuc thiet lap attemp_status
if ($mode!='review')
{
//Update trang thai
scorm_rollup_updatestatus($scorm->id,$scoid,$USER->id);
//------------------------------
}
//Thiet lap thong tin lien quan truy xuat Scorm
$statistic = get_record('scorm_statistic',"scormid",$scorm->id,"userid",$USER->id);
if (empty($statistic)){
$statisticInput->accesstime = time();
$statisticInput->durationtime = 0;
$statisticInput->status = 'during';
$statisticInput->attemptnumber = $attempt;
$statisticInput->scormid = $scorm->id;
$statisticInput->userid = $USER->id;
$statisticid = scorm_insert_statistic($statisticInput);
}
else{
if ($statistic->status=='suspend'){
$statisticInput->accesstime = time();
$statisticInput->durationtime = $statistic->durationtime;
$statisticInput->status = 'during';
$statisticInput->attemptnumber = $attempt;
$statisticInput->scormid = $scorm->id;
$statisticInput->userid = $USER->id;
}
}
//---------------------Ket thuc thiet lap thoi gian ---------------
//Lay thoi gian toi da cho phep
$absoluteTimeLimit = scorm_get_AbsoluteTimeLimit($scoid);
if ($absoluteTimeLimit > 0)
{
echo "<script type='text/javascript'>";
echo "alert('Bai nay co thoi gian lam la: ".$absoluteTimeLimit."');";
echo "function remind(msg1) {";
echo "var msg = 'Da het gio lam bai ' + msg1 +' Secs.Lua chon bai khac de tiep tuc';";
echo "alert(msg);";
echo "window.location.href = 'view.php?id=".$scorm->id."';";
echo "}";
echo "setTimeout('remind(".$absoluteTimeLimit.")',".$absoluteTimeLimit.");";
echo "</script>";
}
//--------------------------------
if ($course->category != 0) {
$navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
if ($scorms = get_all_instances_in_course('scorm', $course)) {
// The module SCORM activity with the least id is the course
$firstscorm = current($scorms);
if (!(($course->format == 'scorm') && ($firstscorm->id == $scorm->id))) {
$navigation .= "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
}
}
} else {
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
}
$pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
if (!$cm->visible and !isteacher($course->id)) {
print_header($pagetitle, "$course->fullname",
"$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
'', '', true, update_module_button($cm->id, $course->id, $strscorm), '', false);
notice(get_string("activityiscurrentlyhidden"));
}
//
// TOC processing
//
//$attempt = scorm_get_last_attempt($scorm->id, $USER->id);
//$f = "D:\\test.txt";
//@$ft = fopen($f,"a");
////fwrite($ft,"\n ++ ++ + ++ Gia tri $attempt lay duoc la ".$attempt);
//if ($mode=='normal'){
// $newattempt = 'on';
//}
if (($newattempt=='on') && (($attempt < $scorm->maxattempt) || ($scorm->maxattempt == 0))) {
$attempt++;
$f = "D:\\test.txt";
@$ft = fopen($f,"a");
//fwrite($ft,"\n ----New attempt------- ".$attempt);
}
$attemptstr = '&amp;attempt=' . $attempt;
//fwrite($ft,"\n ----Gia tri attempt bay gio la------- ".$attempt);
$result = scorm_get_toc($USER,$scorm,'structurelist',$currentorg,$scoid,$mode,$attempt,true);
$sco = $result->sco;
if (($mode == 'browse') && ($scorm->hidebrowse == 1)) {
$mode = 'normal';
}
if ($mode != 'browse') {
////fwrite($ft,"\n ++ ++ + ++ Gia tri $mode khac browser ".$mode);
if ($trackdata = scorm_get_tracks($sco->id,$USER->id,$attempt)) {
if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) {
$mode = 'review';
////fwrite($ft,"\n ++ ++ + ++ Gia tri $mode ".$mode);
} else {
$mode = 'normal';
////fwrite($ft,"\n ++ ++ + ++ Gia tri $mode ".$mode);
}
}
}
add_to_log($course->id, 'scorm', 'view', "player.php?id=$cm->id&scoid=$sco->id", "$scorm->id");
$scoidstr = '&amp;scoid='.$sco->id;
$scoidpop = '&scoid='.$sco->id;
$modestr = '&amp;mode='.$mode;
if ($mode == 'browse') {
$modepop = '&mode='.$mode;
} else {
$modepop = '';
}
$orgstr = '&currentorg='.$currentorg;
$SESSION->scorm_scoid = $sco->id;
$SESSION->scorm_status = 'Not Initialized';
$SESSION->scorm_mode = $mode;
$SESSION->attempt = $attempt;
// Doan code them
////fwrite($ft,"\n ++ ++ + ++ Gia tri attempt duoc gan cho user la ".$attempt);
$USER->attempt = $attempt;
//------------Ket thuc doan them
//
// Print the page header
//
$bodyscript = '';
if ($scorm->popup == 1) {
$bodyscript = 'onunload="main.close();"';
}
// Kiem tra xem co duoc exit khong
if (scorm_isChoiceexit($sco->scorm,$sco->id)){
$exitlink = '(<a href="'.$CFG->wwwroot.'/course/view.php?id='.$cm->course.'">'.get_string('exit','scorm').'</a>)&nbsp;';
}
else
{
$exitlink = get_string('exitisnotallowed','scorm');
}
//Luu giu khoa hoc thoat ra
$suspend = '(<a href="suspend.php?scorm='.$sco->scorm.'&sco='.$sco->id.'&userid='.$USER->id.'&id='.$cm->course.'">'.get_string('suspend','scorm').'</a>)&nbsp;';
print_header($pagetitle, "$course->fullname",
"$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
'', '', true, $exitlink.$suspend.update_module_button($cm->id, $course->id, $strscorm), '', false, $bodyscript);
if ($sco->scormtype == 'sco') {
?>
<script language="JavaScript" type="text/javascript" src="request.js"></script>
<script language="JavaScript" type="text/javascript" src="api.php?id=<?php echo $cm->id.$scoidstr.$modestr.$attemptstr ?>"></script>
<?php
}
if (($sco->previd != 0) && ($sco->previous == 0)) {
$scostr = '&scoid='.$sco->previd;
echo ' <script language="javascript">var prev="'.$CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr."\";</script>\n";
} else {
echo ' <script language="javascript">var prev="'.$CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id."\";</script>\n";
}
if (($sco->nextid != 0) && ($sco->next == 0)) {
$scostr = '&scoid='.$sco->nextid;
echo ' <script language="javascript">var next="'.$CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr."\";</script>\n";
} else {
echo ' <script language="javascript">var next="'.$CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id."\";</script>\n";
}
?>
<div id="scormpage">
<?php
if ($scorm->hidetoc == 0) {
?>
<div id="tocbox" class="generalbox">
<div id="tochead" class="header"><?php print_string('coursestruct','scorm') ?></div>
<div id="toctree">
<?php echo $result->toc; ?>
</div>
</div>
<?php
$class = ' class="toc"';
} else {
$class = ' class="no-toc"';
}
?>
<div id="scormbox"<?php echo $class ?>>
<?php
// 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
(
(
($sco->previd != 0) && // This is not the first learning object of the package
($sco->previous == 0) // Moodle must manage the previous link
) ||
(
($sco->nextid != 0) && // This is not the last learning object of the package
($sco->next == 0) // Moodle must manage the next link
)
)
) || ($scorm->hidetoc == 2) // Teacher want to display toc in a small dropdown menu
) {
?>
<div id="scormtop">
<?php echo $mode == 'browse' ? '<div id="scormmode" class="left">'.get_string('browsemode','scorm')."</div>\n" : ''; ?>
<?php echo $mode == 'review' ? '<div id="scormmode" class="left">'.get_string('reviewmode','scorm')."</div>\n" : ''; ?>
<?php
if (($scorm->hidenav == 0) || ($scorm->hidetoc == 2)) {
?>
<div id="scormnav" class="right">
<?php
$orgstr = '&amp;currentorg='.$currentorg;
if (($scorm->hidenav == 0) && ($sco->previd != 0) && ($sco->previous == 0)) {
/// Print the prev LO link
$scostr = '&amp;scoid='.$sco->previd;
$url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr;
echo '<a href="'.$url.'">&lt; '.get_string('prev','scorm').'</a>';
}
if ($scorm->hidetoc == 2) {
echo $result->tocmenu;
}
if (($scorm->hidenav == 0) && ($sco->nextid != 0) && ($sco->next == 0)) {
/// Print the next LO link
$scostr = '&amp;scoid='.$sco->nextid;
$url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr;
echo ' &nbsp;<a href="'.$url.'">'.get_string('next','scorm').' &gt;</a>';
}
?>
</div>
<?php
}
?>
</div>
<?php
} // The end of the very big test
?>
<div id="scormobject" class="right">
<noscript>
<div id="noscript">
<?php print_string('noscriptnoscorm','scorm'); // No Martin(i), No Party ;-) ?>
</div>
</noscript>
<?php
if ($result->prerequisites) {
if ($scorm->popup == 0) {
if (strpos('MSIE',$_SERVER['HTTP_USER_AGENT']) === false) {
/// Internet Explorer does not has full support to objects
?>
<iframe id="main"
width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>"
height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>"
src="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>">
</iframe>
<?php
} else {
?>
<object id="main"
class="scoframe"
width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>"
height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>"
data="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>"
type="text/html">
<?php print_string('noobjectsupport', 'scorm'); ?>
</object>
<?php
}
} else {
?>
<script lanuguage="javascript">
function openpopup(url,name,options,width,height) {
fullurl = "<?php echo $CFG->wwwroot.'/mod/scorm/' ?>" + url;
windowobj = window.open(fullurl,name,options);
if ((width==100) && (height==100)) {
// Fullscreen
windowobj.moveTo(0,0);
}
if (width<=100) {
width = Math.round(screen.availWidth * width / 100);
}
if (height<=100) {
height = Math.round(screen.availHeight * height / 100);
}
windowobj.resizeTo(width,height);
windowobj.focus();
return windowobj;
}
url = "loadSCO.php?id=<?php echo $cm->id.$scoidpop ?>";
width = <?php p($scorm->width) ?>;
height = <?php p($scorm->height) ?>;
var main = openpopup(url, "<?php p($scorm->name) ?>", "<?php p($scorm->options) ?>", width, height);
</script>
<noscript>
<?php
if (strpos('MSIE',$_SERVER['HTTP_USER_AGENT']) === false) {
/// Internet Explorer does not has full support to objects
?>
<iframe id="main"
width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>"
height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>"
src="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>">
</iframe>
<?php
} else {
?>
<object id="main"
class="scoframe"
width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>"
height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>"
data="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>"
type="text/html">
<?php print_string('noobjectsupport', 'scorm'); ?>
</object>
<?php
}
?>
</noscript>
<?php
}
} else {
print_simple_box(get_string('noprerequisites','scorm'),'center');
}
?>
</div> <!-- SCORM object -->
</div> <!-- SCORM box -->
</div> <!-- SCORM content -->
</div> <!-- Content -->
</div> <!-- Page -->
</body>
</html>

View File

@ -1,320 +1,369 @@
<?php // $Id$
// This script uses installed report plugins to print quiz reports
require_once("../../config.php");
require_once('locallib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // SCORM ID
$b = optional_param('b', '', PARAM_INT); // SCO ID
$user = optional_param('user', '', PARAM_INT); // User ID
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else {
if (!empty($b)) {
if (! $sco = get_record("scorm_scoes", "id", $b)) {
error("Scorm activity is incorrect");
}
$a = $sco->scorm;
}
if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
}
}
require_login($course->id, false, $cm);
if (!isteacher($course->id)) {
error("You are not allowed to use this script");
}
add_to_log($course->id, "scorm", "report", "report.php?id=$cm->id", "$scorm->id");
/// Print the page header
if (empty($noheader)) {
if ($course->category) {
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
} else {
$navigation = '';
}
$strscorms = get_string("modulenameplural", "scorm");
$strscorm = get_string("modulename", "scorm");
$strreport = get_string("report", "scorm");
$strname = get_string('name');
if (empty($b)) {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
-> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a> -> $strreport",
"", "", true);
} else {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
-> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>
-> <a href=\"report.php?id=$cm->id\">$strreport</a> -> $sco->title",
"", "", true);
}
print_heading(format_string($scorm->name));
}
$scormpixdir = $CFG->modpixpath.'/scorm/pix';
if (empty($b) ) {
if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' ORDER BY id")) {
if ($scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid")) {
$table = new stdClass();
$table->head = array('&nbsp;', $strname);
$table->align = array('center', 'left');
$table->wrap = array('nowrap', 'nowrap');
$table->width = '100%';
$table->size = array(10, '*');
foreach ($scoes as $sco) {
if ($sco->launch!='') {
$table->head[]=scorm_string_wrap($sco->title);
//$table->head[]=$sco->title;
$table->align[] = 'center';
$table->wrap[] = 'nowrap';
$table->size[] = '*';
}
}
foreach ($scousers as $scouser) {
if ($userdata = scorm_get_user_data($scouser->userid)) {
$row = array();
$row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true);
$row[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">".
"$userdata->firstname $userdata->lastname</a>";
foreach ($scoes as $sco) {
if ($sco->launch!='') {
$anchorstart = '';
$anchorend = '';
$scoreview = '';
if ($trackdata = scorm_get_tracks($sco->id,$scouser->userid)) {
if ($trackdata->score_raw != '') {
$scoreview = '<br />'.get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
}
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
} else {
$anchorstart = '<a href="report.php?b='.$sco->id.'&user='.$scouser->userid.'" title="'.
get_string('details','scorm').'">';
$anchorend = '</a>';
}
} else {
$trackdata->status = 'notattempted';
$trackdata->total_time = '';
}
$strstatus = get_string($trackdata->status,'scorm');
$row[] = $anchorstart.'<img src="'.$scormpixdir.'/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
$strstatus.'">&nbsp;'.$trackdata->total_time.$scoreview.$anchorend;
}
}
$table->data[] = $row;
}
}
print_table($table);
} else {
notice('No users to report');
}
}
} else {
if (!empty($user)) {
if ($userdata = scorm_get_user_data($user)) {
print_simple_box_start('center');
print_heading(format_string($sco->title));
echo '<div align="center">'."\n";
print_user_picture($user, $course->id, $userdata->picture, false, false);
echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user&course=$course->id\">".
"$userdata->firstname $userdata->lastname</a><br />";
$scoreview = '';
if ($trackdata = scorm_get_tracks($sco->id,$user)) {
if ($trackdata->score_raw != '') {
$scoreview = get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
}
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
}
} else {
$trackdata->status = 'notattempted';
$trackdata->total_time = '';
}
$strstatus = get_string($trackdata->status,'scorm');
echo '<img src="'.$scormpixdir.'/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
$strstatus.'">&nbsp;'.$trackdata->total_time.'<br />'.$scoreview.'<br />';
echo '</div>'."\n";
echo '<hr /><h2>'.get_string('details','scorm').'</h2>';
// Print general score data
$table = new stdClass();
$table->head = array(get_string('element','scorm'), get_string('value','scorm'));
$table->align = array('left', 'left');
$table->wrap = array('nowrap', 'nowrap');
$table->width = '100%';
$table->size = array('*', '*');
$existelements = false;
if ($scorm->version == 'SCORM_1.3') {
$elements = array('raw' => 'cmi.score.raw',
'min' => 'cmi.score.min',
'max' => 'cmi.score.max',
'status' => 'cmi.completition_status',
'time' => 'cmi.total_time');
} else {
$elements = array('raw' => 'cmi.core.score.raw',
'min' => 'cmi.core.score.min',
'max' => 'cmi.core.score.max',
'status' => 'cmi.core.lesson_status',
'time' => 'cmi.core.total_time');
}
foreach ($elements as $key => $element) {
if (isset($trackdata->$element)) {
$existelements = true;
$printedelements[]=$element;
$row = array();
$row[] = get_string($key,'scorm');
$row[] = $trackdata->$element;
$table->data[] = $row;
}
}
if ($existelements) {
echo '<h3>'.get_string('general','scorm').'</h3>';
print_table($table);
}
// Print Interactions data
$table = new stdClass();
$table->head = array(get_string('identifier','scorm'),
get_string('type','scorm'),
get_string('result','scorm'),
get_string('student_response','scorm'));
$table->align = array('center', 'center', 'center', 'center');
$table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap');
$table->width = '100%';
$table->size = array('*', '*', '*', '*', '*');
$existinteraction = false;
$i = 0;
$interactionid = 'cmi.interactions.'.$i.'.id';
while (isset($trackdata->$interactionid)) {
$existinteraction = true;
$printedelements[]=$interactionid;
$elements = array($interactionid,
'cmi.interactions.'.$i.'.type',
'cmi.interactions.'.$i.'.result',
'cmi.interactions.'.$i.'.student_response');
$row = array();
foreach ($elements as $element) {
if (isset($trackdata->$element)) {
$row[] = $trackdata->$element;
$printedelements[]=$element;
} else {
$row[] = '&nbsp;';
}
}
$table->data[] = $row;
$i++;
$interactionid = 'cmi.interactions.'.$i.'.id';
}
if ($existinteraction) {
echo '<h3>'.get_string('interactions','scorm').'</h3>';
print_table($table);
}
// Print Objectives data
$table = new stdClass();
$table->head = array(get_string('identifier','scorm'),
get_string('status','scorm'),
get_string('raw','scorm'),
get_string('min','scorm'),
get_string('max','scorm'));
$table->align = array('center', 'center', 'center', 'center', 'center');
$table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap');
$table->width = '100%';
$table->size = array('*', '*', '*', '*', '*');
$existobjective = false;
$i = 0;
$objectiveid = 'cmi.objectives.'.$i.'.id';
while (isset($trackdata->$objectiveid)) {
$existobjective = true;
$printedelements[]=$objectiveid;
$elements = array($objectiveid,
'cmi.objectives.'.$i.'.status',
'cmi.objectives.'.$i.'.score.raw',
'cmi.objectives.'.$i.'.score.min',
'cmi.objectives.'.$i.'.score.max');
$row = array();
foreach ($elements as $element) {
if (isset($trackdata->$element)) {
$row[] = $trackdata->$element;
$printedelements[]=$element;
} else {
$row[] = '&nbsp;';
}
}
$table->data[] = $row;
$i++;
$objectiveid = 'cmi.objectives.'.$i.'.id';
}
if ($existobjective) {
echo '<h3>'.get_string('objectives','scorm').'</h3>';
print_table($table);
}
$table = new stdClass();
$table->head = array(get_string('element','scorm'), get_string('value','scorm'));
$table->align = array('left', 'left');
$table->wrap = array('nowrap', 'wrap');
$table->width = '100%';
$table->size = array('*', '*');
$existelements = false;
foreach($trackdata as $element => $value) {
if (substr($element,0,3) == 'cmi') {
if (!(in_array ($element, $printedelements))) {
$existelements = true;
$row = array();
$row[] = get_string($element,'scorm') != '[['.$element.']]' ? get_string($element,'scorm') : $element;
$row[] = $value;
$table->data[] = $row;
}
}
}
if ($existelements) {
echo '<h3>'.get_string('othertracks','scorm').'</h3>';
print_table($table);
}
print_simple_box_end();
}
} else {
error('Missing script parameter');
}
}
if (empty($noheader)) {
print_footer($course);
}
?>
<?php // $Id$
// This script uses installed report plugins to print quiz reports
require_once("../../config.php");
require_once('locallib.php');
require_once('sequencinglib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // SCORM ID
$b = optional_param('b', '', PARAM_INT); // SCO ID
$user = optional_param('user', '', PARAM_INT); // User ID
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else {
if (!empty($b)) {
if (! $sco = get_record("scorm_scoes", "id", $b)) {
error("Scorm activity is incorrect");
}
$a = $sco->scorm;
}
if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
}
}
require_login($course->id, false, $cm);
if (!isteacher($course->id)) {
error("You are not allowed to use this script");
}
add_to_log($course->id, "scorm", "report", "report.php?id=$cm->id", "$scorm->id");
/// Print the page header
if (empty($noheader)) {
if ($course->category) {
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
} else {
$navigation = '';
}
$strscorms = get_string("modulenameplural", "scorm");
$strscorm = get_string("modulename", "scorm");
$strreport = get_string("report", "scorm");
$strname = get_string('name');
if (empty($b)) {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
-> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a> -> $strreport",
"", "", true);
} else {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
-> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>
-> <a href=\"report.php?id=$cm->id\">$strreport</a> -> $sco->title",
"", "", true);
}
print_heading(format_string($scorm->name));
}
$scormpixdir = $CFG->modpixpath.'/scorm/pix';
if (empty($b) ) {
if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' ORDER BY id")) {
if ($scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid")) {
$table = new stdClass();
$table->head = array('&nbsp;', $strname);
$table->align = array('center', 'left');
$table->wrap = array('nowrap', 'nowrap');
$table->width = '100%';
$table->size = array(10, '*');
foreach ($scoes as $sco) {
if ($sco->launch!='') {
$table->head[]=scorm_string_wrap($sco->title);
//$table->head[]=$sco->title;
$table->align[] = 'center';
$table->wrap[] = 'nowrap';
$table->size[] = '*';
}
}
foreach ($scousers as $scouser) {
if ($userdata = scorm_get_user_data($scouser->userid)) {
$row = array();
$row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true);
$row[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">".
"$userdata->firstname $userdata->lastname</a>";
foreach ($scoes as $sco) {
if ($sco->launch!='') {
$anchorstart = '';
$anchorend = '';
$scoreview = '';
if ($trackdata = scorm_get_tracks($sco->id,$scouser->userid)) {
if ($trackdata->score_raw != '') {
$scoreview = '<br />'.get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
}
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
} else {
$anchorstart = '<a href="report.php?b='.$sco->id.'&user='.$scouser->userid.'" title="'.
get_string('details','scorm').'">';
$anchorend = '</a>';
}
} else {
$trackdata->status = 'notattempted';
$trackdata->total_time = '';
}
$strstatus = get_string($trackdata->status,'scorm');
$row[] = $anchorstart.'<img src="'.$scormpixdir.'/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
$strstatus.'">&nbsp;'.$trackdata->total_time.$scoreview.$anchorend;
}
}
$table->data[] = $row;
}
}
print_table($table);
} else {
notice('No users to report');
}
}
} else {
if (!empty($user)) {
if ($userdata = scorm_get_user_data($user)) {
print_simple_box_start('center');
print_heading(format_string($sco->title));
echo '<div align="center">'."\n";
print_user_picture($user, $course->id, $userdata->picture, false, false);
echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user&course=$course->id\">".
"$userdata->firstname $userdata->lastname</a><br />";
$scoreview = '';
if ($trackdata = scorm_get_tracks($sco->id,$user)) {
if ($trackdata->score_raw != '') {
$scoreview = get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
}
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
}
} else {
$trackdata->status = 'notattempted';
$trackdata->total_time = '';
}
$strstatus = get_string($trackdata->status,'scorm');
echo '<img src="'.$scormpixdir.'/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
$strstatus.'">&nbsp;'.$trackdata->total_time.'<br />'.$scoreview.'<br />';
echo '</div>'."\n";
echo '<hr /><h2>'.get_string('details','scorm').'</h2>';
// Print general score data
$table = new stdClass();
$table->head = array(get_string('element','scorm'), get_string('value','scorm'));
$table->align = array('left', 'left');
$table->wrap = array('nowrap', 'nowrap');
$table->width = '100%';
$table->size = array('*', '*');
$existelements = false;
if ($scorm->version == 'SCORM_1.3') {
$elements = array('raw' => 'cmi.score.raw',
'min' => 'cmi.score.min',
'max' => 'cmi.score.max',
'status' => 'cmi.completition_status',
'time' => 'cmi.total_time');
} else {
$elements = array('raw' => 'cmi.core.score.raw',
'min' => 'cmi.core.score.min',
'max' => 'cmi.core.score.max',
'status' => 'cmi.core.lesson_status',
'time' => 'cmi.core.total_time');
}
foreach ($elements as $key => $element) {
if (isset($trackdata->$element)) {
$existelements = true;
$printedelements[]=$element;
$row = array();
$row[] = get_string($key,'scorm');
$row[] = $trackdata->$element;
$table->data[] = $row;
}
}
if ($existelements) {
echo '<h3>'.get_string('general','scorm').'</h3>';
print_table($table);
}
// Print Interactions data
$table = new stdClass();
$table->head = array(get_string('identifier','scorm'),
get_string('type','scorm'),
get_string('result','scorm'),
get_string('student_response','scorm'));
$table->align = array('center', 'center', 'center', 'center');
$table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap');
$table->width = '100%';
$table->size = array('*', '*', '*', '*', '*');
$existinteraction = false;
$i = 0;
$interactionid = 'cmi.interactions.'.$i.'.id';
while (isset($trackdata->$interactionid)) {
$existinteraction = true;
$printedelements[]=$interactionid;
$elements = array($interactionid,
'cmi.interactions.'.$i.'.type',
'cmi.interactions.'.$i.'.result',
'cmi.interactions.'.$i.'.student_response');
$row = array();
foreach ($elements as $element) {
if (isset($trackdata->$element)) {
$row[] = $trackdata->$element;
$printedelements[]=$element;
} else {
$row[] = '&nbsp;';
}
}
$table->data[] = $row;
$i++;
$interactionid = 'cmi.interactions.'.$i.'.id';
}
if ($existinteraction) {
echo '<h3>'.get_string('interactions','scorm').'</h3>';
print_table($table);
}
// Print Objectives data
$table = new stdClass();
$table->head = array(get_string('identifier','scorm'),
get_string('status','scorm'),
get_string('raw','scorm'),
get_string('min','scorm'),
get_string('max','scorm'));
$table->align = array('center', 'center', 'center', 'center', 'center');
$table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap');
$table->width = '100%';
$table->size = array('*', '*', '*', '*', '*');
$existobjective = false;
$i = 0;
$objectiveid = 'cmi.objectives.'.$i.'.id';
while (isset($trackdata->$objectiveid)) {
$existobjective = true;
$printedelements[]=$objectiveid;
$elements = array($objectiveid,
'cmi.objectives.'.$i.'.status',
'cmi.objectives.'.$i.'.score.raw',
'cmi.objectives.'.$i.'.score.min',
'cmi.objectives.'.$i.'.score.max');
$row = array();
foreach ($elements as $element) {
if (isset($trackdata->$element)) {
$row[] = $trackdata->$element;
$printedelements[]=$element;
} else {
$row[] = '&nbsp;';
}
}
$table->data[] = $row;
$i++;
$objectiveid = 'cmi.objectives.'.$i.'.id';
}
if ($existobjective) {
echo '<h3>'.get_string('objectives','scorm').'</h3>';
print_table($table);
}
$table = new stdClass();
$table->head = array(get_string('element','scorm'), get_string('value','scorm'));
$table->align = array('left', 'left');
$table->wrap = array('nowrap', 'wrap');
$table->width = '100%';
$table->size = array('*', '*');
$existelements = false;
foreach($trackdata as $element => $value) {
if (substr($element,0,3) == 'cmi') {
if (!(in_array ($element, $printedelements))) {
$existelements = true;
$row = array();
$row[] = get_string($element,'scorm') != '[['.$element.']]' ? get_string($element,'scorm') : $element;
$row[] = $value;
$table->data[] = $row;
}
}
}
if ($existelements) {
echo '<h3>'.get_string('othertracks','scorm').'</h3>';
print_table($table);
}
print_simple_box_end();
}
} else {
error('Missing script parameter');
}
}
print_heading(format_string(get_string('timestatistic','scorm')));
$scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid");
$attempt = scorm_get_last_attempt($scorm->id,$USER->id);
foreach($scousers as $scouser){
$str = 'scormid ='.($scorm->id).' and userid = '.$scouser->userid.' and attempt = '.$attempt.' ORDER BY timemodified asc';
$endtrack = get_record_select("scorm_scoes_track", $str,'max(timemodified) as maxtimemodified');
}
//Phan trinh bay thong ke theo thoi gian
$table = new stdClass();
$table->head = array('&nbsp;', get_string('name','scorm'));
$table->align = array('center', 'left');
$table->wrap = array('nowrap', 'nowrap');
$table->width = '100%';
$table->size = array(10, '*');
$table->head[]=scorm_string_wrap(get_string('beginTime','scorm'));
$table->align[] = 'center';
$table->wrap[] = 'nowrap';
$table->size[] = '*';
$table->head[]=scorm_string_wrap(get_string('endTime','scorm'));
$table->align[] = 'center';
$table->wrap[] = 'nowrap';
$table->size[] = '*';
$row = array();
$row[] = "";
$row[] = "(".get_string('coefficient','scorm').")";
foreach($scousers as $scouser){
$userdata = scorm_get_user_data($scouser->userid);
$row = array();
$row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true);
$row[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">".
"$userdata->firstname $userdata->lastname</a>";
$str = 'scormid ='.($scorm->id).' and userid = '.$scouser->userid.' and attempt = '.$attempt.' ORDER BY timemodified asc';
$begintrack = get_record_select("scorm_scoes_track", $str,'min(timemodified) as mintimemodified');
$row[] = strftime( "%H h -%M ' - %S s - %d -%m-%Y", $begintrack->mintimemodified);
$endtrack = get_record_select("scorm_scoes_track", $str,'max(timemodified) as maxtimemodified');
$row[] = strftime( "%H h -%M ' - %S s - %d -%m-%Y", $endtrack->maxtimemodified);
$table->data[] = $row;
}
print_table($table);
echo "<br><a href='viewScore.php?a=$scorm->id'>".format_string(get_string('viewscore','scorm'))."</a>";
if (empty($noheader)) {
print_footer($course);
}
?>

View File

@ -56,10 +56,6 @@
if (!is_int($scorm->grademethod)) {
$scorm->grademethod = 0;
}
$scorm->maxattempt = backup_todb($info['MOD']['#']['MAXATTEMPT']['0']['#']);
if (!is_int($scorm->maxattempt)) {
$scorm->maxattempt = 1;
}
if ($restore->backup_version < 2005041500) {
$scorm->datadir = substr(backup_todb($info['MOD']['#']['DATADIR']['0']['#']),1);
} else {
@ -234,10 +230,6 @@
$scotrack->scormid = $scorm_id;
$scotrack->userid = backup_todb($sub_info['#']['USERID']['0']['#']);
$scotrack->scoid = backup_todb($sub_info['#']['SCOID']['0']['#']);
$scotrack->attempt = backup_todb($sub_info['#']['ATTEMPT']['0']['#']);
if (!is_int($scotrack->attempt)) {
$scotrack->attempt = 1;
}
$scotrack->element = backup_todb($sub_info['#']['ELEMENT']['0']['#']);
$scotrack->value = backup_todb($sub_info['#']['VALUE']['0']['#']);
@ -492,7 +484,7 @@
$status = update_record("scorm",$scorm);
if ($CFG->debug>7) {
if (!defined('RESTORE_SILENTLY')) {
echo '<br /><hr />'.s($content).'<br />changed to<br />'.s($result).'<hr /><br />';
echo '<br /><hr />'.htmlentities($content).'<br />changed to<br />'.htmlentities($result).'<hr /><br />';
}
}
}

513
mod/scorm/sequencinglib.php Executable file
View File

@ -0,0 +1,513 @@
<?php
// Cac ham danh cho viec thuc thi Sequencing
// --------Ket thuc cac ham danh cho viec thuc thi Sequencing ------------
// Cac ham danh cho viec thuc thi Rollup
//-----------------------------------------------------
function scorm_rollup_updatestatus($scormid,$scoidchild, $userid)
{
//$f = "D:\\test.txt";
//@$ft = fopen($f,"a");
//fwrite($ft,"\n >>>>> SCO goi Rollup la ".$scoidchild);
$scochild = get_record("scorm_scoes","id",$scoidchild);
$scoparent = get_record("scorm_scoes","scorm",$scormid,"identifier",$scochild->parent);
//Danh sach cac con cua cha
$scochildren = get_records_select("scorm_scoes","scorm =".$scormid." and parent ='".$scoparent->identifier."'");
//Lay gia tri last attempt
//fwrite($ft,"\n >>>>> Bat dau xu ly Rollup SCO cha ".$scoparent->id);
$attempt = scorm_get_last_attempt($scormid,$userid);
if(!empty($scoparent)){
$scoid = $scoparent->id;
$rolluprules = get_record("scorm_sequencing_rolluprules","scormid",$scormid,"scoid",$scoid);
if (!empty($rolluprules)){
$idrolluprules = $rolluprules->id;
$rules = get_records_select('scorm_sequencing_rolluprule','scoid ='.$scoid.' and rolluprulesid ='. $idrolluprules);
foreach ($rules as $rule){
$ruleid = $rule->id;
$ruleConditions = get_record("scorm_sequencing_rollupruleconditions","scoid",$scoid,"rollupruleid",$ruleid);
$idruleConditions = $ruleConditions->id;
$conditions = get_records_select('scorm_sequencing_rolluprulecondition','scoid ='.$scoid.' and ruleconditionsid ='.$idruleConditions);
//Truong hop 1: childactivitySet = all
// conditioncombination = any
if (($rule->childactivityset == 'all') && ($ruleConditions->conditioncombination=='any')){
foreach($conditions as $condition){
$conditionOK = false;
//Condition 1: condition = attempted operator = 'noOp'
// Thuc hien rollupaction
if (($condition->condition == 'attempted') && ($condition->operator=='noOp')){
$conditionOK = true;
foreach ($scochildren as $sco){
//fwrite($ft,"\n >>>>> Xu ly Rollup voi dieu kien attempt \n");
$usertrack = scorm_get_tracks($sco->id,$userid);
if ($usertrack->attempt_status != 'attempted'){
//fwrite($ft,"\n >>>>> Co SCO con chua attempted \n");
$conditionOK = false;
}
}
}
//Condition 2: condition = attempted operator = 'not'
// Thuc hien rollupaction
if (($condition->condition == 'attempted') && ($condition->operator=='not')){
$conditionOK = true;
foreach ($scochildren as $sco){
//fwrite($ft,"\n >>>>> Xu ly Rollup voi dieu kien not attempt \n");
$usertrack = scorm_get_tracks($sco->id,$userid);
if ($usertrack->attempt_status != 'notattempted'){
$conditionOK = false;
}
}
}
//Condition 3: condition = satisfied operator = 'noOp'
// Thuc hien rollupaction
if (($condition->condition == 'satisfied') && ($condition->operator=='noOp')){
$conditionOK = true;
foreach ($scochildren as $sco){
$usertrack = scorm_get_tracks($sco->id,$userid);
if ($usertrack->satisfied_status != 'satisfied'){
$conditionOK = false;
}
}
}
//Condition 4: condition = satisfied operator = 'not'
// Thuc hien rollupaction
if (($condition->condition == 'satisfied') && ($condition->operator=='not')){
$conditionOK = true;
foreach ($scochildren as $sco){
$usertrack = scorm_get_tracks($sco->id,$userid);
if ($usertrack->satisfied_status != 'notSatisfied'){
$conditionOK = false;
}
}
}
//Condition 5: condition = completed operator = 'noOp'
// Thuc hien rollupaction
if (($condition->condition == 'completed') && ($condition->operator=='noOp')){
$conditionOK = true;
foreach ($scochildren as $sco){
$usertrack = scorm_get_tracks($sco->id,$userid);
if ($usertrack->attempt_status != 'completed'){
$conditionOK = false;
}
}
}
//Condition 6: condition = completed operator = 'not'
// Thuc hien rollupaction
if (($condition->condition == 'completed') && ($condition->operator=='not')){
$conditionOK = true;
foreach ($scochildren as $sco){
$usertrack = scorm_get_tracks($sco->id,$userid);
if ($usertrack->attempt_status != 'notcompleted'){
$conditionOK = false;
}
}
}
//Neu dieu kien van dung sau khi xem xet thi thuc hien action
if ($conditionOK == true){
if ($ruleConditions->rollupruleaction == 'completed')
{
scorm_insert_track($userid,$scormid,$scoid,$attempt,'cmi.completion_status','completed');
//fwrite($ft,"\n >>>>> Xu ly Rollup thanh cong voi completed cho SCO ".$scoid);
}
if ($ruleConditions->rollupruleaction == 'satisfied')
{
scorm_insert_track($userid,$scormid,$scoid,$attempt,'cmi.success_status','passed');
//fwrite($ft,"\n >>>>> Xu ly Rollup thanh cong voi satisfied\n");
}
if ($ruleConditions->rollupruleaction == 'notSatisfied')
{
scorm_insert_track($userid,$scormid,$scoid,$attempt,'cmi.success_status','failed');
//fwrite($ft,"\n >>>>> Xu ly Rollup thanh cong voi notSatisfied\n");
}
//echo "<script language='JavaScript'>";
//echo "alert('Thuc hien rollup. Trang thai ".$scoparent->identifier." la hoan thanh voi userid".$userid."');";
//echo "<script>";
}
}
}
//Ket thuc truong hop 1
//Truong hop 2: childactivitySet = any
// conditioncombination = any
if (($rule->childactivityset == 'any') && ($ruleConditions->conditioncombination=='any')){
$conditionOK = false;
foreach($conditions as $condition){
//$conditionOK = false;
//Condition 1: condition = attempted operator = 'noOp'
// Thuc hien rollupaction
if (($condition->condition == 'attempted') && ($condition->operator=='noOp')){
$conditionOK = false;
foreach ($scochildren as $sco){
$usertrack = scorm_get_tracks($sco->id,$userid);
if ($usertrack->attempt_status = 'attempted'){
$conditionOK = true;
}
}
}
//Condition 2: condition = attempted operator = 'not'
// Thuc hien rollupaction
if (($condition->condition == 'attempted') && ($condition->operator=='not')){
$conditionOK = false;
foreach ($scochildren as $sco){
$usertrack = scorm_get_tracks($sco->id,$userid);
if ($usertrack->attempt_status = 'notattempted'){
$conditionOK = true;
}
}
}
//Condition 3: condition = satisfied operator = 'noOp'
// Thuc hien rollupaction
if (($condition->condition == 'satisfied') && ($condition->operator=='noOp')){
$conditionOK = false;
foreach ($scochildren as $sco){
$usertrack = scorm_get_tracks($sco->id,$userid);
if ($usertrack->satisfied_status = 'satisfied'){
$conditionOK = true;
}
}
}
//Condition 4: condition = satisfied operator = 'not'
// Thuc hien rollupaction
if (($condition->condition == 'satisfied') && ($condition->operator=='not')){
$conditionOK = false;
foreach ($scochildren as $sco){
$usertrack = scorm_get_tracks($sco->id,$userid);
if ($usertrack->satisfied_status = 'notSatisfied'){
//fwrite($ft,"\n >>>>> Xu ly Rollup voi notSatisfied\n");
$conditionOK = true;
}
}
}
//Condition 5: condition = completed operator = 'noOp'
// Thuc hien rollupaction
if (($condition->condition == 'completed') && ($condition->operator=='noOp')){
$conditionOK = false;
foreach ($scochildren as $sco){
$usertrack = scorm_get_tracks($sco->id,$userid);
if ($usertrack->attempt_status = 'completed'){
$conditionOK = true;
}
}
}
//Condition 6: condition = completed operator = 'not'
// Thuc hien rollupaction
if (($condition->condition == 'completed') && ($condition->operator=='not')){
$conditionOK = false;
foreach ($scochildren as $sco){
$usertrack = scorm_get_tracks($sco->id,$userid);
if ($usertrack->attempt_status = 'notcompleted'){
$conditionOK = true;
}
}
}
//Neu dieu kien van dung sau khi xem xet thi thuc hien action
if ($conditionOK == true){
if ($ruleConditions->rollupruleaction == 'completed')
{
scorm_insert_track($userid,$scormid,$scoid,$attempt,'cmi.completion_status','completed');
//fwrite($ft,"\n >>>>> Xu ly Rollup thanh cong voi completed\n");
}
if ($ruleConditions->rollupruleaction == 'satisfied')
{
scorm_insert_track($userid,$scormid,$scoid,$attempt,'cmi.success_status','passed');
//fwrite($ft,"\n >>>>> Xu ly Rollup thanh cong voi satisfied\n");
}
if ($ruleConditions->rollupruleaction == 'notSatisfied')
{
scorm_insert_track($userid,$scormid,$scoid,$attempt,'cmi.success_status','failed');
//fwrite($ft,"\n >>>>> Xu ly Rollup thanh cong voi notSatisfied\n");
}
//echo "<script language='JavaScript'>";
//echo "alert('Thuc hien rollup. Trang thai ".$scoparent->identifier." la hoan thanh voi userid".$userid."');";
//echo "<script>";
}
}
}
//Ket thuc truong hop 2
//Truong hop 3: childactivitySet = any
// conditioncombination = all
if (($rule->childactivityset == 'any') && ($ruleConditions->conditioncombination=='all')){
foreach ($scochildren as $sco){
$usertrack = scorm_get_tracks($sco->id,$userid);
$conditionOK = true;
foreach($conditions as $condition){
//Condition 1: condition = attempted operator = 'noOp'
// Thuc hien rollupaction
if (($condition->condition == 'attempted') && ($condition->operator=='noOp')){
if ($usertrack->attempt_status != 'attempted'){
$conditionOK = false;
}
}
//Condition 2: condition = attempted operator = 'not'
// Thuc hien rollupaction
if (($condition->condition == 'attempted') && ($condition->operator=='not')){
if ($usertrack->attempt_status != 'notattempted'){
$conditionOK = false;
}
}
//Condition 3: condition = satisfied operator = 'noOp'
// Thuc hien rollupaction
if (($condition->condition == 'satisfied') && ($condition->operator=='noOp')){
if ($usertrack->attempt_status != 'satisfied'){
$conditionOK = false;
}
}
//Condition 4: condition = satisfied operator = 'not'
// Thuc hien rollupaction
if (($condition->condition == 'satisfied') && ($condition->operator=='not')){
if ($usertrack->attempt_status != 'notSatisfied'){
$conditionOK = false;
}
}
//Condition 5: condition = completed operator = 'noOp'
// Thuc hien rollupaction
if (($condition->condition == 'completed') && ($condition->operator=='noOp')){
if ($usertrack->attempt_status != 'completed'){
$conditionOK = false;
}
}
//Condition 6: condition = completed operator = 'not'
// Thuc hien rollupaction
if (($condition->condition == 'completed') && ($condition->operator=='not')){
if ($usertrack->attempt_status != 'notcompleted'){
$conditionOK = false;
}
}
//Neu dieu kien van dung sau khi xem xet thi thuc hien action
}
}
if ($conditionOK == true){
if ($ruleConditions->rollupruleaction == 'completed')
{
scorm_insert_track($userid,$scormid,$scoid,$attempt,'cmi.completion_status','completed');
//fwrite($ft,"\n >>>>> Xu ly Rollup thanh cong voi completed\n");
}
if ($ruleConditions->rollupruleaction == 'satisfied')
{
scorm_insert_track($userid,$scormid,$scoid,$attempt,'cmi.success_status','passed');
//fwrite($ft,"\n >>>>> Xu ly Rollup thanh cong voi satisfied\n");
}
if ($ruleConditions->rollupruleaction == 'notSatisfied')
{
scorm_insert_track($userid,$scormid,$scoid,$attempt,'cmi.success_status','failed');
//fwrite($ft,"\n >>>>> Xu ly Rollup thanh cong voi notSatisfied\n");
}
//echo "<script language='JavaScript'>";
//echo "alert('Thuc hien rollup. Trang thai ".$scoparent->identifier." la hoan thanh voi userid".$userid."');";
//echo "<script>";
}
}
//Ket thuc truong hop 3
//Truong hop 4: childactivitySet = all
// conditioncombination = all
if (($rule->childactivityset == 'all') && ($ruleConditions->conditioncombination=='all')){
$conditionOK = true;
foreach ($scochildren as $sco){
$usertrack = scorm_get_tracks($sco->id,$userid);
foreach($conditions as $condition){
//Condition 1: condition = attempted operator = 'noOp'
// Thuc hien rollupaction
if (($condition->condition == 'attempted') && ($condition->operator=='noOp')){
if ($usertrack->attempt_status != 'attempted'){
$conditionOK = false;
}
}
//Condition 2: condition = attempted operator = 'not'
// Thuc hien rollupaction
if (($condition->condition == 'attempted') && ($condition->operator=='not')){
if ($usertrack->attempt_status != 'notattempted'){
$conditionOK = false;
}
}
//Condition 3: condition = satisfied operator = 'noOp'
// Thuc hien rollupaction
if (($condition->condition == 'satisfied') && ($condition->operator=='noOp')){
if ($usertrack->attempt_status != 'satisfied'){
$conditionOK = false;
}
}
//Condition 4: condition = satisfied operator = 'not'
// Thuc hien rollupaction
if (($condition->condition == 'satisfied') && ($condition->operator=='not')){
if ($usertrack->attempt_status != 'notSatisfied'){
$conditionOK = false;
}
}
//Condition 5: condition = completed operator = 'noOp'
// Thuc hien rollupaction
if (($condition->condition == 'completed') && ($condition->operator=='noOp')){
if ($usertrack->attempt_status != 'completed'){
$conditionOK = false;
}
}
//Condition 6: condition = completed operator = 'not'
// Thuc hien rollupaction
if (($condition->condition == 'completed') && ($condition->operator=='not')){
if ($usertrack->attempt_status != 'notcompleted'){
$conditionOK = false;
}
}
//Neu dieu kien van dung sau khi xem xet thi thuc hien action
}
}
if ($conditionOK == true){
if ($ruleConditions->rollupruleaction == 'completed')
{
scorm_insert_track($userid,$scormid,$scoid,$attempt,'cmi.completion_status','completed');
//fwrite($ft,"\n >>>>> Xu ly Rollup thanh cong voi completed\n");
}
if ($ruleConditions->rollupruleaction == 'satisfied')
{
scorm_insert_track($userid,$scormid,$scoid,$attempt,'cmi.success_status','passed');
//fwrite($ft,"\n >>>>> Xu ly Rollup thanh cong voi satisfied\n");
}
if ($ruleConditions->rollupruleaction == 'notSatisfied')
{
scorm_insert_track($userid,$scormid,$scoid,$attempt,'cmi.success_status','failed');
//fwrite($ft,"\n >>>>> Xu ly Rollup thanh cong voi notSatisfied\n");
}
//echo "<script language='JavaScript'>";
//echo "alert('Thuc hien rollup. Trang thai ".$scoparent->identifier." la hoan thanh voi userid".$userid."');";
//echo "<script>";
}
}
//Ket thuc truong hop 4
}
}
//Thuc hien de qui cho Rollup voi cac muc cha
$scograndparent = get_record("scorm_scoes","scorm",$scormid,"identifier",$scoparent->parent);
if (!empty($scograndparent)){
//fwrite($ft,"\n >>>>> Quay lui Rollup SCO ".$scoparent->id);
scorm_rollup_updatestatus($scormid,$scoparent->id, $userid);
}
}
}
// --------Ket thuc cac ham danh cho viec thuc thi Rollup -------
//---------Thuc hien sequencing rule -----------------
function scorm_sequecingrule_implement($scormid,$scoidchild, $userid)
{
$sequencingResult->rule = ''; //Rule co 3 truong hop exit, pre va post
$sequencingResult->action = '';
$f = "D:\\test.txt";
@$ft = fopen($f,"a");
//fwrite($ft,"\n >>>>> Kiem tra Sequencing \n");
$scochild = get_record("scorm_scoes","id",$scoidchild);
$scoparent = get_record("scorm_scoes","scorm",$scormid,"identifier",$scochild->parent);
//Danh sach cac con cua cha
$scochildren = get_records_select("scorm_scoes","scorm =".$scormid." and parent ='".$scoparent->identifier."'");
//Lay gia tri last attempt
$attempt = scorm_get_last_attempt($scormid,$userid);
if(!empty($scoparent)){
//fwrite($ft,"\n >>>>> Kiem tra Sequencing : Co Parent\n");
$scoid = $scoparent->id;
//Lay trang thai cua SCO cha
$usertrack = scorm_get_tracks($scoid,$userid);
//fwrite($ft,"\n >>>>> Kiem tra Sequencing : id Parent ".$scoid);
//fwrite($ft,"\n >>>>> Kiem tra Sequencing : usertrack ".$usertrack->status);
$sequencingrules = get_records_select("scorm_sequencing_ruleconditions","scormid=".$scormid." and scoid=".$scoid);
if (!empty($sequencingrules)){
foreach($sequencingrules as $sequencingrule){
//fwrite($ft,"\n >>>>> Kiem tra Sequencing : Co Sequencing o SCO".$sequencingrule->scoid);
$idsequencingrule = $sequencingrule->id;
$ruleconditions = get_records_select('scorm_sequencing_rulecondition','scoid ='.$scoid.' and ruleconditionsid ='. $idsequencingrule);
$conditionOK = true;
//Truong hop 1: conditioncombination = all
if ($sequencingrule->conditioncombination =='all'){
//fwrite($ft,"\n >>>>> Kiem tra Sequencing :conditioncombination la all \n");
$conditionOK = true;
//fwrite($ft,"\n >>>>> Usertrack->status la: ".$usertrack->status);
foreach ($ruleconditions as $rulecondition){
//Neu co mot dieu kien khong thoa man thi se khong dung
if (($rulecondition->condition != $usertrack->status)&&($rulecondition->condition != $usertrack->success_status)&&($rulecondition->condition != $usertrack->satisfied_status)){
$conditionOK = false;
}
}
}
//Truong hop 2: conditioncombination = any
if ($sequencingrule->conditioncombination =='any'){
$conditionOK = false;
foreach ($ruleconditions as $rulecondition){
//Neu co mot dieu kien thoa man thi se dung
if (($rulecondition->condition == $usertrack->status) || ($rulecondition->condition == $usertrack->success_status) || ($rulecondition->condition == $usertrack->satisfied_status) ){
$conditionOK = true;
}
}
}
//fwrite($ft,"\n >>>>> Gia tri conditionOK sau khi kiem tra dk la: ".$conditionOK);
//Neu dieu kien van dung thi thuc hien Action
if ($conditionOK == true){
//fwrite($ft,"\n >>>>> Dieu kien Sequencing OK..Thuc hien Action \n");
//Truong hop 1: ExitAction la Exit
if ($sequencingrule->exitconditionruleaction=='exit')
{
//fwrite($ft,"\n >>>>> Xu ly Sequencing thanh cong -- Thuc hien su kien exit \n");
echo "<script language='JavaScript'>";
echo "alert('Thuc hien sequen. Do Trang thai ".$scoparent->identifier." la hoan thanh. Tien hanh EXIT');";
echo "</script>";
$sequencingResult->rule = 'exit';
$sequencingResult->action = 'exit';
}
if ($sequencingrule->preconditionruleaction=='disabled')
{
//fwrite($ft,"\n >>>>> Xu ly Sequencing thanh cong -- Thuc hien su kien disable \n");
echo "<script language='JavaScript'>";
echo "alert('Thuc hien sequen. Do Trang thai ".$scoparent->identifier." la hoan thanh. Tien hanh Disable');";
echo "</script>";
$sequencingResult->rule = 'pre';
$sequencingResult->action = 'disable';
}
}
}
}
}
return $sequencingResult;
}
function get_sco_after_exit($scoid,$scormid){
$scochild = get_record("scorm_scoes","id",$scoid);
$scoparent = get_record("scorm_scoes","scorm",$scormid,"identifier",$scochild->parent);
$exitscoid = $scoid++;
$exitscochild = get_record("scorm_scoes","id",$exitscoid,"scorm",$scormid);
if (empty($exitscochild)){
//Da ra ngoai vung scoid. Hay day chinh la sco cuoi cung
return 0;
}
else{
$exitscoparent = get_record("scorm_scoes","scorm",$scormid,"identifier",$exitscochild->parent);
//Neu chua ra khoi activity do thi tiep tuc
while ($exitscoparent->id == $scoparent->id){
$exitscoid++;
$exitscochild = get_record("scorm_scoes","id",$exitscoid);
if (empty($exitscochild)){
//Da ra ngoai vung scoid. Hay day chinh la sco cuoi cung
return 0;
}
else{
$exitscoparent = get_record("scorm_scoes","scorm",$scormid,"identifier",$exitscochild->parent);
}
}
}
return $exitscoid;
}
?>

View File

@ -1,83 +1,93 @@
.structlist {
list-style-type: none;
white-space: nowrap;
font-size: small;
}
.orgtitle {
font-weight: bold;
font-size: small;
}
.mod-scorm .top {
vertical-align: top;
}
.mod-scorm .left {
text-align: left;
}
.mod-scorm .center {
text-align: center;
}
.mod-scorm .right {
text-align: right;
}
.mod-scorm .scoframe {
}
#mod-scorm-player #scormpage {
position: relative;
width: 100%;
}
#mod-scorm-player #tocbox {
position: absolute;
left: 0px;
top: 0px;
width: 19%;
}
#mod-scorm-player #tochead {
text-align: center;
font-weight: bold;
}
#mod-scorm-player #scormbox {
position: absolute;
right: 0px;
top: 0px;
}
#mod-scorm-player .toc {
width: 80%;
margin-left: 20%;
}
#mod-scorm-player .no-toc {
width: 100%;
}
#mod-scorm-player #scormobject {
/* border: 1px solid black; */
}
#mod-scorm-player #scormtop {
position: relative;
width: 100%;
height: 30px;
}
#mod-scorm-player #scormbrowse {
position: absolute;
left: 5px;
top: 0px;
}
#mod-scorm-player #scormnav {
position: absolute;
right: 5px;
top: 0px;
}
#mod-scorm-player .structurelist {
list-style-type: none;
text-indent:-4ex;
font-size: small;
}
#mod-scorm-view .structurehead {
font-weight: bold;
text-align: center;
}
#mod-scorm-view .structurelist {
list-style-type: none;
white-space: nowrap;
}
.structlist {
list-style-type: none;
white-space: nowrap;
font-size: small;
}
.orgtitle {
font-weight: bold;
font-size: small;
}
.mod-scorm .top {
vertical-align: top;
}
.mod-scorm .left {
text-align: left;
}
.mod-scorm .center {
text-align: center;
}
.mod-scorm .right {
text-align: right;
}
.mod-scorm .scoframe {
}
#mod-scorm-player #scormpage {
position: relative;
width: 100%;
}
#mod-scorm-player #tocbox {
position: absolute;
left: 0px;
top: 0px;
width: 19%;
}
#mod-scorm-player #tochead {
text-align: center;
font-weight: bold;
}
#mod-scorm-player #scormbox {
position: absolute;
right: 0px;
top: 0px;
}
#mod-scorm-player .toc {
width: 80%;
margin-left: 20%;
}
#mod-scorm-player .no-toc {
width: 100%;
}
#mod-scorm-player #scormobject {
/* border: 1px solid black; */
}
#mod-scorm-player #scormtop {
position: relative;
width: 100%;
height: 30px;
}
#mod-scorm-player #scormbrowse {
position: absolute;
left: 5px;
top: 0px;
}
#mod-scorm-player #scormnav {
position: absolute;
right: 5px;
top: 0px;
}
#mod-scorm-player .structurelist {
list-style-type: none;
text-indent:-4ex;
font-size: small;
}
#mod-scorm-view .structurehead {
font-weight: bold;
text-align: center;
}
#mod-scorm-view .structurelist {
list-style-type: none;
white-space: nowrap;
}
.scormtextbox {
border-style: solid;
border-width: 1;
padding-left: 5;
}
.scormtableheader{
font-face: Arial;
color: #000066;
font-weight: bold;
}

36
mod/scorm/suspend.php Executable file
View File

@ -0,0 +1,36 @@
<?php
require_once('../../config.php');
require_once('locallib.php');
require_once('sequencinglib.php');
// $f = "D:\\test.txt";
// @$ft = fopen($f,"a");
// fwrite($ft,"Bat dau ghi tron datamodel.php \n");
$id = required_param('id', PARAM_INT); // course ID
$scormid = required_param('scorm', PARAM_INT); // scorm ID
$scoid = required_param('sco', PARAM_INT); // suspend sco ID
$userid = required_param('userid', PARAM_INT); // user ID
$attempt = scorm_get_last_attempt($scormid,$userid);
$statistic = get_record('scorm_statistic',"scormid",$scormid,"userid",$userid);
$statisticInput->accesstime = $statistic->accesstime;
$statisticInput->durationtime = $statistic->durationtime + time()- $statistic->accesstime;
$statisticInput->status = 'suspend';
$statisticInput->attemptnumber = $attempt;
$statisticInput->scormid = $statistic->scormid;
$statisticInput->userid = $statistic->userid;
$statisticid = scorm_insert_statistic($statisticInput);
$result = scorm_insert_trackmodel($userid, $scormid, $scoid,$attempt);
if ($result) {
echo "<script language='Javascript' type='text/javascript'>";
echo "location.href='".$CFG->wwwroot." /course/view.php?id=".$id."';";
echo "</script>";
}
else {
echo "Suspend failed";
}
?>

10
mod/scorm/timePassReport.htm Executable file
View File

@ -0,0 +1,10 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
Thời gian làm bài đã hết... Mời bạn chọn bài khác.
</body>
</html>

View File

@ -1,121 +1,122 @@
<?php // $Id$
require_once("../../config.php");
require_once('locallib.php');
$courseid = required_param('id', PARAM_INT); // Course Module ID, or
$reference = required_param('reference', PARAM_PATH); // Package path
$scormid = optional_param('instance', '', PARAM_INT); // scorm ID
require_login($courseid, false);
if (confirm_sesskey() && !empty($courseid)) {
$launch = 0;
$validation = new stdClass();
if (empty($reference)) {
$launch = -1;
$validation->result = "packagefile";
}
if (!empty($scormid)) {
//
// SCORM Update
//
if (is_file($CFG->dataroot.'/'.$courseid.'/'.$reference)) {
$fp = fopen($CFG->dataroot.'/'.$courseid.'/'.$reference,"r");
$fstat = fstat($fp);
fclose($fp);
if ($scorm = get_record("scorm","id",$scormid)) {
$launch = $scorm->launch;
if ((($scorm->timemodified < $fstat["mtime"]) && ($scorm->reference == $reference)) || ($scorm->reference != $reference)) {
// This is a new package
$launch = 0;
} else {
// Old package already validated
$validation->result = 'found';
if (strpos($scorm->version,'AICC') !== false) {
$validation->pkgtype = 'AICC';
} else {
$validation->pkgtype = 'SCORM';
}
}
} else {
$validation->result = 'badinstance';
$launch = -1;
}
} else {
$validation->result = 'badreference';
$launch = -1;
}
}
//$launch = 0;
if ($launch == 0) {
//
// Package must be validated
//
$ext = strtolower(substr(basename($reference),strrpos(basename($reference),'.')));
switch ($ext) {
case '.pif':
case '.zip':
// Create a temporary directory to unzip package and validate package
$tempdir = '';
$scormdir = '';
if ($scormdir = make_upload_directory("$courseid/$CFG->moddata/scorm")) {
if ($tempdir = scorm_datadir($scormdir)) {
copy ("$CFG->dataroot/$courseid/$reference", $tempdir."/".basename($reference));
unzip_file($tempdir."/".basename($reference), $tempdir, false);
unlink ($tempdir."/".basename($reference));
$validation = scorm_validate($tempdir);
} else {
$validation->result = "packagedir";
}
} else {
$validation->result = "datadir";
}
break;
case '.xml':
if (basename($reference) == 'imsmanifest.xml') {
$validation = scorm_validate("$CFG->dataroot/$courseid/".dirname($reference));
} else {
$validation->result = "manifestfile";
}
break;
default:
$validation->result = "packagefile";
break;
}
if (($validation->result != "regular") && ($validation->result != "found")) {
$validation->result = get_string($validation->result,'scorm');
if (is_dir($tempdir)) {
// Delete files and temporary directory
scorm_delete_files($tempdir);
}
} else {
if ($ext == '.xml') {
$datadir = dirname($reference);
} else {
$datadir = substr($tempdir,strlen($scormdir));
}
}
}
//
// Print validation result
//
echo 'result=' . $validation->result . "\n";
echo 'launch=' . $launch . "\n";
if (isset($validation->pkgtype)) {
echo 'pkgtype=' . $validation->pkgtype . "\n";
}
if (isset($datadir)) {
echo 'datadir=' . $datadir . "\n";
}
if (isset($validation->errors[1])) {
echo 'errorlogs='."\n";
foreach($validation->errors as $error) {
echo get_string($error->type,"scorm",$error->data) . "\n";
}
}
} else {
echo 'result=' . get_string('badrequest','scorm') . "\n";
}
?>
<?php // $Id$
require_once("../../config.php");
require_once('locallib.php');
require_once('sequencinglib.php');
$courseid = required_param('id', PARAM_INT); // Course Module ID, or
$reference = required_param('reference', PARAM_PATH); // Package path
$scormid = optional_param('instance', '', PARAM_INT); // scorm ID
require_login($courseid, false);
if (confirm_sesskey() && !empty($courseid)) {
$launch = 0;
$validation = new stdClass();
if (empty($reference)) {
$launch = -1;
$validation->result = "packagefile";
}
if (!empty($scormid)) {
//
// SCORM Update
//
if (is_file($CFG->dataroot.'/'.$courseid.'/'.$reference)) {
$fp = fopen($CFG->dataroot.'/'.$courseid.'/'.$reference,"r");
$fstat = fstat($fp);
fclose($fp);
if ($scorm = get_record("scorm","id",$scormid)) {
$launch = $scorm->launch;
if ((($scorm->timemodified < $fstat["mtime"]) && ($scorm->reference == $reference)) || ($scorm->reference != $reference)) {
// This is a new package
$launch = 0;
} else {
// Old package already validated
$validation->result = 'found';
if (strpos($scorm->version,'AICC') !== false) {
$validation->pkgtype = 'AICC';
} else {
$validation->pkgtype = 'SCORM';
}
}
} else {
$validation->result = 'badinstance';
$launch = -1;
}
} else {
$validation->result = 'badreference';
$launch = -1;
}
}
//$launch = 0;
if ($launch == 0) {
//
// Package must be validated
//
$ext = strtolower(substr(basename($reference),strrpos(basename($reference),'.')));
switch ($ext) {
case '.pif':
case '.zip':
// Create a temporary directory to unzip package and validate package
$tempdir = '';
$scormdir = '';
if ($scormdir = make_upload_directory("$courseid/$CFG->moddata/scorm")) {
if ($tempdir = scorm_datadir($scormdir)) {
copy ("$CFG->dataroot/$courseid/$reference", $tempdir."/".basename($reference));
unzip_file($tempdir."/".basename($reference), $tempdir, false);
unlink ($tempdir."/".basename($reference));
$validation = scorm_validate($tempdir);
} else {
$validation->result = "packagedir";
}
} else {
$validation->result = "datadir";
}
break;
case '.xml':
if (basename($reference) == 'imsmanifest.xml') {
$validation = scorm_validate("$CFG->dataroot/$courseid/".dirname($reference));
} else {
$validation->result = "manifestfile";
}
break;
default:
$validation->result = "packagefile";
break;
}
if (($validation->result != "regular") && ($validation->result != "found")) {
$validation->result = get_string($validation->result,'scorm');
if (is_dir($tempdir)) {
// Delete files and temporary directory
scorm_delete_files($tempdir);
}
} else {
if ($ext == '.xml') {
$datadir = dirname($reference);
} else {
$datadir = substr($tempdir,strlen($scormdir));
}
}
}
//
// Print validation result
//
echo 'result=' . $validation->result . "\n";
echo 'launch=' . $launch . "\n";
if (isset($validation->pkgtype)) {
echo 'pkgtype=' . $validation->pkgtype . "\n";
}
if (isset($datadir)) {
echo 'datadir=' . $datadir . "\n";
}
if (isset($validation->errors[1])) {
echo 'errorlogs='."\n";
foreach($validation->errors as $error) {
echo get_string($error->type,"scorm",$error->data) . "\n";
}
}
} else {
echo 'result=' . get_string('badrequest','scorm') . "\n";
}
?>

View File

@ -1,12 +1,12 @@
<?php // $Id$
/////////////////////////////////////////////////////////////////////////////////
/// Code fragment to define the version of scorm
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
$module->version = 2006021401; // The (date) version of this module
$module->requires = 2005060200; // The version of Moodle that is required
$module->cron = 0; // How often should cron check this module (seconds)?
?>
<?php // $Id$
/////////////////////////////////////////////////////////////////////////////////
/// Code fragment to define the version of scorm
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
$module->version = 2006050502; // The (date) version of this module
$module->requires = 2005060200; // The version of Moodle that is required
$module->cron = 0; // How often should cron check this module (seconds)?
?>

View File

@ -1,91 +1,101 @@
<?php // $Id$
/// This page prints a particular instance of scorm
/// (Replace scorm with the name of your module)
require_once("../../config.php");
require_once('locallib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
//$organization = optional_param('organization', '', PARAM_INT); // organization ID
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
} else {
error('A required parameter is missing');
}
require_login($course->id, false, $cm);
if (isset($SESSION->scorm_scoid)) {
unset($SESSION->scorm_scoid);
}
$strscorms = get_string("modulenameplural", "scorm");
$strscorm = get_string("modulename", "scorm");
if ($course->category != 0) {
$navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
if ($scorms = get_all_instances_in_course('scorm', $course)) {
// The module SCORM activity with the least id is the course
$firstscorm = current($scorms);
if (!(($course->format == 'scorm') && ($firstscorm->id == $scorm->id))) {
$navigation .= "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
}
}
} else {
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
}
$pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id");
//
// Print the page header
//
if (!$cm->visible and !isteacher($course->id)) {
print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), '', '', true,
update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
notice(get_string('activityiscurrentlyhidden'));
} else {
print_header($pagetitle, "$course->fullname",
"$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>",
'', '', true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
if (isteacher($course->id)) {
$trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
if ($trackedusers->c > 0) {
echo "<div class=\"reportlink\"><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\">".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
} else {
echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';
}
}
// Print the main part of the page
print_heading(format_string($scorm->name));
print_simple_box(format_text($scorm->summary), 'center', '70%', '', 5, 'generalbox', 'intro');
scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
print_footer($course);
}
?>
<?php // $Id$
/// This page prints a particular instance of scorm
/// (Replace scorm with the name of your module)
require_once("../../config.php");
require_once('locallib.php');
require_once('sequencinglib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
//$organization = optional_param('organization', '', PARAM_INT); // organization ID
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
} else {
error('A required parameter is missing');
}
require_login($course->id, false, $cm);
if (isset($SESSION->scorm_scoid)) {
unset($SESSION->scorm_scoid);
}
$strscorms = get_string("modulenameplural", "scorm");
$strscorm = get_string("modulename", "scorm");
if ($course->category != 0) {
$navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
if ($scorms = get_all_instances_in_course('scorm', $course)) {
// The module SCORM activity with the least id is the course
$firstscorm = current($scorms);
if (!(($course->format == 'scorm') && ($firstscorm->id == $scorm->id))) {
$navigation .= "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
}
}
} else {
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
}
$pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id");
//
// Print the page header
//
if (!$cm->visible and !isteacher($course->id)) {
print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), '', '', true,
update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
notice(get_string('activityiscurrentlyhidden'));
} else {
print_header($pagetitle, "$course->fullname",
"$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>",
'', '', true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
if (isteacher($course->id)) {
//Phan thiet lap he so diem
$examNumber = get_record_select('scorm_scoes', 'scorm ='.($scorm->id).' and minnormalizedmeasure > -1','count(id) as examCount');
//fwrite($ft,"\n So bai kiem tra la ".($examNumber->examCount));
if ($examNumber->examCount > 0){
echo "<div class=\"reportlink\"><img src='pix\SuaHeSoDiem.png' /><a target=\"{$CFG->framename}\" href=\"coefficientSetting.php?id=$cm->id\"> ".get_string('scorecoefficientsetting','scorm',$examNumber->examCount).'</a></div>';
}
//-----------------------
$trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
if ($trackedusers->c > 0) {
echo "<div class=\"reportlink\"><img src='pix\ThongKe.png' /><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\"> ".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
} else {
echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';
}
}
$USER->setAttempt = 'notset';
// Print the main part of the page
print_heading(format_string($scorm->name));
print_simple_box(format_text($scorm->summary), 'center', '70%', '', 5, 'generalbox', 'intro');
scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
print_footer($course);
}
?>