[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. 24
      main/newscorm/learnpath.class.php
  2. 53
      main/newscorm/lp_stats.php

@ -422,15 +422,25 @@ class learnpath {
INNER JOIN '.Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION).' as quiz_rel_question INNER JOIN '.Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION).' as quiz_rel_question
ON quiz_question.id = quiz_rel_question.question_id ON quiz_question.id = quiz_rel_question.question_id
AND quiz_rel_question.exercice_id = '.$id; AND quiz_rel_question.exercice_id = '.$id;
$rsQuiz = api_sql_query($sql, __FILE__, __LINE__); $rsQuiz = api_sql_query($sql, __FILE__, __LINE__);
$max_score = Database::result($rsQuiz, 0, 0); $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 else
{ {
$max_score = 100; $max_score = 100;
$random='';
} }
if($prerequisites!=0){ if($prerequisites!=0)
{
$sql_ins = " $sql_ins = "
INSERT INTO " . $tbl_lp_item . " ( INSERT INTO " . $tbl_lp_item . " (
lp_id, lp_id,
@ -444,7 +454,9 @@ class learnpath {
previous_item_id, previous_item_id,
next_item_id, next_item_id,
display_order, display_order,
parameters,
prerequisite prerequisite
) VALUES ( ) VALUES (
" . $this->get_id() . ", " . $this->get_id() . ",
'" . $type . "', '" . $type . "',
@ -457,11 +469,12 @@ class learnpath {
" . $previous . ", " . $previous . ",
" . $next . ", " . $next . ",
" . ($display_order + 1) . ", " . ($display_order + 1) . ",
" .$random.",
" . $prerequisites . " " . $prerequisites . "
)"; )";
} }
else
else{ {
//insert new item //insert new item
$sql_ins = " $sql_ins = "
INSERT INTO " . $tbl_lp_item . " ( INSERT INTO " . $tbl_lp_item . " (
@ -475,6 +488,7 @@ class learnpath {
parent_item_id, parent_item_id,
previous_item_id, previous_item_id,
next_item_id, next_item_id,
parameters,
display_order display_order
) VALUES ( ) VALUES (
" . $this->get_id() . ", " . $this->get_id() . ",
@ -487,6 +501,7 @@ class learnpath {
" . $parent . ", " . $parent . ",
" . $previous . ", " . $previous . ",
" . $next . ", " . $next . ",
" .$random.",
" . ($display_order + 1) . " " . ($display_order + 1) . "
)"; )";
} }
@ -2358,7 +2373,8 @@ class learnpath {
* @param integer Parent ID of the items to look for * @param integer Parent ID of the items to look for
* @return mixed Ordered list of item IDs or false on error * @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);} //if($this->debug>0){error_log('New LP - In learnpath::get_flat_ordered_items_list('.$lp.','.$parent.')',0);}
$list = array(); $list = array();
if(empty($lp)){return false;} if(empty($lp)){return false;}

@ -149,6 +149,7 @@ foreach ($list as $my_item_id)
$qry_order = 'ASC'; $qry_order = 'ASC';
} }
//prepare statement to go through each attempt //prepare statement to go through each attempt
if (!empty ($view)) 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, " .
@ -156,7 +157,7 @@ foreach ($list as $my_item_id)
"i.title as mytitle, i.max_score as mymaxscore, " . "i.title as mytitle, i.max_score as mymaxscore, " .
"iv.max_score as myviewmaxscore, " . "iv.max_score as myviewmaxscore, " .
"i.item_type as item_type, iv.view_count as iv_view_count, " . "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 ". " FROM $TBL_LP_ITEM as i, $TBL_LP_ITEM_VIEW as iv, $TBL_LP_VIEW as v ".
" WHERE i.id = iv.lp_item_id ". " WHERE i.id = iv.lp_item_id ".
" AND i.id = $my_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.user_id = ".$user_id." ".
" AND v.view_count = $view ". " AND v.view_count = $view ".
" ORDER BY iv.view_count $qry_order "; " ORDER BY iv.view_count $qry_order ";
} else { }
else
{
$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, " . "iv.score as myscore, iv.total_time as mytime, i.id as myid, " .
"i.title as mytitle, i.max_score as mymaxscore, " . "i.title as mytitle, i.max_score as mymaxscore, " .
"iv.max_score as myviewmaxscore, " . "iv.max_score as myviewmaxscore, " .
"i.item_type as item_type, iv.view_count as iv_view_count, " . "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 ". " FROM $TBL_LP_ITEM as i, $TBL_LP_ITEM_VIEW as iv, $TBL_LP_VIEW as v ".
" WHERE i.id = iv.lp_item_id ". " WHERE i.id = iv.lp_item_id ".
" AND i.id = $my_item_id ". " AND i.id = $my_item_id ".
@ -180,10 +183,11 @@ foreach ($list as $my_item_id)
" AND v.user_id = ".$user_id." ". " AND v.user_id = ".$user_id." ".
" ORDER BY iv.view_count $qry_order "; " ORDER BY iv.view_count $qry_order ";
} }
$result = api_sql_query($sql, __FILE__, __LINE__); $result = api_sql_query($sql, __FILE__, __LINE__);
$num = Database :: num_rows($result); $num = Database :: num_rows($result);
$time_for_total = 'NaN'; $time_for_total = 'NaN';
if (($extend_this OR $extend_all) && $num > 0) if (($extend_this || $extend_all) && $num > 0)
{ {
$row = Database :: fetch_array($result); $row = Database :: fetch_array($result);
@ -258,7 +262,8 @@ foreach ($list as $my_item_id)
} }
} }
else{ else
{
$correct_test_link='-'; $correct_test_link='-';
} }
//new attempt //new attempt
@ -293,12 +298,16 @@ foreach ($list as $my_item_id)
$time = learnpathItem :: get_scorm_time('js', $row['mytime']); $time = learnpathItem :: get_scorm_time('js', $row['mytime']);
$type; $type;
$scoIdentifier = $row['myid']; $scoIdentifier = $row['myid'];
if ($score == 0) { if ($score == 0)
{
$maxscore = 0; $maxscore = 0;
} else { }
else
{
if($row['item_type'] == 'sco') if($row['item_type'] == 'sco')
{ {
if(!empty($row['myviewmaxscore']) and $row['myviewmaxscore']>0)
if(!empty($row['myviewmaxscore']) && $row['myviewmaxscore']>0)
{ {
$maxscore=$row['myviewmaxscore']; $maxscore=$row['myviewmaxscore'];
} }
@ -313,6 +322,12 @@ foreach ($list as $my_item_id)
} }
else else
{ {
// 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']; $maxscore = $row['mymaxscore'];
} }
} }
@ -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',); $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 = htmlentities(get_lang($mylanglist[$lesson_status]), ENT_QUOTES, $dokeos_charset);
//$my_lesson_status = get_lang($mylanglist[$lesson_status]); //$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" $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><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"; .'<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)); } while ($row = Database :: fetch_array($result));
} elseif($num>0) { }
elseif($num>0)
{
$row = Database :: fetch_array($result); $row = Database :: fetch_array($result);
//check if there are interactions below //check if there are interactions below
@ -391,9 +410,12 @@ foreach ($list as $my_item_id)
if ($inter_num > 1) { 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>'; $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"; $oddclass = "row_odd";
} else { }
else
{
$oddclass = "row_even"; $oddclass = "row_even";
} }
$lesson_status = $row['mystatus']; $lesson_status = $row['mystatus'];
@ -434,8 +456,15 @@ foreach ($list as $my_item_id)
} }
else else
{ {
// 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']; $maxscore = $row['mymaxscore'];
} }
} }
if (empty ($title)) if (empty ($title))
{ {

Loading…
Cancel
Save