MDL-15115 scorm dml covnersion
This commit is contained in:
+5
-5
@@ -31,14 +31,14 @@
|
||||
}
|
||||
|
||||
if ($sco = scorm_get_sco($scoid, SCO_ONLY)) {
|
||||
if (!$scorm = get_record('scorm','id',$sco->scorm)) {
|
||||
if (!$scorm = $DB->get_record('scorm', array('id'=>$sco->scorm))) {
|
||||
print_error('Invalid script call');
|
||||
}
|
||||
} else {
|
||||
print_error('Invalid script call');
|
||||
}
|
||||
|
||||
if ($scorm = get_record('scorm','id',$sco->scorm)) {
|
||||
if ($scorm = $DB->get_record('scorm', array('id'=>$sco->scorm))) {
|
||||
switch ($command) {
|
||||
case 'getparam':
|
||||
if ($status == 'Not Initialized') {
|
||||
@@ -312,12 +312,12 @@
|
||||
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'")) {
|
||||
if ($track = $DB->get_record('scorm_scoes_track', array('userid'=>$USER->id,'scormid'=>$scorm->id, 'scoid'=>$sco->id, '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();
|
||||
update_record('scorm_scoes_track',$track);
|
||||
$DB->update_record('scorm_scoes_track',$track);
|
||||
$id = $track->id;
|
||||
} else {
|
||||
$track = new object();
|
||||
@@ -327,7 +327,7 @@
|
||||
$track->element = 'cmi.core.total_time';
|
||||
$track->value = $SESSION->scorm_session_time;
|
||||
$track->timemodified = time();
|
||||
$id = insert_record('scorm_scoes_track',$track);
|
||||
$id = $DB->insert_record('scorm_scoes_track',$track);
|
||||
}
|
||||
scorm_update_grades($scorm, $USER->id);
|
||||
}
|
||||
|
||||
+6
-6
@@ -13,17 +13,17 @@
|
||||
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
|
||||
print_error("Course Module ID was incorrect");
|
||||
}
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error("Course is misconfigured");
|
||||
}
|
||||
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
|
||||
if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
|
||||
print_error("Course module is incorrect");
|
||||
}
|
||||
} else if (!empty($a)) {
|
||||
if (! $scorm = get_record("scorm", "id", $a)) {
|
||||
if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
|
||||
print_error("Course module is incorrect");
|
||||
}
|
||||
if (! $course = get_record("course", "id", $scorm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
|
||||
print_error("Course is misconfigured");
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
|
||||
@@ -46,8 +46,8 @@
|
||||
$userdata->status = '';
|
||||
$userdata->score_raw = '';
|
||||
}
|
||||
$userdata->student_id = addslashes($USER->username);
|
||||
$userdata->student_name = addslashes($USER->lastname .', '. $USER->firstname);
|
||||
$userdata->student_id = $USER->username;
|
||||
$userdata->student_name = $USER->lastname .', '. $USER->firstname;
|
||||
$userdata->mode = 'normal';
|
||||
if (isset($mode)) {
|
||||
$userdata->mode = $mode;
|
||||
|
||||
+35
-47
@@ -27,13 +27,12 @@
|
||||
//-----------------------------------------------------------
|
||||
|
||||
function scorm_backup_mods($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
//Iterate over scorm table
|
||||
$scorms = get_records ('scorm','course',$preferences->backup_course,'id');
|
||||
$scorms = $DB->get_records ('scorm', array('course'=>$preferences->backup_course),'id');
|
||||
if ($scorms) {
|
||||
foreach ($scorms as $scorm) {
|
||||
if (backup_mod_selected($preferences,'scorm',$scorm->id)) {
|
||||
@@ -45,10 +44,12 @@
|
||||
}
|
||||
|
||||
function scorm_backup_one_mod($bf,$preferences,$scorm) {
|
||||
global $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
if (is_numeric($scorm)) {
|
||||
$scorm = get_record('scorm','id',$scorm);
|
||||
$scorm = $DB->get_record('scorm', array('id'=>$scorm));
|
||||
}
|
||||
|
||||
//Start mod
|
||||
@@ -93,12 +94,11 @@
|
||||
|
||||
//Backup scorm_scoes contents (executed from scorm_backup_mods)
|
||||
function backup_scorm_scoes ($bf,$preferences,$scorm) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
$scorm_scoes = get_records('scorm_scoes','scorm',$scorm,'id');
|
||||
$scorm_scoes = $DB->get_records('scorm_scoes', array('scorm'=>$scorm),'id');
|
||||
//If there is scoes
|
||||
if ($scorm_scoes) {
|
||||
//Write start tag
|
||||
@@ -131,12 +131,11 @@
|
||||
|
||||
//Backup scorm_scoes_data contents (executed from scorm_backup_scorm_scoes)
|
||||
function backup_scorm_scoes_data ($bf,$preferences,$sco) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
$scorm_sco_datas = get_records('scorm_scoes_data','scoid',$sco,'id');
|
||||
$scorm_sco_datas = $DB->get_records('scorm_scoes_data', array('scoid'=>$sco),'id');
|
||||
//If there is data
|
||||
if ($scorm_sco_datas) {
|
||||
//Write start tag
|
||||
@@ -161,12 +160,11 @@
|
||||
|
||||
//Backup scorm_scoes_track contents (executed from scorm_backup_mods)
|
||||
function backup_scorm_scoes_track ($bf,$preferences,$scorm) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
$scorm_scoes_track = get_records('scorm_scoes_track','scormid',$scorm,'id');
|
||||
$scorm_scoes_track = $DB->get_records('scorm_scoes_track', array('scormid'=>$scorm),'id');
|
||||
//If there is track
|
||||
if ($scorm_scoes_track) {
|
||||
//Write start tag
|
||||
@@ -194,12 +192,11 @@
|
||||
|
||||
|
||||
function backup_scorm_seq_ruleconds ($bf,$preferences,$sco) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
$scorm_seq_ruleconditions = get_records('scorm_seq_ruleconds','scoid',$sco,'id');
|
||||
$scorm_seq_ruleconditions = $DB->get_records('scorm_seq_ruleconds', array('scoid'=>$sco),'id');
|
||||
//If there is rulecondition
|
||||
if ($scorm_seq_ruleconditions) {
|
||||
//Write start tag
|
||||
@@ -227,12 +224,11 @@
|
||||
|
||||
|
||||
function backup_scorm_seq_rulecond ($bf,$preferences,$ruleconditions) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
$scorm_seq_ruleconditions = get_records('scorm_seq_rulecond','ruleconditionsid',$ruleconditions,'id');
|
||||
$scorm_seq_ruleconditions = $DB->get_records('scorm_seq_rulecond', array('ruleconditionsid'=>$ruleconditions),'id');
|
||||
//If there is rulecondition
|
||||
if ($scorm_seq_ruleconditions) {
|
||||
//Write start tag
|
||||
@@ -259,12 +255,11 @@
|
||||
}
|
||||
|
||||
function backup_scorm_seq_rolluprule ($bf,$preferences,$sco) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
$scorm_seq_rolluprules = get_records('scorm_seq_rolluprule','scoid',$sco,'id');
|
||||
$scorm_seq_rolluprules = $DB->get_records('scorm_seq_rolluprule', array('scoid'=>$sco),'id');
|
||||
//If there is rulecondition
|
||||
if ($scorm_seq_rolluprules) {
|
||||
//Write start tag
|
||||
@@ -293,12 +288,11 @@
|
||||
|
||||
|
||||
function backup_scorm_seq_rolluprulecond ($bf,$preferences,$rolluprule) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
$scorm_seq_rollupruleconditions = get_records('scorm_seq_rolluprulecond','rollupruleid',$rolluprule,'id');
|
||||
$scorm_seq_rollupruleconditions = $DB->get_records('scorm_seq_rolluprulecond', array('rollupruleid'=>$rolluprule), 'id');
|
||||
//If there is rulecondition
|
||||
if ($scorm_seq_rollupruleconditions) {
|
||||
//Write start tag
|
||||
@@ -325,12 +319,11 @@
|
||||
|
||||
|
||||
function backup_scorm_seq_objective ($bf,$preferences,$sco) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
$scorm_seq_objectives = get_records('scorm_seq_objective','scoid',$sco,'id');
|
||||
$scorm_seq_objectives = $DB->get_records('scorm_seq_objective', array('scoid'=>$sco),'id');
|
||||
//If there is rulecondition
|
||||
if ($scorm_seq_objectives) {
|
||||
//Write start tag
|
||||
@@ -358,12 +351,11 @@ function backup_scorm_seq_objective ($bf,$preferences,$sco) {
|
||||
}
|
||||
|
||||
function backup_scorm_seq_mapinfo ($bf,$preferences,$objectives) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
$scorm_seq_objectives = get_records('scorm_seq_mapinfo','objectiveid',$objectives,'id');
|
||||
$scorm_seq_objectives = $DB->get_records('scorm_seq_mapinfo', array('objectiveid'=>$objectives),'id');
|
||||
//If there is rulecondition
|
||||
if ($scorm_seq_objectives) {
|
||||
//Write start tag
|
||||
@@ -508,33 +500,29 @@ function backup_scorm_seq_objective ($bf,$preferences,$sco) {
|
||||
|
||||
//Returns an array of scorms id
|
||||
function scorm_ids ($course) {
|
||||
global $CFG, $DB;
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT a.id, a.course
|
||||
FROM {$CFG->prefix}scorm a
|
||||
WHERE a.course = '$course'");
|
||||
return $DB->get_records_sql ("SELECT a.id, a.course
|
||||
FROM {scorm} a
|
||||
WHERE a.course = ?", array($course));
|
||||
}
|
||||
|
||||
//Returns an array of scorm_scoes id
|
||||
function scorm_scoes_track_ids_by_course ($course) {
|
||||
global $CFG, $DB;
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT s.id , s.scormid
|
||||
FROM {$CFG->prefix}scorm_scoes_track s,
|
||||
{$CFG->prefix}scorm a
|
||||
WHERE a.course = '$course' AND
|
||||
s.scormid = a.id");
|
||||
return $DB->get_records_sql ("SELECT s.id , s.scormid
|
||||
FROM {scorm_scoes_track} s, {scorm} a
|
||||
WHERE a.course = ? AND
|
||||
s.scormid = a.id", array($course));
|
||||
}
|
||||
|
||||
//Returns an array of scorm_scoes id
|
||||
function scorm_scoes_track_ids_by_instance ($instanceid) {
|
||||
global $CFG, $DB;
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT s.id , s.scormid
|
||||
FROM {$CFG->prefix}scorm_scoes_track s
|
||||
WHERE s.scormid = $instanceid");
|
||||
return $DB->get_records_sql ("SELECT s.id , s.scormid
|
||||
FROM {scorm_scoes_track} s
|
||||
WHERE s.scormid = ?", array($instanceid));
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -10,20 +10,20 @@
|
||||
|
||||
|
||||
if (!empty($id)) {
|
||||
if (! $cm = get_record("course_modules", "id", $id)) {
|
||||
if (! $cm = $DB->get_record("course_modules", array("id"=>$id))) {
|
||||
print_error("Course Module ID was incorrect");
|
||||
}
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error("Course is misconfigured");
|
||||
}
|
||||
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
|
||||
if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
|
||||
print_error("Course module is incorrect");
|
||||
}
|
||||
} else if (!empty($a)) {
|
||||
if (! $scorm = get_record("scorm", "id", $a)) {
|
||||
if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
|
||||
print_error("Course module is incorrect");
|
||||
}
|
||||
if (! $course = get_record("course", "id", $scorm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
|
||||
print_error("Course is misconfigured");
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
|
||||
|
||||
@@ -91,6 +91,8 @@ function scorm_forge_cols_regexp($columns,$remodule='(".*")?,') {
|
||||
}
|
||||
|
||||
function scorm_parse_aicc($pkgdir,$scormid) {
|
||||
global $DB;
|
||||
|
||||
$version = 'AICC';
|
||||
$ids = array();
|
||||
$courses = array();
|
||||
@@ -199,7 +201,7 @@ function scorm_parse_aicc($pkgdir,$scormid) {
|
||||
}
|
||||
//print_r($courses);
|
||||
|
||||
$oldscoes = get_records('scorm_scoes','scorm',$scormid);
|
||||
$oldscoes = $DB->get_records('scorm_scoes', array('scorm'=>$scormid));
|
||||
|
||||
$launch = 0;
|
||||
if (isset($courses)) {
|
||||
@@ -214,11 +216,12 @@ function scorm_parse_aicc($pkgdir,$scormid) {
|
||||
$sco->scormtype = '';
|
||||
|
||||
//print_r($sco);
|
||||
if (get_record('scorm_scoes','scorm',$scormid,'identifier',$sco->identifier)) {
|
||||
$id = update_record('scorm_scoes',$sco);
|
||||
if ($ss = $DB->get_record('scorm_scoes', array('scorm'=>$scormid,'identifier'=>$sco->identifier))) {
|
||||
$id = $ss->id;
|
||||
$DB->update_record('scorm_scoes',$sco);
|
||||
unset($oldscoes[$id]);
|
||||
} else {
|
||||
$id = insert_record('scorm_scoes',$sco);
|
||||
$id = $DB->insert_record('scorm_scoes',$sco);
|
||||
}
|
||||
|
||||
if ($launch == 0) {
|
||||
@@ -245,11 +248,11 @@ function scorm_parse_aicc($pkgdir,$scormid) {
|
||||
$id = null;
|
||||
if ($oldscoid = scorm_array_search('identifier',$sco->identifier,$oldscoes)) {
|
||||
$sco->id = $oldscoid;
|
||||
$id = update_record('scorm_scoes',$sco);
|
||||
delete_records('scorm_scoes_data','scoid',$oldscoid);
|
||||
$id = $DB->update_record('scorm_scoes',$sco);
|
||||
$DB->delete_records('scorm_scoes_data', array('scoid'=>$oldscoid));
|
||||
unset($oldscoes[$oldscoid]);
|
||||
} else {
|
||||
$id = insert_record('scorm_scoes',$sco);
|
||||
$id = $DB->insert_record('scorm_scoes',$sco);
|
||||
}
|
||||
if (!empty($id)) {
|
||||
unset($scodata);
|
||||
@@ -257,27 +260,27 @@ function scorm_parse_aicc($pkgdir,$scormid) {
|
||||
if (isset($element->web_launch)) {
|
||||
$scodata->name = 'parameters';
|
||||
$scodata->value = $element->web_launch;
|
||||
$dataid = insert_record('scorm_scoes_data',$scodata);
|
||||
$dataid = $DB->insert_record('scorm_scoes_data',$scodata);
|
||||
}
|
||||
if (isset($element->prerequisites)) {
|
||||
$scodata->name = 'prerequisites';
|
||||
$scodata->value = $element->prerequisites;
|
||||
$dataid = insert_record('scorm_scoes_data',$scodata);
|
||||
$dataid = $DB->insert_record('scorm_scoes_data',$scodata);
|
||||
}
|
||||
if (isset($element->max_time_allowed)) {
|
||||
$scodata->name = 'max_time_allowed';
|
||||
$scodata->value = $element->max_time_allowed;
|
||||
$dataid = insert_record('scorm_scoes_data',$scodata);
|
||||
$dataid = $DB->insert_record('scorm_scoes_data',$scodata);
|
||||
}
|
||||
if (isset($element->time_limit_action)) {
|
||||
$scodata->name = 'time_limit_action';
|
||||
$scodata->value = $element->time_limit_action;
|
||||
$dataid = insert_record('scorm_scoes_data',$scodata);
|
||||
$dataid = $DB->insert_record('scorm_scoes_data',$scodata);
|
||||
}
|
||||
if (isset($element->mastery_score)) {
|
||||
$scodata->name = 'mastery_score';
|
||||
$scodata->value = $element->mastery_score;
|
||||
$dataid = insert_record('scorm_scoes_data',$scodata);
|
||||
$dataid = $DB->insert_record('scorm_scoes_data',$scodata);
|
||||
}
|
||||
}
|
||||
if ($launch==0) {
|
||||
@@ -290,16 +293,16 @@ function scorm_parse_aicc($pkgdir,$scormid) {
|
||||
}
|
||||
if (!empty($oldscoes)) {
|
||||
foreach($oldscoes as $oldsco) {
|
||||
delete_records('scorm_scoes','id',$oldsco->id);
|
||||
delete_records('scorm_scoes_track','scoid',$oldsco->id);
|
||||
$DB->delete_records('scorm_scoes', array('id'=>$oldsco->id));
|
||||
$DB->delete_records('scorm_scoes_track', array('scoid'=>$oldsco->id));
|
||||
}
|
||||
}
|
||||
set_field('scorm','version','AICC','id',$scormid);
|
||||
$DB->set_field('scorm','version','AICC', array('id'=>$scormid));
|
||||
return $launch;
|
||||
}
|
||||
|
||||
function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$strexpand = get_string('expcoll','scorm');
|
||||
$modestr = '';
|
||||
@@ -317,13 +320,13 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
|
||||
//
|
||||
// Get the current organization infos
|
||||
//
|
||||
$organizationsql = '';
|
||||
$conditions = array();
|
||||
if (!empty($currentorg)) {
|
||||
if (($organizationtitle = get_field('scorm_scoes','title','scorm',$scorm->id,'identifier',$currentorg)) != '') {
|
||||
if (($organizationtitle = $DB->get_field('scorm_scoes','title', array('scorm'=>$scorm->id,'identifier'=>$currentorg))) != '') {
|
||||
$result->toc .= "\t<li>$organizationtitle</li>\n";
|
||||
$tocmenus[] = $organizationtitle;
|
||||
}
|
||||
$organizationsql = "AND organization='$currentorg'";
|
||||
$conditions['organization'] = $currentorg;
|
||||
}
|
||||
//
|
||||
// If not specified retrieve the last attempt number
|
||||
@@ -332,7 +335,8 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
|
||||
$attempt = scorm_get_last_attempt($scorm->id, $user->id);
|
||||
}
|
||||
$result->attemptleft = $scorm->maxattempt - $attempt;
|
||||
if ($scoes = get_records_select('scorm_scoes',"scorm='$scorm->id' $organizationsql order by id ASC")){
|
||||
$conditions['scorm'] = $scorm->id;
|
||||
if ($scoes = $DB->get_records('scorm_scoes', $conditions, "id ASC")){
|
||||
// drop keys so that we can access array sequentially
|
||||
$scoes = array_values($scoes);
|
||||
//
|
||||
@@ -359,7 +363,7 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
|
||||
|
||||
foreach ($scoes as $pos=>$sco) {
|
||||
$isvisible = false;
|
||||
$sco->title = stripslashes($sco->title);
|
||||
$sco->title = $sco->title;
|
||||
if ($optionaldatas = scorm_get_sco($sco->id, SCO_DATA)) {
|
||||
if (!isset($optionaldatas->isvisible) || (isset($optionaldatas->isvisible) && ($optionaldatas->isvisible == 'true'))) {
|
||||
$isvisible = true;
|
||||
|
||||
@@ -155,7 +155,7 @@ function scorm_eval_prerequisites($prerequisites,$usertracks) {
|
||||
}
|
||||
|
||||
function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$strexpand = get_string('expcoll','scorm');
|
||||
$modestr = '';
|
||||
@@ -173,13 +173,13 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
|
||||
//
|
||||
// Get the current organization infos
|
||||
//
|
||||
$organizationsql = '';
|
||||
$conditions = array();;
|
||||
if (!empty($currentorg)) {
|
||||
if (($organizationtitle = get_field('scorm_scoes','title','scorm',$scorm->id,'identifier',$currentorg)) != '') {
|
||||
if (($organizationtitle = $DB->get_field('scorm_scoes','title', array('scorm'=>$scorm->id,'identifier'=>$currentorg))) != '') {
|
||||
$result->toc .= "\t<li>$organizationtitle</li>\n";
|
||||
$tocmenus[] = $organizationtitle;
|
||||
}
|
||||
$organizationsql = "AND organization='$currentorg'";
|
||||
$conditions['organization'] = $currentorg;
|
||||
}
|
||||
//
|
||||
// If not specified retrieve the last attempt number
|
||||
@@ -188,7 +188,8 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
|
||||
$attempt = scorm_get_last_attempt($scorm->id, $user->id);
|
||||
}
|
||||
$result->attemptleft = $scorm->maxattempt - $attempt;
|
||||
if ($scoes = get_records_select('scorm_scoes',"scorm='$scorm->id' $organizationsql order by id ASC")){
|
||||
$conditions['scorm'] = $scorm->id;
|
||||
if ($scoes = $DB->get_records('scorm_scoes', $conditions, "id ASC")){
|
||||
// drop keys so that we can access array sequentially
|
||||
$scoes = array_values($scoes);
|
||||
//
|
||||
@@ -215,7 +216,7 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
|
||||
|
||||
foreach ($scoes as $pos=>$sco) {
|
||||
$isvisible = false;
|
||||
$sco->title = stripslashes($sco->title);
|
||||
$sco->title = $sco->title;
|
||||
if ($optionaldatas = scorm_get_sco($sco->id, SCO_DATA)) {
|
||||
if (!isset($optionaldatas->isvisible) || (isset($optionaldatas->isvisible) && ($optionaldatas->isvisible == 'true'))) {
|
||||
$isvisible = true;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php // $Id$
|
||||
|
||||
function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$strexpand = get_string('expcoll','scorm');
|
||||
$modestr = '';
|
||||
@@ -19,13 +19,13 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
|
||||
//
|
||||
// Get the current organization infos
|
||||
//
|
||||
$organizationsql = '';
|
||||
$conditions = array();
|
||||
if (!empty($currentorg)) {
|
||||
if (($organizationtitle = get_field('scorm_scoes','title','scorm',$scorm->id,'identifier',$currentorg)) != '') {
|
||||
if (($organizationtitle = $DB->get_field('scorm_scoes', 'title', array('scorm'=>$scorm->id,'identifier'=>$currentorg))) != '') {
|
||||
$result->toc .= "\t<li>$organizationtitle</li>\n";
|
||||
$tocmenus[] = $organizationtitle;
|
||||
}
|
||||
$organizationsql = "AND organization='$currentorg'";
|
||||
$conditions['organization'] = $currentorg;
|
||||
}
|
||||
//
|
||||
// If not specified retrieve the last attempt number
|
||||
@@ -34,7 +34,8 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
|
||||
$attempt = scorm_get_last_attempt($scorm->id, $user->id);
|
||||
}
|
||||
$result->attemptleft = $scorm->maxattempt - $attempt;
|
||||
if ($scoes = get_records_select('scorm_scoes',"scorm='$scorm->id' $organizationsql order by id ASC")){
|
||||
$conditions['scorm'] = $scorm->id;
|
||||
if ($scoes = $DB->get_records('scorm_scoes', $conditions, "id ASC")){
|
||||
// drop keys so that we can access array sequentially
|
||||
$scoes = array_values($scoes);
|
||||
//
|
||||
@@ -210,7 +211,7 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
|
||||
}
|
||||
|
||||
if ($play) {
|
||||
$sco = get_record('scorm_scoes','id',$scoid);
|
||||
$sco = $DB->get_record('scorm_scoes', array('id'=>$scoid));
|
||||
$sco->previd = $previd;
|
||||
$sco->nextid = $nextid;
|
||||
$result->sco = $sco;
|
||||
|
||||
@@ -453,7 +453,7 @@ function scorm_get_manifest($blocks,$scoes) {
|
||||
}
|
||||
|
||||
function scorm_parse_scorm($pkgdir,$scormid) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$launch = 0;
|
||||
$manifestfile = $pkgdir.'/imsmanifest.xml';
|
||||
@@ -474,7 +474,7 @@ function scorm_parse_scorm($pkgdir,$scormid) {
|
||||
$scoes = scorm_get_manifest($manifests,$scoes);
|
||||
//print_object($scoes);
|
||||
if (count($scoes->elements) > 0) {
|
||||
$olditems = get_records('scorm_scoes','scorm',$scormid);
|
||||
$olditems = $DB->get_records('scorm_scoes', array('scorm'=>$scormid));
|
||||
foreach ($scoes->elements as $manifest => $organizations) {
|
||||
foreach ($organizations as $organization => $items) {
|
||||
foreach ($items as $identifier => $item) {
|
||||
@@ -491,11 +491,11 @@ function scorm_parse_scorm($pkgdir,$scormid) {
|
||||
$id = 0;
|
||||
if (!empty($olditems) && ($olditemid = scorm_array_search('identifier',$newitem->identifier,$olditems))) {
|
||||
$newitem->id = $olditemid;
|
||||
$id = update_record('scorm_scoes',$newitem);
|
||||
$id = $DB->update_record('scorm_scoes',$newitem);
|
||||
unset($olditems[$olditemid]);
|
||||
delete_records('scorm_scoes_data','scoid',$olditemid);
|
||||
$DB->delete_records('scorm_scoes_data', array('scoid'=>$olditemid));
|
||||
} else {
|
||||
$id = insert_record('scorm_scoes',$newitem);
|
||||
$id = $DB->insert_record('scorm_scoes',$newitem);
|
||||
}
|
||||
|
||||
if ($optionaldatas = scorm_optionals_data($item,$standarddatas)) {
|
||||
@@ -504,8 +504,8 @@ function scorm_parse_scorm($pkgdir,$scormid) {
|
||||
foreach ($optionaldatas as $optionaldata) {
|
||||
if (isset($item->$optionaldata)) {
|
||||
$data->name = $optionaldata;
|
||||
$data->value = addslashes($item->$optionaldata);
|
||||
$dataid = insert_record('scorm_scoes_data',$data);
|
||||
$data->value = $item->$optionaldata;
|
||||
$dataid = $DB->insert_record('scorm_scoes_data',$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -517,7 +517,7 @@ function scorm_parse_scorm($pkgdir,$scormid) {
|
||||
$rule->ruletype = $sequencingrule->type;
|
||||
$rule->conditioncombination = $sequencingrule->conditioncombination;
|
||||
$rule->action = $sequencingrule->action;
|
||||
$ruleid = insert_record('scorm_seq_ruleconds',$rule);
|
||||
$ruleid = $DB->insert_record('scorm_seq_ruleconds',$rule);
|
||||
if (isset($sequencingrule->ruleconditions)) {
|
||||
foreach($sequencingrule->ruleconditions as $rulecondition) {
|
||||
$rulecond = new stdClass();
|
||||
@@ -526,7 +526,7 @@ function scorm_parse_scorm($pkgdir,$scormid) {
|
||||
$rulecond->referencedobjective = $rulecondition->referencedobjective;
|
||||
$rulecond->measurethreshold = $rulecondition->measurethreshold;
|
||||
$rulecond->cond = $rulecondition->cond;
|
||||
$rulecondid = insert_record('scorm_seq_rulecond',$rulecond);
|
||||
$rulecondid = $DB->insert_record('scorm_seq_rulecond',$rulecond);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -542,7 +542,7 @@ function scorm_parse_scorm($pkgdir,$scormid) {
|
||||
$rollup->rollupruleaction = $rolluprule->rollupruleaction;
|
||||
$rollup->conditioncombination = $rolluprule->conditioncombination;
|
||||
|
||||
$rollupruleid = insert_record('scorm_seq_rolluprule',$rollup);
|
||||
$rollupruleid = $DB->insert_record('scorm_seq_rolluprule',$rollup);
|
||||
if (isset($rollup->conditions)) {
|
||||
foreach($rollup->conditions as $condition){
|
||||
$cond = new stdClass();
|
||||
@@ -550,7 +550,7 @@ function scorm_parse_scorm($pkgdir,$scormid) {
|
||||
$cond->rollupruleid = $rollupruleid;
|
||||
$cond->operator = $condition->operator;
|
||||
$cond->cond = $condition->cond;
|
||||
$conditionid = insert_record('scorm_seq_rolluprulecond',$cond);
|
||||
$conditionid = $DB->insert_record('scorm_seq_rolluprulecond',$cond);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -564,7 +564,7 @@ function scorm_parse_scorm($pkgdir,$scormid) {
|
||||
$obj->satisfiedbumeasure = $objective->satisfiedbymeasure;
|
||||
$obj->objectiveid = $objective->objectiveid;
|
||||
$obj->minnormalizedmeasure = $objective->minnormalizedmeasure;
|
||||
$objectiveid = insert_record('scorm_seq_objective',$obj);
|
||||
$objectiveid = $DB->insert_record('scorm_seq_objective',$obj);
|
||||
if (isset($objective->mapinfos)) {
|
||||
//print_object($objective->mapinfos);
|
||||
foreach($objective->mapinfos as $objmapinfo) {
|
||||
@@ -576,7 +576,7 @@ function scorm_parse_scorm($pkgdir,$scormid) {
|
||||
$mapinfo->writesatisfiedstatus = $objmapinfo->writesatisfiedstatus;
|
||||
$mapinfo->readnormalizedmeasure = $objmapinfo->readnormalizedmeasure;
|
||||
$mapinfo->writenormalizedmeasure = $objmapinfo->writenormalizedmeasure;
|
||||
$mapinfoid = insert_record('scorm_seq_mapinfo',$mapinfo);
|
||||
$mapinfoid = $DB->insert_record('scorm_seq_mapinfo',$mapinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -590,18 +590,18 @@ function scorm_parse_scorm($pkgdir,$scormid) {
|
||||
}
|
||||
if (!empty($olditems)) {
|
||||
foreach($olditems as $olditem) {
|
||||
delete_records('scorm_scoes','id',$olditem->id);
|
||||
delete_records('scorm_scoes_data','scoid',$olditem->id);
|
||||
delete_records('scorm_scoes_track','scoid',$olditem->id);
|
||||
delete_records('scorm_seq_objective','scoid',$olditem->id);
|
||||
delete_records('scorm_seq_mapinfo','scoid',$olditem->id);
|
||||
delete_records('scorm_seq_ruleconds','scoid',$olditem->id);
|
||||
delete_records('scorm_seq_rulecond','scoid',$olditem->id);
|
||||
delete_records('scorm_seq_rolluprule','scoid',$olditem->id);
|
||||
delete_records('scorm_seq_rollupcond','scoid',$olditem->id);
|
||||
$DB->delete_records('scorm_scoes', array('id'=>$olditem->id));
|
||||
$DB->delete_records('scorm_scoes_data',array('scoid'=>$olditem->id));
|
||||
$DB->delete_records('scorm_scoes_track',array('scoid'=>$olditem->id));
|
||||
$DB->delete_records('scorm_seq_objective', array('scoid'=>$olditem->id));
|
||||
$DB->delete_records('scorm_seq_mapinfo', array('scoid'=>$olditem->id));
|
||||
$DB->delete_records('scorm_seq_ruleconds', array('scoid'=>$olditem->id));
|
||||
$DB->delete_records('scorm_seq_rulecond', array('scoid'=>$olditem->id));
|
||||
$DB->delete_records('scorm_seq_rolluprule', array('scoid'=>$olditem->id));
|
||||
$DB->delete_records('scorm_seq_rollupcond', array('scoid'=>$olditem->id));
|
||||
}
|
||||
}
|
||||
set_field('scorm','version',$scoes->version,'id',$scormid);
|
||||
$DB->set_field('scorm','version',$scoes->version, array('id'=>$scormid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,15 +622,19 @@ function scorm_optionals_data($item, $standarddata) {
|
||||
}
|
||||
|
||||
function scorm_is_leaf($sco) {
|
||||
if (get_record('scorm_scoes','scorm',$sco->scorm,'parent',$sco->identifier)) {
|
||||
global $DB;
|
||||
|
||||
if ($DB->get_record('scorm_scoes', array('scorm'=>$sco->scorm, 'parent'=>$sco->identifier))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function scorm_get_parent($sco) {
|
||||
global $DB;
|
||||
|
||||
if ($sco->parent != '/') {
|
||||
if ($parent = get_record('scorm_scoes','scorm',$sco->scorm,'identifier',$sco->parent)) {
|
||||
if ($parent = $DB->get_record('scorm_scoes', array('scorm'=>$sco->scorm,'identifier'=>$sco->parent))) {
|
||||
return scorm_get_sco($parent->id);
|
||||
}
|
||||
}
|
||||
@@ -638,14 +642,18 @@ function scorm_get_parent($sco) {
|
||||
}
|
||||
|
||||
function scorm_get_children($sco) {
|
||||
if ($children = get_records('scorm_scoes','scorm',$sco->scorm,'parent',$sco->identifier)) {//originally this said parent instead of childrean
|
||||
global $DB;
|
||||
|
||||
if ($children = $DB->get_records('scorm_scoes', array('scorm'=>$sco->scorm,'parent'=>$sco->identifier))) {//originally this said parent instead of childrean
|
||||
return $children;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function scorm_get_available_children($sco){
|
||||
$res = get_record('scorm_scoes_track','scoid',$scoid,'userid',$userid,'element','availablechildren');
|
||||
global $DB;
|
||||
|
||||
$res = $DB->get_record('scorm_scoes_track', array('scoid'=>$scoid,'userid'=>$userid,'element'=>'availablechildren')); // TODO: undefined!!!
|
||||
if(!$res || $res == null){
|
||||
return false;
|
||||
}
|
||||
@@ -670,7 +678,9 @@ function scorm_get_available_descendent($descend = array(),$sco){
|
||||
}
|
||||
|
||||
function scorm_get_siblings($sco) {
|
||||
if ($siblings = get_records('scorm_scoes','scorm',$sco->scorm,'parent',$sco->parent)) {
|
||||
global $DB;
|
||||
|
||||
if ($siblings = $DB->get_records('scorm_scoes', array('scorm'=>$sco->scorm,'parent'=>$sco->parent))) {
|
||||
unset($siblings[$sco->id]);
|
||||
if (!empty($siblings)) {
|
||||
return $siblings;
|
||||
@@ -688,8 +698,6 @@ function scorm_get_ancestors($sco) {
|
||||
}
|
||||
|
||||
function scorm_get_preorder($preorder=array(),$sco) {
|
||||
|
||||
|
||||
if ($sco != null) {
|
||||
array_push($preorder,$sco);
|
||||
$children = scorm_get_children($sco);
|
||||
|
||||
@@ -30,6 +30,8 @@ function scorm_seq_overall ($scoid,$userid,$request,$attempt) {
|
||||
|
||||
|
||||
function scorm_seq_navigation ($scoid,$userid,$request,$attempt=0) {
|
||||
global $DB;
|
||||
|
||||
/// Sequencing structure
|
||||
$seq = new stdClass();
|
||||
$seq->currentactivity = scorm_get_sco($scoid);
|
||||
@@ -63,7 +65,7 @@ function scorm_seq_navigation ($scoid,$userid,$request,$attempt=0) {
|
||||
break;
|
||||
case 'resumeall_':
|
||||
if (empty($seq->currentactivity)) {
|
||||
if ($track = get_record('scorm_scoes_track','scoid',$scoid,'userid',$userid,'element','suspendedactivity')) {//I think it's suspend instead of suspendedactivity
|
||||
if ($track = $DB->get_record('scorm_scoes_track', array('scoid'=>$scoid,'userid'=>$userid,'element'=>'suspendedactivity'))) {//I think it's suspend instead of suspendedactivity
|
||||
$seq->navigation = true;
|
||||
$seq->sequencing = 'resumeall';
|
||||
} else {
|
||||
@@ -131,7 +133,7 @@ function scorm_seq_navigation ($scoid,$userid,$request,$attempt=0) {
|
||||
}
|
||||
break;
|
||||
default: /// {target=<STRING>}choice
|
||||
if ($targetsco = get_record('scorm_scoes','scorm',$sco->scorm,'identifier',$request)) {
|
||||
if ($targetsco = $DB->get_record('scorm_scoes', array('scorm'=>$sco->scorm,'identifier'=>$request))) {
|
||||
if ($targetsco->parent != '/') {
|
||||
$seq->target = $request;
|
||||
} else {
|
||||
@@ -298,6 +300,8 @@ function scorm_seq_termination ($seq,$userid) {
|
||||
}
|
||||
|
||||
function scorm_seq_end_attempt($sco,$userid,$seq) {
|
||||
global $DB;
|
||||
|
||||
if (scorm_is_leaf($sco)) {
|
||||
if (!isset($sco->tracked) || ($sco->tracked == 1)) {
|
||||
if (!scorm_seq_is('suspended',$sco->id,$userid)) {
|
||||
@@ -309,7 +313,7 @@ function scorm_seq_end_attempt($sco,$userid,$seq) {
|
||||
}
|
||||
}
|
||||
if (!isset($sco->objectivesetbycontent) || ($sco->objectivesetbycontent == 0)) {
|
||||
if ($objectives = get_records('scorm_seq_objective','scoid',$sco->id)) {
|
||||
if ($objectives = $DB->get_records('scorm_seq_objective', array('scoid'=>$sco->id))) {
|
||||
foreach ($objectives as $objective) {
|
||||
if ($objective->primaryobj) {
|
||||
//if (!scorm_seq_objective_progress_status($sco,$userid,$objective)) {
|
||||
@@ -344,27 +348,30 @@ function scorm_seq_end_attempt($sco,$userid,$seq) {
|
||||
}
|
||||
|
||||
function scorm_seq_is($what, $scoid, $userid, $attempt=0) {
|
||||
global $DB;
|
||||
|
||||
/// Check if passed activity $what is active
|
||||
$active = false;
|
||||
if ($track = get_record('scorm_scoes_track','scoid',$scoid,'userid',$userid,'attempt',$attempt,'element',$what)) {
|
||||
if ($track = $DB->get_record('scorm_scoes_track', array('scoid'=>$scoid,'userid'=>$userid,'attempt'=>$attempt,'element'=>$what))) {
|
||||
$active = true;
|
||||
}
|
||||
return $active;
|
||||
}
|
||||
|
||||
function scorm_seq_set($what, $scoid, $userid, $attempt=0, $value='true') {
|
||||
global $DB;
|
||||
|
||||
$sco = scorm_get_sco($scoid);
|
||||
|
||||
/// set passed activity to active or not
|
||||
if ($value == false) {
|
||||
delete_record('scorm_scoes_track','scoid',$scoid,'userid',$userid,'attempt',$attempt,'element',$what);
|
||||
$DB->delete_record('scorm_scoes_track', array('scoid'=>$scoid,'userid'=>$userid,'attempt'=>$attempt,'element'=>$what));
|
||||
} else {
|
||||
scorm_insert_track($userid, $sco->scorm, $sco->id, 0, $what, $value);
|
||||
}
|
||||
|
||||
// update grades in gradebook
|
||||
$scorm = get_record('scorm', 'id', $sco->scorm);
|
||||
$scorm = $DB->get_record('scorm', array('id'=>$sco->scorm));
|
||||
scorm_update_grades($scorm, $userid, true);
|
||||
}
|
||||
|
||||
@@ -418,8 +425,10 @@ function scorm_seq_post_cond_rules($seq,$userid) {
|
||||
}
|
||||
|
||||
function scorm_seq_rules_check ($sco, $action){
|
||||
global $DB;
|
||||
|
||||
$act = null;
|
||||
if($rules = get_records('scorm_seq_ruleconds','scoid',$sco->id,'action',$action)){
|
||||
if($rules = $DB->get_records('scorm_seq_ruleconds', array('scoid'=>$sco->id,'action'=>$action))) {
|
||||
foreach ($rules as $rule){
|
||||
if($act = scorm_seq_rule_check($sco,$rule)){
|
||||
return $act;
|
||||
@@ -431,9 +440,11 @@ function scorm_seq_rules_check ($sco, $action){
|
||||
}
|
||||
|
||||
function scorm_seq_rule_check ($sco, $rule){
|
||||
global $DB;
|
||||
|
||||
$bag = Array();
|
||||
$cond = '';
|
||||
$ruleconds = get_records('scorm_seq_rulecond','scoid',$sco->id,'ruleconditionsid',$rule->id);
|
||||
$ruleconds = $DB->get_records('scorm_seq_rulecond', array('scoid'=>$sco->id,'ruleconditionsid'=>$rule->id));
|
||||
foreach ($ruleconds as $rulecond){
|
||||
if ($rulecond->operator = 'not') {
|
||||
if ($rulecond->cond != 'unknown' ){
|
||||
@@ -490,9 +501,9 @@ function scorm_seq_measure_rollup($sco,$userid){
|
||||
$countedmeasures = 0;//Same too
|
||||
$targetobjective = null;
|
||||
$readable = true;//to check if status and measure weight are readable
|
||||
$objectives = get_records('scorm_seq_objective','scoid',$sco->id);
|
||||
$objectives = $DB->get_records('scorm_seq_objective', array('scoid'=>$sco->id));
|
||||
|
||||
foreach ($objective as $objective){
|
||||
foreach ($objectives as $objective){
|
||||
|
||||
if ($objective->primaryobj == true){//Objective contributes to rollup I'm using primaryobj field, but not
|
||||
$targetobjective = $objective;
|
||||
@@ -508,8 +519,8 @@ function scorm_seq_measure_rollup($sco,$userid){
|
||||
if (!isset($child->tracked) || ($child->tracked == 1)){
|
||||
|
||||
$rolledupobjective = null;// we set the rolled up activity to undefined
|
||||
$objectives = get_records('scorm_seq_objective','scoid',$child->id);
|
||||
foreach ($objective as $objective){
|
||||
$objectives = $DB->get_records('scorm_seq_objective', array('scoid'=>$child->id));
|
||||
foreach ($objectives as $objective){
|
||||
if ($objective->primaryobj == true){//Objective contributes to rollup I'm using primaryobj field, but not
|
||||
$rolledupobjective = $objective;
|
||||
break;
|
||||
@@ -520,7 +531,7 @@ function scorm_seq_measure_rollup($sco,$userid){
|
||||
|
||||
$countedmeasures = $countedmeasures + ($child->measureweight);
|
||||
if (!scorm_seq_is('objectivemeasurestatus',$sco->id,$userid)) {
|
||||
$normalizedmeasure = get_record('scorm_scoes_track','scoid',$child->id,'userid',$userid,'element','objectivenormalizedmeasure');
|
||||
$normalizedmeasure = $DB->get_record('scorm_scoes_track', array('scoid'=>$child->id,'userid'=>$userid,'element'=>'objectivenormalizedmeasure'));
|
||||
$totalmeasure = $totalmeasure + (($normalizedmeasure->value) * ($child->measureweight));
|
||||
$valid = true;
|
||||
}
|
||||
@@ -540,7 +551,7 @@ function scorm_seq_measure_rollup($sco,$userid){
|
||||
else{
|
||||
if($countedmeasures>0){
|
||||
scorm_seq_set('objectivemeasurestatus',$sco->id,$userid);
|
||||
$val=$totalmeasure/$countedmeasure;
|
||||
$val=$totalmeasure/$countedmeasures;
|
||||
scorm_seq_set('objectivenormalizedmeasure',$sco->id,$userid,$val);
|
||||
|
||||
}
|
||||
@@ -555,6 +566,7 @@ function scorm_seq_measure_rollup($sco,$userid){
|
||||
}
|
||||
|
||||
function scorm_seq_objective_rollup($sco,$userid){
|
||||
global $DB;
|
||||
|
||||
scorm_seq_objective_rollup_measure($sco,$userid);
|
||||
scorm_seq_objective_rollup_rules($sco,$userid);
|
||||
@@ -570,9 +582,9 @@ function scorm_seq_objective_rollup($sco,$userid){
|
||||
}
|
||||
else{
|
||||
|
||||
$rolluprules = get_record('scorm_seq_rolluprule','scoid',$sco->id,'userid',$userid);
|
||||
$rolluprules = $DB->get_record('scorm_seq_rolluprule', array('scoid'=>$sco->id,'userid'=>$userid));
|
||||
foreach($rolluprules as $rolluprule){
|
||||
$rollupruleconds = get_records('scorm_seq_rolluprulecond','rollupruleid',$rolluprule->id);
|
||||
$rollupruleconds = $DB->get_records('scorm_seq_rolluprulecond', array('rollupruleid'=>$rolluprule->id));
|
||||
foreach($rollupruleconds as $rolluprulecond){
|
||||
|
||||
switch ($rolluprulecond->cond!='satisfied' && $rolluprulecond->cond!='completed' && $rolluprulecond->cond!='attempted'){
|
||||
@@ -590,10 +602,12 @@ function scorm_seq_objective_rollup($sco,$userid){
|
||||
}
|
||||
|
||||
function scorm_seq_objective_rollup_measure($sco,$userid){
|
||||
global $DB;
|
||||
|
||||
$targetobjective = null;
|
||||
|
||||
|
||||
$objectives = get_records('scorm_seq_objective','scoid',$sco->id);
|
||||
$objectives = $DB->get_records('scorm_seq_objective', array('scoid'=>$sco->id));
|
||||
foreach ($objectives as $objective){
|
||||
if ($objective->primaryobj == true){
|
||||
$targetobjective = $objective;
|
||||
@@ -619,7 +633,7 @@ function scorm_seq_objective_rollup_measure($sco,$userid){
|
||||
$isactive = false;
|
||||
}
|
||||
|
||||
$normalizedmeasure = get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','objectivenormalizedmeasure');
|
||||
$normalizedmeasure = $DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'objectivenormalizedmeasure'));
|
||||
|
||||
$sco = scorm_get_sco ($sco->id);
|
||||
|
||||
@@ -645,11 +659,13 @@ function scorm_seq_objective_rollup_measure($sco,$userid){
|
||||
}
|
||||
|
||||
function scorm_seq_objective_rollup_default($sco,$userid){
|
||||
global $DB;
|
||||
|
||||
if (!(scorm_seq_rollup_rule_check($sco,$userid,'incomplete')) && !(scorm_seq_rollup_rule_check($sco,$userid,'completed'))){
|
||||
|
||||
$rolluprules = get_record('scorm_seq_rolluprule','scoid',$sco->id,'userid',$userid);
|
||||
$rolluprules = $DB->get_record('scorm_seq_rolluprule', array('scoid'=>$sco->id,'userid'=>$userid));
|
||||
foreach($rolluprules as $rolluprule){
|
||||
$rollupruleconds = get_records('scorm_seq_rolluprulecond','rollupruleid',$rolluprule->id);
|
||||
$rollupruleconds = $DB->get_records('scorm_seq_rolluprulecond', array('rollupruleid'=>$rolluprule->id));
|
||||
foreach($rollupruleconds as $rolluprulecond){
|
||||
|
||||
if ($rolluprulecond->cond!='satisfied' && $rolluprulecond->cond!='completed' && $rolluprulecond->cond!='attempted'){
|
||||
@@ -668,10 +684,12 @@ function scorm_seq_objective_rollup_default($sco,$userid){
|
||||
|
||||
|
||||
function scorm_seq_objective_rollup_rules($sco,$userid){
|
||||
global $DB;
|
||||
|
||||
$targetobjective = null;
|
||||
|
||||
$objectives = get_records('scorm_seq_objective','scoid',$sco->id);
|
||||
foreach ($objective as $objective){
|
||||
$objectives = $DB->get_records('scorm_seq_objective', array('scoid'=>$sco->id));
|
||||
foreach ($objectives as $objective){
|
||||
if ($objective->primaryobj == true){//Objective contributes to rollup I'm using primaryobj field, but not
|
||||
$targetobjective = $objective;
|
||||
break;
|
||||
@@ -713,8 +731,9 @@ function scorm_seq_activity_progress_rollup ($sco, $userid){
|
||||
}
|
||||
|
||||
function scorm_seq_rollup_rule_check ($sco,$userid,$action){
|
||||
global $DB;
|
||||
|
||||
if($rolluprules = get_record('scorm_seq_rolluprule','scoid',$sco->id,'userid',$userid,'action',$action)){
|
||||
if($rolluprules = $DB->get_record('scorm_seq_rolluprule', array('scoid'=>$sco->id,'userid'=>$userid,'action'=>$action))) {
|
||||
|
||||
$childrenbag = Array ();
|
||||
$children = scorm_get_children ($sco);
|
||||
@@ -723,14 +742,14 @@ function scorm_seq_rollup_rule_check ($sco,$userid,$action){
|
||||
|
||||
foreach ($children as $child){
|
||||
|
||||
/*$tracked = get_records('scorm_scoes_track','scoid',$child->id,'userid',$userid);
|
||||
/*$tracked = $DB->get_records('scorm_scoes_track', array('scoid'=>$child->id,'userid'=>$userid));
|
||||
if($tracked && $tracked->attemp != 0){*/
|
||||
$child = scorm_get_sco ($child);
|
||||
if (!isset($child->tracked) || ($child->tracked == 1)){
|
||||
|
||||
if(scorm_seq_check_child ($child,$action,$userid)){
|
||||
|
||||
$rollupruleconds = get_records('scorm_seq_rolluprulecond','rollupruleid',$rolluprule->id);
|
||||
$rollupruleconds = $DB->get_records('scorm_seq_rolluprulecond', array('rollupruleid'=>$rolluprule->id));
|
||||
$evaluate = scorm_seq_evaluate_rollupcond($child,$rolluprule->conditioncombination,$rollupruleconds,$userid);
|
||||
if ($evaluate=='unknown'){
|
||||
array_push($childrenbag,'unknown');
|
||||
@@ -880,15 +899,16 @@ function scorm_seq_evaluate_rollupcond($sco,$conditioncombination,$rolluprulecon
|
||||
}
|
||||
|
||||
function scorm_evaluate_condition ($rolluprulecond,$sco,$userid){
|
||||
global $DB;
|
||||
|
||||
$res = false;
|
||||
|
||||
switch ($rolluprulecond->cond){
|
||||
|
||||
case 'satisfied':
|
||||
if($r=get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','objectivesatisfiedstatus')){
|
||||
if($r=$DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'objectivesatisfiedstatus'))) {
|
||||
if($r->value == true){
|
||||
if ($r=get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','objectiveprogressstatus')){
|
||||
if ($r=$DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'objectiveprogressstatus'))) {
|
||||
if($r->value == true){
|
||||
$res= true;
|
||||
}
|
||||
@@ -898,7 +918,7 @@ function scorm_evaluate_condition ($rolluprulecond,$sco,$userid){
|
||||
break;
|
||||
|
||||
case 'objectiveStatusKnown':
|
||||
if ($r=get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','objectiveprogressstatus')){
|
||||
if ($r=$DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'objectiveprogressstatus'))) {
|
||||
if($r->value == true){
|
||||
$res= true;
|
||||
}
|
||||
@@ -906,7 +926,7 @@ function scorm_evaluate_condition ($rolluprulecond,$sco,$userid){
|
||||
break;
|
||||
|
||||
case 'objectiveMeasureKnown':
|
||||
if ($r = get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','objectivemeasurestatus')){
|
||||
if ($r = $DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'objectivemeasurestatus'))) {
|
||||
if($r->value == true){
|
||||
$res = true;
|
||||
}
|
||||
@@ -916,9 +936,9 @@ function scorm_evaluate_condition ($rolluprulecond,$sco,$userid){
|
||||
break;
|
||||
|
||||
case 'completed':
|
||||
if ($r = get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','attemptcompletionstatus')){
|
||||
if ($r = $DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'attemptcompletionstatus'))) {
|
||||
if($r->value){
|
||||
if ($r = get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','attemptprogressstatus')){
|
||||
if ($r = $DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'attemptprogressstatus'))) {
|
||||
if($r->value){
|
||||
$res = true;
|
||||
}
|
||||
@@ -930,9 +950,9 @@ function scorm_evaluate_condition ($rolluprulecond,$sco,$userid){
|
||||
break;
|
||||
|
||||
case 'attempted':
|
||||
if ($r = get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','activityprogressstatus')){
|
||||
if ($r = $DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'activityprogressstatus'))) {
|
||||
if($r->value){
|
||||
if ($r = get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','activityattemptcount')){
|
||||
if ($r = $DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'activityattemptcount'))) {
|
||||
if($r->value > 0){
|
||||
$res = true;
|
||||
}
|
||||
@@ -945,11 +965,11 @@ function scorm_evaluate_condition ($rolluprulecond,$sco,$userid){
|
||||
|
||||
|
||||
case 'attemptLimitExceeded':
|
||||
if ($r = get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','activityprogressstatus')){
|
||||
if ($r = $DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'activityprogressstatus'))) {
|
||||
if($r->value){
|
||||
if ($r = get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','limitconditionattemptlimitcontrol')){
|
||||
if ($r = $DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'limitconditionattemptlimitcontrol'))) {
|
||||
if($r->value){
|
||||
if ($r = get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','activityattemptcount') && $r2 = get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','limitconditionattemptlimit') ){
|
||||
if ($r = $DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'activityattemptcount')) && $r2 = $DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'limitconditionattemptlimit')) ){
|
||||
if($r->value >= $r2->value){
|
||||
$res = true;
|
||||
}
|
||||
@@ -968,9 +988,9 @@ function scorm_evaluate_condition ($rolluprulecond,$sco,$userid){
|
||||
|
||||
case 'activityProgressKnown':
|
||||
|
||||
if ($r = get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','activityprogressstatus')){
|
||||
if ($r = $DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'activityprogressstatus'))) {
|
||||
if($r->value){
|
||||
if ($r = get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','attemptprogressstatus')){
|
||||
if ($r = $DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'attemptprogressstatus'))) {
|
||||
if($r->value){
|
||||
$res = true;
|
||||
}
|
||||
@@ -988,9 +1008,11 @@ function scorm_evaluate_condition ($rolluprulecond,$sco,$userid){
|
||||
}
|
||||
|
||||
function scorm_seq_check_child ($sco, $action, $userid){
|
||||
global $DB;
|
||||
|
||||
$included = false;
|
||||
$sco=scorm_get_sco($sco->id);
|
||||
$r = get_record('scorm_scoes_track','scoid',$sco->id,'userid',$userid,'element','activityattemptcount');
|
||||
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'activityattemptcount'));
|
||||
if ($action == 'satisfied' || $action == 'notsatisfied'){
|
||||
if (!$sco->rollupobjectivesatisfied){
|
||||
$included = true;
|
||||
@@ -1060,6 +1082,7 @@ function scorm_seq_sequencing ($scoid,$userid,$seq) {
|
||||
switch ($seq->sequencing) {
|
||||
|
||||
case 'start':
|
||||
//TODO: undefined $sco!
|
||||
$seq = scorm_seq_start_sequencing($sco,$userid,$seq); //We'll see the parameters we have to send, this should update delivery and end
|
||||
$seq->sequencing = true;
|
||||
|
||||
@@ -1116,12 +1139,14 @@ function scorm_seq_sequencing ($scoid,$userid,$seq) {
|
||||
|
||||
|
||||
function scorm_seq_start_sequencing($scoid,$userid,$seq){
|
||||
global $DB;
|
||||
|
||||
if (!empty($seq->currentactivity)) {
|
||||
$seq->delivery = null;
|
||||
$seq->exception = 'SB.2.5-1';
|
||||
return $seq;
|
||||
}
|
||||
$sco = get_record('scorm_scoes','scoid',$scoid,'userid',$userid);
|
||||
$sco = $DB->get_record('scorm_scoes', array('scoid'=>$scoid,'userid'=>$userid));
|
||||
if (($sco->parent == '/') && scorm_is_leaf($sco)) {//if the activity is the root and is leaf
|
||||
$seq->delivery = $sco;
|
||||
}
|
||||
@@ -1139,18 +1164,20 @@ function scorm_seq_start_sequencing($scoid,$userid,$seq){
|
||||
}
|
||||
|
||||
function scorm_seq_resume_all_sequencing($scoid,$userid,$seq){
|
||||
global $DB;
|
||||
|
||||
if (!empty($seq->currentactivity)){
|
||||
$seq->delivery = null;
|
||||
$seq->exception = 'SB.2.6-1';
|
||||
return $seq;
|
||||
}
|
||||
$track = get_record('scorm_scoes_track','scoid',$scoid,'userid',$userid,'element','suspendedactivity');
|
||||
$track = $DB->get_record('scorm_scoes_track', array('scoid'=>$scoid,'userid'=>$userid,'element'=>'suspendedactivity'));
|
||||
if (!$track) {
|
||||
$seq->delivery = null;
|
||||
$seq->exception = 'SB.2.6-2';
|
||||
return $seq;
|
||||
}
|
||||
$seq->delivery = get_record('scorm_scoes','scoid',$scoid,'userid',$userid);//we assign the sco to the delivery
|
||||
$seq->delivery = $DB->get_record('scorm_scoes', array('scoid'=>$scoid,'userid'=>$userid));//we assign the sco to the delivery
|
||||
|
||||
}
|
||||
|
||||
@@ -1190,7 +1217,7 @@ function scorm_seq_previous_sequencing($scoid,$userid,$seq){
|
||||
|
||||
$currentact= $seq->currentactivity;
|
||||
if ($currentact->parent != '/') {//if the activity is the root and is leaf
|
||||
$parent = scorm_get_parent ($activity);
|
||||
$parent = scorm_get_parent ($activity); // TODO: undefined!!
|
||||
if (!isset($parent->flow) || ($parent->flow == false)) {
|
||||
$seq->delivery = null;
|
||||
$seq->exception = 'SB.2.8-2';
|
||||
@@ -1269,7 +1296,7 @@ function scorm_seq_flow ($candidate,$direction,$seq,$childrenflag,$userid){
|
||||
$activity=$candidate;
|
||||
$deliverable=false;
|
||||
$previdirection = null;
|
||||
$seq = scorm_seq_flow_tree_traversal ($activity,$direction,$childrenflag,$prevdirection,$seq,$userid);
|
||||
$seq = scorm_seq_flow_tree_traversal ($activity,$direction,$childrenflag,$prevdirection,$seq,$userid); // TODO: undefined
|
||||
if($seq->identifiedactivity == null){//if identifies
|
||||
$seq->identifiedactivity = $candidate;
|
||||
$seq->deliverable = false;
|
||||
@@ -1293,7 +1320,7 @@ function scorm_seq_flow_activity_traversal ($activity, $userid, $direction, $chi
|
||||
return $seq;
|
||||
}
|
||||
|
||||
$rulch = scorm_seq_rules_check($sco, 'skipped');
|
||||
$rulch = scorm_seq_rules_check($sco, 'skipped'); // TODO: undefined
|
||||
if ($rulch != null){
|
||||
$seq = scorm_seq_flow_tree_traversal ($activity, $direction, false, $prevdirection, $seq,$userid);//endsession and exception
|
||||
if ($seq->identifiedactivity == null){
|
||||
@@ -1496,6 +1523,7 @@ function scorm_check_activity ($activity,$userid){
|
||||
}
|
||||
|
||||
function scorm_limit_cond_check ($activity,$userid){
|
||||
global $DB;
|
||||
|
||||
if (isset($activity->tracked) && ($activity->tracked == 0)){
|
||||
|
||||
@@ -1507,42 +1535,42 @@ function scorm_limit_cond_check ($activity,$userid){
|
||||
}
|
||||
|
||||
if (!isset($activity->limitcontrol) || ($activity->limitcontrol == 1)){
|
||||
$r = get_record('scorm_scoes_track','scoid',$activity->id,'userid',$userid,'element','activityattemptcount');
|
||||
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'activityattemptcount'));
|
||||
if (scorm_seq_is('activityprogressstatus',$activity->id,$userid) && ($r->value >=$activity->limitattempt)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($activity->limitabsdurcontrol) || ($activity->limitabsdurcontrol == 1)){
|
||||
$r = get_record('scorm_scoes_track','scoid',$activity->id,'userid',$userid,'element','activityabsoluteduration');
|
||||
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'activityabsoluteduration'));
|
||||
if (scorm_seq_is('activityprogressstatus',$activity->id,$userid) && ($r->value >=$activity->limitabsduration)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($activity->limitexpdurcontrol) || ($activity->limitexpdurcontrol == 1)){
|
||||
$r = get_record('scorm_scoes_track','scoid',$activity->id,'userid',$userid,'element','activityexperiencedduration');
|
||||
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'activityexperiencedduration'));
|
||||
if (scorm_seq_is('activityprogressstatus',$activity->id,$userid) && ($r->value >=$activity->limitexpduration)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($activity->limitattabsdurcontrol) || ($activity->limitattabsdurcontrol == 1)){
|
||||
$r = get_record('scorm_scoes_track','scoid',$activity->id,'userid',$userid,'element','attemptabsoluteduration');
|
||||
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'attemptabsoluteduration'));
|
||||
if (scorm_seq_is('activityprogressstatus',$activity->id,$userid) && ($r->value >=$activity->limitattabsduration)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($activity->limitattexpdurcontrol) || ($activity->limitattexpdurcontrol == 1)){
|
||||
$r = get_record('scorm_scoes_track','scoid',$activity->id,'userid',$userid,'element','attemptexperiencedduration');
|
||||
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'attemptexperiencedduration'));
|
||||
if (scorm_seq_is('activityprogressstatus',$activity->id,$userid) && ($r->value >=$activity->limitattexpduration)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($activity->limitbegincontrol) || ($activity->limitbegincontrol == 1)){
|
||||
$r = get_record('scorm_scoes_track','scoid',$activity->id,'userid',$userid,'element','begintime');
|
||||
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'begintime'));
|
||||
if (time()>=$activity->limitbegintime){
|
||||
return true;
|
||||
}
|
||||
@@ -1839,7 +1867,7 @@ function scorm_seq_choice_flow_tree ($constrained, $traverse, $seq){
|
||||
$parent = scorm_get_parent ($constrained);
|
||||
if ($traverse== 'forward'){
|
||||
$preord = scorm_get_preorder ($constrained);
|
||||
if (sizeof($preorder) == 0 || (sizeof($preorder) == 0 && $preorder[0]->id = $constrained->id)){
|
||||
if (sizeof($preorder) == 0 || (sizeof($preorder) == 0 && $preorder[0]->id = $constrained->id)){ // TODO: undefined
|
||||
$islast = true;//the function is the last activity available
|
||||
}
|
||||
if ($constrained->parent == '/' || $islast){
|
||||
@@ -1959,13 +1987,14 @@ function scorm_sequencing_delivery($scoid,$userid,$seq){
|
||||
}
|
||||
|
||||
function scorm_content_delivery_environment ($seq,$userid){
|
||||
global $DB;
|
||||
|
||||
$act = $seq->currentactivity;
|
||||
if(scorm_seq_is('active',$act->id,$userid)){
|
||||
$seq->exception = 'DB.2-1';
|
||||
return $seq;
|
||||
}
|
||||
$track = get_record('scorm_scoes_track','scoid',$act->id,'userid',$userid,'element','suspendedactivity');
|
||||
$track = $DB->get_record('scorm_scoes_track', array('scoid'=>$act->id,'userid'=>$userid,'element'=>'suspendedactivity'));
|
||||
if ($track != null){
|
||||
$seq = scorm_clear_suspended_activity($seq->delivery, $seq);
|
||||
|
||||
@@ -1978,7 +2007,7 @@ function scorm_content_delivery_environment ($seq,$userid){
|
||||
if(!scorm_seq_is('active',$activity->id,$userid)){
|
||||
if(!isset($activity->tracked) || ($activity->tracked == 1)){
|
||||
if(!scorm_seq_is('suspended',$activity->id,$userid)){
|
||||
$r = get_record('scorm_scoes_track','scoid',$activity->id,'userid',$userid,'element','activityattemptcount');
|
||||
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'activityattemptcount'));
|
||||
$r->value = ($r->value)+1;
|
||||
update_record ('scorm_scoes_track',$r);
|
||||
if ($r->value == 1){
|
||||
@@ -2006,16 +2035,17 @@ function scorm_content_delivery_environment ($seq,$userid){
|
||||
|
||||
if(isset($activity->tracked) || ($activity->tracked == 0)){
|
||||
//How should I track the info and what should I do to not record the information for the activity during delivery?
|
||||
$atabsdur = get_record('scorm_scoes_track','scoid',$activity->id,'userid',$userid,'element','attemptabsoluteduration');
|
||||
$atexpdur = get_record('scorm_scoes_track','scoid',$activity->id,'userid',$userid,'element','attemptexperiencedduration');
|
||||
$atabsdur = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'attemptabsoluteduration'));
|
||||
$atexpdur = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'attemptexperiencedduration'));
|
||||
}
|
||||
return $seq;
|
||||
|
||||
|
||||
}
|
||||
function scorm_clear_suspended_activity($act,$seq){
|
||||
global $DB;
|
||||
$currentact= $seq->currentactivity;
|
||||
$track = get_record('scorm_scoes_track','scoid',$currentact->id,'userid',$userid,'element','suspendedactivity');
|
||||
$track = $DB->get_record('scorm_scoes_track', array('scoid'=>$currentact->id,'userid'=>$userid,'element'=>'suspendedactivity')); // TODO: undefined
|
||||
if ($track != null){
|
||||
$ancestors = scorm_get_ancestors($act);
|
||||
$commonpos = scorm_find_common_ancestor($ancestors,$currentact);
|
||||
@@ -2049,11 +2079,12 @@ function scorm_clear_suspended_activity($act,$seq){
|
||||
}
|
||||
|
||||
function scorm_select_children_process($scoid,$userid){
|
||||
global $DB;
|
||||
|
||||
$sco = scorm_get_sco($scoid);
|
||||
if (!scorm_is_leaf($sco)){
|
||||
if(!scorm_seq_is('suspended',$scoid,$userid) && !scorm_seq_is('active',$scoid,$userid)){
|
||||
$r = get_record('scorm_scoes_track','scoid',$scoid,'userid',$userid,'element','selectiontiming');
|
||||
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$scoid,'userid'=>$userid,'element'=>'selectiontiming'));
|
||||
|
||||
switch($r->value) {
|
||||
|
||||
@@ -2065,7 +2096,7 @@ function scorm_select_children_process($scoid,$userid){
|
||||
if(!scorm_seq_is('activityprogressstatus',$scoid,$userid)){
|
||||
if(scorm_seq_is('selectioncountsstatus',$scoid,$userid)){
|
||||
$childlist = '';
|
||||
$res = get_record('scorm_scoes_track','scoid',$scoid,'userid',$userid,'element','selectioncount');
|
||||
$res = $DB->get_record('scorm_scoes_track', array('scoid'=>$scoid,'userid'=>$userid,'element'=>'selectioncount'));
|
||||
$i = ($res->value)-1;
|
||||
$children = scorm_get_children ($sco);
|
||||
|
||||
@@ -2092,11 +2123,12 @@ function scorm_select_children_process($scoid,$userid){
|
||||
}
|
||||
|
||||
function scorm_randomize_children_process($scoid,$userid){
|
||||
global $DB;
|
||||
|
||||
$sco = scorm_get_sco($scoid);
|
||||
if (!scorm_is_leaf($sco)){
|
||||
if(!scorm_seq_is('suspended',$scoid,$userid) && !scorm_seq_is('active',$scoid,$userid)){
|
||||
$r = get_record('scorm_scoes_track','scoid',$scoid,'userid',$userid,'element','randomizationtiming');
|
||||
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$scoid,'userid'=>$userid,'element'=>'randomizationtiming'));
|
||||
|
||||
switch($r->value) {
|
||||
|
||||
|
||||
+26
-26
@@ -230,7 +230,7 @@ function scorm_user_outline($course, $user, $mod, $scorm) {
|
||||
* @return boolean
|
||||
*/
|
||||
function scorm_user_complete($course, $user, $mod, $scorm) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$liststyle = 'structlist';
|
||||
$scormpixdir = $CFG->modpixpath.'/scorm/pix';
|
||||
@@ -240,22 +240,23 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
|
||||
$sometoreport = false;
|
||||
$report = '';
|
||||
|
||||
if ($orgs = get_records_select('scorm_scoes',"scorm='$scorm->id' AND organization='' AND launch=''",'id','id,identifier,title')) {
|
||||
if ($orgs = $DB->get_records('scorm_scoes', array('scorm'=>$scorm->id, 'organization'=>'', 'launch'=>''),'id','id,identifier,title')) {
|
||||
if (count($orgs) <= 1) {
|
||||
unset($orgs);
|
||||
$orgs[]->identifier = '';
|
||||
}
|
||||
$report .= '<div class="mod-scorm">'."\n";
|
||||
foreach ($orgs as $org) {
|
||||
$organizationsql = '';
|
||||
$conditions = array();
|
||||
$currentorg = '';
|
||||
if (!empty($org->identifier)) {
|
||||
$report .= '<div class="orgtitle">'.$org->title.'</div>';
|
||||
$currentorg = $org->identifier;
|
||||
$organizationsql = "AND organization='$currentorg'";
|
||||
$conditions['organization'] = $currentorg;
|
||||
}
|
||||
$report .= "<ul id='0' class='$liststyle'>";
|
||||
if ($scoes = get_records_select('scorm_scoes',"scorm='$scorm->id' $organizationsql order by id ASC")){
|
||||
$conditions['scorm'] = $scorm->id;
|
||||
if ($scoes = $DB->get_records('scorm_scoes', $conditions, "id ASC")){
|
||||
// drop keys so that we can access array sequentially
|
||||
$scoes = array_values($scoes);
|
||||
$level=0;
|
||||
@@ -369,8 +370,7 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
|
||||
* @return boolean
|
||||
*/
|
||||
function scorm_cron () {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
require_once('locallib.php');
|
||||
|
||||
@@ -389,7 +389,7 @@ function scorm_cron () {
|
||||
|
||||
mtrace('Updating scorm packages which require daily update');//We are updating
|
||||
|
||||
$scormsupdate = get_records('scorm','updatefreq',UPDATE_EVERYDAY);
|
||||
$scormsupdate = $DB->get_records('scorm', array('updatefreq'=>UPDATE_EVERYDAY));
|
||||
if (!empty($scormsupdate)) {
|
||||
foreach($scormsupdate as $scormupdate) {
|
||||
$scormupdate->instance = $scormupdate->id;
|
||||
@@ -409,12 +409,12 @@ function scorm_cron () {
|
||||
* @return array array of grades, false if none
|
||||
*/
|
||||
function scorm_get_user_grades($scorm, $userid=0) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
require_once('locallib.php');
|
||||
|
||||
$grades = array();
|
||||
if (empty($userid)) {
|
||||
if ($scousers = get_records_select('scorm_scoes_track', "scormid='$scorm->id' GROUP BY userid", "", "userid,null")) {
|
||||
if ($scousers = $DB->get_records_select('scorm_scoes_track', "scormid=? GROUP BY userid", array($scorm->id), "", "userid,null")) {
|
||||
foreach ($scousers as $scouser) {
|
||||
$grades[$scouser->userid] = new object();
|
||||
$grades[$scouser->userid]->id = $scouser->userid;
|
||||
@@ -426,7 +426,7 @@ function scorm_get_user_grades($scorm, $userid=0) {
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!get_records_select('scorm_scoes_track', "scormid='$scorm->id' AND userid='$userid' GROUP BY userid", "", "userid,null")) {
|
||||
if (!$DB->get_records_select('scorm_scoes_track', "scormid=? AND userid=? GROUP BY userid", array($scorm->id, $userid), "", "userid,null")) {
|
||||
return false; //no attempt yet
|
||||
}
|
||||
$grades[$userid] = new object();
|
||||
@@ -445,7 +445,7 @@ function scorm_get_user_grades($scorm, $userid=0) {
|
||||
* @param int $userid specific user only, 0 mean all
|
||||
*/
|
||||
function scorm_update_grades($scorm=null, $userid=0, $nullifnone=true) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
if (!function_exists('grade_update')) { //workaround for buggy PHP versions
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
}
|
||||
@@ -466,13 +466,13 @@ function scorm_update_grades($scorm=null, $userid=0, $nullifnone=true) {
|
||||
|
||||
} else {
|
||||
$sql = "SELECT s.*, cm.idnumber as cmidnumber
|
||||
FROM {$CFG->prefix}scorm s, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m
|
||||
FROM {scorm} s, {course_modules} cm, {modules} m
|
||||
WHERE m.name='scorm' AND m.id=cm.module AND cm.instance=s.id";
|
||||
if ($rs = get_recordset_sql($sql)) {
|
||||
while ($scorm = rs_fetch_next_record($rs)) {
|
||||
if ($rs = $DB->get_recordset_sql($sql)) {
|
||||
foreach ($rs as $scorm) {
|
||||
scorm_update_grades($scorm, 0, false);
|
||||
}
|
||||
rs_close($rs);
|
||||
$rs->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -485,7 +485,7 @@ function scorm_update_grades($scorm=null, $userid=0, $nullifnone=true) {
|
||||
* @return object grade_item
|
||||
*/
|
||||
function scorm_grade_item_update($scorm, $grades=NULL) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
if (!function_exists('grade_update')) { //workaround for buggy PHP versions
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
}
|
||||
@@ -493,7 +493,7 @@ function scorm_grade_item_update($scorm, $grades=NULL) {
|
||||
$params = array('itemname'=>$scorm->name, 'idnumber'=>$scorm->cmidnumber);
|
||||
|
||||
if (($scorm->grademethod % 10) == 0) { // GRADESCOES
|
||||
if ($maxgrade = count_records_select('scorm_scoes',"scorm='$scorm->id' AND launch<>''")) {
|
||||
if ($maxgrade = $DB->count_records_select('scorm_scoes',"scorm=? AND launch<>''", array($scorm->id))) {
|
||||
$params['gradetype'] = GRADE_TYPE_VALUE;
|
||||
$params['grademax'] = $maxgrade;
|
||||
$params['grademin'] = 0;
|
||||
@@ -581,13 +581,13 @@ function scorm_reset_course_form_defaults($course) {
|
||||
* @param string optional type
|
||||
*/
|
||||
function scorm_reset_gradebook($courseid, $type='') {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$sql = "SELECT s.*, cm.idnumber as cmidnumber, s.course as courseid
|
||||
FROM {$CFG->prefix}scorm s, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m
|
||||
WHERE m.name='scorm' AND m.id=cm.module AND cm.instance=s.id AND s.course=$courseid";
|
||||
FROM {scorm} s, {course_modules} cm, {modules} m
|
||||
WHERE m.name='scorm' AND m.id=cm.module AND cm.instance=s.id AND s.course=?";
|
||||
|
||||
if ($scorms = get_records_sql($sql)) {
|
||||
if ($scorms = $DB->get_records_sql($sql, array($courseid))) {
|
||||
foreach ($scorms as $scorm) {
|
||||
scorm_grade_item_update($scorm, 'reset');
|
||||
}
|
||||
@@ -601,17 +601,17 @@ function scorm_reset_gradebook($courseid, $type='') {
|
||||
* @return array status array
|
||||
*/
|
||||
function scorm_reset_userdata($data) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$componentstr = get_string('modulenameplural', 'scorm');
|
||||
$status = array();
|
||||
|
||||
if (!empty($data->reset_scorm)) {
|
||||
$scormssql = "SELECT s.id
|
||||
FROM {$CFG->prefix}scorm s
|
||||
WHERE s.course={$data->courseid}";
|
||||
FROM {scorm} s
|
||||
WHERE s.course=?";
|
||||
|
||||
delete_records_select('scorm_scoes_track', "scormid IN ($scormssql)");
|
||||
$DB->delete_records_select('scorm_scoes_track', "scormid IN ($scormssql)", array($data->courseid));
|
||||
|
||||
// remove all grades from gradebook
|
||||
if (empty($data->reset_gradebook_grades)) {
|
||||
|
||||
@@ -12,17 +12,17 @@
|
||||
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
|
||||
print_error('Course Module ID was incorrect');
|
||||
}
|
||||
if (! $course = get_record('course', 'id', $cm->course)) {
|
||||
if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||
print_error('Course is misconfigured');
|
||||
}
|
||||
if (! $scorm = get_record('scorm', 'id', $cm->instance)) {
|
||||
if (! $scorm = $DB->get_record('scorm', array('id'=>$cm->instance))) {
|
||||
print_error('Course module is incorrect');
|
||||
}
|
||||
} else if (!empty($a)) {
|
||||
if (! $scorm = get_record('scorm', 'id', $a)) {
|
||||
if (! $scorm = $DB->get_record('scorm', array('id'=>$a))) {
|
||||
print_error('Course module is incorrect');
|
||||
}
|
||||
if (! $course = get_record('course', 'id', $scorm->course)) {
|
||||
if (! $course = $DB->get_record('course', array('id'=>$scorm->course))) {
|
||||
print_error('Course is misconfigured');
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
|
||||
@@ -40,7 +40,7 @@
|
||||
if ($sco = scorm_get_sco($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')) {
|
||||
if ($scoes = $DB->get_records_select('scorm_scoes',"scorm=? AND launch<>'' AND id>?",array($scorm->id, $sco->id), 'id ASC')) {
|
||||
$sco = current($scoes);
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@
|
||||
// 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');
|
||||
$scoes = $DB->get_records_select('scorm_scoes',"scorm=? AND launch<>''", array($scorm->id),'id ASC');
|
||||
$sco = current($scoes);
|
||||
}
|
||||
|
||||
|
||||
+53
-38
@@ -186,13 +186,15 @@ function scorm_external_link($link) {
|
||||
*/
|
||||
|
||||
function scorm_get_sco($id,$what=SCO_ALL) {
|
||||
if ($sco = get_record('scorm_scoes','id',$id)) {
|
||||
global $DB;
|
||||
|
||||
if ($sco = $DB->get_record('scorm_scoes', array('id'=>$id))) {
|
||||
$sco = ($what == SCO_DATA) ? new stdClass() : $sco;
|
||||
if (($what != SCO_ONLY) && ($scodatas = get_records('scorm_scoes_data','scoid',$id))) {
|
||||
if (($what != SCO_ONLY) && ($scodatas = $DB->get_records('scorm_scoes_data', array('scoid'=>$id)))) {
|
||||
foreach ($scodatas as $scodata) {
|
||||
$sco->{$scodata->name} = $scodata->value;
|
||||
}
|
||||
} else if (($what != SCO_ONLY) && (!($scodatas = get_records('scorm_scoes_data','scoid',$id)))) {
|
||||
} else if (($what != SCO_ONLY) && (!($scodatas = $DB->get_records('scorm_scoes_data', array('scoid'=>$id))))) {
|
||||
$sco->parameters = '';
|
||||
}
|
||||
return $sco;
|
||||
@@ -201,25 +203,27 @@ function scorm_get_sco($id,$what=SCO_ALL) {
|
||||
}
|
||||
}
|
||||
function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value) {
|
||||
global $DB;
|
||||
|
||||
$id = null;
|
||||
if ($track = get_record_select('scorm_scoes_track',"userid='$userid' AND scormid='$scormid' AND scoid='$scoid' AND attempt='$attempt' AND element='$element'")) {
|
||||
if ($track = $DB->get_record('scorm_scoes_track',array('userid'=>$userid, 'scormid'=>$scormid, 'scoid'=>$scoid, 'attempt'=>$attempt, 'element'=>$element))) {
|
||||
$track->value = $value;
|
||||
$track->timemodified = time();
|
||||
$id = update_record('scorm_scoes_track',$track);
|
||||
$id = $DB->update_record('scorm_scoes_track',$track);
|
||||
} else {
|
||||
$track->userid = $userid;
|
||||
$track->scormid = $scormid;
|
||||
$track->scoid = $scoid;
|
||||
$track->attempt = $attempt;
|
||||
$track->element = $element;
|
||||
$track->value = addslashes($value);
|
||||
$track->value = $value;
|
||||
$track->timemodified = time();
|
||||
$id = insert_record('scorm_scoes_track',$track);
|
||||
$id = $DB->insert_record('scorm_scoes_track',$track);
|
||||
}
|
||||
|
||||
// MDL-9552, update the gradebook everything raw score is sent
|
||||
if (strstr($element, '.score.raw')) {
|
||||
$scorm = get_record('scorm', 'id', $scormid);
|
||||
$scorm = $DB->get_record('scorm', array('id'=>$scormid));
|
||||
include_once('lib.php');
|
||||
scorm_update_grades($scorm, $userid);
|
||||
}
|
||||
@@ -229,17 +233,16 @@ function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value) {
|
||||
|
||||
function scorm_get_tracks($scoid,$userid,$attempt='') {
|
||||
/// Gets all tracks of specified sco and user
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
if (empty($attempt)) {
|
||||
if ($scormid = get_field('scorm_scoes','scorm','id',$scoid)) {
|
||||
if ($scormid = $DB->get_field('scorm_scoes','scorm', array('id'=>$scoid))) {
|
||||
$attempt = scorm_get_last_attempt($scormid,$userid);
|
||||
} else {
|
||||
$attempt = 1;
|
||||
}
|
||||
}
|
||||
$attemptsql = ' AND attempt=' . $attempt;
|
||||
if ($tracks = get_records_select('scorm_scoes_track',"userid=$userid AND scoid=$scoid".$attemptsql,'element ASC')) {
|
||||
if ($tracks = $DB->get_records('scorm_scoes_track', array('userid'=>$userid, 'scoid'=>$scoid, 'attempt'=>$attempt),'element ASC')) {
|
||||
$usertrack->userid = $userid;
|
||||
$usertrack->scoid = $scoid;
|
||||
// Defined in order to unify scorm1.2 and scorm2004
|
||||
@@ -283,13 +286,15 @@ function scorm_get_tracks($scoid,$userid,$attempt='') {
|
||||
}
|
||||
|
||||
function scorm_get_user_data($userid) {
|
||||
global $DB;
|
||||
/// Gets user info required to display the table of scorm results
|
||||
/// for report.php
|
||||
|
||||
return get_record('user','id',$userid,'','','','','firstname, lastname, picture');
|
||||
return $DB->get_record('user', array('id'=>$userid),'firstname, lastname, picture');
|
||||
}
|
||||
|
||||
function scorm_grade_user_attempt($scorm, $userid, $attempt=1, $time=false) {
|
||||
global $DB;
|
||||
$attemptscore = NULL;
|
||||
$attemptscore->scoes = 0;
|
||||
$attemptscore->values = 0;
|
||||
@@ -297,7 +302,7 @@ function scorm_grade_user_attempt($scorm, $userid, $attempt=1, $time=false) {
|
||||
$attemptscore->sum = 0;
|
||||
$attemptscore->lastmodify = 0;
|
||||
|
||||
if (!$scoes = get_records('scorm_scoes','scorm',$scorm->id)) {
|
||||
if (!$scoes = $DB->get_records('scorm_scoes', array('scorm'=>$scorm->id))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -416,16 +421,22 @@ function scorm_grade_user($scorm, $userid, $time=false) {
|
||||
}
|
||||
|
||||
function scorm_count_launchable($scormid,$organization='') {
|
||||
$strorganization = '';
|
||||
global $DB;
|
||||
|
||||
$sqlorganization = '';
|
||||
$params = array($scormid);
|
||||
if (!empty($organization)) {
|
||||
$strorganization = " AND organization='$organization'";
|
||||
$sqlorganization = " AND organization=?";
|
||||
$params[] = $organization;
|
||||
}
|
||||
return count_records_select('scorm_scoes',"scorm=$scormid$strorganization AND launch<>''");
|
||||
return $DB->count_records_select('scorm_scoes',"scorm=$scormid $sqlorganization AND launch<>''", $params);
|
||||
}
|
||||
|
||||
function scorm_get_last_attempt($scormid, $userid) {
|
||||
global $DB;
|
||||
|
||||
/// Find the last attempt number for the given user id and scorm id
|
||||
if ($lastattempt = get_record('scorm_scoes_track', 'userid', $userid, 'scormid', $scormid, '', '', 'max(attempt) as a')) {
|
||||
if ($lastattempt = $DB->get_record('scorm_scoes_track', array('userid'=>$userid, 'scormid'=>$scormid), 'max(attempt) as a')) {
|
||||
if (empty($lastattempt->a)) {
|
||||
return '1';
|
||||
} else {
|
||||
@@ -435,7 +446,7 @@ function scorm_get_last_attempt($scormid, $userid) {
|
||||
}
|
||||
|
||||
function scorm_course_format_display($user,$course) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$strupdate = get_string('update');
|
||||
$strmodule = get_string('modulename','scorm');
|
||||
@@ -460,7 +471,7 @@ function scorm_course_format_display($user,$course) {
|
||||
}
|
||||
$headertext .= '</td>';
|
||||
// Display report link
|
||||
$trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
|
||||
$trackedusers = $DB->get_record('scorm_scoes_track', array('scormid'=>$scorm->id), 'count(distinct(userid)) as c');
|
||||
if ($trackedusers->c > 0) {
|
||||
$headertext .= '<td class="reportlink">'.
|
||||
'<a '.$CFG->frametarget.'" href="'.$CFG->wwwroot.'/mod/scorm/report.php?id='.$cm->id.'">'.
|
||||
@@ -526,7 +537,7 @@ function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') {
|
||||
|
||||
/*
|
||||
$orgidentifier = '';
|
||||
if ($org = get_record('scorm_scoes','id',$organization)) {
|
||||
if ($org = $DB->get_record('scorm_scoes', array('id'=>$organization))) {
|
||||
if (($org->organization == '') && ($org->launch == '')) {
|
||||
$orgidentifier = $org->identifier;
|
||||
} else {
|
||||
@@ -574,9 +585,11 @@ function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') {
|
||||
<?php
|
||||
}
|
||||
function scorm_simple_play($scorm,$user) {
|
||||
global $DB;
|
||||
|
||||
$result = false;
|
||||
|
||||
$scoes = get_records_select('scorm_scoes','scorm='.$scorm->id.' AND launch<>\'\'');
|
||||
$scoes = $DB->get_records_select('scorm_scoes', 'scorm=? AND launch<>\'\'', array($scorm->id));
|
||||
|
||||
if ($scoes && (count($scoes) == 1)) {
|
||||
if ($scorm->skipview >= 1) {
|
||||
@@ -594,8 +607,9 @@ function scorm_simple_play($scorm,$user) {
|
||||
}
|
||||
/*
|
||||
function scorm_simple_play($scorm,$user) {
|
||||
global $DB;
|
||||
$result = false;
|
||||
if ($scoes = get_records_select('scorm_scoes','scorm='.$scorm->id.' AND launch<>""')) {
|
||||
if ($scoes = $DB->get_records_select('scorm_scoes','scorm=? AND launch<>""', array($scorm->id))) {
|
||||
if (count($scoes) == 1) {
|
||||
if ($scorm->skipview >= 1) {
|
||||
$sco = current($scoes);
|
||||
@@ -688,7 +702,7 @@ function scorm_validate_aicc($packagedir) {
|
||||
|
||||
|
||||
function scorm_validate($data) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$validation = new stdClass();
|
||||
$validation->errors = array();
|
||||
@@ -710,7 +724,7 @@ function scorm_validate($data) {
|
||||
$scormid = $data['instance']; // scorm ID
|
||||
$scorm = new stdClass();
|
||||
if (!empty($scormid)) {
|
||||
if (!$scorm = get_record('scorm','id',$scormid)) {
|
||||
if (!$scorm = $DB->get_record('scorm', array('id'=>$scormid))) {
|
||||
$validation->errors['reference'] = get_string('missingparam','scorm');
|
||||
$validation->result = false;
|
||||
return $validation;
|
||||
@@ -718,7 +732,7 @@ function scorm_validate($data) {
|
||||
}
|
||||
|
||||
if ($reference[0] == '#') {
|
||||
require_once($repositoryconfigfile);
|
||||
require_once($repositoryconfigfile); // TODO: undefined
|
||||
if ($CFG->repositoryactivate) {
|
||||
$reference = $CFG->repository.substr($reference,1).'/imsmanifest.xml';
|
||||
} else {
|
||||
@@ -794,7 +808,7 @@ function scorm_validate($data) {
|
||||
}
|
||||
|
||||
function scorm_check_package($data) {
|
||||
global $CFG, $COURSE;
|
||||
global $CFG, $COURSE, $DB;
|
||||
|
||||
$courseid = $data->course; // Course Module ID
|
||||
$reference = $data->reference; // Package path
|
||||
@@ -810,7 +824,7 @@ function scorm_check_package($data) {
|
||||
if (empty($reference)) {
|
||||
$validation = null;
|
||||
} else if ($reference[0] == '#') {
|
||||
require_once($repositoryconfigfile);
|
||||
require_once($repositoryconfigfile); // TODO: undefined
|
||||
if ($CFG->repositoryactivate) {
|
||||
$referencefield = $reference.'/imsmanfest.xml';
|
||||
$reference = $CFG->repository.substr($reference,1).'/imsmanifest.xml';
|
||||
@@ -839,7 +853,7 @@ function scorm_check_package($data) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($scorm = get_record('scorm','id',$scormid)) {
|
||||
if ($scorm = $DB->get_record('scorm', array('id'=>$scormid))) {
|
||||
if ($scorm->reference[0] == '#') {
|
||||
require_once($repositoryconfigfile);
|
||||
if ($CFG->repositoryactivate) {
|
||||
@@ -951,24 +965,25 @@ function scorm_check_package($data) {
|
||||
|
||||
|
||||
function scorm_get_count_users($scormid, $groupingid=null) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
if (!empty($CFG->enablegroupings) && !empty($groupingid)) {
|
||||
$sql = "SELECT COUNT(DISTINCT st.userid)
|
||||
FROM {$CFG->prefix}scorm_scoes_track st
|
||||
INNER JOIN {$CFG->prefix}groups_members gm ON st.userid = gm.userid
|
||||
INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = gg.groupid
|
||||
WHERE st.scormid = $scormid AND gg.groupingid = $groupingid
|
||||
FROM {scorm_scoes_track} st
|
||||
INNER JOIN {groups_members} gm ON st.userid = gm.userid
|
||||
INNER JOIN {groupings_groups} gg ON gm.groupid = gg.groupid
|
||||
WHERE st.scormid = ? AND gg.groupingid = ?
|
||||
";
|
||||
$params = array($scormid, $groupingid);
|
||||
} else {
|
||||
$sql = "SELECT COUNT(DISTINCT st.userid)
|
||||
FROM {$CFG->prefix}scorm_scoes_track st
|
||||
WHERE st.scormid = $scormid
|
||||
FROM {scorm_scoes_track} st
|
||||
WHERE st.scormid = ?
|
||||
";
|
||||
$params = array($scormid);
|
||||
}
|
||||
|
||||
return(count_records_sql($sql));
|
||||
return ($DB->count_records_sql($sql, $params));
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -18,17 +18,17 @@
|
||||
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
|
||||
print_error("Course Module ID was incorrect");
|
||||
}
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error("Course is misconfigured");
|
||||
}
|
||||
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
|
||||
if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
|
||||
print_error("Course module is incorrect");
|
||||
}
|
||||
} else if (!empty($a)) {
|
||||
if (! $scorm = get_record("scorm", "id", $a)) {
|
||||
if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
|
||||
print_error("Course module is incorrect");
|
||||
}
|
||||
if (! $course = get_record("course", "id", $scorm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
|
||||
print_error("Course is misconfigured");
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
|
||||
|
||||
+18
-15
@@ -15,24 +15,24 @@
|
||||
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
|
||||
print_error('Course Module ID was incorrect');
|
||||
}
|
||||
if (! $course = get_record('course', 'id', $cm->course)) {
|
||||
if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||
print_error('Course is misconfigured');
|
||||
}
|
||||
if (! $scorm = get_record('scorm', 'id', $cm->instance)) {
|
||||
if (! $scorm = $DB->get_record('scorm', array('id'=>$cm->instance))) {
|
||||
print_error('Course module is incorrect');
|
||||
}
|
||||
} else {
|
||||
if (!empty($b)) {
|
||||
if (! $sco = get_record('scorm_scoes', 'id', $b)) {
|
||||
if (! $sco = $DB->get_record('scorm_scoes', array('id'=>$b))) {
|
||||
print_error('Scorm activity is incorrect');
|
||||
}
|
||||
$a = $sco->scorm;
|
||||
}
|
||||
if (!empty($a)) {
|
||||
if (! $scorm = get_record('scorm', 'id', $a)) {
|
||||
if (! $scorm = $DB->get_record('scorm', array('id'=>$a))) {
|
||||
print_error('Course module is incorrect');
|
||||
}
|
||||
if (! $course = get_record('course', 'id', $scorm->course)) {
|
||||
if (! $course = $DB->get_record('course', array('id'=>$scorm->course))) {
|
||||
print_error('Course is misconfigured');
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
|
||||
@@ -101,21 +101,23 @@
|
||||
|
||||
if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
|
||||
$sql = "SELECT st.userid, st.scormid
|
||||
FROM {$CFG->prefix}scorm_scoes_track st
|
||||
INNER JOIN {$CFG->prefix}groups_members gm ON st.userid = gm.userid
|
||||
INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = gg.groupid
|
||||
WHERE st.scormid = {$scorm->id} AND gg.groupingid = {$cm->groupingid}
|
||||
FROM {scorm_scoes_track} st
|
||||
INNER JOIN {groups_members} gm ON st.userid = gm.userid
|
||||
INNER JOIN {groupings_groups} gg ON gm.groupid = gg.groupid
|
||||
WHERE st.scormid = ? AND gg.groupingid = ?
|
||||
GROUP BY st.userid,st.scormid
|
||||
";
|
||||
$params = array($scorm->id, $cm->groupingid);
|
||||
} else {
|
||||
$sql = "SELECT st.userid, st.scormid
|
||||
FROM {$CFG->prefix}scorm_scoes_track st
|
||||
WHERE st.scormid = {$scorm->id}
|
||||
FROM {scorm_scoes_track} st
|
||||
WHERE st.scormid = ?
|
||||
GROUP BY st.userid,st.scormid
|
||||
";
|
||||
$params = array($scorm->id);
|
||||
}
|
||||
|
||||
if ($scousers=get_records_sql($sql)) {
|
||||
if ($scousers=$DB->get_records_sql($sql, $params)) {
|
||||
$table = new stdClass();
|
||||
$table->head = array(' ', get_string('name'));
|
||||
$table->align = array('center', 'left');
|
||||
@@ -152,8 +154,9 @@
|
||||
$row[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$scouser->userid.'&course='.$course->id.'">'.
|
||||
fullname($userdata).'</a>';
|
||||
$row[] = '<a href="report.php?a='.$scorm->id.'&user='.$scouser->userid.'&attempt='.$a.'">'.$a.'</a>';
|
||||
$select = 'scormid = '.$scorm->id.' and userid = '.$scouser->userid.' and attempt = '.$a;
|
||||
$timetracks = get_record_select('scorm_scoes_track', $select,'min(timemodified) as started, max(timemodified) as last');
|
||||
$select = 'scormid = ? and userid = ? and attempt = ?';
|
||||
$params = array($scorm->id, $scouser->userid, $a);
|
||||
$timetracks = $DB->get_record_select('scorm_scoes_track', $select, $params, 'min(timemodified) as started, max(timemodified) as last');
|
||||
$row[] = userdate($timetracks->started, get_string('strftimedaydatetime'));
|
||||
$row[] = userdate($timetracks->last, get_string('strftimedaydatetime'));
|
||||
|
||||
@@ -166,7 +169,7 @@
|
||||
} else {
|
||||
if (!empty($user)) {
|
||||
// User SCORM report
|
||||
if ($scoes = get_records_select('scorm_scoes',"scorm='$scorm->id' ORDER BY id")) {
|
||||
if ($scoes = $DB->get_records_select('scorm_scoes',"scorm=? ORDER BY id", array($scorm->id))) {
|
||||
if (!empty($userdata)) {
|
||||
print_simple_box_start('center');
|
||||
echo '<div align="center">'."\n";
|
||||
|
||||
+4
-4
@@ -11,17 +11,17 @@
|
||||
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
|
||||
print_error("Course Module ID was incorrect");
|
||||
}
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error("Course is misconfigured");
|
||||
}
|
||||
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
|
||||
if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
|
||||
print_error("Course module is incorrect");
|
||||
}
|
||||
} else if (!empty($a)) {
|
||||
if (! $scorm = get_record("scorm", "id", $a)) {
|
||||
if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
|
||||
print_error("Course module is incorrect");
|
||||
}
|
||||
if (! $course = get_record("course", "id", $scorm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
|
||||
print_error("Course is misconfigured");
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
|
||||
|
||||
Reference in New Issue
Block a user