|
@@ -150,22 +150,23 @@ public class ExtraService {
|
|
|
|
|
|
|
|
|
|
HashMap<String,String> item_index_to_id=new HashMap<>();
|
|
HashMap<String,String> item_index_to_id=new HashMap<>();
|
|
|
|
+ HashMap<String,Integer>item_id_to_optionNum=new HashMap<>();
|
|
for(int i=0;i<itemArray.length();i++) {
|
|
for(int i=0;i<itemArray.length();i++) {
|
|
JSONObject itemObject = itemArray.getJSONObject(i);
|
|
JSONObject itemObject = itemArray.getJSONObject(i);
|
|
- String item_id=saveItem(itemObject,job_id);
|
|
+ String item_id=saveItem(itemObject,job_id,item_id_to_optionNum);
|
|
String item_index=itemObject.getString("index");
|
|
String item_index=itemObject.getString("index");
|
|
item_index_to_id.put(item_index,item_id);
|
|
item_index_to_id.put(item_index,item_id);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONArray workerArray=jsonObject.getJSONArray("workerList");
|
|
JSONArray workerArray=jsonObject.getJSONArray("workerList");
|
|
- createWorkerToItem(item_index_to_id,workerArray,job_id);
|
|
+ createWorkerToItem(item_index_to_id,workerArray,job_id,item_id_to_optionNum);
|
|
|
|
|
|
return job_id;
|
|
return job_id;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private String saveItem(JSONObject itemObject,String job_id){
|
|
+ private String saveItem(JSONObject itemObject,String job_id,HashMap<String,Integer>item_id_to_optionNum){
|
|
|
|
|
|
|
|
|
|
String description=itemObject.getString("description");
|
|
String description=itemObject.getString("description");
|
|
@@ -195,12 +196,13 @@ public class ExtraService {
|
|
options.add(optionObject.getString("option"));
|
|
options.add(optionObject.getString("option"));
|
|
}
|
|
}
|
|
Item item=new Item(description,img_urls,isRequired,isMultiple,file_urls,options,job_id);
|
|
Item item=new Item(description,img_urls,isRequired,isMultiple,file_urls,options,job_id);
|
|
- return itemDao.saveItem(item);
|
|
+ String item_id = itemDao.saveItem(item);
|
|
-
|
|
+ item_id_to_optionNum.put(item_id,optionArray.length());
|
|
|
|
+ return item_id;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private void createWorkerToItem(HashMap<String,String> item_index_to_id,JSONArray workerArray,String job_id){
|
|
+ private void createWorkerToItem(HashMap<String,String> item_index_to_id,JSONArray workerArray,String job_id,HashMap<String,Integer>item_id_to_optionNum){
|
|
HashMap<String,List<String>> worker_to_item=new HashMap<>();
|
|
HashMap<String,List<String>> worker_to_item=new HashMap<>();
|
|
|
|
|
|
for(int i=0;i<workerArray.length();i++){
|
|
for(int i=0;i<workerArray.length();i++){
|
|
@@ -216,7 +218,8 @@ public class ExtraService {
|
|
itemService.saveUserToItem(worker_id,itemIdList,job_id);
|
|
itemService.saveUserToItem(worker_id,itemIdList,job_id);
|
|
for(int j=0;j<itemIdList.size();j++){
|
|
for(int j=0;j<itemIdList.size();j++){
|
|
String item_id=itemIdList.get(j);
|
|
String item_id=itemIdList.get(j);
|
|
- String answer_id=itemService.saveAnswer(item_id,worker_id,job_id,new ArrayList<>(),new ArrayList<>());
|
|
+ int optionNum=item_id_to_optionNum.get(item_id);
|
|
|
|
+ String answer_id=itemService.saveAnswer(item_id,worker_id,job_id,optionNum);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|