|
@@ -154,10 +154,22 @@ public class ExtraService {
|
|
|
|
|
|
public Task saveTask(String id){
|
|
public Task saveTask(String id){
|
|
Task task=taskDao.findById(id);
|
|
Task task=taskDao.findById(id);
|
|
- if(task!=null)
|
|
|
|
- return task;
|
|
|
|
|
|
+ if(task!=null) {
|
|
|
|
+ long oldTime=task.getEnd_time();
|
|
|
|
+ //考试时间已过
|
|
|
|
+ if(oldTime>System.currentTimeMillis()){
|
|
|
|
+ return getAndSaveTaskInfo(id);
|
|
|
|
+ }else {
|
|
|
|
+ return task;
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ return getAndSaveTaskInfo(id);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Task getAndSaveTaskInfo(String id){
|
|
String result = HTTP.sendGet("http://www.mooctest.net/api/exam/" + id + "/info", "");
|
|
String result = HTTP.sendGet("http://www.mooctest.net/api/exam/" + id + "/info", "");
|
|
- if (result != null && !result.equals("")) {
|
|
|
|
|
|
+ if (!result.equals("")) {
|
|
JSONObject json = new JSONObject(result);
|
|
JSONObject json = new JSONObject(result);
|
|
long beginTime = json.getLong("beginTime");
|
|
long beginTime = json.getLong("beginTime");
|
|
long endTime = json.getLong("endTime");
|
|
long endTime = json.getLong("endTime");
|
|
@@ -166,9 +178,9 @@ public class ExtraService {
|
|
Task newTask = new Task(id, name,beginTime, endTime, totalMins, totalMins);
|
|
Task newTask = new Task(id, name,beginTime, endTime, totalMins, totalMins);
|
|
taskDao.save(newTask);
|
|
taskDao.save(newTask);
|
|
return newTask;
|
|
return newTask;
|
|
|
|
+ }else{
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
- return null;
|
|
|
|
-// return taskDao.findById(id);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public boolean updateTask(String id,double writeMins){
|
|
public boolean updateTask(String id,double writeMins){
|