[svn r15312] Fixed score recording for HotPotatoes and Dokeos exercises in Dokeos learning paths by adding max-score to parameters sent from the exercises tool - see FS#2493

skala
Yannick Warnier 18 years ago
parent 7c89705d9d
commit 18a911ec62
  1. 5
      main/exercice/exercise_result.php
  2. 5
      main/exercice/savescores.php
  3. 30
      main/newscorm/learnpathItem.class.php
  4. 15
      main/newscorm/lp_comm.server.php
  5. 7
      main/newscorm/scorm_api.php

@ -25,7 +25,7 @@
* @package dokeos.exercise
* @author Olivier Brouckaert, main author
* @author Roan Embrechts, some refactoring
* @version $Id: exercise_result.php 15310 2008-05-18 23:08:33Z yannoo $
* @version $Id: exercise_result.php 15312 2008-05-19 01:15:03Z yannoo $
*
* @todo split more code up in functions, move functions to library?
*/
@ -875,7 +875,8 @@ if ($origin != 'learnpath')
//we are not in learnpath tool
Display::display_footer();
}else{
echo '<script language="javascript" type="text/javascript">window.parent.API.void_save_asset('.$totalScore.');</script>';
//record the results in the learning path, using the SCORM interface (API)
echo '<script language="javascript" type="text/javascript">window.parent.API.void_save_asset('.$totalScore.','.$totalWeighting.');</script>'."\n";
echo '</body></html>';
}
$send_email = api_get_course_setting('email_alert_manager_on_new_quiz');

@ -22,7 +22,7 @@
* Saving the scores.
* @package dokeos.exercise
* @author
* @version $Id: savescores.php 13988 2007-12-14 05:05:51Z yannoo $
* @version $Id: savescores.php 15312 2008-05-19 01:15:03Z yannoo $
*/
// name of the language file that needs to be included
@ -103,7 +103,8 @@ function save_scores($file, $score)
//if we are in a learning path, save the score in the corresponding
//table to get tracking in there as well
global $jscript2run;
$jscript2run .= '<script language="javascript" type="text/javascript">window.parent.API.void_save_asset('.$score.');</script>';
//record the results in the learning path, using the SCORM interface (API)
$jscript2run .= '<script language="javascript" type="text/javascript">window.parent.API.void_save_asset('.$score.','.$weighting.');</script>';
}
}

@ -870,30 +870,10 @@ class learnpathItem{
function get_score(){
if($this->debug>0){error_log('New LP - In learnpathItem::get_score()',0);}
$res = 0;
if($this->type == 'quiz'){
//get score directly from db and update current
$item_view_table = Database::get_course_table('lp_item_view');
$check = "SELECT * FROM $item_view_table " .
"WHERE lp_item_id = ".$this->db_id. " " .
"AND lp_view_id = ".$this->view_id. " ".
"AND view_count = ".$this->get_attempt_id();
$resq = api_sql_query($check,__FILE__,__LINE__);
if(Database::num_rows($resq)>0){
$row = Database::fetch_array($resq);
if(!empty($row['score'])){
//update current object score
$this->current_score = $row['score'];
$res = $this->current_score;
}
}
}else{
if(!empty($this->current_score))
{
$res = $this->current_score;
}
}
//TODO check this return value is valid for children classes (SCORM?)
if(!empty($this->current_score))
{
$res = $this->current_score;
}
if($this->debug>1){error_log('New LP - Out of learnpathItem::get_score() - returning '.$res,0);}
return $res;
}
@ -1617,7 +1597,6 @@ class learnpathItem{
}
break;
case TOOL_HOTPOTATOES:
break;
case TOOL_QUIZ:
default:
//for now, everything that is not sco and not asset is set to
@ -2069,6 +2048,7 @@ class learnpathItem{
$sql = "UPDATE $item_view_table " .
"SET total_time = ".$this->get_total_time().", " .
" start_time = ".$this->get_current_start_time().", " .
" score = ".$this->get_score().", " .
" status = '".$this->get_status(false)."'," .
" max_score = '".$this->get_max()."'," .
" suspend_data = '".Database::escape_string($this->current_data)."'," .

@ -62,7 +62,7 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
{
global $_configuration;
$debug=0;
if($debug>0){error_log('In xajax_save_item('.$lp_id.','.$user_id.','.$view_id.','.$item_id.','.$score.','.$max.','.$min.','.$status.','.$time.',"'.$suspend.'","'.$location.'","'.(count($interactions)>0?$interactions[0]:'').'","'.$core_exit.'")',0);}
if($debug>0){error_log('In xajax_save_item('.$lp_id.','.$user_id.','.$view_id.','.$item_id.','.$score.','.$max.','.$min.',"'.$status.'",'.$time.',"'.$suspend.'","'.$location.'","'.(count($interactions)>0?$interactions[0]:'').'","'.$core_exit.'")',0);}
$objResponse = new xajaxResponse();
require_once('learnpath.class.php');
require_once('scorm.class.php');
@ -95,15 +95,18 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
$mylpi =& $mylp->items[$item_id];
//$mylpi->set_lp_view($view_id);
if($score!=-1){
$mylpi->set_score($score);
}
if($max!=-1){
if($max!=-1)
{
$mylpi->max_score=$max;
}
if($min!=-1){
if($min!=-1)
{
$mylpi->min_score=$min;
}
if($score!=-1)
{
$mylpi->set_score($score);
}
if($status!='')
{
if($debug>1){error_log('Calling set_status('.$status.') from xajax',0);}

@ -1,4 +1,4 @@
<?php // $Id: scorm_api.php 14952 2008-04-20 01:37:51Z yannoo $
<?php // $Id: scorm_api.php 15312 2008-05-19 01:15:03Z yannoo $
/*
==============================================================================
Dokeos - elearning and course management software
@ -793,11 +793,12 @@ function dokeos_save_asset(){
* Also save the score locally because it hasn't been done through SetValue().
* Saving the status will be dealt with by the XAJAX function.
*/
function dokeos_void_save_asset(myscore)
function dokeos_void_save_asset(myscore,mymax)
{
logit_lms('dokeos_save_asset',2);
score = myscore;
xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, myscore);
if((mymax == null) || (mymax == '')){mymax = 100;} //assume a default of 100, otherwise the score will not get saved (see lpi->set_score())
xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, myscore, mymax);
}
/**
* Logs information about SCORM messages into the log frame

Loading…
Cancel
Save