Feature #272 - The Gradebook: Preparing a file for changes, formatting.

skala
Ivan Tcholakov 16 years ago
parent 75a7fe5d8f
commit b29a8fcab6
  1. 148
      main/gradebook/gradebook_flatview.php

@ -1,95 +1,77 @@
<?php // $Id: $ <?php // $Id: $
/* /* For licensing terms, see /license.txt */
==============================================================================
Dokeos - elearning and course management software $language_file = 'gradebook';
Copyright (c) 2009 Dokeos Latinoamerica SAC
Copyright (c) 2006 Dokeos SPRL
Copyright (c) 2006 Ghent University (UGent)
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
$language_file= 'gradebook';
//$cidReset= true; //$cidReset= true;
require_once ('../inc/global.inc.php');
require_once ('lib/be.inc.php'); require_once '../inc/global.inc.php';
require_once ('lib/gradebook_functions.inc.php'); require_once 'lib/be.inc.php';
require_once ('lib/fe/dataform.class.php'); require_once 'lib/gradebook_functions.inc.php';
require_once ('lib/fe/userform.class.php'); require_once 'lib/fe/dataform.class.php';
require_once ('lib/flatview_data_generator.class.php'); require_once 'lib/fe/userform.class.php';
require_once ('lib/fe/flatviewtable.class.php'); require_once 'lib/flatview_data_generator.class.php';
require_once ('lib/fe/displaygradebook.php'); require_once 'lib/fe/flatviewtable.class.php';
require_once ('lib/fe/exportgradebook.php'); require_once 'lib/fe/displaygradebook.php';
require_once (api_get_path(LIBRARY_PATH).'ezpdf/class.ezpdf.php'); require_once 'lib/fe/exportgradebook.php';
require_once ('lib/scoredisplay.class.php'); require_once api_get_path(LIBRARY_PATH).'ezpdf/class.ezpdf.php';
require_once 'lib/scoredisplay.class.php';
api_block_anonymous_users(); api_block_anonymous_users();
block_students(); block_students();
if (isset ($_POST['submit']) && isset ($_POST['keyword'])) { if (isset ($_POST['submit']) && isset ($_POST['keyword'])) {
header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
. '&search='.Security::remove_XSS($_POST['keyword'])); . '&search=' . Security::remove_XSS($_POST['keyword']));
exit; exit;
} }
$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
$interbreadcrumb[]= array ( $interbreadcrumb[] = array (
'url' => $_SESSION['gradebook_dest'], 'url' => $_SESSION['gradebook_dest'],
'name' => get_lang('Gradebook' 'name' => get_lang('Gradebook')
)); );
$showeval= (isset ($_POST['showeval']) ? '1' : '0'); $showeval = isset($_POST['showeval']) ? '1' : '0';
$showlink= (isset ($_POST['showlink']) ? '1' : '0'); $showlink = isset($_POST['showlink']) ? '1' : '0';
if (($showlink == '0') && ($showeval == '0')) { if (($showlink == '0') && ($showeval == '0')) {
$showlink= '1'; $showlink = '1';
$showeval= '1'; $showeval = '1';
} }
$cat= Category :: load($_REQUEST['selectcat']);
$cat = Category::load($_REQUEST['selectcat']);
if (isset($_GET['userid'])) { if (isset($_GET['userid'])) {
$userid=Security::remove_XSS($_GET['userid']); $userid = Security::remove_XSS($_GET['userid']);
} else { } else {
$userid=''; $userid = '';
} }
if ($showeval) { if ($showeval) {
$alleval= $cat[0]->get_evaluations($userid, true); $alleval = $cat[0]->get_evaluations($userid, true);
} else { } else {
$alleval=null; $alleval = null;
} }
if ($showlink) { if ($showlink) {
$alllinks= $cat[0]->get_links($userid, true); $alllinks = $cat[0]->get_links($userid, true);
} else { } else {
$alllinks=null; $alllinks = null;
} }
if (isset($export_flatview_form) && (!$file_type == 'pdf')) {
Display :: display_normal_message($export_flatview_form->toHtml(), false);
if (isset ($export_flatview_form) && (!$file_type == 'pdf')) {
Display :: display_normal_message($export_flatview_form->toHtml(),false);
} }
if (isset($_GET['selectcat'])) { if (isset($_GET['selectcat'])) {
$category_id=Security::remove_XSS($_GET['selectcat']); $category_id = Security::remove_XSS($_GET['selectcat']);
} else { } else {
$category_id=''; $category_id = '';
} }
$simple_search_form= new UserForm(UserForm :: TYPE_SIMPLE_SEARCH, null, 'simple_search_form', null, api_get_self() . '?selectcat=' .$category_id); $simple_search_form = new UserForm(UserForm :: TYPE_SIMPLE_SEARCH, null, 'simple_search_form', null, api_get_self() . '?selectcat=' . $category_id);
$values= $simple_search_form->exportValues(); $values = $simple_search_form->exportValues();
$keyword = ''; $keyword = '';
if (isset($_GET['search']) && !empty($_GET['search'])) { if (isset($_GET['search']) && !empty($_GET['search'])) {
$keyword = Security::remove_XSS($_GET['search']); $keyword = Security::remove_XSS($_GET['search']);
@ -98,28 +80,28 @@ if ($simple_search_form->validate() && (empty($keyword))) {
$keyword = $values['keyword']; $keyword = $values['keyword'];
} }
if (!empty($keyword)) { if (!empty($keyword)) {
$users= find_students($keyword); $users = find_students($keyword);
} else { } else {
if (isset($alleval) && isset($alllinks)) { if (isset($alleval) && isset($alllinks)) {
$users= get_all_users($alleval, $alllinks); $users = get_all_users($alleval, $alllinks);
}else { } else {
$users=null; $users = null;
} }
} }
if (isset ($_GET['exportpdf'])) { if (isset ($_GET['exportpdf'])) {
$interbreadcrumb[]= array ( $interbreadcrumb[] = array (
'url' => api_get_self().'?selectcat=' . Security::remove_XSS($_GET['selectcat']), 'url' => api_get_self().'?selectcat=' . Security::remove_XSS($_GET['selectcat']),
'name' => get_lang('FlatView') 'name' => get_lang('FlatView')
); );
$export_pdf_form= new DataForm(DataForm :: TYPE_EXPORT_PDF, 'export_pdf_form', null, api_get_self() . '?exportpdf=&offset='.$_GET['offset'].'&selectcat=' . $_GET['selectcat'],'_blank'); $export_pdf_form = new DataForm(DataForm :: TYPE_EXPORT_PDF, 'export_pdf_form', null, api_get_self() . '?exportpdf=&offset='.$_GET['offset'].'&selectcat=' . $_GET['selectcat'],'_blank');
if (!$export_pdf_form->validate()) { if (!$export_pdf_form->validate()) {
Display :: display_header(get_lang('ExportPDF')); Display :: display_header(get_lang('ExportPDF'));
} }
if ($export_pdf_form->validate()) { if ($export_pdf_form->validate()) {
$printable_data = get_printable_data ($users,$alleval, $alllinks); $printable_data = get_printable_data($users, $alleval, $alllinks);
$export= $export_pdf_form->exportValues(); $export = $export_pdf_form->exportValues();
$format = $export['orientation']; $format = $export['orientation'];
$pdf =& new Cezpdf('a4',$format); //format is 'portrait' or 'landscape' $pdf =& new Cezpdf('a4',$format); //format is 'portrait' or 'landscape'
$clear_printable_data=array(); $clear_printable_data=array();
@ -146,24 +128,24 @@ if (isset ($_GET['print'])) {
exit; exit;
} }
if(!empty($_POST['export_report']) && $_POST['export_report'] == 'export_report'){ if (!empty($_POST['export_report']) && $_POST['export_report'] == 'export_report') {
if(api_is_platform_admin() || api_is_course_admin() || api_is_course_coach()) { if (api_is_platform_admin() || api_is_course_admin() || api_is_course_coach()) {
$user_id = null; $user_id = null;
if(empty($_SESSION['export_user_fields'])) { if (empty($_SESSION['export_user_fields'])) {
$_SESSION['export_user_fields'] = false; $_SESSION['export_user_fields'] = false;
} }
if(!api_is_allowed_to_edit(false,false) and !api_is_course_tutor()) { if (!api_is_allowed_to_edit(false, false) and !api_is_course_tutor()) {
$user_id = api_get_user_id(); $user_id = api_get_user_id();
} }
require_once('gradebook_result.class.php'); require_once 'gradebook_result.class.php';
$printable_data = get_printable_data ($users,$alleval, $alllinks); $printable_data = get_printable_data($users, $alleval, $alllinks);
switch($_POST['export_format']) { switch($_POST['export_format']) {
case 'xls': case 'xls':
$export = new GradeBookResult(); $export = new GradeBookResult();
$export->exportCompleteReportXLS($printable_data ); $export->exportCompleteReportXLS($printable_data);
exit; exit;
break; break;
case 'csv': case 'csv':
@ -178,13 +160,13 @@ if(!empty($_POST['export_report']) && $_POST['export_report'] == 'export_report'
} }
} }
$addparams= array ('selectcat' => $cat[0]->get_id()); $addparams = array ('selectcat' => $cat[0]->get_id());
if (isset($_GET['search'])) { if (isset($_GET['search'])) {
$addparams['search'] = $keyword; $addparams['search'] = $keyword;
} }
$offset = (isset($_GET['offset'])?$_GET['offset']:'0');
$flatviewtable= new FlatViewTable($cat[0], $users, $alleval, $alllinks, true, $offset, $addparams); $offset = isset($_GET['offset']) ? $_GET['offset'] : '0';
$flatviewtable = new FlatViewTable($cat[0], $users, $alleval, $alllinks, true, $offset, $addparams);
if (isset($_GET['exportpdf'])) { if (isset($_GET['exportpdf'])) {
echo '<div class="normal-message">'; echo '<div class="normal-message">';
@ -193,10 +175,11 @@ if (isset($_GET['exportpdf'])) {
} else { } else {
Display :: display_header(get_lang('FlatView')); Display :: display_header(get_lang('FlatView'));
} }
if (isset($_GET['isStudentView']) && $_GET['isStudentView']=='false') {
if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false') {
DisplayGradebook :: display_header_reduce_flatview($cat[0], $showeval, $showlink, $simple_search_form); DisplayGradebook :: display_header_reduce_flatview($cat[0], $showeval, $showlink, $simple_search_form);
$flatviewtable->display(); $flatviewtable->display();
} elseif (isset($_GET['selectcat']) && ($_SESSION['studentview']=='teacherview')) { } elseif (isset($_GET['selectcat']) && ($_SESSION['studentview'] == 'teacherview')) {
DisplayGradebook :: display_header_reduce_flatview($cat[0], $showeval, $showlink, $simple_search_form); DisplayGradebook :: display_header_reduce_flatview($cat[0], $showeval, $showlink, $simple_search_form);
/*echo '<div id="contentLoading" class="contentLoading">'; /*echo '<div id="contentLoading" class="contentLoading">';
echo Display::display_icon('loader.gif'); echo Display::display_icon('loader.gif');
@ -206,15 +189,16 @@ if (isset($_GET['isStudentView']) && $_GET['isStudentView']=='false') {
//@todo load images with jquery //@todo load images with jquery
echo '<div id="contentArea" style="text-align:center;" >'; echo '<div id="contentArea" style="text-align:center;" >';
$image_file = $flatviewtable->display_graph(); $image_file = $flatviewtable->display_graph();
$my_info_path_img=array(); $my_info_path_img = array();
$my_info_path_img=explode('/',$image_file); $my_info_path_img = explode('/', $image_file);
if (strlen($my_info_path_img[5])==32) { if (strlen($my_info_path_img[5]) == 32) {
echo '<img src="'.$image_file.'">'; echo '<img src="'.$image_file.'">';
} }
$flatviewtable->display(); $flatviewtable->display();
$flatviewtable->display_graph_by_resource(); $flatviewtable->display_graph_by_resource();
echo '</div>'; echo '</div>';
} }
Display :: display_footer(); Display :: display_footer();
function get_printable_data($users,$alleval, $alllinks) { function get_printable_data($users,$alleval, $alllinks) {

Loading…
Cancel
Save