diff --git a/main/gradebook/gradebook_flatview.php b/main/gradebook/gradebook_flatview.php index f5e7d1fe8b..f4f589d620 100644 --- a/main/gradebook/gradebook_flatview.php +++ b/main/gradebook/gradebook_flatview.php @@ -93,6 +93,10 @@ if (!empty($keyword)) { } } +$offset = isset($_GET['offset']) ? $_GET['offset'] : '0'; +$flatviewtable = new FlatViewTable($cat[0], $users, $alleval, $alllinks, true, $offset, $addparams); + + if (isset ($_GET['exportpdf'])) { $interbreadcrumb[] = array ( @@ -120,15 +124,23 @@ if (isset ($_GET['exportpdf'])) { $time = time(); $cat_name = trim($cat[0]->get_name()); $course_code = trim($cat[0]->get_course_code()); - $report_name = $course_code; - if (!empty($cat_name) && $report_name != $cat_name) { - $report_name .= ' - '.$cat_name; - } $organization = api_get_setting('Institution'); - $creator = api_get_person_name($GLOBALS['_user']['firstName'], $GLOBALS['_user']['lastName']); - + + $displayscore = ScoreDisplay :: instance(); + $customdisplays = $displayscore->get_custom_score_display_settings(); + + if (is_array($customdisplays) && count(($customdisplays))) { + $total = array(); + foreach($customdisplays as $custom) { + $total[$custom['display']] = 0; + } + $user_results = $flatviewtable->datagen->get_data_to_graph2(); + foreach($user_results as $user_result) { + $total[$user_result[count($user_result)-1][1]]++; + } + } + $html = ''; - $img = api_get_path(SYS_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png'; if (file_exists($img)) { @@ -139,10 +151,41 @@ if (isset ($_GET['exportpdf'])) { $html .= '

'.$organization.'

'; } } - $html .= '

'.get_lang('FlatView').'

'; - $html .= '

'.$report_name.'

'; - $html .= '

'.api_convert_and_format_date(date('Y-m-d', time()), 2).'

'; - $html .= '

'.get_lang('By').': '.$creator.'

'; + $html .= '

'.get_lang('FlatView').'

'; + + $html .= ''; + + $html .= ''; + + $html .= '
'; + + $html .= ''; + $session_name = api_get_session_name(api_get_session_id()); + $teacher_list = CourseManager::get_teacher_list_from_course_code_to_string($course_code); + if (!empty($session_name)) { + $html .= Display::tag('tr', Display::tag('td', get_lang('Session')).Display::tag('td', Display::tag('strong', $session_name))); + } + $html .= Display::tag('tr', Display::tag('td', get_lang('Course')).Display::tag('td', Display::tag('strong', $course_code))); + $html .= Display::tag('tr', Display::tag('td', get_lang('Date')).Display::tag('td', Display::tag('strong', api_convert_and_format_date(date('Y-m-d', time()), DATE_TIME_FORMAT_LONG)))); + $html .= Display::tag('tr', Display::tag('td', get_lang('Teacher')).Display::tag('td', Display::tag('strong', $teacher_list))); + $html .= '
'; + + if (!empty($total)) { + foreach($total as $label => $count) { + $total_custom_score = round($count/count($user_results), 2) *100; + $html .= Display::tag('tr', Display::tag('td', $label).Display::tag('td', Display::tag('strong', $total_custom_score.' %'))); + } + } + $html .= '
'; + $headers = $printable_data[0]; + unset($headers[0]); + unset($headers[1]); + unset($headers[count($headers)+1]); + + foreach ($headers as $head) { + $html .= Display::tag('tr', Display::tag('td', 'P1').Display::tag('td', Display::tag('strong', $head))); + } + $html .= '

'; $columns = count($printable_data[0]); $has_data = is_array($printable_data[1]) && count($printable_data[1]) > 0; @@ -184,6 +227,7 @@ if (isset ($_GET['exportpdf'])) { $html .= $table->toHtml(); + //echo $html;exit; // Memory release unset($printable_data); @@ -261,8 +305,7 @@ if (isset($_GET['search'])) { $addparams['search'] = $keyword; } -$offset = isset($_GET['offset']) ? $_GET['offset'] : '0'; -$flatviewtable = new FlatViewTable($cat[0], $users, $alleval, $alllinks, true, $offset, $addparams); + $this_section = SECTION_COURSES; if (isset($_GET['exportpdf'])) { diff --git a/main/gradebook/lib/fe/flatviewtable.class.php b/main/gradebook/lib/fe/flatviewtable.class.php index f317db5980..eaa952e298 100644 --- a/main/gradebook/lib/fe/flatviewtable.class.php +++ b/main/gradebook/lib/fe/flatviewtable.class.php @@ -21,7 +21,7 @@ set_time_limit(0); class FlatViewTable extends SortableTable { private $selectcat; - private $datagen; + public $datagen; private $limit_enabled; private $offset; @@ -188,7 +188,7 @@ class FlatViewTable extends SortableTable $pre_result = $new_result = array(); $DataSet = new pData(); //filling the Dataset - foreach($user_results as $result) { + foreach ($user_results as $result) { //print_r($result); for($i=0; $i< count($header_name); $i++) { $pre_result[$i+3][]= $result[$i+1]; diff --git a/main/gradebook/lib/flatview_data_generator.class.php b/main/gradebook/lib/flatview_data_generator.class.php index 2c5d3cc1b4..32c8a66be5 100644 --- a/main/gradebook/lib/flatview_data_generator.class.php +++ b/main/gradebook/lib/flatview_data_generator.class.php @@ -77,7 +77,7 @@ class FlatViewDataGenerator //$headers[] = $item->get_name().'
'.get_lang('Max').' '.$this->get_max_result_by_link($count + $items_start).' '; $weight = round($item->get_weight()/($count_categories*100), 2)*100; - $headers[] = $item->get_name().'
'.$weight.'% '; + $headers[] = $item->get_name().' '.$weight.'% '; if ($show_detail) { //$headers[] = $item->get_name().' ('.get_lang('Detail').')'; } diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 321b217a24..1dea69c600 100644 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -1291,6 +1291,21 @@ class CourseManager { } return $teachers; } + + public static function get_teacher_list_from_course_code_to_string($course_code) { + $teacher_list = self::get_teacher_list_from_course_code($course_code); + $teacher_string = ''; + $list = array(); + if (!empty($teacher_list)) { + foreach($teacher_list as $teacher) { + $list[]= api_get_person_name($teacher['firstname'], $teacher['lastname']); + } + if (!empty($list)) { + $teacher_string = implode (', ', $list); + } + } + return $teacher_string; + } /** * Return user info array of all users registered in the specified course diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 4bac89b54d..b7243dd2b4 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -2298,7 +2298,7 @@ return 'application/octet-stream'; function documents_total_space($to_group_id = '0') { $TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); $TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); - $course_id = api_get_course_int_id(); + $course_id = api_get_course_int_id(); $sql = "SELECT SUM(size) FROM ".$TABLE_ITEMPROPERTY." AS props, ".$TABLE_DOCUMENT." AS docs WHERE props.c_id = $course_id AND