@@ -116,7 +116,7 @@ |
||
116 | 116 | * @param int $sessionId |
117 | 117 | * @param string $downloadCertificateLink |
118 | 118 | * @param string $badgeLink |
119 | - * @return mixed|string |
|
119 | + * @return string |
|
120 | 120 | */ |
121 | 121 | function generateLPFinalItemTemplate($lpItemId, $courseCode, $sessionId=0, $downloadCertificateLink='', $badgeLink='') |
122 | 122 | { |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // Initialize context |
9 | 9 | $_in_course = true; |
10 | 10 | require_once '../inc/global.inc.php'; |
11 | -$current_course_tool = TOOL_GRADEBOOK; |
|
11 | +$current_course_tool = TOOL_GRADEBOOK; |
|
12 | 12 | |
13 | 13 | // Make sure no anonymous user gets here without permission |
14 | 14 | api_protect_course_script(true); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $currentItem = $lp->items[$currentItemId]; |
41 | 41 | $currentItemStatus = $currentItem->get_status(); |
42 | 42 | $accessGranted = false; |
43 | -if (($count - $completed == 0) or (($count - $completed == 1 && ($currentItemStatus == 'incomplete') or ($currentItemStatus == 'not attempted') ))) { |
|
43 | +if (($count - $completed == 0) or (($count - $completed == 1 && ($currentItemStatus == 'incomplete') or ($currentItemStatus == 'not attempted')))) { |
|
44 | 44 | if ($lp->prerequisites_match($currentItemId)) { |
45 | 45 | $accessGranted = true; |
46 | 46 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @param string $badgeLink |
119 | 119 | * @return mixed|string |
120 | 120 | */ |
121 | -function generateLPFinalItemTemplate($lpItemId, $courseCode, $sessionId=0, $downloadCertificateLink='', $badgeLink='') |
|
121 | +function generateLPFinalItemTemplate($lpItemId, $courseCode, $sessionId = 0, $downloadCertificateLink = '', $badgeLink = '') |
|
122 | 122 | { |
123 | 123 | $documentInfo = DocumentManager::get_document_data_by_id( |
124 | 124 | $lpItemId, |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @param int $sessionId |
142 | 142 | * @return string HTML string for badges |
143 | 143 | */ |
144 | -function generateLPFinalItemTemplateBadgeLinks($userId, $courseId, $sessionId=0) |
|
144 | +function generateLPFinalItemTemplateBadgeLinks($userId, $courseId, $sessionId = 0) |
|
145 | 145 | { |
146 | 146 | $skillRelUser = new SkillRelUser(); |
147 | 147 | $userSkills = $skillRelUser->get_user_skills($userId, $courseId, $sessionId); |
@@ -156,19 +156,19 @@ discard block |
||
156 | 156 | <div class='row'> |
157 | 157 | <div class='col-md-2 col-xs-6'> |
158 | 158 | <div class='thumbnail'> |
159 | - <img class='skill-badge-img' src='" . $oneSkill['web_icon_path'] . "' > |
|
159 | + <img class='skill-badge-img' src='" . $oneSkill['web_icon_path']."' > |
|
160 | 160 | </div> |
161 | 161 | </div> |
162 | 162 | <div class='col-md-8 col-xs-6'> |
163 | - <h5><b>" . $oneSkill['name'] . "</b></h5> |
|
164 | - " . $oneSkill['description'] . " |
|
163 | + <h5><b>" . $oneSkill['name']."</b></h5> |
|
164 | + " . $oneSkill['description']." |
|
165 | 165 | </div> |
166 | 166 | <div class='col-md-2 col-xs-12'> |
167 | - <h5><b>" . get_lang('ShareWithYourFriends') . "</b></h5> |
|
168 | - <a href='http://www.facebook.com/sharer.php?u=" . api_get_path(WEB_PATH) . "badge/" . $oneSkill['id'] . "/user/" . $userId . "' target='_new'> |
|
167 | + <h5><b>" . get_lang('ShareWithYourFriends')."</b></h5> |
|
168 | + <a href='http://www.facebook.com/sharer.php?u=" . api_get_path(WEB_PATH)."badge/".$oneSkill['id']."/user/".$userId."' target='_new'> |
|
169 | 169 | <em class='fa fa-facebook-square fa-3x text-info' aria-hidden='true'></em> |
170 | 170 | </a> |
171 | - <a href='https://twitter.com/home?status=" . api_get_path(WEB_PATH) . "badge/" . $oneSkill['id'] . "/user/" . $userId . "' target='_new'> |
|
171 | + <a href='https://twitter.com/home?status=" . api_get_path(WEB_PATH)."badge/".$oneSkill['id']."/user/".$userId."' target='_new'> |
|
172 | 172 | <em class='fa fa-twitter-square fa-3x text-light' aria-hidden='true'></em> |
173 | 173 | </a> |
174 | 174 | </div> |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $badgeLink .= " |
179 | 179 | <div class='panel panel-default'> |
180 | 180 | <div class='panel-body'> |
181 | - <h3 class='text-center'>" . get_lang('AdditionallyYouHaveObtainedTheFollowingSkills') . "</h3> |
|
181 | + <h3 class='text-center'>" . get_lang('AdditionallyYouHaveObtainedTheFollowingSkills')."</h3> |
|
182 | 182 | $skillList |
183 | 183 | </div> |
184 | 184 | </div> |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | function generateLPFinalItemTemplateCertificateLinks($certificate) |
196 | 196 | { |
197 | - $downloadCertificateLink = Display::url(Display::returnFontAwesomeIcon('file-pdf-o') . |
|
197 | + $downloadCertificateLink = Display::url(Display::returnFontAwesomeIcon('file-pdf-o'). |
|
198 | 198 | get_lang('DownloadCertificatePdf'), |
199 | 199 | $certificate['pdf_url'], |
200 | 200 | ['class' => 'btn btn-default'] |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $downloadCertificateLink = " |
204 | 204 | <div class='panel panel-default'> |
205 | 205 | <div class='panel-body'> |
206 | - <h3 class='text-center'>" . get_lang('NowDownloadYourCertificateClickHere') . "</h3> |
|
206 | + <h3 class='text-center'>" . get_lang('NowDownloadYourCertificateClickHere')."</h3> |
|
207 | 207 | <div class='text-center'>$downloadCertificateLink $viewCertificateLink</div> |
208 | 208 | </div> |
209 | 209 | </div> |
@@ -9,260 +9,260 @@ |
||
9 | 9 | */ |
10 | 10 | class LearnpathLink extends AbstractLink |
11 | 11 | { |
12 | - private $course_info = null; |
|
13 | - private $learnpath_table = null; |
|
14 | - private $learnpath_data = null; |
|
15 | - |
|
16 | - /** |
|
17 | - * Constructor |
|
18 | - */ |
|
19 | - public function __construct() |
|
20 | - { |
|
21 | - parent::__construct(); |
|
22 | - $this->set_type(LINK_LEARNPATH); |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * Generate an array of learnpaths that a teacher hasn't created a link for. |
|
27 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
28 | - */ |
|
29 | - public function get_not_created_links() |
|
30 | - { |
|
31 | - return false; |
|
32 | - if (empty($this->course_code)) |
|
33 | - die('Error in get_not_created_links() : course code not set'); |
|
34 | - |
|
35 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
36 | - |
|
37 | - $sql = 'SELECT id, name from '.$this->get_learnpath_table().' lp |
|
12 | + private $course_info = null; |
|
13 | + private $learnpath_table = null; |
|
14 | + private $learnpath_data = null; |
|
15 | + |
|
16 | + /** |
|
17 | + * Constructor |
|
18 | + */ |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + parent::__construct(); |
|
22 | + $this->set_type(LINK_LEARNPATH); |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * Generate an array of learnpaths that a teacher hasn't created a link for. |
|
27 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
28 | + */ |
|
29 | + public function get_not_created_links() |
|
30 | + { |
|
31 | + return false; |
|
32 | + if (empty($this->course_code)) |
|
33 | + die('Error in get_not_created_links() : course code not set'); |
|
34 | + |
|
35 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
36 | + |
|
37 | + $sql = 'SELECT id, name from '.$this->get_learnpath_table().' lp |
|
38 | 38 | WHERE c_id = '.$this->course_id.' AND id NOT IN ' |
39 | - .' (SELECT ref_id FROM '.$tbl_grade_links |
|
40 | - .' WHERE type = '.LINK_LEARNPATH |
|
41 | - ." AND course_code = '".$this->get_course_code()."'" |
|
42 | - .') AND lp.session_id='.api_get_session_id().''; |
|
43 | - |
|
44 | - $result = Database::query($sql); |
|
45 | - |
|
46 | - $cats=array(); |
|
47 | - while ($data=Database::fetch_array($result)) { |
|
48 | - $cats[] = array ($data['id'], $data['name']); |
|
49 | - } |
|
50 | - |
|
51 | - return $cats; |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Generate an array of all learnpaths available. |
|
56 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
57 | - */ |
|
58 | - public function get_all_links() |
|
59 | - { |
|
60 | - if (empty($this->course_code)) |
|
61 | - die('Error in get_not_created_links() : course code not set'); |
|
62 | - |
|
63 | - $session_id = api_get_session_id(); |
|
64 | - if (empty($session_id)) { |
|
65 | - $session_condition = api_get_session_condition(0, true); |
|
66 | - } else { |
|
67 | - $session_condition = api_get_session_condition($session_id, true, true); |
|
68 | - } |
|
69 | - |
|
70 | - $sql = 'SELECT id, name FROM '.$this->get_learnpath_table().' |
|
39 | + .' (SELECT ref_id FROM '.$tbl_grade_links |
|
40 | + .' WHERE type = '.LINK_LEARNPATH |
|
41 | + ." AND course_code = '".$this->get_course_code()."'" |
|
42 | + .') AND lp.session_id='.api_get_session_id().''; |
|
43 | + |
|
44 | + $result = Database::query($sql); |
|
45 | + |
|
46 | + $cats=array(); |
|
47 | + while ($data=Database::fetch_array($result)) { |
|
48 | + $cats[] = array ($data['id'], $data['name']); |
|
49 | + } |
|
50 | + |
|
51 | + return $cats; |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Generate an array of all learnpaths available. |
|
56 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
57 | + */ |
|
58 | + public function get_all_links() |
|
59 | + { |
|
60 | + if (empty($this->course_code)) |
|
61 | + die('Error in get_not_created_links() : course code not set'); |
|
62 | + |
|
63 | + $session_id = api_get_session_id(); |
|
64 | + if (empty($session_id)) { |
|
65 | + $session_condition = api_get_session_condition(0, true); |
|
66 | + } else { |
|
67 | + $session_condition = api_get_session_condition($session_id, true, true); |
|
68 | + } |
|
69 | + |
|
70 | + $sql = 'SELECT id, name FROM '.$this->get_learnpath_table().' |
|
71 | 71 | WHERE c_id = '.$this->course_id.' '.$session_condition.' '; |
72 | - $result = Database::query($sql); |
|
72 | + $result = Database::query($sql); |
|
73 | 73 | |
74 | - $cats = array(); |
|
75 | - while ($data=Database::fetch_array($result)) { |
|
76 | - $cats[] = array ($data['id'], $data['name']); |
|
77 | - } |
|
74 | + $cats = array(); |
|
75 | + while ($data=Database::fetch_array($result)) { |
|
76 | + $cats[] = array ($data['id'], $data['name']); |
|
77 | + } |
|
78 | 78 | |
79 | - return $cats; |
|
80 | - } |
|
79 | + return $cats; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * Has anyone used this learnpath yet ? |
|
85 | - */ |
|
86 | - public function has_results() |
|
87 | - { |
|
88 | - $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
89 | - $sql = "SELECT count(id) AS number FROM $tbl_stats |
|
83 | + /** |
|
84 | + * Has anyone used this learnpath yet ? |
|
85 | + */ |
|
86 | + public function has_results() |
|
87 | + { |
|
88 | + $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
89 | + $sql = "SELECT count(id) AS number FROM $tbl_stats |
|
90 | 90 | WHERE c_id = ".$this->course_id." AND lp_id = ".$this->get_ref_id(); |
91 | - $result = Database::query($sql); |
|
92 | - $number = Database::fetch_array($result,'NUM'); |
|
93 | - return ($number[0] != 0); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Get the progress of this learnpath. Only the last attempt are taken into account. |
|
98 | - * @param $stud_id student id (default: all students who have results - then the average is returned) |
|
99 | - * @return array (score, max) if student is given |
|
100 | - * array (sum of scores, number of scores) otherwise |
|
101 | - * or null if no scores available |
|
102 | - */ |
|
103 | - public function calc_score($stud_id = null, $type = null) |
|
104 | - { |
|
105 | - $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
106 | - $session_id = api_get_session_id(); |
|
107 | - |
|
108 | - $sql = "SELECT * FROM $tbl_stats |
|
91 | + $result = Database::query($sql); |
|
92 | + $number = Database::fetch_array($result,'NUM'); |
|
93 | + return ($number[0] != 0); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Get the progress of this learnpath. Only the last attempt are taken into account. |
|
98 | + * @param $stud_id student id (default: all students who have results - then the average is returned) |
|
99 | + * @return array (score, max) if student is given |
|
100 | + * array (sum of scores, number of scores) otherwise |
|
101 | + * or null if no scores available |
|
102 | + */ |
|
103 | + public function calc_score($stud_id = null, $type = null) |
|
104 | + { |
|
105 | + $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
106 | + $session_id = api_get_session_id(); |
|
107 | + |
|
108 | + $sql = "SELECT * FROM $tbl_stats |
|
109 | 109 | WHERE |
110 | 110 | c_id = ".$this->course_id." AND |
111 | 111 | lp_id = ".$this->get_ref_id()." AND |
112 | 112 | session_id = $session_id "; |
113 | 113 | |
114 | - if (isset($stud_id)) |
|
115 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
116 | - |
|
117 | - // order by id, that way the student's first attempt is accessed first |
|
118 | - $sql .= ' ORDER BY view_count DESC'; |
|
119 | - |
|
120 | - $scores = Database::query($sql); |
|
121 | - // for 1 student |
|
122 | - if (isset($stud_id)) { |
|
123 | - if ($data = Database::fetch_assoc($scores)) { |
|
124 | - return array ($data['progress'], 100); |
|
125 | - } else |
|
126 | - return null; |
|
127 | - } else { |
|
128 | - // all students -> get average |
|
129 | - $students = array(); // user list, needed to make sure we only |
|
130 | - // take first attempts into account |
|
131 | - $rescount = 0; |
|
132 | - $sum = 0; |
|
133 | - $bestResult = 0; |
|
134 | - $sumResult = 0; |
|
135 | - while ($data = Database::fetch_array($scores)) { |
|
136 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
137 | - $students[$data['user_id']] = $data['progress']; |
|
138 | - $rescount++; |
|
139 | - $sum += $data['progress'] / 100; |
|
140 | - $sumResult += $data['progress']; |
|
141 | - |
|
142 | - if ($data['progress'] > $bestResult) { |
|
143 | - $bestResult = $data['progress']; |
|
144 | - } |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - if ($rescount == 0) { |
|
149 | - return null; |
|
150 | - } else { |
|
151 | - |
|
152 | - switch ($type) { |
|
153 | - case 'best': |
|
154 | - return array($bestResult, 100); |
|
155 | - break; |
|
156 | - case 'average': |
|
157 | - return array($sumResult/$rescount, 100); |
|
158 | - break; |
|
159 | - case 'ranking': |
|
160 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
161 | - break; |
|
162 | - default: |
|
163 | - return array($sum, $rescount); |
|
164 | - break; |
|
165 | - } |
|
166 | - } |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Get URL where to go to if the user clicks on the link. |
|
172 | - */ |
|
173 | - public function get_link() |
|
174 | - { |
|
175 | - $url = api_get_path(WEB_PATH).'main/newscorm/lp_controller.php?cidReq='.$this->get_course_code().'&gradebook=view'; |
|
176 | - $session_id = api_get_session_id(); |
|
177 | - if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) { |
|
178 | - $url .= '&action=view&session_id='.$session_id.'&lp_id='.$this->get_ref_id(); |
|
179 | - } else { |
|
180 | - $url .= '&action=build&session_id='.$session_id.'&lp_id='.$this->get_ref_id(); |
|
181 | - } |
|
182 | - return $url; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Get name to display: same as learnpath title |
|
187 | - */ |
|
188 | - public function get_name() |
|
189 | - { |
|
190 | - $data = $this->get_learnpath_data(); |
|
191 | - return $data['name']; |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Get description to display: same as learnpath description |
|
196 | - */ |
|
197 | - public function get_description() |
|
198 | - { |
|
199 | - $data = $this->get_learnpath_data(); |
|
200 | - return $data['description']; |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Check if this still links to a learnpath |
|
205 | - */ |
|
206 | - public function is_valid_link() { |
|
207 | - $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().' |
|
114 | + if (isset($stud_id)) |
|
115 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
116 | + |
|
117 | + // order by id, that way the student's first attempt is accessed first |
|
118 | + $sql .= ' ORDER BY view_count DESC'; |
|
119 | + |
|
120 | + $scores = Database::query($sql); |
|
121 | + // for 1 student |
|
122 | + if (isset($stud_id)) { |
|
123 | + if ($data = Database::fetch_assoc($scores)) { |
|
124 | + return array ($data['progress'], 100); |
|
125 | + } else |
|
126 | + return null; |
|
127 | + } else { |
|
128 | + // all students -> get average |
|
129 | + $students = array(); // user list, needed to make sure we only |
|
130 | + // take first attempts into account |
|
131 | + $rescount = 0; |
|
132 | + $sum = 0; |
|
133 | + $bestResult = 0; |
|
134 | + $sumResult = 0; |
|
135 | + while ($data = Database::fetch_array($scores)) { |
|
136 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
137 | + $students[$data['user_id']] = $data['progress']; |
|
138 | + $rescount++; |
|
139 | + $sum += $data['progress'] / 100; |
|
140 | + $sumResult += $data['progress']; |
|
141 | + |
|
142 | + if ($data['progress'] > $bestResult) { |
|
143 | + $bestResult = $data['progress']; |
|
144 | + } |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + if ($rescount == 0) { |
|
149 | + return null; |
|
150 | + } else { |
|
151 | + |
|
152 | + switch ($type) { |
|
153 | + case 'best': |
|
154 | + return array($bestResult, 100); |
|
155 | + break; |
|
156 | + case 'average': |
|
157 | + return array($sumResult/$rescount, 100); |
|
158 | + break; |
|
159 | + case 'ranking': |
|
160 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
161 | + break; |
|
162 | + default: |
|
163 | + return array($sum, $rescount); |
|
164 | + break; |
|
165 | + } |
|
166 | + } |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Get URL where to go to if the user clicks on the link. |
|
172 | + */ |
|
173 | + public function get_link() |
|
174 | + { |
|
175 | + $url = api_get_path(WEB_PATH).'main/newscorm/lp_controller.php?cidReq='.$this->get_course_code().'&gradebook=view'; |
|
176 | + $session_id = api_get_session_id(); |
|
177 | + if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) { |
|
178 | + $url .= '&action=view&session_id='.$session_id.'&lp_id='.$this->get_ref_id(); |
|
179 | + } else { |
|
180 | + $url .= '&action=build&session_id='.$session_id.'&lp_id='.$this->get_ref_id(); |
|
181 | + } |
|
182 | + return $url; |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Get name to display: same as learnpath title |
|
187 | + */ |
|
188 | + public function get_name() |
|
189 | + { |
|
190 | + $data = $this->get_learnpath_data(); |
|
191 | + return $data['name']; |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Get description to display: same as learnpath description |
|
196 | + */ |
|
197 | + public function get_description() |
|
198 | + { |
|
199 | + $data = $this->get_learnpath_data(); |
|
200 | + return $data['description']; |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * Check if this still links to a learnpath |
|
205 | + */ |
|
206 | + public function is_valid_link() { |
|
207 | + $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().' |
|
208 | 208 | WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' '; |
209 | - $result = Database::query($sql); |
|
210 | - $number = Database::fetch_row($result,'NUM'); |
|
211 | - return ($number[0] != 0); |
|
212 | - } |
|
213 | - |
|
214 | - public function get_type_name() |
|
215 | - { |
|
216 | - return get_lang('LearningPaths'); |
|
217 | - } |
|
218 | - |
|
219 | - public function needs_name_and_description() |
|
220 | - { |
|
221 | - return false; |
|
222 | - } |
|
223 | - |
|
224 | - public function needs_max() |
|
225 | - { |
|
226 | - return false; |
|
227 | - } |
|
228 | - |
|
229 | - public function needs_results() |
|
230 | - { |
|
231 | - return false; |
|
232 | - } |
|
233 | - |
|
234 | - public function is_allowed_to_change_name() |
|
235 | - { |
|
236 | - return false; |
|
237 | - } |
|
238 | - |
|
239 | - // INTERNAL FUNCTIONS |
|
240 | - |
|
241 | - /** |
|
242 | - * Lazy load function to get the database table of the learnpath |
|
243 | - */ |
|
244 | - private function get_learnpath_table() |
|
245 | - { |
|
246 | - $this->learnpath_table = Database :: get_course_table(TABLE_LP_MAIN); |
|
247 | - return $this->learnpath_table; |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * Lazy load function to get the database contents of this learnpath |
|
252 | - */ |
|
253 | - private function get_learnpath_data() |
|
254 | - { |
|
255 | - if (!isset($this->learnpath_data)) { |
|
256 | - $sql = 'SELECT * FROM '.$this->get_learnpath_table().' |
|
209 | + $result = Database::query($sql); |
|
210 | + $number = Database::fetch_row($result,'NUM'); |
|
211 | + return ($number[0] != 0); |
|
212 | + } |
|
213 | + |
|
214 | + public function get_type_name() |
|
215 | + { |
|
216 | + return get_lang('LearningPaths'); |
|
217 | + } |
|
218 | + |
|
219 | + public function needs_name_and_description() |
|
220 | + { |
|
221 | + return false; |
|
222 | + } |
|
223 | + |
|
224 | + public function needs_max() |
|
225 | + { |
|
226 | + return false; |
|
227 | + } |
|
228 | + |
|
229 | + public function needs_results() |
|
230 | + { |
|
231 | + return false; |
|
232 | + } |
|
233 | + |
|
234 | + public function is_allowed_to_change_name() |
|
235 | + { |
|
236 | + return false; |
|
237 | + } |
|
238 | + |
|
239 | + // INTERNAL FUNCTIONS |
|
240 | + |
|
241 | + /** |
|
242 | + * Lazy load function to get the database table of the learnpath |
|
243 | + */ |
|
244 | + private function get_learnpath_table() |
|
245 | + { |
|
246 | + $this->learnpath_table = Database :: get_course_table(TABLE_LP_MAIN); |
|
247 | + return $this->learnpath_table; |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * Lazy load function to get the database contents of this learnpath |
|
252 | + */ |
|
253 | + private function get_learnpath_data() |
|
254 | + { |
|
255 | + if (!isset($this->learnpath_data)) { |
|
256 | + $sql = 'SELECT * FROM '.$this->get_learnpath_table().' |
|
257 | 257 | WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' '; |
258 | - $result = Database::query($sql); |
|
259 | - $this->learnpath_data = Database::fetch_array($result); |
|
260 | - } |
|
261 | - return $this->learnpath_data; |
|
262 | - } |
|
263 | - |
|
264 | - public function get_icon_name() |
|
265 | - { |
|
266 | - return 'learnpath'; |
|
267 | - } |
|
258 | + $result = Database::query($sql); |
|
259 | + $this->learnpath_data = Database::fetch_array($result); |
|
260 | + } |
|
261 | + return $this->learnpath_data; |
|
262 | + } |
|
263 | + |
|
264 | + public function get_icon_name() |
|
265 | + { |
|
266 | + return 'learnpath'; |
|
267 | + } |
|
268 | 268 | } |