|
|
|
@ -627,7 +627,6 @@ class Category implements GradebookItem |
|
|
|
|
* A category is a course if it has a course code and no parent category. |
|
|
|
|
*/ |
|
|
|
|
public function is_course() { |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
return (isset($this->course_code) && !empty($this->course_code) |
|
|
|
|
&& (!isset($this->parent) || $this->parent == 0)); |
|
|
|
|
} |
|
|
|
@ -654,40 +653,6 @@ class Category implements GradebookItem |
|
|
|
|
$rescount = 0; |
|
|
|
|
$ressum = 0; |
|
|
|
|
$weightsum = 0; |
|
|
|
|
======= |
|
|
|
|
return (isset($this->course_code) && !empty($this->course_code) |
|
|
|
|
&& (!isset($this->parent) || $this->parent == 0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Calculate the score of this category |
|
|
|
|
* @param $stud_id student id (default: all students - then the average is returned) |
|
|
|
|
* @return array (score sum, weight sum) |
|
|
|
|
* or null if no scores available |
|
|
|
|
*/ |
|
|
|
|
public function calc_score ($stud_id = null, $course_code = '', $session_id = null) { |
|
|
|
|
// get appropriate subcategories, evaluations and links |
|
|
|
|
if (!empty($course_code)) { |
|
|
|
|
$cats = $this->get_subcategories($stud_id, $course_code, $session_id); |
|
|
|
|
$evals = $this->get_evaluations($stud_id, false, $course_code); |
|
|
|
|
$links = $this->get_links($stud_id, false, $course_code); |
|
|
|
|
} else { |
|
|
|
|
$cats = $this->get_subcategories($stud_id); |
|
|
|
|
$evals = $this->get_evaluations($stud_id); |
|
|
|
|
$links = $this->get_links($stud_id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// calculate score |
|
|
|
|
$rescount = 0; |
|
|
|
|
$ressum = 0; |
|
|
|
|
$weightsum = 0; |
|
|
|
|
/*$debug = false; |
|
|
|
|
|
|
|
|
|
if ($stud_id == 11) { |
|
|
|
|
$debug = true; |
|
|
|
|
} |
|
|
|
|
if ($debug) var_dump($links);*/ |
|
|
|
|
>>>>>>> julio19x |
|
|
|
|
|
|
|
|
|
if (!empty($cats)) { |
|
|
|
|
foreach ($cats as $cat) { |
|
|
|
@ -700,28 +665,6 @@ class Category implements GradebookItem |
|
|
|
|
if (isset($catres)) { |
|
|
|
|
$ressum += (($catres[0]/$catres[1]) * $catweight); |
|
|
|
|
} |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($evals)) { |
|
|
|
|
foreach ($evals as $eval) { |
|
|
|
|
$evalres = $eval->calc_score($stud_id); |
|
|
|
|
if (isset($evalres) && $eval->get_weight() != 0) { |
|
|
|
|
$evalweight = $eval->get_weight(); |
|
|
|
|
$rescount++; |
|
|
|
|
$weightsum += $evalweight; |
|
|
|
|
$ressum += (($evalres[0]/$evalres[1]) * $evalweight); |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($links)) { |
|
|
|
|
foreach ($links as $link) { |
|
|
|
|
$linkres = $link->calc_score($stud_id); |
|
|
|
|
======= |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -742,8 +685,6 @@ class Category implements GradebookItem |
|
|
|
|
if (!empty($links)) { |
|
|
|
|
foreach ($links as $link) { |
|
|
|
|
$linkres = $link->calc_score($stud_id); |
|
|
|
|
//if ($debug) var_dump($linkres); |
|
|
|
|
>>>>>>> julio19x |
|
|
|
|
|
|
|
|
|
if (isset($linkres) && $link->get_weight() != 0) { |
|
|
|
|
$linkweight = $link->get_weight(); |
|
|
|
|