@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { Session session = RequestAdapter.getSession(request); TaskDAOIf taskDAO = DAOFactory.TaskDAOIf(session); Task task = taskDAO.getTask(Util.parseInteger(request.getParameter("taskid"), 0)); if (task == null) { request.setAttribute("title", "Aufgabe nicht gefunden"); request.getRequestDispatcher("MessageView").forward(request, response); return; } // check Lecture Participation ParticipationDAOIf participationDAO = DAOFactory.ParticipationDAOIf(session); Participation participation = participationDAO.getParticipation( RequestAdapter.getUser(request), task.getTaskGroup().getLecture()); if (participation == null || participation.getRoleType().compareTo(ParticipationRole.ADVISOR) != 0) { response.sendError(HttpServletResponse.SC_FORBIDDEN, "insufficient rights"); return; } if (task.getDeadline().after(Util.correctTimezone(new Date())) || task.getShowPoints() != null) { request.setAttribute("title", "Ungültige Anfrage"); request.getRequestDispatcher("MessageView").forward(request, response); return; } request.setAttribute("task", task); request.getRequestDispatcher("PublishGradesView").forward(request, response); }
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { Session session = RequestAdapter.getSession(request); TaskDAOIf taskDAO = DAOFactory.TaskDAOIf(session); Task task = taskDAO.getTask(Util.parseInteger(request.getParameter("taskid"), 0)); if (task == null) { request.setAttribute("title", "Aufgabe nicht gefunden"); request.getRequestDispatcher("MessageView").forward(request, response); return; } // check Lecture Participation ParticipationDAOIf participationDAO = DAOFactory.ParticipationDAOIf(session); Participation participation = participationDAO.getParticipation( RequestAdapter.getUser(request), task.getTaskGroup().getLecture()); if (participation == null || participation.getRoleType().compareTo(ParticipationRole.ADVISOR) != 0) { response.sendError(HttpServletResponse.SC_FORBIDDEN, "insufficient rights"); return; } if (task.getDeadline().after(Util.correctTimezone(new Date())) || task.getShowPoints() != null) { request.setAttribute("title", "Ungültige Anfrage"); request.getRequestDispatcher("MessageView").forward(request, response); return; } Transaction tx = session.beginTransaction(); session.lock(task, LockMode.UPGRADE); if (request.getParameter("mail") != null) { for (Submission submission : task.getSubmissions()) { for (Participation submitterParticipation : submission.getSubmitters()) { if (submission.getPoints() != null && submission.getPoints().getPointsOk()) { // HACK hardcoded URL MailSender.sendMail( submitterParticipation.getUser().getFullEmail(), "Bewertung erfolgt", "Hallo " + submitterParticipation.getUser().getFullName() + ",\n\neine Ihrer Abgaben wurde bewertet.\n\nEinsehen: <https://si.in.tu-clausthal.de/submissionsystem/servlets/ShowTask?taskid=" + task.getTaskid() + ">.\n\n-- \nReply is not possible."); } } } } task.setShowPoints(task.getDeadline()); session.saveOrUpdate(task); tx.commit(); response.sendRedirect(response.encodeRedirectURL("ShowTask?taskid=" + task.getTaskid())); }