Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Controller
- public class TeacherController {
- TestController testcont = TestController.getInstance();
- @RequestMapping(value = "/sendTest", method = RequestMethod.POST)
- public String sendTest()
- throws IOException, ServletException{
- for(Test test : testcont.showAllTests()){
- if(test.getName().equals("selection")){
- testcont.SetActiveTest(test);
- System.out.println(testcont.getActiveTest());
- //return "Test sent successfully to students! <a href='/Teacher'>Back</a>";
- }
- }
- //return "Something went wrong <a href='/Teacher'>Back</a>";
- return "Teacher";
- }
- @RequestMapping(value = "/resetCurrentTest", method = RequestMethod.POST)
- public String resetCurrentTest(){
- testcont.SetActiveTest(null);
- //return "Current test for students was cleared! <a href='/Teacher'>Back</a>";
- return "Teacher";
- }
- //@RequestMapping(value = "/currentTestOptions", method = RequestMethod.GET)
- @ModelAttribute("currentTestOptions")
- public List<Test> currentTestOptions() {
- return testcont.showAllTests();
- }
- //@RequestMapping(value = "/availableTestList", method = RequestMethod.GET)
- @ModelAttribute("availableTestList")
- public List<Test> availableTestList(){
- return testcont.showAllTests();
- }
- }
- <body>
- <p>
- <a href='/Teacher/NewTest'>New Test upload</a>
- </p>
- <div
- style='height: 150px; width: 400px; border: 1px solid #ccc; font: 16px/26px Georgia, Garamond, Serif; overflow: auto;'>
- <form action='@{/sendTest()}' method='post'>
- <fieldset>
- <label>Select test</label>
- <select class="form-control" th:field="${test.getName}">
- <option
- th:each="test : ${currentTestOptions}"
- th:text="${test.getName}"
- ></option>
- </select>
- </fieldset>
- <input type='submit' value='Submit'>
- </form>
- </div>
- <form action='@{/resetCurrentTest}' method='post'>
- <input type='submit' value='Clear'>
- </form>
- <a> Current Test for students: </a>
- <p th:text="@{/getActiveTest}" ></p>
- <p>All available tests on server:</p>
- <div
- style='height: 200px; width: 400px; border: 1px solid #ccc; font: 16px/26px Georgia, Garamond, Serif; overflow: auto;'>
- <th:block th:each="test : @{availableTestList}">
- </div>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement