Search in sources :

Example 41 with UserEntity

use of fi.otavanopisto.muikku.model.users.UserEntity in project muikku by otavanopisto.

the class ForumController method updateForumThread.

public void updateForumThread(ForumThread thread, String title, String message, Boolean sticky, Boolean locked) {
    UserEntity user = sessionController.getLoggedUserEntity();
    forumThreadDAO.update(thread, title, clean(message), sticky, locked, new Date(), user);
}
Also used : UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) Date(java.util.Date)

Example 42 with UserEntity

use of fi.otavanopisto.muikku.model.users.UserEntity in project muikku by otavanopisto.

the class NotifierEmailMethod method sendNotification.

@Override
public void sendNotification(NotifierAction action, NotifierContext context) {
    NotifierEmailMessageComposer message = emailMessageComposer.select(new NotifierEmailContentAnnotationLiteral(action.getName())).get();
    if (message != null) {
        // List email addresses of user entity (only default identifier)
        UserEntity userEntity = context.getRecipient();
        SchoolDataIdentifier identifier = new SchoolDataIdentifier(userEntity.getDefaultIdentifier(), userEntity.getDefaultSchoolDataSource().getIdentifier());
        List<String> addresses = userEmailEntityController.getUserEmailAddresses(identifier);
        if (CollectionUtils.isNotEmpty(addresses))
            mailer.sendMail(message.getEmailMimeType(context), systemSettingsController.getSystemEmailSenderAddress(), addresses, message.getEmailSubject(context), message.getEmailContent(context));
    }
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity)

Example 43 with UserEntity

use of fi.otavanopisto.muikku.model.users.UserEntity in project muikku by otavanopisto.

the class Evaluation2RESTService method createWorkspaceMaterialAssessment.

@POST
@Path("/workspace/{WORKSPACEENTITYID}/user/{USERENTITYID}/workspacematerial/{WORKSPACEMATERIALID}/assessment")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response createWorkspaceMaterialAssessment(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("USERENTITYID") Long userEntityId, @PathParam("WORKSPACEMATERIALID") Long workspaceMaterialId, RestAssessment payload) {
    if (!sessionController.isLoggedIn()) {
        return Response.status(Status.UNAUTHORIZED).build();
    }
    if (!sessionController.hasEnvironmentPermission(MuikkuPermissions.ACCESS_EVALUATION)) {
        return Response.status(Status.FORBIDDEN).build();
    }
    // User entity
    UserEntity userEntity = userEntityController.findUserEntityById(userEntityId);
    if (userEntity == null) {
        return Response.status(Status.BAD_REQUEST).build();
    }
    // Workspace material
    WorkspaceMaterial workspaceMaterial = workspaceMaterialController.findWorkspaceMaterialById(workspaceMaterialId);
    if (workspaceMaterial == null) {
        return Response.status(Status.BAD_REQUEST).build();
    }
    // Workspace material evaluation
    WorkspaceMaterialEvaluation workspaceMaterialEvaluation = evaluationController.findWorkspaceMaterialEvaluationByWorkspaceMaterialAndStudent(workspaceMaterial, userEntity);
    // Grade
    SchoolDataIdentifier gradingScaleIdentifier = SchoolDataIdentifier.fromId(payload.getGradingScaleIdentifier());
    GradingScale gradingScale = gradingController.findGradingScale(gradingScaleIdentifier);
    SchoolDataIdentifier gradeIdentifier = SchoolDataIdentifier.fromId(payload.getGradeIdentifier());
    GradingScaleItem gradingScaleItem = gradingController.findGradingScaleItem(gradingScale, gradeIdentifier);
    // Assessor
    SchoolDataIdentifier assessorIdentifier = SchoolDataIdentifier.fromId(payload.getAssessorIdentifier());
    User assessingUser = userController.findUserByIdentifier(assessorIdentifier);
    UserEntity assessor = userEntityController.findUserEntityByUser(assessingUser);
    if (workspaceMaterialEvaluation == null) {
        workspaceMaterialEvaluation = evaluationController.createWorkspaceMaterialEvaluation(userEntity, workspaceMaterial, gradingScale, gradingScaleItem, assessor, payload.getAssessmentDate(), payload.getVerbalAssessment());
    } else {
        workspaceMaterialEvaluation = evaluationController.updateWorkspaceMaterialEvaluation(workspaceMaterialEvaluation, gradingScale, gradingScaleItem, assessor, payload.getAssessmentDate(), payload.getVerbalAssessment());
    }
    // Remove possible workspace assignment supplementation request
    SupplementationRequest supplementationRequest = evaluationController.findSupplementationRequestByStudentAndWorkspaceMaterialAndArchived(userEntityId, workspaceMaterialId, Boolean.FALSE);
    if (supplementationRequest != null) {
        evaluationController.deleteSupplementationRequest(supplementationRequest);
    }
    // WorkspaceMaterialEvaluation to RestAssessment
    RestAssessment restAssessment = new RestAssessment(workspaceMaterialEvaluation.getId().toString(), assessorIdentifier.toId(), gradingScaleIdentifier.toId(), gradeIdentifier.toId(), workspaceMaterialEvaluation.getVerbalAssessment(), workspaceMaterialEvaluation.getEvaluated(), gradingScaleItem.isPassingGrade());
    return Response.ok(restAssessment).build();
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) CompositeGradingScale(fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale) GradingScale(fi.otavanopisto.muikku.schooldata.entity.GradingScale) WorkspaceGradingScale(fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGradingScale) User(fi.otavanopisto.muikku.schooldata.entity.User) WorkspaceUser(fi.otavanopisto.muikku.schooldata.entity.WorkspaceUser) WorkspaceMaterialEvaluation(fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation) GradingScaleItem(fi.otavanopisto.muikku.schooldata.entity.GradingScaleItem) RestAssessment(fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestAssessment) SupplementationRequest(fi.otavanopisto.muikku.plugins.evaluation.model.SupplementationRequest) RestSupplementationRequest(fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestSupplementationRequest) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceMaterial(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) POST(javax.ws.rs.POST)

