OSDN Git Service

add a submit flag to the achievement field
authoronuxy <n.nanatunoko@gmail.com>
Mon, 10 Sep 2012 16:35:47 +0000 (01:35 +0900)
committeronuxy <n.nanatunoko@gmail.com>
Mon, 10 Sep 2012 16:35:47 +0000 (01:35 +0900)
CUTEn/src/jp/ac/titech/sharp4k/cuten/Achievement.java
CUTEn/src/jp/ac/titech/sharp4k/cuten/SQLHelper.java

index 6859471..888280b 100644 (file)
@@ -7,10 +7,12 @@ import android.database.sqlite.SQLiteDatabase;
 public class Achievement {
        private Task task;
        private int[] result;
+       private int submitted;
 
        public Achievement(Task task, String result) {
                this.task = task;
                setResultString(result);
+               submitted = 0;
        }
 
        public Task getTask() {
@@ -21,6 +23,10 @@ public class Achievement {
                return result;
        }
 
+       public boolean getSubmitted() {
+               return submitted == 1;
+       }
+
        public String getResultString() {
                StringBuilder str = new StringBuilder(result.length * 3);
                for (int i = 0; i < result.length; i++) {
@@ -44,10 +50,19 @@ public class Achievement {
                }
        }
 
+       public void setSubmitted(boolean submitted) {
+               if (submitted) {
+                       this.submitted = 1;
+               } else {
+                       this.submitted = 0;
+               }
+       }
+
        public long replace(SQLiteDatabase db) {
                ContentValues row = new ContentValues();
                row.put("task_id", getTask().getId());
                row.put("result", getResultString());
+               row.put("submitted", submitted);
                return db.insertWithOnConflict("achievements", null, row,
                                SQLiteDatabase.CONFLICT_REPLACE);
        }
index 1885cd1..9e709ea 100644 (file)
@@ -20,7 +20,7 @@ public class SQLHelper extends SQLiteOpenHelper {
                db.execSQL("CREATE TABLE \"tasks\" (\"id\" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, \"name\" varchar(255), \"lecture_id\" integer);");
                db.execSQL("CREATE TABLE \"apks\" (\"id\" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, \"name\" varchar(255), \"revision\" integer, \"task_id\" integer);");
                db.execSQL("CREATE TABLE \"selected_lectures\" (\"id\" INTEGER PRIMARY KEY NOT NULL);");
-               db.execSQL("CREATE TABLE \"achievements\" (\"task_id\"  INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, \"result\" varchar(255));");
+               db.execSQL("CREATE TABLE \"achievements\" (\"task_id\"  INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, \"result\" varchar(255),\"submitted\" integer);");
                db.execSQL("CREATE INDEX \"index_lectures_on_teacher_id\" ON \"lectures\" (\"teacher_id\");");
                db.execSQL("CREATE INDEX \"index_tasks_on_lecture_id\" ON \"tasks\" (\"lecture_id\");");
                db.execSQL("CREATE INDEX \"index_apks_on_task_id\" ON \"apks\" (\"task_id\");");