Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. @Controller
  2. public class TeacherController {
  3.  
  4. TestController testcont = TestController.getInstance();
  5.  
  6.  
  7. @RequestMapping(value = "/sendTest", method = RequestMethod.POST)
  8. public String sendTest()
  9. throws IOException, ServletException{
  10.  
  11. for(Test test : testcont.showAllTests()){
  12. if(test.getName().equals("selection")){
  13. testcont.SetActiveTest(test);
  14. System.out.println(testcont.getActiveTest());
  15. //return "Test sent successfully to students! <a href='/Teacher'>Back</a>";
  16. }
  17. }
  18. //return "Something went wrong <a href='/Teacher'>Back</a>";
  19. return "Teacher";
  20. }
  21.  
  22. @RequestMapping(value = "/resetCurrentTest", method = RequestMethod.POST)
  23. public String resetCurrentTest(){
  24. testcont.SetActiveTest(null);
  25. //return "Current test for students was cleared! <a href='/Teacher'>Back</a>";
  26. return "Teacher";
  27. }
  28.  
  29.  
  30. //@RequestMapping(value = "/currentTestOptions", method = RequestMethod.GET)
  31. @ModelAttribute("currentTestOptions")
  32. public List<Test> currentTestOptions() {
  33. return testcont.showAllTests();
  34.  
  35. }
  36.  
  37. //@RequestMapping(value = "/availableTestList", method = RequestMethod.GET)
  38. @ModelAttribute("availableTestList")
  39. public List<Test> availableTestList(){
  40. return testcont.showAllTests();
  41. }
  42. }
  43.  
  44. <body>
  45. <p>
  46. <a href='/Teacher/NewTest'>New Test upload</a>
  47. </p>
  48. <div
  49. style='height: 150px; width: 400px; border: 1px solid #ccc; font: 16px/26px Georgia, Garamond, Serif; overflow: auto;'>
  50. <form action='@{/sendTest()}' method='post'>
  51. <fieldset>
  52. <label>Select test</label>
  53. <select class="form-control" th:field="${test.getName}">
  54. <option
  55.  
  56. th:each="test : ${currentTestOptions}"
  57. th:text="${test.getName}"
  58.  
  59. ></option>
  60. </select>
  61. </fieldset>
  62. <input type='submit' value='Submit'>
  63. </form>
  64. </div>
  65. <form action='@{/resetCurrentTest}' method='post'>
  66. <input type='submit' value='Clear'>
  67. </form>
  68. <a> Current Test for students: </a>
  69. <p th:text="@{/getActiveTest}" ></p>
  70. <p>All available tests on server:</p>
  71. <div
  72. style='height: 200px; width: 400px; border: 1px solid #ccc; font: 16px/26px Georgia, Garamond, Serif; overflow: auto;'>
  73. <th:block th:each="test : @{availableTestList}">
  74. </div>
  75. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement