diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 7d63349f04..5b472168f1 100644 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -416,21 +416,31 @@ class learnpath { $id = $this->escape_string($id); if($type == 'quiz') - { - $sql = 'SELECT SUM(ponderation) + { + $sql = 'SELECT SUM(ponderation) FROM '.Database :: get_course_table(TABLE_QUIZ_QUESTION).' as quiz_question INNER JOIN '.Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION).' as quiz_rel_question - ON quiz_question.id = quiz_rel_question.question_id - AND quiz_rel_question.exercice_id = '.$id; - $rsQuiz = api_sql_query($sql, __FILE__, __LINE__); + ON quiz_question.id = quiz_rel_question.question_id + AND quiz_rel_question.exercice_id = '.$id; + + $rsQuiz = api_sql_query($sql, __FILE__, __LINE__); $max_score = Database::result($rsQuiz, 0, 0); + + $sql = 'SELECT random + FROM '.Database :: get_course_table(TABLE_QUIZ_TEST).' as quiz + WHERE quiz.id = '.$id; + + $rsQuizRand = api_sql_query($sql, __FILE__, __LINE__); + $random = Database::result($rsQuizRand, 0, 0); } else { $max_score = 100; + $random=''; } - if($prerequisites!=0){ + if($prerequisites!=0) + { $sql_ins = " INSERT INTO " . $tbl_lp_item . " ( lp_id, @@ -443,8 +453,10 @@ class learnpath { parent_item_id, previous_item_id, next_item_id, - display_order, + display_order, + parameters, prerequisite + ) VALUES ( " . $this->get_id() . ", '" . $type . "', @@ -457,11 +469,12 @@ class learnpath { " . $previous . ", " . $next . ", " . ($display_order + 1) . ", + " .$random.", " . $prerequisites . " )"; - } - - else{ + } + else + { //insert new item $sql_ins = " INSERT INTO " . $tbl_lp_item . " ( @@ -475,6 +488,7 @@ class learnpath { parent_item_id, previous_item_id, next_item_id, + parameters, display_order ) VALUES ( " . $this->get_id() . ", @@ -487,6 +501,7 @@ class learnpath { " . $parent . ", " . $previous . ", " . $next . ", + " .$random.", " . ($display_order + 1) . " )"; } @@ -2358,7 +2373,8 @@ class learnpath { * @param integer Parent ID of the items to look for * @return mixed Ordered list of item IDs or false on error */ - function get_flat_ordered_items_list($lp,$parent=0){ + function get_flat_ordered_items_list($lp,$parent=0) + { //if($this->debug>0){error_log('New LP - In learnpath::get_flat_ordered_items_list('.$lp.','.$parent.')',0);} $list = array(); if(empty($lp)){return false;} diff --git a/main/newscorm/lp_stats.php b/main/newscorm/lp_stats.php index 594b93a560..8a9946d027 100644 --- a/main/newscorm/lp_stats.php +++ b/main/newscorm/lp_stats.php @@ -149,14 +149,15 @@ foreach ($list as $my_item_id) $qry_order = 'ASC'; } //prepare statement to go through each attempt + if (!empty ($view)) { - $sql = "SELECT iv.status as mystatus, v.view_count as mycount, " . + $sql = "SELECT iv.status as mystatus, v.view_count as mycount, " . "iv.score as myscore, iv.total_time as mytime, i.id as myid, " . "i.title as mytitle, i.max_score as mymaxscore, " . "iv.max_score as myviewmaxscore, " . "i.item_type as item_type, iv.view_count as iv_view_count, " . - "iv.id as iv_id, path as path ". + "iv.id as iv_id, path as path, i.parameters". " FROM $TBL_LP_ITEM as i, $TBL_LP_ITEM_VIEW as iv, $TBL_LP_VIEW as v ". " WHERE i.id = iv.lp_item_id ". " AND i.id = $my_item_id ". @@ -165,13 +166,15 @@ foreach ($list as $my_item_id) " AND v.user_id = ".$user_id." ". " AND v.view_count = $view ". " ORDER BY iv.view_count $qry_order "; - } else { + } + else + { $sql = "SELECT iv.status as mystatus, v.view_count as mycount, " . "iv.score as myscore, iv.total_time as mytime, i.id as myid, " . "i.title as mytitle, i.max_score as mymaxscore, " . "iv.max_score as myviewmaxscore, " . "i.item_type as item_type, iv.view_count as iv_view_count, " . - "iv.id as iv_id, path as path ". + "iv.id as iv_id, path as path, i.parameters". " FROM $TBL_LP_ITEM as i, $TBL_LP_ITEM_VIEW as iv, $TBL_LP_VIEW as v ". " WHERE i.id = iv.lp_item_id ". " AND i.id = $my_item_id ". @@ -180,10 +183,11 @@ foreach ($list as $my_item_id) " AND v.user_id = ".$user_id." ". " ORDER BY iv.view_count $qry_order "; } + $result = api_sql_query($sql, __FILE__, __LINE__); $num = Database :: num_rows($result); $time_for_total = 'NaN'; - if (($extend_this OR $extend_all) && $num > 0) + if (($extend_this || $extend_all) && $num > 0) { $row = Database :: fetch_array($result); @@ -258,7 +262,8 @@ foreach ($list as $my_item_id) } } - else{ + else + { $correct_test_link='-'; } //new attempt @@ -293,12 +298,16 @@ foreach ($list as $my_item_id) $time = learnpathItem :: get_scorm_time('js', $row['mytime']); $type; $scoIdentifier = $row['myid']; - if ($score == 0) { + if ($score == 0) + { $maxscore = 0; - } else { + } + else + { if($row['item_type'] == 'sco') { - if(!empty($row['myviewmaxscore']) and $row['myviewmaxscore']>0) + + if(!empty($row['myviewmaxscore']) && $row['myviewmaxscore']>0) { $maxscore=$row['myviewmaxscore']; } @@ -309,11 +318,17 @@ foreach ($list as $my_item_id) else { $maxscore = $row['mymaxscore']; - } + } } else { - $maxscore = $row['mymaxscore']; + // the parameters value is fill with the random value from the table QUIZ is empty or has a value that indicates the quantity of random questions + if ($row['parameters'] != '' && $row['parameters']!=0 ) + { + $maxscore = $row['myviewmaxscore']; + } + else + $maxscore = $row['mymaxscore']; } } //Remove "NaN" if any (@todo: locate the source of these NaN) @@ -326,7 +341,9 @@ foreach ($list as $my_item_id) $mylanglist = array ('completed' => 'ScormCompstatus', 'incomplete' => 'ScormIncomplete', 'failed' => 'ScormFailed', 'passed' => 'ScormPassed', 'browsed' => 'ScormBrowsed', 'not attempted' => 'ScormNotAttempted',); $my_lesson_status = htmlentities(get_lang($mylanglist[$lesson_status]), ENT_QUOTES, $dokeos_charset); //$my_lesson_status = get_lang($mylanglist[$lesson_status]); - if ($row['item_type'] != 'dokeos_chapter') { + + if ($row['item_type'] != 'dokeos_chapter') + { $output .= "\n"."\n"."$extend_attempt_link\n".''.htmlentities(get_lang('Attempt'), ENT_QUOTES, $dokeos_charset).' '.$row['iv_view_count']."\n" //."
".htmlentities($array_status[$lesson_status],ENT_QUOTES,$charset_lang)."
\n" .'
'.$my_lesson_status."
\n".'
'. ($score == 0 ? '-' : ($maxscore==0?$score:$score.'/'.$maxscore))."
\n".'
'.$time."
\n"."\n"; @@ -362,7 +379,9 @@ foreach ($list as $my_item_id) } } } while ($row = Database :: fetch_array($result)); - } elseif($num>0) { + } + elseif($num>0) + { $row = Database :: fetch_array($result); //check if there are interactions below @@ -391,9 +410,12 @@ foreach ($list as $my_item_id) if ($inter_num > 1) { $extend_link = 'extend_view'; } - if (($counter % 2) == 0) { + if (($counter % 2) == 0) + { $oddclass = "row_odd"; - } else { + } + else + { $oddclass = "row_even"; } $lesson_status = $row['mystatus']; @@ -416,7 +438,7 @@ foreach ($list as $my_item_id) $maxscore = 0; } else - { + { if($row['item_type'] == 'sco') { if(!empty($row['myviewmaxscore']) and $row['myviewmaxscore']>0) @@ -434,8 +456,15 @@ foreach ($list as $my_item_id) } else { - $maxscore = $row['mymaxscore']; - } + // the parameters value is fill with the random value from the table QUIZ is empty or has a value that indicates the quantity of random questions + if ($row['parameters'] != '' && $row['parameters']!=0 ) + { + $maxscore = $row['myviewmaxscore']; + } + else + $maxscore = $row['mymaxscore']; + } + } if (empty ($title)) {