Search in sources :

Example 1 with WorkspaceAssessmentState

use of fi.otavanopisto.muikku.plugins.assessmentrequest.WorkspaceAssessmentState in project muikku by otavanopisto.

the class GuiderRESTService method getWorkspaceAssessmentsStudyProgressAnalysis.

@GET
@Path("/workspaces/{WORKSPACEENTITYID}/activity")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response getWorkspaceAssessmentsStudyProgressAnalysis(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId) {
    SchoolDataIdentifier userIdentifier = sessionController.getLoggedUser();
    if (userIdentifier == null) {
        return Response.status(Status.BAD_REQUEST).entity("Invalid userIdentifier").build();
    }
    WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
    if (workspaceEntity == null) {
        return Response.status(Status.NOT_FOUND).entity("WorkspaceEntity not found").build();
    }
    GuiderStudentWorkspaceActivity activity = guiderController.getStudentWorkspaceActivity(workspaceEntity, userIdentifier);
    if (activity == null) {
        return Response.status(Status.INTERNAL_SERVER_ERROR).entity(String.format("Failed to analyze assignments progress for student %s in workspace %d", userIdentifier, workspaceEntity.getId())).build();
    }
    WorkspaceAssessmentState assessmentState = new WorkspaceAssessmentState(WorkspaceAssessmentState.UNASSESSED);
    WorkspaceUserEntity workspaceUserEntity = workspaceUserEntityController.findWorkspaceUserEntityByWorkspaceAndUserIdentifier(workspaceEntity, userIdentifier);
    if (workspaceUserEntity != null && workspaceUserEntity.getWorkspaceUserRole().getArchetype() == WorkspaceRoleArchetype.STUDENT) {
        assessmentState = assessmentRequestController.getWorkspaceAssessmentState(workspaceUserEntity);
    }
    return Response.ok(toRestModel(activity, assessmentState)).build();
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) WorkspaceAssessmentState(fi.otavanopisto.muikku.plugins.assessmentrequest.WorkspaceAssessmentState) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 2 with WorkspaceAssessmentState

use of fi.otavanopisto.muikku.plugins.assessmentrequest.WorkspaceAssessmentState in project muikku by otavanopisto.

the class WorkspaceBackingBean method setWorkspaceUrlName.

public void setWorkspaceUrlName(String workspaceUrlName) {
    WorkspaceEntity workspaceEntity = resolveWorkspaceEntity(workspaceUrlName);
    if (workspaceEntity != null) {
        this.workspaceEntityId = workspaceEntity.getId();
        this.workspaceUrlName = workspaceEntity.getUrlName();
    }
    homeVisible = workspaceToolSettingsController.getToolVisible(workspaceEntity, "home");
    guidesVisible = workspaceToolSettingsController.getToolVisible(workspaceEntity, "guides");
    materialsVisible = workspaceToolSettingsController.getToolVisible(workspaceEntity, "materials");
    discussionsVisible = sessionController.hasWorkspacePermission(ForumResourcePermissionCollection.FORUM_ACCESSWORKSPACEFORUMS, workspaceEntity) && workspaceToolSettingsController.getToolVisible(workspaceEntity, "discussions");
    usersVisible = sessionController.hasWorkspacePermission(MuikkuPermissions.MANAGE_WORKSPACE_MEMBERS, workspaceEntity) && workspaceToolSettingsController.getToolVisible(workspaceEntity, "users");
    journalVisible = sessionController.hasWorkspacePermission(MuikkuPermissions.ACCESS_WORKSPACE_JOURNAL, workspaceEntity) && workspaceToolSettingsController.getToolVisible(workspaceEntity, "journal");
    // Assessment state
    if (sessionController.isLoggedIn() && sessionController.hasWorkspacePermission(MuikkuPermissions.REQUEST_WORKSPACE_ASSESSMENT, workspaceEntity)) {
        WorkspaceUserEntity workspaceUserEntity = workspaceUserEntityController.findActiveWorkspaceUserByWorkspaceEntityAndUserIdentifier(workspaceEntity, sessionController.getLoggedUser());
        if (workspaceUserEntity != null) {
            WorkspaceAssessmentState workspaceAssessmentState = assessmentRequestController.getWorkspaceAssessmentState(workspaceUserEntity);
            this.assessmentState = workspaceAssessmentState == null ? null : workspaceAssessmentState.getState();
        }
    } else {
        this.assessmentState = null;
    }
    schoolDataBridgeSessionController.startSystemSession();
    try {
        Workspace workspace = workspaceController.findWorkspace(workspaceEntity);
        if (workspace != null) {
            this.workspaceName = workspace.getName();
            this.workspaceNameExtension = workspace.getNameExtension();
        }
    } finally {
        schoolDataBridgeSessionController.endSystemSession();
    }
}
Also used : WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) WorkspaceAssessmentState(fi.otavanopisto.muikku.plugins.assessmentrequest.WorkspaceAssessmentState) Workspace(fi.otavanopisto.muikku.schooldata.entity.Workspace)

Example 3 with WorkspaceAssessmentState

use of fi.otavanopisto.muikku.plugins.assessmentrequest.WorkspaceAssessmentState in project muikku by otavanopisto.

the class GuiderRESTService method getWorkspaceAssessmentsStudyProgressAnalysis.

@GET
@Path("/workspaces/{WORKSPACEENTITYID}/studentactivity/{USERIDENTIFIER}")
@RESTPermit(GuiderPermissions.GUIDER_FIND_STUDENT_WORKSPACE_ACTIVITY)
public Response getWorkspaceAssessmentsStudyProgressAnalysis(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("USERIDENTIFIER") String userId) {
    SchoolDataIdentifier userIdentifier = SchoolDataIdentifier.fromId(userId);
    if (userIdentifier == null) {
        return Response.status(Status.BAD_REQUEST).entity("Invalid userIdentifier").build();
    }
    WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
    if (workspaceEntity == null) {
        return Response.status(Status.NOT_FOUND).entity("WorkspaceEntity not found").build();
    }
    WorkspaceUserEntity workspaceUserEntity = workspaceUserEntityController.findWorkspaceUserEntityByWorkspaceAndUserIdentifier(workspaceEntity, userIdentifier);
    if (workspaceUserEntity == null) {
        return Response.status(Status.NOT_FOUND).entity("WorkspaceUserEntity not found").build();
    }
    GuiderStudentWorkspaceActivity activity = guiderController.getStudentWorkspaceActivity(workspaceEntity, userIdentifier);
    if (activity == null) {
        return Response.status(Status.INTERNAL_SERVER_ERROR).entity(String.format("Failed to analyze assignments progress for student %s in workspace %d", userIdentifier, workspaceEntity.getId())).build();
    }
    WorkspaceAssessmentState assessmentState = assessmentRequestController.getWorkspaceAssessmentState(workspaceUserEntity);
    return Response.ok(toRestModel(activity, assessmentState)).build();
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) WorkspaceAssessmentState(fi.otavanopisto.muikku.plugins.assessmentrequest.WorkspaceAssessmentState) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Aggregations

WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)3 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)3 WorkspaceAssessmentState (fi.otavanopisto.muikku.plugins.assessmentrequest.WorkspaceAssessmentState)3 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)2 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Workspace (fi.otavanopisto.muikku.schooldata.entity.Workspace)1