public static List <MultipleChoice> LoadAllMultipleChoice(long typeId) { List <MultipleChoice> list = new List <MultipleChoice>(); string sql = String.Format("select * from {0} as a left join {1} as b on a.typeid = b.id ", TABLE_NAME, ProblemType.TABLE_NAME); if (typeId != -1) { sql += " where typeid = " + typeId; } DataSet ds = SQLiteHelper.Query(sql); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { MultipleChoice item = new MultipleChoice { id = (long)ds.Tables[0].Rows[i].ItemArray[0], content = (string)ds.Tables[0].Rows[i].ItemArray[1], aska = (string)ds.Tables[0].Rows[i].ItemArray[2], askb = (string)ds.Tables[0].Rows[i].ItemArray[3], askc = (string)ds.Tables[0].Rows[i].ItemArray[4], askd = (string)ds.Tables[0].Rows[i].ItemArray[5], ans = (string)ds.Tables[0].Rows[i].ItemArray[6], typeId = (long)ds.Tables[0].Rows[i].ItemArray[7], isDone = (long)ds.Tables[0].Rows[i].ItemArray[8], typeName = (string)ds.Tables[0].Rows[i].ItemArray[10] }; list.Add(item); } return(list); }
public static void ImportMultipleChoiceQuestion(string filePath) { DataSet ds = ExcelToDS(filePath); List <MultipleChoice> choiceList = new List <MultipleChoice>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { MultipleChoice item = new MultipleChoice { content = ds.Tables[0].Rows[i].ItemArray[0].ToString(), aska = ds.Tables[0].Rows[i].ItemArray[1].ToString(), askb = ds.Tables[0].Rows[i].ItemArray[2].ToString(), askc = ds.Tables[0].Rows[i].ItemArray[3].ToString(), askd = ds.Tables[0].Rows[i].ItemArray[4].ToString(), ans = ds.Tables[0].Rows[i].ItemArray[5].ToString(), typeName = ds.Tables[0].Rows[i].ItemArray[6].ToString() }; choiceList.Add(item); } DBManager.ImportMultipleChoice(choiceList); }
public static void UpdateHistory(MultipleChoice multipleChoice, int isRight) { UpdateHistory(TYPE_MULTIPLECHOICE, multipleChoice.id, USER_ID, isRight); }