@@ -10,133 +10,133 @@ |
||
10 | 10 | */ |
11 | 11 | class LinkForm extends FormValidator |
12 | 12 | { |
13 | - const TYPE_CREATE = 1; |
|
14 | - const TYPE_MOVE = 2; |
|
15 | - /** @var Category */ |
|
16 | - private $category_object; |
|
17 | - private $link_object; |
|
18 | - private $extra; |
|
13 | + const TYPE_CREATE = 1; |
|
14 | + const TYPE_MOVE = 2; |
|
15 | + /** @var Category */ |
|
16 | + private $category_object; |
|
17 | + private $link_object; |
|
18 | + private $extra; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Builds a form containing form items based on a given parameter |
|
22 | - * @param int form_type 1=choose link |
|
23 | - * @param obj cat_obj the category object |
|
24 | - * @param string form name |
|
25 | - * @param method |
|
26 | - * @param action |
|
27 | - */ |
|
28 | - public function LinkForm( |
|
29 | - $form_type, |
|
30 | - $category_object, |
|
31 | - $link_object, |
|
32 | - $form_name, |
|
33 | - $method = 'post', |
|
34 | - $action = null, |
|
35 | - $extra = null |
|
36 | - ) { |
|
37 | - parent :: __construct($form_name, $method, $action); |
|
20 | + /** |
|
21 | + * Builds a form containing form items based on a given parameter |
|
22 | + * @param int form_type 1=choose link |
|
23 | + * @param obj cat_obj the category object |
|
24 | + * @param string form name |
|
25 | + * @param method |
|
26 | + * @param action |
|
27 | + */ |
|
28 | + public function LinkForm( |
|
29 | + $form_type, |
|
30 | + $category_object, |
|
31 | + $link_object, |
|
32 | + $form_name, |
|
33 | + $method = 'post', |
|
34 | + $action = null, |
|
35 | + $extra = null |
|
36 | + ) { |
|
37 | + parent :: __construct($form_name, $method, $action); |
|
38 | 38 | |
39 | - if (isset ($category_object)) { |
|
40 | - $this->category_object = $category_object; |
|
41 | - } else { |
|
42 | - if (isset($link_object)) { |
|
43 | - $this->link_object = $link_object; |
|
44 | - } |
|
45 | - } |
|
39 | + if (isset ($category_object)) { |
|
40 | + $this->category_object = $category_object; |
|
41 | + } else { |
|
42 | + if (isset($link_object)) { |
|
43 | + $this->link_object = $link_object; |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | - if (isset ($extra)) { |
|
48 | - $this->extra = $extra; |
|
49 | - } |
|
50 | - if ($form_type == self :: TYPE_CREATE) { |
|
51 | - $this->build_create(); |
|
52 | - } elseif ($form_type == self :: TYPE_MOVE) { |
|
53 | - $this->build_move(); |
|
54 | - } |
|
55 | - } |
|
47 | + if (isset ($extra)) { |
|
48 | + $this->extra = $extra; |
|
49 | + } |
|
50 | + if ($form_type == self :: TYPE_CREATE) { |
|
51 | + $this->build_create(); |
|
52 | + } elseif ($form_type == self :: TYPE_MOVE) { |
|
53 | + $this->build_move(); |
|
54 | + } |
|
55 | + } |
|
56 | 56 | |
57 | - protected function build_move() |
|
58 | - { |
|
59 | - $renderer =& $this->defaultRenderer(); |
|
60 | - $renderer->setCustomElementTemplate('<span>{element}</span> '); |
|
61 | - $this->addElement('static',null,null,'"'.$this->link_object->get_name().'" '); |
|
62 | - $this->addElement('static',null,null,get_lang('MoveTo').' : '); |
|
63 | - $select = $this->addElement('select','move_cat',null,null); |
|
64 | - $line = ''; |
|
65 | - foreach ($this->link_object->get_target_categories() as $cat) { |
|
66 | - for ($i=0;$i<$cat[2];$i++) { |
|
67 | - $line .= '—'; |
|
68 | - } |
|
69 | - $select->addoption($line.' '.$cat[1],$cat[0]); |
|
70 | - $line = ''; |
|
71 | - } |
|
72 | - $this->addElement('submit', null, get_lang('Ok')); |
|
73 | - } |
|
57 | + protected function build_move() |
|
58 | + { |
|
59 | + $renderer =& $this->defaultRenderer(); |
|
60 | + $renderer->setCustomElementTemplate('<span>{element}</span> '); |
|
61 | + $this->addElement('static',null,null,'"'.$this->link_object->get_name().'" '); |
|
62 | + $this->addElement('static',null,null,get_lang('MoveTo').' : '); |
|
63 | + $select = $this->addElement('select','move_cat',null,null); |
|
64 | + $line = ''; |
|
65 | + foreach ($this->link_object->get_target_categories() as $cat) { |
|
66 | + for ($i=0;$i<$cat[2];$i++) { |
|
67 | + $line .= '—'; |
|
68 | + } |
|
69 | + $select->addoption($line.' '.$cat[1],$cat[0]); |
|
70 | + $line = ''; |
|
71 | + } |
|
72 | + $this->addElement('submit', null, get_lang('Ok')); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Builds the form |
|
77 | - */ |
|
78 | - protected function build_create() |
|
79 | - { |
|
80 | - $this->addElement('header', get_lang('MakeLink')); |
|
81 | - $select = $this->addElement( |
|
82 | - 'select', |
|
83 | - 'select_link', |
|
84 | - get_lang('ChooseLink'), |
|
85 | - null, |
|
86 | - array('onchange' => 'document.create_link.submit()') |
|
87 | - ); |
|
75 | + /** |
|
76 | + * Builds the form |
|
77 | + */ |
|
78 | + protected function build_create() |
|
79 | + { |
|
80 | + $this->addElement('header', get_lang('MakeLink')); |
|
81 | + $select = $this->addElement( |
|
82 | + 'select', |
|
83 | + 'select_link', |
|
84 | + get_lang('ChooseLink'), |
|
85 | + null, |
|
86 | + array('onchange' => 'document.create_link.submit()') |
|
87 | + ); |
|
88 | 88 | |
89 | - $linkTypes = LinkFactory::get_all_types(); |
|
89 | + $linkTypes = LinkFactory::get_all_types(); |
|
90 | 90 | |
91 | - $select->addoption('['.get_lang('ChooseLink').']', 0); |
|
91 | + $select->addoption('['.get_lang('ChooseLink').']', 0); |
|
92 | 92 | |
93 | - $courseCode = $this->category_object->get_course_code(); |
|
93 | + $courseCode = $this->category_object->get_course_code(); |
|
94 | 94 | |
95 | - foreach ($linkTypes as $linkType) { |
|
96 | - // The hot potatoe link will be added "inside" the exercise option. |
|
97 | - if ($linkType == LINK_HOTPOTATOES) { |
|
98 | - continue; |
|
99 | - } |
|
100 | - $link = $this->createLink($linkType, $courseCode); |
|
101 | - // disable this element if the link works with a dropdownlist |
|
102 | - // and if there are no links left |
|
103 | - if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') { |
|
104 | - $select->addoption($link->get_type_name(), $linkType, 'disabled'); |
|
105 | - } else { |
|
106 | - if ($link->get_type() == LINK_EXERCISE) { |
|
107 | - // Adding exercise |
|
108 | - $select->addoption($link->get_type_name(), $linkType); |
|
109 | - // Adding hot potatoes |
|
110 | - $linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode); |
|
111 | - $select->addoption( |
|
112 | - ' '.$linkHot->get_type_name(), |
|
113 | - LINK_HOTPOTATOES |
|
114 | - ); |
|
115 | - } else { |
|
116 | - $select->addoption($link->get_type_name(), $linkType); |
|
117 | - } |
|
118 | - } |
|
119 | - } |
|
95 | + foreach ($linkTypes as $linkType) { |
|
96 | + // The hot potatoe link will be added "inside" the exercise option. |
|
97 | + if ($linkType == LINK_HOTPOTATOES) { |
|
98 | + continue; |
|
99 | + } |
|
100 | + $link = $this->createLink($linkType, $courseCode); |
|
101 | + // disable this element if the link works with a dropdownlist |
|
102 | + // and if there are no links left |
|
103 | + if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') { |
|
104 | + $select->addoption($link->get_type_name(), $linkType, 'disabled'); |
|
105 | + } else { |
|
106 | + if ($link->get_type() == LINK_EXERCISE) { |
|
107 | + // Adding exercise |
|
108 | + $select->addoption($link->get_type_name(), $linkType); |
|
109 | + // Adding hot potatoes |
|
110 | + $linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode); |
|
111 | + $select->addoption( |
|
112 | + ' '.$linkHot->get_type_name(), |
|
113 | + LINK_HOTPOTATOES |
|
114 | + ); |
|
115 | + } else { |
|
116 | + $select->addoption($link->get_type_name(), $linkType); |
|
117 | + } |
|
118 | + } |
|
119 | + } |
|
120 | 120 | |
121 | - if (isset($this->extra)) { |
|
122 | - $this->setDefaults(array('select_link' => $this->extra)); |
|
123 | - } |
|
124 | - } |
|
121 | + if (isset($this->extra)) { |
|
122 | + $this->setDefaults(array('select_link' => $this->extra)); |
|
123 | + } |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * @param $link |
|
128 | - * @param $courseCode |
|
129 | - * @return AttendanceLink|DropboxLink|ExerciseLink|ForumThreadLink|LearnpathLink|null|StudentPublicationLink|SurveyLink |
|
130 | - */ |
|
131 | - private function createLink($link, $courseCode) |
|
132 | - { |
|
133 | - $link = LinkFactory::create($link); |
|
134 | - if (!empty($courseCode)) { |
|
135 | - $link->set_course_code($courseCode); |
|
136 | - } elseif(!empty($_GET['course_code'])) { |
|
137 | - $link->set_course_code(Database::escape_string($_GET['course_code'], null, false)); |
|
138 | - } |
|
126 | + /** |
|
127 | + * @param $link |
|
128 | + * @param $courseCode |
|
129 | + * @return AttendanceLink|DropboxLink|ExerciseLink|ForumThreadLink|LearnpathLink|null|StudentPublicationLink|SurveyLink |
|
130 | + */ |
|
131 | + private function createLink($link, $courseCode) |
|
132 | + { |
|
133 | + $link = LinkFactory::create($link); |
|
134 | + if (!empty($courseCode)) { |
|
135 | + $link->set_course_code($courseCode); |
|
136 | + } elseif(!empty($_GET['course_code'])) { |
|
137 | + $link->set_course_code(Database::escape_string($_GET['course_code'], null, false)); |
|
138 | + } |
|
139 | 139 | |
140 | - return $link; |
|
141 | - } |
|
140 | + return $link; |
|
141 | + } |
|
142 | 142 | } |
@@ -10,162 +10,162 @@ |
||
10 | 10 | */ |
11 | 11 | class ResultTable extends SortableTable |
12 | 12 | { |
13 | - private $datagen; |
|
14 | - private $evaluation; |
|
15 | - private $allresults; |
|
16 | - private $iscourse; |
|
17 | - |
|
18 | - /** |
|
19 | - * Constructor |
|
20 | - */ |
|
13 | + private $datagen; |
|
14 | + private $evaluation; |
|
15 | + private $allresults; |
|
16 | + private $iscourse; |
|
17 | + |
|
18 | + /** |
|
19 | + * Constructor |
|
20 | + */ |
|
21 | 21 | public function ResultTable ($evaluation, $results = array(), $iscourse, $addparams = null,$forprint = false) |
22 | - { |
|
23 | - parent :: __construct ('resultlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1); |
|
24 | - |
|
25 | - $this->datagen = new ResultsDataGenerator($evaluation, $results, true); |
|
26 | - |
|
27 | - $this->evaluation = $evaluation; |
|
28 | - $this->iscourse = $iscourse; |
|
29 | - $this->forprint = $forprint; |
|
30 | - |
|
31 | - if (isset ($addparams)) { |
|
32 | - $this->set_additional_parameters($addparams); |
|
33 | - } |
|
34 | - $scoredisplay = ScoreDisplay :: instance(); |
|
35 | - $column= 0; |
|
36 | - if ($this->iscourse == '1') { |
|
37 | - $this->set_header($column++, '', false); |
|
38 | - $this->set_form_actions(array ( |
|
39 | - 'delete' => get_lang('Delete') |
|
40 | - )); |
|
41 | - } |
|
42 | - if (api_is_western_name_order()) { |
|
43 | - $this->set_header($column++, get_lang('FirstName')); |
|
44 | - $this->set_header($column++, get_lang('LastName')); |
|
45 | - } else { |
|
46 | - $this->set_header($column++, get_lang('LastName')); |
|
47 | - $this->set_header($column++, get_lang('FirstName')); |
|
48 | - } |
|
49 | - $this->set_header($column++, get_lang('Score')); |
|
50 | - if ($scoredisplay->is_custom()) { |
|
51 | - $this->set_header($column++, get_lang('Display')); |
|
52 | - } |
|
53 | - if (!$this->forprint) { |
|
54 | - $this->set_header($column++, get_lang('Modify'),false); |
|
55 | - } |
|
22 | + { |
|
23 | + parent :: __construct ('resultlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1); |
|
24 | + |
|
25 | + $this->datagen = new ResultsDataGenerator($evaluation, $results, true); |
|
26 | + |
|
27 | + $this->evaluation = $evaluation; |
|
28 | + $this->iscourse = $iscourse; |
|
29 | + $this->forprint = $forprint; |
|
30 | + |
|
31 | + if (isset ($addparams)) { |
|
32 | + $this->set_additional_parameters($addparams); |
|
33 | + } |
|
34 | + $scoredisplay = ScoreDisplay :: instance(); |
|
35 | + $column= 0; |
|
36 | + if ($this->iscourse == '1') { |
|
37 | + $this->set_header($column++, '', false); |
|
38 | + $this->set_form_actions(array ( |
|
39 | + 'delete' => get_lang('Delete') |
|
40 | + )); |
|
41 | + } |
|
42 | + if (api_is_western_name_order()) { |
|
43 | + $this->set_header($column++, get_lang('FirstName')); |
|
44 | + $this->set_header($column++, get_lang('LastName')); |
|
45 | + } else { |
|
46 | + $this->set_header($column++, get_lang('LastName')); |
|
47 | + $this->set_header($column++, get_lang('FirstName')); |
|
48 | + } |
|
49 | + $this->set_header($column++, get_lang('Score')); |
|
50 | + if ($scoredisplay->is_custom()) { |
|
51 | + $this->set_header($column++, get_lang('Display')); |
|
52 | + } |
|
53 | + if (!$this->forprint) { |
|
54 | + $this->set_header($column++, get_lang('Modify'),false); |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Function used by SortableTable to get total number of items in the table |
|
61 | - */ |
|
62 | - function get_total_number_of_items () { |
|
63 | - return $this->datagen->get_total_results_count(); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Function used by SortableTable to generate the data to display |
|
68 | - */ |
|
69 | - function get_table_data ($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) { |
|
70 | - |
|
71 | - $is_western_name_order = api_is_western_name_order(); |
|
72 | - $scoredisplay = ScoreDisplay :: instance(); |
|
73 | - |
|
74 | - // determine sorting type |
|
75 | - $col_adjust = $this->iscourse == '1' ? 1 : 0; |
|
76 | - |
|
77 | - switch ($this->column) { |
|
78 | - // first name or last name |
|
79 | - case (0 + $col_adjust): |
|
80 | - if ($is_western_name_order) { |
|
81 | - $sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME; |
|
82 | - } else { |
|
83 | - $sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME; |
|
84 | - } |
|
85 | - break; |
|
59 | + /** |
|
60 | + * Function used by SortableTable to get total number of items in the table |
|
61 | + */ |
|
62 | + function get_total_number_of_items () { |
|
63 | + return $this->datagen->get_total_results_count(); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Function used by SortableTable to generate the data to display |
|
68 | + */ |
|
69 | + function get_table_data ($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) { |
|
70 | + |
|
71 | + $is_western_name_order = api_is_western_name_order(); |
|
72 | + $scoredisplay = ScoreDisplay :: instance(); |
|
73 | + |
|
74 | + // determine sorting type |
|
75 | + $col_adjust = $this->iscourse == '1' ? 1 : 0; |
|
76 | + |
|
77 | + switch ($this->column) { |
|
86 | 78 | // first name or last name |
87 | - case (1 + $col_adjust): |
|
88 | - if ($is_western_name_order) { |
|
89 | - $sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME; |
|
90 | - } else { |
|
91 | - $sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME; |
|
92 | - } |
|
93 | - break; |
|
79 | + case (0 + $col_adjust): |
|
80 | + if ($is_western_name_order) { |
|
81 | + $sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME; |
|
82 | + } else { |
|
83 | + $sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME; |
|
84 | + } |
|
85 | + break; |
|
86 | + // first name or last name |
|
87 | + case (1 + $col_adjust): |
|
88 | + if ($is_western_name_order) { |
|
89 | + $sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME; |
|
90 | + } else { |
|
91 | + $sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME; |
|
92 | + } |
|
93 | + break; |
|
94 | 94 | //Score |
95 | - case (2 + $col_adjust): |
|
96 | - $sorting = ResultsDataGenerator :: RDG_SORT_SCORE; |
|
97 | - break; |
|
98 | - case (3 + $col_adjust): |
|
99 | - $sorting = ResultsDataGenerator :: RDG_SORT_MASK; |
|
100 | - break; |
|
101 | - } |
|
102 | - |
|
103 | - if ($this->direction == 'DESC') { |
|
104 | - $sorting |= ResultsDataGenerator :: RDG_SORT_DESC; |
|
105 | - } else { |
|
106 | - $sorting |= ResultsDataGenerator :: RDG_SORT_ASC; |
|
107 | - } |
|
108 | - |
|
109 | - $data_array = $this->datagen->get_data($sorting, $from, $this->per_page); |
|
110 | - |
|
111 | - // generate the data to display |
|
112 | - $sortable_data = array(); |
|
113 | - foreach ($data_array as $item) { |
|
114 | - $row = array (); |
|
115 | - if ($this->iscourse == '1') { |
|
116 | - $row[] = $item['result_id']; |
|
117 | - } |
|
118 | - if ($is_western_name_order) { |
|
119 | - $row[] = $item['firstname']; |
|
120 | - $row[] = $item['lastname']; |
|
121 | - } else { |
|
122 | - $row[] = $item['lastname']; |
|
123 | - $row[] = $item['firstname']; |
|
124 | - } |
|
125 | - |
|
126 | - $row[] = Display::bar_progress($item['percentage_score'], false, $item['score']); |
|
95 | + case (2 + $col_adjust): |
|
96 | + $sorting = ResultsDataGenerator :: RDG_SORT_SCORE; |
|
97 | + break; |
|
98 | + case (3 + $col_adjust): |
|
99 | + $sorting = ResultsDataGenerator :: RDG_SORT_MASK; |
|
100 | + break; |
|
101 | + } |
|
102 | + |
|
103 | + if ($this->direction == 'DESC') { |
|
104 | + $sorting |= ResultsDataGenerator :: RDG_SORT_DESC; |
|
105 | + } else { |
|
106 | + $sorting |= ResultsDataGenerator :: RDG_SORT_ASC; |
|
107 | + } |
|
108 | + |
|
109 | + $data_array = $this->datagen->get_data($sorting, $from, $this->per_page); |
|
110 | + |
|
111 | + // generate the data to display |
|
112 | + $sortable_data = array(); |
|
113 | + foreach ($data_array as $item) { |
|
114 | + $row = array (); |
|
115 | + if ($this->iscourse == '1') { |
|
116 | + $row[] = $item['result_id']; |
|
117 | + } |
|
118 | + if ($is_western_name_order) { |
|
119 | + $row[] = $item['firstname']; |
|
120 | + $row[] = $item['lastname']; |
|
121 | + } else { |
|
122 | + $row[] = $item['lastname']; |
|
123 | + $row[] = $item['firstname']; |
|
124 | + } |
|
125 | + |
|
126 | + $row[] = Display::bar_progress($item['percentage_score'], false, $item['score']); |
|
127 | 127 | //$row[] = Display::bar_progress($item['percentage_score'], true); |
128 | - if ($scoredisplay->is_custom()) { |
|
129 | - $row[] = $item['display']; |
|
130 | - } |
|
131 | - if (!$this->forprint) { |
|
132 | - $row[] = $this->build_edit_column ($item); |
|
133 | - } |
|
134 | - $sortable_data[] = $row; |
|
135 | - } |
|
136 | - |
|
137 | - return $sortable_data; |
|
138 | - } |
|
139 | - |
|
140 | - private function build_edit_column ($item) |
|
141 | - { |
|
142 | - $status=CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); |
|
143 | - $locked_status = $this->evaluation->get_locked(); |
|
144 | - if (api_is_allowed_to_edit(null, true) && $locked_status == 0) { |
|
145 | - //api_is_course_admin() |
|
146 | - $edit_column = '<a href="' . api_get_self() . '?editres=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'. |
|
147 | - Display::return_icon('edit.png', get_lang('Modify'),'','22').'</a>'; |
|
148 | - $edit_column .= ' <a href="' . api_get_self() . '?delete_mark=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'. |
|
149 | - Display::return_icon('delete.png', get_lang('Delete'),'','22').'</a>'; |
|
150 | - } |
|
151 | - if ($this->evaluation->get_course_code() == null) { |
|
152 | - $edit_column.= ' <a href="' . api_get_self() . '?resultdelete=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '" onclick="return confirmationuser();"> |
|
128 | + if ($scoredisplay->is_custom()) { |
|
129 | + $row[] = $item['display']; |
|
130 | + } |
|
131 | + if (!$this->forprint) { |
|
132 | + $row[] = $this->build_edit_column ($item); |
|
133 | + } |
|
134 | + $sortable_data[] = $row; |
|
135 | + } |
|
136 | + |
|
137 | + return $sortable_data; |
|
138 | + } |
|
139 | + |
|
140 | + private function build_edit_column ($item) |
|
141 | + { |
|
142 | + $status=CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); |
|
143 | + $locked_status = $this->evaluation->get_locked(); |
|
144 | + if (api_is_allowed_to_edit(null, true) && $locked_status == 0) { |
|
145 | + //api_is_course_admin() |
|
146 | + $edit_column = '<a href="' . api_get_self() . '?editres=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'. |
|
147 | + Display::return_icon('edit.png', get_lang('Modify'),'','22').'</a>'; |
|
148 | + $edit_column .= ' <a href="' . api_get_self() . '?delete_mark=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'. |
|
149 | + Display::return_icon('delete.png', get_lang('Delete'),'','22').'</a>'; |
|
150 | + } |
|
151 | + if ($this->evaluation->get_course_code() == null) { |
|
152 | + $edit_column.= ' <a href="' . api_get_self() . '?resultdelete=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '" onclick="return confirmationuser();"> |
|
153 | 153 | <img src="../img/delete.gif" border="0" title="' . get_lang('Delete') . '" alt="" /></a>'; |
154 | - $edit_column.= ' <a href="user_stats.php?userid=' . $item['id'] . '&selecteval=' . $this->evaluation->get_id() . '&'.api_get_cidreq().'"> |
|
154 | + $edit_column.= ' <a href="user_stats.php?userid=' . $item['id'] . '&selecteval=' . $this->evaluation->get_id() . '&'.api_get_cidreq().'"> |
|
155 | 155 | <img src="../img/statistics.gif" width="17px" border="0" title="' . get_lang('Statistics') . '" alt="" /></a>'; |
156 | - } |
|
157 | - // Evaluation's origin is a link |
|
158 | - if ($this->evaluation->get_category_id() < 0) { |
|
159 | - $link = LinkFactory :: get_evaluation_link ($this->evaluation->get_id()); |
|
160 | - |
|
161 | - $doc_url = $link->get_view_url($item['id']); |
|
162 | - |
|
163 | - if ($doc_url != null) { |
|
164 | - $edit_column .= ' <a href="'. $doc_url . '" target="_blank">' |
|
165 | - .'<img src="'. api_get_path(WEB_CODE_PATH) . 'img/link.gif" border="0" title="' . get_lang('OpenDocument') . '" alt="" />' |
|
166 | - .'</a>'; |
|
167 | - } |
|
168 | - } |
|
169 | - return $edit_column; |
|
170 | - } |
|
156 | + } |
|
157 | + // Evaluation's origin is a link |
|
158 | + if ($this->evaluation->get_category_id() < 0) { |
|
159 | + $link = LinkFactory :: get_evaluation_link ($this->evaluation->get_id()); |
|
160 | + |
|
161 | + $doc_url = $link->get_view_url($item['id']); |
|
162 | + |
|
163 | + if ($doc_url != null) { |
|
164 | + $edit_column .= ' <a href="'. $doc_url . '" target="_blank">' |
|
165 | + .'<img src="'. api_get_path(WEB_CODE_PATH) . 'img/link.gif" border="0" title="' . get_lang('OpenDocument') . '" alt="" />' |
|
166 | + .'</a>'; |
|
167 | + } |
|
168 | + } |
|
169 | + return $edit_column; |
|
170 | + } |
|
171 | 171 | } |
@@ -1,18 +1,18 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /license.txt */ |
3 | 3 | /** |
4 | - * Script |
|
5 | - * @package chamilo.gradebook |
|
6 | - */ |
|
4 | + * Script |
|
5 | + * @package chamilo.gradebook |
|
6 | + */ |
|
7 | 7 | /** |
8 | - * Prints an HTML page with a table containing the gradebook data |
|
9 | - * @param array Array containing the data to be printed in the table |
|
10 | - * @param array Table headers |
|
11 | - * @param string View to print as a title for the table |
|
12 | - * @param string Course name to print as title for the table |
|
13 | - */ |
|
8 | + * Prints an HTML page with a table containing the gradebook data |
|
9 | + * @param array Array containing the data to be printed in the table |
|
10 | + * @param array Table headers |
|
11 | + * @param string View to print as a title for the table |
|
12 | + * @param string Course name to print as title for the table |
|
13 | + */ |
|
14 | 14 | function print_table ($data_array,$header_names,$view,$coursename) { |
15 | - $printdata= '<!DOCTYPE html |
|
15 | + $printdata= '<!DOCTYPE html |
|
16 | 16 | PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
17 | 17 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
18 | 18 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.api_get_language_isocode().'" lang="'.api_get_language_isocode().'"> |
@@ -64,24 +64,24 @@ discard block |
||
64 | 64 | </head> |
65 | 65 | <body dir="'.api_get_text_direction().'"><div id="main">'; |
66 | 66 | |
67 | - $printdata .= '<h2>'.$view.' : '.$coursename.'</h2>'; |
|
68 | - //@todo not necessary here |
|
69 | - //$printdata .= '<h3>'.get_lang('Date').' : '.api_convert_and_format_date(null, DATE_FORMAT_SHORT). ' ' . api_convert_and_format_date(null, TIME_NO_SEC_FORMAT).'</h3>'; |
|
70 | - $printdata .= '<table border="1" width="90%" cellspacing="1" cellpadding="1">'; |
|
71 | - foreach ($header_names as $header) { |
|
72 | - $printdata .= '<th>'.$header.'</th>'; |
|
73 | - } |
|
67 | + $printdata .= '<h2>'.$view.' : '.$coursename.'</h2>'; |
|
68 | + //@todo not necessary here |
|
69 | + //$printdata .= '<h3>'.get_lang('Date').' : '.api_convert_and_format_date(null, DATE_FORMAT_SHORT). ' ' . api_convert_and_format_date(null, TIME_NO_SEC_FORMAT).'</h3>'; |
|
70 | + $printdata .= '<table border="1" width="90%" cellspacing="1" cellpadding="1">'; |
|
71 | + foreach ($header_names as $header) { |
|
72 | + $printdata .= '<th>'.$header.'</th>'; |
|
73 | + } |
|
74 | 74 | |
75 | - foreach ($data_array as $data) { |
|
76 | - $printdata .= '<tr>'; |
|
77 | - foreach ($data as $rowdata) { |
|
78 | - $printdata .= '<td>'.$rowdata.'</td>'; |
|
79 | - } |
|
80 | - $printdata .= '</tr>'; |
|
75 | + foreach ($data_array as $data) { |
|
76 | + $printdata .= '<tr>'; |
|
77 | + foreach ($data as $rowdata) { |
|
78 | + $printdata .= '<td>'.$rowdata.'</td>'; |
|
79 | + } |
|
80 | + $printdata .= '</tr>'; |
|
81 | 81 | |
82 | - } |
|
83 | - $printdata .= '</table></div></body></html>'; |
|
84 | - return $printdata; |
|
82 | + } |
|
83 | + $printdata .= '</table></div></body></html>'; |
|
84 | + return $printdata; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | */ |
96 | 96 | function export_pdf_attendance($headers_table, $data_table, $headers_pdf, $footers_pdf, $title_pdf) { |
97 | 97 | |
98 | - $mpdf = new mPDF('UTF-8', 'A4-L', '', '', 15, 10, 35, 20, 4, 2, 'L'); |
|
99 | - $mpdf->useOnlyCoreFonts = true; |
|
100 | - $mpdf->mirrorMargins = 0; // Use different Odd/Even headers and footers and mirror margins |
|
98 | + $mpdf = new mPDF('UTF-8', 'A4-L', '', '', 15, 10, 35, 20, 4, 2, 'L'); |
|
99 | + $mpdf->useOnlyCoreFonts = true; |
|
100 | + $mpdf->mirrorMargins = 0; // Use different Odd/Even headers and footers and mirror margins |
|
101 | 101 | |
102 | - if (is_array($headers_pdf)) { |
|
103 | - // preparing headers pdf |
|
104 | - $header = '<table width="100%" cellspacing="1" cellpadding="1" border="0" class="strong"> |
|
102 | + if (is_array($headers_pdf)) { |
|
103 | + // preparing headers pdf |
|
104 | + $header = '<table width="100%" cellspacing="1" cellpadding="1" border="0" class="strong"> |
|
105 | 105 | <tr> |
106 | 106 | <td ROWSPAN="3" style="text-align: left;" class="title"><img src="'.api_get_path(WEB_CSS_PATH).api_get_setting('stylesheets').'/images/header-logo.png"></td><td colspan="3"><h1>'.$title_pdf.'</h1></td> |
107 | 107 | <tr> |
@@ -121,92 +121,92 @@ discard block |
||
121 | 121 | <td><strong>'.$headers_pdf[5][0].'</strong> </td><td> <strong>'.$headers_pdf[5][1].'</strong></td> |
122 | 122 | </tr> |
123 | 123 | </table>'; |
124 | - } |
|
124 | + } |
|
125 | 125 | |
126 | - // preparing footer pdf |
|
127 | - $footer = '<table width="100%" cellspacing="2" cellpadding="10" border="0">'; |
|
128 | - if (is_array($footers_pdf)) { |
|
129 | - $footer .= '<tr>'; |
|
130 | - foreach ($footers_pdf as $foot_pdf) { |
|
131 | - $footer .= '<td width="33%" style="text-align: center;">'.$foot_pdf.'</td>'; |
|
132 | - } |
|
133 | - $footer .= '</tr>'; |
|
134 | - } |
|
135 | - $footer .= '</table>'; |
|
126 | + // preparing footer pdf |
|
127 | + $footer = '<table width="100%" cellspacing="2" cellpadding="10" border="0">'; |
|
128 | + if (is_array($footers_pdf)) { |
|
129 | + $footer .= '<tr>'; |
|
130 | + foreach ($footers_pdf as $foot_pdf) { |
|
131 | + $footer .= '<td width="33%" style="text-align: center;">'.$foot_pdf.'</td>'; |
|
132 | + } |
|
133 | + $footer .= '</tr>'; |
|
134 | + } |
|
135 | + $footer .= '</table>'; |
|
136 | 136 | |
137 | - $footer .= '<div align="right" style="font-weight: bold;">{PAGENO}/{nb}</div>'; |
|
137 | + $footer .= '<div align="right" style="font-weight: bold;">{PAGENO}/{nb}</div>'; |
|
138 | 138 | |
139 | - // preparing content pdf |
|
140 | - $css_file = api_get_path(TO_SYS, WEB_CSS_PATH).api_get_setting('stylesheets').'/print.css'; |
|
141 | - if (file_exists($css_file)) { |
|
142 | - $css = @file_get_contents($css_file); |
|
143 | - } else { |
|
144 | - $css = ''; |
|
145 | - } |
|
139 | + // preparing content pdf |
|
140 | + $css_file = api_get_path(TO_SYS, WEB_CSS_PATH).api_get_setting('stylesheets').'/print.css'; |
|
141 | + if (file_exists($css_file)) { |
|
142 | + $css = @file_get_contents($css_file); |
|
143 | + } else { |
|
144 | + $css = ''; |
|
145 | + } |
|
146 | 146 | |
147 | - if(count($data_table) > 30) |
|
148 | - $items_per_page = (count($data_table)/2); |
|
149 | - else |
|
150 | - $items_per_page = count($data_table); |
|
147 | + if(count($data_table) > 30) |
|
148 | + $items_per_page = (count($data_table)/2); |
|
149 | + else |
|
150 | + $items_per_page = count($data_table); |
|
151 | 151 | |
152 | - $count_pages = ceil(count($data_table) / $items_per_page); |
|
153 | - for ($x = 0; $x<$count_pages; $x++) { |
|
154 | - $content_table .= '<table width="100%" border="1" style="border-collapse:collapse">'; |
|
155 | - // header table |
|
156 | - $content_table .= '<tr>'; |
|
157 | - $i = 0; |
|
158 | - if (is_array($headers_table)) { |
|
152 | + $count_pages = ceil(count($data_table) / $items_per_page); |
|
153 | + for ($x = 0; $x<$count_pages; $x++) { |
|
154 | + $content_table .= '<table width="100%" border="1" style="border-collapse:collapse">'; |
|
155 | + // header table |
|
156 | + $content_table .= '<tr>'; |
|
157 | + $i = 0; |
|
158 | + if (is_array($headers_table)) { |
|
159 | 159 | |
160 | - foreach ($headers_table as $head_table) { |
|
161 | - if (!empty($head_table[0])) { |
|
162 | - $width = (!empty($head_table[1])?$head_table[1].'%':''); |
|
163 | - $content_table .= '<th width="'.$width.'">'.$head_table[0].'</th>'; |
|
164 | - $i++; |
|
165 | - } |
|
166 | - } |
|
167 | - } |
|
168 | - $content_table .= '</tr>'; |
|
169 | - // body table |
|
170 | - if (is_array($data_table) && count($data_table) > 0) { |
|
171 | - $offset = $x*$items_per_page; |
|
172 | - $data_table = array_slice ($data_table, $offset, count($data_table)); |
|
173 | - $i = 1; |
|
174 | - $item = $offset+1; |
|
175 | - foreach ($data_table as $data) { |
|
176 | - $content_table .= '<tr>'; |
|
177 | - $content_table .= '<td>'.($item<10?'0'.$item:$item).'</td>'; |
|
178 | - foreach ($data as $key => $content) { |
|
179 | - if (isset($content)) { |
|
180 | - $key == 1 ? $align='align="left"':$align='align="center"'; |
|
181 | - $content_table .= '<td '.$align.' style="padding:4px;" >'.$content.'</td>'; |
|
182 | - } |
|
183 | - } |
|
184 | - $content_table .= '</tr>'; |
|
185 | - $i++; |
|
186 | - $item++; |
|
187 | - if ($i > $items_per_page) { break; } |
|
188 | - } |
|
189 | - } else { |
|
190 | - $content_table .= '<tr colspan="'.$i.'"><td>'.get_lang('Empty').'</td></tr>'; |
|
191 | - } |
|
192 | - $content_table .= '</table>'; |
|
193 | - if ($x < ($count_pages - 1)) { $content_table .= '<pagebreak />'; } |
|
194 | - } |
|
160 | + foreach ($headers_table as $head_table) { |
|
161 | + if (!empty($head_table[0])) { |
|
162 | + $width = (!empty($head_table[1])?$head_table[1].'%':''); |
|
163 | + $content_table .= '<th width="'.$width.'">'.$head_table[0].'</th>'; |
|
164 | + $i++; |
|
165 | + } |
|
166 | + } |
|
167 | + } |
|
168 | + $content_table .= '</tr>'; |
|
169 | + // body table |
|
170 | + if (is_array($data_table) && count($data_table) > 0) { |
|
171 | + $offset = $x*$items_per_page; |
|
172 | + $data_table = array_slice ($data_table, $offset, count($data_table)); |
|
173 | + $i = 1; |
|
174 | + $item = $offset+1; |
|
175 | + foreach ($data_table as $data) { |
|
176 | + $content_table .= '<tr>'; |
|
177 | + $content_table .= '<td>'.($item<10?'0'.$item:$item).'</td>'; |
|
178 | + foreach ($data as $key => $content) { |
|
179 | + if (isset($content)) { |
|
180 | + $key == 1 ? $align='align="left"':$align='align="center"'; |
|
181 | + $content_table .= '<td '.$align.' style="padding:4px;" >'.$content.'</td>'; |
|
182 | + } |
|
183 | + } |
|
184 | + $content_table .= '</tr>'; |
|
185 | + $i++; |
|
186 | + $item++; |
|
187 | + if ($i > $items_per_page) { break; } |
|
188 | + } |
|
189 | + } else { |
|
190 | + $content_table .= '<tr colspan="'.$i.'"><td>'.get_lang('Empty').'</td></tr>'; |
|
191 | + } |
|
192 | + $content_table .= '</table>'; |
|
193 | + if ($x < ($count_pages - 1)) { $content_table .= '<pagebreak />'; } |
|
194 | + } |
|
195 | 195 | |
196 | - $html = $content_table; |
|
196 | + $html = $content_table; |
|
197 | 197 | |
198 | 198 | |
199 | - // set attributes for pdf |
|
200 | - $mpdf->SetHTMLHeader($header); |
|
201 | - $mpdf->SetHTMLFooter($footer); |
|
202 | - if (!empty($css)) { |
|
203 | - $mpdf->WriteHTML($css, 1); |
|
204 | - $mpdf->WriteHTML($html, 2); |
|
205 | - } else { |
|
206 | - $mpdf->WriteHTML($html); |
|
207 | - } |
|
208 | - $mpdf->Output(api_replace_dangerous_char($title_pdf.'.pdf'), 'D'); |
|
209 | - exit; |
|
199 | + // set attributes for pdf |
|
200 | + $mpdf->SetHTMLHeader($header); |
|
201 | + $mpdf->SetHTMLFooter($footer); |
|
202 | + if (!empty($css)) { |
|
203 | + $mpdf->WriteHTML($css, 1); |
|
204 | + $mpdf->WriteHTML($html, 2); |
|
205 | + } else { |
|
206 | + $mpdf->WriteHTML($html); |
|
207 | + } |
|
208 | + $mpdf->Output(api_replace_dangerous_char($title_pdf.'.pdf'), 'D'); |
|
209 | + exit; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | |
@@ -220,88 +220,88 @@ discard block |
||
220 | 220 | */ |
221 | 221 | function export_pdf_with_html($headers_table, $data_table, $headers_pdf, $footers_pdf, $title_pdf) |
222 | 222 | { |
223 | - $headers_in_pdf = '<img src="'.api_get_path(WEB_CSS_PATH).api_get_setting('stylesheets').'/images/header-logo.png">'; |
|
223 | + $headers_in_pdf = '<img src="'.api_get_path(WEB_CSS_PATH).api_get_setting('stylesheets').'/images/header-logo.png">'; |
|
224 | 224 | |
225 | - if (is_array($headers_pdf)) { |
|
226 | - // preparing headers pdf |
|
227 | - $header = '<br/><br/><table width="100%" cellspacing="1" cellpadding="5" border="0" class="strong"> |
|
225 | + if (is_array($headers_pdf)) { |
|
226 | + // preparing headers pdf |
|
227 | + $header = '<br/><br/><table width="100%" cellspacing="1" cellpadding="5" border="0" class="strong"> |
|
228 | 228 | <tr><td width="100%" style="text-align: center;" class="title" colspan="4"><h1>'.$title_pdf.'</h1></td></tr>'; |
229 | - foreach($headers_pdf as $header_pdf) { |
|
230 | - if (!empty($header_pdf[0]) && !empty($header_pdf[1])) { |
|
231 | - $header.= '<tr><td><strong>'.$header_pdf[0].'</strong> </td><td>'.$header_pdf[1].'</td></tr>'; |
|
232 | - } |
|
233 | - } |
|
234 | - $header.='</table><br />'; |
|
235 | - } |
|
229 | + foreach($headers_pdf as $header_pdf) { |
|
230 | + if (!empty($header_pdf[0]) && !empty($header_pdf[1])) { |
|
231 | + $header.= '<tr><td><strong>'.$header_pdf[0].'</strong> </td><td>'.$header_pdf[1].'</td></tr>'; |
|
232 | + } |
|
233 | + } |
|
234 | + $header.='</table><br />'; |
|
235 | + } |
|
236 | 236 | |
237 | - // preparing footer pdf |
|
238 | - $footer = '<table width="100%" cellspacing="2" cellpadding="10" border="0">'; |
|
239 | - if (is_array($footers_pdf)) { |
|
240 | - $footer .= '<tr>'; |
|
241 | - foreach ($footers_pdf as $foot_pdf) { |
|
242 | - $footer .= '<td width="33%" style="text-align: center;">'.$foot_pdf.'</td>'; |
|
243 | - } |
|
244 | - $footer .= '</tr>'; |
|
245 | - } |
|
246 | - $footer .= '</table>'; |
|
247 | - $footer .= '<div align="right" style="font-weight: bold;">{PAGENO}/{nb}</div>'; |
|
237 | + // preparing footer pdf |
|
238 | + $footer = '<table width="100%" cellspacing="2" cellpadding="10" border="0">'; |
|
239 | + if (is_array($footers_pdf)) { |
|
240 | + $footer .= '<tr>'; |
|
241 | + foreach ($footers_pdf as $foot_pdf) { |
|
242 | + $footer .= '<td width="33%" style="text-align: center;">'.$foot_pdf.'</td>'; |
|
243 | + } |
|
244 | + $footer .= '</tr>'; |
|
245 | + } |
|
246 | + $footer .= '</table>'; |
|
247 | + $footer .= '<div align="right" style="font-weight: bold;">{PAGENO}/{nb}</div>'; |
|
248 | 248 | |
249 | - // preparing content pdf |
|
250 | - $css_file = api_get_path(TO_SYS, WEB_CSS_PATH).api_get_setting('stylesheets').'/print.css'; |
|
251 | - if (file_exists($css_file)) { |
|
252 | - $css = @file_get_contents($css_file); |
|
253 | - } else { |
|
254 | - $css = ''; |
|
255 | - } |
|
256 | - $items_per_page = 30; |
|
257 | - $count_pages = ceil(count($data_table) / $items_per_page); |
|
258 | - for ($x = 0; $x<$count_pages; $x++) { |
|
259 | - $content_table .= '<table width="100%" border="1" style="border-collapse:collapse">'; |
|
260 | - // header table |
|
261 | - $content_table .= '<tr>'; |
|
262 | - $i = 0; |
|
263 | - if (is_array($headers_table)) { |
|
264 | - foreach ($headers_table as $head_table) { |
|
265 | - if (!empty($head_table[0])) { |
|
266 | - $width = (!empty($head_table[1])?$head_table[1].'%':''); |
|
267 | - $content_table .= '<th width="'.$width.'">'.$head_table[0].'</th>'; |
|
268 | - $i++; |
|
269 | - } |
|
270 | - } |
|
271 | - } |
|
272 | - $content_table .= '</tr>'; |
|
273 | - // body table |
|
249 | + // preparing content pdf |
|
250 | + $css_file = api_get_path(TO_SYS, WEB_CSS_PATH).api_get_setting('stylesheets').'/print.css'; |
|
251 | + if (file_exists($css_file)) { |
|
252 | + $css = @file_get_contents($css_file); |
|
253 | + } else { |
|
254 | + $css = ''; |
|
255 | + } |
|
256 | + $items_per_page = 30; |
|
257 | + $count_pages = ceil(count($data_table) / $items_per_page); |
|
258 | + for ($x = 0; $x<$count_pages; $x++) { |
|
259 | + $content_table .= '<table width="100%" border="1" style="border-collapse:collapse">'; |
|
260 | + // header table |
|
261 | + $content_table .= '<tr>'; |
|
262 | + $i = 0; |
|
263 | + if (is_array($headers_table)) { |
|
264 | + foreach ($headers_table as $head_table) { |
|
265 | + if (!empty($head_table[0])) { |
|
266 | + $width = (!empty($head_table[1])?$head_table[1].'%':''); |
|
267 | + $content_table .= '<th width="'.$width.'">'.$head_table[0].'</th>'; |
|
268 | + $i++; |
|
269 | + } |
|
270 | + } |
|
271 | + } |
|
272 | + $content_table .= '</tr>'; |
|
273 | + // body table |
|
274 | 274 | |
275 | - if (is_array($data_table) && count($data_table) > 0) { |
|
276 | - $offset = $x*$items_per_page; |
|
277 | - $data_table = array_slice ($data_table, $offset, count($data_table)); |
|
278 | - $i = 1; |
|
279 | - $item = $offset+1; |
|
280 | - foreach ($data_table as $data) { |
|
281 | - $content_table .= '<tr>'; |
|
282 | - $content_table .= '<td>'.($item<10?'0'.$item:$item).'</td>'; |
|
283 | - foreach ($data as $key => $content) { |
|
284 | - if (isset($content)) { |
|
285 | - $key == 1 ? $align='align="left"':$align='align="center"'; |
|
286 | - $content_table .= '<td '.$align.' style="padding:4px;" >'.$content.'</td>'; |
|
287 | - } |
|
288 | - } |
|
289 | - $content_table .= '</tr>'; |
|
290 | - $i++; |
|
291 | - $item++; |
|
292 | - if ($i > $items_per_page) { break; } |
|
293 | - } |
|
294 | - } else { |
|
295 | - $content_table .= '<tr colspan="'.$i.'"><td>'.get_lang('Empty').'</td></tr>'; |
|
296 | - } |
|
297 | - $content_table .= '</table>'; |
|
298 | - if ($x < ($count_pages - 1)) { $content_table .= '<pagebreak />'; } |
|
299 | - } |
|
300 | - $pdf = new PDF(); |
|
301 | - $pdf->set_custom_footer($footer); |
|
302 | - $pdf->set_custom_header($headers_in_pdf); |
|
303 | - $pdf->content_to_pdf($header.$content_table, $css, $title_pdf ); |
|
304 | - exit; |
|
275 | + if (is_array($data_table) && count($data_table) > 0) { |
|
276 | + $offset = $x*$items_per_page; |
|
277 | + $data_table = array_slice ($data_table, $offset, count($data_table)); |
|
278 | + $i = 1; |
|
279 | + $item = $offset+1; |
|
280 | + foreach ($data_table as $data) { |
|
281 | + $content_table .= '<tr>'; |
|
282 | + $content_table .= '<td>'.($item<10?'0'.$item:$item).'</td>'; |
|
283 | + foreach ($data as $key => $content) { |
|
284 | + if (isset($content)) { |
|
285 | + $key == 1 ? $align='align="left"':$align='align="center"'; |
|
286 | + $content_table .= '<td '.$align.' style="padding:4px;" >'.$content.'</td>'; |
|
287 | + } |
|
288 | + } |
|
289 | + $content_table .= '</tr>'; |
|
290 | + $i++; |
|
291 | + $item++; |
|
292 | + if ($i > $items_per_page) { break; } |
|
293 | + } |
|
294 | + } else { |
|
295 | + $content_table .= '<tr colspan="'.$i.'"><td>'.get_lang('Empty').'</td></tr>'; |
|
296 | + } |
|
297 | + $content_table .= '</table>'; |
|
298 | + if ($x < ($count_pages - 1)) { $content_table .= '<pagebreak />'; } |
|
299 | + } |
|
300 | + $pdf = new PDF(); |
|
301 | + $pdf->set_custom_footer($footer); |
|
302 | + $pdf->set_custom_header($headers_in_pdf); |
|
303 | + $pdf->content_to_pdf($header.$content_table, $css, $title_pdf ); |
|
304 | + exit; |
|
305 | 305 | |
306 | 306 | } |
307 | 307 | |
@@ -313,20 +313,20 @@ discard block |
||
313 | 313 | * @param string Format (portrait or landscape) |
314 | 314 | */ |
315 | 315 | function export_pdf($pdf,$newarray,$header_names,$format) { |
316 | - $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); |
|
317 | - $pdf->ezSetCmMargins(0,0,0,0); |
|
318 | - $pdf->ezSetY(($format=='portrait')?'820':'570'); |
|
319 | - $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); |
|
320 | - //$pdf->ezText(get_lang('FlatView').' ('. api_convert_and_format_date(null, DATE_FORMAT_SHORT). ' ' . api_convert_and_format_date(null, TIME_NO_SEC_FORMAT) .')',12,array('justification'=>'center')); |
|
321 | - if ($format=='portrait') { |
|
322 | - $pdf->line(40,790,540,790); |
|
323 | - $pdf->line(40,40,540,40); |
|
324 | - } else { |
|
325 | - $pdf->line(40,540,790,540); |
|
326 | - $pdf->line(40,40,790,40); |
|
327 | - } |
|
328 | - $pdf->ezSetY(($format=='portrait')?'750':'520'); |
|
329 | - $pdf->ezTable($newarray,$header_names,'',array('showHeadings'=>1,'shaded'=>1,'showLines'=>1,'rowGap'=>3,'width'=>(($format=='portrait')?'500':'750'))); |
|
330 | - $pdf->ezStream(); |
|
316 | + $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); |
|
317 | + $pdf->ezSetCmMargins(0,0,0,0); |
|
318 | + $pdf->ezSetY(($format=='portrait')?'820':'570'); |
|
319 | + $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); |
|
320 | + //$pdf->ezText(get_lang('FlatView').' ('. api_convert_and_format_date(null, DATE_FORMAT_SHORT). ' ' . api_convert_and_format_date(null, TIME_NO_SEC_FORMAT) .')',12,array('justification'=>'center')); |
|
321 | + if ($format=='portrait') { |
|
322 | + $pdf->line(40,790,540,790); |
|
323 | + $pdf->line(40,40,540,40); |
|
324 | + } else { |
|
325 | + $pdf->line(40,540,790,540); |
|
326 | + $pdf->line(40,40,790,40); |
|
327 | + } |
|
328 | + $pdf->ezSetY(($format=='portrait')?'750':'520'); |
|
329 | + $pdf->ezTable($newarray,$header_names,'',array('showHeadings'=>1,'shaded'=>1,'showLines'=>1,'rowGap'=>3,'width'=>(($format=='portrait')?'500':'750'))); |
|
330 | + $pdf->ezStream(); |
|
331 | 331 | |
332 | 332 | } |
@@ -9,108 +9,108 @@ discard block |
||
9 | 9 | */ |
10 | 10 | class LinkAddEditForm extends FormValidator |
11 | 11 | { |
12 | - const TYPE_ADD = 1; |
|
13 | - const TYPE_EDIT = 2; |
|
14 | - |
|
15 | - /** |
|
16 | - * Constructor |
|
17 | - * To add link, define category_object and link_type |
|
18 | - * To edit link, define link_object |
|
19 | - */ |
|
20 | - public function LinkAddEditForm( |
|
21 | - $form_type, |
|
22 | - $category_object, |
|
23 | - $link_type, |
|
24 | - $link_object, |
|
25 | - $form_name, |
|
26 | - $action = null |
|
27 | - ) { |
|
28 | - parent :: __construct($form_name, 'post', $action); |
|
29 | - |
|
30 | - // set or create link object |
|
31 | - if (isset($link_object)) { |
|
32 | - $link = $link_object; |
|
33 | - } elseif (isset($link_type) && isset($category_object)) { |
|
34 | - $link = LinkFactory :: create ($link_type); |
|
35 | - $link->set_course_code(api_get_course_id()); |
|
36 | - $link->set_category_id($category_object[0]->get_id()); |
|
37 | - } else { |
|
38 | - die ('LinkAddEditForm error: define link_type/category_object or link_object'); |
|
39 | - } |
|
40 | - |
|
41 | - $defaults = array(); |
|
42 | - $this->addElement('hidden', 'zero', 0); |
|
43 | - |
|
44 | - if (!empty($_GET['editlink'])) { |
|
45 | - $this->addElement('header', '', get_lang('EditLink')); |
|
46 | - } |
|
47 | - |
|
48 | - // ELEMENT: name |
|
49 | - if ($form_type == self :: TYPE_ADD || $link->is_allowed_to_change_name()) { |
|
50 | - if ($link->needs_name_and_description()) { |
|
51 | - $this->addText('name', get_lang('Name'), true, array('size'=>'40', 'maxlength'=>'40')); |
|
52 | - } else { |
|
53 | - $select = $this->addElement('select', 'select_link', get_lang('ChooseItem')); |
|
54 | - foreach ($link->get_all_links() as $newlink) { |
|
55 | - $select->addoption($newlink[1],$newlink[0]); |
|
56 | - } |
|
57 | - } |
|
58 | - } else { |
|
59 | - $this->addElement('label',get_lang('Name'), '<span class="freeze">'.$link->get_name().' ['.$link->get_type_name().']</span>'); |
|
60 | - $this->addElement('hidden','name_link',$link->get_name(),array('id'=>'name_link')); |
|
61 | - } |
|
62 | - |
|
63 | - if (count($category_object) == 1) { |
|
64 | - $this->addElement('hidden', 'select_gradebook', $category_object[0]->get_id()); |
|
65 | - } else { |
|
66 | - $select_gradebook = $this->addElement( |
|
67 | - 'select', |
|
68 | - 'select_gradebook', |
|
69 | - get_lang('SelectGradebook'), |
|
70 | - array(), |
|
71 | - array('id' => 'hide_category_id') |
|
72 | - ); |
|
73 | - $this->addRule('select_gradebook', get_lang('ThisFieldIsRequired'), 'nonzero'); |
|
74 | - |
|
75 | - $default_weight = 0; |
|
76 | - if (!empty($category_object)) { |
|
77 | - foreach ($category_object as $my_cat) { |
|
78 | - |
|
79 | - if ($my_cat->get_course_code() == api_get_course_id()) { |
|
80 | - $grade_model_id = $my_cat->get_grade_model_id(); |
|
81 | - if (empty($grade_model_id)) { |
|
82 | - |
|
83 | - if ($my_cat->get_parent_id() == 0 ) { |
|
84 | - $default_weight = $my_cat->get_weight(); |
|
85 | - $select_gradebook->addoption(get_lang('Default'), $my_cat->get_id()); |
|
86 | - } else { |
|
87 | - $select_gradebook->addoption($my_cat->get_name(), $my_cat->get_id()); |
|
88 | - } |
|
89 | - } else { |
|
90 | - $select_gradebook->addoption(get_lang('Select'), 0); |
|
91 | - } |
|
92 | - if ($link->get_category_id() == $my_cat->get_id()) { |
|
93 | - $default_weight = $my_cat->get_weight(); |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - $this->addText( |
|
101 | - 'weight_mask', |
|
102 | - array(get_lang('Weight'), null, ' [0 .. <span id="max_weight">'.$category_object[0]->get_weight().'</span>] '), |
|
103 | - true, |
|
104 | - array( |
|
105 | - 'size' => '4', |
|
106 | - 'maxlength' => '5', |
|
107 | - 'class' => 'span1' |
|
108 | - ) |
|
109 | - ); |
|
110 | - |
|
111 | - $this->addElement('hidden', 'weight'); |
|
112 | - |
|
113 | - /* |
|
12 | + const TYPE_ADD = 1; |
|
13 | + const TYPE_EDIT = 2; |
|
14 | + |
|
15 | + /** |
|
16 | + * Constructor |
|
17 | + * To add link, define category_object and link_type |
|
18 | + * To edit link, define link_object |
|
19 | + */ |
|
20 | + public function LinkAddEditForm( |
|
21 | + $form_type, |
|
22 | + $category_object, |
|
23 | + $link_type, |
|
24 | + $link_object, |
|
25 | + $form_name, |
|
26 | + $action = null |
|
27 | + ) { |
|
28 | + parent :: __construct($form_name, 'post', $action); |
|
29 | + |
|
30 | + // set or create link object |
|
31 | + if (isset($link_object)) { |
|
32 | + $link = $link_object; |
|
33 | + } elseif (isset($link_type) && isset($category_object)) { |
|
34 | + $link = LinkFactory :: create ($link_type); |
|
35 | + $link->set_course_code(api_get_course_id()); |
|
36 | + $link->set_category_id($category_object[0]->get_id()); |
|
37 | + } else { |
|
38 | + die ('LinkAddEditForm error: define link_type/category_object or link_object'); |
|
39 | + } |
|
40 | + |
|
41 | + $defaults = array(); |
|
42 | + $this->addElement('hidden', 'zero', 0); |
|
43 | + |
|
44 | + if (!empty($_GET['editlink'])) { |
|
45 | + $this->addElement('header', '', get_lang('EditLink')); |
|
46 | + } |
|
47 | + |
|
48 | + // ELEMENT: name |
|
49 | + if ($form_type == self :: TYPE_ADD || $link->is_allowed_to_change_name()) { |
|
50 | + if ($link->needs_name_and_description()) { |
|
51 | + $this->addText('name', get_lang('Name'), true, array('size'=>'40', 'maxlength'=>'40')); |
|
52 | + } else { |
|
53 | + $select = $this->addElement('select', 'select_link', get_lang('ChooseItem')); |
|
54 | + foreach ($link->get_all_links() as $newlink) { |
|
55 | + $select->addoption($newlink[1],$newlink[0]); |
|
56 | + } |
|
57 | + } |
|
58 | + } else { |
|
59 | + $this->addElement('label',get_lang('Name'), '<span class="freeze">'.$link->get_name().' ['.$link->get_type_name().']</span>'); |
|
60 | + $this->addElement('hidden','name_link',$link->get_name(),array('id'=>'name_link')); |
|
61 | + } |
|
62 | + |
|
63 | + if (count($category_object) == 1) { |
|
64 | + $this->addElement('hidden', 'select_gradebook', $category_object[0]->get_id()); |
|
65 | + } else { |
|
66 | + $select_gradebook = $this->addElement( |
|
67 | + 'select', |
|
68 | + 'select_gradebook', |
|
69 | + get_lang('SelectGradebook'), |
|
70 | + array(), |
|
71 | + array('id' => 'hide_category_id') |
|
72 | + ); |
|
73 | + $this->addRule('select_gradebook', get_lang('ThisFieldIsRequired'), 'nonzero'); |
|
74 | + |
|
75 | + $default_weight = 0; |
|
76 | + if (!empty($category_object)) { |
|
77 | + foreach ($category_object as $my_cat) { |
|
78 | + |
|
79 | + if ($my_cat->get_course_code() == api_get_course_id()) { |
|
80 | + $grade_model_id = $my_cat->get_grade_model_id(); |
|
81 | + if (empty($grade_model_id)) { |
|
82 | + |
|
83 | + if ($my_cat->get_parent_id() == 0 ) { |
|
84 | + $default_weight = $my_cat->get_weight(); |
|
85 | + $select_gradebook->addoption(get_lang('Default'), $my_cat->get_id()); |
|
86 | + } else { |
|
87 | + $select_gradebook->addoption($my_cat->get_name(), $my_cat->get_id()); |
|
88 | + } |
|
89 | + } else { |
|
90 | + $select_gradebook->addoption(get_lang('Select'), 0); |
|
91 | + } |
|
92 | + if ($link->get_category_id() == $my_cat->get_id()) { |
|
93 | + $default_weight = $my_cat->get_weight(); |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + $this->addText( |
|
101 | + 'weight_mask', |
|
102 | + array(get_lang('Weight'), null, ' [0 .. <span id="max_weight">'.$category_object[0]->get_weight().'</span>] '), |
|
103 | + true, |
|
104 | + array( |
|
105 | + 'size' => '4', |
|
106 | + 'maxlength' => '5', |
|
107 | + 'class' => 'span1' |
|
108 | + ) |
|
109 | + ); |
|
110 | + |
|
111 | + $this->addElement('hidden', 'weight'); |
|
112 | + |
|
113 | + /* |
|
114 | 114 | |
115 | 115 | // ELEMENT: weight |
116 | 116 | $this->addText('weight', array(get_lang('Weight'), null, '/ <span id="max_weight">'.$default_weight.'</span>'), true, array ( |
@@ -119,76 +119,76 @@ discard block |
||
119 | 119 | 'class' => 'span1' |
120 | 120 | ));*/ |
121 | 121 | |
122 | - $this->addRule('weight_mask',get_lang('OnlyNumbers'),'numeric'); |
|
123 | - $this->addRule(array ('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>='); |
|
124 | - if ($form_type == self :: TYPE_EDIT) { |
|
125 | - $parent_cat = Category :: load($link->get_category_id()); |
|
126 | - |
|
127 | - if ($parent_cat[0]->get_parent_id() == 0) { |
|
128 | - $values['weight'] = $link->get_weight(); |
|
129 | - } else { |
|
130 | - $cat = Category :: load($parent_cat[0]->get_parent_id()); |
|
131 | - //$global_weight = $cat[0]->get_weight(); |
|
132 | - //$values['weight'] = $link->get_weight()/$parent_cat[0]->get_weight()*$global_weight; |
|
133 | - //var_dump($global_weight, $link->get_weight(), $parent_cat[0]->get_weight()); |
|
134 | - //$weight = $parent_cat[0]->get_weight()* $link->get_weight() / $global_weight; |
|
135 | - //$values['weight'] = $weight; |
|
136 | - $values['weight'] = $link->get_weight() ; |
|
137 | - } |
|
138 | - $defaults['weight_mask'] = $values['weight'] ; |
|
139 | - $defaults['select_gradebook'] = $link->get_category_id(); |
|
140 | - |
|
141 | - } |
|
142 | - // ELEMENT: max |
|
143 | - if ($link->needs_max()) { |
|
144 | - if ($form_type == self :: TYPE_EDIT && $link->has_results()) { |
|
145 | - $this->addText('max', get_lang('QualificationNumeric'), false, array ('size' => '4','maxlength' => '5', 'disabled' => 'disabled')); |
|
146 | - } else { |
|
147 | - $this->addText('max', get_lang('QualificationNumeric'), true, array ('size' => '4','maxlength' => '5')); |
|
148 | - $this->addRule('max', get_lang('OnlyNumbers'), 'numeric'); |
|
149 | - $this->addRule(array ('max', 'zero'), get_lang('NegativeValue'), 'compare', '>='); |
|
150 | - } |
|
151 | - if ($form_type == self :: TYPE_EDIT) { |
|
152 | - $defaults['max'] = $link->get_max(); |
|
153 | - } |
|
154 | - } |
|
155 | - |
|
156 | - // ELEMENT: description |
|
157 | - if ($link->needs_name_and_description()) { |
|
158 | - $this->addElement('textarea', 'description', get_lang('Description'), array ('rows' => '3','cols' => '34')); |
|
159 | - if ($form_type == self :: TYPE_EDIT) { |
|
160 | - $defaults['description'] = $link->get_description(); |
|
161 | - } |
|
162 | - } |
|
163 | - |
|
164 | - // ELEMENT: visible |
|
165 | - $visible = ($form_type == self :: TYPE_EDIT && $link->is_visible()) ? '1' : '0'; |
|
166 | - $this->addElement('checkbox', 'visible', null, get_lang('Visible'), $visible); |
|
167 | - if ($form_type == self :: TYPE_EDIT) { |
|
168 | - $defaults['visible'] = $link->is_visible(); |
|
169 | - } |
|
170 | - |
|
171 | - // ELEMENT: add results |
|
172 | - if ($form_type == self :: TYPE_ADD && $link->needs_results()) { |
|
173 | - $this->addElement('checkbox', 'addresult', get_lang('AddResult')); |
|
174 | - } |
|
175 | - // submit button |
|
176 | - if ($form_type == self :: TYPE_ADD) { |
|
177 | - $this->addButtonCreate(get_lang('CreateLink')); |
|
178 | - } else { |
|
179 | - $this->addButtonUpdate(get_lang('LinkMod')); |
|
180 | - } |
|
181 | - |
|
182 | - if ($form_type == self :: TYPE_ADD) { |
|
183 | - $setting = api_get_setting('tool_visible_by_default_at_creation'); |
|
184 | - $visibility_default = 1; |
|
185 | - if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') { |
|
186 | - $visibility_default = 0; |
|
187 | - } |
|
188 | - $defaults['visible'] = $visibility_default; |
|
189 | - } |
|
190 | - |
|
191 | - // set default values |
|
192 | - $this->setDefaults($defaults); |
|
193 | - } |
|
122 | + $this->addRule('weight_mask',get_lang('OnlyNumbers'),'numeric'); |
|
123 | + $this->addRule(array ('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>='); |
|
124 | + if ($form_type == self :: TYPE_EDIT) { |
|
125 | + $parent_cat = Category :: load($link->get_category_id()); |
|
126 | + |
|
127 | + if ($parent_cat[0]->get_parent_id() == 0) { |
|
128 | + $values['weight'] = $link->get_weight(); |
|
129 | + } else { |
|
130 | + $cat = Category :: load($parent_cat[0]->get_parent_id()); |
|
131 | + //$global_weight = $cat[0]->get_weight(); |
|
132 | + //$values['weight'] = $link->get_weight()/$parent_cat[0]->get_weight()*$global_weight; |
|
133 | + //var_dump($global_weight, $link->get_weight(), $parent_cat[0]->get_weight()); |
|
134 | + //$weight = $parent_cat[0]->get_weight()* $link->get_weight() / $global_weight; |
|
135 | + //$values['weight'] = $weight; |
|
136 | + $values['weight'] = $link->get_weight() ; |
|
137 | + } |
|
138 | + $defaults['weight_mask'] = $values['weight'] ; |
|
139 | + $defaults['select_gradebook'] = $link->get_category_id(); |
|
140 | + |
|
141 | + } |
|
142 | + // ELEMENT: max |
|
143 | + if ($link->needs_max()) { |
|
144 | + if ($form_type == self :: TYPE_EDIT && $link->has_results()) { |
|
145 | + $this->addText('max', get_lang('QualificationNumeric'), false, array ('size' => '4','maxlength' => '5', 'disabled' => 'disabled')); |
|
146 | + } else { |
|
147 | + $this->addText('max', get_lang('QualificationNumeric'), true, array ('size' => '4','maxlength' => '5')); |
|
148 | + $this->addRule('max', get_lang('OnlyNumbers'), 'numeric'); |
|
149 | + $this->addRule(array ('max', 'zero'), get_lang('NegativeValue'), 'compare', '>='); |
|
150 | + } |
|
151 | + if ($form_type == self :: TYPE_EDIT) { |
|
152 | + $defaults['max'] = $link->get_max(); |
|
153 | + } |
|
154 | + } |
|
155 | + |
|
156 | + // ELEMENT: description |
|
157 | + if ($link->needs_name_and_description()) { |
|
158 | + $this->addElement('textarea', 'description', get_lang('Description'), array ('rows' => '3','cols' => '34')); |
|
159 | + if ($form_type == self :: TYPE_EDIT) { |
|
160 | + $defaults['description'] = $link->get_description(); |
|
161 | + } |
|
162 | + } |
|
163 | + |
|
164 | + // ELEMENT: visible |
|
165 | + $visible = ($form_type == self :: TYPE_EDIT && $link->is_visible()) ? '1' : '0'; |
|
166 | + $this->addElement('checkbox', 'visible', null, get_lang('Visible'), $visible); |
|
167 | + if ($form_type == self :: TYPE_EDIT) { |
|
168 | + $defaults['visible'] = $link->is_visible(); |
|
169 | + } |
|
170 | + |
|
171 | + // ELEMENT: add results |
|
172 | + if ($form_type == self :: TYPE_ADD && $link->needs_results()) { |
|
173 | + $this->addElement('checkbox', 'addresult', get_lang('AddResult')); |
|
174 | + } |
|
175 | + // submit button |
|
176 | + if ($form_type == self :: TYPE_ADD) { |
|
177 | + $this->addButtonCreate(get_lang('CreateLink')); |
|
178 | + } else { |
|
179 | + $this->addButtonUpdate(get_lang('LinkMod')); |
|
180 | + } |
|
181 | + |
|
182 | + if ($form_type == self :: TYPE_ADD) { |
|
183 | + $setting = api_get_setting('tool_visible_by_default_at_creation'); |
|
184 | + $visibility_default = 1; |
|
185 | + if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') { |
|
186 | + $visibility_default = 0; |
|
187 | + } |
|
188 | + $defaults['visible'] = $visibility_default; |
|
189 | + } |
|
190 | + |
|
191 | + // set default values |
|
192 | + $this->setDefaults($defaults); |
|
193 | + } |
|
194 | 194 | } |
@@ -8,102 +8,102 @@ |
||
8 | 8 | */ |
9 | 9 | class DataForm extends FormValidator |
10 | 10 | { |
11 | - const TYPE_IMPORT = 1; |
|
12 | - const TYPE_EXPORT = 2; |
|
13 | - const TYPE_EXPORT_PDF = 3; |
|
11 | + const TYPE_IMPORT = 1; |
|
12 | + const TYPE_EXPORT = 2; |
|
13 | + const TYPE_EXPORT_PDF = 3; |
|
14 | 14 | |
15 | - /** |
|
16 | - * Builds a form containing form items based on a given parameter |
|
17 | - * @param int form_type 1=import, 2=export |
|
18 | - * @param obj cat_obj the category object |
|
19 | - * @param obj res_obj the result object |
|
20 | - * @param string form name |
|
21 | - * @param method |
|
22 | - * @param action |
|
23 | - */ |
|
24 | - public function DataForm($form_type, $form_name, $method = 'post', $action = null, $target='', $locked_status) |
|
25 | - { |
|
26 | - parent :: __construct($form_name, $method, $action,$target); |
|
27 | - $this->form_type = $form_type; |
|
28 | - if ($this->form_type == self :: TYPE_IMPORT) { |
|
29 | - $this->build_import_form(); |
|
30 | - } elseif ($this->form_type == self :: TYPE_EXPORT) { |
|
31 | - if ($locked_status == 0) { |
|
32 | - $this->build_export_form_option(false); |
|
33 | - } else { |
|
34 | - $this->build_export_form(); |
|
35 | - } |
|
36 | - } elseif ($this->form_type == self :: TYPE_EXPORT_PDF) { |
|
37 | - $this->build_pdf_export_form(); |
|
38 | - } |
|
39 | - $this->setDefaults(); |
|
40 | - } |
|
15 | + /** |
|
16 | + * Builds a form containing form items based on a given parameter |
|
17 | + * @param int form_type 1=import, 2=export |
|
18 | + * @param obj cat_obj the category object |
|
19 | + * @param obj res_obj the result object |
|
20 | + * @param string form name |
|
21 | + * @param method |
|
22 | + * @param action |
|
23 | + */ |
|
24 | + public function DataForm($form_type, $form_name, $method = 'post', $action = null, $target='', $locked_status) |
|
25 | + { |
|
26 | + parent :: __construct($form_name, $method, $action,$target); |
|
27 | + $this->form_type = $form_type; |
|
28 | + if ($this->form_type == self :: TYPE_IMPORT) { |
|
29 | + $this->build_import_form(); |
|
30 | + } elseif ($this->form_type == self :: TYPE_EXPORT) { |
|
31 | + if ($locked_status == 0) { |
|
32 | + $this->build_export_form_option(false); |
|
33 | + } else { |
|
34 | + $this->build_export_form(); |
|
35 | + } |
|
36 | + } elseif ($this->form_type == self :: TYPE_EXPORT_PDF) { |
|
37 | + $this->build_pdf_export_form(); |
|
38 | + } |
|
39 | + $this->setDefaults(); |
|
40 | + } |
|
41 | 41 | |
42 | - protected function build_pdf_export_form() |
|
43 | - { |
|
44 | - $renderer =& $this->defaultRenderer(); |
|
45 | - $renderer->setCustomElementTemplate('<span>{element}</span>'); |
|
46 | - $this->addElement('header', get_lang('ChooseOrientation')); |
|
47 | - $this->addElement('radio', 'orientation', null, get_lang('Portrait'), 'portrait'); |
|
48 | - $this->addElement('radio', 'orientation', null, get_lang('Landscape'), 'landscape'); |
|
49 | - $this->addButtonExport(get_lang('Export')); |
|
50 | - $this->setDefaults(array ( |
|
51 | - 'orientation' => 'portrait' |
|
52 | - )); |
|
53 | - } |
|
42 | + protected function build_pdf_export_form() |
|
43 | + { |
|
44 | + $renderer =& $this->defaultRenderer(); |
|
45 | + $renderer->setCustomElementTemplate('<span>{element}</span>'); |
|
46 | + $this->addElement('header', get_lang('ChooseOrientation')); |
|
47 | + $this->addElement('radio', 'orientation', null, get_lang('Portrait'), 'portrait'); |
|
48 | + $this->addElement('radio', 'orientation', null, get_lang('Landscape'), 'landscape'); |
|
49 | + $this->addButtonExport(get_lang('Export')); |
|
50 | + $this->setDefaults(array ( |
|
51 | + 'orientation' => 'portrait' |
|
52 | + )); |
|
53 | + } |
|
54 | 54 | |
55 | - protected function build_export_form() |
|
56 | - { |
|
57 | - $this->addElement('header', get_lang('ChooseFormat')); |
|
58 | - $this->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV (Comma-Separated Values)', 'csv'); |
|
59 | - $this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml'); |
|
60 | - $this->addElement('radio', 'file_type', null, 'PDF (Portable Document Format)', 'pdf'); |
|
61 | - $this->addButtonExport(get_lang('Export')); |
|
62 | - $this->setDefaults(array ( |
|
63 | - 'file_type' => 'csv' |
|
64 | - )); |
|
65 | - } |
|
55 | + protected function build_export_form() |
|
56 | + { |
|
57 | + $this->addElement('header', get_lang('ChooseFormat')); |
|
58 | + $this->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV (Comma-Separated Values)', 'csv'); |
|
59 | + $this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml'); |
|
60 | + $this->addElement('radio', 'file_type', null, 'PDF (Portable Document Format)', 'pdf'); |
|
61 | + $this->addButtonExport(get_lang('Export')); |
|
62 | + $this->setDefaults(array ( |
|
63 | + 'file_type' => 'csv' |
|
64 | + )); |
|
65 | + } |
|
66 | 66 | |
67 | - protected function build_export_form_option($show_pdf=true) |
|
68 | - { |
|
69 | - $this->addElement('header', get_lang('ChooseFormat')); |
|
70 | - $this->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV (Comma-Separated Values)', 'csv'); |
|
71 | - $this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml'); |
|
72 | - $this->addElement('radio', 'file_type', Display::return_icon('info3.gif',get_lang('ToExportMustLockEvaluation')), 'PDF (Portable Document Format)', 'pdf', array('disabled')); |
|
73 | - $this->addButtonExport(get_lang('Export')); |
|
74 | - $this->setDefaults(array ( |
|
75 | - 'file_type' => 'csv' |
|
76 | - )); |
|
77 | - } |
|
67 | + protected function build_export_form_option($show_pdf=true) |
|
68 | + { |
|
69 | + $this->addElement('header', get_lang('ChooseFormat')); |
|
70 | + $this->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV (Comma-Separated Values)', 'csv'); |
|
71 | + $this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml'); |
|
72 | + $this->addElement('radio', 'file_type', Display::return_icon('info3.gif',get_lang('ToExportMustLockEvaluation')), 'PDF (Portable Document Format)', 'pdf', array('disabled')); |
|
73 | + $this->addButtonExport(get_lang('Export')); |
|
74 | + $this->setDefaults(array ( |
|
75 | + 'file_type' => 'csv' |
|
76 | + )); |
|
77 | + } |
|
78 | 78 | |
79 | - protected function build_import_form() |
|
80 | - { |
|
81 | - $this->addElement('hidden', 'formSent'); |
|
82 | - $this->addElement('header', get_lang('ImportFileLocation')); |
|
83 | - $this->addElement('file', 'import_file',get_lang('Location')); |
|
84 | - $allowed_file_types = array ( |
|
85 | - 'xml', |
|
86 | - 'csv' |
|
87 | - ); |
|
88 | - //$this->addRule('file', get_lang('InvalidExtension') . ' (' . implode(',', $allowed_file_types) . ')', 'filetype', $allowed_file_types); |
|
89 | - $this->addElement('radio', 'file_type', get_lang('FileType'), 'CSV (<a href="docs/example_csv.html" target="_blank">' . get_lang('ExampleCSVFile') . '</a>)', 'csv'); |
|
90 | - $this->addElement('radio', 'file_type', null, 'XML (<a href="docs/example_xml.html" target="_blank">' . get_lang('ExampleXMLFile') . '</a>)', 'xml'); |
|
91 | - $this->addElement('checkbox','overwrite', null,get_lang('OverwriteScores')); |
|
92 | - $this->addElement('checkbox','ignoreerrors',null,get_lang('IgnoreErrors')); |
|
93 | - $this->addButtonImport(get_lang('Ok')); |
|
94 | - $this->setDefaults(array( |
|
95 | - 'formSent' => '1', |
|
96 | - 'file_type' => 'csv' |
|
97 | - )); |
|
98 | - } |
|
79 | + protected function build_import_form() |
|
80 | + { |
|
81 | + $this->addElement('hidden', 'formSent'); |
|
82 | + $this->addElement('header', get_lang('ImportFileLocation')); |
|
83 | + $this->addElement('file', 'import_file',get_lang('Location')); |
|
84 | + $allowed_file_types = array ( |
|
85 | + 'xml', |
|
86 | + 'csv' |
|
87 | + ); |
|
88 | + //$this->addRule('file', get_lang('InvalidExtension') . ' (' . implode(',', $allowed_file_types) . ')', 'filetype', $allowed_file_types); |
|
89 | + $this->addElement('radio', 'file_type', get_lang('FileType'), 'CSV (<a href="docs/example_csv.html" target="_blank">' . get_lang('ExampleCSVFile') . '</a>)', 'csv'); |
|
90 | + $this->addElement('radio', 'file_type', null, 'XML (<a href="docs/example_xml.html" target="_blank">' . get_lang('ExampleXMLFile') . '</a>)', 'xml'); |
|
91 | + $this->addElement('checkbox','overwrite', null,get_lang('OverwriteScores')); |
|
92 | + $this->addElement('checkbox','ignoreerrors',null,get_lang('IgnoreErrors')); |
|
93 | + $this->addButtonImport(get_lang('Ok')); |
|
94 | + $this->setDefaults(array( |
|
95 | + 'formSent' => '1', |
|
96 | + 'file_type' => 'csv' |
|
97 | + )); |
|
98 | + } |
|
99 | 99 | |
100 | - public function display() |
|
101 | - { |
|
102 | - parent :: display(); |
|
103 | - } |
|
100 | + public function display() |
|
101 | + { |
|
102 | + parent :: display(); |
|
103 | + } |
|
104 | 104 | |
105 | - public function setDefaults($defaults = array(), $filter = null) |
|
106 | - { |
|
107 | - parent :: setDefaults($defaults, $filter); |
|
108 | - } |
|
105 | + public function setDefaults($defaults = array(), $filter = null) |
|
106 | + { |
|
107 | + parent :: setDefaults($defaults, $filter); |
|
108 | + } |
|
109 | 109 | } |
@@ -10,128 +10,128 @@ |
||
10 | 10 | */ |
11 | 11 | class UserTable extends SortableTable |
12 | 12 | { |
13 | - private $userid; |
|
14 | - private $datagen; |
|
13 | + private $userid; |
|
14 | + private $datagen; |
|
15 | 15 | |
16 | - /** |
|
17 | - * Constructor |
|
18 | - */ |
|
19 | - public function UserTable($userid, $evals = array(), $links = array(), $addparams = null) |
|
20 | - { |
|
21 | - parent :: __construct ('userlist', null, null, 0); |
|
22 | - $this->userid = $userid; |
|
23 | - $this->datagen = new UserDataGenerator($userid, $evals, $links); |
|
24 | - if (isset($addparams)) { |
|
25 | - $this->set_additional_parameters($addparams); |
|
26 | - } |
|
27 | - $column = 0; |
|
28 | - $this->set_header($column++, get_lang('Type')); |
|
29 | - $this->set_header($column++, get_lang('Evaluation')); |
|
30 | - $this->set_header($column++, get_lang('Course')); |
|
31 | - $this->set_header($column++, get_lang('Category')); |
|
32 | - $this->set_header($column++, get_lang('EvaluationAverage')); |
|
33 | - $this->set_header($column++, get_lang('Result')); |
|
16 | + /** |
|
17 | + * Constructor |
|
18 | + */ |
|
19 | + public function UserTable($userid, $evals = array(), $links = array(), $addparams = null) |
|
20 | + { |
|
21 | + parent :: __construct ('userlist', null, null, 0); |
|
22 | + $this->userid = $userid; |
|
23 | + $this->datagen = new UserDataGenerator($userid, $evals, $links); |
|
24 | + if (isset($addparams)) { |
|
25 | + $this->set_additional_parameters($addparams); |
|
26 | + } |
|
27 | + $column = 0; |
|
28 | + $this->set_header($column++, get_lang('Type')); |
|
29 | + $this->set_header($column++, get_lang('Evaluation')); |
|
30 | + $this->set_header($column++, get_lang('Course')); |
|
31 | + $this->set_header($column++, get_lang('Category')); |
|
32 | + $this->set_header($column++, get_lang('EvaluationAverage')); |
|
33 | + $this->set_header($column++, get_lang('Result')); |
|
34 | 34 | |
35 | - $scoredisplay = ScoreDisplay :: instance(); |
|
36 | - if ($scoredisplay->is_custom()) { |
|
37 | - $this->set_header($column++, get_lang('Display')); |
|
38 | - } |
|
39 | - } |
|
35 | + $scoredisplay = ScoreDisplay :: instance(); |
|
36 | + if ($scoredisplay->is_custom()) { |
|
37 | + $this->set_header($column++, get_lang('Display')); |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Function used by SortableTable to get total number of items in the table |
|
43 | - */ |
|
44 | - function get_total_number_of_items() |
|
45 | - { |
|
46 | - return $this->datagen->get_total_items_count(); |
|
47 | - } |
|
41 | + /** |
|
42 | + * Function used by SortableTable to get total number of items in the table |
|
43 | + */ |
|
44 | + function get_total_number_of_items() |
|
45 | + { |
|
46 | + return $this->datagen->get_total_items_count(); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Function used by SortableTable to generate the data to display |
|
51 | - */ |
|
52 | - public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) |
|
53 | - { |
|
54 | - $scoredisplay = ScoreDisplay :: instance(); |
|
49 | + /** |
|
50 | + * Function used by SortableTable to generate the data to display |
|
51 | + */ |
|
52 | + public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) |
|
53 | + { |
|
54 | + $scoredisplay = ScoreDisplay :: instance(); |
|
55 | 55 | |
56 | - // determine sorting type |
|
57 | - switch ($this->column) { |
|
58 | - // Type |
|
59 | - case 0: |
|
60 | - $sorting = UserDataGenerator :: UDG_SORT_TYPE; |
|
61 | - break; |
|
62 | - case 1: |
|
63 | - $sorting = UserDataGenerator :: UDG_SORT_NAME; |
|
64 | - break; |
|
65 | - case 2: |
|
66 | - $sorting = UserDataGenerator :: UDG_SORT_COURSE; |
|
67 | - break; |
|
68 | - case 3: |
|
69 | - $sorting = UserDataGenerator :: UDG_SORT_CATEGORY; |
|
70 | - break; |
|
71 | - case 4: |
|
72 | - $sorting = UserDataGenerator :: UDG_SORT_AVERAGE; |
|
73 | - break; |
|
74 | - case 5: |
|
75 | - $sorting = UserDataGenerator :: UDG_SORT_SCORE; |
|
76 | - break; |
|
77 | - case 6: |
|
78 | - $sorting = UserDataGenerator :: UDG_SORT_MASK; |
|
79 | - break; |
|
80 | - } |
|
81 | - if ($this->direction == 'DESC') { |
|
82 | - $sorting |= UserDataGenerator :: UDG_SORT_DESC; |
|
83 | - } else { |
|
84 | - $sorting |= UserDataGenerator :: UDG_SORT_ASC; |
|
85 | - } |
|
86 | - $data_array = $this->datagen->get_data($sorting, $from, $this->per_page); |
|
87 | - // generate the data to display |
|
88 | - $sortable_data = array(); |
|
89 | - foreach ($data_array as $data) { |
|
90 | - if ($data[2]!="") {//filter by course removed |
|
91 | - $row = array (); |
|
92 | - $row[] = $this->build_type_column($data[0]); |
|
93 | - $row[] = $this->build_name_link($data[0]); |
|
94 | - $row[] = $data[2]; |
|
95 | - $row[] = $data[3]; |
|
96 | - $row[] = $data[4]; |
|
97 | - $row[] = $data[5]; |
|
98 | - if ($scoredisplay->is_custom()) |
|
99 | - $row[] = $data[6]; |
|
100 | - $sortable_data[] = $row; |
|
101 | - } |
|
102 | - } |
|
56 | + // determine sorting type |
|
57 | + switch ($this->column) { |
|
58 | + // Type |
|
59 | + case 0: |
|
60 | + $sorting = UserDataGenerator :: UDG_SORT_TYPE; |
|
61 | + break; |
|
62 | + case 1: |
|
63 | + $sorting = UserDataGenerator :: UDG_SORT_NAME; |
|
64 | + break; |
|
65 | + case 2: |
|
66 | + $sorting = UserDataGenerator :: UDG_SORT_COURSE; |
|
67 | + break; |
|
68 | + case 3: |
|
69 | + $sorting = UserDataGenerator :: UDG_SORT_CATEGORY; |
|
70 | + break; |
|
71 | + case 4: |
|
72 | + $sorting = UserDataGenerator :: UDG_SORT_AVERAGE; |
|
73 | + break; |
|
74 | + case 5: |
|
75 | + $sorting = UserDataGenerator :: UDG_SORT_SCORE; |
|
76 | + break; |
|
77 | + case 6: |
|
78 | + $sorting = UserDataGenerator :: UDG_SORT_MASK; |
|
79 | + break; |
|
80 | + } |
|
81 | + if ($this->direction == 'DESC') { |
|
82 | + $sorting |= UserDataGenerator :: UDG_SORT_DESC; |
|
83 | + } else { |
|
84 | + $sorting |= UserDataGenerator :: UDG_SORT_ASC; |
|
85 | + } |
|
86 | + $data_array = $this->datagen->get_data($sorting, $from, $this->per_page); |
|
87 | + // generate the data to display |
|
88 | + $sortable_data = array(); |
|
89 | + foreach ($data_array as $data) { |
|
90 | + if ($data[2]!="") {//filter by course removed |
|
91 | + $row = array (); |
|
92 | + $row[] = $this->build_type_column($data[0]); |
|
93 | + $row[] = $this->build_name_link($data[0]); |
|
94 | + $row[] = $data[2]; |
|
95 | + $row[] = $data[3]; |
|
96 | + $row[] = $data[4]; |
|
97 | + $row[] = $data[5]; |
|
98 | + if ($scoredisplay->is_custom()) |
|
99 | + $row[] = $data[6]; |
|
100 | + $sortable_data[] = $row; |
|
101 | + } |
|
102 | + } |
|
103 | 103 | |
104 | - return $sortable_data; |
|
105 | - } |
|
104 | + return $sortable_data; |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @param $item |
|
109 | - * @return string |
|
110 | - */ |
|
111 | - private function build_type_column($item) |
|
112 | - { |
|
113 | - return GradebookUtils::build_type_icon_tag($item->get_icon_name()); |
|
114 | - } |
|
107 | + /** |
|
108 | + * @param $item |
|
109 | + * @return string |
|
110 | + */ |
|
111 | + private function build_type_column($item) |
|
112 | + { |
|
113 | + return GradebookUtils::build_type_icon_tag($item->get_icon_name()); |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * @param $item |
|
118 | - * @return string |
|
119 | - */ |
|
120 | - private function build_name_link($item) |
|
121 | - { |
|
122 | - switch ($item->get_item_type()) { |
|
123 | - // evaluation |
|
124 | - case 'E' : |
|
125 | - return ' ' |
|
126 | - . '<a href="gradebook_view_result.php?selecteval=' . $item->get_id() . '">' |
|
127 | - . $item->get_name() |
|
128 | - . '</a>'; |
|
129 | - // link |
|
130 | - case 'L' : |
|
131 | - return ' <a href="' . $item->get_link() . '">' |
|
132 | - . $item->get_name() |
|
133 | - . '</a>' |
|
134 | - . ' [' . $item->get_type_name() . ']'; |
|
135 | - } |
|
136 | - } |
|
116 | + /** |
|
117 | + * @param $item |
|
118 | + * @return string |
|
119 | + */ |
|
120 | + private function build_name_link($item) |
|
121 | + { |
|
122 | + switch ($item->get_item_type()) { |
|
123 | + // evaluation |
|
124 | + case 'E' : |
|
125 | + return ' ' |
|
126 | + . '<a href="gradebook_view_result.php?selecteval=' . $item->get_id() . '">' |
|
127 | + . $item->get_name() |
|
128 | + . '</a>'; |
|
129 | + // link |
|
130 | + case 'L' : |
|
131 | + return ' <a href="' . $item->get_link() . '">' |
|
132 | + . $item->get_name() |
|
133 | + . '</a>' |
|
134 | + . ' [' . $item->get_type_name() . ']'; |
|
135 | + } |
|
136 | + } |
|
137 | 137 | } |
@@ -10,47 +10,47 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class ScoreDisplayForm extends FormValidator |
12 | 12 | { |
13 | - /** |
|
14 | - * @param $form_name |
|
15 | - * @param null $action |
|
16 | - */ |
|
17 | - public function ScoreDisplayForm($form_name, $action= null) |
|
18 | - { |
|
19 | - parent :: __construct($form_name, 'post', $action); |
|
20 | - $displayscore = ScoreDisplay :: instance(); |
|
21 | - $customdisplays = $displayscore->get_custom_score_display_settings(); |
|
22 | - |
|
23 | - $nr_items = (count($customdisplays)!='0') ? count($customdisplays) : '1'; |
|
24 | - $this->setDefaults(array ( |
|
13 | + /** |
|
14 | + * @param $form_name |
|
15 | + * @param null $action |
|
16 | + */ |
|
17 | + public function ScoreDisplayForm($form_name, $action= null) |
|
18 | + { |
|
19 | + parent :: __construct($form_name, 'post', $action); |
|
20 | + $displayscore = ScoreDisplay :: instance(); |
|
21 | + $customdisplays = $displayscore->get_custom_score_display_settings(); |
|
22 | + |
|
23 | + $nr_items = (count($customdisplays)!='0') ? count($customdisplays) : '1'; |
|
24 | + $this->setDefaults(array ( |
|
25 | 25 | 'scorecolpercent' => $displayscore->get_color_split_value() |
26 | - )); |
|
26 | + )); |
|
27 | 27 | |
28 | - $this->addElement('hidden', 'maxvalue', '100'); |
|
29 | - $this->addElement('hidden', 'minvalue', '0'); |
|
30 | - $counter= 1; |
|
28 | + $this->addElement('hidden', 'maxvalue', '100'); |
|
29 | + $this->addElement('hidden', 'minvalue', '0'); |
|
30 | + $counter= 1; |
|
31 | 31 | |
32 | - //setting the default values |
|
32 | + //setting the default values |
|
33 | 33 | |
34 | - if(is_array($customdisplays)) { |
|
35 | - foreach ($customdisplays as $customdisplay) { |
|
36 | - $this->setDefaults(array ( |
|
37 | - 'endscore[' . $counter . ']' => $customdisplay['score'], |
|
38 | - 'displaytext[' . $counter . ']' => $customdisplay['display'] |
|
39 | - )); |
|
40 | - $counter++; |
|
41 | - } |
|
42 | - } |
|
43 | - $scorecol = array(); |
|
34 | + if(is_array($customdisplays)) { |
|
35 | + foreach ($customdisplays as $customdisplay) { |
|
36 | + $this->setDefaults(array ( |
|
37 | + 'endscore[' . $counter . ']' => $customdisplay['score'], |
|
38 | + 'displaytext[' . $counter . ']' => $customdisplay['display'] |
|
39 | + )); |
|
40 | + $counter++; |
|
41 | + } |
|
42 | + } |
|
43 | + $scorecol = array(); |
|
44 | 44 | |
45 | - //settings for the colored score |
|
46 | - $this->addElement('header', get_lang('ScoreEdit')); |
|
45 | + //settings for the colored score |
|
46 | + $this->addElement('header', get_lang('ScoreEdit')); |
|
47 | 47 | |
48 | 48 | if ($displayscore->is_coloring_enabled()) { |
49 | 49 | $this->addElement('html', '<b>' . get_lang('ScoreColor') . '</b>'); |
50 | 50 | $this->addElement('text', 'scorecolpercent', array(get_lang('Below'), get_lang('WillColorRed'), '%'), array( |
51 | 51 | 'size' => 5, |
52 | 52 | 'maxlength' => 5, |
53 | - 'input-size' => 2 |
|
53 | + 'input-size' => 2 |
|
54 | 54 | )); |
55 | 55 | |
56 | 56 | if (api_get_setting('teachers_can_change_score_settings') != 'true') { |
@@ -62,25 +62,25 @@ discard block |
||
62 | 62 | $this->addRule(array('scorecolpercent','minvalue'), get_lang('UnderMin'), 'compare', '>'); |
63 | 63 | } |
64 | 64 | |
65 | - //Settings for the scoring system |
|
65 | + //Settings for the scoring system |
|
66 | 66 | |
67 | - if ($displayscore->is_custom()) { |
|
67 | + if ($displayscore->is_custom()) { |
|
68 | 68 | $this->addElement('html', '<br /><b>' . get_lang('ScoringSystem') . '</b>'); |
69 | - $this->addElement('static', null, null, get_lang('ScoreInfo')); |
|
70 | - $this->setDefaults(array( |
|
71 | - 'beginscore' => '0' |
|
72 | - )); |
|
73 | - $this->addElement('text', 'beginscore', array(get_lang('Between'), null, '%'), array( |
|
74 | - 'size' => 5, |
|
75 | - 'maxlength' => 5, |
|
76 | - 'disabled' => 'disabled', |
|
77 | - 'input-size' => 2 |
|
78 | - )); |
|
79 | - |
|
80 | - for ($counter= 1; $counter <= 20; $counter++) { |
|
81 | - $renderer =& $this->defaultRenderer(); |
|
82 | - $elementTemplateTwoLabel = |
|
83 | - '<div id=' . $counter . ' style="display: '.(($counter<=$nr_items)?'inline':'none').';"> |
|
69 | + $this->addElement('static', null, null, get_lang('ScoreInfo')); |
|
70 | + $this->setDefaults(array( |
|
71 | + 'beginscore' => '0' |
|
72 | + )); |
|
73 | + $this->addElement('text', 'beginscore', array(get_lang('Between'), null, '%'), array( |
|
74 | + 'size' => 5, |
|
75 | + 'maxlength' => 5, |
|
76 | + 'disabled' => 'disabled', |
|
77 | + 'input-size' => 2 |
|
78 | + )); |
|
79 | + |
|
80 | + for ($counter= 1; $counter <= 20; $counter++) { |
|
81 | + $renderer =& $this->defaultRenderer(); |
|
82 | + $elementTemplateTwoLabel = |
|
83 | + '<div id=' . $counter . ' style="display: '.(($counter<=$nr_items)?'inline':'none').';"> |
|
84 | 84 | |
85 | 85 | <!-- BEGIN required --><span class="form_required">*</span> <!-- END required --> |
86 | 86 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | '; |
107 | 107 | |
108 | - $elementTemplateTwoLabel2 =' |
|
108 | + $elementTemplateTwoLabel2 =' |
|
109 | 109 | <div class="col-sm-2"> |
110 | 110 | <!-- BEGIN error --><span class="form_error">{error}</span> |
111 | 111 | <!-- END error --> |
@@ -118,33 +118,33 @@ discard block |
||
118 | 118 | </div> |
119 | 119 | </div>'; |
120 | 120 | |
121 | - $scorebetw = array(); |
|
122 | - $this->addElement('text', 'endscore[' . $counter . ']', null, array ( |
|
123 | - 'size' => 5, |
|
124 | - 'maxlength' => 5, |
|
125 | - 'id' => 'txta-'.$counter, |
|
126 | - 'input-size' => 2 |
|
127 | - )); |
|
128 | - |
|
129 | - $this->addElement('text', 'displaytext[' . $counter . ']', null,array ( |
|
130 | - 'size' => 40, |
|
131 | - 'maxlength' => 40, |
|
132 | - 'id' => 'txtb-'.$counter |
|
133 | - )); |
|
134 | - $renderer->setElementTemplate($elementTemplateTwoLabel, 'endscore[' . $counter . ']'); |
|
135 | - $renderer->setElementTemplate($elementTemplateTwoLabel2, 'displaytext[' . $counter . ']'); |
|
136 | - $this->addRule('endscore[' . $counter . ']', get_lang('OnlyNumbers'), 'numeric'); |
|
137 | - $this->addRule(array ('endscore[' . $counter . ']', 'maxvalue'), get_lang('Over100'), 'compare', '<='); |
|
138 | - $this->addRule(array ('endscore[' . $counter . ']', 'minvalue'), get_lang('UnderMin'), 'compare', '>'); |
|
139 | - } |
|
140 | - } |
|
121 | + $scorebetw = array(); |
|
122 | + $this->addElement('text', 'endscore[' . $counter . ']', null, array ( |
|
123 | + 'size' => 5, |
|
124 | + 'maxlength' => 5, |
|
125 | + 'id' => 'txta-'.$counter, |
|
126 | + 'input-size' => 2 |
|
127 | + )); |
|
128 | + |
|
129 | + $this->addElement('text', 'displaytext[' . $counter . ']', null,array ( |
|
130 | + 'size' => 40, |
|
131 | + 'maxlength' => 40, |
|
132 | + 'id' => 'txtb-'.$counter |
|
133 | + )); |
|
134 | + $renderer->setElementTemplate($elementTemplateTwoLabel, 'endscore[' . $counter . ']'); |
|
135 | + $renderer->setElementTemplate($elementTemplateTwoLabel2, 'displaytext[' . $counter . ']'); |
|
136 | + $this->addRule('endscore[' . $counter . ']', get_lang('OnlyNumbers'), 'numeric'); |
|
137 | + $this->addRule(array ('endscore[' . $counter . ']', 'maxvalue'), get_lang('Over100'), 'compare', '<='); |
|
138 | + $this->addRule(array ('endscore[' . $counter . ']', 'minvalue'), get_lang('UnderMin'), 'compare', '>'); |
|
139 | + } |
|
140 | + } |
|
141 | 141 | |
142 | 142 | if ($displayscore->is_custom()) { |
143 | - $this->addButtonSave(get_lang('Ok')); |
|
144 | - } |
|
145 | - } |
|
143 | + $this->addButtonSave(get_lang('Ok')); |
|
144 | + } |
|
145 | + } |
|
146 | 146 | |
147 | - function validate() { |
|
148 | - return parent :: validate(); |
|
149 | - } |
|
147 | + function validate() { |
|
148 | + return parent :: validate(); |
|
149 | + } |
|
150 | 150 | } |
@@ -194,13 +194,13 @@ discard block |
||
194 | 194 | in exercice/exercice.php, look for note-query-exe-results marker*/ |
195 | 195 | $session_id = api_get_session_id(); |
196 | 196 | $courseId = $this->getCourseId(); |
197 | - $exercise = new Exercise($courseId); |
|
197 | + $exercise = new Exercise($courseId); |
|
198 | 198 | $exercise->read($this->get_ref_id()); |
199 | 199 | |
200 | 200 | if (!$this->is_hp) { |
201 | 201 | |
202 | - if ($exercise->exercise_was_added_in_lp == false) { |
|
203 | - $sql = "SELECT * FROM $tblStats |
|
202 | + if ($exercise->exercise_was_added_in_lp == false) { |
|
203 | + $sql = "SELECT * FROM $tblStats |
|
204 | 204 | WHERE |
205 | 205 | exe_exo_id = ".intval($this->get_ref_id())." AND |
206 | 206 | orig_lp_id = 0 AND |
@@ -209,15 +209,15 @@ discard block |
||
209 | 209 | session_id = $session_id AND |
210 | 210 | c_id = $courseId |
211 | 211 | "; |
212 | - } else { |
|
213 | - $lpId = null; |
|
214 | - if (!empty($exercise->lpList)) { |
|
215 | - // Taking only the first LP |
|
216 | - $lpId = current($exercise->lpList); |
|
217 | - $lpId = $lpId['lp_id']; |
|
218 | - } |
|
219 | - |
|
220 | - $sql = "SELECT * FROM $tblStats |
|
212 | + } else { |
|
213 | + $lpId = null; |
|
214 | + if (!empty($exercise->lpList)) { |
|
215 | + // Taking only the first LP |
|
216 | + $lpId = current($exercise->lpList); |
|
217 | + $lpId = $lpId['lp_id']; |
|
218 | + } |
|
219 | + |
|
220 | + $sql = "SELECT * FROM $tblStats |
|
221 | 221 | WHERE |
222 | 222 | exe_exo_id = ".intval($this->get_ref_id())." AND |
223 | 223 | orig_lp_id = $lpId AND |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | session_id = $session_id AND |
226 | 226 | c_id = $courseId |
227 | 227 | "; |
228 | - } |
|
228 | + } |
|
229 | 229 | |
230 | 230 | if (!empty($stud_id) && $type != 'ranking') { |
231 | 231 | $sql .= " AND exe_user_id = $stud_id "; |
@@ -8,16 +8,16 @@ |
||
8 | 8 | */ |
9 | 9 | interface GradebookItem |
10 | 10 | { |
11 | - public function get_item_type(); |
|
12 | - public function get_id(); |
|
13 | - public function get_name(); |
|
14 | - public function get_description(); |
|
15 | - public function get_course_code(); |
|
16 | - public function get_weight(); |
|
17 | - public function get_date(); |
|
18 | - public function is_visible(); |
|
19 | - public function get_icon_name(); |
|
20 | - public function getStudentList(); |
|
21 | - public function setStudentList($list); |
|
22 | - public function calc_score($stud_id = null, $type = null); |
|
11 | + public function get_item_type(); |
|
12 | + public function get_id(); |
|
13 | + public function get_name(); |
|
14 | + public function get_description(); |
|
15 | + public function get_course_code(); |
|
16 | + public function get_weight(); |
|
17 | + public function get_date(); |
|
18 | + public function is_visible(); |
|
19 | + public function get_icon_name(); |
|
20 | + public function getStudentList(); |
|
21 | + public function setStudentList($list); |
|
22 | + public function calc_score($stud_id = null, $type = null); |
|
23 | 23 | } |