skala
Julio Montoya 13 years ago
commit 730a9f8e36
  1. 149
      main/gradebook/gradebook_flatview.php
  2. 2
      main/gradebook/index.php
  3. 2
      main/gradebook/lib/fe/catform.class.php
  4. 139
      main/gradebook/lib/gradebook_functions.inc.php
  5. 25
      main/install/db_main.sql
  6. 6
      main/install/migrate-db-1.8.8-1.9.0-pre.sql

@ -107,152 +107,9 @@ if (isset($_GET['exportpdf'])) {
$export_pdf_form = new DataForm(DataForm::TYPE_EXPORT_PDF, 'export_pdf_form', null, api_get_self().'?exportpdf=&offset='.intval($_GET['offset']).'&selectcat='.intval($_GET['selectcat']), '_blank', '');
if ($export_pdf_form->validate()) {
// Beginning of PDF report creation
$printable_data = get_printable_data($cat[0], $users, $alleval, $alllinks);
$export = $export_pdf_form->exportValues();
// Reading report's CSS
//$css_file = api_get_path(TO_SYS, WEB_CSS_PATH).api_get_setting('stylesheets').'/print.css';
$css_file = api_get_path(SYS_CODE_PATH).'gradebook/print.css';
$css = file_exists($css_file) ? @file_get_contents($css_file) : '';
// HTML report creation first
$time = time();
$course_code = trim($cat[0]->get_course_code());
$organization = api_get_setting('Institution');
$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)) {
$img = api_get_path(WEB_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png';
$html .= "<img src='$img'>";
} else {
if (!empty($organization)) {
$html .= '<h2 align="left">'.$organization.'</h2>';
}
}
$html .= '<h2 align="center">'.get_lang('FlatView').'</h2>';
$html .= '<table align="center" width="100%"><tr><td valign="top">';
$html .= '<table align="left" width="33%">';
$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 .= '</table></td>';
$html .= '<td valign="top"><table align="left" width="33%">';
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', 'P1').Display::tag('td', Display::tag('strong', $head)));
$html .= Display::tag('tr', Display::tag('td', Display::tag('strong', $head)));
}
$html .= '</table></td></table><br />';
$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]);
}
}
}
$table = new HTML_Table(array('class' => 'data_table'));
$row = 0;
$column = 0;
foreach ($printable_data[0] as $printable_data_cell) {
$table->setHeaderContents($row, $column, $printable_data_cell);
$column++;
}
$row++;
if ($has_data) {
foreach ($printable_data[1] as &$printable_data_row) {
$column = 0;
foreach ($printable_data_row as &$printable_data_cell) {
$table->setCellContents($row, $column, $printable_data_cell);
$table->updateCellAttributes($row, $column, 'align="center"');
$column++;
}
$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
$row++;
}
} else {
$column = 0;
$table->setCellContents($row, $column, get_lang('NoResults'));
$table->updateCellAttributes($row, $column, 'colspan="'.$columns.'" align="center" class="row_odd"');
}
$html .= $table->toHtml();
//echo $html;exit;
// Memory release
unset($printable_data);
unset($table);
// Conversion of the created HTML report to a PDF report
$html = api_utf8_encode($html);
//@todo this is really a must?
$creator_pdf = api_utf8_encode($creator);
$title_pdf = api_utf8_encode($report_name);
$subject_pdf = api_utf8_encode(get_lang('FlatView'));
$keywods_pdf = api_utf8_encode($course_code);
$page_format = $export['orientation'] == 'landscape' ? 'A4-L' : 'A4';
$pdf = new PDF($page_format, $export['orientation']);
// Sending the created PDF report to the client
$file_name = date('YmdHi_', $time);
if (!empty($course_code)) {
$file_name .= $course_code.'_';
}
$file_name .= get_lang('FlatView').'.pdf';
$pdf->content_to_pdf($html, $css, $file_name, api_get_course_id());
exit;
if ($export_pdf_form->validate()) {
$params = $export_pdf_form->exportValues();
export_pdf_flatview($cat, $users, $alleval, $alllinks, $params);
} else {
Display :: display_header(get_lang('ExportPDF'));
}

