Ejemplo n.º 1
0
  public void getHITStatus(String hitId) {

    HIT hit = service.getHIT(hitId);

    HITStatus hitStatus = hit.getHITStatus();

    String value = hitStatus.getValue();

    System.out.println("hit value  = " + value);

    Assignment[] assignments = service.getAssignmentsForHIT(hitId, 1);
    if (assignments != null) {
      for (Assignment assignment : assignments) {
        System.out.println("assignment:" + assignment.getAnswer());
      }
    }
  }
  /**
   * 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());
    }
  }