Example #1
0
  @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();
  }
Example #2
0
  @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 = "&amp;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);
  }