Code Duplication    Length = 22-32 lines in 3 locations

main/exercice/TestCategory.php 1 location

@@ 670-691 (lines=22) @@
667
	 * return total score for test exe_id for all question in the category $in_cat_id for user
668
	 * If no question for this category, return ""
669
	 */
670
	public static function getCatScoreForExeidForUserid($in_cat_id, $in_exe_id, $in_user_id)
671
	{
672
		$tbl_track_attempt		= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
673
		$tbl_question_rel_category = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
674
		$in_cat_id = intval($in_cat_id);
675
		$in_exe_id = intval($in_exe_id);
676
		$in_user_id = intval($in_user_id);
677
678
		$query = "SELECT DISTINCT
679
		            marks, exe_id, user_id, ta.question_id, category_id
680
                  FROM $tbl_track_attempt ta , $tbl_question_rel_category qrc
681
                  WHERE
682
                    ta.question_id=qrc.question_id AND
683
                    qrc.category_id=$in_cat_id AND
684
                    exe_id=$in_exe_id AND user_id=$in_user_id";
685
		$res = Database::query($query);
686
		$totalcatscore = "";
687
		while ($data = Database::fetch_array($res)) {
688
			$totalcatscore += $data['marks'];
689
		}
690
		return $totalcatscore;
691
	}
692
693
	/**
694
     * return the number max of question in a category

main/inc/lib/exercise.lib.php 1 location

@@ 3336-3367 (lines=32) @@
3333
     * @param int $session_id
3334
     * @return int
3335
     */
3336
    public static function get_number_students_finish_exercise(
3337
        $exercise_id,
3338
        $course_code,
3339
        $session_id
3340
    ) {
3341
        $track_exercises = Database::get_main_table(
3342
            TABLE_STATISTIC_TRACK_E_EXERCISES
3343
        );
3344
        $track_attempt = Database::get_main_table(
3345
            TABLE_STATISTIC_TRACK_E_ATTEMPT
3346
        );
3347
3348
        $exercise_id = intval($exercise_id);
3349
        $course_code = Database::escape_string($course_code);
3350
        $session_id = intval($session_id);
3351
3352
        $sql = "SELECT DISTINCT exe_user_id
3353
    		FROM $track_exercises e
3354
    		INNER JOIN $track_attempt a ON (a.exe_id = e.exe_id)
3355
    		WHERE
3356
    		    exe_exo_id 	 = $exercise_id AND
3357
    			course_code  = '$course_code' AND
3358
    			e.session_id = $session_id AND
3359
    			status = ''";
3360
        $result = Database::query($sql);
3361
        $return = 0;
3362
        if ($result) {
3363
            $return = Database::num_rows($result);
3364
3365
        }
3366
        return $return;
3367
    }
3368
3369
    /**
3370
     * @param string $in_name is the name and the id of the <select>

main/inc/lib/groupmanager.lib.php 1 location

@@ 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
     *