Search in sources :

Example 16 with CourseDetailsBundle

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

the class CoursesLogic method getCourseSummary.

/**
 * Returns the {@link CourseDetailsBundle} course details for a course using {@link CourseAttributes}.
 */
public CourseDetailsBundle getCourseSummary(CourseAttributes cd) {
    Assumption.assertNotNull("Supplied parameter was null", cd);
    CourseDetailsBundle cdd = new CourseDetailsBundle(cd);
    cdd.sections = (ArrayList<SectionDetailsBundle>) getSectionsForCourse(cd, cdd);
    return cdd;
}
Also used : CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) SectionDetailsBundle(teammates.common.datatransfer.SectionDetailsBundle)

Example 17 with CourseDetailsBundle

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

the class CoursesLogic method getCourseSummariesForInstructor.

/**
 * Returns course summaries for instructors.<br>
 *
 * @return Map with courseId as key, and CourseDetailsBundle as value.
 *         Does not include details within the course, such as feedback sessions.
 */
public Map<String, CourseDetailsBundle> getCourseSummariesForInstructor(List<InstructorAttributes> instructorAttributesList) {
    HashMap<String, CourseDetailsBundle> courseSummaryList = new HashMap<>();
    List<String> courseIdList = new ArrayList<>();
    for (InstructorAttributes instructor : instructorAttributesList) {
        courseIdList.add(instructor.courseId);
    }
    List<CourseAttributes> courseList = coursesDb.getCourses(courseIdList);
    // Check that all courseIds queried returned a course.
    if (courseIdList.size() > courseList.size()) {
        for (CourseAttributes ca : courseList) {
            courseIdList.remove(ca.getId());
        }
        log.severe("Course(s) was deleted but the instructor still exists: " + System.lineSeparator() + courseIdList.toString());
    }
    for (CourseAttributes ca : courseList) {
        courseSummaryList.put(ca.getId(), getCourseSummary(ca));
    }
    return courseSummaryList;
}
Also used : CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 18 with CourseDetailsBundle

use of teammates.common.datatransfer.CourseDetailsBundle 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 19 with CourseDetailsBundle

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

the class InstructorCourseDetailsPageAction method execute.

@Override
public ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    // this is for ajax loading of the htm table in the modal
    boolean isHtmlTableNeeded = getRequestParamAsBoolean(Const.ParamsNames.CSV_TO_HTML_TABLE_NEEDED);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId));
    /* Setup page data for the "Course Details" page */
    InstructorCourseDetailsPageData data = new InstructorCourseDetailsPageData(account, sessionToken);
    if (isHtmlTableNeeded) {
        String courseStudentListAsCsv = logic.getCourseStudentListAsCsv(courseId, account.googleId);
        data.setStudentListHtmlTableAsString(StringHelper.csvToHtmlTable(courseStudentListAsCsv));
        statusToAdmin = "instructorCourseDetails Page Ajax Html table Load<br>" + "Viewing Student List Table for Course <span class=\"bold\">[" + courseId + "]</span>";
        return createAjaxResult(data);
    }
    CourseDetailsBundle courseDetails = logic.getCourseDetails(courseId);
    List<InstructorAttributes> instructors = logic.getInstructorsForCourse(courseId);
    data.init(instructor, courseDetails, instructors);
    if (courseDetails.getStats().getStudentsTotal() == 0) {
        String message = String.format(Const.StatusMessages.INSTRUCTOR_COURSE_EMPTY, data.getInstructorCourseEnrollLink(courseId));
        statusToUser.add(new StatusMessage(message, StatusMessageColor.WARNING));
    }
    statusToAdmin = "instructorCourseDetails Page Load<br>" + "Viewing Course Details for Course <span class=\"bold\">[" + courseId + "]</span>";
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_DETAILS, data);
}
Also used : CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) InstructorCourseDetailsPageData(teammates.ui.pagedata.InstructorCourseDetailsPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage)

Example 20 with CourseDetailsBundle

use of teammates.common.datatransfer.CourseDetailsBundle 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

CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)21 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)8 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)8 ArrayList (java.util.ArrayList)7 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)6 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)6 HashMap (java.util.HashMap)5 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)5 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)4 Test (org.testng.annotations.Test)3 SectionDetailsBundle (teammates.common.datatransfer.SectionDetailsBundle)3 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)3 FeedbackSessionDetailsBundle (teammates.common.datatransfer.FeedbackSessionDetailsBundle)2 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)2 StatusMessage (teammates.common.util.StatusMessage)2 InstructorCourseDetailsPageData (teammates.ui.pagedata.InstructorCourseDetailsPageData)2 StudentHomePageData (teammates.ui.pagedata.StudentHomePageData)2 CourseTable (teammates.ui.template.CourseTable)2 Text (com.google.appengine.api.datastore.Text)1 CourseEnrollmentResult (teammates.common.datatransfer.CourseEnrollmentResult)1