[svn r20396] Fixed average of score of exercise in reporting - partial FS#4063

skala
Cristian Fasanando 16 years ago
parent 7c6fb87fc2
commit d5e5525a52
  1. 26
      main/inc/lib/tracking.lib.php
  2. 24
      main/mySpace/index.php
  3. 4
      main/mySpace/myStudents.php
  4. 65
      main/tracking/courseLog.php

@ -268,7 +268,7 @@ class Tracking {
$count_exe = Database::num_rows($rs);
if ($count_exe > 0) {
$quiz_avg_score = 0;
$quiz_avg_total_score = 0;
while($quiz = Database::fetch_array($rs)) {
// get the score and max score from track_e_exercise
@ -277,24 +277,28 @@ class Tracking {
WHERE exe_exo_id = '.(int)$quiz['id'].'
AND exe_user_id = '.(int)$student_id.'
AND orig_lp_id = 0
AND exe_cours_id = "'.Database::escape_string($course_code).'"
AND orig_lp_item_id = 0
ORDER BY exe_date DESC';
$rsAttempt = api_sql_query($sql, __FILE__, __LINE__);
$nb_attempts = 0;
while ($attempt = Database::fetch_array($rsAttempt)) {
$nb_attempts++;
$quiz_avg_score = 0;
while ($attempt = Database::fetch_array($rsAttempt)) {
$nb_attempts++;
$exe_weight=$attempt['exe_weighting'];
if ($exe_weight>0) {
$quiz_avg_score = $attempt['exe_result']/$exe_weight*100;
}
}
if ($exe_weight >0) {
$quiz_avg_score += round(($attempt['exe_result']/$exe_weight*100),2);
}
}
if($nb_attempts>0) {
$quiz_avg_score = $quiz_avg_score / $nb_attempts;
}
}
return $quiz_avg_score/$count_exe;
}
$quiz_avg_total_score += $quiz_avg_score;
}
return $quiz_avg_total_score/$count_exe;
}
}
else

