[svn r15989] The "parameters" field in lp_item table is fill with the random value of a Quiz. see FS#2785

skala
Julio Montoya 18 years ago
parent a168d6b20f
commit e55c87c138
  1. 28
      main/newscorm/learnpath.class.php
  2. 59
      main/newscorm/lp_stats.php

@ -420,17 +420,27 @@ class learnpath {
$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;
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,
@ -444,7 +454,9 @@ class learnpath {
previous_item_id,
next_item_id,
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;}

@ -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'];
}
@ -313,7 +322,13 @@ 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'];
}
}
//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 .= "<tr class='$oddclass'>\n"."<td></td>\n"."<td>$extend_attempt_link</td>\n".'<td colspan="3">'.htmlentities(get_lang('Attempt'), ENT_QUOTES, $dokeos_charset).' '.$row['iv_view_count']."</td>\n"
//."<td><font color='$color'><div class='mystatus'>".htmlentities($array_status[$lesson_status],ENT_QUOTES,$charset_lang)."</div></font></td>\n"
.'<td colspan="2"><font color="'.$color.'"><div class="mystatus">'.$my_lesson_status."</div></font></td>\n".'<td colspan="2"><div class="mystatus" align="center">'. ($score == 0 ? '-' : ($maxscore==0?$score:$score.'/'.$maxscore))."</div></td>\n".'<td colspan="2"><div class="mystatus">'.$time."</div></td><td></td>\n"."</tr>\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 = '<a href="'.api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix.'"><img src="../img/invisible.gif" alt="extend_view" border="0"></a>';
}
if (($counter % 2) == 0) {
if (($counter % 2) == 0)
{
$oddclass = "row_odd";
} else {
}
else
{
$oddclass = "row_even";
}
$lesson_status = $row['mystatus'];
@ -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))
{

Loading…
Cancel
Save