Search in sources :

Example 1 with ActiveCoursesTable

use of teammates.ui.template.ActiveCoursesTable in project teammates by TEAMMATES.

the class InstructorCoursesPageData method convertToActiveCoursesTable.

private ActiveCoursesTable convertToActiveCoursesTable(List<CourseAttributes> courses) {
    ActiveCoursesTable activeCourses = new ActiveCoursesTable();
    int idx = -1;
    for (CourseAttributes course : courses) {
        idx++;
        List<ElementTag> actionsParam = new ArrayList<>();
        Boolean hasModifyPermission = instructorsForCourses.get(course.getId()).isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
        ElementTag enrollButton = createButton("Enroll", "btn btn-default btn-xs t_course_enroll" + idx, "", getInstructorCourseEnrollLink(course.getId()), Const.Tooltips.COURSE_ENROLL, !hasModifyPermission);
        ElementTag viewButton = createButton("View", "btn btn-default btn-xs t_course_view" + idx, "", getInstructorCourseDetailsLink(course.getId()), Const.Tooltips.COURSE_DETAILS, false);
        ElementTag editButton = createButton("Edit", "btn btn-default btn-xs t_course_edit" + idx, "", getInstructorCourseEditLink(course.getId()), Const.Tooltips.COURSE_EDIT, false);
        ElementTag archiveButton = createButton("Archive", "btn btn-default btn-xs t_course_archive" + idx, "", getInstructorCourseArchiveLink(course.getId(), true, false), Const.Tooltips.COURSE_ARCHIVE, false);
        String deleteLink = getInstructorCourseDeleteLink(course.getId(), false);
        Boolean hasDeletePermission = instructorsForCourses.get(course.getId()).isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE);
        ElementTag deleteButton = createButton("Delete", "btn btn-default btn-xs course-delete-link " + "t_course_delete" + idx, "", deleteLink, Const.Tooltips.COURSE_DELETE, !hasDeletePermission);
        deleteButton.setAttribute("data-course-id", course.getId());
        actionsParam.add(enrollButton);
        actionsParam.add(viewButton);
        actionsParam.add(editButton);
        actionsParam.add(archiveButton);
        actionsParam.add(deleteButton);
        ActiveCoursesTableRow row = new ActiveCoursesTableRow(SanitizationHelper.sanitizeForHtml(course.getId()), SanitizationHelper.sanitizeForHtml(course.getName()), course.getCreatedAtDateString(), course.getCreatedAtDateStamp(), course.getCreatedAtFullDateTimeString(), this.getInstructorCourseStatsLink(course.getId()), actionsParam);
        activeCourses.getRows().add(row);
    }
    return activeCourses;
}
Also used : ArrayList(java.util.ArrayList) ActiveCoursesTable(teammates.ui.template.ActiveCoursesTable) ElementTag(teammates.ui.template.ElementTag) ActiveCoursesTableRow(teammates.ui.template.ActiveCoursesTableRow) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Aggregations

ArrayList (java.util.ArrayList)1 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)1 ActiveCoursesTable (teammates.ui.template.ActiveCoursesTable)1 ActiveCoursesTableRow (teammates.ui.template.ActiveCoursesTableRow)1 ElementTag (teammates.ui.template.ElementTag)1