コード例 #1
0
  private List<ElementTag> createPermissionInputGroup3ForSectionRow(int sectionIndex) {
    List<ElementTag> permissionInputGroup = new ArrayList<ElementTag>();

    String[] privileges = {
      Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS,
      Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS,
      Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS
    };

    String[] checkboxContent = {
      "Sessions: Submit Responses and Add Comments",
      "Sessions: View Responses and Comments",
      "Sessions: Edit/Delete Responses/Comments by Others"
    };

    int index = 0;
    for (String privilege : privileges) {
      boolean isChecked =
          instructor != null && instructor.isAllowedForPrivilege(sectionName, privilege);
      String name = privilege + Const.ParamsNames.INSTRUCTOR_SECTION_GROUP + sectionIndex;
      permissionInputGroup.add(createCheckBox(checkboxContent[index], name, "true", isChecked));
      index++;
    }

    return permissionInputGroup;
  }
コード例 #2
0
  private List<ElementTag> createPermissionInputGroup2ForSectionRow(int sectionIndex) {
    List<ElementTag> permissionInputGroup = new ArrayList<ElementTag>();

    String[] privileges = {
      Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS,
      Const.ParamsNames.INSTRUCTOR_PERMISSION_GIVE_COMMENT_IN_SECTIONS,
      Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_COMMENT_IN_SECTIONS,
      Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COMMENT_IN_SECTIONS
    };

    String[] checkboxContent = {
      "View Students' Details",
      "Give Comments for Students",
      "View Others' Comments on Students",
      "Edit/Delete Others' Comments on Students"
    };

    int index = 0;
    for (String privilege : privileges) {
      boolean isChecked =
          instructor != null && instructor.isAllowedForPrivilege(sectionName, privilege);
      String name = privilege + Const.ParamsNames.INSTRUCTOR_SECTION_GROUP + sectionIndex;
      permissionInputGroup.add(createCheckBox(checkboxContent[index], name, "true", isChecked));
      index++;
    }

    return permissionInputGroup;
  }
コード例 #3
0
  public CourseEditSectionRow(
      String sectionName,
      List<String> sectionNames,
      int sectionIndex,
      InstructorAttributes instructor,
      int instructorIndex,
      List<String> feedbackNames) {
    this.sectionName = sectionName;
    this.sectionIndex = sectionIndex;
    this.instructor = instructor;
    feedbackSessions = new ArrayList<CourseEditFeedbackSessionRow>();

    specialSections = createSpecialSectionsForSectionRow(sectionNames, sectionIndex);
    permissionInputGroup2 = createPermissionInputGroup2ForSectionRow(sectionIndex);
    permissionInputGroup3 = createPermissionInputGroup3ForSectionRow(sectionIndex);

    String content = "";
    String onClick = "";
    if (isSessionsInSectionSpecial()) {
      content = "Hide session-level permissions";
      onClick = "hideTuneSessionnPermissionsDiv(" + instructorIndex + ", " + sectionIndex + ")";
    } else {
      content = "Give different permissions for sessions in this section";
      onClick = "showTuneSessionnPermissionsDiv(" + instructorIndex + ", " + sectionIndex + ")";
    }

    String id = "toggleSessionLevelInSection" + sectionIndex + "ForInstructor" + instructorIndex;
    toggleSessionLevelInSectionButton =
        createButton(content, "small col-sm-5", id, "javascript:;", onClick);

    String[] privileges = {
      Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS,
      Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS,
      Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS
    };

    for (String feedbackName : feedbackNames) {
      List<ElementTag> checkBoxList = new ArrayList<ElementTag>();
      for (String privilege : privileges) {
        String name =
            privilege
                + Const.ParamsNames.INSTRUCTOR_SECTION_GROUP
                + sectionIndex
                + "feedback"
                + feedbackName;
        boolean isChecked =
            instructor != null
                && instructor.isAllowedForPrivilege(sectionName, feedbackName, privilege);
        checkBoxList.add(createCheckBox(null, name, "true", isChecked));
      }

      CourseEditFeedbackSessionRow feedbackSessionRow =
          new CourseEditFeedbackSessionRow(feedbackName, checkBoxList);
      feedbackSessions.add(feedbackSessionRow);
    }
  }
