/** * Removes an instance of the feedbackccna from the database * * Given an ID of an instance of this module, * this function will permanently delete the instance * and any data that depends on it. * * @param int $id Id of the module instance * @return boolean Success/Failure */ function feedbackccna_delete_instance($id) { global $DB; if (!($feedbackccna = $DB->get_record('feedbackccna', array('id' => $id)))) { return false; } $section_id = $DB->get_field_sql("SELECT section FROM {course_modules}\n WHERE instance = ?\n AND added = ?", array($feedbackccna->id, $feedbackccna->timecreated)); $section = get_correct_section($section_id); delete_feedback_module($feedbackccna->course, $section, $feedbackccna->id); $DB->delete_records('feedbackccna', array('id' => $feedbackccna->id)); return true; }
function get_feedback_answer_id($course_id, $student_id, $section, $f_id, $which_way, $type) { global $DB; $section = get_correct_section($section); $id_records = $DB->get_records_sql("SELECT a.id FROM {feedbackccna_answer} a\n JOIN {feedbackccna_module} m\n ON a.module_id = m.id\n AND a.student_id = ?\n AND m.section = ?\n AND m.course_id = ?\n AND m.which_way = ?\n AND type = ?", array($student_id, $section, $course_id, $which_way, $type)); foreach ($id_records as $id_record) { return $id_record->id; } return 0; }