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