@ -815,7 +815,7 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
if (!empty($cats)) {
if (api_is_allowed_to_edit(null, true)) {
if (api_is_allowed_to_edit(null, true) && api_get_setting('teachers_can_change_grade_model_settings') == 'true') {
//Getting grade models
$obj = new GradeModel();
$grade_models = $obj->get_all();

@ -193,7 +193,7 @@ class CatForm extends FormValidator {
$this->addElement('hidden','hid_parent_id');
$this->addElement('textarea', 'description', get_lang('Description'),array('class'=>'span3','cols' => '34'));
if (isset($this->category_object) && $this->category_object->get_parent_id() == 0) {
if (isset($this->category_object) && $this->category_object->get_parent_id() == 0 && api_get_setting('teachers_can_change_grade_model_settings') == 'true') {
//Getting grade models
$obj = new GradeModel();
$grade_models = $obj->get_all();

@ -208,6 +208,10 @@ function build_edit_icons_cat($cat, $selectcat) {
$modify_icons .= '<a class="view_children" data-cat-id="'.$cat->get_id().'" href="javascript:void(0);">'.Display::return_icon('view_more_stats.gif', get_lang('Show'),'',ICON_SIZE_SMALL).'</a>';
if (api_is_allowed_to_edit(null, true)) {
//PDF
$modify_icons .= '&nbsp;<a href="gradebook_flat_view.php?export_pdf=category&selectcat=' . $cat->get_id() . '" >'.Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_SMALL).'</a>';
if (empty($grade_model_id) || $grade_model_id == -1) {
$modify_icons .= '<a href="gradebook_edit_cat.php?editcat='.$cat->get_id().'&amp;cidReq='.$cat->get_course_code().'">'.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'</a>';
}
@ -605,3 +609,138 @@ function get_user_certificate_content($user_id, $course_code, $is_preview = fals
$new_content_html = $new_content[0].$print.'</head>'.$new_content_html;
return array('content' => $new_content_html, 'variables'=>$content_html['variables']);
}
function export_pdf_flatview($cat, $users, $alleval, $alllinks, $params = array()) {
// Beginning of PDF report creation
$printable_data = get_printable_data($cat[0], $users, $alleval, $alllinks);
// Reading report's CSS
$css_file = api_get_path(SYS_CODE_PATH).'gradebook/print.css';
$css = file_exists($css_file) ? @file_get_contents($css_file) : '';
// HTML report creation first
$time = time();
$course_code = trim($cat[0]->get_course_code());
$organization = api_get_setting('Institution');
$displayscore = ScoreDisplay :: instance();
$customdisplays = $displayscore->get_custom_score_display_settings();
$total = array();
if (is_array($customdisplays) && count(($customdisplays))) {
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)) {
$img = api_get_path(WEB_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png';
$html .= "<img src='$img'>";
} else {
if (!empty($organization)) {
$html .= '<h2 align="left">'.$organization.'</h2>';
}
}
$html .= '<h2 align="center">'.get_lang('FlatView').'</h2>';
$html .= '<table align="center" width="100%"><tr><td valign="top">';
$html .= '<table align="left" width="33%">';
$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 .= '</table></td>';
$html .= '<td valign="top"><table align="left" width="33%">';
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]);
$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]);
}
}
}
$table = new HTML_Table(array('class' => 'data_table'));
$row = 0;
$column = 0;
foreach ($printable_data[0] as $printable_data_cell) {
$table->setHeaderContents($row, $column, $printable_data_cell);
$column++;
}
$row++;
if ($has_data) {
foreach ($printable_data[1] as &$printable_data_row) {
$column = 0;
foreach ($printable_data_row as &$printable_data_cell) {
$table->setCellContents($row, $column, $printable_data_cell);
$table->updateCellAttributes($row, $column, 'align="center"');
$column++;
}
$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
$row++;
}
} else {
$column = 0;
$table->setCellContents($row, $column, get_lang('NoResults'));
$table->updateCellAttributes($row, $column, 'colspan="'.$columns.'" align="center" class="row_odd"');
}
$html .= $table->toHtml();
unset($printable_data);
unset($table);
// Conversion of the created HTML report to a PDF report
$html = api_utf8_encode($html);
$page_format = $params['orientation'] == 'landscape' ? 'A4-L' : 'A4';
$pdf = new PDF($page_format, $params['orientation']);
// Sending the created PDF report to the client
$file_name = date('YmdHi_', $time);
if (!empty($course_code)) {
$file_name .= $course_code.'_';
}
$file_name .= get_lang('FlatView').'.pdf';
$pdf->content_to_pdf($html, $css, $file_name, api_get_course_id());
exit;
}