Example 44 with UserEntity

use of fi.otavanopisto.muikku.model.users.UserEntity in project muikku by otavanopisto.

the class Evaluation2RESTService method findWorkspaceSupplementationRequest.

@GET
@Path("/workspace/{WORKSPACEENTITYID}/user/{USERENTITYID}/supplementationrequest")
@RESTPermit(handling = Handling.INLINE)
public Response findWorkspaceSupplementationRequest(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("USERENTITYID") Long userEntityId) {
    if (!sessionController.isLoggedIn()) {
        return Response.status(Status.UNAUTHORIZED).build();
    }
    if (!sessionController.hasEnvironmentPermission(MuikkuPermissions.ACCESS_EVALUATION)) {
        return Response.status(Status.FORBIDDEN).build();
    }
    // User entity
    UserEntity userEntity = userEntityController.findUserEntityById(userEntityId);
    if (userEntity == null) {
        return Response.status(Status.BAD_REQUEST).build();
    }
    // Workspace entity
    WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
    if (workspaceEntity == null) {
        return Response.status(Status.NOT_FOUND).entity("workspaceEntity not found").build();
    }
    // Workspace supplementation request
    SupplementationRequest supplementationRequest = evaluationController.findSupplementationRequestByStudentAndWorkspace(userEntityId, workspaceEntityId);
    if (supplementationRequest == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    // SupplementationRequest to RestSupplementationRequest
    RestSupplementationRequest restSupplementationRequest = new RestSupplementationRequest(supplementationRequest.getId(), supplementationRequest.getUserEntityId(), supplementationRequest.getStudentEntityId(), supplementationRequest.getWorkspaceEntityId(), supplementationRequest.getWorkspaceMaterialId(), supplementationRequest.getRequestDate(), supplementationRequest.getRequestText());
    return Response.ok(restSupplementationRequest).build();
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) RestSupplementationRequest(fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestSupplementationRequest) SupplementationRequest(fi.otavanopisto.muikku.plugins.evaluation.model.SupplementationRequest) RestSupplementationRequest(fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestSupplementationRequest) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 45 with UserEntity

use of fi.otavanopisto.muikku.model.users.UserEntity in project muikku by otavanopisto.

the class EvaluationController method updateWorkspaceMaterialEvaluation.

public WorkspaceMaterialEvaluation updateWorkspaceMaterialEvaluation(WorkspaceMaterialEvaluation workspaceMaterialEvaluation, GradingScale gradingScale, GradingScaleItem grade, UserEntity assessor, Date evaluated, String verbalAssessment) {
    workspaceMaterialEvaluationDAO.updateGradingScaleIdentifier(workspaceMaterialEvaluation, gradingScale.getIdentifier());
    workspaceMaterialEvaluationDAO.updateGradingScaleSchoolDataSource(workspaceMaterialEvaluation, gradingScale.getSchoolDataSource());
    workspaceMaterialEvaluationDAO.updateVerbalAssessment(workspaceMaterialEvaluation, verbalAssessment);
    workspaceMaterialEvaluationDAO.updateGradeIdentifier(workspaceMaterialEvaluation, grade.getIdentifier());
    workspaceMaterialEvaluationDAO.updateGradeSchoolDataSource(workspaceMaterialEvaluation, grade.getSchoolDataSource());
    workspaceMaterialEvaluationDAO.updateAssessorEntityId(workspaceMaterialEvaluation, assessor.getId());
    workspaceMaterialEvaluationDAO.updateEvaluated(workspaceMaterialEvaluation, evaluated);
    WorkspaceMaterial workspaceMaterial = workspaceMaterialController.findWorkspaceMaterialById(workspaceMaterialEvaluation.getWorkspaceMaterialId());
    UserEntity student = userEntityController.findUserEntityById(workspaceMaterialEvaluation.getStudentEntityId());
    WorkspaceMaterialReply reply = workspaceMaterialReplyController.findWorkspaceMaterialReplyByWorkspaceMaterialAndUserEntity(workspaceMaterial, student);
    WorkspaceMaterialReplyState state = grade.isPassingGrade() ? WorkspaceMaterialReplyState.PASSED : WorkspaceMaterialReplyState.FAILED;
    if (reply == null) {
        workspaceMaterialReplyController.createWorkspaceMaterialReply(workspaceMaterial, state, student);
    } else {
        workspaceMaterialReplyController.updateWorkspaceMaterialReply(reply, state);
    }
    return workspaceMaterialEvaluation;
}
Also used : WorkspaceMaterialReply(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply) WorkspaceMaterialReplyState(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReplyState) WorkspaceMaterial(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity)

Aggregations

UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)163 Path (javax.ws.rs.Path)101 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)88 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)65 GET (javax.ws.rs.GET)58 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)54 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)50 User (fi.otavanopisto.muikku.schooldata.entity.User)36 ArrayList (java.util.ArrayList)35 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)27 POST (javax.ws.rs.POST)26 Date (java.util.Date)24 CommunicatorMessageId (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId)22 HashMap (java.util.HashMap)20 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)18 EnvironmentUser (fi.otavanopisto.muikku.model.users.EnvironmentUser)14 CommunicatorMessage (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessage)14 RESTPermitUnimplemented (fi.otavanopisto.muikku.rest.RESTPermitUnimplemented)13 UserGroupEntity (fi.otavanopisto.muikku.model.users.UserGroupEntity)12 PUT (javax.ws.rs.PUT)12