Search in sources :

Example 51 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.

the class BackDoorTest method testDeletion.

@Test
public void testDeletion() {
    // ----------deleting Instructor entities-------------------------
    InstructorAttributes instructor1OfCourse1 = dataBundle.instructors.get("instructor2OfCourse2");
    verifyPresentInDatastore(instructor1OfCourse1);
    String status = BackDoor.deleteInstructor(instructor1OfCourse1.courseId, instructor1OfCourse1.email);
    assertEquals(Const.StatusCodes.BACKDOOR_STATUS_SUCCESS, status);
    verifyAbsentInDatastore(instructor1OfCourse1);
    // try to delete again: should indicate as success because delete fails silently.
    status = BackDoor.deleteInstructor(instructor1OfCourse1.email, instructor1OfCourse1.courseId);
    assertEquals(Const.StatusCodes.BACKDOOR_STATUS_SUCCESS, status);
    // ----------deleting Feedback Response entities-------------------------
    FeedbackQuestionAttributes fq = dataBundle.feedbackQuestions.get("qn2InSession1InCourse1");
    FeedbackResponseAttributes fr = dataBundle.feedbackResponses.get("response1ForQ2S1C1");
    fq = BackDoor.getFeedbackQuestion(fq.courseId, fq.feedbackSessionName, fq.questionNumber);
    fr = BackDoor.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    verifyPresentInDatastore(fr);
    status = BackDoor.deleteFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertEquals(Const.StatusCodes.BACKDOOR_STATUS_SUCCESS, status);
    verifyAbsentInDatastore(fr);
    // ----------deleting Feedback Question entities-------------------------
    fq = dataBundle.feedbackQuestions.get("qn5InSession1InCourse1");
    verifyPresentInDatastore(fq);
    status = BackDoor.deleteFeedbackQuestion(fq.getId());
    assertEquals(Const.StatusCodes.BACKDOOR_STATUS_SUCCESS, status);
    verifyAbsentInDatastore(fq);
    // ----------deleting Course entities-------------------------
    // #COURSE 2
    CourseAttributes course2 = dataBundle.courses.get("typicalCourse2");
    verifyPresentInDatastore(course2);
    status = BackDoor.deleteCourse(course2.getId());
    assertEquals(Const.StatusCodes.BACKDOOR_STATUS_SUCCESS, status);
    verifyAbsentInDatastore(course2);
    // check if related student entities are also deleted
    StudentAttributes student2InCourse2 = dataBundle.students.get("student2InCourse2");
    verifyAbsentInDatastore(student2InCourse2);
    // #COURSE 1
    CourseAttributes course1 = dataBundle.courses.get("typicalCourse1");
    verifyPresentInDatastore(course1);
    status = BackDoor.deleteCourse(course1.getId());
    assertEquals(Const.StatusCodes.BACKDOOR_STATUS_SUCCESS, status);
    verifyAbsentInDatastore(course1);
    // check if related student entities are also deleted
    StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1");
    verifyAbsentInDatastore(student1InCourse1);
    // #COURSE NO EVALS
    CourseAttributes courseNoEvals = dataBundle.courses.get("courseNoEvals");
    verifyPresentInDatastore(courseNoEvals);
    status = BackDoor.deleteCourse(courseNoEvals.getId());
    assertEquals(Const.StatusCodes.BACKDOOR_STATUS_SUCCESS, status);
    verifyAbsentInDatastore(courseNoEvals);
// ----------deleting Feedback Session entities-------------------------
// TODO: do proper deletion test
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 52 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.

the class BackDoorTest method testCreateCourse.

@Test
public void testCreateCourse() {
    // only minimal testing because this is a wrapper method for
    // another well-tested method.
    String courseId = "tmapitt.tcc.course";
    CourseAttributes course = CourseAttributes.builder(courseId, "Name of tmapitt.tcc.instructor", ZoneId.of("UTC")).build();
    // Make sure not already inside
    BackDoor.deleteCourse(courseId);
    verifyAbsentInDatastore(course);
    // Perform creation
    BackDoor.createCourse(course);
    verifyPresentInDatastore(course);
    // Clean up
    BackDoor.deleteCourse(courseId);
    verifyAbsentInDatastore(course);
}
Also used : CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 53 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.

the class InstructorFeedbackSessionsPageData method buildNewForm.

private void buildNewForm(List<CourseAttributes> courses, String courseIdForNewSession, Map<String, InstructorAttributes> instructors, FeedbackSessionAttributes newFeedbackSession, String feedbackSessionType) {
    List<String> courseIds = new ArrayList<>();
    for (CourseAttributes course : courses) {
        courseIds.add(course.getId());
    }
    FeedbackSessionsAdditionalSettingsFormSegment additionalSettings = buildFormAdditionalSettings(newFeedbackSession);
    newFsForm = buildBasicForm(courses, courseIdForNewSession, instructors, newFeedbackSession, feedbackSessionType, courseIds, additionalSettings);
}
Also used : ArrayList(java.util.ArrayList) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) FeedbackSessionsAdditionalSettingsFormSegment(teammates.ui.template.FeedbackSessionsAdditionalSettingsFormSegment)

Example 54 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.

the class InstructorFeedbackSessionsPageData method getCourseIdOptions.

private List<ElementTag> getCourseIdOptions(List<CourseAttributes> courses, String courseIdForNewSession, Map<String, InstructorAttributes> instructors, FeedbackSessionAttributes newFeedbackSession) {
    ArrayList<ElementTag> result = new ArrayList<>();
    for (CourseAttributes course : courses) {
        // True if this is a submission of the filled 'new session' form
        // for this course:
        boolean isFilledFormForSessionInThisCourse = newFeedbackSession != null && course.getId().equals(newFeedbackSession.getCourseId());
        // True if this is for displaying an empty form for creating a
        // session for this course:
        boolean isEmptyFormForSessionInThisCourse = course.getId().equals(courseIdForNewSession);
        if (instructors.get(course.getId()).isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION)) {
            ElementTag option = createOption(course.getId(), course.getId(), isFilledFormForSessionInThisCourse || isEmptyFormForSessionInThisCourse);
            result.add(option);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ElementTag(teammates.ui.template.ElementTag) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 55 with CourseAttributes

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

CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)106 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)48 Test (org.testng.annotations.Test)40 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)33 ArrayList (java.util.ArrayList)31 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)19 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)16 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)15 EmailWrapper (teammates.common.util.EmailWrapper)15 HashMap (java.util.HashMap)12 InvalidParametersException (teammates.common.exception.InvalidParametersException)10 EmailGenerator (teammates.logic.api.EmailGenerator)10 CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)8 StatusMessage (teammates.common.util.StatusMessage)6 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)5 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)4 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)4 EntityAlreadyExistsException (teammates.common.exception.EntityAlreadyExistsException)4 InstructorCoursesPageData (teammates.ui.pagedata.InstructorCoursesPageData)4 InstructorFeedbackSessionsPageData (teammates.ui.pagedata.InstructorFeedbackSessionsPageData)4