@@ -10,133 +10,133 @@ |
||
10 | 10 | */ |
11 | 11 | class LinkForm extends FormValidator |
12 | 12 | { |
13 | - const TYPE_CREATE = 1; |
|
14 | - const TYPE_MOVE = 2; |
|
15 | - /** @var Category */ |
|
16 | - private $category_object; |
|
17 | - private $link_object; |
|
18 | - private $extra; |
|
13 | + const TYPE_CREATE = 1; |
|
14 | + const TYPE_MOVE = 2; |
|
15 | + /** @var Category */ |
|
16 | + private $category_object; |
|
17 | + private $link_object; |
|
18 | + private $extra; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Builds a form containing form items based on a given parameter |
|
22 | - * @param int form_type 1=choose link |
|
23 | - * @param obj cat_obj the category object |
|
24 | - * @param string form name |
|
25 | - * @param method |
|
26 | - * @param action |
|
27 | - */ |
|
28 | - public function __construct( |
|
29 | - $form_type, |
|
30 | - $category_object, |
|
31 | - $link_object, |
|
32 | - $form_name, |
|
33 | - $method = 'post', |
|
34 | - $action = null, |
|
35 | - $extra = null |
|
36 | - ) { |
|
37 | - parent :: __construct($form_name, $method, $action); |
|
20 | + /** |
|
21 | + * Builds a form containing form items based on a given parameter |
|
22 | + * @param int form_type 1=choose link |
|
23 | + * @param obj cat_obj the category object |
|
24 | + * @param string form name |
|
25 | + * @param method |
|
26 | + * @param action |
|
27 | + */ |
|
28 | + public function __construct( |
|
29 | + $form_type, |
|
30 | + $category_object, |
|
31 | + $link_object, |
|
32 | + $form_name, |
|
33 | + $method = 'post', |
|
34 | + $action = null, |
|
35 | + $extra = null |
|
36 | + ) { |
|
37 | + parent :: __construct($form_name, $method, $action); |
|
38 | 38 | |
39 | - if (isset ($category_object)) { |
|
40 | - $this->category_object = $category_object; |
|
41 | - } else { |
|
42 | - if (isset($link_object)) { |
|
43 | - $this->link_object = $link_object; |
|
44 | - } |
|
45 | - } |
|
39 | + if (isset ($category_object)) { |
|
40 | + $this->category_object = $category_object; |
|
41 | + } else { |
|
42 | + if (isset($link_object)) { |
|
43 | + $this->link_object = $link_object; |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | - if (isset ($extra)) { |
|
48 | - $this->extra = $extra; |
|
49 | - } |
|
50 | - if ($form_type == self :: TYPE_CREATE) { |
|
51 | - $this->build_create(); |
|
52 | - } elseif ($form_type == self :: TYPE_MOVE) { |
|
53 | - $this->build_move(); |
|
54 | - } |
|
55 | - } |
|
47 | + if (isset ($extra)) { |
|
48 | + $this->extra = $extra; |
|
49 | + } |
|
50 | + if ($form_type == self :: TYPE_CREATE) { |
|
51 | + $this->build_create(); |
|
52 | + } elseif ($form_type == self :: TYPE_MOVE) { |
|
53 | + $this->build_move(); |
|
54 | + } |
|
55 | + } |
|
56 | 56 | |
57 | - protected function build_move() |
|
58 | - { |
|
59 | - $renderer =& $this->defaultRenderer(); |
|
60 | - $renderer->setCustomElementTemplate('<span>{element}</span> '); |
|
61 | - $this->addElement('static',null,null,'"'.$this->link_object->get_name().'" '); |
|
62 | - $this->addElement('static',null,null,get_lang('MoveTo').' : '); |
|
63 | - $select = $this->addElement('select','move_cat',null,null); |
|
64 | - $line = ''; |
|
65 | - foreach ($this->link_object->get_target_categories() as $cat) { |
|
66 | - for ($i=0;$i<$cat[2];$i++) { |
|
67 | - $line .= '—'; |
|
68 | - } |
|
69 | - $select->addoption($line.' '.$cat[1],$cat[0]); |
|
70 | - $line = ''; |
|
71 | - } |
|
72 | - $this->addElement('submit', null, get_lang('Ok')); |
|
73 | - } |
|
57 | + protected function build_move() |
|
58 | + { |
|
59 | + $renderer =& $this->defaultRenderer(); |
|
60 | + $renderer->setCustomElementTemplate('<span>{element}</span> '); |
|
61 | + $this->addElement('static',null,null,'"'.$this->link_object->get_name().'" '); |
|
62 | + $this->addElement('static',null,null,get_lang('MoveTo').' : '); |
|
63 | + $select = $this->addElement('select','move_cat',null,null); |
|
64 | + $line = ''; |
|
65 | + foreach ($this->link_object->get_target_categories() as $cat) { |
|
66 | + for ($i=0;$i<$cat[2];$i++) { |
|
67 | + $line .= '—'; |
|
68 | + } |
|
69 | + $select->addoption($line.' '.$cat[1],$cat[0]); |
|
70 | + $line = ''; |
|
71 | + } |
|
72 | + $this->addElement('submit', null, get_lang('Ok')); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Builds the form |
|
77 | - */ |
|
78 | - protected function build_create() |
|
79 | - { |
|
80 | - $this->addElement('header', get_lang('MakeLink')); |
|
81 | - $select = $this->addElement( |
|
82 | - 'select', |
|
83 | - 'select_link', |
|
84 | - get_lang('ChooseLink'), |
|
85 | - null, |
|
86 | - array('onchange' => 'document.create_link.submit()') |
|
87 | - ); |
|
75 | + /** |
|
76 | + * Builds the form |
|
77 | + */ |
|
78 | + protected function build_create() |
|
79 | + { |
|
80 | + $this->addElement('header', get_lang('MakeLink')); |
|
81 | + $select = $this->addElement( |
|
82 | + 'select', |
|
83 | + 'select_link', |
|
84 | + get_lang('ChooseLink'), |
|
85 | + null, |
|
86 | + array('onchange' => 'document.create_link.submit()') |
|
87 | + ); |
|
88 | 88 | |
89 | - $linkTypes = LinkFactory::get_all_types(); |
|
89 | + $linkTypes = LinkFactory::get_all_types(); |
|
90 | 90 | |
91 | - $select->addoption('['.get_lang('ChooseLink').']', 0); |
|
91 | + $select->addoption('['.get_lang('ChooseLink').']', 0); |
|
92 | 92 | |
93 | - $courseCode = $this->category_object->get_course_code(); |
|
93 | + $courseCode = $this->category_object->get_course_code(); |
|
94 | 94 | |
95 | - foreach ($linkTypes as $linkType) { |
|
96 | - // The hot potatoe link will be added "inside" the exercise option. |
|
97 | - if ($linkType == LINK_HOTPOTATOES) { |
|
98 | - continue; |
|
99 | - } |
|
100 | - $link = $this->createLink($linkType, $courseCode); |
|
101 | - // disable this element if the link works with a dropdownlist |
|
102 | - // and if there are no links left |
|
103 | - if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') { |
|
104 | - $select->addoption($link->get_type_name(), $linkType, 'disabled'); |
|
105 | - } else { |
|
106 | - if ($link->get_type() == LINK_EXERCISE) { |
|
107 | - // Adding exercise |
|
108 | - $select->addoption($link->get_type_name(), $linkType); |
|
109 | - // Adding hot potatoes |
|
110 | - $linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode); |
|
111 | - $select->addoption( |
|
112 | - ' '.$linkHot->get_type_name(), |
|
113 | - LINK_HOTPOTATOES |
|
114 | - ); |
|
115 | - } else { |
|
116 | - $select->addoption($link->get_type_name(), $linkType); |
|
117 | - } |
|
118 | - } |
|
119 | - } |
|
95 | + foreach ($linkTypes as $linkType) { |
|
96 | + // The hot potatoe link will be added "inside" the exercise option. |
|
97 | + if ($linkType == LINK_HOTPOTATOES) { |
|
98 | + continue; |
|
99 | + } |
|
100 | + $link = $this->createLink($linkType, $courseCode); |
|
101 | + // disable this element if the link works with a dropdownlist |
|
102 | + // and if there are no links left |
|
103 | + if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') { |
|
104 | + $select->addoption($link->get_type_name(), $linkType, 'disabled'); |
|
105 | + } else { |
|
106 | + if ($link->get_type() == LINK_EXERCISE) { |
|
107 | + // Adding exercise |
|
108 | + $select->addoption($link->get_type_name(), $linkType); |
|
109 | + // Adding hot potatoes |
|
110 | + $linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode); |
|
111 | + $select->addoption( |
|
112 | + ' '.$linkHot->get_type_name(), |
|
113 | + LINK_HOTPOTATOES |
|
114 | + ); |
|
115 | + } else { |
|
116 | + $select->addoption($link->get_type_name(), $linkType); |
|
117 | + } |
|
118 | + } |
|
119 | + } |
|
120 | 120 | |
121 | - if (isset($this->extra)) { |
|
122 | - $this->setDefaults(array('select_link' => $this->extra)); |
|
123 | - } |
|
124 | - } |
|
121 | + if (isset($this->extra)) { |
|
122 | + $this->setDefaults(array('select_link' => $this->extra)); |
|
123 | + } |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * @param integer $link |
|
128 | - * @param null|string $courseCode |
|
129 | - * @return AttendanceLink|DropboxLink|ExerciseLink|ForumThreadLink|LearnpathLink|null|StudentPublicationLink|SurveyLink |
|
130 | - */ |
|
131 | - private function createLink($link, $courseCode) |
|
132 | - { |
|
133 | - $link = LinkFactory::create($link); |
|
134 | - if (!empty($courseCode)) { |
|
135 | - $link->set_course_code($courseCode); |
|
136 | - } elseif(!empty($_GET['course_code'])) { |
|
137 | - $link->set_course_code(Database::escape_string($_GET['course_code'], null, false)); |
|
138 | - } |
|
126 | + /** |
|
127 | + * @param integer $link |
|
128 | + * @param null|string $courseCode |
|
129 | + * @return AttendanceLink|DropboxLink|ExerciseLink|ForumThreadLink|LearnpathLink|null|StudentPublicationLink|SurveyLink |
|
130 | + */ |
|
131 | + private function createLink($link, $courseCode) |
|
132 | + { |
|
133 | + $link = LinkFactory::create($link); |
|
134 | + if (!empty($courseCode)) { |
|
135 | + $link->set_course_code($courseCode); |
|
136 | + } elseif(!empty($_GET['course_code'])) { |
|
137 | + $link->set_course_code(Database::escape_string($_GET['course_code'], null, false)); |
|
138 | + } |
|
139 | 139 | |
140 | - return $link; |
|
141 | - } |
|
140 | + return $link; |
|
141 | + } |
|
142 | 142 | } |
@@ -10,54 +10,54 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class ForumThreadLink extends AbstractLink |
12 | 12 | { |
13 | - private $forum_thread_table = null; |
|
14 | - private $itemprop_table = null; |
|
15 | - |
|
16 | - /** |
|
17 | - * Constructor |
|
18 | - */ |
|
19 | - public function __construct() |
|
20 | - { |
|
21 | - parent::__construct(); |
|
22 | - $this->set_type(LINK_FORUM_THREAD); |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function get_type_name() |
|
29 | - { |
|
30 | - return get_lang('ForumThreads'); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * @return bool |
|
35 | - */ |
|
36 | - public function is_allowed_to_change_name() |
|
37 | - { |
|
38 | - return false; |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * Generate an array of exercises that a teacher hasn't created a link for. |
|
43 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
44 | - */ |
|
45 | - public function get_not_created_links() |
|
46 | - { |
|
47 | - if (empty($this->course_code)) { |
|
48 | - die('Error in get_not_created_links() : course code not set'); |
|
49 | - } |
|
50 | - |
|
51 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
52 | - |
|
53 | - $sql = 'SELECT thread_id,thread_title,thread_title_qualify FROM '.$this->get_forum_thread_table() |
|
54 | - .' forum_thread WHERE thread_id NOT IN' |
|
55 | - .' (SELECT ref_id FROM '.$tbl_grade_links |
|
56 | - .' WHERE type = '.LINK_FORUM_THREAD |
|
57 | - ." AND c_id = ".intval($this->course_id) |
|
58 | - .') AND forum_thread.session_id='.api_get_session_id().''; |
|
59 | - |
|
60 | - $result = Database::query($sql); |
|
13 | + private $forum_thread_table = null; |
|
14 | + private $itemprop_table = null; |
|
15 | + |
|
16 | + /** |
|
17 | + * Constructor |
|
18 | + */ |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + parent::__construct(); |
|
22 | + $this->set_type(LINK_FORUM_THREAD); |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function get_type_name() |
|
29 | + { |
|
30 | + return get_lang('ForumThreads'); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * @return bool |
|
35 | + */ |
|
36 | + public function is_allowed_to_change_name() |
|
37 | + { |
|
38 | + return false; |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * Generate an array of exercises that a teacher hasn't created a link for. |
|
43 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
44 | + */ |
|
45 | + public function get_not_created_links() |
|
46 | + { |
|
47 | + if (empty($this->course_code)) { |
|
48 | + die('Error in get_not_created_links() : course code not set'); |
|
49 | + } |
|
50 | + |
|
51 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
52 | + |
|
53 | + $sql = 'SELECT thread_id,thread_title,thread_title_qualify FROM '.$this->get_forum_thread_table() |
|
54 | + .' forum_thread WHERE thread_id NOT IN' |
|
55 | + .' (SELECT ref_id FROM '.$tbl_grade_links |
|
56 | + .' WHERE type = '.LINK_FORUM_THREAD |
|
57 | + ." AND c_id = ".intval($this->course_id) |
|
58 | + .') AND forum_thread.session_id='.api_get_session_id().''; |
|
59 | + |
|
60 | + $result = Database::query($sql); |
|
61 | 61 | |
62 | 62 | $cats = array(); |
63 | 63 | while ($data = Database::fetch_array($result)) { |
@@ -72,29 +72,29 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | return $cats; |
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Generate an array of all exercises available. |
|
79 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
80 | - */ |
|
81 | - public function get_all_links() |
|
82 | - { |
|
83 | - if (empty($this->course_code)) { |
|
84 | - die('Error in get_not_created_links() : course code not set'); |
|
85 | - } |
|
86 | - |
|
87 | - $tbl_grade_links = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
88 | - $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
89 | - $session_id = api_get_session_id(); |
|
90 | - |
|
91 | - if ($session_id) { |
|
92 | - $session_condition = 'tl.session_id='.api_get_session_id(); |
|
93 | - } else { |
|
94 | - $session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)'; |
|
95 | - } |
|
96 | - |
|
97 | - $sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Generate an array of all exercises available. |
|
79 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
80 | + */ |
|
81 | + public function get_all_links() |
|
82 | + { |
|
83 | + if (empty($this->course_code)) { |
|
84 | + die('Error in get_not_created_links() : course code not set'); |
|
85 | + } |
|
86 | + |
|
87 | + $tbl_grade_links = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
88 | + $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
89 | + $session_id = api_get_session_id(); |
|
90 | + |
|
91 | + if ($session_id) { |
|
92 | + $session_condition = 'tl.session_id='.api_get_session_id(); |
|
93 | + } else { |
|
94 | + $session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)'; |
|
95 | + } |
|
96 | + |
|
97 | + $sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify |
|
98 | 98 | FROM '.$tbl_grade_links.' tl INNER JOIN '.$tbl_item_property.' ip |
99 | 99 | ON (tl.thread_id = ip.ref AND tl.c_id = ip.c_id ) |
100 | 100 | WHERE |
@@ -105,24 +105,24 @@ discard block |
||
105 | 105 | '.$session_condition.' |
106 | 106 | '; |
107 | 107 | |
108 | - $result = Database::query($sql); |
|
108 | + $result = Database::query($sql); |
|
109 | 109 | |
110 | - while ($data = Database::fetch_array($result)) { |
|
111 | - if ( isset($data['thread_title_qualify']) and $data['thread_title_qualify']!=""){ |
|
112 | - $cats[] = array ($data['thread_id'], $data['thread_title_qualify']); |
|
113 | - } else { |
|
114 | - $cats[] = array ($data['thread_id'], $data['thread_title']); |
|
115 | - } |
|
116 | - } |
|
117 | - $my_cats = isset($cats) ? $cats : null; |
|
110 | + while ($data = Database::fetch_array($result)) { |
|
111 | + if ( isset($data['thread_title_qualify']) and $data['thread_title_qualify']!=""){ |
|
112 | + $cats[] = array ($data['thread_id'], $data['thread_title_qualify']); |
|
113 | + } else { |
|
114 | + $cats[] = array ($data['thread_id'], $data['thread_title']); |
|
115 | + } |
|
116 | + } |
|
117 | + $my_cats = isset($cats) ? $cats : null; |
|
118 | 118 | |
119 | - return $my_cats; |
|
120 | - } |
|
119 | + return $my_cats; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | /** |
123 | - * Has anyone done this exercise yet ? |
|
124 | - * @return boolean |
|
125 | - */ |
|
123 | + * Has anyone done this exercise yet ? |
|
124 | + * @return boolean |
|
125 | + */ |
|
126 | 126 | public function has_results() |
127 | 127 | { |
128 | 128 | $table = Database :: get_course_table(TABLE_FORUM_POST); |
@@ -134,40 +134,40 @@ discard block |
||
134 | 134 | $number = Database::fetch_row($result); |
135 | 135 | |
136 | 136 | return $number[0] != 0; |
137 | - } |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * @param int $stud_id |
|
139 | + /** |
|
140 | + * @param int $stud_id |
|
141 | 141 | * @param string $type |
142 | 142 | * |
143 | - * @return array|null |
|
144 | - */ |
|
145 | - public function calc_score($stud_id = null, $type = null) |
|
146 | - { |
|
143 | + * @return array|null |
|
144 | + */ |
|
145 | + public function calc_score($stud_id = null, $type = null) |
|
146 | + { |
|
147 | 147 | require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php'; |
148 | 148 | $threadInfo = get_thread_information($this->get_ref_id()); |
149 | 149 | |
150 | - $thread_qualify = Database :: get_course_table(TABLE_FORUM_THREAD_QUALIFY); |
|
150 | + $thread_qualify = Database :: get_course_table(TABLE_FORUM_THREAD_QUALIFY); |
|
151 | 151 | |
152 | - $sql = 'SELECT thread_qualify_max |
|
152 | + $sql = 'SELECT thread_qualify_max |
|
153 | 153 | FROM '.Database :: get_course_table(TABLE_FORUM_THREAD)." |
154 | 154 | WHERE c_id = ".$this->course_id." AND thread_id = '".$this->get_ref_id()."'"; |
155 | - $query = Database::query($sql); |
|
156 | - $assignment = Database::fetch_array($query); |
|
155 | + $query = Database::query($sql); |
|
156 | + $assignment = Database::fetch_array($query); |
|
157 | 157 | |
158 | - $sql = "SELECT * FROM $thread_qualify |
|
158 | + $sql = "SELECT * FROM $thread_qualify |
|
159 | 159 | WHERE c_id = ".$this->course_id." AND thread_id = ".$this->get_ref_id(); |
160 | - if (isset($stud_id)) { |
|
161 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
162 | - } |
|
160 | + if (isset($stud_id)) { |
|
161 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
162 | + } |
|
163 | 163 | |
164 | - // order by id, that way the student's first attempt is accessed first |
|
165 | - $sql .= ' ORDER BY qualify_time DESC'; |
|
164 | + // order by id, that way the student's first attempt is accessed first |
|
165 | + $sql .= ' ORDER BY qualify_time DESC'; |
|
166 | 166 | |
167 | - $scores = Database::query($sql); |
|
167 | + $scores = Database::query($sql); |
|
168 | 168 | |
169 | - // for 1 student |
|
170 | - if (isset($stud_id)) { |
|
169 | + // for 1 student |
|
170 | + if (isset($stud_id)) { |
|
171 | 171 | if ($threadInfo['thread_peer_qualify'] == 0) { |
172 | 172 | // Classic way of calculate score |
173 | 173 | if ($data = Database::fetch_array($scores)) { |
@@ -195,175 +195,175 @@ discard block |
||
195 | 195 | } |
196 | 196 | return [$score/$counter, $assignment['thread_qualify_max']]; |
197 | 197 | } |
198 | - } else { |
|
199 | - // All students -> get average |
|
200 | - $students = array(); // user list, needed to make sure we only |
|
201 | - // take first attempts into account |
|
202 | - $counter = 0; |
|
203 | - $sum = 0; |
|
204 | - $bestResult = 0; |
|
205 | - $weight = 0; |
|
206 | - $sumResult = 0; |
|
207 | - |
|
208 | - while ($data = Database::fetch_array($scores)) { |
|
209 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
210 | - if ($assignment['thread_qualify_max'] != 0) { |
|
211 | - $students[$data['user_id']] = $data['qualify']; |
|
212 | - $counter++; |
|
213 | - $sum += $data['qualify'] / $assignment['thread_qualify_max']; |
|
214 | - $sumResult += $data['qualify']; |
|
215 | - if ($data['qualify'] > $bestResult) { |
|
216 | - $bestResult = $data['qualify']; |
|
217 | - } |
|
218 | - $weight = $assignment['thread_qualify_max']; |
|
219 | - } |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - if ($counter == 0) { |
|
224 | - return null; |
|
225 | - } else { |
|
226 | - switch ($type) { |
|
227 | - case 'best': |
|
228 | - return array($bestResult, $weight); |
|
229 | - break; |
|
230 | - case 'average': |
|
231 | - return array($sumResult/$counter, $weight); |
|
232 | - break; |
|
233 | - case 'ranking': |
|
234 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
235 | - break; |
|
236 | - default: |
|
237 | - return array($sum, $counter); |
|
238 | - break; |
|
239 | - } |
|
240 | - } |
|
241 | - } |
|
242 | - } |
|
243 | - |
|
244 | - /** |
|
245 | - * Lazy load function to get the database table of the student publications |
|
246 | - */ |
|
247 | - private function get_forum_thread_table() |
|
248 | - { |
|
249 | - return $this->forum_thread_table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
250 | - } |
|
251 | - |
|
252 | - public function needs_name_and_description() |
|
253 | - { |
|
254 | - return false; |
|
255 | - } |
|
256 | - |
|
257 | - public function needs_max() |
|
258 | - { |
|
259 | - return false; |
|
260 | - } |
|
261 | - |
|
262 | - public function needs_results() |
|
263 | - { |
|
264 | - return false; |
|
265 | - } |
|
198 | + } else { |
|
199 | + // All students -> get average |
|
200 | + $students = array(); // user list, needed to make sure we only |
|
201 | + // take first attempts into account |
|
202 | + $counter = 0; |
|
203 | + $sum = 0; |
|
204 | + $bestResult = 0; |
|
205 | + $weight = 0; |
|
206 | + $sumResult = 0; |
|
207 | + |
|
208 | + while ($data = Database::fetch_array($scores)) { |
|
209 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
210 | + if ($assignment['thread_qualify_max'] != 0) { |
|
211 | + $students[$data['user_id']] = $data['qualify']; |
|
212 | + $counter++; |
|
213 | + $sum += $data['qualify'] / $assignment['thread_qualify_max']; |
|
214 | + $sumResult += $data['qualify']; |
|
215 | + if ($data['qualify'] > $bestResult) { |
|
216 | + $bestResult = $data['qualify']; |
|
217 | + } |
|
218 | + $weight = $assignment['thread_qualify_max']; |
|
219 | + } |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + if ($counter == 0) { |
|
224 | + return null; |
|
225 | + } else { |
|
226 | + switch ($type) { |
|
227 | + case 'best': |
|
228 | + return array($bestResult, $weight); |
|
229 | + break; |
|
230 | + case 'average': |
|
231 | + return array($sumResult/$counter, $weight); |
|
232 | + break; |
|
233 | + case 'ranking': |
|
234 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
235 | + break; |
|
236 | + default: |
|
237 | + return array($sum, $counter); |
|
238 | + break; |
|
239 | + } |
|
240 | + } |
|
241 | + } |
|
242 | + } |
|
243 | + |
|
244 | + /** |
|
245 | + * Lazy load function to get the database table of the student publications |
|
246 | + */ |
|
247 | + private function get_forum_thread_table() |
|
248 | + { |
|
249 | + return $this->forum_thread_table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
250 | + } |
|
251 | + |
|
252 | + public function needs_name_and_description() |
|
253 | + { |
|
254 | + return false; |
|
255 | + } |
|
256 | + |
|
257 | + public function needs_max() |
|
258 | + { |
|
259 | + return false; |
|
260 | + } |
|
261 | + |
|
262 | + public function needs_results() |
|
263 | + { |
|
264 | + return false; |
|
265 | + } |
|
266 | 266 | |
267 | 267 | /** |
268 | 268 | * @return string |
269 | 269 | */ |
270 | - public function get_name() |
|
271 | - { |
|
272 | - $this->get_exercise_data(); |
|
273 | - $thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : ''; |
|
274 | - $thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : ''; |
|
275 | - if ( isset($thread_title_qualify) && $thread_title_qualify!="") { |
|
276 | - return $this->exercise_data['thread_title_qualify']; |
|
277 | - } else { |
|
278 | - return $thread_title; |
|
279 | - } |
|
280 | - } |
|
270 | + public function get_name() |
|
271 | + { |
|
272 | + $this->get_exercise_data(); |
|
273 | + $thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : ''; |
|
274 | + $thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : ''; |
|
275 | + if ( isset($thread_title_qualify) && $thread_title_qualify!="") { |
|
276 | + return $this->exercise_data['thread_title_qualify']; |
|
277 | + } else { |
|
278 | + return $thread_title; |
|
279 | + } |
|
280 | + } |
|
281 | 281 | |
282 | 282 | /** |
283 | 283 | * @return string |
284 | 284 | */ |
285 | - public function get_description() |
|
286 | - { |
|
287 | - return '';//$this->exercise_data['description']; |
|
288 | - } |
|
289 | - |
|
290 | - /** |
|
291 | - * Check if this still links to an exercise |
|
292 | - */ |
|
293 | - public function is_valid_link() |
|
294 | - { |
|
295 | - $sql = 'SELECT count(id) from '.$this->get_forum_thread_table().' |
|
285 | + public function get_description() |
|
286 | + { |
|
287 | + return '';//$this->exercise_data['description']; |
|
288 | + } |
|
289 | + |
|
290 | + /** |
|
291 | + * Check if this still links to an exercise |
|
292 | + */ |
|
293 | + public function is_valid_link() |
|
294 | + { |
|
295 | + $sql = 'SELECT count(id) from '.$this->get_forum_thread_table().' |
|
296 | 296 | WHERE c_id = '.$this->course_id.' AND thread_id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().''; |
297 | - $result = Database::query($sql); |
|
298 | - $number = Database::fetch_row($result); |
|
299 | - return ($number[0] != 0); |
|
300 | - } |
|
301 | - |
|
302 | - public function get_test_id() |
|
303 | - { |
|
304 | - return 'DEBUG:ID'; |
|
305 | - } |
|
306 | - |
|
307 | - public function get_link() |
|
308 | - { |
|
309 | - $sessionId = api_get_session_id(); |
|
310 | - //it was extracts the forum id |
|
311 | - $sql = 'SELECT * FROM '.$this->get_forum_thread_table()." |
|
297 | + $result = Database::query($sql); |
|
298 | + $number = Database::fetch_row($result); |
|
299 | + return ($number[0] != 0); |
|
300 | + } |
|
301 | + |
|
302 | + public function get_test_id() |
|
303 | + { |
|
304 | + return 'DEBUG:ID'; |
|
305 | + } |
|
306 | + |
|
307 | + public function get_link() |
|
308 | + { |
|
309 | + $sessionId = api_get_session_id(); |
|
310 | + //it was extracts the forum id |
|
311 | + $sql = 'SELECT * FROM '.$this->get_forum_thread_table()." |
|
312 | 312 | WHERE c_id = '.$this->course_id.' AND thread_id = '".$this->get_ref_id()."' AND session_id = ".$sessionId.""; |
313 | - $result = Database::query($sql); |
|
314 | - $row = Database::fetch_array($result,'ASSOC'); |
|
315 | - $forum_id=$row['forum_id']; |
|
316 | - |
|
317 | - $url = api_get_path(WEB_PATH).'main/forum/viewthread.php?'.api_get_cidreq_params($this->get_course_code(), $sessionId).'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id; |
|
318 | - return $url; |
|
319 | - } |
|
320 | - |
|
321 | - private function get_exercise_data() |
|
322 | - { |
|
323 | - $session_id = api_get_session_id(); |
|
324 | - if ($session_id) { |
|
325 | - $session_condition = 'session_id='.api_get_session_id(); |
|
326 | - } else { |
|
327 | - $session_condition = '(session_id = 0 OR session_id IS NULL)'; |
|
328 | - } |
|
329 | - |
|
330 | - if (!isset($this->exercise_data)) { |
|
331 | - $sql = 'SELECT * FROM '.$this->get_forum_thread_table().' |
|
313 | + $result = Database::query($sql); |
|
314 | + $row = Database::fetch_array($result,'ASSOC'); |
|
315 | + $forum_id=$row['forum_id']; |
|
316 | + |
|
317 | + $url = api_get_path(WEB_PATH).'main/forum/viewthread.php?'.api_get_cidreq_params($this->get_course_code(), $sessionId).'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id; |
|
318 | + return $url; |
|
319 | + } |
|
320 | + |
|
321 | + private function get_exercise_data() |
|
322 | + { |
|
323 | + $session_id = api_get_session_id(); |
|
324 | + if ($session_id) { |
|
325 | + $session_condition = 'session_id='.api_get_session_id(); |
|
326 | + } else { |
|
327 | + $session_condition = '(session_id = 0 OR session_id IS NULL)'; |
|
328 | + } |
|
329 | + |
|
330 | + if (!isset($this->exercise_data)) { |
|
331 | + $sql = 'SELECT * FROM '.$this->get_forum_thread_table().' |
|
332 | 332 | WHERE c_id = '.$this->course_id.' AND thread_id = '.$this->get_ref_id().' AND '.$session_condition; |
333 | - $query = Database::query($sql); |
|
334 | - $this->exercise_data = Database::fetch_array($query); |
|
335 | - } |
|
336 | - return $this->exercise_data; |
|
337 | - } |
|
338 | - |
|
339 | - public function get_icon_name() |
|
340 | - { |
|
341 | - return 'forum'; |
|
342 | - } |
|
343 | - |
|
344 | - function save_linked_data() |
|
345 | - { |
|
346 | - $weight = (float)$this->get_weight(); |
|
347 | - $ref_id = $this->get_ref_id(); |
|
348 | - |
|
349 | - if (!empty($ref_id)) { |
|
350 | - $sql = 'UPDATE '.$this->get_forum_thread_table().' SET thread_weight='.$weight.' |
|
333 | + $query = Database::query($sql); |
|
334 | + $this->exercise_data = Database::fetch_array($query); |
|
335 | + } |
|
336 | + return $this->exercise_data; |
|
337 | + } |
|
338 | + |
|
339 | + public function get_icon_name() |
|
340 | + { |
|
341 | + return 'forum'; |
|
342 | + } |
|
343 | + |
|
344 | + function save_linked_data() |
|
345 | + { |
|
346 | + $weight = (float)$this->get_weight(); |
|
347 | + $ref_id = $this->get_ref_id(); |
|
348 | + |
|
349 | + if (!empty($ref_id)) { |
|
350 | + $sql = 'UPDATE '.$this->get_forum_thread_table().' SET thread_weight='.$weight.' |
|
351 | 351 | WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id; |
352 | - Database::query($sql); |
|
353 | - } |
|
354 | - } |
|
355 | - |
|
356 | - function delete_linked_data() |
|
357 | - { |
|
358 | - $ref_id = $this->get_ref_id(); |
|
359 | - if (!empty($ref_id)) { |
|
360 | - //Cleans forum |
|
361 | - $sql = 'UPDATE '.$this->get_forum_thread_table().' SET |
|
352 | + Database::query($sql); |
|
353 | + } |
|
354 | + } |
|
355 | + |
|
356 | + function delete_linked_data() |
|
357 | + { |
|
358 | + $ref_id = $this->get_ref_id(); |
|
359 | + if (!empty($ref_id)) { |
|
360 | + //Cleans forum |
|
361 | + $sql = 'UPDATE '.$this->get_forum_thread_table().' SET |
|
362 | 362 | thread_qualify_max = 0, |
363 | 363 | thread_weight = 0, |
364 | 364 | thread_title_qualify = "" |
365 | 365 | WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id; |
366 | - Database::query($sql); |
|
367 | - } |
|
368 | - } |
|
366 | + Database::query($sql); |
|
367 | + } |
|
368 | + } |
|
369 | 369 | } |
@@ -399,10 +399,10 @@ |
||
399 | 399 | if(count($_plugins['menu_administrator']) > 0) { |
400 | 400 | $blocks['plugins']['icon'] = Display::return_icon( |
401 | 401 | 'plugins.png', |
402 | - get_lang('Plugins'), |
|
403 | - array(), |
|
404 | - ICON_SIZE_MEDIUM, |
|
405 | - false |
|
402 | + get_lang('Plugins'), |
|
403 | + array(), |
|
404 | + ICON_SIZE_MEDIUM, |
|
405 | + false |
|
406 | 406 | ); |
407 | 407 | $blocks['plugins']['label'] = api_ucfirst(get_lang('Plugins')); |
408 | 408 | $blocks['plugins']['class'] = 'block-admin-platform'; |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | // Coach can't view this page |
21 | 21 | $extend_rights_for_coachs = api_get_setting('extend_rights_for_coach_on_survey'); |
22 | 22 | $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh( |
23 | - api_get_user_id(), |
|
24 | - api_get_course_info() |
|
23 | + api_get_user_id(), |
|
24 | + api_get_course_info() |
|
25 | 25 | ); |
26 | 26 | |
27 | 27 | if ($isDrhOfCourse) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | (api_is_course_coach() && $extend_rights_for_coachs == 'false') |
33 | 33 | ) { |
34 | 34 | api_not_allowed(true); |
35 | - exit; |
|
35 | + exit; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // Database table definitions |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | |
50 | 50 | // Breadcrumbs |
51 | 51 | $interbreadcrumb[] = array( |
52 | - 'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', |
|
53 | - 'name' => get_lang('SurveyList'), |
|
52 | + 'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', |
|
53 | + 'name' => get_lang('SurveyList'), |
|
54 | 54 | ); |
55 | 55 | |
56 | 56 | // Getting the survey information |
57 | 57 | if (!empty($_GET['survey_id'])) { |
58 | - $course_code = api_get_course_id(); |
|
59 | - if ($course_code!=-1) { |
|
60 | - $survey_data = SurveyManager::get_survey($survey_id); |
|
61 | - } else { |
|
62 | - Display :: display_header(get_lang('ToolSurvey')); |
|
63 | - Display :: display_error_message(get_lang('NotAllowed'), false); |
|
64 | - Display :: display_footer(); |
|
65 | - exit; |
|
66 | - } |
|
58 | + $course_code = api_get_course_id(); |
|
59 | + if ($course_code!=-1) { |
|
60 | + $survey_data = SurveyManager::get_survey($survey_id); |
|
61 | + } else { |
|
62 | + Display :: display_header(get_lang('ToolSurvey')); |
|
63 | + Display :: display_error_message(get_lang('NotAllowed'), false); |
|
64 | + Display :: display_footer(); |
|
65 | + exit; |
|
66 | + } |
|
67 | 67 | } else { |
68 | 68 | Display :: display_header(get_lang('ToolSurvey')); |
69 | 69 | Display :: display_error_message(get_lang('NotAllowed'), false); |
@@ -76,30 +76,30 @@ discard block |
||
76 | 76 | $is_survey_type_1 = $survey_data['survey_type'] == 1; |
77 | 77 | |
78 | 78 | if (api_strlen(strip_tags($survey_data['title'])) > 40) { |
79 | - $tool_name .= '...'; |
|
79 | + $tool_name .= '...'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | if ($is_survey_type_1 && ($action == 'addgroup' || $action == 'deletegroup')) { |
83 | - $_POST['name'] = trim($_POST['name']); |
|
84 | - if ($action == 'addgroup') { |
|
85 | - if (!empty($_POST['group_id'])) { |
|
86 | - Database::query('UPDATE '.$table_survey_question_group.' SET description = \''.Database::escape_string($_POST['description']).'\' |
|
83 | + $_POST['name'] = trim($_POST['name']); |
|
84 | + if ($action == 'addgroup') { |
|
85 | + if (!empty($_POST['group_id'])) { |
|
86 | + Database::query('UPDATE '.$table_survey_question_group.' SET description = \''.Database::escape_string($_POST['description']).'\' |
|
87 | 87 | WHERE c_id = '.$course_id.' AND id = \''.Database::escape_string($_POST['group_id']).'\''); |
88 | - $sendmsg = 'GroupUpdatedSuccessfully'; |
|
89 | - } elseif(!empty($_POST['name'])) { |
|
90 | - Database::query('INSERT INTO '.$table_survey_question_group.' (c_id, name,description,survey_id) values ('.$course_id.', \''.Database::escape_string($_POST['name']).'\',\''.Database::escape_string($_POST['description']).'\',\''.Database::escape_string($survey_id).'\') '); |
|
91 | - $sendmsg = 'GroupCreatedSuccessfully'; |
|
92 | - } else { |
|
93 | - $sendmsg = 'GroupNeedName'; |
|
94 | - } |
|
95 | - } |
|
96 | - |
|
97 | - if ($action == 'deletegroup') { |
|
98 | - Database::query('DELETE FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND id = '.intval($_GET['gid']).' and survey_id = '.intval($survey_id)); |
|
99 | - $sendmsg = 'GroupDeletedSuccessfully'; |
|
100 | - } |
|
101 | - header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&sendmsg='.$sendmsg); |
|
102 | - exit; |
|
88 | + $sendmsg = 'GroupUpdatedSuccessfully'; |
|
89 | + } elseif(!empty($_POST['name'])) { |
|
90 | + Database::query('INSERT INTO '.$table_survey_question_group.' (c_id, name,description,survey_id) values ('.$course_id.', \''.Database::escape_string($_POST['name']).'\',\''.Database::escape_string($_POST['description']).'\',\''.Database::escape_string($survey_id).'\') '); |
|
91 | + $sendmsg = 'GroupCreatedSuccessfully'; |
|
92 | + } else { |
|
93 | + $sendmsg = 'GroupNeedName'; |
|
94 | + } |
|
95 | + } |
|
96 | + |
|
97 | + if ($action == 'deletegroup') { |
|
98 | + Database::query('DELETE FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND id = '.intval($_GET['gid']).' and survey_id = '.intval($survey_id)); |
|
99 | + $sendmsg = 'GroupDeletedSuccessfully'; |
|
100 | + } |
|
101 | + header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&sendmsg='.$sendmsg); |
|
102 | + exit; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | // Displaying the header |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | $message_information = isset($_GET['message']) ? Security::remove_XSS($_GET['message']) : null; |
114 | 114 | |
115 | 115 | if (isset($action)) { |
116 | - if (($action == 'moveup' || $action == 'movedown') && isset($_GET['question_id'])) { |
|
117 | - SurveyManager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey); |
|
118 | - Display::display_confirmation_message(get_lang('SurveyQuestionMoved')); |
|
119 | - } |
|
120 | - if ($action == 'delete' AND is_numeric($_GET['question_id'])) { |
|
121 | - SurveyManager::delete_survey_question($my_survey_id_survey, $my_question_id_survey, $survey_data['is_shared']); |
|
122 | - } |
|
116 | + if (($action == 'moveup' || $action == 'movedown') && isset($_GET['question_id'])) { |
|
117 | + SurveyManager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey); |
|
118 | + Display::display_confirmation_message(get_lang('SurveyQuestionMoved')); |
|
119 | + } |
|
120 | + if ($action == 'delete' AND is_numeric($_GET['question_id'])) { |
|
121 | + SurveyManager::delete_survey_question($my_survey_id_survey, $my_question_id_survey, $survey_data['is_shared']); |
|
122 | + } |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | if (!empty($survey_data['survey_version'])) echo '<b>'.get_lang('Version').': '.$survey_data['survey_version'].'</b>'; |
@@ -137,26 +137,26 @@ discard block |
||
137 | 137 | echo '<div class="actions">'.$survey_actions.'</div>'; |
138 | 138 | |
139 | 139 | if ($survey_data['survey_type'] == 0) { |
140 | - echo '<div class="panel panel-default">'; |
|
140 | + echo '<div class="panel panel-default">'; |
|
141 | 141 | echo '<div class="panel-body">'; |
142 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=yesno&survey_id='.$survey_id.'">'.Display::return_icon('yesno.png', get_lang('YesNo'), null, ICON_SIZE_BIG).'</a>'; |
|
143 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=multiplechoice&survey_id='.$survey_id.'">'.Display::return_icon('mcua.png', get_lang('UniqueSelect'), null, ICON_SIZE_BIG).'</a>'; |
|
144 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=multipleresponse&survey_id='.$survey_id.'">'.Display::return_icon('mcma.png', get_lang('MultipleResponse'), null, ICON_SIZE_BIG).'</a>'; |
|
145 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=open&survey_id='.$survey_id.'">'.Display::return_icon('open_answer.png', get_lang('Open'), null, ICON_SIZE_BIG).'</a>'; |
|
146 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=dropdown&survey_id='.$survey_id.'">'.Display::return_icon('dropdown.png', get_lang('Dropdown'), null, ICON_SIZE_BIG).'</a>'; |
|
147 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=percentage&survey_id='.$survey_id.'">'.Display::return_icon('percentagequestion.png', get_lang('Percentage'), null, ICON_SIZE_BIG).'</a>'; |
|
148 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=score&survey_id='.$survey_id.'">'.Display::return_icon('scorequestion.png', get_lang('Score'), null, ICON_SIZE_BIG).'</a>'; |
|
149 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=comment&survey_id='.$survey_id.'">'.Display::return_icon('commentquestion.png', get_lang('Comment'), null, ICON_SIZE_BIG).'</a>'; |
|
150 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=pagebreak&survey_id='.$survey_id.'">'.Display::return_icon('page_end.png', get_lang('Pagebreak'), null, ICON_SIZE_BIG).'</a>'; |
|
151 | - echo '</div>'; |
|
142 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=yesno&survey_id='.$survey_id.'">'.Display::return_icon('yesno.png', get_lang('YesNo'), null, ICON_SIZE_BIG).'</a>'; |
|
143 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=multiplechoice&survey_id='.$survey_id.'">'.Display::return_icon('mcua.png', get_lang('UniqueSelect'), null, ICON_SIZE_BIG).'</a>'; |
|
144 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=multipleresponse&survey_id='.$survey_id.'">'.Display::return_icon('mcma.png', get_lang('MultipleResponse'), null, ICON_SIZE_BIG).'</a>'; |
|
145 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=open&survey_id='.$survey_id.'">'.Display::return_icon('open_answer.png', get_lang('Open'), null, ICON_SIZE_BIG).'</a>'; |
|
146 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=dropdown&survey_id='.$survey_id.'">'.Display::return_icon('dropdown.png', get_lang('Dropdown'), null, ICON_SIZE_BIG).'</a>'; |
|
147 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=percentage&survey_id='.$survey_id.'">'.Display::return_icon('percentagequestion.png', get_lang('Percentage'), null, ICON_SIZE_BIG).'</a>'; |
|
148 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=score&survey_id='.$survey_id.'">'.Display::return_icon('scorequestion.png', get_lang('Score'), null, ICON_SIZE_BIG).'</a>'; |
|
149 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=comment&survey_id='.$survey_id.'">'.Display::return_icon('commentquestion.png', get_lang('Comment'), null, ICON_SIZE_BIG).'</a>'; |
|
150 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=pagebreak&survey_id='.$survey_id.'">'.Display::return_icon('page_end.png', get_lang('Pagebreak'), null, ICON_SIZE_BIG).'</a>'; |
|
151 | + echo '</div>'; |
|
152 | 152 | echo '</div>'; |
153 | 153 | } else { |
154 | - echo '<div class="panel panel-default">'; |
|
154 | + echo '<div class="panel panel-default">'; |
|
155 | 155 | echo '<div class="panel-body">'; |
156 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=personality&survey_id='.$survey_id.'">'; |
|
157 | - echo Display::return_icon("yesno.png"); |
|
158 | - echo '</a></div>'; |
|
159 | - echo '</div>'; |
|
156 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=personality&survey_id='.$survey_id.'">'; |
|
157 | + echo Display::return_icon("yesno.png"); |
|
158 | + echo '</a></div>'; |
|
159 | + echo '</div>'; |
|
160 | 160 | echo '</div>'; |
161 | 161 | } |
162 | 162 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | echo ' <th width="50" >'.get_lang('NumberOfOptions').'</th>'; |
170 | 170 | echo ' <th width="100">'.get_lang('Modify').'</th>'; |
171 | 171 | if ($is_survey_type_1) { |
172 | - echo '<th width="100">'.get_lang('Condition').'</th>'; |
|
172 | + echo '<th width="100">'.get_lang('Condition').'</th>'; |
|
173 | 173 | echo '<th width="40">'.get_lang('Group').'</th>'; |
174 | 174 | } |
175 | 175 | echo ' </tr>'; |
@@ -196,97 +196,97 @@ discard block |
||
196 | 196 | $result = Database::query($sql); |
197 | 197 | $question_counter_max = Database::num_rows($result); |
198 | 198 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
199 | - echo '<tr>'; |
|
200 | - echo ' <td>'.$question_counter.'</td>'; |
|
201 | - echo ' <td>'; |
|
202 | - if (api_strlen($row['survey_question']) > 100) { |
|
203 | - echo api_substr(strip_tags($row['survey_question']), 0, 100).' ... '; |
|
204 | - } else { |
|
205 | - echo $row['survey_question']; |
|
206 | - } |
|
207 | - |
|
208 | - if ($row['type'] == 'yesno') { |
|
209 | - $tool_name = get_lang('YesNo'); |
|
210 | - } else if ($row['type'] == 'multiplechoice') { |
|
211 | - $tool_name = get_lang('UniqueSelect'); |
|
212 | - } else { |
|
213 | - $tool_name = get_lang(api_ucfirst(Security::remove_XSS($row['type']))); |
|
214 | - } |
|
215 | - |
|
216 | - echo '</td>'; |
|
217 | - echo ' <td>'.$tool_name.'</td>'; |
|
218 | - echo ' <td>'.$row['number_of_options'].'</td>'; |
|
219 | - echo ' <td>'; |
|
220 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=edit&type='.$row['type'].'&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'; |
|
221 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'&question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?',ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
|
222 | - if ($question_counter > 1) { |
|
223 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=moveup&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'),'',ICON_SIZE_SMALL).'</a>'; |
|
224 | - } else { |
|
225 | - Display::display_icon('up_na.png',' ','',ICON_SIZE_SMALL); |
|
226 | - } |
|
227 | - if ($question_counter < $question_counter_max) { |
|
228 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=movedown&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'),'',ICON_SIZE_SMALL).'</a>'; |
|
229 | - } else { |
|
230 | - Display::display_icon('down_na.png',' ','',ICON_SIZE_SMALL); |
|
231 | - } |
|
232 | - echo ' </td>'; |
|
233 | - $question_counter++; |
|
234 | - |
|
235 | - if ($is_survey_type_1) { |
|
236 | - echo '<td>'.(($row['survey_group_pri']==0)?get_lang('Secondary'):get_lang('Primary')).'</td>'; |
|
199 | + echo '<tr>'; |
|
200 | + echo ' <td>'.$question_counter.'</td>'; |
|
201 | + echo ' <td>'; |
|
202 | + if (api_strlen($row['survey_question']) > 100) { |
|
203 | + echo api_substr(strip_tags($row['survey_question']), 0, 100).' ... '; |
|
204 | + } else { |
|
205 | + echo $row['survey_question']; |
|
206 | + } |
|
207 | + |
|
208 | + if ($row['type'] == 'yesno') { |
|
209 | + $tool_name = get_lang('YesNo'); |
|
210 | + } else if ($row['type'] == 'multiplechoice') { |
|
211 | + $tool_name = get_lang('UniqueSelect'); |
|
212 | + } else { |
|
213 | + $tool_name = get_lang(api_ucfirst(Security::remove_XSS($row['type']))); |
|
214 | + } |
|
215 | + |
|
216 | + echo '</td>'; |
|
217 | + echo ' <td>'.$tool_name.'</td>'; |
|
218 | + echo ' <td>'.$row['number_of_options'].'</td>'; |
|
219 | + echo ' <td>'; |
|
220 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=edit&type='.$row['type'].'&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'; |
|
221 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'&question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?',ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
|
222 | + if ($question_counter > 1) { |
|
223 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=moveup&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'),'',ICON_SIZE_SMALL).'</a>'; |
|
224 | + } else { |
|
225 | + Display::display_icon('up_na.png',' ','',ICON_SIZE_SMALL); |
|
226 | + } |
|
227 | + if ($question_counter < $question_counter_max) { |
|
228 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=movedown&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'),'',ICON_SIZE_SMALL).'</a>'; |
|
229 | + } else { |
|
230 | + Display::display_icon('down_na.png',' ','',ICON_SIZE_SMALL); |
|
231 | + } |
|
232 | + echo ' </td>'; |
|
233 | + $question_counter++; |
|
234 | + |
|
235 | + if ($is_survey_type_1) { |
|
236 | + echo '<td>'.(($row['survey_group_pri']==0)?get_lang('Secondary'):get_lang('Primary')).'</td>'; |
|
237 | 237 | echo '<td>'.(($row['survey_group_pri']==0)?$groups[$row['survey_group_sec1']].'-'.$groups[$row['survey_group_sec2']]:$groups[$row['survey_group_pri']]).'</td>'; |
238 | 238 | } |
239 | - echo '</tr>'; |
|
239 | + echo '</tr>'; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | echo '</table>'; |
243 | 243 | |
244 | 244 | if ($is_survey_type_1) { |
245 | - echo '<br /><br /><b>'.get_lang('ManageGroups').'</b><br /><br />'; |
|
246 | - |
|
247 | - if (in_array($_GET['sendmsg'], array('GroupUpdatedSuccessfully', 'GroupDeletedSuccessfully', 'GroupCreatedSuccessfully'))) { |
|
248 | - echo Display::display_confirmation_message(get_lang($_GET['sendmsg']), false); |
|
249 | - } |
|
250 | - |
|
251 | - if (in_array($_GET['sendmsg'], array('GroupNeedName'))){ |
|
252 | - echo Display::display_warning_message(get_lang($_GET['sendmsg']), false); |
|
253 | - } |
|
254 | - echo '<table border="0"><tr><td width="100">'.get_lang('Name').'</td><td>'.get_lang('Description').'</td></tr></table>'; |
|
255 | - echo '<form action="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?action=addgroup&survey_id='.$survey_id.'" method="post">'; |
|
256 | - if ($_GET['action'] == 'editgroup') { |
|
257 | - $sql = 'SELECT name,description FROM '.$table_survey_question_group.' WHERE id = '.intval($_GET['gid']).' AND survey_id = '.intval($survey_id).' limit 1'; |
|
258 | - $rs = Database::query($sql); |
|
259 | - $editedrow = Database::fetch_array($rs,'ASSOC'); |
|
260 | - echo '<input type="text" maxlength="20" name="name" value="'.$editedrow['name'].'" size="10" disabled>'; |
|
261 | - echo '<input type="text" maxlength="150" name="description" value="'.$editedrow['description'].'" size="40">'; |
|
262 | - echo '<input type="hidden" name="group_id" value="'.Security::remove_XSS($_GET['gid']).'">'; |
|
263 | - echo '<input type="submit" value="'.get_lang('Save').'"'.'<input type="button" value="'.get_lang('Cancel').'" onclick="window.location.href = \'survey.php?survey_id='.Security::remove_XSS($survey_id).'\';" />'; |
|
264 | - } else { |
|
265 | - echo '<input type="text" maxlength="20" name="name" value="" size="10">'; |
|
266 | - echo '<input type="text" maxlength="250" name="description" value="" size="80">'; |
|
267 | - echo '<input type="submit" value="'.get_lang('Create').'"'; |
|
268 | - } |
|
269 | - echo '</form><br />'; |
|
270 | - |
|
271 | - echo '<table class="data_table">'; |
|
272 | - echo ' <tr class="row_odd">'; |
|
273 | - echo ' <th width="200">'.get_lang('Name').'</th>'; |
|
274 | - echo ' <th>'.get_lang('Description').'</th>'; |
|
275 | - echo ' <th width="100">'.get_lang('Modify').'</th>'; |
|
276 | - echo ' </tr>'; |
|
277 | - |
|
278 | - $sql = 'SELECT id,name,description FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND survey_id = '.intval($survey_id).' ORDER BY name'; |
|
279 | - |
|
280 | - $rs = Database::query($sql); |
|
281 | - while($row = Database::fetch_array($rs,ASSOC)){ |
|
282 | - $grouplist .= '<tr><td>'.$row['name'].'</td><td>'.$row['description'].'</td><td>'. |
|
283 | - '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=editgroup">'. |
|
284 | - Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> '. |
|
285 | - '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=deletegroup" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('DeleteSurveyGroup'),$row['name']).'?',ENT_QUOTES)).'\')) return false;">'. |
|
286 | - Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'. |
|
287 | - '</td></tr>'; |
|
288 | - } |
|
289 | - echo $grouplist.'</table>'; |
|
245 | + echo '<br /><br /><b>'.get_lang('ManageGroups').'</b><br /><br />'; |
|
246 | + |
|
247 | + if (in_array($_GET['sendmsg'], array('GroupUpdatedSuccessfully', 'GroupDeletedSuccessfully', 'GroupCreatedSuccessfully'))) { |
|
248 | + echo Display::display_confirmation_message(get_lang($_GET['sendmsg']), false); |
|
249 | + } |
|
250 | + |
|
251 | + if (in_array($_GET['sendmsg'], array('GroupNeedName'))){ |
|
252 | + echo Display::display_warning_message(get_lang($_GET['sendmsg']), false); |
|
253 | + } |
|
254 | + echo '<table border="0"><tr><td width="100">'.get_lang('Name').'</td><td>'.get_lang('Description').'</td></tr></table>'; |
|
255 | + echo '<form action="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?action=addgroup&survey_id='.$survey_id.'" method="post">'; |
|
256 | + if ($_GET['action'] == 'editgroup') { |
|
257 | + $sql = 'SELECT name,description FROM '.$table_survey_question_group.' WHERE id = '.intval($_GET['gid']).' AND survey_id = '.intval($survey_id).' limit 1'; |
|
258 | + $rs = Database::query($sql); |
|
259 | + $editedrow = Database::fetch_array($rs,'ASSOC'); |
|
260 | + echo '<input type="text" maxlength="20" name="name" value="'.$editedrow['name'].'" size="10" disabled>'; |
|
261 | + echo '<input type="text" maxlength="150" name="description" value="'.$editedrow['description'].'" size="40">'; |
|
262 | + echo '<input type="hidden" name="group_id" value="'.Security::remove_XSS($_GET['gid']).'">'; |
|
263 | + echo '<input type="submit" value="'.get_lang('Save').'"'.'<input type="button" value="'.get_lang('Cancel').'" onclick="window.location.href = \'survey.php?survey_id='.Security::remove_XSS($survey_id).'\';" />'; |
|
264 | + } else { |
|
265 | + echo '<input type="text" maxlength="20" name="name" value="" size="10">'; |
|
266 | + echo '<input type="text" maxlength="250" name="description" value="" size="80">'; |
|
267 | + echo '<input type="submit" value="'.get_lang('Create').'"'; |
|
268 | + } |
|
269 | + echo '</form><br />'; |
|
270 | + |
|
271 | + echo '<table class="data_table">'; |
|
272 | + echo ' <tr class="row_odd">'; |
|
273 | + echo ' <th width="200">'.get_lang('Name').'</th>'; |
|
274 | + echo ' <th>'.get_lang('Description').'</th>'; |
|
275 | + echo ' <th width="100">'.get_lang('Modify').'</th>'; |
|
276 | + echo ' </tr>'; |
|
277 | + |
|
278 | + $sql = 'SELECT id,name,description FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND survey_id = '.intval($survey_id).' ORDER BY name'; |
|
279 | + |
|
280 | + $rs = Database::query($sql); |
|
281 | + while($row = Database::fetch_array($rs,ASSOC)){ |
|
282 | + $grouplist .= '<tr><td>'.$row['name'].'</td><td>'.$row['description'].'</td><td>'. |
|
283 | + '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=editgroup">'. |
|
284 | + Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> '. |
|
285 | + '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=deletegroup" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('DeleteSurveyGroup'),$row['name']).'?',ENT_QUOTES)).'\')) return false;">'. |
|
286 | + Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'. |
|
287 | + '</td></tr>'; |
|
288 | + } |
|
289 | + echo $grouplist.'</table>'; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | Session::erase('answer_count'); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | // We exit here if there is no valid $_GET parameter |
45 | 45 | if (!isset($_GET['survey_id']) || !is_numeric($_GET['survey_id'])) { |
46 | 46 | api_not_allowed(true, Display::return_message(get_lang('InvallidSurvey'), 'error', false)); |
47 | - exit; |
|
47 | + exit; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // Getting the survey information |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | |
54 | 54 | if (empty($survey_data)) { |
55 | 55 | api_not_allowed(true, Display::return_message(get_lang('InvallidSurvey'), 'error', false)); |
56 | - exit; |
|
56 | + exit; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | $urlname = strip_tags($survey_data['title']); |
60 | 60 | if (api_is_allowed_to_edit()) { |
61 | - // Breadcrumbs |
|
62 | - $interbreadcrumb[] = array( |
|
61 | + // Breadcrumbs |
|
62 | + $interbreadcrumb[] = array( |
|
63 | 63 | 'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq(), |
64 | 64 | 'name' => get_lang('SurveyList') |
65 | 65 | ); |
@@ -86,57 +86,57 @@ discard block |
||
86 | 86 | $counter_question = 0; |
87 | 87 | // Only a course admin is allowed to preview a survey: you are a course admin |
88 | 88 | if (api_is_course_admin() || |
89 | - (api_is_course_admin() && $_GET['isStudentView'] == 'true') || |
|
90 | - api_is_allowed_to_session_edit(false, true) |
|
89 | + (api_is_course_admin() && $_GET['isStudentView'] == 'true') || |
|
90 | + api_is_allowed_to_session_edit(false, true) |
|
91 | 91 | ) { |
92 | - // Survey information |
|
93 | - echo '<div id="survey_title">'.$survey_data['survey_title'].'</div>'; |
|
94 | - echo '<div id="survey_subtitle">'.$survey_data['survey_subtitle'].'</div>'; |
|
92 | + // Survey information |
|
93 | + echo '<div id="survey_title">'.$survey_data['survey_title'].'</div>'; |
|
94 | + echo '<div id="survey_subtitle">'.$survey_data['survey_subtitle'].'</div>'; |
|
95 | 95 | |
96 | - // Displaying the survey introduction |
|
97 | - if (!isset($_GET['show'])) { |
|
96 | + // Displaying the survey introduction |
|
97 | + if (!isset($_GET['show'])) { |
|
98 | 98 | if (!empty($survey_data['survey_introduction'])) { |
99 | 99 | echo '<div id="survey_content" class="survey_content">'.$survey_data['survey_introduction'].'</div>'; |
100 | 100 | } |
101 | - $limit = 0; |
|
102 | - } |
|
101 | + $limit = 0; |
|
102 | + } |
|
103 | 103 | |
104 | - // Displaying the survey thanks message |
|
105 | - if (isset($_POST['finish_survey'])) { |
|
106 | - Display::display_confirmation_message(get_lang('SurveyFinished')); |
|
104 | + // Displaying the survey thanks message |
|
105 | + if (isset($_POST['finish_survey'])) { |
|
106 | + Display::display_confirmation_message(get_lang('SurveyFinished')); |
|
107 | 107 | echo $survey_data['survey_thanks']; |
108 | - Display :: display_footer(); |
|
109 | - exit; |
|
110 | - } |
|
108 | + Display :: display_footer(); |
|
109 | + exit; |
|
110 | + } |
|
111 | 111 | |
112 | 112 | $questions = array(); |
113 | 113 | |
114 | - if (isset($_GET['show'])) { |
|
115 | - // Getting all the questions for this page and add them to a |
|
116 | - // multidimensional array where the first index is the page. |
|
117 | - // as long as there is no pagebreak fount we keep adding questions to the page |
|
118 | - $questions_displayed = array(); |
|
119 | - $paged_questions = array(); |
|
120 | - $counter = 0; |
|
121 | - $sql = "SELECT * FROM $table_survey_question |
|
114 | + if (isset($_GET['show'])) { |
|
115 | + // Getting all the questions for this page and add them to a |
|
116 | + // multidimensional array where the first index is the page. |
|
117 | + // as long as there is no pagebreak fount we keep adding questions to the page |
|
118 | + $questions_displayed = array(); |
|
119 | + $paged_questions = array(); |
|
120 | + $counter = 0; |
|
121 | + $sql = "SELECT * FROM $table_survey_question |
|
122 | 122 | WHERE c_id = $course_id AND survey_id = '".intval($survey_id)."' |
123 | 123 | ORDER BY sort ASC"; |
124 | - $result = Database::query($sql); |
|
124 | + $result = Database::query($sql); |
|
125 | 125 | $questions_exists = true; |
126 | 126 | if (Database::num_rows($result)) { |
127 | - while ($row = Database::fetch_array($result)) { |
|
128 | - if ($row['type'] == 'pagebreak') { |
|
129 | - $counter++; |
|
130 | - } else { |
|
131 | - $paged_questions[$counter][] = $row['question_id']; |
|
132 | - } |
|
133 | - } |
|
127 | + while ($row = Database::fetch_array($result)) { |
|
128 | + if ($row['type'] == 'pagebreak') { |
|
129 | + $counter++; |
|
130 | + } else { |
|
131 | + $paged_questions[$counter][] = $row['question_id']; |
|
132 | + } |
|
133 | + } |
|
134 | 134 | } else { |
135 | 135 | $questions_exists = false; |
136 | 136 | } |
137 | 137 | |
138 | - if (array_key_exists($_GET['show'], $paged_questions)) { |
|
139 | - $sql = "SELECT |
|
138 | + if (array_key_exists($_GET['show'], $paged_questions)) { |
|
139 | + $sql = "SELECT |
|
140 | 140 | survey_question.question_id, |
141 | 141 | survey_question.survey_id, |
142 | 142 | survey_question.survey_question, |
@@ -158,75 +158,75 @@ discard block |
||
158 | 158 | survey_question.c_id = $course_id |
159 | 159 | ORDER BY survey_question.sort, survey_question_option.sort ASC"; |
160 | 160 | |
161 | - $result = Database::query($sql); |
|
162 | - $question_counter_max = Database::num_rows($result); |
|
163 | - $limit = 0; |
|
164 | - while ($row = Database::fetch_array($result)) { |
|
165 | - // If the type is not a pagebreak we store it in the $questions array |
|
166 | - if ($row['type'] != 'pagebreak') { |
|
167 | - $questions[$row['sort']]['question_id'] = $row['question_id']; |
|
168 | - $questions[$row['sort']]['survey_id'] = $row['survey_id']; |
|
169 | - $questions[$row['sort']]['survey_question'] = $row['survey_question']; |
|
170 | - $questions[$row['sort']]['display'] = $row['display']; |
|
171 | - $questions[$row['sort']]['type'] = $row['type']; |
|
172 | - $questions[$row['sort']]['options'][intval($row['option_sort'])] = $row['option_text']; |
|
173 | - $questions[$row['sort']]['maximum_score'] = $row['max_value']; |
|
174 | - } else { |
|
175 | - // If the type is a pagebreak we are finished loading the questions for this page |
|
176 | - break; |
|
177 | - } |
|
178 | - $counter_question++; |
|
179 | - } |
|
180 | - } |
|
181 | - } |
|
182 | - |
|
183 | - // Selecting the maximum number of pages |
|
184 | - $sql = "SELECT * FROM $table_survey_question |
|
161 | + $result = Database::query($sql); |
|
162 | + $question_counter_max = Database::num_rows($result); |
|
163 | + $limit = 0; |
|
164 | + while ($row = Database::fetch_array($result)) { |
|
165 | + // If the type is not a pagebreak we store it in the $questions array |
|
166 | + if ($row['type'] != 'pagebreak') { |
|
167 | + $questions[$row['sort']]['question_id'] = $row['question_id']; |
|
168 | + $questions[$row['sort']]['survey_id'] = $row['survey_id']; |
|
169 | + $questions[$row['sort']]['survey_question'] = $row['survey_question']; |
|
170 | + $questions[$row['sort']]['display'] = $row['display']; |
|
171 | + $questions[$row['sort']]['type'] = $row['type']; |
|
172 | + $questions[$row['sort']]['options'][intval($row['option_sort'])] = $row['option_text']; |
|
173 | + $questions[$row['sort']]['maximum_score'] = $row['max_value']; |
|
174 | + } else { |
|
175 | + // If the type is a pagebreak we are finished loading the questions for this page |
|
176 | + break; |
|
177 | + } |
|
178 | + $counter_question++; |
|
179 | + } |
|
180 | + } |
|
181 | + } |
|
182 | + |
|
183 | + // Selecting the maximum number of pages |
|
184 | + $sql = "SELECT * FROM $table_survey_question |
|
185 | 185 | WHERE |
186 | 186 | c_id = $course_id AND |
187 | 187 | type='".Database::escape_string('pagebreak')."' AND |
188 | 188 | survey_id='".intval($survey_id)."'"; |
189 | - $result = Database::query($sql); |
|
190 | - $numberofpages = Database::num_rows($result) + 1; |
|
191 | - |
|
192 | - // Displaying the form with the questions |
|
193 | - if (isset($_GET['show'])) { |
|
194 | - $show = (int)$_GET['show'] + 1; |
|
195 | - } else { |
|
196 | - $show = 0; |
|
197 | - } |
|
198 | - |
|
199 | - $url = api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show; |
|
200 | - $form = new FormValidator('question', 'post', $url); |
|
201 | - |
|
202 | - if (is_array($questions) && count($questions) > 0) { |
|
203 | - foreach ($questions as $key => & $question) { |
|
204 | - $ch_type = 'ch_'.$question['type']; |
|
205 | - /** @var survey_question $display */ |
|
206 | - $display = new $ch_type; |
|
207 | - $form->addHtml('<div class="survey_question_wrapper"><div class="survey_question">'); |
|
208 | - $form->addHtml($question['survey_question']); |
|
209 | - $display->render($form, $question); |
|
210 | - $form->addHtml('</div></div>'); |
|
211 | - } |
|
212 | - } |
|
213 | - |
|
214 | - if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0)) { |
|
189 | + $result = Database::query($sql); |
|
190 | + $numberofpages = Database::num_rows($result) + 1; |
|
191 | + |
|
192 | + // Displaying the form with the questions |
|
193 | + if (isset($_GET['show'])) { |
|
194 | + $show = (int)$_GET['show'] + 1; |
|
195 | + } else { |
|
196 | + $show = 0; |
|
197 | + } |
|
198 | + |
|
199 | + $url = api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show; |
|
200 | + $form = new FormValidator('question', 'post', $url); |
|
201 | + |
|
202 | + if (is_array($questions) && count($questions) > 0) { |
|
203 | + foreach ($questions as $key => & $question) { |
|
204 | + $ch_type = 'ch_'.$question['type']; |
|
205 | + /** @var survey_question $display */ |
|
206 | + $display = new $ch_type; |
|
207 | + $form->addHtml('<div class="survey_question_wrapper"><div class="survey_question">'); |
|
208 | + $form->addHtml($question['survey_question']); |
|
209 | + $display->render($form, $question); |
|
210 | + $form->addHtml('</div></div>'); |
|
211 | + } |
|
212 | + } |
|
213 | + |
|
214 | + if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0)) { |
|
215 | 215 | if ($show == 0) { |
216 | - $form->addButton('next_survey_page', get_lang('StartSurvey'), 'arrow-right', 'success', 'large'); |
|
216 | + $form->addButton('next_survey_page', get_lang('StartSurvey'), 'arrow-right', 'success', 'large'); |
|
217 | 217 | } else { |
218 | - $form->addButton('next_survey_page', get_lang('NextQuestion'), 'arrow-right'); |
|
218 | + $form->addButton('next_survey_page', get_lang('NextQuestion'), 'arrow-right'); |
|
219 | 219 | } |
220 | - } |
|
221 | - if ($show >= $numberofpages && $_GET['show'] || (isset($_GET['show']) && count($questions) == 0)) { |
|
222 | - if ($questions_exists == false) { |
|
223 | - echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>'; |
|
224 | - } |
|
225 | - $form->addButton('finish_survey', get_lang('FinishSurvey'), 'arrow-right'); |
|
226 | - } |
|
227 | - $form->display(); |
|
220 | + } |
|
221 | + if ($show >= $numberofpages && $_GET['show'] || (isset($_GET['show']) && count($questions) == 0)) { |
|
222 | + if ($questions_exists == false) { |
|
223 | + echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>'; |
|
224 | + } |
|
225 | + $form->addButton('finish_survey', get_lang('FinishSurvey'), 'arrow-right'); |
|
226 | + } |
|
227 | + $form->display(); |
|
228 | 228 | } else { |
229 | - Display :: display_error_message(get_lang('NotAllowed'), false); |
|
229 | + Display :: display_error_message(get_lang('NotAllowed'), false); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | Display :: display_footer(); |
@@ -94,12 +94,12 @@ |
||
94 | 94 | */ |
95 | 95 | protected $assignedLastUser; |
96 | 96 | |
97 | - /** |
|
98 | - * @var Status |
|
99 | - * |
|
100 | - * @ORM\ManyToOne(targetEntity="Chamilo\TicketBundle\Entity\Status") |
|
101 | - * @ORM\JoinColumn(name="status_id", referencedColumnName="id") |
|
102 | - **/ |
|
97 | + /** |
|
98 | + * @var Status |
|
99 | + * |
|
100 | + * @ORM\ManyToOne(targetEntity="Chamilo\TicketBundle\Entity\Status") |
|
101 | + * @ORM\JoinColumn(name="status_id", referencedColumnName="id") |
|
102 | + **/ |
|
103 | 103 | protected $status; |
104 | 104 | |
105 | 105 | /** |
@@ -56,7 +56,7 @@ |
||
56 | 56 | */ |
57 | 57 | protected $filename; |
58 | 58 | |
59 | - /** |
|
59 | + /** |
|
60 | 60 | * @var integer |
61 | 61 | * |
62 | 62 | * @ORM\Column(name="size", type="integer", nullable=false, unique=false) |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | // When creating a new course this settings are added to the course |
12 | 12 | public $course_settings = array( |
13 | - array( |
|
13 | + array( |
|
14 | 14 | 'name' => 'course_block_pre_footer', |
15 | 15 | 'type' => 'textarea' |
16 | 16 | ), |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | - * @param string $region |
|
70 | - * @return string |
|
71 | - */ |
|
69 | + * @param string $region |
|
70 | + * @return string |
|
71 | + */ |
|
72 | 72 | public function renderRegion($region) |
73 | 73 | { |
74 | 74 | $content = ''; |
@@ -53,12 +53,12 @@ |
||
53 | 53 | */ |
54 | 54 | protected $ipAddress; |
55 | 55 | |
56 | - /** |
|
57 | - * @var Ticket |
|
58 | - * |
|
59 | - * @ORM\ManyToOne(targetEntity="Chamilo\TicketBundle\Entity\Ticket") |
|
60 | - * @ORM\JoinColumn(name="ticket_id", referencedColumnName="id") |
|
61 | - **/ |
|
56 | + /** |
|
57 | + * @var Ticket |
|
58 | + * |
|
59 | + * @ORM\ManyToOne(targetEntity="Chamilo\TicketBundle\Entity\Ticket") |
|
60 | + * @ORM\JoinColumn(name="ticket_id", referencedColumnName="id") |
|
61 | + **/ |
|
62 | 62 | protected $ticket; |
63 | 63 | |
64 | 64 | /** |