コード例 #4
0
  @SuppressWarnings("deprecation")
  private void testCreateInstructorAction() throws Exception {

    InstructorAttributes instructor = new InstructorAttributes();

    String shortName = "Instrúctör";
    instructor.name = "AHPUiT Instrúctör";
    instructor.email = "*****@*****.**";
    String institute = "TEAMMATES Test Institute 1";
    String demoCourseId = "AHPUiT.instr1.gma-demo";

    ______TS(
        "action success : create instructor account and the account is created successfully after user's verification");

    BackDoor.deleteAccount(TestProperties.inst().TEST_INSTRUCTOR_ACCOUNT);
    BackDoor.deleteCourse(demoCourseId);
    BackDoor.deleteInstructor(demoCourseId, instructor.email);

    homePage.createInstructor(shortName, instructor, institute);

    String expectedjoinUrl = Config.APP_URL + Const.ActionURIs.INSTRUCTOR_COURSE_JOIN;

    expectedjoinUrl =
        Url.addParamToUrl(
            expectedjoinUrl,
            Const.ParamsNames.REGKEY,
            StringHelper.encrypt(BackDoor.getKeyForInstructor(demoCourseId, instructor.email)));

    expectedjoinUrl =
        Url.addParamToUrl(expectedjoinUrl, Const.ParamsNames.INSTRUCTOR_INSTITUTION, institute);

    homePage
        .getStatus()
        .contains(
            "Instructor AHPUiT Instrúctör has been successfully created with join link:\n"
                + expectedjoinUrl);
    homePage.logout();
    // verify the instructor and the demo course have been created
    assertNotNull(BackDoor.getCourse(demoCourseId));
    assertNotNull(BackDoor.getInstructorByEmail(instructor.email, demoCourseId));

    // get the joinURL which sent to the requester's email
    String joinActionUrl =
        TestProperties.inst().TEAMMATES_URL + Const.ActionURIs.INSTRUCTOR_COURSE_JOIN;

    String joinLink =
        Url.addParamToUrl(
            joinActionUrl,
            Const.ParamsNames.REGKEY,
            StringHelper.encrypt(BackDoor.getKeyForInstructor(demoCourseId, instructor.email)));

    joinLink = Url.addParamToUrl(joinLink, Const.ParamsNames.INSTRUCTOR_INSTITUTION, institute);

    // simulate the user's verification here because it is added by admin
    browser.driver.get(joinLink);
    confirmationPage =
        createCorrectLoginPageType(browser.driver.getPageSource())
            .loginAsJoiningInstructor(
                TestProperties.inst().TEST_INSTRUCTOR_ACCOUNT,
                TestProperties.inst().TEST_INSTRUCTOR_PASSWORD);
    confirmationPage.clickCancelButton();

    browser.driver.get(joinLink);
    confirmationPage =
        createCorrectLoginPageType(browser.driver.getPageSource())
            .loginAsJoiningInstructor(
                TestProperties.inst().TEST_INSTRUCTOR_ACCOUNT,
                TestProperties.inst().TEST_INSTRUCTOR_PASSWORD);
    confirmationPage.clickConfirmButton();

    // check a account has been created for the requester successfully
    assertNotNull(BackDoor.getAccount(TestProperties.inst().TEST_INSTRUCTOR_ACCOUNT));

    // verify sample course is accessible for newly joined instructor as an instructor

    ______TS("new instructor can see sample course in homepage");
    InstructorHomePage instructorHomePage =
        AppPage.getNewPageInstance(browser, InstructorHomePage.class);
    instructorHomePage.verifyHtmlMainContent("/newlyJoinedInstructorHomePage.html");

    ______TS("new instructor can access sample coure enroll page");
    InstructorCourseEnrollPage enrollPage = instructorHomePage.clickCourseErollLink(demoCourseId);
    enrollPage.verifyHtmlMainContent("/newlyJoinedInstructorCourseEnrollPage.html");

    ______TS("new instructor can access sample coure details page");
    instructorHomePage = enrollPage.goToPreviousPage(InstructorHomePage.class);
    InstructorCourseDetailsPage detailsPage = instructorHomePage.clickCourseViewLink(demoCourseId);
    detailsPage.verifyHtmlMainContent("/newlyJoinedInstructorCourseDetailsPage.html");

    ______TS("new instructor can access sample coure edit page");
    instructorHomePage = detailsPage.goToPreviousPage(InstructorHomePage.class);
    InstructorCourseEditPage editPage = instructorHomePage.clickCourseEditLink(demoCourseId);
    editPage.verifyHtmlMainContent("/newlyJoinedInstructorCourseEditPage.html");

    ______TS("new instructor can access sample coure feedback session adding page");
    instructorHomePage = editPage.goToPreviousPage(InstructorHomePage.class);
    InstructorFeedbacksPage feedbacksPage =
        instructorHomePage.clickCourseAddEvaluationLink(demoCourseId);
    feedbacksPage.verifyHtmlMainContent("/newlyJoinedInstructorFeedbacksPage.html");

    ______TS("new instructor can archive sample course");
    instructorHomePage = feedbacksPage.goToPreviousPage(InstructorHomePage.class);
    instructorHomePage.clickArchiveCourseLinkAndConfirm(demoCourseId);
    instructorHomePage.verifyHtmlMainContent(
        "/newlyJoinedInstructorHomePageSampleCourseArchived.html");

    ______TS("new instructor can unarchive sample course");
    String url =
        Url.addParamToUrl(
            TestProperties.inst().TEAMMATES_URL + Const.ActionURIs.INSTRUCTOR_COURSES_PAGE,
            Const.ParamsNames.USER_ID,
            TestProperties.inst().TEST_INSTRUCTOR_ACCOUNT);
    browser.driver.get(url);
    InstructorCoursesPage coursesPage =
        AppPage.getNewPageInstance(browser, InstructorCoursesPage.class);
    coursesPage.unarchiveCourse(demoCourseId);
    coursesPage.verifyHtmlMainContent(
        "/newlyJoinedInstructorCoursesPageSampleCourseUnarhived.html");

    ______TS("new instructor can access sample course students page");
    coursesPage
        .loadStudentsTab()
        .verifyHtmlMainContent("/newlyJoinedInstructorStudentListPage.html");
    ______TS("new instructor can access sample course comments page");
    coursesPage
        .loadInstructorCommentsTab()
        .verifyHtmlMainContent("/newlyJoinedInstructorCommentsPage.html");

    ______TS("new instructor can view feedbackSession result of sample course");
    coursesPage.loadInstructorHomeTab();
    instructorHomePage = AppPage.getNewPageInstance(browser, InstructorHomePage.class);
    instructorHomePage
        .clickFeedbackSessionViewResultsLink(
            "AHPUiT.instr1.gma-demo", "Second team feedback session")
        .verifyHtmlMainContent("/newlyJoinedInstructorFeedbackResultsPage.html");

    ______TS("new instructor can edit feedbackSession of sample course");
    instructorHomePage.loadInstructorHomeTab();
    InstructorFeedbackEditPage feedbackEditPage =
        instructorHomePage.clickFeedbackSessionEditLink(
            "AHPUiT.instr1.gma-demo", "Second team feedback session");

    feedbackEditPage.clickEditSessionButton();

    FeedbackSessionAttributes feedbackSession =
        BackDoor.getFeedbackSession("AHPUiT.instr1.gma-demo", "Second team feedback session");
    feedbackEditPage.editFeedbackSession(
        feedbackSession.startTime,
        feedbackSession.endTime,
        new Text("updated instructions"),
        feedbackSession.gracePeriod);
    instructorHomePage.verifyHtmlMainContent(
        "/newlyJoinedInstructorFeedbackSessionSuccessEdited.html");

    ______TS("new instructor can click submit button of sample feedbackSession");
    instructorHomePage.loadInstructorHomeTab();
    FeedbackSubmitPage fbsp =
        instructorHomePage.clickFeedbackSessionSubmitLink(
            "AHPUiT.instr1.gma-demo", "Second team feedback session");
    fbsp.verifyHtmlMainContent("/newlyJoinedInstructorFeedbackSubmissionEditPage.html");

    ______TS("new instructor can send reminder of sample course");
    instructorHomePage.loadInstructorHomeTab();
    feedbacksPage =
        instructorHomePage.clickFeedbackSessionRemindLink(
            "AHPUiT.instr1.gma-demo", "Second team feedback session");
    feedbacksPage.verifyHtmlMainContent("/newlyJoinedInstructorFeedbackSessionRemind.html");

    ______TS("new instructor can unpublish feedbackSession of sample course");
    instructorHomePage.loadInstructorHomeTab();
    feedbacksPage =
        instructorHomePage.clickFeedbackSessionUnpublishLink(
            "AHPUiT.instr1.gma-demo", "Second team feedback session");
    feedbacksPage.verifyHtmlMainContent("/newlyJoinedInstructorFeedbackSessionUnpublished.html");

    ______TS("new instructor can publish feedbackSession of sample course");
    instructorHomePage.loadInstructorHomeTab();
    feedbacksPage =
        instructorHomePage.clickFeedbackSessionPublishLink(
            "AHPUiT.instr1.gma-demo", "Second team feedback session");
    feedbacksPage.verifyHtmlMainContent("/newlyJoinedInstructorFeedbackSessionPublished.html");

    feedbacksPage.logout();

    ______TS("action failure : invalid parameter");

    Url homeUrl = createUrl(Const.ActionURIs.ADMIN_HOME_PAGE);
    homePage = loginAdminToPage(browser, homeUrl, AdminHomePage.class);

    instructor.email = "AHPUiT.email.tmt";
    homePage
        .createInstructor(shortName, instructor, institute)
        .verifyStatus(
            String.format(
                FieldValidator.EMAIL_ERROR_MESSAGE,
                instructor.email,
                FieldValidator.REASON_INCORRECT_FORMAT));

    ______TS("action success: course is accessible for newly joined instructor as student");
    // in staging server, the student account uses the hardcoded email above, so this can only be
    // test on dev server
    if (!TestProperties.inst().TEAMMATES_URL.contains("local")) {

      BackDoor.deleteCourse(demoCourseId);
      BackDoor.deleteAccount(TestProperties.inst().TEST_INSTRUCTOR_ACCOUNT);
      BackDoor.deleteInstructor(demoCourseId, instructor.email);
      return;
    }

    // verify sample course is accessible for newly joined instructor as an student

    StudentHomePage studentHomePage =
        HomePage.getNewInstance(browser)
            .clickStudentLogin()
            .loginAsStudent(
                TestProperties.inst().TEST_INSTRUCTOR_ACCOUNT,
                TestProperties.inst().TEST_INSTRUCTOR_PASSWORD);

    studentHomePage.verifyContains(demoCourseId);
    studentHomePage.clickViewTeam();

    StudentCourseDetailsPage courseDetailsPage =
        AppPage.getNewPageInstance(browser, StudentCourseDetailsPage.class);
    courseDetailsPage.verifyHtmlMainContent("/newlyJoinedInstructorStudentCourseDetailsPage.html");

    studentHomePage = courseDetailsPage.goToPreviousPage(StudentHomePage.class);
    studentHomePage.getViewFeedbackButton("First team feedback session").click();
    StudentFeedbackResultsPage sfrp =
        AppPage.getNewPageInstance(browser, StudentFeedbackResultsPage.class);
    sfrp.verifyHtmlMainContent("/newlyJoinedInstructorStudentFeedbackResultsPage.html");

    studentHomePage = sfrp.goToPreviousPage(StudentHomePage.class);
    studentHomePage.getEditFeedbackButton("First team feedback session").click();
    FeedbackSubmitPage fsp = AppPage.getNewPageInstance(browser, FeedbackSubmitPage.class);
    fsp.verifyHtmlMainContent("/newlyJoinedInstructorStudentFeedbackSubmissionEdit.html");

    studentHomePage = fsp.loadStudentHomeTab();
    StudentCommentsPage scp = studentHomePage.loadStudentCommentsTab();
    scp.verifyHtmlMainContent("/newlyJoinedInstructorStudentCommentsPage.html");

    studentHomePage = scp.loadStudentHomeTab();

    StudentProfilePage spp = studentHomePage.loadProfileTab();
    spp.verifyContains("Student Profile");
    spp.verifyContains("AHPUiT Instrúctör");

    studentHomePage.logout();

    // login in as instructor again to test sample course deletion
    instructorHomePage =
        HomePage.getNewInstance(browser)
            .clickInstructorLogin()
            .loginAsInstructor(
                TestProperties.inst().TEST_INSTRUCTOR_ACCOUNT,
                TestProperties.inst().TEST_INSTRUCTOR_PASSWORD);

    instructorHomePage.clickAndConfirm(instructorHomePage.getDeleteCourseLink(demoCourseId));
    assertTrue(
        instructorHomePage
            .getStatus()
            .contains("The course " + demoCourseId + " has been deleted."));

    instructorHomePage.logout();

    BackDoor.deleteAccount(TestProperties.inst().TEST_INSTRUCTOR_ACCOUNT);
    BackDoor.deleteCourse(demoCourseId);
    BackDoor.deleteInstructor(demoCourseId, instructor.email);
  }