@ -518,10 +518,10 @@ if(api_is_allowed_to_create_course() && $view=='teacher')
$table->set_additional_parameters($parameters);
$table -> set_header(0, get_lang('CourseTitle'), false, 'align="center"');
$table -> set_header(1, get_lang('NbStudents'), false);
$table -> set_header(2, get_lang('AvgTimeSpentInTheCourse').Display :: return_icon('info2.gif', get_lang('TimeOfActiveByTraining')),false);
$table -> set_header(3, get_lang('AvgStudentsProgress').Display :: return_icon('info2.gif', get_lang('AvgAllUsersInAllCourses')), false);
$table -> set_header(4, get_lang('AvgCourseScore'), false);
$table -> set_header(5, get_lang('AvgExercisesScore'), false);
$table -> set_header(2, get_lang('AvgTimeSpentInTheCourse').Display :: return_icon('info3.gif', get_lang('TimeOfActiveByTraining')),false);
$table -> set_header(3, get_lang('AvgStudentsProgress').Display :: return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses')), false);
$table -> set_header(4, get_lang('AvgCourseScore').Display :: return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses')), false);
$table -> set_header(5, get_lang('AvgExercisesScore').Display :: return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses')), false);
$table -> set_header(6, get_lang('AvgMessages'), false);
$table -> set_header(7, get_lang('AvgAssignments'), false);
$table -> set_header(8, get_lang('Details'), false);
@ -606,7 +606,7 @@ if(api_is_allowed_to_create_course() && $view=='teacher')
$table_row[] = $avg_score_in_exercise;
$table_row[] = $avg_messages_in_course;
$table_row[] = $avg_assignments_in_course;
$table_row[] = '<a href="../tracking/courseLog.php?cidReq='.$course_code.'&studentlist=true"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
$table_row[] = '<center><a href="../tracking/courseLog.php?cidReq='.$course_code.'&studentlist=true"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></center>';
$csv_content[] = array(
html_entity_decode($course['title']),
@ -748,7 +748,7 @@ if(api_is_platform_admin() && $view=='admin')
$table_row[] = $nb_students;
$table_row[] = $nb_courses;
$table_row[] = $nb_sessions;
$table_row[] = '<a href="session.php?id_coach='.$a_coachs['user_id'].'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
$table_row[] = '<center><a href="session.php?id_coach='.$a_coachs['user_id'].'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></center>';
$all_datas[] = $table_row;
$csv_content[] = array(
@ -900,9 +900,11 @@ function export_tracking_user_overview()
// time spent in the course
$csv_row[] = api_time_to_hms(Tracking :: get_time_spent_on_the_course ($user[4], $row[0]));
// student progress in course
$csv_row[] = Tracking :: get_avg_student_progress ($user[4], $row[0]);
$csv_row[] = round(Tracking :: get_avg_student_progress ($user[4], $row[0]),2);
// student score
$csv_row[] = Tracking :: get_avg_student_score ($user[4], $row[0]);
$csv_row[] = round(Tracking :: get_avg_student_score ($user[4], $row[0]),2);
// student tes score
$csv_row[] = round(Tracking :: get_avg_student_exercise_score ($user[4], $row[0]),2);
// student messages
$csv_row[] = Tracking :: count_student_messages ($user[4], $row[0]);
// student assignments
@ -1046,9 +1048,11 @@ function course_info_tracking_filter($user_id,$url_params,$row)
// time spent in the course
$return .= ' <td>'.api_time_to_hms(Tracking :: get_time_spent_on_the_course ($user_id, $row[0])).'</td>';
// student progress in course
$return .= ' <td>'.Tracking :: get_avg_student_progress ($user_id, $row[0]).'</td>';
$return .= ' <td>'.round(Tracking :: get_avg_student_progress ($user_id, $row[0]),2).'</td>';
// student score
$return .= ' <td>'.Tracking :: get_avg_student_score ($user_id, $row[0]).'</td>';
$return .= ' <td>'.round(Tracking :: get_avg_student_score ($user_id, $row[0]),2).'</td>';
// student tes score
$return .= ' <td>'.round(Tracking :: get_avg_student_exercise_score ($user_id, $row[0]),2).'%</td>';
// student messages
$return .= ' <td>'.Tracking :: count_student_messages ($user_id, $row[0]).'</td>';
// student assignments

@ -1,4 +1,4 @@
<?php //$Id: myStudents.php 20368 2009-05-06 16:02:20Z iflorespaz $
<?php //$Id: myStudents.php 20396 2009-05-07 21:23:22Z cfasanando $
/* For licensing terms, see /dokeos_license.txt */
/**
* Implements the tracking of students in the Reporting pages
@ -748,7 +748,7 @@ if(!empty($_GET['student']))
<?php echo get_lang('Exercices'); ?>
</th>
<th>
<?php echo get_lang('Score') ?>
<?php echo get_lang('Score').Display :: return_icon('info3.gif', get_lang('LastScoreTest')) ?>
</th>
<th>
<?php echo get_lang('Attempts'); ?>

@ -228,38 +228,51 @@ if($_GET['studentlist'] == 'false') {
if (Database::num_rows($rs)>0) {
// gets course actual administrators
$sql = "SELECT user.user_id FROM $table_user user, $TABLECOURSUSER course_user
WHERE course_user.user_id=user.user_id AND course_user.course_code='".api_get_course_id()."' AND course_user.status='1'";
WHERE course_user.user_id=user.user_id AND course_user.course_code='".api_get_course_id()."' AND course_user.status <> '1' ";
$res = api_sql_query($sql,__FILE__,__LINE__);
$admin_course = '';
$student_ids = array();
while($row = Database::fetch_row($res)) {
$admin_course .='\''.$row[0].'\',';
$student_ids[] = $row[0];
}
$admin_course = substr($admin_course,0,(strlen($admin_course)-1));
$cond_user = (!empty($admin_course)?' AND exe_user_id NOT IN('.$admin_course.')':' ');
$count_students = count($student_ids);
while($quiz = Database::fetch_array($rs)) {
$quiz_avg_score = 0;
// get the scorn in exercises
$sql = 'SELECT exe_result , exe_weighting
FROM '.$TABLETRACK_EXERCISES.'
WHERE exe_exo_id = '.$quiz['id'].'
'.$cond_user.'
AND orig_lp_id = 0
AND orig_lp_item_id = 0
ORDER BY exe_date DESC';
$rsAttempt = api_sql_query($sql, __FILE__, __LINE__);
$nb_attempts = 0;
while ($attempt = Database::fetch_array($rsAttempt)) {
$nb_attempts++;
$exe_weight=$attempt['exe_weighting'];
if ($exe_weight>0) {
$quiz_avg_score += $attempt['exe_result']/$exe_weight*100;
}
if($count_students > 0) {
foreach($student_ids as $student_id) {
// get the scorn in exercises
$sql = 'SELECT exe_result , exe_weighting
FROM '.$TABLETRACK_EXERCISES.'
WHERE exe_exo_id = '.$quiz['id'].'
AND exe_user_id = '.(int)$student_id.'
AND exe_cours_id = "'.api_get_course_id().'"
AND orig_lp_id = 0
AND orig_lp_item_id = 0
ORDER BY exe_date DESC';
$rsAttempt = api_sql_query($sql, __FILE__, __LINE__);
$nb_attempts = 0;
$avg_student_score = 0;
while ($attempt = Database::fetch_array($rsAttempt)) {
$nb_attempts++;
$exe_weight=$attempt['exe_weighting'];
if ($exe_weight>0) {
$avg_student_score += round(($attempt['exe_result']/$exe_weight*100),2);
}
}
if ($nb_attempts>0) {
$avg_student_score = $avg_student_score / $nb_attempts;
}
$quiz_avg_score += $avg_student_score;
}
}
if($nb_attempts>0) {
$quiz_avg_score = $quiz_avg_score / $nb_attempts;
}
echo '<tr><td>'.$quiz['title'].'</td><td align="right">'.round($quiz_avg_score,2).' %</td></tr>';
echo '<tr><td>'.$quiz['title'].'</td><td align="right">'.round(($quiz_avg_score/$count_students),2).' %</td></tr>';
if ($export_csv) {
$temp=array($quiz['title'],$quiz_avg_score);
$csv_content[] = $temp;

Loading…
Cancel
Save