@@ 2080-2103 (lines=24) @@ | ||
2077 | * @param int $user_id |
|
2078 | * @return array |
|
2079 | */ |
|
2080 | public static function getAllGroupPerUserSubscription($user_id) |
|
2081 | { |
|
2082 | $table_group_user = Database::get_course_table(TABLE_GROUP_USER); |
|
2083 | $table_tutor_user = Database::get_course_table(TABLE_GROUP_TUTOR); |
|
2084 | $table_group = Database::get_course_table(TABLE_GROUP); |
|
2085 | $user_id = intval($user_id); |
|
2086 | $course_id = api_get_course_int_id(); |
|
2087 | $sql = "SELECT DISTINCT g.* |
|
2088 | FROM $table_group g |
|
2089 | LEFT JOIN $table_group_user gu |
|
2090 | ON (gu.group_id = g.id AND g.c_id = gu.c_id) |
|
2091 | LEFT JOIN $table_tutor_user tu |
|
2092 | ON (tu.group_id = g.id AND g.c_id = tu.c_id) |
|
2093 | WHERE |
|
2094 | g.c_id = $course_id AND |
|
2095 | (gu.user_id = $user_id OR tu.user_id = $user_id) "; |
|
2096 | $res = Database::query($sql); |
|
2097 | $groups = array(); |
|
2098 | while ($group = Database::fetch_array($res, 'ASSOC')) { |
|
2099 | $groups[] = $group; |
|
2100 | } |
|
2101 | ||
2102 | return $groups; |
|
2103 | } |
|
2104 | ||
2105 | /** |
|
2106 | * |
@@ 3353-3384 (lines=32) @@ | ||
3350 | * @param int $session_id |
|
3351 | * @return int |
|
3352 | */ |
|
3353 | public static function get_number_students_finish_exercise( |
|
3354 | $exercise_id, |
|
3355 | $course_code, |
|
3356 | $session_id |
|
3357 | ) { |
|
3358 | $track_exercises = Database::get_main_table( |
|
3359 | TABLE_STATISTIC_TRACK_E_EXERCISES |
|
3360 | ); |
|
3361 | $track_attempt = Database::get_main_table( |
|
3362 | TABLE_STATISTIC_TRACK_E_ATTEMPT |
|
3363 | ); |
|
3364 | ||
3365 | $exercise_id = intval($exercise_id); |
|
3366 | $course_code = Database::escape_string($course_code); |
|
3367 | $session_id = intval($session_id); |
|
3368 | ||
3369 | $sql = "SELECT DISTINCT exe_user_id |
|
3370 | FROM $track_exercises e |
|
3371 | INNER JOIN $track_attempt a ON (a.exe_id = e.exe_id) |
|
3372 | WHERE |
|
3373 | exe_exo_id = $exercise_id AND |
|
3374 | course_code = '$course_code' AND |
|
3375 | e.session_id = $session_id AND |
|
3376 | status = ''"; |
|
3377 | $result = Database::query($sql); |
|
3378 | $return = 0; |
|
3379 | if ($result) { |
|
3380 | $return = Database::num_rows($result); |
|
3381 | ||
3382 | } |
|
3383 | return $return; |
|
3384 | } |
|
3385 | ||
3386 | /** |
|
3387 | * @param string $in_name is the name and the id of the <select> |
@@ 673-694 (lines=22) @@ | ||
670 | * return total score for test exe_id for all question in the category $in_cat_id for user |
|
671 | * If no question for this category, return "" |
|
672 | */ |
|
673 | public static function getCatScoreForExeidForUserid($in_cat_id, $in_exe_id, $in_user_id) |
|
674 | { |
|
675 | $tbl_track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
676 | $tbl_question_rel_category = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
677 | $in_cat_id = intval($in_cat_id); |
|
678 | $in_exe_id = intval($in_exe_id); |
|
679 | $in_user_id = intval($in_user_id); |
|
680 | ||
681 | $query = "SELECT DISTINCT |
|
682 | marks, exe_id, user_id, ta.question_id, category_id |
|
683 | FROM $tbl_track_attempt ta , $tbl_question_rel_category qrc |
|
684 | WHERE |
|
685 | ta.question_id=qrc.question_id AND |
|
686 | qrc.category_id=$in_cat_id AND |
|
687 | exe_id=$in_exe_id AND user_id=$in_user_id"; |
|
688 | $res = Database::query($query); |
|
689 | $totalcatscore = ""; |
|
690 | while ($data = Database::fetch_array($res)) { |
|
691 | $totalcatscore += $data['marks']; |
|
692 | } |
|
693 | return $totalcatscore; |
|
694 | } |
|
695 | ||
696 | /** |
|
697 | * return the number max of question in a category |