コード例 #1
0
    /**
     * Retrieve evaluations where a student has results for
     * and return them as an array of Evaluation objects
     * @param int $cat_id parent category (use 'null' to retrieve them in all categories)
     * @param int $stud_id student id
     */
    public static function get_evaluations_with_result_for_student($cat_id = null, $stud_id)
    {
        $tbl_grade_evaluations = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
        $tbl_grade_results = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
        $sql = 'SELECT * FROM ' . $tbl_grade_evaluations . '
				WHERE id IN (
					SELECT evaluation_id FROM ' . $tbl_grade_results . '
					WHERE user_id = ' . intval($stud_id) . ' AND score IS NOT NULL
				)';
        if (!api_is_allowed_to_edit()) {
            $sql .= ' AND visible = 1';
        }
        if (isset($cat_id)) {
            $sql .= ' AND category_id = ' . intval($cat_id);
        } else {
            $sql .= ' AND category_id >= 0';
        }
        $result = Database::query($sql);
        $alleval = Evaluation::create_evaluation_objects_from_sql_result($result);
        return $alleval;
    }