コード例 #5
0
  public void testCreateCourseAndInstructor() throws Exception {

    /* Explanation: SUT has 5 paths. They are,
     * path 1 - exit because the account doesn't' exist.
     * path 2 - exit because the account exists but doesn't have instructor privileges.
     * path 3 - exit because course creation failed.
     * path 4 - exit because instructor creation failed.
     * path 5 - success.
     * Accordingly, we have 5 test cases.
     */

    ______TS("fails: account doesn't exist");

    CourseAttributes c = new CourseAttributes();
    c.id = "fresh-course-tccai";
    c.name = "Fresh course for tccai";

    @SuppressWarnings("deprecation")
    InstructorAttributes i =
        new InstructorAttributes(
            "instructor-for-tccai", c.id, "Instructor for tccai", "*****@*****.**");

    try {
      coursesLogic.createCourseAndInstructor(i.googleId, c.id, c.name);
      signalFailureToDetectException();
    } catch (AssertionError e) {
      AssertHelper.assertContains("for a non-existent instructor", e.getMessage());
    }
    TestHelper.verifyAbsentInDatastore(c);
    TestHelper.verifyAbsentInDatastore(i);

    ______TS("fails: account doesn't have instructor privileges");

    AccountAttributes a = new AccountAttributes();
    a.googleId = i.googleId;
    a.name = i.name;
    a.email = i.email;
    a.institute = "TEAMMATES Test Institute 5";
    a.isInstructor = false;
    a.studentProfile = new StudentProfileAttributes();
    a.studentProfile.googleId = i.googleId;
    accountsDb.createAccount(a);
    try {
      coursesLogic.createCourseAndInstructor(i.googleId, c.id, c.name);
      signalFailureToDetectException();
    } catch (AssertionError e) {
      AssertHelper.assertContains("doesn't have instructor privileges", e.getMessage());
    }
    TestHelper.verifyAbsentInDatastore(c);
    TestHelper.verifyAbsentInDatastore(i);

    ______TS("fails: error during course creation");

    a.isInstructor = true;
    accountsDb.updateAccount(a);

    c.id = "invalid id";

    try {
      coursesLogic.createCourseAndInstructor(i.googleId, c.id, c.name);
      signalFailureToDetectException();
    } catch (InvalidParametersException e) {
      AssertHelper.assertContains("not acceptable to TEAMMATES as a Course ID", e.getMessage());
    }
    TestHelper.verifyAbsentInDatastore(c);
    TestHelper.verifyAbsentInDatastore(i);

    ______TS("fails: error during instructor creation due to duplicate instructor");

    c.id = "fresh-course-tccai";
    instructorsDb.createEntity(i); // create a duplicate instructor

    try {
      coursesLogic.createCourseAndInstructor(i.googleId, c.id, c.name);
      signalFailureToDetectException();
    } catch (AssertionError e) {
      AssertHelper.assertContains(
          "Unexpected exception while trying to create instructor for a new course",
          e.getMessage());
    }
    TestHelper.verifyAbsentInDatastore(c);

    ______TS("fails: error during instructor creation due to invalid parameters");

    i.email = "ins.for.iccai.gmail.tmt";

    try {
      coursesLogic.createCourseAndInstructor(i.googleId, c.id, c.name);
      signalFailureToDetectException();
    } catch (AssertionError e) {
      AssertHelper.assertContains(
          "Unexpected exception while trying to create instructor for a new course",
          e.getMessage());
    }
    TestHelper.verifyAbsentInDatastore(c);

    ______TS("success: typical case");

    i.email = "*****@*****.**";

    // remove the duplicate instructor object from the datastore.
    instructorsDb.deleteInstructor(i.courseId, i.email);

    coursesLogic.createCourseAndInstructor(i.googleId, c.id, c.name);
    TestHelper.verifyPresentInDatastore(c);
    TestHelper.verifyPresentInDatastore(i);

    ______TS("Null parameter");

    try {
      coursesLogic.createCourseAndInstructor(null, c.id, c.name);
      signalFailureToDetectException();
    } catch (AssertionError e) {
      assertEquals("Supplied parameter was null\n", e.getMessage());
    }
  }