use of fi.otavanopisto.pyramus.rest.model.CourseStaffMember in project muikku by otavanopisto.
the class NewEvaluationTestsBase method evaluationRequestImportanceOrderingTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void evaluationRequestImportanceOrderingTest() throws Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
MockStudent student2 = new MockStudent(3l, 3l, "Apprentice", "Master", "maprentice@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "111109-1212", Sex.MALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
MockStudent student3 = new MockStudent(4l, 4l, "Anotha", "Student", "hurhurhrurh@example.com", 1l, OffsetDateTime.of(1992, 3, 1, 0, 0, 0, 0, ZoneOffset.UTC), "010392-2145", Sex.MALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
OffsetDateTime date = OffsetDateTime.of(2016, 11, 10, 1, 1, 1, 1, ZoneOffset.UTC);
Builder mockBuilder = mocker();
try {
mockBuilder.addStudent(student).addStudent(student2).addStudent(student3).addStaffMember(admin).mockLogin(admin).build();
Long courseId = 3l;
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
OffsetDateTime created = OffsetDateTime.of(2015, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
OffsetDateTime begin = OffsetDateTime.of(2015, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
OffsetDateTime end = OffsetDateTime.of(2045, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
MockCourse mockCourse = new MockCourse(workspace.getId(), workspace.getName(), created, "test course", begin, end);
MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
MockCourseStudent courseStudent2 = new MockCourseStudent(3l, courseId, student2.getId());
MockCourseStudent courseStudent3 = new MockCourseStudent(4l, courseId, student3.getId());
CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
mockBuilder.addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).addCourseStudent(courseId, courseStudent2).addCourseStudent(courseId, courseStudent3).build();
createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
try {
mockBuilder.mockAssessmentRequests(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, date).mockAssessmentRequests(student2.getId(), courseId, courseStudent2.getId(), "Hello!", false, false, date).mockAssessmentRequests(student3.getId(), courseId, courseStudent3.getId(), "Tsadaam!", false, false, date).mockCompositeGradingScales().addCompositeCourseAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student, date).addCompositeCourseAssessmentRequest(student2.getId(), courseId, courseStudent2.getId(), "Hello!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student2, date.minusDays(2l)).addCompositeCourseAssessmentRequest(student3.getId(), courseId, courseStudent3.getId(), "Tsadaam!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student3, date.minusDays(1l)).mockCompositeCourseAssessmentRequests().addStaffCompositeAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student, admin.getId(), date).addStaffCompositeAssessmentRequest(student2.getId(), courseId, courseStudent2.getId(), "Hello!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student2, admin.getId(), date.minusDays(2l)).addStaffCompositeAssessmentRequest(student3.getId(), courseId, courseStudent3.getId(), "Tsadaam!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student3, admin.getId(), date.minusDays(1l)).mockStaffCompositeCourseAssessmentRequests();
navigate(String.format("/evaluation2"), true);
waitForPresent(".evaluation-card:first-child .evaluation-card-title .evaluation-card-student");
assertTextIgnoreCase(".evaluation-card:first-child .evaluation-card-title .evaluation-card-student", "master, apprentice");
waitForPresent("div[data-user-entity-id=\"1\"]");
waitAndClick("div[data-user-entity-id=\"1\"] .evaluation-important-button");
waitUntilTextRemovedFromElement(".evaluation-card:first-child .evaluation-card-title .evaluation-card-student", "master, apprentice");
assertTextIgnoreCase(".evaluation-card:first-child .evaluation-card-title .evaluation-card-student", "tester, student");
waitAndClick(".icon-sort-alpha-desc");
assertTextIgnoreCase(".evaluation-card:first-child .evaluation-card-title .evaluation-card-student", "tester, student");
waitUntilTextRemovedFromElement(".evaluation-card:nth-child(2) .evaluation-card-title .evaluation-card-student", "master, apprentice");
assertTextIgnoreCase(".evaluation-card:nth-child(2) .evaluation-card-title .evaluation-card-student", "student, anotha");
assertTextIgnoreCase(".evaluation-card:first-child .evaluation-card-title .evaluation-card-student", "tester, student");
waitAndClick("div[data-user-entity-id=\"1\"] .evaluation-unimportant-button");
waitAndClick(".icon-sort-alpha-asc");
waitUntilTextRemovedFromElement(".evaluation-card:first-child .evaluation-card-title .evaluation-card-student", "tester, student");
assertTextIgnoreCase(".evaluation-card:first-child .evaluation-card-title .evaluation-card-student", "master, apprentice");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.pyramus.rest.model.CourseStaffMember in project muikku by otavanopisto.
the class ToRTestsBase method recordsWorkspaceEvaluationTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI, TestEnvironments.Browser.PHANTOMJS })
public void recordsWorkspaceEvaluationTest() throws Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
OffsetDateTime date = OffsetDateTime.of(2016, 11, 10, 1, 1, 1, 1, ZoneOffset.UTC);
Builder mockBuilder = mocker();
try {
mockBuilder.addStudent(student).addStaffMember(admin).mockLogin(admin).build();
Long courseId = 2l;
login();
Workspace workspace = createWorkspace("testcourses", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
OffsetDateTime created = OffsetDateTime.of(2015, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
OffsetDateTime begin = OffsetDateTime.of(2015, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
OffsetDateTime end = OffsetDateTime.of(2045, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
MockCourse mockCourse = new MockCourse(workspace.getId(), workspace.getName(), created, "test course", begin, end);
MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
mockBuilder.addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
WorkspaceFolder workspaceFolder1 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.getId(), "Test", "text/html;editor=CKEditor", "<p><object type=\"application/vnd.muikku.field.text\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{"name":"muikku-field-nT0yyez23QwFXD3G0I8HzYeK","rightAnswers":[],"columns":"","hint":""}\" /></object></p>", 1l, "EVALUATED");
try {
mockBuilder.mockAssessmentRequests(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, date).mockCompositeGradingScales().addCompositeCourseAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student, date).mockCompositeCourseAssessmentRequests().addStaffCompositeAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student, admin.getId(), date).mockStaffCompositeCourseAssessmentRequests().addStaffCompositeAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, true, TestUtilities.courseFromMockCourse(mockCourse), student, admin.getId(), date).mockStaffCompositeCourseAssessmentRequests().mockAssessmentRequests(student.getId(), courseId, courseStudent.getId(), "Hello! I'd like to get assessment.", false, true, date).mockCourseAssessments(courseStudent, admin);
logout();
mockBuilder.mockLogin(student).build();
login();
navigate("/records/", true);
waitForPresent("div.tr-study-programme-accomplishments .tr-item-header-name .tr-item-long");
assertText("div.tr-study-programme-accomplishments .tr-item-header-name .tr-item-long", "testcourses (test extension)");
waitAndClick("div.tr-study-programme-accomplishments .tr-item-header-name .tr-item-long");
waitForPresent(".tr-evaluation-verbal .content");
assertText(".tr-evaluation-verbal .content", "Test evaluation.");
waitForPresent(".tr-item-details .tr-item-description-title .grade");
assertText(".tr-item-details .tr-item-description-title .grade", "Excellent");
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.pyramus.rest.model.CourseStaffMember in project muikku by otavanopisto.
the class PyramusUpdater method updateCourseStaffMember.
/**
* Updates course staff member from Pyramus
*
* @param courseStaffMemberId id of course staff member in Pyramus
* @param courseId id of course in Pyramus
* @param staffMemberId id of staff member in Pyramus
* @return returns whether new staff member was created or not
*/
public boolean updateCourseStaffMember(Long courseStaffMemberId, Long courseId, Long staffMemberId) {
String workspaceIdentifier = identifierMapper.getWorkspaceIdentifier(courseId);
String identifier = identifierMapper.getWorkspaceStaffIdentifier(courseStaffMemberId);
// TODO: course staff member removals can be left unnoticed if
// webhooks fails because they do not have archived flag
WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityByDataSourceAndIdentifier(SchoolDataPyramusPluginDescriptor.SCHOOL_DATA_SOURCE, workspaceIdentifier);
if (workspaceEntity == null) {
updateCourse(courseId);
workspaceEntity = workspaceController.findWorkspaceEntityByDataSourceAndIdentifier(SchoolDataPyramusPluginDescriptor.SCHOOL_DATA_SOURCE, workspaceIdentifier);
}
if (workspaceEntity != null) {
SchoolDataIdentifier workspaceUserIdentifier = new SchoolDataIdentifier(identifier, SchoolDataPyramusPluginDescriptor.SCHOOL_DATA_SOURCE);
WorkspaceUserEntity workspaceUserEntity = workspaceUserEntityController.findWorkspaceUserEntityByWorkspaceUserIdentifierIncludeArchived(workspaceUserIdentifier);
CourseStaffMember staffMember = pyramusClient.get().get("/courses/courses/" + courseId + "/staffMembers/" + courseStaffMemberId, CourseStaffMember.class);
if (staffMember != null) {
if (workspaceUserEntity == null) {
fireCourseStaffMemberDiscovered(staffMember);
return true;
} else {
fireCourseStaffMemberUpdated(staffMember);
}
} else {
if (workspaceUserEntity != null) {
fireCourseStaffMemberRemoved(courseStaffMemberId, staffMemberId, courseId);
return true;
}
}
}
return false;
}
use of fi.otavanopisto.pyramus.rest.model.CourseStaffMember in project muikku by otavanopisto.
the class PyramusUpdater method updateCourseStaffMembers.
/**
* Updates course staff members from Pyramus
*
* @param courseId id of course in Pyramus
* @return count of updated courses staff members
*/
public int updateCourseStaffMembers(Long courseId) {
// List of staff members according to Muikku
List<WorkspaceUserEntity> currentStaffMembers;
String workspaceIdentifier = identifierMapper.getWorkspaceIdentifier(courseId);
WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceByDataSourceAndIdentifier(SchoolDataPyramusPluginDescriptor.SCHOOL_DATA_SOURCE, workspaceIdentifier);
if (workspaceEntity != null) {
currentStaffMembers = workspaceUserEntityController.listActiveWorkspaceStaffMembers(workspaceEntity);
} else {
currentStaffMembers = Collections.emptyList();
}
// List of staff members according to Pyramus
CourseStaffMember[] staffMembers = pyramusClient.get().get("/courses/courses/" + courseId + "/staffMembers", CourseStaffMember[].class);
if (staffMembers != null) {
for (CourseStaffMember staffMember : staffMembers) {
String staffIdentifier = identifierMapper.getWorkspaceStaffIdentifier(staffMember.getId());
SchoolDataIdentifier workspaceUserIdentifier = new SchoolDataIdentifier(staffIdentifier, SchoolDataPyramusPluginDescriptor.SCHOOL_DATA_SOURCE);
WorkspaceUserEntity workspaceUserEntity = workspaceUserEntityController.findWorkspaceUserEntityByWorkspaceUserIdentifier(workspaceUserIdentifier);
if (workspaceUserEntity == null) {
fireCourseStaffMemberDiscovered(staffMember);
} else {
for (int i = currentStaffMembers.size() - 1; i >= 0; i--) {
if (currentStaffMembers.get(i).getId().equals(workspaceUserEntity.getId())) {
currentStaffMembers.remove(i);
}
}
}
}
}
for (WorkspaceUserEntity currentStaffMember : currentStaffMembers) {
try {
String courseStaffMemberIdentifier = currentStaffMember.getIdentifier();
String staffMemberIdentifier = currentStaffMember.getUserSchoolDataIdentifier().getUserEntity().getDefaultIdentifier();
Long courseStaffMemberId = identifierMapper.getPyramusCourseStaffId(courseStaffMemberIdentifier);
Long staffMemberId = identifierMapper.getPyramusStaffId(staffMemberIdentifier);
fireCourseStaffMemberRemoved(courseStaffMemberId, staffMemberId, courseId);
} catch (Exception e) {
logger.log(Level.WARNING, String.format("Error re-syncing WorkspaceUserEntity %d", currentStaffMember.getId()), e);
}
}
return 0;
}
use of fi.otavanopisto.pyramus.rest.model.CourseStaffMember in project muikku by otavanopisto.
the class CourseUsersTestsBase method courseArchiveStudentTest.
@Test
public void courseArchiveStudentTest() throws Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
Builder mockBuilder = mocker();
try {
mockBuilder.addStaffMember(admin).mockLogin(admin).build();
login();
Long courseId = 1l;
Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
mockBuilder.addStudent(student).addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
try {
navigate(String.format("/workspace/%s/users", workspace.getUrlName()), true);
waitForPresent(".workspace-students-listing-wrapper .workspace-users-name");
waitAndClick("div[data-user-id='PYRAMUS-STUDENT-2']>div.workspace-users-archive");
waitAndClick(".archive-button");
waitForPresentAndVisible(".workspace-students-listing-wrapper");
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
String payload = objectMapper.writeValueAsString(new WebhookStudentUpdatePayload(2l));
TestUtilities.webhookCall("http://dev.muikku.fi:" + getPortHttp() + "/pyramus/webhook", payload);
reloadCurrentPage();
waitForPresent(".workspace-students-list");
assertNotPresent("div[data-user-id='PYRAMUS-STUDENT-2']");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
mockBuilder.resetBuilder();
}
}
Aggregations