|
@@ -3323,27 +3323,28 @@ class SurveyUtil
|
|
|
/**
|
|
|
* Check if the current survey has answers
|
|
|
*
|
|
|
- * @param $surveyId
|
|
|
+ * @param int $surveyId
|
|
|
* @return boolean return true if the survey has answers, false otherwise
|
|
|
*/
|
|
|
public static function checkIfSurveyHasAnswers($surveyId)
|
|
|
{
|
|
|
$tableSurveyAnswer = Database::get_course_table(TABLE_SURVEY_ANSWER);
|
|
|
$courseId = api_get_course_int_id();
|
|
|
+ $surveyId = (int)$surveyId;
|
|
|
+
|
|
|
+ if (empty($courseId) || empty($surveyId)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
$sql = "SELECT * FROM $tableSurveyAnswer
|
|
|
WHERE
|
|
|
c_id = $courseId AND
|
|
|
- survey_id='".$surveyId."'
|
|
|
+ survey_id = '".$surveyId."'
|
|
|
ORDER BY answer_id, user ASC";
|
|
|
$result = Database::query($sql);
|
|
|
|
|
|
$response = Database::affected_rows($result);
|
|
|
|
|
|
- if ($response > 0) {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ return $response > 0;
|
|
|
}
|
|
|
}
|