@ -852,19 +852,11 @@ VALUES
('allow_browser_sniffer', NULL, 'radio', 'Tuning', 'false', 'AllowBrowserSnifferTitle', 'AllowBrowserSnifferComment', NULL, NULL, 0),
('enable_wami_record',NULL,'radio','Tools','false','EnableWamiRecordTitle','EnableWamiRecordComment',NULL,NULL, 0),
('gradebook_default_weight', NULL, 'textfield', 'Gradebook', '100', 'GradebookDefaultWeightTitle', 'GradebookDefaultWeightComment', NULL, NULL, 0),
('gradebook_ranking_1', 'ranking', 'gradebook_ranking', 'Gradebook', '', '', '', NULL, NULL, 1),
('gradebook_ranking_2', 'ranking', 'gradebook_ranking', 'Gradebook', '', '', '', NULL, NULL, 1),
('gradebook_ranking_3', 'ranking', 'gradebook_ranking', 'Gradebook', '', '', '', NULL, NULL, 1),
('gradebook_ranking_4', 'ranking', 'gradebook_ranking', 'Gradebook', '', '', '', NULL, NULL, 1),
('gradebook_ranking_5', 'ranking', 'gradebook_ranking', 'Gradebook', '', '', '', NULL, NULL, 1),
('gradebook_ranking_6', 'ranking', 'gradebook_ranking', 'Gradebook', '', '', '', NULL, NULL, 1),
('gradebook_ranking_7', 'ranking', 'gradebook_ranking', 'Gradebook', '', '', '', NULL, NULL, 1),
('gradebook_ranking_8', 'ranking', 'gradebook_ranking', 'Gradebook', '', '', '', NULL, NULL, 1),
('gradebook_ranking_9', 'ranking', 'gradebook_ranking', 'Gradebook', '', '', '', NULL, NULL, 1),
('gradebook_ranking_10', 'ranking', 'gradebook_ranking', 'Gradebook', '', '', '', NULL, NULL, 1),
('chamilo_database_version',NULL,'textfield',NULL, '1.9.0.17734','DatabaseVersion','', NULL, NULL, 0);
('teachers_can_change_score_settings', NULL, 'radio', 'Gradebook', 'true', 'TeachersCanChangeScoreSettingsTitle', 'TeachersCanChangeScoreSettingsComment', NULL, NULL, 1),
('teachers_can_change_grade_model_settings', NULL, 'radio', 'Gradebook', 'true', 'TeachersCanChangeGradeModelSettingsTitle', 'TeachersCanChangeGradeModelSettingsComment', NULL, NULL, 1),
('shibboleth_description', NULL, 'radio', 'Shibboleth', 'false', 'ShibbolethMainActivateTitle', 'ShibbolethMainActivateComment', NULL, NULL, 0),
('facebook_description', NULL, 'radio', 'Facebook', 'false', 'FacebookMainActivateTitle', 'FacebookMainActivateComment', NULL, NULL, 0);
('facebook_description', NULL, 'radio', 'Facebook', 'false', 'FacebookMainActivateTitle', 'FacebookMainActivateComment', NULL, NULL, 0),
('chamilo_database_version',NULL,'textfield',NULL, '1.9.0.17759','DatabaseVersion','', NULL, NULL, 0);
/*
('show_tabs', 'custom_tab_1', 'checkbox', 'Platform', 'true', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom1', 1),
@ -1199,13 +1191,10 @@ VALUES
('allow_browser_sniffer', 'false', 'No'),
('enable_wami_record', 'true', 'Yes'),
('enable_wami_record', 'false', 'No'),
('cas_add_user_activate', 'extldap', 'casAddUserActivateLDAP'),
('update_user_info_cas_with_ldap', 'true', 'Yes'),
('update_user_info_cas_with_ldap', 'false', 'No'),
('teachers_can_change_score_settings', 'true', 'Yes'),
('teachers_can_change_score_settings', 'false', 'No');
('teachers_can_change_score_settings', 'false', 'No'),
('teachers_can_change_grade_model_settings', 'true', 'Yes'),
('teachers_can_change_grade_model_settings', 'false', 'No');
UNLOCK TABLES;
/*
('activate_send_event_by_mail', 'true', 'Yes'),

@ -96,6 +96,10 @@ INSERT INTO settings_current (variable, subkey, type, category, selected_value,
INSERT INTO settings_options (variable, value, display_text) VALUES ('teachers_can_change_score_settings', 'true', 'Yes');
INSERT INTO settings_options (variable, value, display_text) VALUES ('teachers_can_change_score_settings', 'false', 'No');
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('teachers_can_change_grade_model_settings', NULL, 'radio', 'Gradebook', 'true', 'TeachersCanChangeGradeModelSettingsTitle', 'TeachersCanChangeGradeModelSettingsComment', NULL, NULL, 1);
INSERT INTO settings_options (variable, value, display_text) VALUES ('teachers_can_change_grade_model_settings', 'true', 'Yes');
INSERT INTO settings_options (variable, value, display_text) VALUES ('teachers_can_change_grade_model_settings', 'false', 'No');
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_users_to_change_email_with_no_password', NULL, 'radio', 'User', 'false', 'AllowUsersToChangeEmailWithNoPasswordTitle', 'AllowUsersToChangeEmailWithNoPasswordComment', NULL, NULL, 0);
INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_users_to_change_email_with_no_password', 'true', 'Yes');
INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_users_to_change_email_with_no_password', 'false', 'No');
@ -184,7 +188,7 @@ DELETE FROM settings_current WHERE variable = 'use_document_title';
DELETE FROM settings_options WHERE variable = 'use_document_title';
-- Do not move this query
UPDATE settings_current SET selected_value = '1.9.0.17752' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.9.0.17759' WHERE variable = 'chamilo_database_version';
-- xxSTATSxx
ALTER TABLE track_e_exercices ADD COLUMN questions_to_check TEXT NOT NULL DEFAULT '';

Loading…
Cancel
Save