Search in sources :

Example 81 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class StudentHomePageAction method execute.

@Override
public ActionResult execute() {
    gateKeeper.verifyLoggedInUserPrivileges();
    String recentlyJoinedCourseId = getRequestParamValue(Const.ParamsNames.CHECK_PERSISTENCE_COURSE);
    List<CourseDetailsBundle> courses = new ArrayList<>();
    Map<FeedbackSessionAttributes, Boolean> sessionSubmissionStatusMap = new HashMap<>();
    try {
        courses = logic.getCourseDetailsListForStudent(account.googleId);
        sessionSubmissionStatusMap = generateFeedbackSessionSubmissionStatusMap(courses, account.googleId);
        CourseDetailsBundle.sortDetailedCoursesByCourseId(courses);
        statusToAdmin = "studentHome Page Load<br>" + "Total courses: " + courses.size();
        boolean isDataConsistent = isCourseIncluded(recentlyJoinedCourseId, courses);
        if (!isDataConsistent) {
            addPlaceholderCourse(courses, recentlyJoinedCourseId, sessionSubmissionStatusMap);
        }
        for (CourseDetailsBundle course : courses) {
            FeedbackSessionDetailsBundle.sortFeedbackSessionsByCreationTime(course.feedbackSessions);
        }
    } catch (EntityDoesNotExistException e) {
        if (recentlyJoinedCourseId == null) {
            statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_FIRST_TIME, StatusMessageColor.WARNING));
            statusToAdmin = Const.ACTION_RESULT_FAILURE + " :" + e.getMessage();
        } else {
            addPlaceholderCourse(courses, recentlyJoinedCourseId, sessionSubmissionStatusMap);
        }
    }
    StudentHomePageData data = new StudentHomePageData(account, sessionToken, courses, sessionSubmissionStatusMap);
    return createShowPageResult(Const.ViewURIs.STUDENT_HOME, data);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) HashMap(java.util.HashMap) StudentHomePageData(teammates.ui.pagedata.StudentHomePageData) ArrayList(java.util.ArrayList) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException) StatusMessage(teammates.common.util.StatusMessage)

Example 82 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class StudentHomePageData method createSessionRows.

private List<HomeFeedbackSessionRow> createSessionRows(List<FeedbackSessionDetailsBundle> feedbackSessions, Map<FeedbackSessionAttributes, Boolean> sessionSubmissionStatusMap, int startingSessionIdx) {
    List<HomeFeedbackSessionRow> rows = new ArrayList<>();
    int sessionIdx = startingSessionIdx;
    for (FeedbackSessionDetailsBundle session : feedbackSessions) {
        FeedbackSessionAttributes feedbackSession = session.feedbackSession;
        String sessionName = feedbackSession.getFeedbackSessionName();
        boolean hasSubmitted = sessionSubmissionStatusMap.get(feedbackSession);
        rows.add(new StudentHomeFeedbackSessionRow(PageData.sanitizeForHtml(sessionName), getStudentSubmissionsTooltipForSession(feedbackSession, hasSubmitted), getStudentPublishedTooltipForSession(feedbackSession), getStudentSubmissionStatusForSession(feedbackSession, hasSubmitted), getStudentPublishedStatusForSession(feedbackSession), TimeHelper.formatDateTimeForSessions(feedbackSession.getEndTime(), feedbackSession.getTimeZone()), feedbackSession.getEndTimeInIso8601UtcFormat(), getStudentFeedbackSessionActions(feedbackSession, hasSubmitted), sessionIdx));
        ++sessionIdx;
    }
    return rows;
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) StudentHomeFeedbackSessionRow(teammates.ui.template.StudentHomeFeedbackSessionRow) HomeFeedbackSessionRow(teammates.ui.template.HomeFeedbackSessionRow) StudentHomeFeedbackSessionRow(teammates.ui.template.StudentHomeFeedbackSessionRow) ArrayList(java.util.ArrayList) FeedbackSessionDetailsBundle(teammates.common.datatransfer.FeedbackSessionDetailsBundle)

Example 83 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method deleteInstructorRespondent.

public void deleteInstructorRespondent(String email, String feedbackSessionName, String courseId) throws EntityDoesNotExistException, InvalidParametersException {
    Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, feedbackSessionName);
    Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, courseId);
    Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, email);
    FeedbackSessionAttributes sessionToUpdate = getFeedbackSession(feedbackSessionName, courseId);
    if (sessionToUpdate == null) {
        throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_UPDATE + courseId + "/" + feedbackSessionName);
    }
    fsDb.deleteInstructorRespondent(email, sessionToUpdate);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 84 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method updateFeedbackSession.

