@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())); }
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { Session session = RequestAdapter.getSession(request); UserDAOIf userDAO = DAOFactory.UserDAOIf(session); User user = userDAO.getUser(RequestAdapter.getUser(request).getUid()); if (user == null) { request.setAttribute("title", "Benutzer nicht gefunden"); request.getRequestDispatcher("MessageView").forward(request, response); return; } if (Configuration.getInstance().isMatrikelNumberMustBeEnteredManuallyIfMissing() && !(user instanceof Student)) { if (request.getParameter("matrikelno") != null && Util.parseInteger(request.getParameter("matrikelno"), 0) > 0) { userDAO.makeUserStudent( RequestAdapter.getUser(request).getUid(), Util.parseInteger(request.getParameter("matrikelno"), 0)); } } if (user instanceof Student) { Student student = (Student) user; if (request.getParameter("studiengang") != null && !"".equals(request.getParameter("studiengang").trim())) { student.setStudiengang(request.getParameter("studiengang")); } Transaction tx = session.beginTransaction(); userDAO.saveUser(student); tx.commit(); } ContextAdapter contextAdapter = new ContextAdapter(getServletContext()); response.sendRedirect( request.getContextPath() + "/" + contextAdapter.getServletsPath() + "/Overview"); }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { Template template = TemplateFactory.getTemplate(request, response); Task task = (Task) request.getAttribute("task"); template.addKeepAlive(); template.printTemplateHeader("Abgaben durchsuchen", task); PrintWriter out = response.getWriter(); out.println( "<form action=\"" + response.encodeURL("?taskid=" + task.getTaskid()) + "\" method=post>"); out.println("<table class=border>"); out.println("<tr>"); out.println("<th>Suchen nach:</th>"); out.println("<td><input type=input name=q></td>"); out.println("</tr>"); out.println("<tr>"); out.println("<th>Suchen in:</th>"); out.println("<td><select multiple size=15 name=search>"); if (task.isADynamicTask()) { out.println( "<option value=\"dyntaskdescription\" selected>Dynamische Daten der Aufgabenstellung</option>"); out.println( "<option value=\"dyntasksolution\" selected>Dynamische Daten der Lösung</option>"); } out.println("<option value=\"files\" selected>Abgegebene Dateien</option>"); if (task.getDeadline().before(Util.correctTimezone(new Date()))) { out.println( "<option value=\"publiccomments\" selected>Öffentliche Bewertungs-Kommentare</option>"); out.println( "<option value=\"privatecomments\" selected>Interne Bewertungs-Kommentare</option>"); if (task.getTests().size() >= 0) { out.println("<option value=\"testresults\" selected>Testergebnisse</option>"); } } out.println("</select></td>"); out.println("</tr>"); out.println("<tr>"); out.println( "<td colspan=2 class=mid><input type=submit value=Suchen> <a href=\"" + response.encodeURL("ShowTask?taskid=" + task.getTaskid()) + "\">Abbrechen</a></td>"); out.println("</tr>"); out.println("</table>"); out.println("</form>"); template.printTemplateFooter(); }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { Session session = RequestAdapter.getSession(request); SubmissionDAOIf submissionDAO = DAOFactory.SubmissionDAOIf(session); Submission submission = submissionDAO.getSubmission(Util.parseInteger(request.getParameter("sid"), 0)); if (submission == null) { request.setAttribute("title", "Abgabe nicht gefunden"); request.getRequestDispatcher("MessageView").forward(request, response); return; } Task task = submission.getTask(); // check Lecture Participation ParticipationDAOIf participationDAO = DAOFactory.ParticipationDAOIf(session); Participation participation = participationDAO.getParticipation( RequestAdapter.getUser(request), submission.getTask().getTaskGroup().getLecture()); if (participation == null || participation.getRoleType().compareTo(ParticipationRole.TUTOR) < 0) { response.sendError(HttpServletResponse.SC_FORBIDDEN, "insufficient rights"); return; } if ((task.getDeadline().before(Util.correctTimezone(new Date())) || (task.isShowTextArea() == false && "-".equals(task.getFilenameRegexp()))) && request.getParameter("points") != null) { PointsDAOIf pointsDAO = DAOFactory.PointsDAOIf(session); String publicComment = ""; if (request.getParameter("publiccomment") != null) { publicComment = request.getParameter("publiccomment").trim(); } String internalComment = ""; if (request.getParameter("internalcomment") != null) { internalComment = request.getParameter("internalcomment").trim(); } PointStatus pointStatus = PointStatus.NICHT_ABGENOMMEN; if ("failed".equals(request.getParameter("pointsstatus"))) { pointStatus = PointStatus.ABGENOMMEN_FAILED; } else if ("ok".equals(request.getParameter("pointsstatus"))) { pointStatus = PointStatus.ABGENOMMEN; } else if ("nbewertet".equals(request.getParameter("pointsstatus"))) { pointStatus = PointStatus.NICHT_BEWERTET; } Transaction tx = session.beginTransaction(); Integer duplicate = null; if (request.getParameter("isdupe") != null && Util.parseInteger(request.getParameter("duplicate"), -1) >= 0) { duplicate = Util.parseInteger(request.getParameter("duplicate"), -1); } // attention: quite similar code in MarkEmptyTask if (task.getPointCategories().size() > 0) { pointsDAO.createPoints( request.getParameterMap(), submission, participation, publicComment, internalComment, pointStatus, duplicate); } else { pointsDAO.createPoints( Util.convertToPoints(request.getParameter("points")), submission, participation, publicComment, internalComment, pointStatus, duplicate); } tx.commit(); String groupAdding = ""; if (request.getParameter("group") != null && Util.parseInteger(request.getParameter("group"), 0) > 0) { groupAdding = "&groupid=" + Util.parseInteger(request.getParameter("group"), 0); } response.sendRedirect( response.encodeRedirectURL( "ShowSubmission?sid=" + submission.getSubmissionid() + groupAdding)); return; } if (Util.parseInteger(request.getParameter("partnerid"), 0) > 0) { Transaction tx = session.beginTransaction(); Participation partnerParticipation = participationDAO.getParticipation( Util.parseInteger(request.getParameter("partnerid"), 0)); if (submission.getSubmitters().size() < task.getMaxSubmitters() && partnerParticipation != null && partnerParticipation.getLecture().getId() == task.getTaskGroup().getLecture().getId() && submissionDAO.getSubmissionLocked(task, partnerParticipation.getUser()) == null) { submission.getSubmitters().add(partnerParticipation); session.update(submission); tx.commit(); response.sendRedirect( response.encodeRedirectURL("ShowSubmission?sid=" + submission.getSubmissionid())); return; } tx.rollback(); PrintWriter out = response.getWriter(); Template template = TemplateFactory.getTemplate(request, response); template.printTemplateHeader("Ungültige Anfrage"); out.println( "<div class=mid>Der ausgewählte Partner hat bereits eine eigene Abgabe initiiert oder es wurden insgesamt zu viele Partner ausgewählt.</div>"); template.printTemplateFooter(); return; } request.setAttribute("submission", submission); request.setAttribute( "submittedFiles", Util.listFilesAsRelativeStringList( new File( new ContextAdapter(getServletContext()).getDataPath().getAbsolutePath() + System.getProperty("file.separator") + task.getTaskGroup().getLecture().getId() + System.getProperty("file.separator") + task.getTaskid() + System.getProperty("file.separator") + submission.getSubmissionid() + System.getProperty("file.separator")))); request.getRequestDispatcher("ShowSubmissionView").forward(request, response); }