dokeos
[ class tree: dokeos ] [ index: dokeos ] [ all elements ]

Source for file gradebooktable.class.php

Documentation is available at gradebooktable.class.php

  1. <?php
  2. /*
  3. ==============================================================================
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2008 Dokeos SPRL
  7.  
  8.     For a full list of contributors, see "credits.txt".
  9.     The full license can be read in "license.txt".
  10.  
  11.     This program is free software; you can redistribute it and/or
  12.     modify it under the terms of the GNU General Public License
  13.     as published by the Free Software Foundation; either version 2
  14.     of the License, or (at your option) any later version.
  15.  
  16.     See the GNU General Public License for more details.
  17.  
  18.     Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  19.     Mail: info@dokeos.com
  20. ==============================================================================
  21. */
  22.  
  23.  
  24. include_once (dirname(__FILE__).'/../../../inc/global.inc.php');
  25. include_once (dirname(__FILE__).'/../be.inc.php');
  26.  
  27. /**
  28.  * Table to display categories, evaluations and links
  29.  * @author Stijn Konings
  30.  * @author Bert Stepp� (refactored, optimised)
  31.  */
  32. class GradebookTable extends SortableTable
  33. {
  34.  
  35.     private $currentcat;
  36.     private $datagen;
  37.  
  38.  
  39.     /**
  40.      * Constructor
  41.      */
  42.     function GradebookTable ($currentcat$cats array()$evals array()$links array()$addparams null)
  43.     {
  44.         parent :: SortableTable ('gradebooklist'nullnull(api_is_allowed_to_create_course()?1:0));
  45.  
  46.         $this->currentcat = $currentcat;
  47.  
  48.         $this->datagen = new GradebookDataGenerator($cats$evals$links);
  49.         
  50.         if (isset($addparams))
  51.             $this->set_additional_parameters($addparams);
  52.     
  53.         $column0;
  54.         if (api_is_allowed_to_create_course())
  55.             $this->set_header($column++''false);
  56.         $this->set_header($column++get_lang('Type'));
  57.         $this->set_header($column++get_lang('Name'));
  58.         $this->set_header($column++get_lang('Description'))
  59.         $this->set_header($column++get_lang('Weight'));
  60.         $this->set_header($column++get_lang('Date'),true'width="100"');
  61.         
  62.         //admins get an edit column
  63.         if (api_is_allowed_to_create_course())
  64.         {
  65.             
  66.             $this->set_header($column++get_lang('Modify')false'width="80"');
  67.             //actions on multiple selected documents
  68.             $this->set_form_actions(array (
  69.                 'delete' => get_lang('DeleteSelected'),
  70.                 'setvisible' => get_lang('SetVisible'),
  71.                 'setinvisible' => get_lang('SetInvisible')));
  72.         }
  73.         //students get a result column
  74.         else
  75.         {
  76.             $this->set_header($column++get_lang('Results')false);
  77.             $this->set_header($column++get_lang('Certificates')false);
  78.         }
  79.     }
  80.  
  81.  
  82.     /**
  83.      * Function used by SortableTable to get total number of items in the table
  84.      */
  85.     function get_total_number_of_items()
  86.     {
  87.         return $this->datagen->get_total_items_count();
  88.     }
  89.  
  90.  
  91.     /** 
  92.      * Function used by SortableTable to generate the data to display
  93.      */
  94.     function get_table_data($from 1)
  95.     {
  96.  
  97.         // determine sorting type
  98.         $col_adjust (api_is_allowed_to_create_course(0);
  99.         switch ($this->column)
  100.         {
  101.             // Type
  102.             case ($col_adjust:
  103.                 $sorting GradebookDataGenerator :: GDG_SORT_TYPE;
  104.                 break;
  105.             case ($col_adjust:
  106.                 $sorting GradebookDataGenerator :: GDG_SORT_NAME;
  107.                 break;
  108.             case ($col_adjust:
  109.                 $sorting GradebookDataGenerator :: GDG_SORT_DESCRIPTION;
  110.                 break;
  111.             case ($col_adjust:
  112.                 $sorting GradebookDataGenerator :: GDG_SORT_WEIGHT;
  113.                 break;
  114.             case ($col_adjust:
  115.                 $sorting GradebookDataGenerator :: GDG_SORT_DATE;
  116.                 break;
  117.         }
  118.         if ($this->direction == 'DESC')
  119.             $sorting |= GradebookDataGenerator :: GDG_SORT_DESC;
  120.         else
  121.             $sorting |= GradebookDataGenerator :: GDG_SORT_ASC;
  122.  
  123.  
  124.  
  125.         $data_array $this->datagen->get_data($sorting$from$this->per_page);
  126.  
  127.  
  128.         // generate the data to display
  129.         $sortable_data array();
  130.         foreach ($data_array as $data)
  131.         {
  132.             $row array ();
  133.  
  134.             $item $data[0];
  135.  
  136.             //if the item is invisible, wrap it in a span with class invisible
  137.             $invisibility_span_open (api_is_allowed_to_create_course(&& $item->is_visible(== '0''<span class="invisible">' '';
  138.             $invisibility_span_close (api_is_allowed_to_create_course(&& $item->is_visible(== '0''</span>' '';
  139.             
  140.             if (api_is_allowed_to_create_course())
  141.                 $row[$this->build_id_column ($item);
  142.                 
  143.             $row[$this->build_type_column ($item);
  144.             $row[$invisibility_span_open $this->build_name_link ($item$invisibility_span_close;
  145.             $row[$invisibility_span_open $data[2$invisibility_span_close;
  146.             $row[$invisibility_span_open $data[3$invisibility_span_close;
  147.             $row[$invisibility_span_open $data[4$invisibility_span_close;
  148.  
  149.             //admins get an edit column
  150.             if (api_is_allowed_to_create_course())
  151.             {
  152.                 $row[$this->build_edit_column ($item);
  153.             }
  154.             //students get the results and certificates columns
  155.             else
  156.             {
  157.                 $row[$data[5];
  158.                 $row[$data[6];
  159.             }
  160.             $sortable_data[$row;
  161.         }
  162.         
  163.         return $sortable_data;
  164.     }
  165.  
  166.  
  167.  
  168.  
  169.     
  170. // Other functions
  171.  
  172.     private function build_id_column ($item)
  173.     {
  174.         switch ($item->get_item_type())
  175.         {
  176.             // category
  177.             case 'C' :
  178.                 return 'CATE' $item->get_id();
  179.             // evaluation
  180.             case 'E' :
  181.                 return 'EVAL' $item->get_id();
  182.             // link
  183.             case 'L' :
  184.                 return 'LINK' $item->get_id();
  185.         }
  186.     }
  187.  
  188.     private function build_type_column ($item)
  189.     {
  190.         return build_type_icon_tag($item->get_icon_name());
  191.     }
  192.  
  193.     private function build_name_link ($item)
  194.     {
  195.         switch ($item->get_item_type())
  196.         {
  197.             // category
  198.             case 'C' :
  199.                 return '&nbsp;<a href="gradebook.php?selectcat=' $item->get_id('">'
  200.                          . $item->get_name()
  201.                          . '</a>'
  202.                          . ($item->is_course(' &nbsp;[' $item->get_course_code(']' '');
  203.             // evaluation
  204.             case 'E' :
  205.  
  206.                 // course/platform admin can go to the view_results page
  207.                 if (api_is_allowed_to_create_course())
  208.                     return '&nbsp;'
  209.                         . '<a href="gradebook_view_result.php?selecteval=' $item->get_id('">'
  210.                         . $item->get_name()
  211.                         . '</a>';
  212.                 // students can go to the statistics page (if custom display enabled)
  213.                 elseif (ScoreDisplay :: instance()->is_custom())
  214.                     return '&nbsp;'
  215.                         . '<a href="gradebook_statistics.php?selecteval=' $item->get_id('">'
  216.                         . $item->get_name()
  217.                         . '</a>';
  218.                 else
  219.                     return $item->get_name();
  220.                 
  221.             // link
  222.             case 'L' :
  223.                 $url $item->get_link();
  224.                 if (isset($url))
  225.                     $text '&nbsp;<a href="' $item->get_link('">'
  226.                             . $item->get_name()
  227.                             . '</a>';
  228.                 else
  229.                     $text $item->get_name();
  230.                 $text .= '&nbsp;[' $item->get_type_name(']';
  231.                 $cc $this->currentcat->get_course_code();
  232.                 if(empty($cc))
  233.                 {
  234.                     $text .= '&nbsp;[<a href="'.api_get_path(REL_COURSE_PATH).$item->get_course_code().'/">'.$item->get_course_code().'</a>]';
  235.                 }
  236.                 return $text;
  237.         }
  238.     }
  239.  
  240.  
  241.     private function build_edit_column ($item)
  242.     {
  243.         switch ($item->get_item_type())
  244.         {
  245.             // category
  246.             case 'C' :
  247.                 return build_edit_icons_cat($item$this->currentcat->get_id());
  248.             // evaluation
  249.             case 'E' :
  250.                 return build_edit_icons_eval($item$this->currentcat->get_id());
  251.             // link
  252.             case 'L' :
  253.                 return build_edit_icons_link($item$this->currentcat->get_id());
  254.         }
  255.     }
  256.  
  257.  
  258.  
  259. }
  260. ?>

Documentation generated on Thu, 12 Jun 2008 13:33:58 -0500 by phpDocumentor 1.4.1