diff --git a/main/exercice/exercise_result.php b/main/exercice/exercise_result.php index c97c7f97e0..be7f4a63ce 100644 --- a/main/exercice/exercise_result.php +++ b/main/exercice/exercise_result.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 ''; + //record the results in the learning path, using the SCORM interface (API) + echo ''."\n"; echo ''; } $send_email = api_get_course_setting('email_alert_manager_on_new_quiz'); diff --git a/main/exercice/savescores.php b/main/exercice/savescores.php index 976cb8d1af..4edd08520b 100644 --- a/main/exercice/savescores.php +++ b/main/exercice/savescores.php @@ -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 .= ''; + //record the results in the learning path, using the SCORM interface (API) + $jscript2run .= ''; } } diff --git a/main/newscorm/learnpathItem.class.php b/main/newscorm/learnpathItem.class.php index 314fff4d7f..3ed19e4e63 100644 --- a/main/newscorm/learnpathItem.class.php +++ b/main/newscorm/learnpathItem.class.php @@ -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)."'," . diff --git a/main/newscorm/lp_comm.server.php b/main/newscorm/lp_comm.server.php index 6fca304949..758b67bdbe 100644 --- a/main/newscorm/lp_comm.server.php +++ b/main/newscorm/lp_comm.server.php @@ -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);} diff --git a/main/newscorm/scorm_api.php b/main/newscorm/scorm_api.php index 8ce1175af8..7d53450855 100644 --- a/main/newscorm/scorm_api.php +++ b/main/newscorm/scorm_api.php @@ -1,4 +1,4 @@ -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