public void updateFeedbackSession(FeedbackSessionAttributes newSession) throws InvalidParametersException, EntityDoesNotExistException {
    Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, newSession);
    FeedbackSessionAttributes oldSession = fsDb.getFeedbackSession(newSession.getCourseId(), newSession.getFeedbackSessionName());
    if (oldSession == null) {
        throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_UPDATE + newSession.getCourseId() + "/" + newSession.getFeedbackSessionName());
    }
    // These can't be changed anyway. Copy values to defensively avoid
    // invalid parameters.
    newSession.setCreatorEmail(oldSession.getCreatorEmail());
    newSession.setCreatedTime(oldSession.getCreatedTime());
    if (newSession.getInstructions() == null) {
        newSession.setInstructions(oldSession.getInstructions());
    }
    if (newSession.getStartTime() == null) {
        newSession.setStartTime(oldSession.getStartTime());
    }
    if (newSession.getEndTime() == null) {
        newSession.setEndTime(oldSession.getEndTime());
    }
    if (newSession.getFeedbackSessionType() == null) {
        newSession.setFeedbackSessionType(oldSession.getFeedbackSessionType());
    }
    if (newSession.getSessionVisibleFromTime() == null) {
        newSession.setSessionVisibleFromTime(oldSession.getSessionVisibleFromTime());
    }
    if (newSession.getResultsVisibleFromTime() == null) {
        newSession.setResultsVisibleFromTime(oldSession.getResultsVisibleFromTime());
    }
    makeEmailStateConsistent(oldSession, newSession);
    fsDb.updateFeedbackSession(newSession);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 85 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method updateRespondentsForSession.

public void updateRespondentsForSession(String feedbackSessionName, String courseId) throws InvalidParametersException, EntityDoesNotExistException {
    clearInstructorRespondents(feedbackSessionName, courseId);
    clearStudentRespondents(feedbackSessionName, courseId);
    FeedbackSessionAttributes fsa = getFeedbackSession(feedbackSessionName, courseId);
    List<FeedbackQuestionAttributes> questions = fqLogic.getFeedbackQuestionsForSession(feedbackSessionName, courseId);
    List<InstructorAttributes> instructors = instructorsLogic.getInstructorsForCourse(courseId);
    Map<String, List<String>> instructorQuestionsMap = new HashMap<>();
    for (InstructorAttributes instructor : instructors) {
        List<FeedbackQuestionAttributes> instructorQns = fqLogic.getFeedbackQuestionsForInstructor(questions, fsa.isCreator(instructor.email));
        if (!instructorQns.isEmpty()) {
            List<String> questionIds = new ArrayList<>();
            for (FeedbackQuestionAttributes question : instructorQns) {
                questionIds.add(question.getId());
            }
            instructorQuestionsMap.put(instructor.email, questionIds);
        }
    }
    Set<String> respondingStudentList = new HashSet<>();
    Set<String> respondingInstructorList = new HashSet<>();
    List<FeedbackResponseAttributes> responses = frLogic.getFeedbackResponsesForSession(feedbackSessionName, courseId);
    for (FeedbackResponseAttributes response : responses) {
        List<String> instructorQuestions = instructorQuestionsMap.get(response.giver);
        if (instructorQuestions != null && instructorQuestions.contains(response.feedbackQuestionId)) {
            respondingInstructorList.add(response.giver);
        } else {
            respondingStudentList.add(response.giver);
        }
    }
    addInstructorRespondents(new ArrayList<>(respondingInstructorList), feedbackSessionName, courseId);
    addStudentRespondents(new ArrayList<>(respondingStudentList), feedbackSessionName, courseId);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Aggregations

FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)205 Test (org.testng.annotations.Test)85 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)78 ArrayList (java.util.ArrayList)47 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)35 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)32 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)30 RedirectResult (teammates.ui.controller.RedirectResult)27 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)21 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)19 StatusMessage (teammates.common.util.StatusMessage)19 HashMap (java.util.HashMap)17 InvalidParametersException (teammates.common.exception.InvalidParametersException)14 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)13 EmailWrapper (teammates.common.util.EmailWrapper)12 Text (com.google.appengine.api.datastore.Text)11 DataBundle (teammates.common.datatransfer.DataBundle)11 EmailGenerator (teammates.logic.api.EmailGenerator)10 List (java.util.List)9 TaskWrapper (teammates.common.util.TaskWrapper)9