示例#1
0
  private void reviewAssignment(String assignmentId, boolean correct) {

    try {
      if (correct) {
        service.approveAssignment(assignmentId, "Product classified correctly.  Thank you.");
      } else {
        service.approveAssignment(assignmentId, "Product classified.  Thank you.");
      }
    } catch (InternalServiceException e) {
      log.error(
          "InternalServiceException while trying to approve["
              + correct
              + "] assignment "
              + assignmentId
              + ", "
              + e.getMessage());
    } catch (Exception e) {
      log.error(
          "Exception while trying to approve["
              + correct
              + "] assignment "
              + assignmentId
              + ", "
              + e.getMessage());
    }
  }
  /**
   * Approves all the submissions for the hit whose ID is given
   *
   * @param HIT Id
   * @throws IOException
   */
  public void approveHIT(String hitId) throws IOException {
    try {
      hitId.trim();
      HIT currentHIT = service.getHIT(hitId);
      Assignment[] answers = service.getAssignmentsForHIT(hitId, currentHIT.getMaxAssignments());

      // Print out the HITId and the URL to view the HIT.
      System.out.println("Retrieved HIT: " + hitId);
      for (Assignment answer : answers) {
        answer.setAssignmentStatus(AssignmentStatus.Approved);
        System.out.println("Approved HIT: " + hitId);
        service.approveAssignment(answer.getAssignmentId(), "Accepted");
      }

    } catch (ServiceException e) {
      System.err.println(e.getLocalizedMessage());
    }
  }