Search in sources :

Example 6 with StudentProfileAttributes

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

the class InstructorCourseStudentDetailsPageAction method loadStudentProfile.

private StudentProfileAttributes loadStudentProfile(StudentAttributes student, InstructorAttributes currentInstructor) {
    StudentProfileAttributes studentProfile = null;
    boolean isInstructorAllowedToViewStudent = currentInstructor.isAllowedForPrivilege(student.section, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS);
    boolean isStudentWithProfile = !student.googleId.isEmpty();
    if (isInstructorAllowedToViewStudent && isStudentWithProfile) {
        studentProfile = logic.getStudentProfile(student.googleId);
        Assumption.assertNotNull(studentProfile);
        return studentProfile;
    }
    // this means that the user is returning to the page and is not the first time
    boolean hasExistingStatus = !statusToUser.isEmpty() || session.getAttribute(Const.ParamsNames.STATUS_MESSAGES_LIST) != null;
    if (!isStudentWithProfile && !hasExistingStatus) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_NOT_JOINED_YET_FOR_RECORDS, StatusMessageColor.WARNING));
    }
    if (!isInstructorAllowedToViewStudent && !hasExistingStatus) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_PROFILE_UNACCESSIBLE_TO_INSTRUCTOR, StatusMessageColor.WARNING));
    }
    return null;
}
Also used : StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) StatusMessage(teammates.common.util.StatusMessage)

Example 7 with StudentProfileAttributes

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

the class InstructorCourseStudentDetailsPageAction method execute.

@Override
public ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    String studentEmail = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
    Assumption.assertPostParamNotNull(Const.ParamsNames.STUDENT_EMAIL, studentEmail);
    StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail);
    if (student == null) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_COURSE_DETAILS, StatusMessageColor.DANGER));
        isError = true;
        return createRedirectResult(Const.ActionURIs.INSTRUCTOR_HOME_PAGE);
    }
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), student.section, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS);
    boolean hasSection = logic.hasIndicatedSections(courseId);
    StudentProfileAttributes studentProfile = loadStudentProfile(student, instructor);
    InstructorCourseStudentDetailsPageData data = new InstructorCourseStudentDetailsPageData(account, sessionToken, student, studentProfile, hasSection);
    statusToAdmin = "instructorCourseStudentDetails Page Load<br>" + "Viewing details for Student <span class=\"bold\">" + studentEmail + "</span> in Course <span class=\"bold\">[" + courseId + "]</span>";
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_STUDENT_DETAILS, data);
}
Also used : InstructorCourseStudentDetailsPageData(teammates.ui.pagedata.InstructorCourseStudentDetailsPageData) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) StatusMessage(teammates.common.util.StatusMessage) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 8 with StudentProfileAttributes

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

the class CoursesLogicTest method testGetCourseSummary.

private void testGetCourseSummary() throws Exception {
    ______TS("typical case");
    CourseAttributes course = dataBundle.courses.get("typicalCourse1");
    CourseDetailsBundle courseSummary = coursesLogic.getCourseSummary(course.getId());
    assertEquals(course.getId(), courseSummary.course.getId());
    assertEquals(course.getName(), courseSummary.course.getName());
    assertEquals(2, courseSummary.stats.teamsTotal);
    assertEquals(5, courseSummary.stats.studentsTotal);
    assertEquals(0, courseSummary.stats.unregisteredTotal);
    assertEquals(1, courseSummary.sections.get(0).teams.size());
    assertEquals("Team 1.1</td></div>'\"", courseSummary.sections.get(0).teams.get(0).name);
    ______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", "Asia/Singapore");
    courseSummary = coursesLogic.getCourseSummary("course1");
    assertEquals("course1", courseSummary.course.getId());
    assertEquals("course 1", courseSummary.course.getName());
    assertEquals("Asia/Singapore", courseSummary.course.getTimeZone().getId());
    assertEquals(0, courseSummary.stats.teamsTotal);
    assertEquals(0, courseSummary.stats.studentsTotal);
    assertEquals(0, courseSummary.stats.unregisteredTotal);
    assertEquals(0, courseSummary.sections.size());
    coursesLogic.deleteCourseCascade("course1");
    accountsDb.deleteAccount("instructor1");
    ______TS("non-existent");
    try {
        coursesLogic.getCourseSummary("non-existent-course");
        signalFailureToDetectException();
    } catch (EntityDoesNotExistException e) {
        AssertHelper.assertContains("The course does not exist:", e.getMessage());
    }
    ______TS("null parameter");
    try {
        coursesLogic.getCourseSummary((CourseAttributes) null);
        signalFailureToDetectException();
    } catch (AssertionError e) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
    }
    try {
        coursesLogic.getCourseSummary((String) null);
        signalFailureToDetectException();
    } catch (AssertionError e) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
    }
}
Also used : CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 9 with StudentProfileAttributes

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

