|
|
|
|
@ -93,15 +93,15 @@ class ScoreDisplay |
|
|
|
|
/** |
|
|
|
|
* Get the instance of this class. |
|
|
|
|
* |
|
|
|
|
* @param int $category_id |
|
|
|
|
* @param int $categoryId |
|
|
|
|
* |
|
|
|
|
* @return ScoreDisplay |
|
|
|
|
*/ |
|
|
|
|
public static function instance($category_id = 0) |
|
|
|
|
public static function instance($categoryId = 0) |
|
|
|
|
{ |
|
|
|
|
static $instance; |
|
|
|
|
if (!isset($instance)) { |
|
|
|
|
$instance = new ScoreDisplay($category_id); |
|
|
|
|
$instance = new ScoreDisplay($categoryId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $instance; |
|
|
|
|
@ -114,18 +114,20 @@ class ScoreDisplay |
|
|
|
|
{ |
|
|
|
|
if (!isset($score1)) { |
|
|
|
|
return isset($score2) ? 1 : 0; |
|
|
|
|
} elseif (!isset($score2)) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!isset($score2)) { |
|
|
|
|
return -1; |
|
|
|
|
} else { |
|
|
|
|
$scoreDisplay = self::instance(); |
|
|
|
|
$custom1 = $scoreDisplay->display_custom($score1); |
|
|
|
|
$custom2 = $scoreDisplay->display_custom($score2); |
|
|
|
|
if ($custom1 == $custom2) { |
|
|
|
|
return 0; |
|
|
|
|
} else { |
|
|
|
|
return ($score1[0] / $score1[1]) < ($score2[0] / $score2[1]) ? -1 : 1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$scoreDisplay = self::instance(); |
|
|
|
|
$custom1 = $scoreDisplay->display_custom($score1); |
|
|
|
|
$custom2 = $scoreDisplay->display_custom($score2); |
|
|
|
|
if ($custom1 == $custom2) { |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ($score1[0] / $score1[1]) < ($score2[0] / $score2[1]) ? -1 : 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -346,25 +348,20 @@ class ScoreDisplay |
|
|
|
|
private function get_current_gradebook_category_id() |
|
|
|
|
{ |
|
|
|
|
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); |
|
|
|
|
$curr_course_code = api_get_course_id(); |
|
|
|
|
$curr_session_id = api_get_session_id(); |
|
|
|
|
$courseCode = api_get_course_id(); |
|
|
|
|
$sessionId = api_get_session_id(); |
|
|
|
|
$sessionCondition = api_get_session_condition($sessionId, true); |
|
|
|
|
|
|
|
|
|
if (empty($curr_session_id)) { |
|
|
|
|
$session_condition = ' AND session_id is null '; |
|
|
|
|
} else { |
|
|
|
|
$session_condition = ' AND session_id = '.$curr_session_id; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$sql = 'SELECT id FROM '.$table.' |
|
|
|
|
WHERE course_code = "'.$curr_course_code.'" '.$session_condition; |
|
|
|
|
$sql = "SELECT id FROM $table |
|
|
|
|
WHERE course_code = '$courseCode' $sessionCondition"; |
|
|
|
|
$rs = Database::query($sql); |
|
|
|
|
$category_id = 0; |
|
|
|
|
$categoryId = 0; |
|
|
|
|
if (Database::num_rows($rs) > 0) { |
|
|
|
|
$row = Database::fetch_row($rs); |
|
|
|
|
$category_id = $row[0]; |
|
|
|
|
$categoryId = $row[0]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $category_id; |
|
|
|
|
return $categoryId; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -524,7 +521,7 @@ class ScoreDisplay |
|
|
|
|
{ |
|
|
|
|
$tbl_display = Database::get_main_table(TABLE_MAIN_GRADEBOOK_SCORE_DISPLAY); |
|
|
|
|
if (isset($category_id)) { |
|
|
|
|
$category_id = intval($category_id); |
|
|
|
|
$category_id = (int) $category_id; |
|
|
|
|
} else { |
|
|
|
|
$category_id = $this->get_current_gradebook_category_id(); |
|
|
|
|
} |
|
|
|
|
@ -553,7 +550,7 @@ class ScoreDisplay |
|
|
|
|
{ |
|
|
|
|
$tbl_display = Database::get_main_table(TABLE_MAIN_GRADEBOOK_SCORE_DISPLAY); |
|
|
|
|
if (isset($category_id)) { |
|
|
|
|
$category_id = intval($category_id); |
|
|
|
|
$category_id = (int) $category_id; |
|
|
|
|
} else { |
|
|
|
|
$category_id = $this->get_current_gradebook_category_id(); |
|
|
|
|
} |
|
|
|
|
|