|
|
|
@ -3782,123 +3782,7 @@ class Tracking |
|
|
|
|
return $a_students; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets the average of test and scorm inside a learning path |
|
|
|
|
* @param int User id |
|
|
|
|
* @param string Course id |
|
|
|
|
* @return float average of test |
|
|
|
|
* @author isaac flores paz |
|
|
|
|
* @deprecated get_avg_student_score should be use |
|
|
|
|
*/ |
|
|
|
|
public static function get_average_test_scorm_and_lp($user_id, $course_id) |
|
|
|
|
{ |
|
|
|
|
//the score inside the Reporting table |
|
|
|
|
$course_info = api_get_course_info($course_id); |
|
|
|
|
$course_id = $course_info['real_id']; |
|
|
|
|
|
|
|
|
|
$lp_table = Database :: get_course_table(TABLE_LP_MAIN); |
|
|
|
|
$lp_view_table = Database :: get_course_table(TABLE_LP_VIEW); |
|
|
|
|
$lp_item_view_table = Database :: get_course_table(TABLE_LP_ITEM_VIEW); |
|
|
|
|
$lp_item_table = Database :: get_course_table(TABLE_LP_ITEM); |
|
|
|
|
|
|
|
|
|
$sql_type = "SELECT id, lp_type FROM $lp_table WHERE c_id = $course_id"; |
|
|
|
|
$rs_type=Database::query($sql_type); |
|
|
|
|
$count_loop=0; |
|
|
|
|
$average_data_sum = 0; |
|
|
|
|
$lp_list = array(); |
|
|
|
|
while ($row_type = Database::fetch_array($rs_type)) { |
|
|
|
|
$lp_list[] = $row_type['id']; |
|
|
|
|
if ($row_type['lp_type']==1) { |
|
|
|
|
//lp chamilo |
|
|
|
|
|
|
|
|
|
$sql = "SELECT id FROM $lp_view_table |
|
|
|
|
WHERE c_id = $course_id AND user_id = '".intval($user_id)."' and lp_id='".$row_type['id']."'"; |
|
|
|
|
$rs_last_lp_view_id = Database::query($sql); |
|
|
|
|
$lp_view_id = intval(Database::result($rs_last_lp_view_id,0,'id')); |
|
|
|
|
|
|
|
|
|
$sql_list_view="SELECT li.max_score,lv.user_id,liw.score,(liw.score/li.max_score) as sum_data |
|
|
|
|
FROM $lp_item_table li |
|
|
|
|
INNER JOIN $lp_view_table lv |
|
|
|
|
ON li.lp_id=lv.lp_id |
|
|
|
|
INNER JOIN $lp_item_view_table liw |
|
|
|
|
ON liw.lp_item_id=li.id |
|
|
|
|
WHERE li.c_id = $course_id AND |
|
|
|
|
liw.c_id = $course_id AND |
|
|
|
|
lv.c_id = $course_id AND |
|
|
|
|
lv.user_id= $user_id AND |
|
|
|
|
li.item_type = 'quiz' AND |
|
|
|
|
liw.lp_view_id= $lp_view_id"; |
|
|
|
|
$sum=0; |
|
|
|
|
$tot=0; |
|
|
|
|
$rs_list_view1=Database::query($sql_list_view); |
|
|
|
|
while ($row_list_view=Database::fetch_array($rs_list_view1)) { |
|
|
|
|
$sum=$sum+$row_list_view['sum_data']; |
|
|
|
|
$tot++; |
|
|
|
|
} |
|
|
|
|
if ($tot==0) { |
|
|
|
|
$tot=1; |
|
|
|
|
} |
|
|
|
|
$average_data1=$sum/$tot; |
|
|
|
|
} elseif ($row_type['lp_type']==2) { |
|
|
|
|
//lp scorm |
|
|
|
|
$sql = "SELECT id FROM $lp_view_table |
|
|
|
|
WHERE c_id = $course_id AND user_id = '".intval($user_id)."' and lp_id='".$row_type['id']."'"; |
|
|
|
|
$rs_last_lp_view_id = Database::query($sql); |
|
|
|
|
$lp_view_id = intval(Database::result($rs_last_lp_view_id,0,'id')); |
|
|
|
|
|
|
|
|
|
$sql_list_view = "SELECT li.max_score,lv.user_id,liw.score,((liw.score/li.max_score)*100) as sum_data |
|
|
|
|
FROM $lp_item_table li |
|
|
|
|
INNER JOIN $lp_view_table lv |
|
|
|
|
ON li.lp_id=lv.lp_id |
|
|
|
|
INNER JOIN $lp_item_view_table liw ON liw.lp_item_id=li.id |
|
|
|
|
WHERE li.c_id = $course_id AND |
|
|
|
|
liw.c_id = $course_id AND |
|
|
|
|
lv.c_id = $course_id AND |
|
|
|
|
lv.user_id= $user_id AND |
|
|
|
|
(li.item_type = 'sco' OR li.item_type='quiz') AND |
|
|
|
|
liw.lp_view_id = $lp_view_id"; |
|
|
|
|
$tot = 0; |
|
|
|
|
$sum = 0; |
|
|
|
|
|
|
|
|
|
$rs_list_view2=Database::query($sql_list_view); |
|
|
|
|
while ($row_list_view = Database::fetch_array($rs_list_view2)) { |
|
|
|
|
$sum = $sum + $row_list_view['sum_data']; |
|
|
|
|
$tot++; |
|
|
|
|
} |
|
|
|
|
if ($tot == 0) { |
|
|
|
|
$tot = 1; |
|
|
|
|
} |
|
|
|
|
$average_data2=$sum/$tot; |
|
|
|
|
} |
|
|
|
|
$average_data_sum = $average_data_sum+$average_data1+$average_data2; |
|
|
|
|
$average_data2=0; |
|
|
|
|
$average_data1=0; |
|
|
|
|
$count_loop++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//We only count the LP that have an exercise to get the average |
|
|
|
|
$lp_with_quiz = 0; |
|
|
|
|
foreach ($lp_list as $lp_id) { |
|
|
|
|
|
|
|
|
|
//check if LP have a score |
|
|
|
|
$sql = "SELECT count(id) as count FROM $lp_item_table |
|
|
|
|
WHERE c_id = $course_id AND item_type = 'quiz' AND lp_id = ".$lp_id." "; |
|
|
|
|
$result_have_quiz = Database::query($sql); |
|
|
|
|
|
|
|
|
|
if (Database::num_rows($result_have_quiz) > 0 ) { |
|
|
|
|
$row = Database::fetch_array($result_have_quiz,'ASSOC'); |
|
|
|
|
if (is_numeric($row['count']) && $row['count'] != 0) { |
|
|
|
|
$lp_with_quiz++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($lp_with_quiz > 0) { |
|
|
|
|
$avg_student_score = round(($average_data_sum / $lp_with_quiz * 100), 2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $avg_student_score; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* get count clicks about tools most used by course |
|
|
|
|