[svn r16969] minor - changes in logic - allows correct view view flat(forum,exercises,works)

skala
Isaac Flores 16 years ago
parent 2db52e103a
commit 515f2018f4
  1. 61
      main/gradebook/lib/be/exerciselink.class.php
  2. 6
      main/gradebook/lib/be/studentpublicationlink.class.php

@ -113,35 +113,50 @@ class ExerciseLink extends AbstractLink
*/ */
public function calc_score($stud_id = null) { public function calc_score($stud_id = null) {
$tbl_stats = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $tbl_stats = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$sql = 'SELECT * FROM '.$tbl_stats $tbl_stats_e_attempt_recording = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
." WHERE exe_cours_id = '".$this->get_course_code()."'" // for 1 student
.' AND exe_exo_id = '.$this->get_ref_id(); if (isset($stud_id))
{
if (isset($stud_id)) { $sql = "SELECT DISTINCT e.exe_id, exe_result, exe_weighting, exe_user_id
$sql .= ' AND exe_user_id = '.$stud_id; FROM $tbl_stats as e INNER JOIN
$tbl_stats_e_attempt_recording as r
ON (e.exe_id =r.exe_id)
WHERE e.exe_cours_id = '".$this->get_course_code()."'AND
e.exe_id = '".$this->get_ref_id()."' AND author != '' AND exe_user_id = '$stud_id' ORDER BY e.exe_id DESC ";
$scores = api_sql_query($sql, __FILE__, __LINE__);
if ($data=mysql_fetch_array($scores))
{
return array ($data['exe_result'], $data['exe_weighting']);
}
else
return null;
} }
// order by id, that way the student's first attempt is accessed first // all students -> get average
$sql .= ' ORDER BY exe_id'; else
{
// normal way of getting the info
$scores = api_sql_query($sql, __FILE__, __LINE__); $sql = "SELECT DISTINCT e.exe_id, exe_result, exe_weighting, exe_user_id
FROM $tbl_stats as e INNER JOIN
$tbl_stats_e_attempt_recording as r
ON (e.exe_id =r.exe_id)
WHERE e.exe_cours_id = '".$this->get_course_code()."'AND
e.exe_exo_id = '".$this->get_ref_id()."' AND author != '' ORDER BY e.exe_id DESC ";
// for 1 student $scores = api_sql_query($sql, __FILE__, __LINE__);
if (isset($stud_id)) {
if ($data=Database::fetch_array($scores)) {
return array ($data['exe_result'], $data['exe_weighting']);
} else {
return null;
}
} else {// all students -> get average
$students=array(); // user list, needed to make sure we only $students=array(); // user list, needed to make sure we only
// take first attempts into account // take first attempts into account
$rescount = 0; $rescount = 0;
$sum = 0; $sum = 0;
while ($data=Database::fetch_array($scores)) { while ($data=mysql_fetch_array($scores))
if (!(array_key_exists($data['exe_user_id'],$students))) { {
if ($data['exe_weighting'] != 0) { if (!(array_key_exists($data['exe_user_id'],$students)))
{
if ($data['exe_weighting'] != 0)
{
$students[$data['exe_user_id']] = $data['exe_result']; $students[$data['exe_user_id']] = $data['exe_result'];
$rescount++; $rescount++;
$sum += ($data['exe_result'] / $data['exe_weighting']); $sum += ($data['exe_result'] / $data['exe_weighting']);
@ -149,12 +164,10 @@ class ExerciseLink extends AbstractLink
} }
} }
if ($rescount == 0) { if ($rescount == 0)
return null; return null;
} else { else
return array ($sum , $rescount); return array ($sum , $rescount);
}
} }
} }

@ -24,7 +24,7 @@
*/ */
/** /**
* Gradebook link to student publication item * Gradebook link to student publication item
* @author Bert Steppé * @author Bert Stepp<EFBFBD>
* @package dokeos.gradebook * @package dokeos.gradebook
*/ */
class StudentPublicationLink extends AbstractLink class StudentPublicationLink extends AbstractLink
@ -154,7 +154,7 @@ class StudentPublicationLink extends AbstractLink
$query = api_sql_query($sql,__FILE__,__LINE__); $query = api_sql_query($sql,__FILE__,__LINE__);
$assignment = Database::fetch_array($query); $assignment = Database::fetch_array($query);
if(Database::num_rows($assignment)==0) { if(count($assignment)==0) {
$v_assigment_id ='0'; $v_assigment_id ='0';
} else { } else {
$v_assigment_id = $assignment['id']; $v_assigment_id = $assignment['id'];
@ -175,7 +175,7 @@ class StudentPublicationLink extends AbstractLink
if ($data=Database::fetch_array($scores)) { if ($data=Database::fetch_array($scores)) {
return array ($data['qualification'], $assignment['qualification']); return array ($data['qualification'], $assignment['qualification']);
} else { } else {
return null; return '';
} }
} else { } else {
$students=array(); // user list, needed to make sure we only $students=array(); // user list, needed to make sure we only

Loading…
Cancel
Save