Search in sources :

Example 1 with CourseSummaryBundle

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

the class CoursesLogic method getCourseSummaryWithoutStatsForInstructor.

private Map<String, CourseSummaryBundle> getCourseSummaryWithoutStatsForInstructor(List<InstructorAttributes> instructorAttributesList) {
    HashMap<String, CourseSummaryBundle> courseSummaryList = new HashMap<>();
    List<String> courseIdList = new ArrayList<>();
    for (InstructorAttributes ia : instructorAttributesList) {
        courseIdList.add(ia.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(), getCourseSummaryWithoutStats(ca));
    }
    return courseSummaryList;
}
Also used : CourseSummaryBundle(teammates.common.datatransfer.CourseSummaryBundle) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 2 with CourseSummaryBundle

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

the class CoursesLogicTest method testGetCourseSummaryWithoutStats.

private void testGetCourseSummaryWithoutStats() throws Exception {
    ______TS("typical case");
    CourseAttributes course = dataBundle.courses.get("typicalCourse1");
    CourseSummaryBundle courseSummary = coursesLogic.getCourseSummaryWithoutStats(course.getId());
    assertEquals(course.getId(), courseSummary.course.getId());
    assertEquals(course.getName(), courseSummary.course.getName());
    ______TS("course without students");
    StudentProfileAttributes spa = StudentProfileAttributes.builder("instructor1").build();
    AccountsLogic.inst().createAccount(AccountAttributes.builder().withGoogleId("instructor1").withName("Instructor 1").withEmail("instructor@email.tmt").withInstitute("TEAMMATES Test Institute 1").withIsInstructor(true).withStudentProfileAttributes(spa).build());
    coursesLogic.createCourseAndInstructor("instructor1", "course1", "course 1", "America/Los_Angeles");
    courseSummary = coursesLogic.getCourseSummaryWithoutStats("course1");
    assertEquals("course1", courseSummary.course.getId());
    assertEquals("course 1", courseSummary.course.getName());
    assertEquals("America/Los_Angeles", courseSummary.course.getTimeZone().getId());
    coursesLogic.deleteCourseCascade("course1");
    accountsDb.deleteAccount("instructor1");
    ______TS("non-existent");
    try {
        coursesLogic.getCourseSummaryWithoutStats("non-existent-course");
        signalFailureToDetectException();
    } catch (EntityDoesNotExistException e) {
        AssertHelper.assertContains("The course does not exist:", e.getMessage());
    }
    ______TS("null parameter");
    try {
        coursesLogic.getCourseSummaryWithoutStats((CourseAttributes) null);
        signalFailureToDetectException();
    } catch (AssertionError e) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
    }
    try {
        coursesLogic.getCourseSummaryWithoutStats((String) null);
        signalFailureToDetectException();
    } catch (AssertionError e) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
    }
}
Also used : CourseSummaryBundle(teammates.common.datatransfer.CourseSummaryBundle) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 3 with CourseSummaryBundle

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

the class CoursesLogic method getCourseSummaryWithFeedbackSessionsForInstructor.

/**
 * Returns the {@link CourseSummaryBundle course summary}, including its
 * feedback sessions using the given {@link InstructorAttributes}.
 */
public CourseSummaryBundle getCourseSummaryWithFeedbackSessionsForInstructor(InstructorAttributes instructor) throws EntityDoesNotExistException {
    CourseSummaryBundle courseSummary = getCourseSummaryWithoutStats(instructor.courseId);
    courseSummary.feedbackSessions.addAll(feedbackSessionsLogic.getFeedbackSessionListForInstructor(instructor));
    return courseSummary;
}
Also used : CourseSummaryBundle(teammates.common.datatransfer.CourseSummaryBundle)

Example 4 with CourseSummaryBundle

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

the class InstructorHomePageAction method loadCourse.

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);
    InstructorHomeCourseAjaxPageData data = new InstructorHomeCourseAjaxPageData(account, sessionToken);
    data.init(index, course, instructor);
    statusToAdmin = "instructorHome Course Load:<br>" + courseToLoad;
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_HOME_AJAX_COURSE_TABLE, data);
}
Also used : CourseSummaryBundle(teammates.common.datatransfer.CourseSummaryBundle) InstructorHomeCourseAjaxPageData(teammates.ui.pagedata.InstructorHomeCourseAjaxPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 5 with CourseSummaryBundle

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

the class InstructorHomePageAction method loadPage.

private ActionResult loadPage() {
    boolean shouldOmitArchived = true;
    Map<String, CourseSummaryBundle> courses = logic.getCourseSummariesWithoutStatsForInstructor(account.googleId, shouldOmitArchived);
    ArrayList<CourseSummaryBundle> courseList = new ArrayList<>(courses.values());
    String sortCriteria = getSortCriteria();
    sortCourse(courseList, sortCriteria);
    InstructorHomePageData data = new InstructorHomePageData(account, sessionToken);
    data.init(courseList, sortCriteria);
    if (logic.isNewInstructor(account.googleId)) {
        statusToUser.add(new StatusMessage(StatusMessages.HINT_FOR_NEW_INSTRUCTOR, StatusMessageColor.INFO));
    }
    statusToAdmin = "instructorHome Page Load<br>" + "Total Courses: " + courseList.size();
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_HOME, data);
}
Also used : CourseSummaryBundle(teammates.common.datatransfer.CourseSummaryBundle) InstructorHomePageData(teammates.ui.pagedata.InstructorHomePageData) ArrayList(java.util.ArrayList) StatusMessage(teammates.common.util.StatusMessage)

Aggregations

CourseSummaryBundle (teammates.common.datatransfer.CourseSummaryBundle)5 ArrayList (java.util.ArrayList)2 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)2 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)2 HashMap (java.util.HashMap)1 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)1 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)1 StatusMessage (teammates.common.util.StatusMessage)1 InstructorHomeCourseAjaxPageData (teammates.ui.pagedata.InstructorHomeCourseAjaxPageData)1 InstructorHomePageData (teammates.ui.pagedata.InstructorHomePageData)1