//云端数据同步导本地
import db from "./db";

export async function queryStudentCount(store) {
  db.init();
  const results = await db.query(
    "select count(*) as count from eb_exam_student where exam_id=?",
    [store.env.exam.id]
  );
  return results[0].count;
}

export async function replaceStudents(students) {
  db.init();
  await db.batchQuery(
    // "select 1 from eb_exam_student",
    // []
    "replace into eb_exam_student(id, exam_id, school_id\
              , exam_number, secret_number, name, student_code, subject_code, subject_name, campus_name\
              , package_code, batch_code, sheet_count, slice_count, answers, is_upload\
              , is_absent, is_manual_absent, is_breach, is_exception\
              , objective_score, subjective_score, objective_score_list, subjective_score_list, subjective_status\
              , exam_site, exam_room, remark, college, class_name, teacher, paper_type) \
              values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,?,?,?,?,?,?,?,?,?,?,?,?)",
    students
  );
}

export async function replacePackage(packageData) {
  db.init();
  await db.batchQuery(
    // "select 1 from eb_exam_student",
    // []
    "replace into eb_exam_package(exam_id, code, pic_count) values (?,?,?)",
    packageData
  );
}
