[svn r19809] Logic change - Fixed qualification of an exercise in lp when it has multiple attempts - partial FS#3909

skala
Cristian Fasanando 16 years ago
parent 9b1fc8c58c
commit 650ae4b657
  1. 57
      main/exercice/exercice.php
  2. 3
      main/exercice/exercise_show.php
  3. 74
      main/newscorm/lp_stats.php

@ -1,4 +1,4 @@
<?php // $Id: exercice.php 19709 2009-04-11 16:10:04Z iflorespaz $
<?php // $Id: exercice.php 19809 2009-04-16 20:05:58Z cfasanando $
/*
==============================================================================
@ -82,6 +82,7 @@ $TBL_TRACK_HOTPOTATOES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_H
$TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$TBL_TRACK_ATTEMPT_RECORDING = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$TBL_LP_ITEM_VIEW = Database::get_course_table (TABLE_LP_ITEM_VIEW);
$TBL_LP_ITEM = Database::get_course_table (TABLE_LP_ITEM);
$TBL_LP_VIEW = Database::get_course_table (TABLE_LP_VIEW);
// document path
@ -270,22 +271,50 @@ $headers="From:$from_name\r\nReply-to: $to\r\nContent-type: text/html; charset="
api_mail_html($emailid, $emailid, $subject, $mess, $from_name, $from);
if (in_array($origin, array('tracking_course','user_course'))){
// update score when you qualify the exercises in Learning path detail
if (isset($_REQUEST['lp_item_id']) && isset($_REQUEST['lp_item_view_id']) && isset($_REQUEST['student_id']) && isset($_REQUEST['total_score']) && isset($_REQUEST['total_time'])) {
$lp_item_id = $_REQUEST['lp_item_id'];
$lp_item_view_id = $_REQUEST['lp_item_view_id'];
$student_id = $_REQUEST['student_id'];
if (in_array($origin, array('tracking_course','user_course'))){
if (isset($_POST['lp_item_id']) && isset($_POST['lp_item_view_id']) && isset($_POST['student_id']) && isset($_POST['total_score']) && isset($_POST['total_time']) && isset($_POST['totalWeighting']) ) {
$lp_item_id = $_POST['lp_item_id'];
$lp_item_view_id = $_POST['lp_item_view_id'];
$student_id = $_POST['student_id'];
$totalWeighting = $_POST['totalWeighting'];
if ($lp_item_id == strval(intval($lp_item_id)) && $lp_item_view_id == strval(intval($lp_item_view_id)) && $student_id == strval(intval($student_id))) {
$score = (float)$_REQUEST['total_score'];
$total_time = (int)$_REQUEST['total_time'];
$sql_update_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = $score,total_time = $total_time WHERE lp_item_id = '".(int)$lp_item_view_id."'
$score = Database::escape_string($_POST['total_score']);
$total_time = Database::escape_string($_POST['total_time']);
$lp_item_id = Database::escape_string($lp_item_id);
$lp_item_view_id = Database::escape_string($lp_item_view_id);
$student_id = Database::escape_string($student_id);
$totalWeighting = Database::escape_string($totalWeighting);
// get max view_count from lp_item_view
$sql = "SELECT MAX(view_count) FROM $TBL_LP_ITEM_VIEW WHERE lp_item_id = '".(int)$lp_item_view_id."'
AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '".(int)$student_id."' and lp_id='".(int)$lp_item_id."')";
api_sql_query($sql_update_score,__FILE__,__LINE__);
$res_max_view_count = api_sql_query($sql,__FILE__,__LINE__);
$row_max_view_count = Database::fetch_row($res_max_view_count);
$max_view_count = (int)$row_max_view_count[0];
// update score and total_time from last attempt when you qualify the exercise in Learning path detail
$sql_update_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = '".(float)$score."',total_time = '".(int)$total_time."' WHERE lp_item_id = '".(int)$lp_item_view_id."'
AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '".(int)$student_id."' and lp_id='".(int)$lp_item_id."') AND view_count = '$max_view_count'";
api_sql_query($sql_update_score,__FILE__,__LINE__);
// update score and total_time from last attempt when you qualify the exercise in Learning path detail
$sql_update_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = '".(float)$score."',total_time = '".(int)$total_time."' WHERE lp_item_id = '".(int)$lp_item_view_id."'
AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '".(int)$student_id."' and lp_id='".(int)$lp_item_id."') AND view_count = '$max_view_count'";
api_sql_query($sql_update_score,__FILE__,__LINE__);
// update max_score from a exercise in lp
$sql_update_max_score = "UPDATE $TBL_LP_ITEM SET max_score = '".(float)$totalWeighting."' WHERE id = '".(int)$lp_item_view_id."'";
api_sql_query($sql_update_max_score,__FILE__,__LINE__);
}
}
//Redirect to the reporting
header('location: ../mySpace/myStudents.php?origin='.$origin.'&student='.$_GET['student'].'&details=true&course='.$_GET['course']);
}
if ($origin=='tracking_course') {
//Redirect to the course detail in lp
header('location: ../mySpace/lp_tracking.php?course='.Security::remove_XSS($_GET['course']).'&origin='.$origin.'&lp_id='.Security::remove_XSS($_POST['lp_item_id']).'&student_id='.Security::remove_XSS($_POST['student_id']));
} else {
//Redirect to the reporting
header('location: ../mySpace/myStudents.php?origin='.$origin.'&student='.Security::remove_XSS($_GET['student']).'&details=true&course='.Security::remove_XSS($_GET['course']));
}
}
}
if ($_GET['gradebook'] && $_GET['exerciseId']) {

@ -4,7 +4,7 @@
*
* @package dokeos.exercise
* @author Julio Montoya Armas Added switchable fill in blank option added
* @version $Id: exercise_show.php 19768 2009-04-14 20:37:08Z juliomontoya $
* @version $Id: exercise_show.php 19809 2009-04-16 20:05:58Z cfasanando $
*
* @todo remove the debug code and use the general debug library
* @todo use the Database:: functions
@ -1014,6 +1014,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
<input type = "hidden" name="student_id" value="<?php echo Security::remove_XSS($_GET['student']);?>">
<input type = "hidden" name="total_score" value="<?php echo $totalScore; ?>">
<input type = "hidden" name="total_time" value="<?php echo Security::remove_XSS($_GET['total_time']);?>">
<input type = "hidden" name="totalWeighting" value="<?php echo $totalWeighting; ?>">
<?php
}
} else {

@ -182,7 +182,7 @@ foreach ($list as $my_item_id) {
if (!empty ($view)) {
$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.lp_id as mylpid, " .
"iv.score as myscore, iv.total_time as mytime, i.id as myid, i.lp_id as mylpid, iv.lp_view_id as mylpviewid, " .
"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, " .
@ -197,7 +197,7 @@ foreach ($list as $my_item_id) {
" ORDER BY iv.view_count $qry_order ";
} 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.lp_id as mylpid, " .
"iv.score as myscore, iv.total_time as mytime, i.id as myid, i.lp_id as mylpid, iv.lp_view_id as mylpviewid, " .
"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, " .
@ -235,45 +235,8 @@ foreach ($list as $my_item_id) {
$title = rl_get_resource_name(api_get_course_id(), $lp_id, $row['myid']);
}
if ($row['item_type'] != 'dokeos_chapter') {
$correct_test_link = array ();
if ($row['item_type'] == 'quiz')
{
if ($origin != 'tracking') {
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . api_get_user_id() . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" AND status <> "incomplete" ORDER BY exe_date DESC limit 1';
} else {
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $_GET['student_id'] . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" AND status <> "incomplete" ORDER BY exe_date DESC limit 1';
}
$resultLastAttempt = api_sql_query($sql_last_attempt, __FILE__, __LINE__);
$num = Database :: num_rows($resultLastAttempt);
if ($num > 0) {
if ($num > 1) {
while ($rowLA = Database :: fetch_row($resultLastAttempt)) {
$id_last_attempt = $rowLA[0];
if ($origin != 'tracking') {
$correct_test_link = '<a href="../exercice/exercise_show.php?origin=student_progress&id=' . $id_last_attempt . '&cidReq=' . $course_code . '" target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif"></a>';
} else {
$correct_test_link = '<a href="../exercice/exercise_show.php?origin=tracking_course&myid='.$my_id.'&my_lp_id='.$my_lp_id.'&id=' . $id_last_attempt . '&cidReq=' . $course_code . '&student=' . $_GET['student_id'] . '" target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif"></a>';
}
}
} else {
$id_last_attempt = Database :: result($resultLastAttempt, 0, 0);
if ($origin != 'tracking') {
$correct_test_link = '<a href="../exercice/exercise_show.php?origin=student_progress&id=' . $id_last_attempt . '&cidReq=' . $course_code . '" target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif"></a>';
} else {
$correct_test_link = '<a href="../exercice/exercise_show.php?origin=tracking_course&myid='.$my_id.'&my_lp_id='.$my_lp_id.'&id=' . $id_last_attempt . '&cidReq=' . $course_code . '&student=' . $_GET['student_id'] . '" target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif"></a>';
}
}
}
} else {
$correct_test_link = '-';
}
//new attempt
if ($row['item_type'] != 'dokeos_chapter') {
$correct_test_link = '-';
$output .= "<tr class='$oddclass'>\n" . "<td>$extend_link</td>\n" . '<td colspan="4" class="content"><div class="mystatus">' . htmlentities($title, ENT_QUOTES, $lp_charset) . "</div></td>\n" . '<td colspan="2" class="content"></td>' . "\n" . '<td colspan="2" class="content"></td>' . "\n" . '<td colspan="2" class="content"></td><td class="content"></td>' . "\n" . "</tr>\n";
}
@ -381,7 +344,10 @@ foreach ($list as $my_item_id) {
}
elseif ($num > 0) {
$row = Database :: fetch_array($result);
$my_id = $row['myid'];
$my_lp_id = $row['mylpid'];
$my_lp_view_id = $row['mylpviewid'];
//check if there are interactions below
$extend_attempt_link = '';
$extend_this_attempt = 0;
@ -440,13 +406,7 @@ foreach ($list as $my_item_id) {
if ($num > 0) {
while ($rowLA = Database :: fetch_array($resultLastAttempt)) {
$id_last_attempt = $rowLA['exe_id'];
$last_start_date = convert_mysql_date($rowLA['start_date']);
$last_exe_date = convert_mysql_date($rowLA['exe_date']);
$score = $rowLA['exe_result'];
}
$subtotal_time = ((int)$last_exe_date-(int)$last_start_date);
$time = learnpathItem :: get_scorm_time('js', $subtotal_time);
}
if ($score == 0)
@ -470,7 +430,19 @@ foreach ($list as $my_item_id) {
{
if ($row['item_type'] == 'quiz')
{
$myid= $row['myid'];
// get score and total time from last attempt of a exercise en lp
$sql = "SELECT score,total_time FROM $TBL_LP_ITEM_VIEW WHERE lp_item_id = '".(int)$my_id."' and lp_view_id = '".(int)$my_lp_view_id."'
ORDER BY view_count DESC limit 1";
$res_score_time = api_sql_query($sql,__FILE__,__LINE__);
$row_score_time = Database::fetch_array($res_score_time);
if (Database::num_rows($res_score_time) > 0) {
$score = (float)$row_score_time['score'];
$subtotal_time = (int)$row_score_time['total_time'];
} else {
$score = 0;
$subtotal_time = 0;
}
$time = learnpathItem :: get_scorm_time('js', $subtotal_time);
// selecting the max score from an attempt
$sql = "SELECT SUM(t.ponderation) as maxscore from ( SELECT distinct question_id, marks,ponderation FROM $tbl_stats_attempts as at " .
"INNER JOIN $tbl_quiz_questions as q on(q.id = at.question_id) where exe_id ='$id_last_attempt' ) as t";
@ -505,9 +477,7 @@ foreach ($list as $my_item_id) {
'not attempted' => 'ScormNotAttempted',
);
$my_lesson_status = htmlentities(get_lang($mylanglist[$lesson_status]), ENT_QUOTES, $dokeos_charset);
$my_id = $row['myid'];
$my_lp_id = $row['mylpid'];
$my_lesson_status = htmlentities(get_lang($mylanglist[$lesson_status]), ENT_QUOTES, $dokeos_charset);
if ($row['item_type'] != 'dokeos_chapter') {
if ($row['item_type'] == 'quiz') {
$correct_test_link = '';

Loading…
Cancel
Save