示例#1
0
  /**
   * Updates the feedback session identified by {@code newAttributes.feedbackSesionName} and {@code
   * newAttributes.courseId}. For the remaining parameters, the existing value is preserved if the
   * parameter is null (due to 'keep existing' policy).<br>
   * Preconditions: <br>
   * * {@code newAttributes.feedbackSesionName} and {@code newAttributes.courseId} are non-null and
   * correspond to an existing feedback session. <br>
   */
  public void updateFeedbackSession(FeedbackSessionAttributes newAttributes)
      throws InvalidParametersException, EntityDoesNotExistException {

    Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, newAttributes);

    newAttributes.sanitizeForSaving();

    if (!newAttributes.isValid()) {
      throw new InvalidParametersException(newAttributes.getInvalidityInfo());
    }

    FeedbackSession fs = (FeedbackSession) getEntity(newAttributes);

    if (fs == null) {
      throw new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT + newAttributes.toString());
    }
    fs.setInstructions(newAttributes.instructions);
    fs.setStartTime(newAttributes.startTime);
    fs.setEndTime(newAttributes.endTime);
    fs.setSessionVisibleFromTime(newAttributes.sessionVisibleFromTime);
    fs.setResultsVisibleFromTime(newAttributes.resultsVisibleFromTime);
    fs.setTimeZone(newAttributes.timeZone);
    fs.setGracePeriod(newAttributes.gracePeriod);
    fs.setFeedbackSessionType(newAttributes.feedbackSessionType);
    fs.setSentOpenEmail(newAttributes.sentOpenEmail);
    fs.setSentPublishedEmail(newAttributes.sentPublishedEmail);
    fs.setIsOpeningEmailEnabled(newAttributes.isOpeningEmailEnabled);
    fs.setSendClosingEmail(newAttributes.isClosingEmailEnabled);
    fs.setSendPublishedEmail(newAttributes.isPublishedEmailEnabled);

    getPM().close();
  }
  private ActionResult loadCourse(String courseToLoad) throws EntityDoesNotExistException {
    int index = Integer.parseInt(getRequestParamValue("index"));

    InstructorAttributes instructor =
        logic.getInstructorForGoogleId(courseToLoad, account.googleId);

    CourseSummaryBundle course = logic.getCourseSummaryWithFeedbackSessions(instructor);
    FeedbackSessionAttributes.sortFeedbackSessionsByCreationTimeDescending(course.feedbackSessions);

    int commentsForSendingStateCount =
        logic.getCommentsForSendingState(courseToLoad, CommentSendingState.PENDING).size();
    int feedbackResponseCommentsForSendingStateCount =
        logic
            .getFeedbackResponseCommentsForSendingState(courseToLoad, CommentSendingState.PENDING)
            .size();
    int pendingCommentsCount =
        commentsForSendingStateCount + feedbackResponseCommentsForSendingStateCount;
    List<String> sectionNames = logic.getSectionNamesForCourse(course.course.id);

    InstructorHomeCourseAjaxPageData data = new InstructorHomeCourseAjaxPageData(account);
    data.init(index, course, instructor, pendingCommentsCount, sectionNames);

    statusToAdmin = "instructorHome Course Load:<br>" + courseToLoad;

    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_HOME_AJAX_COURSE_TABLE, data);
  }
  @Override
  public boolean execute() {

    log.info(
        "Adjusting submissions for feedback session :" + sessionName + "in course : " + courseId);

    FeedbackSessionAttributes feedbackSession =
        FeedbackSessionsLogic.inst().getFeedbackSession(sessionName, courseId);

    String errorString =
        "Error encountered while adjusting feedback session responses of %s in course : %s : %s\n%s";

    if (feedbackSession == null) {
      log.severe(String.format(errorString, sessionName, courseId, "feedback session is null", ""));
      return false;
    }

    List<FeedbackResponseAttributes> allResponses =
        FeedbackResponsesLogic.inst()
            .getFeedbackResponsesForSession(
                feedbackSession.getFeedbackSessionName(), feedbackSession.getCourseId());
    Gson gsonParser = Utils.getTeammatesGson();
    ArrayList<StudentEnrollDetails> enrollmentList =
        gsonParser.fromJson(
            enrollmentDetails, new TypeToken<ArrayList<StudentEnrollDetails>>() {}.getType());
    for (FeedbackResponseAttributes response : allResponses) {
      try {
        StudentsLogic.inst().adjustFeedbackResponseForEnrollments(enrollmentList, response);
      } catch (Exception e) {
        log.severe(
            String.format(
                errorString,
                sessionName,
                courseId,
                e.getMessage(),
                ActivityLogEntry.generateServletActionFailureLogMessage(request, e)));
        return false;
      }
    }
    return true;
  }