Official code added in the PDF export of the gradebook results see BT#4080

skala
Julio Montoya 13 years ago
parent 5f965452cd
commit 98cdf50612
  1. 8
      main/gradebook/gradebook_flatview.php
  2. 31
      main/gradebook/lib/flatview_data_generator.class.php
  3. 46
      main/gradebook/lib/gradebook_functions.inc.php
  4. 27
      main/gradebook/lib/gradebook_functions_users.inc.php
  5. BIN
      main/img/icons/22/lock_na.png

@ -84,9 +84,10 @@ if ($simple_search_form->validate() && (empty($keyword))) {
if (!empty($keyword)) {
$users = find_students($keyword);
} else {
if (isset($alleval) && isset($alllinks)) {
$users = get_all_users($alleval, $alllinks);
$users = get_all_users($alleval, $alllinks);
} else {
$users = null;
}
@ -102,6 +103,9 @@ $flatviewtable->set_additional_parameters($parameters);
if (isset($_GET['export_pdf']) && $_GET['export_pdf'] == 'category') {
$params = array();
$params['only_total_category'] = true;
$params['join_firstname_lastname'] = true;
$params['show_official_code'] = true;
if ($cat[0]->is_locked() == true || api_is_platform_admin()) {
Display :: set_header(null, false, false);
export_pdf_flatview($cat, $users, $alleval, $alllinks, $params);
@ -119,6 +123,8 @@ if (isset($_GET['exportpdf'])) {
if ($export_pdf_form->validate()) {
$params = $export_pdf_form->exportValues();
Display :: set_header(null, false, false);
$params['join_firstname_lastname'] = true;
$params['show_usercode'] = true;
export_pdf_flatview($cat, $users, $alleval, $alllinks, $params);
} else {
Display :: display_header(get_lang('ExportPDF'));

@ -56,9 +56,17 @@ class FlatViewDataGenerator
*/
public function get_header_names($items_start = 0, $items_count = null , $show_detail = false) {
$headers = array();
$headers[] = get_lang('LastName');
$headers[] = get_lang('FirstName');
if (isset($this->params['show_official_code']) && $this->params['show_official_code']) {
$headers[] = get_lang('OfficialCode');
}
if (isset($this->params['join_firstname_lastname']) && $this->params['join_firstname_lastname']) {
$headers[] = get_lang('Name');
} else {
$headers[] = get_lang('LastName');
$headers[] = get_lang('FirstName');
}
if (!isset($items_count)) {
$items_count = count($this->evals_links) - $items_start;
}
@ -224,12 +232,21 @@ class FlatViewDataGenerator
if (empty($grade_model_id) || $grade_model_id == -1) {
$use_grade_model = false;
}
foreach ($selected_users as $user) {
foreach ($selected_users as $user) {
$row = array();
$row[] = $user_id = $user[0]; //user id
$row[] = $user[2]; //last name
$row[] = $user[3]; //first name
if (isset($this->params['show_official_code']) && $this->params['show_official_code']) {
$row[] = $user[4]; //official code
}
if (isset($this->params['join_firstname_lastname']) && $this->params['join_firstname_lastname']) {
$row[] = api_get_person_name($user[3], $user[2]); //last name
} else {
$row[] = $user[2]; //last name
$row[] = $user[3]; //first name
}
$item_value = 0;
$item_value_total = 0;
$item_total = 0;
@ -337,7 +354,7 @@ class FlatViewDataGenerator
}
unset($score);
$data[] = $row;
}
}
return $data;
}

@ -435,7 +435,8 @@ function get_printable_data($cat, $users, $alleval, $alllinks, $params) {
foreach ($data_array as $data) {
$newarray[] = array_slice($data, 1);
}
return array ($header_names, $newarray);
$return = array($header_names, $newarray);
return $return;
}
@ -711,7 +712,7 @@ function export_pdf_flatview($cat, $users, $alleval, $alllinks, $params = array(
$css = file_exists($css_file) ? @file_get_contents($css_file) : '';
// HTML report creation first
$time = time();
$time = time();
$course_code = trim($cat[0]->get_course_code());
$organization = api_get_setting('Institution');
@ -783,38 +784,27 @@ function export_pdf_flatview($cat, $users, $alleval, $alllinks, $params = array(
Display::$global_template->assign('pdf_date', api_format_date(api_get_utc_datetime(), DATE_TIME_FORMAT_LONG));
Display::$global_template->assign('pdf_teachers', $teacher_list);
/*
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 .= '</table></td>';
$html .= '<td valign="top"><table align="left" width="33%">';
$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', Display::tag('strong', $head)));
}
$html .= '</table></td></table><br />';
*/
$columns = count($printable_data[0]);
$columns = count($printable_data[0]);
$has_data = is_array($printable_data[1]) && count($printable_data[1]) > 0;
if (api_is_western_name_order()) {
// Choosing the right person name order according to the current language.
list($printable_data[0][0], $printable_data[0][1]) = array($printable_data[0][1], $printable_data[0][0]);
if ($has_data) {
foreach ($printable_data[1] as &$printable_data_row) {
list($printable_data_row[0], $printable_data_row[1]) = array($printable_data_row[1], $printable_data_row[0]);
$firstname_position = 0;
$lastname_position = 1;
if (!isset($params['join_firstname_lastname'])) {
if (isset($params['show_usercode']) && $params['show_usercode'] ) {
$firstname_position ++;
$lastname_position ++;
}
list($printable_data[0][$firstname_position], $printable_data[0][$lastname_position]) = array($printable_data[0][$lastname_position], $printable_data[0][$firstname_position]);
if ($has_data) {
foreach ($printable_data[1] as &$printable_data_row) {
list($printable_data_row[$firstname_position], $printable_data_row[$lastname_position]) = array($printable_data_row[$lastname_position], $printable_data_row[$firstname_position]);
}
}
}
}

@ -26,13 +26,12 @@ function get_users_in_course($course_id) {
AND scru.status=0
AND scru.course_code='$course_id' AND id_session ='$current_session' $order_clause ";
} else {
$sql = 'SELECT user.user_id, user.username, lastname, firstname, official_code'
.' FROM '.$tbl_course_user.' as course_rel_user, '.$tbl_user.' as user'
.' WHERE course_rel_user.user_id=user.user_id'
.' AND course_rel_user.status='.STUDENT
." AND course_rel_user.course_code='".$course_id."'"
.$order_clause;
}
$sql = 'SELECT user.user_id, user.username, lastname, firstname, official_code
FROM '.$tbl_course_user.' as course_rel_user, '.$tbl_user.' as user
WHERE course_rel_user.user_id=user.user_id AND
course_rel_user.status='.STUDENT.' AND
course_rel_user.course_code = "'.$course_id.'" '.$order_clause;
}
$result = Database::query($sql);
return get_user_array_from_sql_result($result);
}
@ -41,7 +40,7 @@ function get_users_in_course($course_id) {
function get_user_array_from_sql_result($result) {
$a_students = array();
while ($user = Database::fetch_array($result)) {
if (!array_key_exists($user['user_id'],$a_students)) {
if (!array_key_exists($user['user_id'], $a_students)) {
$a_current_student = array ();
$a_current_student[] = $user['user_id'];
$a_current_student[] = $user['username'];
@ -70,15 +69,15 @@ function get_all_users ($evals = array(), $links = array()) {
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_res = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$sql = 'SELECT user.user_id,lastname,firstname'
.' FROM '.$tbl_res.' as res, '.$tbl_user.' as user'
.' WHERE res.evaluation_id = '.intval($eval->get_id())
$sql = 'SELECT user.user_id,lastname, firstname, user.official_code
FROM '.$tbl_res.' as res, '.$tbl_user.' as user
WHERE res.evaluation_id = '.intval($eval->get_id())
.' AND res.user_id = user.user_id';
$result = Database::query($sql);
$users = array_merge($users,get_user_array_from_sql_result($result));
$users = array_merge($users, get_user_array_from_sql_result($result));
}
}
foreach ($links as $link) {
// links are always in a course
$coursecode = $link->get_course_code();
@ -104,7 +103,7 @@ function find_students($mask= '') {
$tbl_user= Database :: get_main_table(TABLE_MAIN_USER);
$tbl_cru= Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$sql= 'SELECT DISTINCT user.user_id, user.lastname, user.firstname, user.email' . ' FROM ' . $tbl_user . ' user';
$sql= 'SELECT DISTINCT user.user_id, user.lastname, user.firstname, user.email, user.official_code ' . ' FROM ' . $tbl_user . ' user';
if (!api_is_platform_admin()) {
$sql .= ', ' . $tbl_cru . ' cru';
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Loading…
Cancel
Save