public ExerciseResultInfo(Exercise exercise, DateTime dateOfPassing, int errorsCount, int assesment, int speed) { this.exercise=exercise; this.dateOfPassing = dateOfPassing; this.errorsCount=errorsCount; this.assesment = assesment; this.speed = speed; this.level = level; }
public ExerciseResultInfo(Exercise exercise, DateTime dateOfPassing, int errorsCount, int assesment, double speed, int spendetTime) { this.exercise=exercise; this.exerciseId = exercise.id; this.dateOfPassing = dateOfPassing; this.errorsCount=errorsCount; this.assesment = assesment; this.speed = speed; this.level = exercise.level; this.spendetTime = spendetTime; }
private static string generateExerciseID(Exercise exercise) { //connection.Open(); command = new SQLiteCommand("SELECT * FROM 'Exercise' WHERE level = @param1 ORDER BY exercise_id DESC;", connection); command.Parameters.Add(new SQLiteParameter("@param1", exercise.level)); ; reader = command.ExecuteReader(); string exercise_id = ""; if (reader.Read()) { exercise_id = reader["exercise_id"].ToString(); int lastId = Convert.ToInt32(exercise_id.Substring(1)); lastId++; exercise_id = exercise.level.ToString() + lastId.ToString(); } else exercise_id = exercise.level.ToString() + "1"; //connection.Close(); return exercise_id; }
public static void SaveExercise(Exercise exercise) { connection.Open(); string exercise_id = generateExerciseID(exercise); command = new SQLiteCommand("INSERT INTO Exercise (max_time,max_errors,name,text,keyboard_areas,level,exercise_id) VALUES (@param1,@param2,@param3,@param4,@param5,@param6,@param7)", connection); command.Parameters.Add(new SQLiteParameter("@param1", exercise.maxTime)); command.Parameters.Add(new SQLiteParameter("@param2", exercise.maxErrors)); command.Parameters.Add(new SQLiteParameter("@param3", exercise.name)); command.Parameters.Add(new SQLiteParameter("@param4", exercise.text)); command.Parameters.Add(new SQLiteParameter("@param5", exercise.getAreasAsString())); command.Parameters.Add(new SQLiteParameter("@param6", exercise.level)); command.Parameters.Add(new SQLiteParameter("@param7", exercise_id)); command.ExecuteNonQuery(); connection.Close(); }
public static List<Exercise> LoadExercises(int exLevel) { List<Exercise> exercises = new List<Exercise>(); connection.Open(); command = new SQLiteCommand("SELECT * FROM 'Exercise' where level=@param1;", connection); command.Parameters.Add(new SQLiteParameter("@param1", exLevel)); reader = command.ExecuteReader(); while (reader.Read()) { string name = reader["name"].ToString(); string text = reader["text"].ToString(); string keyboardAreas = reader["keyboard_areas"].ToString(); int level = Convert.ToInt16(reader["level"].ToString()); int maxTime = Convert.ToInt32(reader["max_time"].ToString()); int maxErrors = Convert.ToInt32(reader["max_errors"].ToString()); int id = Convert.ToInt32(reader["exercise_id"].ToString()); string areas = reader["keyboard_areas"].ToString(); List<KeyboardArea> listAreas = Exercise.getAreasList(areas); Exercise exercise = new Exercise(id, name, text, listAreas, maxErrors, maxTime); exercises.Add(exercise); } connection.Close(); return exercises; }