[svn r12958] Added code to deal with SCORM 1.2's mastery_score and max_time_allowed. Possibly introducing a risk in calculating the status of the element. If the mastery score has been reached, then the status is changed to "passed" (if not already 'completed').

skala
Yannick Warnier 18 years ago
parent b137515cf0
commit 7e2a86eed7
  1. 37
      main/newscorm/learnpathItem.class.php
  2. 6
      main/newscorm/lp_comm.server.php
  3. 9
      main/newscorm/scorm.class.php
  4. 17
      main/newscorm/scormItem.class.php
  5. 12
      main/newscorm/scorm_api.php

@ -32,7 +32,9 @@ class learnpathItem{
//var $location; //only set this for SCORM?
var $lp_id;
var $max_score;
var $mastery_score;
var $min_score;
var $max_time_allowed = '';
var $name;
var $next;
var $parent;
@ -84,12 +86,13 @@ class learnpathItem{
$this->title = $row['title'];
$this->description = $row['description'];
$this->path = $row['path'];
$this->masteryscore = $row['mastery_score'];
$this->mastery_score = $row['mastery_score'];
$this->parent = $row['parent_item_id'];
$this->next = $row['next_item_id'];
$this->previous = $row['previous_item_id'];
$this->display_order = $row['display_order'];
$this->prereq_string = $row['prerequisite'];
$this->max_time_allowed = $row['max_time_allowed'];
if(isset($row['launch_data'])){
$this->launch_data = $row['launch_data'];
}
@ -390,6 +393,14 @@ class learnpathItem{
if(empty($this->level)){return 0;}
return $this->level;
}
/**
* Gets the mastery score
*/
function get_mastery_score()
{
if($this->debug>0){error_log('New LP - In learnpathItem::get_mastery_score()',0);}
if(isset($this->mastery_score)){return $this->mastery_score;}else{return -1;}
}
/**
* Gets the maximum (score)
* @return int Maximum score. Defaults to 100
@ -398,6 +409,15 @@ class learnpathItem{
if($this->debug>0){error_log('New LP - In learnpathItem::get_max()',0);}
if(!empty($this->max_score)){return $this->max_score;}else{return 100;}
}
/**
* Gets the maximum time allowed for this user in this attempt on this item
* @return string Time string in SCORM format (HH:MM:SS or HH:MM:SS.SS or HHHH:MM:SS.SS)
*/
function get_max_time_allowed()
{
if($this->debug>0){error_log('New LP - In learnpathItem::get_max_time_allowed()',0);}
if(!empty($this->max_time_allowed)){return $this->max_time_allowed;}else{return '';}
}
/**
* Gets the minimum (score)
* @return int Minimum score. Defaults to 0
@ -1338,7 +1358,10 @@ class learnpathItem{
//foreach($interactions as $interaction){
// ;
//}
break;
break;
//case 'maxtimeallowed':
// $this->set_max_time_allowed($value);
// break;
/*
case 'objectives._count':
$this->attempt_id = $value;
@ -1539,6 +1562,13 @@ class learnpathItem{
if(($score <= $this->max_score) && ($score >= $this->min_score))
{
$this->current_score = $score;
$master = $this->get_mastery_score();
$current_status = $this->get_status(false);
//if mastery_score is set AND the current score reaches the mastery score AND the current status is different from 'completed', then set it to 'passed'
if($master != -1 && $this->current_score >= $master && $current_status != $this->possible_status[2])
{
$this->set_status($this->possible_status[3]);
}
return true;
}
return false;
@ -1712,6 +1742,7 @@ class learnpathItem{
"lp_view_id, " .
"view_count, " .
"suspend_data, " .
//"max_time_allowed," .
"lesson_location)" .
"VALUES" .
"(".$this->get_total_time()."," .
@ -1722,6 +1753,7 @@ class learnpathItem{
"".$this->view_id."," .
"".$this->get_attempt_id()."," .
"'".Database::escape_string($this->current_data)."'," .
//"'".$this->get_max_time_allowed()."'," .
"'".$this->lesson_location."')";
if($this->debug>2){error_log('New LP - In learnpathItem::write_to_db() - Inserting into item_view: '.$sql,0);}
$res = api_sql_query($sql,__FILE__,__LINE__);
@ -1749,6 +1781,7 @@ class learnpathItem{
" score = ".$this->get_score().", " .
" status = '".$this->get_status(false)."'," .
" suspend_data = '".Database::escape_string($this->current_data)."'," .
//" max_time_allowed = '".$this->get_max_time_allowed()."'," .
" lesson_location = '".$this->lesson_location."' " .
"WHERE lp_item_id = ".$this->db_id." " .
"AND lp_view_id = ".$this->view_id." " .

@ -263,6 +263,9 @@ function switch_item_details($lp_id,$user_id,$view_id,$current_item,$next_item)
$mylesson_status = $mylpi->get_status();
$mylesson_location = $mylpi->get_lesson_location();
$mytotal_time = $mylpi->get_scorm_time('js');
$mymastery_score = $mylpi->get_mastery_score();
$mymax_time_allowed = $mylpi->get_max_time_allowed();
$mylaunch_data = $mylpi->get_launch_data();
/*
if($mylpi->get_type() == 'asset'){
//temporary measure to save completion of an asset. Later on, Dokeos should trigger something on unload, maybe... (even though that would mean the last item cannot be completed)
@ -284,6 +287,9 @@ function switch_item_details($lp_id,$user_id,$view_id,$current_item,$next_item)
"suspend_data='".$mysuspend_data."';" .
"lesson_location='".$mylesson_location."';" .
"total_time = '".$mytotal_time."';" .
"mastery_score = '".$mymastery_score."';" .
"max_time_allowed = '".$mymax_time_allowed."';" .
"launch_data = '".$mylaunch_data."';" .
"interactions = new Array();" .
"G_lastError = 0;" .
"G_LastErrorMessage = 'No error';");

@ -422,8 +422,13 @@ class scorm extends learnpath {
$field_add = '';
$value_add = '';
if(!empty($item['masteryscore'])){
$field_add = 'mastery_score, ';
$value_add = $item['masteryscore'].',';
$field_add .= 'mastery_score, ';
$value_add .= $item['masteryscore'].',';
}
if(!empty($item['maxtimeallowed']))
{
$field_add .= 'max_time_allowed, ';
$value_add .= "'".$item['maxtimeallowed']."',";
}
$title = mysql_real_escape_string($item['title']);
//if($this->manifest_encoding != 'ISO-8859-1'){

@ -17,10 +17,10 @@ class scormItem extends learnpathItem{
var $sub_items = array();
var $metadata;
//var $prerequisites = ''; - defined in learnpathItem.class.php
var $maxtimeallowed = '00:00:00';
var $max_time_allowed = ''; //should be something like HHHH:MM:SS.SS
var $timelimitaction = '';
var $datafromlms = '';
var $masteryscore = '';
var $mastery_score = '';
var $scorm_contact;
/**
@ -63,7 +63,7 @@ class scormItem extends learnpathItem{
$tmp_children = $child->children();
if(count($tmp_children)==1 and $tmp_children[0]->content!='' )
{
$this->maxtimeallowed = $tmp_children[0]->content;
$this->max_time_allowed = $tmp_children[0]->content;
}
break;
case 'prerequisites':
@ -91,7 +91,7 @@ class scormItem extends learnpathItem{
$tmp_children = $child->children();
if(count($tmp_children)==1 and $tmp_children[0]->content!='' )
{
$this->masteryscore = $tmp_children[0]->content;
$this->mastery_score = $tmp_children[0]->content;
}
break;
case 'item':
@ -165,7 +165,7 @@ class scormItem extends learnpathItem{
//if(count($tmp_children)==1 and $tmp_children[0]->textContent!='' )
if($tmp_children->length==1 and $child->firstChild->nodeValue!='' )
{
$this->maxtimeallowed = $child->firstChild->nodeValue;
$this->max_time_allowed = $child->firstChild->nodeValue;
}
break;
case 'prerequisites':
@ -188,6 +188,7 @@ class scormItem extends learnpathItem{
break;
case 'datafromlms':
case 'adlcp:datafromlms':
case 'adlcp:launchdata': //in some cases (Wouters)
$tmp_children = $child->childNodes;
//if(count($tmp_children)==1 and $tmp_children[0]->textContent!='' )
if($tmp_children->length==1 and $child->firstChild->nodeValue!='' )
@ -201,7 +202,7 @@ class scormItem extends learnpathItem{
//if(count($tmp_children)==1 and $tmp_children[0]->textContent!='' )
if($tmp_children->length==1 and $child->firstChild->nodeValue!='' )
{
$this->masteryscore = $child->firstChild->nodeValue;
$this->mastery_score = $child->firstChild->nodeValue;
}
break;
case 'item':
@ -267,8 +268,8 @@ class scormItem extends learnpathItem{
'identifierref' => $this->identifierref,
'isvisible' => $this->isvisible,
'level' => $level,
'masteryscore' => $this->masteryscore,
'maxtimeallowed' => $this->maxtimeallowed,
'masteryscore' => $this->mastery_score,
'maxtimeallowed' => $this->max_time_allowed,
'metadata' => $this->metadata,
'parameters' => $this->parameters,
'prerequisites' => (!empty($this->prereq_string)?$this->prereq_string:''),

@ -132,6 +132,9 @@ var session_time='<?php echo $oItem->get_scorm_time('js');?>';
var suspend_data = '<?php echo $oItem->get_suspend_data();?>';
var lesson_location = '<?php echo $oItem->get_lesson_location();?>';
var total_time = '<?php echo $oItem->get_scorm_time('js');?>';
var mastery_score = '<?php echo $oItem->get_mastery_score();?>';
var launch_data = '<?php echo $oItem->get_launch_data();?>';
var max_time_allowed = '<?php echo $oItem->get_max_time_allowed();?>';
var interactions = new Array();
//Dokeos internal variables
@ -272,6 +275,12 @@ function LMSGetValue(param) {
result = interactions.length;
}else if(param == 'cmi.interactions._children'){
result = 'id,time,type,correct_responses,weighting,student_response,result,latency';
}else if(param == 'cmi.student_data.mastery_score'){
result = mastery_score;
}else if(param == 'cmi.student_data.launch_data'){
result = launch_data;
}else if(param == 'cmi.student_data.max_time_allowed'){
result = max_time_allowed;
}else{
result = '';
G_lastError = G_NotImplementedError;
@ -409,6 +418,9 @@ function LMSSetValue(param, val) {
case 'cmi.suspend_data' : suspend_data = val;return_value='true';break;
case 'cmi.core.exit' : lms_item_core_exit = val;return_value='true';break;
case 'cmi.core.entry' : G_LastError = G_ElementIsReadOnly; break;
case 'cmi.student_data.mastery_score' : G_LastError = G_ElementIsReadOnly; break;
case 'cmi.student_data.max_time_allowed' : G_LastError = G_ElementIsReadOnly; break;
case 'cmi.launch_data' : G_LastError = G_ElementIsReadOnly; break;
default:
var myres = new Array();
if(myres = param.match(/cmi.interactions.(\d+).(id|time|type|correct_responses|weighting|student_response|result|latency)(.*)/)){

Loading…
Cancel
Save