Code Duplication    Length = 16-20 lines in 3 locations

main/exercise/answer.class.php 1 location

@@ 341-357 (lines=17) @@
338
	 * return array answer by id else return a bool
339
	 * @param integer $auto_id
340
	 */
341
	public function selectAnswerByAutoId($auto_id)
342
	{
343
		$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
344
345
		$auto_id = intval($auto_id);
346
		$sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER
347
				WHERE c_id = {$this->course_id} AND id_auto='$auto_id'";
348
		$rs = Database::query($sql);
349
350
		if (Database::num_rows($rs) > 0) {
351
			$row = Database::fetch_array($rs, 'ASSOC');
352
353
			return $row;
354
		}
355
356
		return false;
357
	}
358
359
    /**
360
     * returns the answer title from an answer's position

main/survey/survey.lib.php 1 location

@@ 4981-5000 (lines=20) @@
4978
     * @param $surveyId
4979
     * @return boolean return true if the survey has answers, false otherwise
4980
     */
4981
    public static function checkIfSurveyHasAnswers($surveyId)
4982
    {
4983
        $tableSurveyAnswer = Database :: get_course_table(TABLE_SURVEY_ANSWER);
4984
        $courseId = api_get_course_int_id();
4985
4986
        $sql = "SELECT * FROM $tableSurveyAnswer
4987
                WHERE
4988
                    c_id = $courseId AND
4989
                    survey_id='".$surveyId."'
4990
                ORDER BY answer_id, user ASC";
4991
        $result = Database::query($sql);
4992
4993
        $response = Database::affected_rows($result);
4994
4995
        if ($response > 0) {
4996
            return true;
4997
        }
4998
4999
        return false;
5000
    }
5001
}
5002

main/forum/forumfunction.inc.php 1 location

@@ 982-997 (lines=16) @@
979
 * @author Patrick Cool <[email protected]>, Ghent University
980
 * @version february 2006, dokeos 1.8
981
 */
982
function check_if_last_post_of_thread($thread_id)
983
{
984
    $table_posts = Database :: get_course_table(TABLE_FORUM_POST);
985
    $course_id = api_get_course_int_id();
986
    $sql = "SELECT * FROM $table_posts
987
            WHERE c_id = $course_id AND thread_id = ".intval($thread_id)."
988
            ORDER BY post_date DESC";
989
    $result = Database::query($sql);
990
    if (Database::num_rows($result) > 0) {
991
        $row = Database::fetch_array($result);
992
993
        return $row;
994
    } else {
995
        return false;
996
    }
997
}
998
999
/**
1000
 * @param $content what is it that we want to make (in)visible: forum category, forum, thread, post