Commit d34f6711c31b59256838852990f1153f87b4a38d
1 parent
c617106f
试题
Showing
2 changed files
with
57 additions
and
71 deletions
WebRoot/WEB-INF/jsp/sunvote/teacher/teach_paper.jsp
src/com/fh/controller/api/V1.java
| ... | ... | @@ -5,6 +5,7 @@ import java.util.Date; |
| 5 | 5 | import java.util.Iterator; |
| 6 | 6 | import java.util.List; |
| 7 | 7 | import java.util.Map; |
| 8 | +import java.util.Set; | |
| 8 | 9 | |
| 9 | 10 | import javax.annotation.Resource; |
| 10 | 11 | import javax.servlet.http.HttpServletRequest; |
| ... | ... | @@ -52,11 +53,9 @@ import com.fh.service.sunvote.questiontype.QuestionTypeManager; |
| 52 | 53 | import com.fh.service.sunvote.school.SchoolManager; |
| 53 | 54 | import com.fh.service.sunvote.schoolgradesubject.SchoolGradeSubjectManager; |
| 54 | 55 | import com.fh.service.sunvote.sclass.SClassManager; |
| 55 | -import com.fh.service.sunvote.sclass.impl.SClassService; | |
| 56 | 56 | import com.fh.service.sunvote.student.StudentManager; |
| 57 | 57 | import com.fh.service.sunvote.studenttest.StudentTestManager; |
| 58 | 58 | import com.fh.service.sunvote.subject.SubjectManager; |
| 59 | -import com.fh.service.sunvote.subject.impl.SubjectService; | |
| 60 | 59 | import com.fh.service.sunvote.teacher.TeacherManager; |
| 61 | 60 | import com.fh.service.sunvote.teachingmaterial.TeachingMaterialManager; |
| 62 | 61 | import com.fh.service.sunvote.testpaper.TestPaperManager; |
| ... | ... | @@ -64,7 +63,6 @@ import com.fh.service.sunvote.testpaperinfo.TestPaperInfoManager; |
| 64 | 63 | import com.fh.service.sunvote.textbook.TextbookManager; |
| 65 | 64 | import com.fh.service.system.user.UserManager; |
| 66 | 65 | import com.fh.util.PageData; |
| 67 | -import com.fh.util.SpringBeanFactoryUtils; | |
| 68 | 66 | import com.fh.util.Tools; |
| 69 | 67 | |
| 70 | 68 | @Controller |
| ... | ... | @@ -529,91 +527,78 @@ public class V1 extends BaseController { |
| 529 | 527 | event("paperInfo"); |
| 530 | 528 | long cur = System.currentTimeMillis(); |
| 531 | 529 | PageData pd = this.getPageData(); |
| 532 | - ResponseGson<Paper> res = new ResponseGson<Paper>(); | |
| 530 | + ResponseGson<PageData> res = new ResponseGson<PageData>(); | |
| 533 | 531 | if (pd.containsKey("PAPER_ID")) { |
| 534 | 532 | try { |
| 535 | 533 | try { |
| 536 | - Paper paper = new Paper(); | |
| 537 | 534 | PageData ppd = paperService.findById(pd); |
| 538 | 535 | if (ppd != null) { |
| 539 | - paper.setTitle(ppd.getString("TITLE")); | |
| 540 | - paper.setExam_time(ppd.getString("EXAM_TIME")); | |
| 541 | - paper.setUser_id(ppd.getString("USER_ID")); | |
| 542 | - paper.setPaper_type(ppd.getString("PAPER_TYPE")); | |
| 543 | - paper.setSubject_id(ppd.getString("SUBJECT_ID")); | |
| 544 | - paper.setGrade_id(ppd.getString("GRADE_ID")); | |
| 545 | - paper.setScore(ppd.getString("SCORE")); | |
| 546 | - paper.setQuestions(new ArrayList<Question>()); | |
| 547 | - | |
| 548 | 536 | List<PageData> questList = v1Service |
| 549 | 537 | .getTestPaperInfo(pd); |
| 538 | + ppd.put("QUESTIONS", questList); | |
| 550 | 539 | for (PageData qpd : questList) { |
| 551 | - Question question = new Question(); | |
| 552 | - question.setAnswer(qpd.getString("ANSWER")); | |
| 553 | - question.setQuestion_id(qpd | |
| 554 | - .getString("QUESTION_ID")); | |
| 555 | - question.setSubject_id(qpd.getString("SUBJECT_ID")); | |
| 556 | - question.setChapter_id(qpd.getString("CHAPTER_ID")); | |
| 557 | - question.setProblem_type_id(qpd | |
| 558 | - .getString("PROBLEM_TYPE_ID")); | |
| 559 | - question.setKnowledge_id(qpd | |
| 560 | - .getString("KNOWLEDGE_ID")); | |
| 561 | - question.setContent(qpd.getString("CONTENT")); | |
| 562 | - question.setOption_num(qpd.getString("OPTION_NUM")); | |
| 563 | - question.setOption_content(qpd | |
| 564 | - .getString("OPTION_CONTENT")); | |
| 565 | - question.setDifficulty(qpd.getString("DIFFICULTY")); | |
| 566 | - question.setAnalysis(qpd.getString("ANALYSIS")); | |
| 567 | - question.setQuestion_from(qpd | |
| 568 | - .getString("QUESTION_FROM")); | |
| 569 | - question.setScore(qpd.getString("SCORE")); | |
| 570 | - question.setPart_score(qpd.getString("PART_SCORE")); | |
| 571 | - question.setQuestionType(qpd | |
| 572 | - .getString("PROBLEM_TYPE_ID")); | |
| 573 | - question.setRank(qpd.getString("RANK")); | |
| 574 | - question.setNo_name(qpd.getString("NO_NAME")); | |
| 540 | + | |
| 541 | + String optionContent = qpd | |
| 542 | + .getString("OPTION_CONTENT"); | |
| 543 | + if (optionContent != null | |
| 544 | + && optionContent.startsWith("[") | |
| 545 | + && optionContent.endsWith("]")) { | |
| 546 | + String[] options = optionContent.substring(1, | |
| 547 | + optionContent.length() - 1).split(","); | |
| 548 | + qpd.put("OPTION_CONTENT", options); | |
| 549 | + } else { | |
| 550 | + qpd.put("OPTION_CONTENT", | |
| 551 | + new String[] { optionContent }); | |
| 552 | + } | |
| 575 | 553 | if ("-1".equals("" + qpd.getString("P_ID"))) { |
| 576 | 554 | PageData pidPd = new PageData(); |
| 577 | - pidPd.put("PID", question.getQuestion_id()); | |
| 578 | - question.setQuestions(new ArrayList<Question>()); | |
| 555 | + pidPd.put("PID", qpd.getString("QUESTION_ID")); | |
| 579 | 556 | List<PageData> qs = v1Service |
| 580 | 557 | .getQuestionsByPID(pidPd); |
| 581 | - for (PageData q : qs) { | |
| 582 | - Question qq = new Question(); | |
| 583 | - qq.setAnswer(q.getString("ANSWER")); | |
| 584 | - qq.setQuestion_id(q | |
| 585 | - .getString("QUESTION_ID")); | |
| 586 | - qq.setSubject_id(q.getString("SUBJECT_ID")); | |
| 587 | - qq.setChapter_id(q.getString("CHAPTER_ID")); | |
| 588 | - qq.setProblem_type_id(q | |
| 589 | - .getString("PROBLEM_TYPE_ID")); | |
| 590 | - qq.setKnowledge_id(q | |
| 591 | - .getString("KNOWLEDGE_ID")); | |
| 592 | - qq.setContent(q.getString("CONTENT")); | |
| 593 | - qq.setOption_num(q.getString("OPTION_NUM")); | |
| 594 | - qq.setOption_content(q | |
| 595 | - .getString("OPTION_CONTENT")); | |
| 596 | - qq.setDifficulty(q.getString("DIFFICULTY")); | |
| 597 | - qq.setAnalysis(q.getString("ANALYSIS")); | |
| 598 | - qq.setQuestion_from(q | |
| 599 | - .getString("QUESTION_FROM")); | |
| 600 | - qq.setScore(q.getString("SCORE")); | |
| 601 | - qq.setPart_score(q.getString("PART_SCORE")); | |
| 602 | - qq.setQuestionType(qpd | |
| 603 | - .getString("PROBLEM_TYPE_ID")); | |
| 604 | - qq.setRank(q.getString("RANK")); | |
| 605 | - qq.setNo_name(q.getString("NO_NAME")); | |
| 606 | - question.getQuestions().add(qq); | |
| 558 | + for (PageData pcd : qs) { | |
| 559 | + String optionContent1 = pcd | |
| 560 | + .getString("OPTION_CONTENT"); | |
| 561 | + if (optionContent1 != null | |
| 562 | + && optionContent1.startsWith("[") | |
| 563 | + && optionContent1.endsWith("]")) { | |
| 564 | + String[] options = optionContent1 | |
| 565 | + .substring( | |
| 566 | + 1, | |
| 567 | + optionContent1.length() - 1) | |
| 568 | + .split(","); | |
| 569 | + pcd.put("OPTION_CONTENT", options); | |
| 570 | + } else { | |
| 571 | + pcd.put("OPTION_CONTENT", | |
| 572 | + new String[] { optionContent1 }); | |
| 573 | + } | |
| 574 | + String[] keys = new String[pcd.keySet().size()]; | |
| 575 | + pcd.keySet().toArray(keys); | |
| 576 | + Iterator map1it = pcd.entrySet().iterator(); | |
| 577 | + for (String key : keys) { | |
| 578 | + pcd.put(key.toLowerCase(),pcd.get(key)); | |
| 579 | + pcd.remove(key.toUpperCase()); | |
| 580 | + } | |
| 607 | 581 | } |
| 582 | + qpd.put("QUESTIONS", qs); | |
| 608 | 583 | } |
| 609 | - if ("-1".equals(qpd.getString("P_ID")) | |
| 610 | - || "0".equals(qpd.getString("P_ID"))) { | |
| 611 | - paper.getQuestions().add(question); | |
| 584 | + | |
| 585 | + String[] keys = new String[qpd.keySet().size()]; | |
| 586 | + qpd.keySet().toArray(keys); | |
| 587 | + for (String key : keys) { | |
| 588 | + qpd.put(key.toLowerCase(), qpd.get(key)); | |
| 589 | + qpd.remove(key.toUpperCase()); | |
| 612 | 590 | } |
| 591 | + | |
| 592 | + } | |
| 593 | + String[] keys = new String[ppd.keySet().size()]; | |
| 594 | + ppd.keySet().toArray(keys); | |
| 595 | + for (String key : keys) { | |
| 596 | + ppd.put(key.toLowerCase(), ppd.get(key)); | |
| 597 | + ppd.remove(key.toUpperCase()); | |
| 613 | 598 | } |
| 614 | 599 | // pd.put("JSON", paper.toJson()); |
| 615 | - res.setData(paper); | |
| 616 | - logger.info(paper.toJson()); | |
| 600 | + res.setData(ppd); | |
| 601 | + logger.info(res.toJson()); | |
| 617 | 602 | |
| 618 | 603 | } |
| 619 | 604 | } catch (Exception ex) { | ... | ... |