@@ -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 | } |
@@ -14,28 +14,28 @@ discard block |
||
14 | 14 | * @param $form_name |
15 | 15 | * @param null $action |
16 | 16 | */ |
17 | - public function ScoreDisplayForm($form_name, $action= null) |
|
17 | + public function ScoreDisplayForm($form_name, $action = null) |
|
18 | 18 | { |
19 | 19 | parent :: __construct($form_name, 'post', $action); |
20 | 20 | $displayscore = ScoreDisplay :: instance(); |
21 | 21 | $customdisplays = $displayscore->get_custom_score_display_settings(); |
22 | 22 | |
23 | - $nr_items = (count($customdisplays)!='0') ? count($customdisplays) : '1'; |
|
24 | - $this->setDefaults(array ( |
|
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 | 28 | $this->addElement('hidden', 'maxvalue', '100'); |
29 | 29 | $this->addElement('hidden', 'minvalue', '0'); |
30 | - $counter= 1; |
|
30 | + $counter = 1; |
|
31 | 31 | |
32 | 32 | //setting the default values |
33 | 33 | |
34 | - if(is_array($customdisplays)) { |
|
34 | + if (is_array($customdisplays)) { |
|
35 | 35 | foreach ($customdisplays as $customdisplay) { |
36 | - $this->setDefaults(array ( |
|
37 | - 'endscore[' . $counter . ']' => $customdisplay['score'], |
|
38 | - 'displaytext[' . $counter . ']' => $customdisplay['display'] |
|
36 | + $this->setDefaults(array( |
|
37 | + 'endscore['.$counter.']' => $customdisplay['score'], |
|
38 | + 'displaytext['.$counter.']' => $customdisplay['display'] |
|
39 | 39 | )); |
40 | 40 | $counter++; |
41 | 41 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $this->addElement('header', get_lang('ScoreEdit')); |
47 | 47 | |
48 | 48 | if ($displayscore->is_coloring_enabled()) { |
49 | - $this->addElement('html', '<b>' . get_lang('ScoreColor') . '</b>'); |
|
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, |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | $this->addRule('scorecolpercent', get_lang('OnlyNumbers'), 'numeric'); |
61 | - $this->addRule(array('scorecolpercent','maxvalue'), get_lang('Over100'), 'compare', '<='); |
|
62 | - $this->addRule(array('scorecolpercent','minvalue'), get_lang('UnderMin'), 'compare', '>'); |
|
61 | + $this->addRule(array('scorecolpercent', 'maxvalue'), get_lang('Over100'), 'compare', '<='); |
|
62 | + $this->addRule(array('scorecolpercent', 'minvalue'), get_lang('UnderMin'), 'compare', '>'); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | //Settings for the scoring system |
66 | 66 | |
67 | 67 | if ($displayscore->is_custom()) { |
68 | - $this->addElement('html', '<br /><b>' . get_lang('ScoringSystem') . '</b>'); |
|
68 | + $this->addElement('html', '<br /><b>'.get_lang('ScoringSystem').'</b>'); |
|
69 | 69 | $this->addElement('static', null, null, get_lang('ScoreInfo')); |
70 | 70 | $this->setDefaults(array( |
71 | 71 | 'beginscore' => '0' |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | 'input-size' => 2 |
78 | 78 | )); |
79 | 79 | |
80 | - for ($counter= 1; $counter <= 20; $counter++) { |
|
81 | - $renderer =& $this->defaultRenderer(); |
|
80 | + for ($counter = 1; $counter <= 20; $counter++) { |
|
81 | + $renderer = & $this->defaultRenderer(); |
|
82 | 82 | $elementTemplateTwoLabel = |
83 | - '<div id=' . $counter . ' style="display: '.(($counter<=$nr_items)?'inline':'none').';"> |
|
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,39 +105,39 @@ 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 --> |
112 | 112 | {element} |
113 | 113 | </div> |
114 | 114 | <div class="col-sm-1"> |
115 | - <a href="javascript:plusItem(' . ($counter+1) . ')"> |
|
116 | - <img style="display: '.(($counter>=$nr_items)?'inline':'none').';" id="plus-' . ($counter+1) . '" src="'.Display::returnIconPath('add.png').'" alt="'.get_lang('Add').'" title="'.get_lang('Add').'"></a> |
|
117 | - <a href="javascript:minItem(' . ($counter) . ')"> |
|
118 | - <img style="display: '.(($counter>=$nr_items && $counter!=1)?'inline':'none').';" id="min-' . $counter . '" src="'.Display::returnIconPath('delete.png').'" alt="'.get_lang('Delete').'" title="'.get_lang('Delete').'"></a> |
|
115 | + <a href="javascript:plusItem(' . ($counter + 1).')"> |
|
116 | + <img style="display: '.(($counter >= $nr_items) ? 'inline' : 'none').';" id="plus-'.($counter + 1).'" src="'.Display::returnIconPath('add.png').'" alt="'.get_lang('Add').'" title="'.get_lang('Add').'"></a> |
|
117 | + <a href="javascript:minItem(' . ($counter).')"> |
|
118 | + <img style="display: '.(($counter >= $nr_items && $counter != 1) ? 'inline' : 'none').';" id="min-'.$counter.'" src="'.Display::returnIconPath('delete.png').'" alt="'.get_lang('Delete').'" title="'.get_lang('Delete').'"></a> |
|
119 | 119 | </div> |
120 | 120 | </div> |
121 | 121 | </div>'; |
122 | 122 | |
123 | 123 | $scorebetw = array(); |
124 | - $this->addElement('text', 'endscore[' . $counter . ']', null, array ( |
|
124 | + $this->addElement('text', 'endscore['.$counter.']', null, array( |
|
125 | 125 | 'size' => 5, |
126 | 126 | 'maxlength' => 5, |
127 | 127 | 'id' => 'txta-'.$counter, |
128 | 128 | 'input-size' => 2 |
129 | 129 | )); |
130 | 130 | |
131 | - $this->addElement('text', 'displaytext[' . $counter . ']', null,array ( |
|
131 | + $this->addElement('text', 'displaytext['.$counter.']', null, array( |
|
132 | 132 | 'size' => 40, |
133 | 133 | 'maxlength' => 40, |
134 | 134 | 'id' => 'txtb-'.$counter |
135 | 135 | )); |
136 | - $renderer->setElementTemplate($elementTemplateTwoLabel, 'endscore[' . $counter . ']'); |
|
137 | - $renderer->setElementTemplate($elementTemplateTwoLabel2, 'displaytext[' . $counter . ']'); |
|
138 | - $this->addRule('endscore[' . $counter . ']', get_lang('OnlyNumbers'), 'numeric'); |
|
139 | - $this->addRule(array ('endscore[' . $counter . ']', 'maxvalue'), get_lang('Over100'), 'compare', '<='); |
|
140 | - $this->addRule(array ('endscore[' . $counter . ']', 'minvalue'), get_lang('UnderMin'), 'compare', '>'); |
|
136 | + $renderer->setElementTemplate($elementTemplateTwoLabel, 'endscore['.$counter.']'); |
|
137 | + $renderer->setElementTemplate($elementTemplateTwoLabel2, 'displaytext['.$counter.']'); |
|
138 | + $this->addRule('endscore['.$counter.']', get_lang('OnlyNumbers'), 'numeric'); |
|
139 | + $this->addRule(array('endscore['.$counter.']', 'maxvalue'), get_lang('Over100'), 'compare', '<='); |
|
140 | + $this->addRule(array('endscore['.$counter.']', 'minvalue'), get_lang('UnderMin'), 'compare', '>'); |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 |
@@ -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 | } |
@@ -8,48 +8,48 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class AttendanceLink extends AbstractLink |
10 | 10 | { |
11 | - private $attendance_table = null; |
|
12 | - private $itemprop_table = null; |
|
11 | + private $attendance_table = null; |
|
12 | + private $itemprop_table = null; |
|
13 | 13 | |
14 | - /** |
|
15 | - * Constructor |
|
16 | - */ |
|
17 | - public function __construct() |
|
18 | - { |
|
19 | - parent::__construct(); |
|
20 | - $this->set_type(LINK_ATTENDANCE); |
|
21 | - } |
|
14 | + /** |
|
15 | + * Constructor |
|
16 | + */ |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + parent::__construct(); |
|
20 | + $this->set_type(LINK_ATTENDANCE); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function get_type_name() |
|
27 | - { |
|
28 | - return get_lang('Attendance'); |
|
29 | - } |
|
23 | + /** |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function get_type_name() |
|
27 | + { |
|
28 | + return get_lang('Attendance'); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @return bool |
|
33 | - */ |
|
34 | - public function is_allowed_to_change_name() |
|
35 | - { |
|
36 | - return false; |
|
37 | - } |
|
31 | + /** |
|
32 | + * @return bool |
|
33 | + */ |
|
34 | + public function is_allowed_to_change_name() |
|
35 | + { |
|
36 | + return false; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Generate an array of attendances that a teacher hasn't created a link for. |
|
41 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
42 | - * @todo seems to be depracated |
|
43 | - */ |
|
44 | - public function get_not_created_links() |
|
45 | - { |
|
46 | - return false; |
|
47 | - if (empty($this->course_code)) { |
|
48 | - die('Error in get_not_created_links() : course code not set'); |
|
49 | - } |
|
50 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
39 | + /** |
|
40 | + * Generate an array of attendances that a teacher hasn't created a link for. |
|
41 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
42 | + * @todo seems to be depracated |
|
43 | + */ |
|
44 | + public function get_not_created_links() |
|
45 | + { |
|
46 | + return false; |
|
47 | + if (empty($this->course_code)) { |
|
48 | + die('Error in get_not_created_links() : course code not set'); |
|
49 | + } |
|
50 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
51 | 51 | |
52 | - $sql = 'SELECT att.id, att.name, att.attendance_qualify_title |
|
52 | + $sql = 'SELECT att.id, att.name, att.attendance_qualify_title |
|
53 | 53 | FROM '.$this->get_attendance_table().' att |
54 | 54 | WHERE |
55 | 55 | att.c_id = '.$this->course_id.' AND |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | course_code = "'.Database::escape_string($this->get_course_code()).'" |
61 | 61 | ) |
62 | 62 | AND att.session_id='.api_get_session_id().''; |
63 | - $result = Database::query($sql); |
|
63 | + $result = Database::query($sql); |
|
64 | 64 | |
65 | 65 | $cats = array(); |
66 | 66 | while ($data = Database::fetch_array($result)) { |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - return $cats; |
|
75 | - } |
|
74 | + return $cats; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Generate an array of all attendances available. |
|
79 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
80 | - */ |
|
77 | + /** |
|
78 | + * Generate an array of all attendances available. |
|
79 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
80 | + */ |
|
81 | 81 | public function get_all_links() |
82 | 82 | { |
83 | 83 | if (empty($this->course_code)) { |
@@ -104,55 +104,55 @@ discard block |
||
104 | 104 | $my_cats = isset($cats) ? $cats : null; |
105 | 105 | |
106 | 106 | return $my_cats; |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Has anyone done this exercise yet ? |
|
111 | - */ |
|
112 | - public function has_results() |
|
113 | - { |
|
114 | - $tbl_attendance_result = Database :: get_course_table(TABLE_ATTENDANCE_RESULT); |
|
115 | - $session_id = api_get_session_id(); |
|
116 | - $sql = 'SELECT count(*) AS number FROM '.$tbl_attendance_result." |
|
109 | + /** |
|
110 | + * Has anyone done this exercise yet ? |
|
111 | + */ |
|
112 | + public function has_results() |
|
113 | + { |
|
114 | + $tbl_attendance_result = Database :: get_course_table(TABLE_ATTENDANCE_RESULT); |
|
115 | + $session_id = api_get_session_id(); |
|
116 | + $sql = 'SELECT count(*) AS number FROM '.$tbl_attendance_result." |
|
117 | 117 | WHERE |
118 | 118 | session_id = $session_id AND |
119 | 119 | c_id = '.$this->course_id.' AND |
120 | 120 | attendance_id = '".intval($this->get_ref_id())."'"; |
121 | - $result = Database::query($sql); |
|
122 | - $number = Database::fetch_row($result); |
|
121 | + $result = Database::query($sql); |
|
122 | + $number = Database::fetch_row($result); |
|
123 | 123 | |
124 | - return $number[0] != 0; |
|
125 | - } |
|
124 | + return $number[0] != 0; |
|
125 | + } |
|
126 | 126 | |
127 | - /** |
|
128 | - * @param int $stud_id |
|
129 | - * @return array|null |
|
130 | - */ |
|
131 | - public function calc_score($stud_id = null, $type = null) |
|
132 | - { |
|
133 | - $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
134 | - $session_id = api_get_session_id(); |
|
127 | + /** |
|
128 | + * @param int $stud_id |
|
129 | + * @return array|null |
|
130 | + */ |
|
131 | + public function calc_score($stud_id = null, $type = null) |
|
132 | + { |
|
133 | + $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
134 | + $session_id = api_get_session_id(); |
|
135 | 135 | |
136 | - // get attendance qualify max |
|
137 | - $sql = 'SELECT att.attendance_qualify_max |
|
136 | + // get attendance qualify max |
|
137 | + $sql = 'SELECT att.attendance_qualify_max |
|
138 | 138 | FROM '.$this->get_attendance_table().' att |
139 | 139 | WHERE |
140 | 140 | att.c_id = '.$this->course_id.' AND |
141 | 141 | att.id = '.intval($this->get_ref_id()).' AND |
142 | 142 | att.session_id='.intval($session_id).''; |
143 | - $query = Database::query($sql); |
|
144 | - $attendance = Database::fetch_array($query, 'ASSOC'); |
|
143 | + $query = Database::query($sql); |
|
144 | + $attendance = Database::fetch_array($query, 'ASSOC'); |
|
145 | 145 | |
146 | - // Get results |
|
147 | - $sql = 'SELECT * |
|
146 | + // Get results |
|
147 | + $sql = 'SELECT * |
|
148 | 148 | FROM '.$tbl_attendance_result.' |
149 | 149 | WHERE c_id = '.$this->course_id.' AND attendance_id = '.intval($this->get_ref_id()); |
150 | - if (isset($stud_id)) { |
|
151 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
152 | - } |
|
153 | - $scores = Database::query($sql); |
|
154 | - // for 1 student |
|
155 | - if (isset($stud_id)) { |
|
150 | + if (isset($stud_id)) { |
|
151 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
152 | + } |
|
153 | + $scores = Database::query($sql); |
|
154 | + // for 1 student |
|
155 | + if (isset($stud_id)) { |
|
156 | 156 | if ($data = Database::fetch_array($scores, 'ASSOC')) { |
157 | 157 | return array( |
158 | 158 | $data['score'], |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | //We sent the 0/attendance_qualify_max instead of null for correct calculations |
163 | 163 | return array(0, $attendance['attendance_qualify_max']); |
164 | 164 | } |
165 | - } else { |
|
165 | + } else { |
|
166 | 166 | // all students -> get average |
167 | 167 | $students = array(); // user list, needed to make sure we only |
168 | 168 | // take first attempts into account |
@@ -171,144 +171,144 @@ discard block |
||
171 | 171 | $sumResult = 0; |
172 | 172 | $bestResult = 0; |
173 | 173 | |
174 | - while ($data = Database::fetch_array($scores)) { |
|
175 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
176 | - if ($attendance['attendance_qualify_max'] != 0) { |
|
177 | - $students[$data['user_id']] = $data['score']; |
|
178 | - $rescount++; |
|
179 | - $sum += $data['score'] / $attendance['attendance_qualify_max']; |
|
180 | - $sumResult += $data['score']; |
|
181 | - if ($data['score'] > $bestResult) { |
|
182 | - $bestResult = $data['score']; |
|
183 | - } |
|
184 | - $weight = $attendance['attendance_qualify_max']; |
|
185 | - } |
|
186 | - } |
|
187 | - } |
|
174 | + while ($data = Database::fetch_array($scores)) { |
|
175 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
176 | + if ($attendance['attendance_qualify_max'] != 0) { |
|
177 | + $students[$data['user_id']] = $data['score']; |
|
178 | + $rescount++; |
|
179 | + $sum += $data['score'] / $attendance['attendance_qualify_max']; |
|
180 | + $sumResult += $data['score']; |
|
181 | + if ($data['score'] > $bestResult) { |
|
182 | + $bestResult = $data['score']; |
|
183 | + } |
|
184 | + $weight = $attendance['attendance_qualify_max']; |
|
185 | + } |
|
186 | + } |
|
187 | + } |
|
188 | 188 | |
189 | - if ($rescount == 0) { |
|
190 | - return null; |
|
191 | - } else { |
|
192 | - switch ($type) { |
|
193 | - case 'best': |
|
194 | - return array($bestResult, $weight); |
|
195 | - break; |
|
196 | - case 'average': |
|
197 | - return array($sumResult / $rescount, $weight); |
|
198 | - break; |
|
199 | - case 'ranking': |
|
200 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
201 | - break; |
|
202 | - default: |
|
203 | - return array($sum, $rescount); |
|
204 | - break; |
|
205 | - } |
|
206 | - } |
|
207 | - } |
|
208 | - } |
|
189 | + if ($rescount == 0) { |
|
190 | + return null; |
|
191 | + } else { |
|
192 | + switch ($type) { |
|
193 | + case 'best': |
|
194 | + return array($bestResult, $weight); |
|
195 | + break; |
|
196 | + case 'average': |
|
197 | + return array($sumResult / $rescount, $weight); |
|
198 | + break; |
|
199 | + case 'ranking': |
|
200 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
201 | + break; |
|
202 | + default: |
|
203 | + return array($sum, $rescount); |
|
204 | + break; |
|
205 | + } |
|
206 | + } |
|
207 | + } |
|
208 | + } |
|
209 | 209 | |
210 | - /** |
|
211 | - * Lazy load function to get the database table of the student publications |
|
212 | - */ |
|
213 | - private function get_attendance_table() |
|
214 | - { |
|
215 | - $this->attendance_table = Database::get_course_table(TABLE_ATTENDANCE); |
|
216 | - return $this->attendance_table; |
|
217 | - } |
|
210 | + /** |
|
211 | + * Lazy load function to get the database table of the student publications |
|
212 | + */ |
|
213 | + private function get_attendance_table() |
|
214 | + { |
|
215 | + $this->attendance_table = Database::get_course_table(TABLE_ATTENDANCE); |
|
216 | + return $this->attendance_table; |
|
217 | + } |
|
218 | 218 | |
219 | - public function needs_name_and_description() |
|
220 | - { |
|
221 | - return false; |
|
222 | - } |
|
219 | + public function needs_name_and_description() |
|
220 | + { |
|
221 | + return false; |
|
222 | + } |
|
223 | 223 | |
224 | - public function needs_max() |
|
225 | - { |
|
226 | - return false; |
|
227 | - } |
|
224 | + public function needs_max() |
|
225 | + { |
|
226 | + return false; |
|
227 | + } |
|
228 | 228 | |
229 | - public function needs_results() |
|
230 | - { |
|
231 | - return false; |
|
232 | - } |
|
229 | + public function needs_results() |
|
230 | + { |
|
231 | + return false; |
|
232 | + } |
|
233 | 233 | |
234 | - /** |
|
235 | - * @return string |
|
236 | - */ |
|
237 | - public function get_name() |
|
238 | - { |
|
239 | - $this->get_attendance_data(); |
|
240 | - $attendance_title = isset($this->attendance_data['name']) ? $this->attendance_data['name'] : ''; |
|
241 | - $attendance_qualify_title = isset($this->attendance_data['attendance_qualify_title']) ? $this->attendance_data['attendance_qualify_title'] : ''; |
|
242 | - if ( isset($attendance_qualify_title) && $attendance_qualify_title != '') { |
|
243 | - return $this->attendance_data['attendance_qualify_title']; |
|
244 | - } else { |
|
245 | - return $attendance_title; |
|
246 | - } |
|
247 | - } |
|
234 | + /** |
|
235 | + * @return string |
|
236 | + */ |
|
237 | + public function get_name() |
|
238 | + { |
|
239 | + $this->get_attendance_data(); |
|
240 | + $attendance_title = isset($this->attendance_data['name']) ? $this->attendance_data['name'] : ''; |
|
241 | + $attendance_qualify_title = isset($this->attendance_data['attendance_qualify_title']) ? $this->attendance_data['attendance_qualify_title'] : ''; |
|
242 | + if ( isset($attendance_qualify_title) && $attendance_qualify_title != '') { |
|
243 | + return $this->attendance_data['attendance_qualify_title']; |
|
244 | + } else { |
|
245 | + return $attendance_title; |
|
246 | + } |
|
247 | + } |
|
248 | 248 | |
249 | - /** |
|
250 | - * @return string |
|
251 | - */ |
|
252 | - public function get_description() |
|
253 | - { |
|
254 | - return ''; |
|
255 | - } |
|
249 | + /** |
|
250 | + * @return string |
|
251 | + */ |
|
252 | + public function get_description() |
|
253 | + { |
|
254 | + return ''; |
|
255 | + } |
|
256 | 256 | |
257 | - /** |
|
258 | - * Check if this still links to an exercise |
|
259 | - */ |
|
260 | - public function is_valid_link() |
|
261 | - { |
|
262 | - $session_id = api_get_session_id(); |
|
263 | - $sql = 'SELECT count(att.id) FROM '.$this->get_attendance_table().' att |
|
257 | + /** |
|
258 | + * Check if this still links to an exercise |
|
259 | + */ |
|
260 | + public function is_valid_link() |
|
261 | + { |
|
262 | + $session_id = api_get_session_id(); |
|
263 | + $sql = 'SELECT count(att.id) FROM '.$this->get_attendance_table().' att |
|
264 | 264 | WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' '; |
265 | - $result = Database::query($sql); |
|
266 | - $number = Database::fetch_row($result); |
|
267 | - return ($number[0] != 0); |
|
268 | - } |
|
265 | + $result = Database::query($sql); |
|
266 | + $number = Database::fetch_row($result); |
|
267 | + return ($number[0] != 0); |
|
268 | + } |
|
269 | 269 | |
270 | - public function get_test_id() |
|
271 | - { |
|
272 | - return 'DEBUG:ID'; |
|
273 | - } |
|
270 | + public function get_test_id() |
|
271 | + { |
|
272 | + return 'DEBUG:ID'; |
|
273 | + } |
|
274 | 274 | |
275 | - public function get_link() |
|
276 | - { |
|
277 | - //it was extracts the attendance id |
|
278 | - $session_id = api_get_session_id(); |
|
279 | - $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
275 | + public function get_link() |
|
276 | + { |
|
277 | + //it was extracts the attendance id |
|
278 | + $session_id = api_get_session_id(); |
|
279 | + $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
280 | 280 | WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' '; |
281 | - $result = Database::query($sql); |
|
282 | - $row = Database::fetch_array($result,'ASSOC'); |
|
283 | - $attendance_id = $row['id']; |
|
284 | - $url = api_get_path(WEB_PATH).'main/attendance/index.php?action=attendance_sheet_list&gradebook=view&attendance_id='.$attendance_id.'&session_id='.$session_id.'&cidReq='.$this->get_course_code(); |
|
281 | + $result = Database::query($sql); |
|
282 | + $row = Database::fetch_array($result,'ASSOC'); |
|
283 | + $attendance_id = $row['id']; |
|
284 | + $url = api_get_path(WEB_PATH).'main/attendance/index.php?action=attendance_sheet_list&gradebook=view&attendance_id='.$attendance_id.'&session_id='.$session_id.'&cidReq='.$this->get_course_code(); |
|
285 | 285 | |
286 | - return $url; |
|
287 | - } |
|
286 | + return $url; |
|
287 | + } |
|
288 | 288 | |
289 | - /** |
|
290 | - * @return array|bool |
|
291 | - */ |
|
292 | - private function get_attendance_data() |
|
293 | - { |
|
294 | - $tbl_name = $this->get_attendance_table(); |
|
295 | - $session_id = api_get_session_id(); |
|
296 | - if ($tbl_name == '') { |
|
297 | - return false; |
|
298 | - } elseif (!isset($this->attendance_data)) { |
|
299 | - $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
289 | + /** |
|
290 | + * @return array|bool |
|
291 | + */ |
|
292 | + private function get_attendance_data() |
|
293 | + { |
|
294 | + $tbl_name = $this->get_attendance_table(); |
|
295 | + $session_id = api_get_session_id(); |
|
296 | + if ($tbl_name == '') { |
|
297 | + return false; |
|
298 | + } elseif (!isset($this->attendance_data)) { |
|
299 | + $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
300 | 300 | WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' '; |
301 | - $query = Database::query($sql); |
|
302 | - $this->attendance_data = Database::fetch_array($query); |
|
303 | - } |
|
304 | - return $this->attendance_data; |
|
305 | - } |
|
301 | + $query = Database::query($sql); |
|
302 | + $this->attendance_data = Database::fetch_array($query); |
|
303 | + } |
|
304 | + return $this->attendance_data; |
|
305 | + } |
|
306 | 306 | |
307 | - /** |
|
308 | - * @return string |
|
309 | - */ |
|
310 | - public function get_icon_name() |
|
311 | - { |
|
312 | - return 'attendance'; |
|
313 | - } |
|
307 | + /** |
|
308 | + * @return string |
|
309 | + */ |
|
310 | + public function get_icon_name() |
|
311 | + { |
|
312 | + return 'attendance'; |
|
313 | + } |
|
314 | 314 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } |
165 | 165 | } else { |
166 | 166 | // all students -> get average |
167 | - $students = array(); // user list, needed to make sure we only |
|
167 | + $students = array(); // user list, needed to make sure we only |
|
168 | 168 | // take first attempts into account |
169 | 169 | $rescount = 0; |
170 | 170 | $sum = 0; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $this->get_attendance_data(); |
240 | 240 | $attendance_title = isset($this->attendance_data['name']) ? $this->attendance_data['name'] : ''; |
241 | 241 | $attendance_qualify_title = isset($this->attendance_data['attendance_qualify_title']) ? $this->attendance_data['attendance_qualify_title'] : ''; |
242 | - if ( isset($attendance_qualify_title) && $attendance_qualify_title != '') { |
|
242 | + if (isset($attendance_qualify_title) && $attendance_qualify_title != '') { |
|
243 | 243 | return $this->attendance_data['attendance_qualify_title']; |
244 | 244 | } else { |
245 | 245 | return $attendance_title; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
280 | 280 | WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' '; |
281 | 281 | $result = Database::query($sql); |
282 | - $row = Database::fetch_array($result,'ASSOC'); |
|
282 | + $row = Database::fetch_array($result, 'ASSOC'); |
|
283 | 283 | $attendance_id = $row['id']; |
284 | 284 | $url = api_get_path(WEB_PATH).'main/attendance/index.php?action=attendance_sheet_list&gradebook=view&attendance_id='.$attendance_id.'&session_id='.$session_id.'&cidReq='.$this->get_course_code(); |
285 | 285 |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | $eval = $this->get_evaluation(); |
48 | 48 | // course/platform admin can go to the view_results page |
49 | 49 | if (api_is_allowed_to_edit()) { |
50 | - return 'gradebook_view_result.php?' . api_get_cidreq() . '&selecteval=' . $eval->get_id(); |
|
50 | + return 'gradebook_view_result.php?'.api_get_cidreq().'&selecteval='.$eval->get_id(); |
|
51 | 51 | } // students can go to the statistics page (if custom display enabled) |
52 | 52 | elseif (ScoreDisplay :: instance()->is_custom()) { |
53 | - return 'gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . $eval->get_id(); |
|
53 | + return 'gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.$eval->get_id(); |
|
54 | 54 | } else { |
55 | 55 | return null; |
56 | 56 | } |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | $eval = new Evaluation(); |
177 | 177 | $eval->set_category_id(-1); |
178 | 178 | $eval->set_date(api_get_utc_datetime()); // these values will be changed |
179 | - $eval->set_weight(0); // when the link setter |
|
180 | - $eval->set_visible(0); // is called |
|
179 | + $eval->set_weight(0); // when the link setter |
|
180 | + $eval->set_visible(0); // is called |
|
181 | 181 | $eval->set_id(-1); // a 'real' id will be set when eval is added to db |
182 | 182 | $eval->set_user_id($this->get_user_id()); |
183 | 183 | $eval->set_course_code($this->get_course_code()); |
@@ -117,6 +117,9 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | + /** |
|
121 | + * @param string $name |
|
122 | + */ |
|
120 | 123 | public function set_name($name) |
121 | 124 | { |
122 | 125 | if ($this->is_valid_link()) { |
@@ -124,6 +127,9 @@ discard block |
||
124 | 127 | } |
125 | 128 | } |
126 | 129 | |
130 | + /** |
|
131 | + * @param string $description |
|
132 | + */ |
|
127 | 133 | public function set_description($description) |
128 | 134 | { |
129 | 135 | if ($this->is_valid_link()) { |
@@ -131,6 +137,9 @@ discard block |
||
131 | 137 | } |
132 | 138 | } |
133 | 139 | |
140 | + /** |
|
141 | + * @param integer $max |
|
142 | + */ |
|
134 | 143 | public function set_max($max) |
135 | 144 | { |
136 | 145 | if ($this->is_valid_link()) { |
@@ -8,94 +8,94 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class SurveyLink extends AbstractLink |
10 | 10 | { |
11 | - private $survey_table = null; |
|
12 | - |
|
13 | - /** |
|
14 | - * Constructor |
|
15 | - */ |
|
16 | - public function __construct() |
|
17 | - { |
|
18 | - parent::__construct(); |
|
19 | - $this->set_type(LINK_SURVEY); |
|
20 | - } |
|
21 | - |
|
22 | - public function get_name() |
|
23 | - { |
|
24 | - $this->get_survey_data(); |
|
25 | - return $this->survey_data['code'].': '.self::html_to_text($this->survey_data['title']); |
|
26 | - } |
|
27 | - |
|
28 | - public function get_description() |
|
29 | - { |
|
30 | - $this->get_survey_data(); |
|
31 | - return $this->survey_data['subtitle']; |
|
32 | - } |
|
33 | - |
|
34 | - public function get_type_name() |
|
35 | - { |
|
36 | - return get_lang('Survey'); |
|
37 | - } |
|
38 | - |
|
39 | - public function is_allowed_to_change_name() |
|
40 | - { |
|
41 | - return false; |
|
42 | - } |
|
43 | - |
|
44 | - public function needs_name_and_description() |
|
45 | - { |
|
46 | - return false; |
|
47 | - } |
|
48 | - |
|
49 | - public function needs_max() |
|
50 | - { |
|
51 | - return false; |
|
52 | - } |
|
53 | - |
|
54 | - public function needs_results() |
|
55 | - { |
|
56 | - return false; |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * Generates an array of all surveys available. |
|
61 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
62 | - */ |
|
63 | - public function get_all_links() |
|
64 | - { |
|
65 | - if (empty($this->course_code)) { |
|
66 | - die('Error in get_all_links() : course code not set'); |
|
67 | - } |
|
68 | - $tbl_survey = $this->get_survey_table(); |
|
69 | - $session_id = api_get_session_id(); |
|
70 | - $course_id = api_get_course_int_id(); |
|
71 | - $sql = 'SELECT survey_id, title, code FROM '.$tbl_survey.' |
|
11 | + private $survey_table = null; |
|
12 | + |
|
13 | + /** |
|
14 | + * Constructor |
|
15 | + */ |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + parent::__construct(); |
|
19 | + $this->set_type(LINK_SURVEY); |
|
20 | + } |
|
21 | + |
|
22 | + public function get_name() |
|
23 | + { |
|
24 | + $this->get_survey_data(); |
|
25 | + return $this->survey_data['code'].': '.self::html_to_text($this->survey_data['title']); |
|
26 | + } |
|
27 | + |
|
28 | + public function get_description() |
|
29 | + { |
|
30 | + $this->get_survey_data(); |
|
31 | + return $this->survey_data['subtitle']; |
|
32 | + } |
|
33 | + |
|
34 | + public function get_type_name() |
|
35 | + { |
|
36 | + return get_lang('Survey'); |
|
37 | + } |
|
38 | + |
|
39 | + public function is_allowed_to_change_name() |
|
40 | + { |
|
41 | + return false; |
|
42 | + } |
|
43 | + |
|
44 | + public function needs_name_and_description() |
|
45 | + { |
|
46 | + return false; |
|
47 | + } |
|
48 | + |
|
49 | + public function needs_max() |
|
50 | + { |
|
51 | + return false; |
|
52 | + } |
|
53 | + |
|
54 | + public function needs_results() |
|
55 | + { |
|
56 | + return false; |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * Generates an array of all surveys available. |
|
61 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
62 | + */ |
|
63 | + public function get_all_links() |
|
64 | + { |
|
65 | + if (empty($this->course_code)) { |
|
66 | + die('Error in get_all_links() : course code not set'); |
|
67 | + } |
|
68 | + $tbl_survey = $this->get_survey_table(); |
|
69 | + $session_id = api_get_session_id(); |
|
70 | + $course_id = api_get_course_int_id(); |
|
71 | + $sql = 'SELECT survey_id, title, code FROM '.$tbl_survey.' |
|
72 | 72 | WHERE c_id = '.$course_id.' AND session_id = '.intval($session_id).''; |
73 | - $result = Database::query($sql); |
|
74 | - while ($data = Database::fetch_array($result)) { |
|
75 | - $links[] = array( |
|
76 | - $data['survey_id'], |
|
77 | - api_trunc_str( |
|
78 | - $data['code'] . ': ' . self::html_to_text($data['title']), |
|
79 | - 80 |
|
80 | - ) |
|
81 | - ); |
|
82 | - } |
|
83 | - |
|
84 | - return isset($links) ? $links : null; |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Generates an array of surveys that a teacher hasn't created a link for. |
|
89 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
90 | - */ |
|
91 | - public function get_not_created_links() |
|
92 | - { |
|
93 | - if (empty($this->course_code)) { |
|
94 | - die('Error in get_not_created_links() : course code not set'); |
|
95 | - } |
|
96 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
97 | - |
|
98 | - $sql = 'SELECT survey_id, title, code |
|
73 | + $result = Database::query($sql); |
|
74 | + while ($data = Database::fetch_array($result)) { |
|
75 | + $links[] = array( |
|
76 | + $data['survey_id'], |
|
77 | + api_trunc_str( |
|
78 | + $data['code'] . ': ' . self::html_to_text($data['title']), |
|
79 | + 80 |
|
80 | + ) |
|
81 | + ); |
|
82 | + } |
|
83 | + |
|
84 | + return isset($links) ? $links : null; |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Generates an array of surveys that a teacher hasn't created a link for. |
|
89 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
90 | + */ |
|
91 | + public function get_not_created_links() |
|
92 | + { |
|
93 | + if (empty($this->course_code)) { |
|
94 | + die('Error in get_not_created_links() : course code not set'); |
|
95 | + } |
|
96 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
97 | + |
|
98 | + $sql = 'SELECT survey_id, title, code |
|
99 | 99 | FROM '.$this->get_survey_table().' AS srv |
100 | 100 | WHERE survey_id NOT IN |
101 | 101 | ( |
@@ -106,28 +106,28 @@ discard block |
||
106 | 106 | ) |
107 | 107 | AND srv.session_id = '.api_get_session_id(); |
108 | 108 | |
109 | - $result = Database::query($sql); |
|
110 | - |
|
111 | - $links = array(); |
|
112 | - while ($data = Database::fetch_array($result)) { |
|
113 | - $links[] = array( |
|
114 | - $data['survey_id'], |
|
115 | - api_trunc_str($data['code'].': '.self::html_to_text($data['title']), 80) |
|
116 | - ); |
|
117 | - } |
|
118 | - return $links; |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Has anyone done this survey yet? |
|
123 | - */ |
|
124 | - public function has_results($stud_id=null) |
|
125 | - { |
|
126 | - $ref_id = intval($this->get_ref_id()); |
|
127 | - $session_id = api_get_session_id(); |
|
128 | - $tbl_survey = Database::get_course_table(TABLE_SURVEY); |
|
129 | - $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); |
|
130 | - $sql = "SELECT |
|
109 | + $result = Database::query($sql); |
|
110 | + |
|
111 | + $links = array(); |
|
112 | + while ($data = Database::fetch_array($result)) { |
|
113 | + $links[] = array( |
|
114 | + $data['survey_id'], |
|
115 | + api_trunc_str($data['code'].': '.self::html_to_text($data['title']), 80) |
|
116 | + ); |
|
117 | + } |
|
118 | + return $links; |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Has anyone done this survey yet? |
|
123 | + */ |
|
124 | + public function has_results($stud_id=null) |
|
125 | + { |
|
126 | + $ref_id = intval($this->get_ref_id()); |
|
127 | + $session_id = api_get_session_id(); |
|
128 | + $tbl_survey = Database::get_course_table(TABLE_SURVEY); |
|
129 | + $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); |
|
130 | + $sql = "SELECT |
|
131 | 131 | COUNT(i.answered) |
132 | 132 | FROM $tbl_survey AS s |
133 | 133 | JOIN $tbl_survey_invitation AS i ON s.code = i.survey_code |
@@ -137,30 +137,30 @@ discard block |
||
137 | 137 | s.survey_id = $ref_id AND |
138 | 138 | i.session_id = $session_id"; |
139 | 139 | |
140 | - $sql_result = Database::query($sql); |
|
141 | - $data = Database::fetch_array($sql_result); |
|
140 | + $sql_result = Database::query($sql); |
|
141 | + $data = Database::fetch_array($sql_result); |
|
142 | 142 | |
143 | - return ($data[0] != 0); |
|
144 | - } |
|
143 | + return ($data[0] != 0); |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * @param int $stud_id |
|
148 | - * @return array|null |
|
149 | - */ |
|
150 | - public function calc_score($stud_id = null, $type = null) |
|
151 | - { |
|
152 | - // Note: Max score is assumed to be always 1 for surveys, |
|
153 | - // only student's participation is to be taken into account. |
|
154 | - $max_score = 1; |
|
146 | + /** |
|
147 | + * @param int $stud_id |
|
148 | + * @return array|null |
|
149 | + */ |
|
150 | + public function calc_score($stud_id = null, $type = null) |
|
151 | + { |
|
152 | + // Note: Max score is assumed to be always 1 for surveys, |
|
153 | + // only student's participation is to be taken into account. |
|
154 | + $max_score = 1; |
|
155 | 155 | |
156 | - $ref_id = intval($this->get_ref_id()); |
|
157 | - $session_id = api_get_session_id(); |
|
158 | - $tbl_survey = Database::get_course_table(TABLE_SURVEY); |
|
159 | - $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); |
|
156 | + $ref_id = intval($this->get_ref_id()); |
|
157 | + $session_id = api_get_session_id(); |
|
158 | + $tbl_survey = Database::get_course_table(TABLE_SURVEY); |
|
159 | + $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); |
|
160 | 160 | |
161 | - $get_individual_score = !is_null($stud_id); |
|
161 | + $get_individual_score = !is_null($stud_id); |
|
162 | 162 | |
163 | - $sql = "SELECT i.answered |
|
163 | + $sql = "SELECT i.answered |
|
164 | 164 | FROM $tbl_survey AS s |
165 | 165 | JOIN $tbl_survey_invitation AS i |
166 | 166 | ON s.code = i.survey_code |
@@ -171,131 +171,131 @@ discard block |
||
171 | 171 | i.session_id = $session_id |
172 | 172 | "; |
173 | 173 | |
174 | - if ($get_individual_score) { |
|
175 | - $sql .= ' AND i.user = '.intval($stud_id); |
|
176 | - } |
|
177 | - |
|
178 | - $sql_result = Database::query($sql); |
|
179 | - |
|
180 | - if ($get_individual_score) { |
|
181 | - // for 1 student |
|
182 | - if ($data = Database::fetch_array($sql_result)) { |
|
183 | - return array($data['answered'] ? $max_score : 0, $max_score); |
|
184 | - } |
|
185 | - return array(0, $max_score); |
|
186 | - } else { |
|
187 | - // for all the students -> get average |
|
188 | - $rescount = 0; |
|
189 | - $sum = 0; |
|
190 | - $bestResult = 0; |
|
191 | - $weight = 0; |
|
192 | - while ($data = Database::fetch_array($sql_result)) { |
|
193 | - $sum += $data['answered'] ? $max_score : 0; |
|
194 | - $rescount++; |
|
195 | - if ($data['answered'] > $bestResult) { |
|
196 | - $bestResult = $data['answered']; |
|
197 | - $weight = $assignment['qualification']; |
|
198 | - } |
|
199 | - } |
|
200 | - $sum = $sum / $max_score; |
|
201 | - |
|
202 | - if ($rescount == 0) { |
|
203 | - return null; |
|
204 | - } |
|
205 | - |
|
206 | - switch ($type) { |
|
207 | - case 'best': |
|
208 | - return array($bestResult, $rescount); |
|
209 | - break; |
|
210 | - case 'average': |
|
211 | - return array($sum, $rescount); |
|
212 | - break; |
|
213 | - case 'ranking': |
|
214 | - return null; |
|
215 | - break; |
|
216 | - default: |
|
217 | - return array($sum, $rescount); |
|
218 | - break; |
|
219 | - } |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - /** |
|
224 | - * Lazy load function to get the database table of the surveys |
|
225 | - */ |
|
226 | - private function get_survey_table() |
|
227 | - { |
|
228 | - $this->survey_table = Database :: get_course_table(TABLE_SURVEY); |
|
229 | - return $this->survey_table; |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * Check if this still links to a survey |
|
234 | - */ |
|
235 | - public function is_valid_link() |
|
236 | - { |
|
237 | - $session_id = api_get_session_id(); |
|
238 | - $sql = 'SELECT count(survey_id) FROM '.$this->get_survey_table().' |
|
174 | + if ($get_individual_score) { |
|
175 | + $sql .= ' AND i.user = '.intval($stud_id); |
|
176 | + } |
|
177 | + |
|
178 | + $sql_result = Database::query($sql); |
|
179 | + |
|
180 | + if ($get_individual_score) { |
|
181 | + // for 1 student |
|
182 | + if ($data = Database::fetch_array($sql_result)) { |
|
183 | + return array($data['answered'] ? $max_score : 0, $max_score); |
|
184 | + } |
|
185 | + return array(0, $max_score); |
|
186 | + } else { |
|
187 | + // for all the students -> get average |
|
188 | + $rescount = 0; |
|
189 | + $sum = 0; |
|
190 | + $bestResult = 0; |
|
191 | + $weight = 0; |
|
192 | + while ($data = Database::fetch_array($sql_result)) { |
|
193 | + $sum += $data['answered'] ? $max_score : 0; |
|
194 | + $rescount++; |
|
195 | + if ($data['answered'] > $bestResult) { |
|
196 | + $bestResult = $data['answered']; |
|
197 | + $weight = $assignment['qualification']; |
|
198 | + } |
|
199 | + } |
|
200 | + $sum = $sum / $max_score; |
|
201 | + |
|
202 | + if ($rescount == 0) { |
|
203 | + return null; |
|
204 | + } |
|
205 | + |
|
206 | + switch ($type) { |
|
207 | + case 'best': |
|
208 | + return array($bestResult, $rescount); |
|
209 | + break; |
|
210 | + case 'average': |
|
211 | + return array($sum, $rescount); |
|
212 | + break; |
|
213 | + case 'ranking': |
|
214 | + return null; |
|
215 | + break; |
|
216 | + default: |
|
217 | + return array($sum, $rescount); |
|
218 | + break; |
|
219 | + } |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * Lazy load function to get the database table of the surveys |
|
225 | + */ |
|
226 | + private function get_survey_table() |
|
227 | + { |
|
228 | + $this->survey_table = Database :: get_course_table(TABLE_SURVEY); |
|
229 | + return $this->survey_table; |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * Check if this still links to a survey |
|
234 | + */ |
|
235 | + public function is_valid_link() |
|
236 | + { |
|
237 | + $session_id = api_get_session_id(); |
|
238 | + $sql = 'SELECT count(survey_id) FROM '.$this->get_survey_table().' |
|
239 | 239 | WHERE |
240 | 240 | c_id = '.$this->course_id.' AND |
241 | 241 | survey_id = '.intval($this->get_ref_id()).' AND |
242 | 242 | session_id='.intval($session_id).''; |
243 | - $result = Database::query($sql); |
|
244 | - $number = Database::fetch_row($result); |
|
245 | - return ($number[0] != 0); |
|
246 | - } |
|
247 | - |
|
248 | - public function get_test_id() |
|
249 | - { |
|
250 | - return 'DEBUG:ID'; |
|
251 | - } |
|
252 | - |
|
253 | - public function get_link() |
|
254 | - { |
|
255 | - if (api_is_allowed_to_edit()) { // Let students make access only through "Surveys" tool. |
|
256 | - $tbl_name = $this->get_survey_table(); |
|
257 | - $session_id = api_get_session_id(); |
|
258 | - if ($tbl_name != '') { |
|
259 | - $sql = 'SELECT survey_id FROM '.$this->get_survey_table().' |
|
243 | + $result = Database::query($sql); |
|
244 | + $number = Database::fetch_row($result); |
|
245 | + return ($number[0] != 0); |
|
246 | + } |
|
247 | + |
|
248 | + public function get_test_id() |
|
249 | + { |
|
250 | + return 'DEBUG:ID'; |
|
251 | + } |
|
252 | + |
|
253 | + public function get_link() |
|
254 | + { |
|
255 | + if (api_is_allowed_to_edit()) { // Let students make access only through "Surveys" tool. |
|
256 | + $tbl_name = $this->get_survey_table(); |
|
257 | + $session_id = api_get_session_id(); |
|
258 | + if ($tbl_name != '') { |
|
259 | + $sql = 'SELECT survey_id FROM '.$this->get_survey_table().' |
|
260 | 260 | WHERE |
261 | 261 | c_id = '.$this->course_id.' AND |
262 | 262 | survey_id = '.intval($this->get_ref_id()).' AND |
263 | 263 | session_id = '.intval($session_id).' '; |
264 | - $result = Database::query($sql); |
|
265 | - $row = Database::fetch_array($result, 'ASSOC'); |
|
266 | - $survey_id = $row['survey_id']; |
|
267 | - return api_get_path(WEB_PATH).'main/survey/reporting.php?cidReq='.$this->get_course_code().'&survey_id='.$survey_id; |
|
268 | - } |
|
269 | - } |
|
270 | - return null; |
|
271 | - } |
|
272 | - |
|
273 | - private function get_survey_data() |
|
274 | - { |
|
275 | - $tbl_name = $this->get_survey_table(); |
|
276 | - $session_id = api_get_session_id(); |
|
277 | - if ($tbl_name == '') { |
|
278 | - return false; |
|
279 | - } elseif (!isset($this->survey_data)) { |
|
280 | - $sql = 'SELECT * FROM '.$tbl_name.' |
|
264 | + $result = Database::query($sql); |
|
265 | + $row = Database::fetch_array($result, 'ASSOC'); |
|
266 | + $survey_id = $row['survey_id']; |
|
267 | + return api_get_path(WEB_PATH).'main/survey/reporting.php?cidReq='.$this->get_course_code().'&survey_id='.$survey_id; |
|
268 | + } |
|
269 | + } |
|
270 | + return null; |
|
271 | + } |
|
272 | + |
|
273 | + private function get_survey_data() |
|
274 | + { |
|
275 | + $tbl_name = $this->get_survey_table(); |
|
276 | + $session_id = api_get_session_id(); |
|
277 | + if ($tbl_name == '') { |
|
278 | + return false; |
|
279 | + } elseif (!isset($this->survey_data)) { |
|
280 | + $sql = 'SELECT * FROM '.$tbl_name.' |
|
281 | 281 | WHERE |
282 | 282 | c_id = '.$this->course_id.' AND |
283 | 283 | survey_id = '.intval($this->get_ref_id()).' AND |
284 | 284 | session_id='.intval($session_id).''; |
285 | - $query = Database::query($sql); |
|
286 | - $this->survey_data = Database::fetch_array($query); |
|
287 | - } |
|
288 | - return $this->survey_data; |
|
289 | - } |
|
290 | - |
|
291 | - public function get_icon_name() |
|
292 | - { |
|
293 | - return 'survey'; |
|
294 | - } |
|
295 | - |
|
296 | - private static function html_to_text($string) |
|
297 | - { |
|
298 | - return strip_tags($string); |
|
299 | - //return trim(api_html_entity_decode(strip_tags(str_ireplace(array('<p>', '</p>', '<br />', '<br/>', '<br>'), array('', ' ', ' ', ' ', ' '), $string)), ENT_QUOTES)); |
|
300 | - } |
|
285 | + $query = Database::query($sql); |
|
286 | + $this->survey_data = Database::fetch_array($query); |
|
287 | + } |
|
288 | + return $this->survey_data; |
|
289 | + } |
|
290 | + |
|
291 | + public function get_icon_name() |
|
292 | + { |
|
293 | + return 'survey'; |
|
294 | + } |
|
295 | + |
|
296 | + private static function html_to_text($string) |
|
297 | + { |
|
298 | + return strip_tags($string); |
|
299 | + //return trim(api_html_entity_decode(strip_tags(str_ireplace(array('<p>', '</p>', '<br />', '<br/>', '<br>'), array('', ' ', ' ', ' ', ' '), $string)), ENT_QUOTES)); |
|
300 | + } |
|
301 | 301 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $links[] = array( |
76 | 76 | $data['survey_id'], |
77 | 77 | api_trunc_str( |
78 | - $data['code'] . ': ' . self::html_to_text($data['title']), |
|
78 | + $data['code'].': '.self::html_to_text($data['title']), |
|
79 | 79 | 80 |
80 | 80 | ) |
81 | 81 | ); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | /** |
122 | 122 | * Has anyone done this survey yet? |
123 | 123 | */ |
124 | - public function has_results($stud_id=null) |
|
124 | + public function has_results($stud_id = null) |
|
125 | 125 | { |
126 | 126 | $ref_id = intval($this->get_ref_id()); |
127 | 127 | $session_id = api_get_session_id(); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param string $name_mask search string |
59 | 59 | * @return array link objects matching the search criterium |
60 | 60 | */ |
61 | - public function find_links($name_mask,$selectcat) |
|
61 | + public function find_links($name_mask, $selectcat) |
|
62 | 62 | { |
63 | 63 | return AbstractLink::find_links($name_mask, $selectcat); |
64 | 64 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | public static function get_all_types() |
99 | 99 | { |
100 | 100 | //LINK_DROPBOX, |
101 | - return array ( |
|
101 | + return array( |
|
102 | 102 | LINK_EXERCISE, |
103 | 103 | //LINK_DROPBOX, |
104 | 104 | LINK_HOTPOTATOES, |
@@ -93,7 +93,7 @@ |
||
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Return an array of all known link types |
96 | - * @return array |
|
96 | + * @return integer[] |
|
97 | 97 | */ |
98 | 98 | public static function get_all_types() |
99 | 99 | { |
@@ -8,102 +8,102 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class StudentPublicationLink extends AbstractLink |
10 | 10 | { |
11 | - private $studpub_table = null; |
|
12 | - private $itemprop_table = null; |
|
13 | - |
|
14 | - /** |
|
15 | - * Constructor |
|
16 | - */ |
|
17 | - public function __construct() |
|
18 | - { |
|
19 | - parent::__construct(); |
|
20 | - $this->set_type(LINK_STUDENTPUBLICATION); |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * |
|
25 | - * Returns the URL of a document |
|
26 | - * This function is loaded when using a gradebook as a tab (gradebook = -1) |
|
27 | - * see issue #2705 |
|
28 | - * |
|
29 | - */ |
|
30 | - public function get_view_url($stud_id) |
|
31 | - { |
|
32 | - // find a file uploaded by the given student, |
|
33 | - // with the same title as the evaluation name |
|
34 | - |
|
35 | - $eval = $this->get_evaluation(); |
|
36 | - $stud_id = intval($stud_id); |
|
37 | - |
|
38 | - $sql = 'SELECT pub.url |
|
11 | + private $studpub_table = null; |
|
12 | + private $itemprop_table = null; |
|
13 | + |
|
14 | + /** |
|
15 | + * Constructor |
|
16 | + */ |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + parent::__construct(); |
|
20 | + $this->set_type(LINK_STUDENTPUBLICATION); |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * |
|
25 | + * Returns the URL of a document |
|
26 | + * This function is loaded when using a gradebook as a tab (gradebook = -1) |
|
27 | + * see issue #2705 |
|
28 | + * |
|
29 | + */ |
|
30 | + public function get_view_url($stud_id) |
|
31 | + { |
|
32 | + // find a file uploaded by the given student, |
|
33 | + // with the same title as the evaluation name |
|
34 | + |
|
35 | + $eval = $this->get_evaluation(); |
|
36 | + $stud_id = intval($stud_id); |
|
37 | + |
|
38 | + $sql = 'SELECT pub.url |
|
39 | 39 | FROM '.$this->get_itemprop_table().' prop, '.$this->get_studpub_table().' pub' |
40 | - ." WHERE |
|
40 | + ." WHERE |
|
41 | 41 | prop.c_id = ".$this->course_id." AND |
42 | 42 | pub.c_id = ".$this->course_id." AND |
43 | 43 | prop.tool = 'work'" |
44 | - .' AND prop.insert_user_id = '.$stud_id |
|
45 | - .' AND prop.ref = pub.id' |
|
46 | - ." AND pub.title = '".Database::escape_string($eval->get_name())."' AND pub.session_id=".api_get_session_id().""; |
|
47 | - |
|
48 | - $result = Database::query($sql); |
|
49 | - if ($fileurl = Database::fetch_row($result)) { |
|
50 | - return null; |
|
51 | - } else { |
|
52 | - return null; |
|
53 | - } |
|
54 | - } |
|
55 | - |
|
56 | - public function get_type_name() |
|
57 | - { |
|
58 | - return get_lang('Works'); |
|
59 | - } |
|
60 | - |
|
61 | - public function is_allowed_to_change_name() |
|
62 | - { |
|
63 | - return false; |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Generate an array of exercises that a teacher hasn't created a link for. |
|
68 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
69 | - */ |
|
70 | - public function get_not_created_links() |
|
71 | - { |
|
72 | - return false; |
|
73 | - if (empty($this->course_code)) { |
|
74 | - die('Error in get_not_created_links() : course code not set'); |
|
75 | - } |
|
76 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
77 | - |
|
78 | - $sql = 'SELECT id, url from '.$this->get_studpub_table() |
|
79 | - .' pup WHERE c_id = '.$this->course_id.' AND has_properties != '."''".' AND id NOT IN' |
|
80 | - .' (SELECT ref_id FROM '.$tbl_grade_links |
|
81 | - .' WHERE type = '.LINK_STUDENTPUBLICATION |
|
82 | - ." AND course_code = '".Database::escape_string($this->get_course_code())."'" |
|
83 | - .') AND pub.session_id='.api_get_session_id().''; |
|
84 | - |
|
85 | - $result = Database::query($sql); |
|
86 | - |
|
87 | - $cats=array(); |
|
88 | - while ($data=Database::fetch_array($result)) { |
|
89 | - $cats[] = array ($data['id'], $data['url']); |
|
90 | - } |
|
91 | - return $cats; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Generate an array of all exercises available. |
|
96 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
97 | - */ |
|
98 | - public function get_all_links() |
|
99 | - { |
|
100 | - if (empty($this->course_code)) { |
|
101 | - die('Error in get_not_created_links() : course code not set'); |
|
102 | - } |
|
103 | - $tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
104 | - |
|
105 | - $session_id = api_get_session_id(); |
|
106 | - /* |
|
44 | + .' AND prop.insert_user_id = '.$stud_id |
|
45 | + .' AND prop.ref = pub.id' |
|
46 | + ." AND pub.title = '".Database::escape_string($eval->get_name())."' AND pub.session_id=".api_get_session_id().""; |
|
47 | + |
|
48 | + $result = Database::query($sql); |
|
49 | + if ($fileurl = Database::fetch_row($result)) { |
|
50 | + return null; |
|
51 | + } else { |
|
52 | + return null; |
|
53 | + } |
|
54 | + } |
|
55 | + |
|
56 | + public function get_type_name() |
|
57 | + { |
|
58 | + return get_lang('Works'); |
|
59 | + } |
|
60 | + |
|
61 | + public function is_allowed_to_change_name() |
|
62 | + { |
|
63 | + return false; |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Generate an array of exercises that a teacher hasn't created a link for. |
|
68 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
69 | + */ |
|
70 | + public function get_not_created_links() |
|
71 | + { |
|
72 | + return false; |
|
73 | + if (empty($this->course_code)) { |
|
74 | + die('Error in get_not_created_links() : course code not set'); |
|
75 | + } |
|
76 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
77 | + |
|
78 | + $sql = 'SELECT id, url from '.$this->get_studpub_table() |
|
79 | + .' pup WHERE c_id = '.$this->course_id.' AND has_properties != '."''".' AND id NOT IN' |
|
80 | + .' (SELECT ref_id FROM '.$tbl_grade_links |
|
81 | + .' WHERE type = '.LINK_STUDENTPUBLICATION |
|
82 | + ." AND course_code = '".Database::escape_string($this->get_course_code())."'" |
|
83 | + .') AND pub.session_id='.api_get_session_id().''; |
|
84 | + |
|
85 | + $result = Database::query($sql); |
|
86 | + |
|
87 | + $cats=array(); |
|
88 | + while ($data=Database::fetch_array($result)) { |
|
89 | + $cats[] = array ($data['id'], $data['url']); |
|
90 | + } |
|
91 | + return $cats; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Generate an array of all exercises available. |
|
96 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
97 | + */ |
|
98 | + public function get_all_links() |
|
99 | + { |
|
100 | + if (empty($this->course_code)) { |
|
101 | + die('Error in get_not_created_links() : course code not set'); |
|
102 | + } |
|
103 | + $tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
104 | + |
|
105 | + $session_id = api_get_session_id(); |
|
106 | + /* |
|
107 | 107 | if (empty($session_id)) { |
108 | 108 | $session_condition = api_get_session_condition(0, true); |
109 | 109 | } else { |
@@ -112,68 +112,68 @@ discard block |
||
112 | 112 | $sql = "SELECT id, url, title FROM $tbl_grade_links |
113 | 113 | WHERE c_id = {$this->course_id} AND filetype='folder' AND active = 1 $session_condition ";*/ |
114 | 114 | |
115 | - //Only show works from the session |
|
116 | - //AND has_properties != '' |
|
117 | - $sql = "SELECT id, url, title FROM $tbl_grade_links |
|
115 | + //Only show works from the session |
|
116 | + //AND has_properties != '' |
|
117 | + $sql = "SELECT id, url, title FROM $tbl_grade_links |
|
118 | 118 | WHERE |
119 | 119 | c_id = {$this->course_id} AND |
120 | 120 | active = 1 AND |
121 | 121 | filetype='folder' AND |
122 | 122 | session_id = ".api_get_session_id().""; |
123 | 123 | |
124 | - $result = Database::query($sql); |
|
125 | - while ($data = Database::fetch_array($result)) { |
|
126 | - $work_name = $data['title']; |
|
127 | - if (empty($work_name)) { |
|
128 | - $work_name = basename($data['url']); |
|
129 | - } |
|
130 | - $cats[] = array ($data['id'], $work_name); |
|
131 | - } |
|
132 | - $cats=isset($cats) ? $cats : array(); |
|
133 | - return $cats; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Has anyone done this exercise yet ? |
|
138 | - */ |
|
139 | - public function has_results() |
|
140 | - { |
|
141 | - $tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
142 | - $sql = 'SELECT count(*) AS number FROM '.$tbl_grade_links." |
|
124 | + $result = Database::query($sql); |
|
125 | + while ($data = Database::fetch_array($result)) { |
|
126 | + $work_name = $data['title']; |
|
127 | + if (empty($work_name)) { |
|
128 | + $work_name = basename($data['url']); |
|
129 | + } |
|
130 | + $cats[] = array ($data['id'], $work_name); |
|
131 | + } |
|
132 | + $cats=isset($cats) ? $cats : array(); |
|
133 | + return $cats; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Has anyone done this exercise yet ? |
|
138 | + */ |
|
139 | + public function has_results() |
|
140 | + { |
|
141 | + $tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
142 | + $sql = 'SELECT count(*) AS number FROM '.$tbl_grade_links." |
|
143 | 143 | WHERE c_id = {$this->course_id} AND |
144 | 144 | parent_id = '".intval($this->get_ref_id())."' AND |
145 | 145 | session_id =".api_get_session_id().""; |
146 | - $result = Database::query($sql); |
|
147 | - $number = Database::fetch_row($result); |
|
148 | - return ($number[0] != 0); |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * @param null $stud_id |
|
153 | - * @return array|null |
|
154 | - */ |
|
155 | - public function calc_score($stud_id = null, $type = null) |
|
156 | - { |
|
157 | - $stud_id = intval($stud_id); |
|
158 | - $table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); |
|
159 | - $sql = 'SELECT * FROM '.$table." |
|
146 | + $result = Database::query($sql); |
|
147 | + $number = Database::fetch_row($result); |
|
148 | + return ($number[0] != 0); |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * @param null $stud_id |
|
153 | + * @return array|null |
|
154 | + */ |
|
155 | + public function calc_score($stud_id = null, $type = null) |
|
156 | + { |
|
157 | + $stud_id = intval($stud_id); |
|
158 | + $table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); |
|
159 | + $sql = 'SELECT * FROM '.$table." |
|
160 | 160 | WHERE |
161 | 161 | c_id = {$this->course_id} AND |
162 | 162 | id = '".intval($this->get_ref_id())."' AND |
163 | 163 | session_id = ".api_get_session_id()." |
164 | 164 | " |
165 | - ; |
|
165 | + ; |
|
166 | 166 | |
167 | - $query = Database::query($sql); |
|
168 | - $assignment = Database::fetch_array($query); |
|
167 | + $query = Database::query($sql); |
|
168 | + $assignment = Database::fetch_array($query); |
|
169 | 169 | |
170 | - if (count($assignment) == 0) { |
|
171 | - $parentId = '0'; |
|
172 | - } else { |
|
173 | - $parentId = $assignment['id']; |
|
174 | - } |
|
170 | + if (count($assignment) == 0) { |
|
171 | + $parentId = '0'; |
|
172 | + } else { |
|
173 | + $parentId = $assignment['id']; |
|
174 | + } |
|
175 | 175 | |
176 | - $sql = 'SELECT * FROM '.$table.' |
|
176 | + $sql = 'SELECT * FROM '.$table.' |
|
177 | 177 | WHERE |
178 | 178 | c_id = '.$this->course_id.' AND |
179 | 179 | active = 1 AND |
@@ -181,190 +181,190 @@ discard block |
||
181 | 181 | session_id = '.api_get_session_id() .' AND |
182 | 182 | qualificator_id <> 0 |
183 | 183 | '; |
184 | - if (!empty($stud_id)) { |
|
185 | - $sql .= " AND user_id = $stud_id "; |
|
186 | - } |
|
187 | - |
|
188 | - $order = api_get_setting('student_publication_to_take_in_gradebook'); |
|
189 | - |
|
190 | - switch ($order) { |
|
191 | - case 'last': |
|
192 | - // latest attempt |
|
193 | - $sql .= ' ORDER BY sent_date DESC'; |
|
194 | - break; |
|
195 | - case 'first': |
|
196 | - default: |
|
197 | - // first attempt |
|
198 | - $sql .= ' ORDER BY id'; |
|
199 | - break; |
|
200 | - } |
|
201 | - |
|
202 | - $scores = Database::query($sql); |
|
203 | - |
|
204 | - // for 1 student |
|
205 | - if (!empty($stud_id)) { |
|
206 | - if ($data = Database::fetch_array($scores)) { |
|
207 | - return array( |
|
208 | - $data['qualification'], |
|
209 | - $assignment['qualification'] |
|
210 | - ); |
|
211 | - } else { |
|
212 | - return ''; |
|
213 | - } |
|
214 | - } else { |
|
215 | - $students = array(); // user list, needed to make sure we only |
|
216 | - // take first attempts into account |
|
217 | - $rescount = 0; |
|
218 | - $sum = 0; |
|
219 | - $bestResult = 0; |
|
220 | - $weight = 0; |
|
221 | - $sumResult = 0; |
|
222 | - $myResult = 0; |
|
223 | - |
|
224 | - while ($data = Database::fetch_array($scores)) { |
|
225 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
226 | - if ($assignment['qualification'] != 0) { |
|
227 | - $students[$data['user_id']] = $data['qualification']; |
|
228 | - $rescount++; |
|
229 | - $sum += $data['qualification'] / $assignment['qualification']; |
|
230 | - $sumResult += $data['qualification']; |
|
231 | - |
|
232 | - if ($data['qualification'] > $bestResult) { |
|
233 | - $bestResult = $data['qualification']; |
|
234 | - } |
|
235 | - $weight = $assignment['qualification']; |
|
236 | - } |
|
237 | - } |
|
238 | - } |
|
239 | - |
|
240 | - if ($rescount == 0) { |
|
241 | - return null; |
|
242 | - } else { |
|
243 | - switch ($type) { |
|
244 | - case 'best': |
|
245 | - return array($bestResult, $weight); |
|
246 | - break; |
|
247 | - case 'average': |
|
248 | - return array($sumResult/$rescount, $weight); |
|
249 | - break; |
|
250 | - case 'ranking': |
|
251 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
252 | - break; |
|
253 | - default: |
|
254 | - return array($sum, $rescount); |
|
255 | - break; |
|
256 | - } |
|
257 | - } |
|
258 | - } |
|
259 | - } |
|
260 | - |
|
261 | - /** |
|
262 | - * Lazy load function to get the database table of the student publications |
|
263 | - */ |
|
264 | - private function get_studpub_table() |
|
265 | - { |
|
266 | - return $this->studpub_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * Lazy load function to get the database table of the item properties |
|
271 | - */ |
|
272 | - private function get_itemprop_table() |
|
273 | - { |
|
274 | - return $this->itemprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
275 | - } |
|
276 | - |
|
277 | - public function needs_name_and_description() |
|
278 | - { |
|
279 | - return false; |
|
280 | - } |
|
281 | - |
|
282 | - public function get_name() |
|
283 | - { |
|
284 | - $this->get_exercise_data(); |
|
285 | - return (isset($this->exercise_data['title']) && !empty($this->exercise_data['title'])) ? $this->exercise_data['title'] : get_lang('Untitled'); |
|
286 | - } |
|
287 | - |
|
288 | - public function get_description() |
|
289 | - { |
|
290 | - $this->get_exercise_data(); |
|
291 | - return isset($this->exercise_data['description']) ? $this->exercise_data['description'] : null; |
|
292 | - } |
|
293 | - |
|
294 | - public function get_test_id() |
|
295 | - { |
|
296 | - return 'DEBUG:ID'; |
|
297 | - } |
|
298 | - |
|
299 | - public function get_link() |
|
300 | - { |
|
301 | - $session_id = api_get_session_id(); |
|
302 | - $url = api_get_path(WEB_PATH).'main/work/work.php?session_id='.$session_id.'&cidReq='.$this->get_course_code().'&id='.$this->exercise_data['id'].'&gradebook=view'; |
|
303 | - return $url; |
|
304 | - } |
|
305 | - |
|
306 | - private function get_exercise_data() |
|
307 | - { |
|
308 | - $tbl_name = $this->get_studpub_table(); |
|
309 | - $course_info = api_get_course_info($this->get_course_code()); |
|
310 | - if ($tbl_name=='') { |
|
311 | - return false; |
|
312 | - } elseif (!isset($this->exercise_data)) { |
|
313 | - $sql = 'SELECT * FROM '.$this->get_studpub_table()." |
|
184 | + if (!empty($stud_id)) { |
|
185 | + $sql .= " AND user_id = $stud_id "; |
|
186 | + } |
|
187 | + |
|
188 | + $order = api_get_setting('student_publication_to_take_in_gradebook'); |
|
189 | + |
|
190 | + switch ($order) { |
|
191 | + case 'last': |
|
192 | + // latest attempt |
|
193 | + $sql .= ' ORDER BY sent_date DESC'; |
|
194 | + break; |
|
195 | + case 'first': |
|
196 | + default: |
|
197 | + // first attempt |
|
198 | + $sql .= ' ORDER BY id'; |
|
199 | + break; |
|
200 | + } |
|
201 | + |
|
202 | + $scores = Database::query($sql); |
|
203 | + |
|
204 | + // for 1 student |
|
205 | + if (!empty($stud_id)) { |
|
206 | + if ($data = Database::fetch_array($scores)) { |
|
207 | + return array( |
|
208 | + $data['qualification'], |
|
209 | + $assignment['qualification'] |
|
210 | + ); |
|
211 | + } else { |
|
212 | + return ''; |
|
213 | + } |
|
214 | + } else { |
|
215 | + $students = array(); // user list, needed to make sure we only |
|
216 | + // take first attempts into account |
|
217 | + $rescount = 0; |
|
218 | + $sum = 0; |
|
219 | + $bestResult = 0; |
|
220 | + $weight = 0; |
|
221 | + $sumResult = 0; |
|
222 | + $myResult = 0; |
|
223 | + |
|
224 | + while ($data = Database::fetch_array($scores)) { |
|
225 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
226 | + if ($assignment['qualification'] != 0) { |
|
227 | + $students[$data['user_id']] = $data['qualification']; |
|
228 | + $rescount++; |
|
229 | + $sum += $data['qualification'] / $assignment['qualification']; |
|
230 | + $sumResult += $data['qualification']; |
|
231 | + |
|
232 | + if ($data['qualification'] > $bestResult) { |
|
233 | + $bestResult = $data['qualification']; |
|
234 | + } |
|
235 | + $weight = $assignment['qualification']; |
|
236 | + } |
|
237 | + } |
|
238 | + } |
|
239 | + |
|
240 | + if ($rescount == 0) { |
|
241 | + return null; |
|
242 | + } else { |
|
243 | + switch ($type) { |
|
244 | + case 'best': |
|
245 | + return array($bestResult, $weight); |
|
246 | + break; |
|
247 | + case 'average': |
|
248 | + return array($sumResult/$rescount, $weight); |
|
249 | + break; |
|
250 | + case 'ranking': |
|
251 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
252 | + break; |
|
253 | + default: |
|
254 | + return array($sum, $rescount); |
|
255 | + break; |
|
256 | + } |
|
257 | + } |
|
258 | + } |
|
259 | + } |
|
260 | + |
|
261 | + /** |
|
262 | + * Lazy load function to get the database table of the student publications |
|
263 | + */ |
|
264 | + private function get_studpub_table() |
|
265 | + { |
|
266 | + return $this->studpub_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * Lazy load function to get the database table of the item properties |
|
271 | + */ |
|
272 | + private function get_itemprop_table() |
|
273 | + { |
|
274 | + return $this->itemprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
275 | + } |
|
276 | + |
|
277 | + public function needs_name_and_description() |
|
278 | + { |
|
279 | + return false; |
|
280 | + } |
|
281 | + |
|
282 | + public function get_name() |
|
283 | + { |
|
284 | + $this->get_exercise_data(); |
|
285 | + return (isset($this->exercise_data['title']) && !empty($this->exercise_data['title'])) ? $this->exercise_data['title'] : get_lang('Untitled'); |
|
286 | + } |
|
287 | + |
|
288 | + public function get_description() |
|
289 | + { |
|
290 | + $this->get_exercise_data(); |
|
291 | + return isset($this->exercise_data['description']) ? $this->exercise_data['description'] : null; |
|
292 | + } |
|
293 | + |
|
294 | + public function get_test_id() |
|
295 | + { |
|
296 | + return 'DEBUG:ID'; |
|
297 | + } |
|
298 | + |
|
299 | + public function get_link() |
|
300 | + { |
|
301 | + $session_id = api_get_session_id(); |
|
302 | + $url = api_get_path(WEB_PATH).'main/work/work.php?session_id='.$session_id.'&cidReq='.$this->get_course_code().'&id='.$this->exercise_data['id'].'&gradebook=view'; |
|
303 | + return $url; |
|
304 | + } |
|
305 | + |
|
306 | + private function get_exercise_data() |
|
307 | + { |
|
308 | + $tbl_name = $this->get_studpub_table(); |
|
309 | + $course_info = api_get_course_info($this->get_course_code()); |
|
310 | + if ($tbl_name=='') { |
|
311 | + return false; |
|
312 | + } elseif (!isset($this->exercise_data)) { |
|
313 | + $sql = 'SELECT * FROM '.$this->get_studpub_table()." |
|
314 | 314 | WHERE |
315 | 315 | c_id ='".$course_info['real_id']."' AND |
316 | 316 | id = '".intval($this->get_ref_id())."' "; |
317 | - $query = Database::query($sql); |
|
318 | - $this->exercise_data = Database::fetch_array($query); |
|
319 | - } |
|
320 | - return $this->exercise_data; |
|
321 | - } |
|
322 | - |
|
323 | - public function needs_max() |
|
324 | - { |
|
325 | - return false; |
|
326 | - } |
|
327 | - |
|
328 | - public function needs_results() |
|
329 | - { |
|
330 | - return false; |
|
331 | - } |
|
332 | - |
|
333 | - public function is_valid_link() |
|
334 | - { |
|
335 | - $sql = 'SELECT count(id) FROM '.$this->get_studpub_table().' |
|
317 | + $query = Database::query($sql); |
|
318 | + $this->exercise_data = Database::fetch_array($query); |
|
319 | + } |
|
320 | + return $this->exercise_data; |
|
321 | + } |
|
322 | + |
|
323 | + public function needs_max() |
|
324 | + { |
|
325 | + return false; |
|
326 | + } |
|
327 | + |
|
328 | + public function needs_results() |
|
329 | + { |
|
330 | + return false; |
|
331 | + } |
|
332 | + |
|
333 | + public function is_valid_link() |
|
334 | + { |
|
335 | + $sql = 'SELECT count(id) FROM '.$this->get_studpub_table().' |
|
336 | 336 | WHERE c_id = "'.$this->course_id.'" AND id = '.intval($this->get_ref_id()).''; |
337 | - $result = Database::query($sql); |
|
338 | - $number = Database::fetch_row($result); |
|
339 | - return ($number[0] != 0); |
|
340 | - } |
|
341 | - |
|
342 | - public function get_icon_name() |
|
343 | - { |
|
344 | - return 'studentpublication'; |
|
345 | - } |
|
346 | - |
|
347 | - public function save_linked_data() |
|
348 | - { |
|
349 | - $weight = (float)$this->get_weight(); |
|
350 | - $ref_id = $this->get_ref_id(); |
|
351 | - |
|
352 | - if (!empty($ref_id)) { |
|
353 | - //Cleans works |
|
354 | - $sql = 'UPDATE '.$this->get_studpub_table().' SET weight= '.$weight.' |
|
337 | + $result = Database::query($sql); |
|
338 | + $number = Database::fetch_row($result); |
|
339 | + return ($number[0] != 0); |
|
340 | + } |
|
341 | + |
|
342 | + public function get_icon_name() |
|
343 | + { |
|
344 | + return 'studentpublication'; |
|
345 | + } |
|
346 | + |
|
347 | + public function save_linked_data() |
|
348 | + { |
|
349 | + $weight = (float)$this->get_weight(); |
|
350 | + $ref_id = $this->get_ref_id(); |
|
351 | + |
|
352 | + if (!empty($ref_id)) { |
|
353 | + //Cleans works |
|
354 | + $sql = 'UPDATE '.$this->get_studpub_table().' SET weight= '.$weight.' |
|
355 | 355 | WHERE c_id = '.$this->course_id.' AND id ='.$ref_id; |
356 | - Database::query($sql); |
|
357 | - } |
|
358 | - } |
|
359 | - |
|
360 | - public function delete_linked_data() |
|
361 | - { |
|
362 | - $ref_id = $this->get_ref_id(); |
|
363 | - if (!empty($ref_id)) { |
|
364 | - //Cleans works |
|
365 | - $sql = 'UPDATE '.$this->get_studpub_table().' SET weight=0 |
|
356 | + Database::query($sql); |
|
357 | + } |
|
358 | + } |
|
359 | + |
|
360 | + public function delete_linked_data() |
|
361 | + { |
|
362 | + $ref_id = $this->get_ref_id(); |
|
363 | + if (!empty($ref_id)) { |
|
364 | + //Cleans works |
|
365 | + $sql = 'UPDATE '.$this->get_studpub_table().' SET weight=0 |
|
366 | 366 | WHERE c_id = '.$this->course_id.' AND id ='.$ref_id; |
367 | - Database::query($sql); |
|
368 | - } |
|
369 | - } |
|
367 | + Database::query($sql); |
|
368 | + } |
|
369 | + } |
|
370 | 370 | } |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | |
85 | 85 | $result = Database::query($sql); |
86 | 86 | |
87 | - $cats=array(); |
|
88 | - while ($data=Database::fetch_array($result)) { |
|
89 | - $cats[] = array ($data['id'], $data['url']); |
|
87 | + $cats = array(); |
|
88 | + while ($data = Database::fetch_array($result)) { |
|
89 | + $cats[] = array($data['id'], $data['url']); |
|
90 | 90 | } |
91 | 91 | return $cats; |
92 | 92 | } |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | if (empty($work_name)) { |
128 | 128 | $work_name = basename($data['url']); |
129 | 129 | } |
130 | - $cats[] = array ($data['id'], $work_name); |
|
130 | + $cats[] = array($data['id'], $work_name); |
|
131 | 131 | } |
132 | - $cats=isset($cats) ? $cats : array(); |
|
132 | + $cats = isset($cats) ? $cats : array(); |
|
133 | 133 | return $cats; |
134 | 134 | } |
135 | 135 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | c_id = '.$this->course_id.' AND |
179 | 179 | active = 1 AND |
180 | 180 | parent_id = "'.$parentId.'" AND |
181 | - session_id = '.api_get_session_id() .' AND |
|
181 | + session_id = '.api_get_session_id().' AND |
|
182 | 182 | qualificator_id <> 0 |
183 | 183 | '; |
184 | 184 | if (!empty($stud_id)) { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | return ''; |
213 | 213 | } |
214 | 214 | } else { |
215 | - $students = array(); // user list, needed to make sure we only |
|
215 | + $students = array(); // user list, needed to make sure we only |
|
216 | 216 | // take first attempts into account |
217 | 217 | $rescount = 0; |
218 | 218 | $sum = 0; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | return array($bestResult, $weight); |
246 | 246 | break; |
247 | 247 | case 'average': |
248 | - return array($sumResult/$rescount, $weight); |
|
248 | + return array($sumResult / $rescount, $weight); |
|
249 | 249 | break; |
250 | 250 | case 'ranking': |
251 | 251 | return AbstractLink::getCurrentUserRanking($stud_id, $students); |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | { |
308 | 308 | $tbl_name = $this->get_studpub_table(); |
309 | 309 | $course_info = api_get_course_info($this->get_course_code()); |
310 | - if ($tbl_name=='') { |
|
310 | + if ($tbl_name == '') { |
|
311 | 311 | return false; |
312 | 312 | } elseif (!isset($this->exercise_data)) { |
313 | 313 | $sql = 'SELECT * FROM '.$this->get_studpub_table()." |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | |
347 | 347 | public function save_linked_data() |
348 | 348 | { |
349 | - $weight = (float)$this->get_weight(); |
|
349 | + $weight = (float) $this->get_weight(); |
|
350 | 350 | $ref_id = $this->get_ref_id(); |
351 | 351 | |
352 | 352 | if (!empty($ref_id)) { |
@@ -249,7 +249,7 @@ |
||
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | - $modify_icons .= '<a href="gradebook_edit_all.php?selectcat=' .$cat->get_id() . '&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id().'">' . |
|
252 | + $modify_icons .= '<a href="gradebook_edit_all.php?selectcat=' .$cat->get_id() . '&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id().'">' . |
|
253 | 253 | Display::return_icon( |
254 | 254 | 'percentage.png', |
255 | 255 | get_lang('EditAllWeights'), |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | $course_code = Database::escape_string($course_code); |
78 | 78 | if (!empty($link_id)) { |
79 | 79 | $link_id = intval($link_id); |
80 | - $sql = 'UPDATE ' . Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK) . ' |
|
81 | - SET weight = ' . "'" . Database::escape_string((float) $weight) . "'" . ' |
|
82 | - WHERE course_code = "' . $course_code . '" AND id = ' . $link_id; |
|
80 | + $sql = 'UPDATE '.Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK).' |
|
81 | + SET weight = ' . "'".Database::escape_string((float) $weight)."'".' |
|
82 | + WHERE course_code = "' . $course_code.'" AND id = '.$link_id; |
|
83 | 83 | Database::query($sql); |
84 | 84 | } |
85 | 85 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | // TODO find the corresponding category (the first one for this course, ordered by ID) |
101 | 101 | $l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
102 | - $sql = "DELETE FROM $l WHERE id = ".(int)$link_id; |
|
102 | + $sql = "DELETE FROM $l WHERE id = ".(int) $link_id; |
|
103 | 103 | Database::query($sql); |
104 | 104 | |
105 | 105 | return true; |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | $visibility_icon = ($cat->is_visible() == 0) ? 'invisible' : 'visible'; |
196 | 196 | $visibility_command = ($cat->is_visible() == 0) ? 'set_visible' : 'set_invisible'; |
197 | 197 | |
198 | - $modify_icons .= '<a class="view_children" data-cat-id="' . $cat->get_id() . '" href="javascript:void(0);">' . |
|
199 | - Display::return_icon('view_more_stats.gif', get_lang('Show'), '', ICON_SIZE_SMALL) . '</a>'; |
|
198 | + $modify_icons .= '<a class="view_children" data-cat-id="'.$cat->get_id().'" href="javascript:void(0);">'. |
|
199 | + Display::return_icon('view_more_stats.gif', get_lang('Show'), '', ICON_SIZE_SMALL).'</a>'; |
|
200 | 200 | |
201 | 201 | if (!api_is_allowed_to_edit(null, true)) { |
202 | 202 | $modify_icons .= Display::url( |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | '', |
207 | 207 | ICON_SIZE_SMALL |
208 | 208 | ), |
209 | - 'personal_stats.php?' . http_build_query([ |
|
209 | + 'personal_stats.php?'.http_build_query([ |
|
210 | 210 | 'selectcat' => $cat->get_id() |
211 | - ]) . '&' . api_get_cidreq(), |
|
211 | + ]).'&'.api_get_cidreq(), |
|
212 | 212 | [ |
213 | 213 | 'class' => 'ajax', |
214 | 214 | 'data-title' => get_lang('FlatView') |
@@ -222,16 +222,16 @@ discard block |
||
222 | 222 | if (api_get_setting('gradebook_locking_enabled') == 'true') { |
223 | 223 | if ($cat->is_locked()) { |
224 | 224 | if (api_is_platform_admin()) { |
225 | - $modify_icons .= ' <a onclick="javascript:if (!confirm(\'' . addslashes(get_lang('ConfirmToUnlockElement')) . '\')) return false;" href="' . api_get_self() . '?' . api_get_cidreq() . '&category_id=' . $cat->get_id() . '&action=unlock">' . |
|
226 | - Display::return_icon('lock.png', get_lang('UnLockEvaluation'), '', ICON_SIZE_SMALL) . '</a>'; |
|
225 | + $modify_icons .= ' <a onclick="javascript:if (!confirm(\''.addslashes(get_lang('ConfirmToUnlockElement')).'\')) return false;" href="'.api_get_self().'?'.api_get_cidreq().'&category_id='.$cat->get_id().'&action=unlock">'. |
|
226 | + Display::return_icon('lock.png', get_lang('UnLockEvaluation'), '', ICON_SIZE_SMALL).'</a>'; |
|
227 | 227 | } else { |
228 | - $modify_icons .= ' <a href="#">' . Display::return_icon('lock_na.png', get_lang('GradebookLockedAlert'), '', ICON_SIZE_SMALL) . '</a>'; |
|
228 | + $modify_icons .= ' <a href="#">'.Display::return_icon('lock_na.png', get_lang('GradebookLockedAlert'), '', ICON_SIZE_SMALL).'</a>'; |
|
229 | 229 | } |
230 | - $modify_icons .= ' <a href="gradebook_flatview.php?export_pdf=category&selectcat=' . $cat->get_id() . '" >' . Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL) . '</a>'; |
|
230 | + $modify_icons .= ' <a href="gradebook_flatview.php?export_pdf=category&selectcat='.$cat->get_id().'" >'.Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL).'</a>'; |
|
231 | 231 | } else { |
232 | - $modify_icons .= ' <a onclick="javascript:if (!confirm(\'' . addslashes(get_lang('ConfirmToLockElement')) . '\')) return false;" href="' . api_get_self() . '?' . api_get_cidreq() . '&category_id=' . $cat->get_id() . '&action=lock">' . |
|
233 | - Display::return_icon('unlock.png', get_lang('LockEvaluation'), '', ICON_SIZE_SMALL) . '</a>'; |
|
234 | - $modify_icons .= ' <a href="#" >' . Display::return_icon('pdf_na.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL) . '</a>'; |
|
232 | + $modify_icons .= ' <a onclick="javascript:if (!confirm(\''.addslashes(get_lang('ConfirmToLockElement')).'\')) return false;" href="'.api_get_self().'?'.api_get_cidreq().'&category_id='.$cat->get_id().'&action=lock">'. |
|
233 | + Display::return_icon('unlock.png', get_lang('LockEvaluation'), '', ICON_SIZE_SMALL).'</a>'; |
|
234 | + $modify_icons .= ' <a href="#" >'.Display::return_icon('pdf_na.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL).'</a>'; |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | |
@@ -239,44 +239,44 @@ discard block |
||
239 | 239 | if ($cat->is_locked() && !api_is_platform_admin()) { |
240 | 240 | $modify_icons .= Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL); |
241 | 241 | } else { |
242 | - $modify_icons .= '<a href="gradebook_edit_cat.php?' .'editcat=' . $cat->get_id() . '&cidReq=' .$cat->get_course_code() . '&id_session='.$cat->get_session_id().'">' . |
|
242 | + $modify_icons .= '<a href="gradebook_edit_cat.php?'.'editcat='.$cat->get_id().'&cidReq='.$cat->get_course_code().'&id_session='.$cat->get_session_id().'">'. |
|
243 | 243 | Display::return_icon( |
244 | 244 | 'edit.png', |
245 | 245 | get_lang('Modify'), |
246 | 246 | '', |
247 | 247 | ICON_SIZE_SMALL |
248 | - ) . '</a>'; |
|
248 | + ).'</a>'; |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | - $modify_icons .= '<a href="gradebook_edit_all.php?selectcat=' .$cat->get_id() . '&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id().'">' . |
|
252 | + $modify_icons .= '<a href="gradebook_edit_all.php?selectcat='.$cat->get_id().'&cidReq='.$cat->get_course_code().'&id_session='.$cat->get_session_id().'">'. |
|
253 | 253 | Display::return_icon( |
254 | 254 | 'percentage.png', |
255 | 255 | get_lang('EditAllWeights'), |
256 | 256 | '', |
257 | 257 | ICON_SIZE_SMALL |
258 | - ) . '</a>'; |
|
258 | + ).'</a>'; |
|
259 | 259 | |
260 | - $modify_icons .= '<a href="gradebook_flatview.php?selectcat=' .$cat->get_id() . '&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id(). '">' . |
|
260 | + $modify_icons .= '<a href="gradebook_flatview.php?selectcat='.$cat->get_id().'&cidReq='.$cat->get_course_code().'&id_session='.$cat->get_session_id().'">'. |
|
261 | 261 | Display::return_icon( |
262 | 262 | 'stats.png', |
263 | 263 | get_lang('FlatView'), |
264 | 264 | '', |
265 | 265 | ICON_SIZE_SMALL |
266 | - ) . '</a>'; |
|
267 | - $modify_icons .= ' <a href="' . api_get_self() .'?visiblecat=' . $cat->get_id() . '&' .$visibility_command . '=&selectcat=' . $selectcat .'&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id(). '">' . |
|
266 | + ).'</a>'; |
|
267 | + $modify_icons .= ' <a href="'.api_get_self().'?visiblecat='.$cat->get_id().'&'.$visibility_command.'=&selectcat='.$selectcat.'&cidReq='.$cat->get_course_code().'&id_session='.$cat->get_session_id().'">'. |
|
268 | 268 | Display::return_icon( |
269 | - $visibility_icon . '.png', |
|
269 | + $visibility_icon.'.png', |
|
270 | 270 | get_lang('Visible'), |
271 | 271 | '', |
272 | 272 | ICON_SIZE_SMALL |
273 | - ) . '</a>'; |
|
273 | + ).'</a>'; |
|
274 | 274 | |
275 | 275 | if ($cat->is_locked() && !api_is_platform_admin()) { |
276 | 276 | $modify_icons .= Display::return_icon('delete_na.png', get_lang('DeleteAll'), '', ICON_SIZE_SMALL); |
277 | 277 | } else { |
278 | - $modify_icons .= ' <a href="' . api_get_self() . '?deletecat=' . $cat->get_id() . '&selectcat=' . $selectcat . '&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id(). '" onclick="return confirmation();">' . |
|
279 | - Display::return_icon('delete.png', get_lang('DeleteAll'), '', ICON_SIZE_SMALL) . '</a>'; |
|
278 | + $modify_icons .= ' <a href="'.api_get_self().'?deletecat='.$cat->get_id().'&selectcat='.$selectcat.'&cidReq='.$cat->get_course_code().'&id_session='.$cat->get_session_id().'" onclick="return confirmation();">'. |
|
279 | + Display::return_icon('delete.png', get_lang('DeleteAll'), '', ICON_SIZE_SMALL).'</a>'; |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
@@ -303,21 +303,21 @@ discard block |
||
303 | 303 | if ($is_locked && !api_is_platform_admin()) { |
304 | 304 | $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL); |
305 | 305 | } else { |
306 | - $modify_icons = '<a href="gradebook_edit_eval.php?editeval=' . $eval->get_id() . '&cidReq=' . $eval->get_course_code() . '&id_session='.$eval->getSessionId(). '">' . |
|
307 | - Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>'; |
|
306 | + $modify_icons = '<a href="gradebook_edit_eval.php?editeval='.$eval->get_id().'&cidReq='.$eval->get_course_code().'&id_session='.$eval->getSessionId().'">'. |
|
307 | + Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL).'</a>'; |
|
308 | 308 | } |
309 | 309 | |
310 | - $modify_icons .= ' <a href="' . api_get_self() . '?visibleeval=' . $eval->get_id() . '&' . $visibility_command . '=&selectcat=' . $selectcat . '&id_session='.$eval->getSessionId(). ' ">' . |
|
311 | - Display::return_icon($visibility_icon . '.png', get_lang('Visible'), '', ICON_SIZE_SMALL) . '</a>'; |
|
310 | + $modify_icons .= ' <a href="'.api_get_self().'?visibleeval='.$eval->get_id().'&'.$visibility_command.'=&selectcat='.$selectcat.'&id_session='.$eval->getSessionId().' ">'. |
|
311 | + Display::return_icon($visibility_icon.'.png', get_lang('Visible'), '', ICON_SIZE_SMALL).'</a>'; |
|
312 | 312 | if (api_is_allowed_to_edit(null, true)) { |
313 | - $modify_icons .= ' <a href="gradebook_showlog_eval.php?visiblelog=' . $eval->get_id() . '&selectcat=' . $selectcat . ' &cidReq=' . $eval->get_course_code() . '&id_session='.$eval->getSessionId(). '">' . |
|
314 | - Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL) . '</a>'; |
|
313 | + $modify_icons .= ' <a href="gradebook_showlog_eval.php?visiblelog='.$eval->get_id().'&selectcat='.$selectcat.' &cidReq='.$eval->get_course_code().'&id_session='.$eval->getSessionId().'">'. |
|
314 | + Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL).'</a>'; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | if ($is_locked && !api_is_platform_admin()) { |
318 | - $modify_icons .= ' ' . Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL); |
|
318 | + $modify_icons .= ' '.Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL); |
|
319 | 319 | } else { |
320 | - $modify_icons .= ' <a href="' . api_get_self() . '?deleteeval=' . $eval->get_id() . '&selectcat=' . $selectcat . ' &cidReq=' . $eval->get_course_code() . '&id_session='.$eval->getSessionId(). '" onclick="return confirmation();">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>'; |
|
320 | + $modify_icons .= ' <a href="'.api_get_self().'?deleteeval='.$eval->get_id().'&selectcat='.$selectcat.' &cidReq='.$eval->get_course_code().'&id_session='.$eval->getSessionId().'" onclick="return confirmation();">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; |
|
321 | 321 | } |
322 | 322 | return $modify_icons; |
323 | 323 | } |
@@ -347,21 +347,21 @@ discard block |
||
347 | 347 | if ($is_locked && !api_is_platform_admin()) { |
348 | 348 | $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL); |
349 | 349 | } else { |
350 | - $modify_icons = '<a href="gradebook_edit_link.php?editlink=' . $link->get_id() . '&cidReq=' . $link->get_course_code() . '&id_session='.$link->get_session_id().'">' . |
|
351 | - Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>'; |
|
350 | + $modify_icons = '<a href="gradebook_edit_link.php?editlink='.$link->get_id().'&cidReq='.$link->get_course_code().'&id_session='.$link->get_session_id().'">'. |
|
351 | + Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL).'</a>'; |
|
352 | 352 | } |
353 | - $modify_icons .= ' <a href="' . api_get_self() . '?visiblelink=' . $link->get_id() . '&' . $visibility_command . '=&selectcat=' . $selectcat . '&id_session='.$link->get_session_id(). ' ">' . |
|
354 | - Display::return_icon($visibility_icon . '.png', get_lang('Visible'), '', ICON_SIZE_SMALL) . '</a>'; |
|
355 | - $modify_icons .= ' <a href="gradebook_showlog_link.php?visiblelink=' . $link->get_id() . '&selectcat=' . $selectcat . '&cidReq=' . $link->get_course_code() . '&id_session='.$link->get_session_id(). '">' . |
|
356 | - Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL) . '</a>'; |
|
353 | + $modify_icons .= ' <a href="'.api_get_self().'?visiblelink='.$link->get_id().'&'.$visibility_command.'=&selectcat='.$selectcat.'&id_session='.$link->get_session_id().' ">'. |
|
354 | + Display::return_icon($visibility_icon.'.png', get_lang('Visible'), '', ICON_SIZE_SMALL).'</a>'; |
|
355 | + $modify_icons .= ' <a href="gradebook_showlog_link.php?visiblelink='.$link->get_id().'&selectcat='.$selectcat.'&cidReq='.$link->get_course_code().'&id_session='.$link->get_session_id().'">'. |
|
356 | + Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL).'</a>'; |
|
357 | 357 | |
358 | 358 | //If a work is added in a gradebook you can only delete the link in the work tool |
359 | 359 | |
360 | 360 | if ($is_locked && !api_is_platform_admin()) { |
361 | - $modify_icons .= ' ' . Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL); |
|
361 | + $modify_icons .= ' '.Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL); |
|
362 | 362 | } else { |
363 | - $modify_icons .= ' <a href="' . api_get_self() . '?deletelink=' . $link->get_id() . '&selectcat=' . $selectcat . ' &cidReq=' . $link->get_course_code() . '&id_session='.$link->get_session_id(). '" onclick="return confirmation();">' . |
|
364 | - Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>'; |
|
363 | + $modify_icons .= ' <a href="'.api_get_self().'?deletelink='.$link->get_id().'&selectcat='.$selectcat.' &cidReq='.$link->get_course_code().'&id_session='.$link->get_session_id().'" onclick="return confirmation();">'. |
|
364 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; |
|
365 | 365 | } |
366 | 366 | return $modify_icons; |
367 | 367 | } |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | $sql = "SELECT * FROM $table l |
383 | 383 | WHERE |
384 | 384 | course_code = '$course_code' AND |
385 | - type = ".(int)$resource_type . " AND |
|
386 | - ref_id = " . (int)$resource_id; |
|
385 | + type = ".(int) $resource_type." AND |
|
386 | + ref_id = " . (int) $resource_id; |
|
387 | 387 | $res = Database::query($sql); |
388 | 388 | |
389 | 389 | if (Database::num_rows($res) < 1) { |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | } |
406 | 406 | // TODO find the corresponding category (the first one for this course, ordered by ID) |
407 | 407 | $l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
408 | - $sql = "SELECT * FROM $l WHERE id = " . (int) $link_id; |
|
408 | + $sql = "SELECT * FROM $l WHERE id = ".(int) $link_id; |
|
409 | 409 | $res = Database::query($sql); |
410 | 410 | $row = array(); |
411 | 411 | if (Database::num_rows($res) > 0) { |
@@ -423,10 +423,10 @@ discard block |
||
423 | 423 | { |
424 | 424 | $course_table = Database::get_main_table(TABLE_MAIN_COURSE); |
425 | 425 | $tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
426 | - $sql = 'SELECT c.id FROM ' . $course_table . ' c |
|
427 | - INNER JOIN ' . $tbl_grade_links . ' l |
|
426 | + $sql = 'SELECT c.id FROM '.$course_table.' c |
|
427 | + INNER JOIN ' . $tbl_grade_links.' l |
|
428 | 428 | ON c.code = l.course_code |
429 | - WHERE l.id=' . intval($id_link) . ' OR l.category_id=' . intval($id_link); |
|
429 | + WHERE l.id=' . intval($id_link).' OR l.category_id='.intval($id_link); |
|
430 | 430 | $res = Database::query($sql); |
431 | 431 | $array = Database::fetch_array($res, 'ASSOC'); |
432 | 432 | return $array['id']; |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | { |
536 | 536 | $result = Result :: load($resid); |
537 | 537 | if ($importscore > $eval_max) { |
538 | - header('Location: gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']) . '&overwritemax='); |
|
538 | + header('Location: gradebook_view_result.php?selecteval='.Security::remove_XSS($_GET['selecteval']).'&overwritemax='); |
|
539 | 539 | exit; |
540 | 540 | } |
541 | 541 | $result[0]->set_score($importscore); |
@@ -576,8 +576,8 @@ discard block |
||
576 | 576 | { |
577 | 577 | $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
578 | 578 | $sql = 'SELECT COUNT(*) as count |
579 | - FROM ' . $table . ' gc |
|
580 | - WHERE gc.cat_id="' . intval($cat_id) . '" AND user_id="' . intval($user_id) . '" '; |
|
579 | + FROM ' . $table.' gc |
|
580 | + WHERE gc.cat_id="' . intval($cat_id).'" AND user_id="'.intval($user_id).'" '; |
|
581 | 581 | $rs_exist = Database::query($sql); |
582 | 582 | $row = Database::fetch_array($rs_exist); |
583 | 583 | if ($row['count'] == 0) { |
@@ -600,8 +600,8 @@ discard block |
||
600 | 600 | public static function get_certificate_by_user_id($cat_id, $user_id) |
601 | 601 | { |
602 | 602 | $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
603 | - $sql = 'SELECT * FROM ' . $table_certificate . ' |
|
604 | - WHERE cat_id="' . intval($cat_id) . '" AND user_id="' . intval($user_id) . '"'; |
|
603 | + $sql = 'SELECT * FROM '.$table_certificate.' |
|
604 | + WHERE cat_id="' . intval($cat_id).'" AND user_id="'.intval($user_id).'"'; |
|
605 | 605 | |
606 | 606 | $result = Database::query($sql); |
607 | 607 | $row = Database::fetch_array($result, 'ASSOC'); |
@@ -620,18 +620,18 @@ discard block |
||
620 | 620 | $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
621 | 621 | $table_user = Database::get_main_table(TABLE_MAIN_USER); |
622 | 622 | $sql = 'SELECT DISTINCT u.user_id, u.lastname, u.firstname, u.username |
623 | - FROM ' . $table_user . ' u |
|
624 | - INNER JOIN ' . $table_certificate . ' gc |
|
623 | + FROM ' . $table_user.' u |
|
624 | + INNER JOIN ' . $table_certificate.' gc |
|
625 | 625 | ON u.user_id=gc.user_id '; |
626 | 626 | if (!is_null($cat_id) && $cat_id > 0) { |
627 | - $sql.=' WHERE cat_id=' . intval($cat_id); |
|
627 | + $sql .= ' WHERE cat_id='.intval($cat_id); |
|
628 | 628 | } |
629 | 629 | if (!empty($userList)) { |
630 | 630 | $userList = array_map('intval', $userList); |
631 | 631 | $userListCondition = implode("','", $userList); |
632 | 632 | $sql .= " AND u.user_id IN ('$userListCondition')"; |
633 | 633 | } |
634 | - $sql.=' ORDER BY u.firstname'; |
|
634 | + $sql .= ' ORDER BY u.firstname'; |
|
635 | 635 | $rs = Database::query($sql); |
636 | 636 | |
637 | 637 | $list_users = array(); |
@@ -652,10 +652,10 @@ discard block |
||
652 | 652 | { |
653 | 653 | $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
654 | 654 | $sql = 'SELECT gc.score_certificate, gc.created_at, gc.path_certificate, gc.cat_id, gc.user_id, gc.id |
655 | - FROM ' . $table_certificate . ' gc |
|
656 | - WHERE gc.user_id="' . intval($user_id) . '" '; |
|
655 | + FROM ' . $table_certificate.' gc |
|
656 | + WHERE gc.user_id="' . intval($user_id).'" '; |
|
657 | 657 | if (!is_null($cat_id) && $cat_id > 0) { |
658 | - $sql.=' AND cat_id=' . intval($cat_id); |
|
658 | + $sql .= ' AND cat_id='.intval($cat_id); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | $rs = Database::query($sql); |
@@ -693,12 +693,12 @@ discard block |
||
693 | 693 | $variables = $content_html['variables']; |
694 | 694 | } |
695 | 695 | |
696 | - $path_image = api_get_path(WEB_COURSE_PATH) . api_get_course_path($course_code) . '/document/images/gallery'; |
|
696 | + $path_image = api_get_path(WEB_COURSE_PATH).api_get_course_path($course_code).'/document/images/gallery'; |
|
697 | 697 | $new_content_html = str_replace('../images/gallery', $path_image, $new_content_html); |
698 | 698 | |
699 | - $path_image_in_default_course = api_get_path(WEB_CODE_PATH) . 'default_course_document'; |
|
699 | + $path_image_in_default_course = api_get_path(WEB_CODE_PATH).'default_course_document'; |
|
700 | 700 | $new_content_html = str_replace('/main/default_course_document', $path_image_in_default_course, $new_content_html); |
701 | - $new_content_html = str_replace(SYS_CODE_PATH . 'img/', api_get_path(WEB_IMG_PATH), $new_content_html); |
|
701 | + $new_content_html = str_replace(SYS_CODE_PATH.'img/', api_get_path(WEB_IMG_PATH), $new_content_html); |
|
702 | 702 | |
703 | 703 | //add print header |
704 | 704 | if ($hide_print_button == false) { |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | } |
710 | 710 | |
711 | 711 | // Add header |
712 | - $new_content_html = $contentHead. $print . '</head>' . $new_content_html; |
|
712 | + $new_content_html = $contentHead.$print.'</head>'.$new_content_html; |
|
713 | 713 | |
714 | 714 | return array( |
715 | 715 | 'content' => $new_content_html, |
@@ -731,9 +731,9 @@ discard block |
||
731 | 731 | $session_id = api_get_session_id(); |
732 | 732 | |
733 | 733 | $t = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); |
734 | - $sql = "SELECT * FROM $t WHERE course_code = '" . Database::escape_string($course_code) . "' "; |
|
734 | + $sql = "SELECT * FROM $t WHERE course_code = '".Database::escape_string($course_code)."' "; |
|
735 | 735 | if (!empty($session_id)) { |
736 | - $sql .= " AND session_id = " . (int) $session_id; |
|
736 | + $sql .= " AND session_id = ".(int) $session_id; |
|
737 | 737 | } else { |
738 | 738 | $sql .= " AND (session_id IS NULL OR session_id = 0) "; |
739 | 739 | } |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | if (!empty($session_id)) { |
746 | 746 | $my_session_id = api_get_session_id(); |
747 | 747 | $s_name = api_get_session_name($my_session_id); |
748 | - $cat->set_name($course_code . ' - ' . get_lang('Session') . ' ' . $s_name); |
|
748 | + $cat->set_name($course_code.' - '.get_lang('Session').' '.$s_name); |
|
749 | 749 | $cat->set_session_id($session_id); |
750 | 750 | } else { |
751 | 751 | $cat->set_name($course_code); |
@@ -867,13 +867,13 @@ discard block |
||
867 | 867 | |
868 | 868 | if ($use_grade_model) { |
869 | 869 | if ($parent_id == 0) { |
870 | - $title = api_strtoupper(get_lang('Average')) . '<br />' . get_lang('Detailed'); |
|
870 | + $title = api_strtoupper(get_lang('Average')).'<br />'.get_lang('Detailed'); |
|
871 | 871 | } else { |
872 | - $title = api_strtoupper(get_lang('Average')) . '<br />' . $cat[0]->get_description() . ' - (' . $cat[0]->get_name() . ')'; |
|
872 | + $title = api_strtoupper(get_lang('Average')).'<br />'.$cat[0]->get_description().' - ('.$cat[0]->get_name().')'; |
|
873 | 873 | } |
874 | 874 | } else { |
875 | 875 | if ($parent_id == 0) { |
876 | - $title = api_strtoupper(get_lang('Average')) . '<br />' . get_lang('Detailed'); |
|
876 | + $title = api_strtoupper(get_lang('Average')).'<br />'.get_lang('Detailed'); |
|
877 | 877 | } else { |
878 | 878 | $title = api_strtoupper(get_lang('Average')); |
879 | 879 | } |
@@ -927,11 +927,11 @@ discard block |
||
927 | 927 | } else { |
928 | 928 | $column = 0; |
929 | 929 | $table->setCellContents($row, $column, get_lang('NoResults')); |
930 | - $table->updateCellAttributes($row, $column, 'colspan="' . $columns . '" align="center" class="row_odd"'); |
|
930 | + $table->updateCellAttributes($row, $column, 'colspan="'.$columns.'" align="center" class="row_odd"'); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | $pdfParams = array( |
934 | - 'filename' => get_lang('FlatView') . '_' . api_get_utc_datetime(), |
|
934 | + 'filename' => get_lang('FlatView').'_'.api_get_utc_datetime(), |
|
935 | 935 | 'pdf_title' => $title, |
936 | 936 | 'course_code' => $course_code, |
937 | 937 | 'add_signatures' => true |
@@ -1016,7 +1016,7 @@ discard block |
||
1016 | 1016 | $a_students = array(); |
1017 | 1017 | while ($user = Database::fetch_array($result)) { |
1018 | 1018 | if (!array_key_exists($user['user_id'], $a_students)) { |
1019 | - $a_current_student = array (); |
|
1019 | + $a_current_student = array(); |
|
1020 | 1020 | $a_current_student[] = $user['user_id']; |
1021 | 1021 | $a_current_student[] = $user['username']; |
1022 | 1022 | $a_current_student[] = $user['lastname']; |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | foreach ($links as $link) { |
1075 | 1075 | // links are always in a course |
1076 | 1076 | $coursecode = $link->get_course_code(); |
1077 | - if (!array_key_exists($coursecode,$coursecodes)) { |
|
1077 | + if (!array_key_exists($coursecode, $coursecodes)) { |
|
1078 | 1078 | $coursecodes[$coursecode] = '1'; |
1079 | 1079 | $users = array_merge($users, GradebookUtils::get_users_in_course($coursecode)); |
1080 | 1080 | } |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | * Search students matching a given last name and/or first name |
1088 | 1088 | * @author Bert Steppé |
1089 | 1089 | */ |
1090 | - public static function find_students($mask= '') |
|
1090 | + public static function find_students($mask = '') |
|
1091 | 1091 | { |
1092 | 1092 | // students shouldn't be here // don't search if mask empty |
1093 | 1093 | if (!api_is_allowed_to_edit() || empty ($mask)) { |
@@ -1098,23 +1098,23 @@ discard block |
||
1098 | 1098 | $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); |
1099 | 1099 | $tbl_cru = Database :: get_main_table(TABLE_MAIN_COURSE_USER); |
1100 | 1100 | $sql = 'SELECT DISTINCT user.user_id, user.lastname, user.firstname, user.email, user.official_code |
1101 | - FROM ' . $tbl_user . ' user'; |
|
1101 | + FROM ' . $tbl_user.' user'; |
|
1102 | 1102 | if (!api_is_platform_admin()) { |
1103 | - $sql .= ', ' . $tbl_cru . ' cru'; |
|
1103 | + $sql .= ', '.$tbl_cru.' cru'; |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | - $sql .= ' WHERE user.status = ' . STUDENT; |
|
1107 | - $sql .= ' AND (user.lastname LIKE '."'%" . $mask . "%'"; |
|
1108 | - $sql .= ' OR user.firstname LIKE '."'%" . $mask . "%')"; |
|
1106 | + $sql .= ' WHERE user.status = '.STUDENT; |
|
1107 | + $sql .= ' AND (user.lastname LIKE '."'%".$mask."%'"; |
|
1108 | + $sql .= ' OR user.firstname LIKE '."'%".$mask."%')"; |
|
1109 | 1109 | |
1110 | 1110 | if (!api_is_platform_admin()) { |
1111 | 1111 | $sql .= ' AND user.user_id = cru.user_id AND |
1112 | 1112 | cru.relation_type <> '.COURSE_RELATION_TYPE_RRHH.' AND |
1113 | 1113 | cru.c_id in ( |
1114 | - SELECT c_id FROM '.$tbl_cru . ' |
|
1114 | + SELECT c_id FROM '.$tbl_cru.' |
|
1115 | 1115 | WHERE |
1116 | - user_id = ' . api_get_user_id() . ' AND |
|
1117 | - status = ' . COURSEMANAGER . ' |
|
1116 | + user_id = ' . api_get_user_id().' AND |
|
1117 | + status = ' . COURSEMANAGER.' |
|
1118 | 1118 | ) |
1119 | 1119 | '; |
1120 | 1120 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | $sql = 'SELECT ref_id FROM '.$table_link.' |
1158 | 1158 | WHERE id = '.$linkId.' AND type='.LINK_ATTENDANCE; |
1159 | 1159 | |
1160 | - $rs_attendance = Database::query($sql); |
|
1160 | + $rs_attendance = Database::query($sql); |
|
1161 | 1161 | if (Database::num_rows($rs_attendance) > 0) { |
1162 | 1162 | $row_attendance = Database::fetch_array($rs_attendance); |
1163 | 1163 | $sql = 'UPDATE '.$tbl_attendance.' SET attendance_weight ='.$weight.' |
@@ -1243,7 +1243,7 @@ discard block |
||
1243 | 1243 | 'course' => $courseInfo['title'], |
1244 | 1244 | 'score' => $certificateInfo['score_certificate'], |
1245 | 1245 | 'date' => api_format_date($certificateInfo['created_at'], DATE_FORMAT_SHORT), |
1246 | - 'link' => api_get_path(WEB_PATH) . "certificates/index.php?id={$certificateInfo['id']}" |
|
1246 | + 'link' => api_get_path(WEB_PATH)."certificates/index.php?id={$certificateInfo['id']}" |
|
1247 | 1247 | ]; |
1248 | 1248 | } |
1249 | 1249 | |
@@ -1307,7 +1307,7 @@ discard block |
||
1307 | 1307 | 'course' => $course['title'], |
1308 | 1308 | 'score' => $certificateInfo['score_certificate'], |
1309 | 1309 | 'date' => api_format_date($certificateInfo['created_at'], DATE_FORMAT_SHORT), |
1310 | - 'link' => api_get_path(WEB_PATH) . "certificates/index.php?id={$certificateInfo['id']}" |
|
1310 | + 'link' => api_get_path(WEB_PATH)."certificates/index.php?id={$certificateInfo['id']}" |
|
1311 | 1311 | ]; |
1312 | 1312 | } |
1313 | 1313 | } |
@@ -19,6 +19,7 @@ discard block |
||
19 | 19 | * @param int Visibility (0 hidden, 1 shown) |
20 | 20 | * @param int Session ID (optional or 0 if not defined) |
21 | 21 | * @param int |
22 | + * @param integer $resource_type |
|
22 | 23 | * @return boolean True on success, false on failure |
23 | 24 | */ |
24 | 25 | public static function add_resource_to_course_gradebook( |
@@ -117,7 +118,6 @@ discard block |
||
117 | 118 | |
118 | 119 | /** |
119 | 120 | * Builds an img tag for a gradebook item |
120 | - * @param string $type value returned by a gradebookitem's get_icon_name() |
|
121 | 121 | */ |
122 | 122 | public static function build_type_icon_tag($kind, $attributes = array()) |
123 | 123 | { |
@@ -572,6 +572,9 @@ discard block |
||
572 | 572 | * @param int The user id |
573 | 573 | * @param float The score obtained for certified |
574 | 574 | * @param Datetime The date when you obtained the certificate |
575 | + * @param integer $cat_id |
|
576 | + * @param integer $user_id |
|
577 | + * @param string $date_certificate |
|
575 | 578 | * @return void() |
576 | 579 | */ |
577 | 580 | public static function register_user_info_about_certificate($cat_id, $user_id, $score_certificate, $date_certificate) |
@@ -950,7 +953,7 @@ discard block |
||
950 | 953 | } |
951 | 954 | |
952 | 955 | /** |
953 | - * @param array $list_values |
|
956 | + * @param string[] $list_values |
|
954 | 957 | * @return string |
955 | 958 | */ |
956 | 959 | public static function score_badges($list_values) |
@@ -1010,7 +1013,7 @@ discard block |
||
1010 | 1013 | } |
1011 | 1014 | |
1012 | 1015 | /** |
1013 | - * @param $result |
|
1016 | + * @param Doctrine\DBAL\Driver\Statement|null $result |
|
1014 | 1017 | * @return array |
1015 | 1018 | */ |
1016 | 1019 | public static function get_user_array_from_sql_result($result) |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | api_protect_admin_script(); |
20 | 20 | |
21 | 21 | // Setting breadcrumbs. |
22 | -$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
|
23 | -$interbreadcrumb[] = array ('url' => 'class_list.php', 'name' => get_lang('AdminClasses')); |
|
22 | +$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
|
23 | +$interbreadcrumb[] = array('url' => 'class_list.php', 'name' => get_lang('AdminClasses')); |
|
24 | 24 | |
25 | 25 | |
26 | 26 | // Setting the name of the tool. |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | $class_id = intval($_GET['idclass']); |
31 | 31 | $class = ClassManager :: get_class_info($class_id); |
32 | 32 | $form = new FormValidator('edit_class', 'post', 'class_edit.php?idclass='.$class_id); |
33 | -$form->addText('name',get_lang('ClassName')); |
|
33 | +$form->addText('name', get_lang('ClassName')); |
|
34 | 34 | $form->addButtonUpdate(get_lang('Ok')); |
35 | 35 | $form->setDefaults(array('name'=>$class['name'])); |
36 | -if($form->validate()) |
|
36 | +if ($form->validate()) |
|
37 | 37 | { |
38 | 38 | $values = $form->exportValues(); |
39 | 39 | ClassManager :: set_name($values['name'], $class_id); |