Commit 61c5da7dd1bd6e85cf4689b438265ded9735126c
Merge branch 'develop' of http://120.78.57.84/Elvis/SunvoteEducation into develop
Showing
4 changed files
with
61 additions
and
111 deletions
resources/mybatis1/sunvote/HomeworkProblemMapper.xml
| @@ -94,6 +94,16 @@ | @@ -94,6 +94,16 @@ | ||
| 94 | HOMEWORKPROBLEM_ID = #{HOMEWORKPROBLEM_ID} | 94 | HOMEWORKPROBLEM_ID = #{HOMEWORKPROBLEM_ID} |
| 95 | </select> | 95 | </select> |
| 96 | 96 | ||
| 97 | + <select id="findByCodeAndRank" parameterType="pd" resultType="pd"> | ||
| 98 | + select | ||
| 99 | + <include refid="Field"></include> | ||
| 100 | + from | ||
| 101 | + <include refid="tableName"></include> | ||
| 102 | + where | ||
| 103 | + CODE = #{CODE}, | ||
| 104 | + and RANK = #{RANK} | ||
| 105 | + </select> | ||
| 106 | + | ||
| 97 | <!-- 列表 --> | 107 | <!-- 列表 --> |
| 98 | <select id="datalistPage" parameterType="page" resultType="pd"> | 108 | <select id="datalistPage" parameterType="page" resultType="pd"> |
| 99 | select | 109 | select |
src/com/fh/controller/sunvote/homework/HomeworkController.java
| @@ -44,7 +44,8 @@ import com.fh.util.StringUtil; | @@ -44,7 +44,8 @@ import com.fh.util.StringUtil; | ||
| 44 | import com.google.gson.Gson; | 44 | import com.google.gson.Gson; |
| 45 | 45 | ||
| 46 | /** | 46 | /** |
| 47 | - * 说明:作业 创建人:FH Q313596790 创建时间:2019-03-07 | 47 | + * 说明:作业 创建人:FH Q313596790 |
| 48 | + * 创建时间:2019-03-07 | ||
| 48 | */ | 49 | */ |
| 49 | @Controller | 50 | @Controller |
| 50 | @RequestMapping(value = "/homework") | 51 | @RequestMapping(value = "/homework") |
| @@ -321,75 +322,6 @@ public class HomeworkController extends BaseController { | @@ -321,75 +322,6 @@ public class HomeworkController extends BaseController { | ||
| 321 | return modelAndView; | 322 | return modelAndView; |
| 322 | } | 323 | } |
| 323 | 324 | ||
| 324 | - /** | ||
| 325 | - * 传入homework_id | ||
| 326 | - * index 第几题 | ||
| 327 | - * @return | ||
| 328 | - * @throws Exception | ||
| 329 | - */ | ||
| 330 | - @RequestMapping(value = "/homeworkindexview") | ||
| 331 | - public ModelAndView homeworkindexview() throws Exception { | ||
| 332 | - PageData pageData = this.getPageData(); | ||
| 333 | - ModelAndView modelAndView = getModelAndView(); | ||
| 334 | - | ||
| 335 | - String homeworkId = pageData.getString("HOMEWORK_ID"); | ||
| 336 | - String index = pageData.getString("INDEX"); | ||
| 337 | - int indexint = Integer.parseInt(index); | ||
| 338 | - List<PageData> data = homeworkReporkService.findNoAnswerByHomeworkID(pageData); | ||
| 339 | - List<PageData> result = new ArrayList(); | ||
| 340 | - PageData aresult = new PageData(); | ||
| 341 | - aresult.put("ANSWER", "A"); | ||
| 342 | - PageData bresult = new PageData(); | ||
| 343 | - bresult.put("ANSWER", "B"); | ||
| 344 | - PageData cresult = new PageData(); | ||
| 345 | - cresult.put("ANSWER", "C"); | ||
| 346 | - PageData dresult = new PageData(); | ||
| 347 | - dresult.put("ANSWER", "D"); | ||
| 348 | - PageData eresult = new PageData(); | ||
| 349 | - eresult.put("ANSWER", ""); | ||
| 350 | - result.add(aresult); | ||
| 351 | - result.add(bresult); | ||
| 352 | - result.add(cresult); | ||
| 353 | - result.add(dresult); | ||
| 354 | - result.add(eresult); | ||
| 355 | - for(PageData pd : data){ | ||
| 356 | - String answer = pd.getString("ANSWER"); | ||
| 357 | - if(!StringUtils.isEmpty(answer)){ | ||
| 358 | - String[] answers = answer.split(";"); | ||
| 359 | - if(answers.length >= indexint -1){ | ||
| 360 | - String ans = answers[indexint - 1]; | ||
| 361 | - String[] anss = ans.split(":"); | ||
| 362 | - if(anss != null && anss.length == 2){ | ||
| 363 | - PageData tresult = null; | ||
| 364 | - for(PageData ptd : result){ | ||
| 365 | - if(anss[0].toUpperCase().equals(anss[0].toUpperCase())){ | ||
| 366 | - tresult = ptd; | ||
| 367 | - } | ||
| 368 | - } | ||
| 369 | - if(tresult == null){ | ||
| 370 | - tresult = new PageData(); | ||
| 371 | - result.add(tresult); | ||
| 372 | - } | ||
| 373 | - List<String> list = (List)tresult.get("STUDENTS"); | ||
| 374 | - if(list == null){ | ||
| 375 | - list = new ArrayList(); | ||
| 376 | - } | ||
| 377 | - list.add(pd.getString("STUDENT_NAME")); | ||
| 378 | - tresult.put("ANSWER", anss[0].toUpperCase()); | ||
| 379 | - tresult.put("STUDENTS", list); | ||
| 380 | - tresult.put("RIGHT", !"0".equals(anss[1])); | ||
| 381 | - } | ||
| 382 | - } | ||
| 383 | - } | ||
| 384 | - } | ||
| 385 | - | ||
| 386 | - modelAndView.addObject("datas", new Gson().toJson(result)); | ||
| 387 | -// modelAndView.addObject("datas",result); | ||
| 388 | - | ||
| 389 | - modelAndView.setViewName(""); | ||
| 390 | - return modelAndView; | ||
| 391 | - } | ||
| 392 | - | ||
| 393 | 325 | ||
| 394 | /** | 326 | /** |
| 395 | * 传入homework_id | 327 | * 传入homework_id |
| @@ -406,53 +338,47 @@ public class HomeworkController extends BaseController { | @@ -406,53 +338,47 @@ public class HomeworkController extends BaseController { | ||
| 406 | String index = pageData.getString("INDEX"); | 338 | String index = pageData.getString("INDEX"); |
| 407 | int indexint = Integer.parseInt(index); | 339 | int indexint = Integer.parseInt(index); |
| 408 | List<PageData> data = homeworkReporkService.findNoAnswerByHomeworkID(pageData); | 340 | List<PageData> data = homeworkReporkService.findNoAnswerByHomeworkID(pageData); |
| 409 | - List<PageData> result = new ArrayList(); | ||
| 410 | - PageData aresult = new PageData(); | ||
| 411 | - aresult.put("ANSWER", "A"); | ||
| 412 | - PageData bresult = new PageData(); | ||
| 413 | - bresult.put("ANSWER", "B"); | ||
| 414 | - PageData cresult = new PageData(); | ||
| 415 | - cresult.put("ANSWER", "C"); | ||
| 416 | - PageData dresult = new PageData(); | ||
| 417 | - dresult.put("ANSWER", "D"); | ||
| 418 | - PageData eresult = new PageData(); | ||
| 419 | - eresult.put("ANSWER", ""); | ||
| 420 | - result.add(aresult); | ||
| 421 | - result.add(bresult); | ||
| 422 | - result.add(cresult); | ||
| 423 | - result.add(dresult); | ||
| 424 | - result.add(eresult); | ||
| 425 | - for(PageData pd : data){ | ||
| 426 | - String answer = pd.getString("ANSWER"); | ||
| 427 | - if(!StringUtils.isEmpty(answer)){ | ||
| 428 | - String[] answers = answer.split(";"); | ||
| 429 | - if(answers.length >= indexint -1){ | ||
| 430 | - String ans = answers[indexint - 1]; | ||
| 431 | - String[] anss = ans.split(","); | ||
| 432 | - if(anss != null && anss.length == 2){ | ||
| 433 | - PageData tresult = null; | ||
| 434 | - for(PageData ptd : result){ | ||
| 435 | - if(anss[0].toUpperCase().equals(anss[0].toUpperCase())){ | ||
| 436 | - tresult = ptd; | 341 | + pageData = homeworkService.findById(pageData); |
| 342 | + pageData.put("RANK", indexint); | ||
| 343 | + pageData = homeworkproblemService.findByCodeAndRank(pageData); | ||
| 344 | + pageData.remove("HOMEWORKPROBLEM_ID"); | ||
| 345 | + pageData.remove("HOMEWORK_ID"); | ||
| 346 | + pageData.remove("CODE"); | ||
| 347 | + pageData.remove("RANK"); | ||
| 348 | + pageData.remove("NAME"); | ||
| 349 | + pageData.remove("TYPE"); | ||
| 350 | + String optionNumStr = pageData.getString("OPTION_NUM"); | ||
| 351 | + String rightAnswer = pageData.getString("RIGHT_ANSWER"); | ||
| 352 | + rightAnswer = rightAnswer.toUpperCase(); | ||
| 353 | + int optionNum = Integer.parseInt(optionNumStr); | ||
| 354 | + | ||
| 355 | + List<List<String>> resultData = new ArrayList(); | ||
| 356 | + for (int i = 0; i < optionNum; i++) { | ||
| 357 | + List<String> optionAnswer = new ArrayList(); | ||
| 358 | + resultData.add(optionAnswer); | ||
| 359 | + for (PageData pd : data) { | ||
| 360 | + String answer = pd.getString("ANSWER"); | ||
| 361 | + if (!StringUtils.isEmpty(answer)) { | ||
| 362 | + String[] answers = answer.split(";"); | ||
| 363 | + if (answers.length >= indexint - 1) { | ||
| 364 | + String ans = answers[indexint - 1]; | ||
| 365 | + String[] anss = ans.split(","); | ||
| 366 | + if (anss != null && anss.length == 2) { | ||
| 367 | + char option = (char)('A' + i) ; | ||
| 368 | + if(anss[0] != null){ | ||
| 369 | + if(anss[0].contains("" + option)){ | ||
| 370 | + optionAnswer.add(pd.getString("STUDENT_NAME")); | ||
| 371 | + } | ||
| 437 | } | 372 | } |
| 438 | } | 373 | } |
| 439 | - if(tresult == null){ | ||
| 440 | - tresult = new PageData(); | ||
| 441 | - result.add(tresult); | ||
| 442 | - } | ||
| 443 | - List<String> list = (List)tresult.get("STUDENTS"); | ||
| 444 | - if(list == null){ | ||
| 445 | - list = new ArrayList(); | ||
| 446 | - } | ||
| 447 | - list.add(pd.getString("STUDENT_NAME")); | ||
| 448 | - tresult.put("ANSWER", anss[0].toUpperCase()); | ||
| 449 | - tresult.put("STUDENTS", list); | ||
| 450 | - tresult.put("RIGHT", !"0".equals(anss[1])); | ||
| 451 | } | 374 | } |
| 452 | } | 375 | } |
| 453 | } | 376 | } |
| 454 | } | 377 | } |
| 455 | - return new Gson().toJson(result); | 378 | + Map<String,Object> map = new HashMap(); |
| 379 | + map.put("ANSWER", rightAnswer); | ||
| 380 | + map.put("DATA", resultData); | ||
| 381 | + return new Gson().toJson(map); | ||
| 456 | 382 | ||
| 457 | } | 383 | } |
| 458 | 384 |
src/com/fh/service/sunvote/homeworkproblem/HomeworkProblemManager.java
| @@ -64,6 +64,12 @@ public interface HomeworkProblemManager{ | @@ -64,6 +64,12 @@ public interface HomeworkProblemManager{ | ||
| 64 | */ | 64 | */ |
| 65 | public PageData findById(PageData pd)throws Exception; | 65 | public PageData findById(PageData pd)throws Exception; |
| 66 | 66 | ||
| 67 | + /**通过id获取数据 | ||
| 68 | + * @param pd | ||
| 69 | + * @throws Exception | ||
| 70 | + */ | ||
| 71 | + public PageData findByCodeAndRank(PageData pd)throws Exception; | ||
| 72 | + | ||
| 67 | /**批量删除 | 73 | /**批量删除 |
| 68 | * @param ArrayDATA_IDS | 74 | * @param ArrayDATA_IDS |
| 69 | * @throws Exception | 75 | * @throws Exception |
src/com/fh/service/sunvote/homeworkproblem/impl/HomeworkProblemService.java
| @@ -90,6 +90,14 @@ public class HomeworkProblemService implements HomeworkProblemManager{ | @@ -90,6 +90,14 @@ public class HomeworkProblemService implements HomeworkProblemManager{ | ||
| 90 | return (PageData)dao.findForObject("HomeworkProblemMapper.findById", pd); | 90 | return (PageData)dao.findForObject("HomeworkProblemMapper.findById", pd); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | + /**通过id获取数据 | ||
| 94 | + * @param pd | ||
| 95 | + * @throws Exception | ||
| 96 | + */ | ||
| 97 | + public PageData findByCodeAndRank(PageData pd)throws Exception{ | ||
| 98 | + return (PageData)dao.findForObject("HomeworkProblemMapper.findByCodeAndRank", pd); | ||
| 99 | + } | ||
| 100 | + | ||
| 93 | /**批量删除 | 101 | /**批量删除 |
| 94 | * @param ArrayDATA_IDS | 102 | * @param ArrayDATA_IDS |
| 95 | * @throws Exception | 103 | * @throws Exception |