$questions = get_questions(); $exam_questions = get_exam_questions($exam_id); foreach ($exam_questions as $i => $quest) { $in_exam[$quest['ID']] = true; } foreach ($questions as $i => $quest) { if (!isset($in_exam[$quest['ID']])) { $in_exam[$quest['ID']] = false; } } ?> <?php if (isset($_POST['submit_exam'])) { clear_exam($exam_id); foreach ($_POST as $key => $value) { $arr = explode("_", $key); if ($arr[0] == 'checkbox') { $question_id = $arr[1]; add_question_to_exam($question_id, $exam_id); } } header("Location: " . pageURL()); } ?> <html> <head> <title>Edit Exam</title>
clear_exam("examdetail", $exam_id); if ($link) { mysqli_close($link); } sleep(DELAY_SEC); //echo -__LINE__; echo ERR_INSERT_DATABASE; return; } } // save to json file, file_name id.json $json_file_name = EXAM_FILES_DIR . "/" . $exam_id . ".json"; $exam_json = json_encode(array("exam_id" => (int) $exam_id, "exam_name" => $exam_name, "status" => (int) $exam_status, "type" => (int) $exam_type, "begin" => (int) $from_timestamp, "end" => (int) $to_timestamp, "duration" => (int) $exam_duration, "ans_type" => (int) $exam_answer_type, "description" => $exam_desc, "location" => (int) $exam_location, "password" => $exam_password, "allow_times" => (int) $exam_allow_times, "qualify_percent" => (int) $exam_qualify_percent, "questions" => $problems)); if (!file_put_contents($json_file_name, $exam_json)) { clear_exam("exams", $exam_id); clear_exam("examdetail", $exam_id); echo ERR_SAVE_JSON_FILE; return; } insert_select_problems($exam_id, $select_problems); insert_problem_sets($exam_id, $problem_sets); echo 0; return; function insert_into_examdetail($exam_id, $prob_id, $score) { $ret = SUCCESS; $link = @mysqli_connect(DB_HOST, ADMIN_ACCOUNT, ADMIN_PASSWORD, CONNECT_DB); if (!$link) { sleep(DELAY_SEC); return DB_ERROR; }