Пример #1
0
 /**
  * This function deletes all the questions of a given survey
  * This function is normally only called when a survey is deleted
  *
  * @param int $survey_id the id of the survey that has to be deleted
  * @return true
  *
  * @author Patrick Cool <*****@*****.**>, Ghent University
  * @version January 2007
  */
 public static function delete_all_survey_questions($survey_id, $shared = false)
 {
     $course_id = api_get_course_int_id();
     // Table definitions
     $table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
     $course_condition = " c_id = {$course_id} AND ";
     if ($shared) {
         $course_condition = "";
         $table_survey_question = Database::get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION);
     }
     $sql = "DELETE FROM {$table_survey_question}\n\t\t        WHERE {$course_condition} survey_id='" . Database::escape_string($survey_id) . "'";
     // Deleting the survey questions
     Database::query($sql);
     // Deleting all the options of the questions of the survey
     survey_manager::delete_all_survey_questions_options($survey_id, $shared);
     // Deleting all the answers on this survey
     survey_manager::delete_all_survey_answers($survey_id);
 }