| @@ 1208-1221 (lines=14) @@ | ||
| 1205 | * @param int $user_id |
|
| 1206 | * @return bool |
|
| 1207 | */ |
|
| 1208 | public function get_user_skill_ranking($user_id) |
|
| 1209 | { |
|
| 1210 | $user_id = intval($user_id); |
|
| 1211 | $sql = "SELECT count(skill_id) count FROM {$this->table} s |
|
| 1212 | INNER JOIN {$this->table_skill_rel_user} su |
|
| 1213 | ON (s.id = su.skill_id) |
|
| 1214 | WHERE user_id = $user_id"; |
|
| 1215 | $result = Database::query($sql); |
|
| 1216 | if (Database::num_rows($result)) { |
|
| 1217 | $result = Database::fetch_row($result); |
|
| 1218 | return $result[0]; |
|
| 1219 | } |
|
| 1220 | return false; |
|
| 1221 | } |
|
| 1222 | ||
| 1223 | /** |
|
| 1224 | * @param $start |
|
| @@ 1279-1294 (lines=16) @@ | ||
| 1276 | * @param string $course_code |
|
| 1277 | * @return int |
|
| 1278 | */ |
|
| 1279 | public function get_count_skills_by_course($course_code) |
|
| 1280 | { |
|
| 1281 | $courseId = api_get_course_int_id($course_code); |
|
| 1282 | $sql = "SELECT count(skill_id) as count |
|
| 1283 | FROM {$this->table_gradebook} g |
|
| 1284 | INNER JOIN {$this->table_skill_rel_gradebook} sg |
|
| 1285 | ON g.id = sg.gradebook_id |
|
| 1286 | WHERE g.c_id = " . $courseId; |
|
| 1287 | ||
| 1288 | $result = Database::query($sql); |
|
| 1289 | if (Database::num_rows($result)) { |
|
| 1290 | $result = Database::fetch_row($result); |
|
| 1291 | return $result[0]; |
|
| 1292 | } |
|
| 1293 | return 0; |
|
| 1294 | } |
|
| 1295 | ||
| 1296 | /** |
|
| 1297 | * @param int $skill_id |
|
| @@ 6301-6315 (lines=15) @@ | ||
| 6298 | /** |
|
| 6299 | * Get total number of question that will be parsed when using the category/exercise |
|
| 6300 | */ |
|
| 6301 | public function getNumberQuestionExerciseCategory() |
|
| 6302 | { |
|
| 6303 | $table = Database::get_course_table(TABLE_QUIZ_REL_CATEGORY); |
|
| 6304 | if (!empty($this->id)) { |
|
| 6305 | $sql = "SELECT SUM(count_questions) count_questions |
|
| 6306 | FROM $table |
|
| 6307 | WHERE exercise_id = {$this->id} AND c_id = {$this->course_id}"; |
|
| 6308 | $result = Database::query($sql); |
|
| 6309 | if (Database::num_rows($result)) { |
|
| 6310 | $row = Database::fetch_array($result); |
|
| 6311 | return $row['count_questions']; |
|
| 6312 | } |
|
| 6313 | } |
|
| 6314 | return 0; |
|
| 6315 | } |
|
| 6316 | ||
| 6317 | /** |
|
| 6318 | * Save categories in the TABLE_QUIZ_REL_CATEGORY table |
|