// ----------------------------------------------------------
  private NSArray<Submission> extractSubmissions(NSArray<UserSubmissionPair> userSubs) {
    NSMutableArray<Submission> submissions = new NSMutableArray<Submission>();

    for (UserSubmissionPair pair : userSubs) {
      if (pair.userHasSubmission()) {
        submissions.addObject(pair.submission());
      }
    }

    return submissions;
  }
  /**
   * Marks all the submissions shown that have been partially graded as being completed, sending
   * e-mail notifications as necessary.
   *
   * @return null to force this page to reload
   */
  public int markSubmissionsAsComplete() {
    int numberNotified = 0;

    assignmentOffering = offeringForAction;
    for (UserSubmissionPair pair : userGroup().allObjects()) {
      if (pair.userHasSubmission()) {
        Submission sub = pair.submission();

        if (sub.result().status() == Status.UNFINISHED
            || (sub.result().status() != Status.CHECK
                && !sub.assignmentOffering().assignment().usesTAScore())) {
          sub.result().setStatus(Status.CHECK);
          if (applyLocalChanges()) {
            numberNotified++;
            sub.emailNotificationToStudent("has been updated by the course staff");
          }
        }
      }
    }

    return numberNotified;
  }
  // ----------------------------------------------------------
  public WOComponent repartner() {
    for (UserSubmissionPair pair : userGroup().allObjects()) {
      Submission sub = pair.submission();

      if (sub != null && sub.result() != null) {
        for (Submission psub : sub.result().submissions()) {
          if (psub != sub
              && psub.assignmentOffering().assignment() != sub.assignmentOffering().assignment()) {
            log.warn(
                "found partner submission "
                    + psub.user()
                    + " #"
                    + psub.submitNumber()
                    + "\non incorrect assignment offering "
                    + psub.assignmentOffering());

            NSArray<AssignmentOffering> partnerOfferings =
                AssignmentOffering.objectsMatchingQualifier(
                    localContext(),
                    AssignmentOffering.courseOffering
                        .dot(CourseOffering.course)
                        .eq(sub.assignmentOffering().courseOffering().course())
                        .and(
                            AssignmentOffering.courseOffering
                                .dot(CourseOffering.students)
                                .eq(psub.user()))
                        .and(
                            AssignmentOffering.assignment.eq(
                                sub.assignmentOffering().assignment())));
            if (partnerOfferings.count() == 0) {
              log.error(
                  "Cannot locate correct assignment "
                      + "offering for partner"
                      + psub.user()
                      + " #"
                      + psub.submitNumber()
                      + "\non incorrect assignment offering "
                      + psub.assignmentOffering());
            } else {
              if (partnerOfferings.count() > 1) {
                log.warn(
                    "Multiple possible offerings for "
                        + "partner "
                        + psub.user()
                        + " #"
                        + psub.submitNumber()
                        + "\non incorrect assignment offering "
                        + psub.assignmentOffering());
                for (AssignmentOffering ao : partnerOfferings) {
                  log.warn("\t" + ao);
                }
              }

              psub.setAssignmentOfferingRelationship(partnerOfferings.get(0));
            }
          }
        }
      }
    }
    applyLocalChanges();
    return null;
  }
 // ----------------------------------------------------------
 public void setAUserSubmission(UserSubmissionPair pair) {
   aUserSubmission = pair;
   aSubmission = (pair != null ? pair.submission() : null);
 }