Search in sources :

Example 46 with StudentAttributes

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

the class InstructorStudentRecordsAjaxPageAction 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);
    String targetSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, targetSessionName);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId));
    StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail);
    if (student == null) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_RECORDS, StatusMessageColor.DANGER));
        isError = true;
        return createRedirectResult(Const.ActionURIs.INSTRUCTOR_HOME_PAGE);
    }
    List<FeedbackSessionAttributes> feedbacks = logic.getFeedbackSessionsListForInstructor(account.googleId, false);
    filterFeedbackSessions(courseId, feedbacks, instructor, student);
    List<SessionAttributes> sessions = new ArrayList<>();
    sessions.addAll(feedbacks);
    sessions.sort(SessionAttributes.DESCENDING_ORDER);
    List<FeedbackSessionResultsBundle> results = new ArrayList<>();
    for (SessionAttributes session : sessions) {
        if (session instanceof FeedbackSessionAttributes) {
            if (!targetSessionName.isEmpty() && targetSessionName.equals(session.getSessionName())) {
                FeedbackSessionResultsBundle result = logic.getFeedbackSessionResultsForInstructor(session.getSessionName(), courseId, instructor.email);
                results.add(result);
            }
        } else {
            Assumption.fail("Unknown session type");
        }
    }
    statusToAdmin = "instructorStudentRecords Ajax Page Load<br>" + "Viewing <span class=\"bold\">" + studentEmail + "'s</span> records " + "for session <span class=\"bold\">[" + targetSessionName + "]</span> " + "in course <span class=\"bold\">[" + courseId + "]</span>";
    InstructorStudentRecordsAjaxPageData data = new InstructorStudentRecordsAjaxPageData(account, student, sessionToken, results);
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_STUDENT_RECORDS_AJAX, data);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorStudentRecordsAjaxPageData(teammates.ui.pagedata.InstructorStudentRecordsAjaxPageData) SessionAttributes(teammates.common.datatransfer.attributes.SessionAttributes) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage) FeedbackSessionResultsBundle(teammates.common.datatransfer.FeedbackSessionResultsBundle)

Example 47 with StudentAttributes

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

the class BackDoorLogic method editStudentAsJson.

public void editStudentAsJson(String originalEmail, String newValues) throws InvalidParametersException, EntityDoesNotExistException {
    StudentAttributes student = JsonUtils.fromJson(newValues, StudentAttributes.class);
    populateNullSection(student);
    updateStudentWithoutDocument(originalEmail, student);
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 48 with StudentAttributes

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

the class BackDoorLogic method processStudentsAndPopulateAccounts.

private void processStudentsAndPopulateAccounts(Collection<StudentAttributes> students, Map<String, AccountAttributes> googleIdAccountMap) {
    for (StudentAttributes student : students) {
        populateNullSection(student);
        if (StringHelper.isEmpty(student.googleId) || googleIdAccountMap.containsKey(student.googleId)) {
            // or instructor account already exists (i.e. instructor is also a student)
            continue;
        }
        googleIdAccountMap.put(student.googleId, makeAccount(student));
    }
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 49 with StudentAttributes

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

the class BackDoorLogic method putDocuments.

/**
 * Creates document for entities that have document, i.e. searchable.
 * @return status of the request in the form 'status meassage'+'additional
 *         info (if any)' e.g., "[BACKEND_STATUS_SUCCESS]" e.g.,
 *         "[BACKEND_STATUS_FAILURE]NullPointerException at ..."
 */
public String putDocuments(DataBundle dataBundle) {
    // query the entity in db first to get the actual data and create document for actual entity
    Map<String, StudentAttributes> students = dataBundle.students;
    for (StudentAttributes student : students.values()) {
        StudentAttributes studentInDb = studentsDb.getStudentForEmail(student.course, student.email);
        studentsDb.putDocument(studentInDb);
    }
    Map<String, InstructorAttributes> instructors = dataBundle.instructors;
    for (InstructorAttributes instructor : instructors.values()) {
        InstructorAttributes instructorInDb = instructorsDb.getInstructorForEmail(instructor.courseId, instructor.email);
        instructorsDb.putDocument(instructorInDb);
    }
    Map<String, FeedbackResponseCommentAttributes> responseComments = dataBundle.feedbackResponseComments;
    for (FeedbackResponseCommentAttributes responseComment : responseComments.values()) {
        FeedbackResponseCommentAttributes fcInDb = fcDb.getFeedbackResponseComment(responseComment.courseId, responseComment.createdAt, responseComment.giverEmail);
        fcDb.putDocument(fcInDb);
    }
    return Const.StatusCodes.BACKDOOR_STATUS_SUCCESS;
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 50 with StudentAttributes

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

the class AccountsLogic method joinCourseForStudent.

public void joinCourseForStudent(String registrationKey, String googleId) throws JoinCourseException, InvalidParametersException {
    verifyStudentJoinCourseRequest(registrationKey, googleId);
    StudentAttributes student = studentsLogic.getStudentForRegistrationKey(registrationKey);
    // register the student
    student.googleId = googleId;
    try {
        studentsLogic.updateStudentCascade(student.email, student);
    } catch (EntityDoesNotExistException e) {
        Assumption.fail("Student disappered while trying to register " + TeammatesException.toStringWithStackTrace(e));
    }
    if (accountsDb.getAccount(googleId) == null) {
        createStudentAccount(student);
    }
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Aggregations

StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)241 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)85 Test (org.testng.annotations.Test)80 ArrayList (java.util.ArrayList)55 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)33 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)33 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)30 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)27 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)22 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)17 ShowPageResult (teammates.ui.controller.ShowPageResult)15 HashMap (java.util.HashMap)14 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)14 InvalidParametersException (teammates.common.exception.InvalidParametersException)14 EmailWrapper (teammates.common.util.EmailWrapper)13 RedirectResult (teammates.ui.controller.RedirectResult)12 List (java.util.List)11 StatusMessage (teammates.common.util.StatusMessage)10 HashSet (java.util.HashSet)9 StudentEnrollDetails (teammates.common.datatransfer.StudentEnrollDetails)9