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;
}
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());
}
}
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;
}
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);
}
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);
}
Aggregations