Search in sources :

Example 6 with FeedbackSessionDetailsBundle

use of teammates.common.datatransfer.FeedbackSessionDetailsBundle in project teammates by TEAMMATES.

the class CoursesLogic method getCourseDetailsListForStudent.

/**
 * Returns a list of {@link CourseDetailsBundle} for all
 * courses a given student is enrolled in.
 *
 * @param googleId The Google ID of the student
 */
public List<CourseDetailsBundle> getCourseDetailsListForStudent(String googleId) throws EntityDoesNotExistException {
    List<CourseAttributes> courseList = getCoursesForStudentAccount(googleId);
    CourseAttributes.sortById(courseList);
    List<CourseDetailsBundle> courseDetailsList = new ArrayList<>();
    for (CourseAttributes c : courseList) {
        StudentAttributes s = studentsLogic.getStudentForCourseIdAndGoogleId(c.getId(), googleId);
        if (s == null) {
            // TODO Remove excessive logging after the reason why s can be null is found
            StringBuilder logMsgBuilder = new StringBuilder();
            String logMsg = "Student is null in CoursesLogic.getCourseDetailsListForStudent(String googleId)" + "<br> Student Google ID: " + googleId + "<br> Course: " + c.getId() + "<br> All Courses Retrieved using the Google ID:";
            logMsgBuilder.append(logMsg);
            for (CourseAttributes course : courseList) {
                logMsgBuilder.append("<br>").append(course.getId());
            }
            log.severe(logMsgBuilder.toString());
            // TODO Failing might not be the best course of action here.
            // Maybe throw a custom exception and tell user to wait due to eventual consistency?
            Assumption.fail("Student should not be null at this point.");
        }
        // Skip the course existence check since the course ID is obtained from a
        // valid CourseAttributes resulting from query
        List<FeedbackSessionAttributes> feedbackSessionList = feedbackSessionsLogic.getFeedbackSessionsForUserInCourseSkipCheck(c.getId(), s.email);
        CourseDetailsBundle cdd = new CourseDetailsBundle(c);
        for (FeedbackSessionAttributes fs : feedbackSessionList) {
            cdd.feedbackSessions.add(new FeedbackSessionDetailsBundle(fs));
        }
        courseDetailsList.add(cdd);
    }
    return courseDetailsList;
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) ArrayList(java.util.ArrayList) FeedbackSessionDetailsBundle(teammates.common.datatransfer.FeedbackSessionDetailsBundle) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 7 with FeedbackSessionDetailsBundle

use of teammates.common.datatransfer.FeedbackSessionDetailsBundle in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method getFeedbackSessionDetails.

public FeedbackSessionDetailsBundle getFeedbackSessionDetails(FeedbackSessionAttributes fsa) throws EntityDoesNotExistException {
    FeedbackSessionDetailsBundle details = new FeedbackSessionDetailsBundle(fsa);
    details.stats.expectedTotal = 0;
    details.stats.submittedTotal = 0;
    switch(fsa.getFeedbackSessionType()) {
        case STANDARD:
            List<StudentAttributes> students = studentsLogic.getStudentsForCourse(fsa.getCourseId());
            List<InstructorAttributes> instructors = instructorsLogic.getInstructorsForCourse(fsa.getCourseId());
            List<FeedbackQuestionAttributes> questions = fqLogic.getFeedbackQuestionsForSession(fsa.getFeedbackSessionName(), fsa.getCourseId());
            List<FeedbackQuestionAttributes> studentQns = fqLogic.getFeedbackQuestionsForStudents(questions);
            if (!studentQns.isEmpty()) {
                details.stats.expectedTotal += students.size();
            }
            for (InstructorAttributes instructor : instructors) {
                List<FeedbackQuestionAttributes> instructorQns = fqLogic.getFeedbackQuestionsForInstructor(questions, fsa.isCreator(instructor.email));
                if (!instructorQns.isEmpty()) {
                    details.stats.expectedTotal += 1;
                }
            }
            details.stats.submittedTotal += fsa.getRespondingStudentList().size() + fsa.getRespondingInstructorList().size();
            break;
        case PRIVATE:
            List<FeedbackQuestionAttributes> instructorQuestions = fqLogic.getFeedbackQuestionsForInstructor(fsa.getFeedbackSessionName(), fsa.getCourseId(), fsa.getCreatorEmail());
            List<FeedbackQuestionAttributes> validQuestions = fqLogic.getQuestionsWithRecipients(instructorQuestions, fsa.getCreatorEmail());
            if (validQuestions.isEmpty()) {
                break;
            }
            details.stats.expectedTotal = 1;
            if (isFeedbackSessionFullyCompletedByInstructor(fsa.getFeedbackSessionName(), fsa.getCourseId(), fsa.getCreatorEmail())) {
                details.stats.submittedTotal = 1;
            }
            break;
        default:
            break;
    }
    return details;
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackSessionDetailsBundle(teammates.common.datatransfer.FeedbackSessionDetailsBundle) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 8 with FeedbackSessionDetailsBundle

use of teammates.common.datatransfer.FeedbackSessionDetailsBundle in project teammates by TEAMMATES.

the class StudentHomePageAction method generateFeedbackSessionSubmissionStatusMap.

private Map<FeedbackSessionAttributes, Boolean> generateFeedbackSessionSubmissionStatusMap(List<CourseDetailsBundle> courses, String googleId) {
    Map<FeedbackSessionAttributes, Boolean> returnValue = new HashMap<>();
    for (CourseDetailsBundle c : courses) {
        for (FeedbackSessionDetailsBundle fsb : c.feedbackSessions) {
            FeedbackSessionAttributes f = fsb.feedbackSession;
            returnValue.put(f, getStudentStatusForSession(f, googleId));
        }
    }
    return returnValue;
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) HashMap(java.util.HashMap) FeedbackSessionDetailsBundle(teammates.common.datatransfer.FeedbackSessionDetailsBundle)

Aggregations

FeedbackSessionDetailsBundle (teammates.common.datatransfer.FeedbackSessionDetailsBundle)8 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)2 CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)2 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)2 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)2 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)2 Test (org.testng.annotations.Test)1 DataBundle (teammates.common.datatransfer.DataBundle)1 FeedbackSessionStats (teammates.common.datatransfer.FeedbackSessionStats)1 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)1 FeedbackQuestionsLogic (teammates.logic.core.FeedbackQuestionsLogic)1 FeedbackSessionsLogic (teammates.logic.core.FeedbackSessionsLogic)1 InstructorFeedbackQuestionEditAction (teammates.ui.controller.InstructorFeedbackQuestionEditAction)1 HomeFeedbackSessionRow (teammates.ui.template.HomeFeedbackSessionRow)1 StudentHomeFeedbackSessionRow (teammates.ui.template.StudentHomeFeedbackSessionRow)1