the class CoursesLogicTest method testGetCourseDetails.

private void testGetCourseDetails() throws Exception {
    ______TS("typical case");
    CourseAttributes course = dataBundle.courses.get("typicalCourse1");
    CourseDetailsBundle courseDetails = coursesLogic.getCourseSummary(course.getId());
    assertEquals(course.getId(), courseDetails.course.getId());
    assertEquals(course.getName(), courseDetails.course.getName());
    assertEquals(course.getTimeZone(), courseDetails.course.getTimeZone());
    assertEquals(2, courseDetails.stats.teamsTotal);
    assertEquals(5, courseDetails.stats.studentsTotal);
    assertEquals(0, courseDetails.stats.unregisteredTotal);
    assertEquals(1, courseDetails.sections.get(0).teams.size());
    assertEquals("Team 1.1</td></div>'\"", courseDetails.sections.get(0).teams.get(0).name);
    ______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", "Australia/Adelaide");
    courseDetails = coursesLogic.getCourseSummary("course1");
    assertEquals("course1", courseDetails.course.getId());
    assertEquals("course 1", courseDetails.course.getName());
    assertEquals("Australia/Adelaide", courseDetails.course.getTimeZone().getId());
    assertEquals(0, courseDetails.stats.teamsTotal);
    assertEquals(0, courseDetails.stats.studentsTotal);
    assertEquals(0, courseDetails.stats.unregisteredTotal);
    assertEquals(0, courseDetails.sections.size());
    coursesLogic.deleteCourseCascade("course1");
    accountsDb.deleteAccount("instructor1");
    ______TS("non-existent");
    try {
        coursesLogic.getCourseSummary("non-existent-course");
        signalFailureToDetectException();
    } catch (EntityDoesNotExistException e) {
        AssertHelper.assertContains("The course does not exist:", e.getMessage());
    }
    ______TS("null parameter");
    try {
        coursesLogic.getCourseSummary((String) null);
        signalFailureToDetectException();
    } catch (AssertionError e) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
    }
}
Also used : CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 10 with StudentProfileAttributes

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

the class AccountsDbTest method testDeleteAccount.

@Test
public void testDeleteAccount() throws Exception {
    AccountAttributes a = createNewAccount();
    a.studentProfile.pictureKey = writeFileToGcs(a.googleId, "src/test/resources/images/profile_pic_default.png");
    profilesDb.updateStudentProfilePicture(a.googleId, a.studentProfile.pictureKey);
    ______TS("typical success case");
    AccountAttributes newAccount = accountsDb.getAccount(a.googleId);
    assertNotNull(newAccount);
    accountsDb.deleteAccount(a.googleId);
    AccountAttributes newAccountdeleted = accountsDb.getAccount(a.googleId);
    assertNull(newAccountdeleted);
    StudentProfileAttributes deletedProfile = profilesDb.getStudentProfile(a.googleId);
    assertNull(deletedProfile);
    assertFalse(doesFileExistInGcs(new BlobKey(a.studentProfile.pictureKey)));
    ______TS("silent deletion of same account");
    accountsDb.deleteAccount(a.googleId);
    ______TS("failure null paramter");
    try {
        accountsDb.deleteAccount(null);
        signalFailureToDetectException(" - AssertionError");
    } catch (AssertionError ae) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage());
    }
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) BlobKey(com.google.appengine.api.blobstore.BlobKey) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) Test(org.testng.annotations.Test)

Aggregations

StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)45 Test (org.testng.annotations.Test)15 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)11 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)7 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)6 BlobKey (com.google.appengine.api.blobstore.BlobKey)5 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)5 RedirectResult (teammates.ui.controller.RedirectResult)5 ArrayList (java.util.ArrayList)4 InvalidParametersException (teammates.common.exception.InvalidParametersException)4 StatusMessage (teammates.common.util.StatusMessage)4 StudentProfile (teammates.storage.entity.StudentProfile)4 StudentProfileEditSaveAction (teammates.ui.controller.StudentProfileEditSaveAction)4 CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)3 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)3 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)3 Text (com.google.appengine.api.datastore.Text)2 ShowPageResult (teammates.ui.controller.ShowPageResult)2 InstructorStudentRecordsPageData (teammates.ui.pagedata.InstructorStudentRecordsPageData)2 Key (com.googlecode.objectify.Key)1