Fixing ordering in gradebook list

skala
Julio Montoya 14 years ago
parent 98060fe235
commit d5fe7d15cf
  1. 9
      main/gradebook/index.php
  2. 11
      main/gradebook/lib/fe/gradebooktable.class.php
  3. 7
      main/gradebook/lib/flatview_data_generator.class.php
  4. 22
      main/gradebook/lib/gradebook_data_generator.class.php

@ -15,7 +15,6 @@ $course_code = api_get_course_id();
$stud_id = api_get_user_id();
$session_id = api_get_session_id();
//make sure the destination for scripts is index.php instead of gradebook.php
$_SESSION['gradebook_dest'] = 'index.php';
@ -793,8 +792,7 @@ if (api_is_allowed_to_edit(null, true)) {
if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
echo '<meta http-equiv="refresh" content="0;url='.api_get_self().'?cidReq='.$course_code.'" />';
} else {
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false); //already init
} else {
$models = api_get_settings_options('grading_model');
$course_grading_model_id = api_get_course_setting('course_grading_model');
$grading_model = '';
@ -810,8 +808,11 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
$grading_contents = api_grading_model_functions($grading_model, 'to_array');
$grading_string = api_grading_model_functions($grading_model, 'decorate');
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false); //already init
if (!empty($cats)) {
$items = $grading_contents['items'];
$i = 0;
foreach ($cats as $cat) {

@ -97,6 +97,9 @@ class GradebookTable extends SortableTable {
$scoretotal = 0;
// determine sorting type
$col_adjust = (api_is_allowed_to_edit() ? 1 : 0);
// By id
$this->column = 5;
switch ($this->column) {
// Type
case (0 + $col_adjust) :
@ -113,6 +116,8 @@ class GradebookTable extends SortableTable {
break;
case (4 + $col_adjust) :
$sorting = GradebookDataGenerator :: GDG_SORT_DATE;
case (5 + $col_adjust) :
$sorting = GradebookDataGenerator :: GDG_SORT_ID;
break;
}
@ -120,15 +125,13 @@ class GradebookTable extends SortableTable {
$sorting |= GradebookDataGenerator :: GDG_SORT_DESC;
} else {
$sorting |= GradebookDataGenerator :: GDG_SORT_ASC;
}
$sorting = GradebookDataGenerator :: GDG_SORT_DATE;
$sorting |= GradebookDataGenerator :: GDG_SORT_DESC;
}
//status of user in course
$user_id = api_get_user_id();
$course_code = api_get_course_id();
$status_user = api_get_status_of_user_in_course($user_id, $course_code);
$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);

@ -220,15 +220,16 @@ class FlatViewDataGenerator
$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
$item_value = round($score[0]/$divide,2)*100;
$item_value = round($score[0]/$divide,2) * 100;
$percentage = round($item->get_weight()/($sub_cat_percentage) * $sub_cat_percentage/$this->category->get_weight(), 2);
$item_value = $percentage*$item_value;
$item_total += $item->get_weight();
$temp_score = $scoredisplay->display_score($score,SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);
$temp_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);
$temp_score = $temp_score . ' '.$item_value.' / '.$this->category->get_weight();
//$temp_score = $temp_score . ' '.$item_value.' / '.$this->category->get_weight();
$temp_score = $temp_score;
if (!$show_all) {
//$row[] = $scoredisplay->display_score($score,SCORE_DIV_PERCENT);

@ -14,14 +14,16 @@ class GradebookDataGenerator
{
// Sorting types constants
const GDG_SORT_TYPE = 1;
const GDG_SORT_NAME = 2;
const GDG_SORT_DESCRIPTION = 4;
const GDG_SORT_WEIGHT = 8;
const GDG_SORT_DATE = 16;
const GDG_SORT_TYPE = 1;
const GDG_SORT_NAME = 2;
const GDG_SORT_DESCRIPTION = 4;
const GDG_SORT_WEIGHT = 8;
const GDG_SORT_DATE = 16;
const GDG_SORT_ASC = 32;
const GDG_SORT_DESC = 64;
const GDG_SORT_ASC = 32;
const GDG_SORT_DESC = 64;
const GDG_SORT_ID = 128;
private $items;
@ -66,6 +68,8 @@ class GradebookDataGenerator
// sort array
if ($sorting & self :: GDG_SORT_TYPE) {
usort($allitems, array('GradebookDataGenerator', 'sort_by_type'));
} elseif ($sorting & self :: GDG_SORT_ID) {
usort($allitems, array('GradebookDataGenerator', 'sort_by_id'));
} elseif ($sorting & self :: GDG_SORT_NAME) {
usort($allitems, array('GradebookDataGenerator', 'sort_by_name'));
} elseif ($sorting & self :: GDG_SORT_DESCRIPTION) {
@ -125,6 +129,10 @@ class GradebookDataGenerator
function sort_by_name($item1, $item2) {
return api_strnatcmp($item1->get_name(), $item2->get_name());
}
function sort_by_id($item1, $item2) {
return api_strnatcmp($item1->get_id(), $item2->get_id());
}
function sort_by_type($item1, $item2) {
if ($item1->get_item_type() == $item2->get_item_type()) {

Loading…
Cancel
Save