use of org.olat.restapi.support.vo.AssessableResultsVO in project openolat by klemens.
the class CourseAssessmentWebService method getCourseResults.
/**
* Returns the results of the course.
* @response.representation.200.qname {http://www.example.com}assessableResultsVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc Array of results for the whole the course
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_ASSESSABLERESULTSVOes}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course not found
* @param courseId The course resourceable's id
* @param httpRequest The HTTP request
* @param request The REST request
* @return
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getCourseResults(@PathParam("courseId") Long courseId, @Context HttpServletRequest httpRequest, @Context Request request) {
if (!RestSecurityHelper.isAuthor(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
ICourse course = CoursesWebService.loadCourse(courseId);
if (course == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
// fxdiff VCRP-1,2: access control of resources
List<Identity> courseUsers = loadUsers(course);
int i = 0;
Date lastModified = null;
AssessableResultsVO[] results = new AssessableResultsVO[courseUsers.size()];
for (Identity courseUser : courseUsers) {
AssessableResultsVO result = getRootResult(courseUser, course);
if (lastModified == null || (result.getLastModifiedDate() != null && lastModified.before(result.getLastModifiedDate()))) {
lastModified = result.getLastModifiedDate();
}
results[i++] = result;
}
if (lastModified != null) {
Response.ResponseBuilder response = request.evaluatePreconditions(lastModified);
if (response != null) {
return response.build();
}
return Response.ok(results).lastModified(lastModified).cacheControl(cc).build();
}
return Response.ok(results).build();
}
use of org.olat.restapi.support.vo.AssessableResultsVO in project OpenOLAT by OpenOLAT.
the class CourseAssessmentWebService method getCourseResultsOf.
/**
* Returns the results of the course.
* @response.representation.200.qname {http://www.example.com}assessableResultsVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The result of the course
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_ASSESSABLERESULTSVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The identity or the course not found
* @param courseId The course resourceable's id
* @param identityKey The id of the user
* @param httpRequest The HTTP request
* @param request The REST request
* @return
*/
@GET
@Path("users/{identityKey}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getCourseResultsOf(@PathParam("courseId") Long courseId, @PathParam("identityKey") Long identityKey, @Context HttpServletRequest httpRequest, @Context Request request) {
if (!RestSecurityHelper.isAuthor(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
try {
Identity userIdentity = BaseSecurityManager.getInstance().loadIdentityByKey(identityKey, false);
if (userIdentity == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
ICourse course = CoursesWebService.loadCourse(courseId);
if (course == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
AssessableResultsVO results = getRootResult(userIdentity, course);
if (results.getLastModifiedDate() != null) {
Response.ResponseBuilder response = request.evaluatePreconditions(results.getLastModifiedDate());
if (response != null) {
return response.build();
}
}
ResponseBuilder response = Response.ok(results);
if (results.getLastModifiedDate() != null) {
response = response.lastModified(results.getLastModifiedDate()).cacheControl(cc);
}
return response.build();
} catch (Throwable e) {
throw new WebApplicationException(e);
}
}
use of org.olat.restapi.support.vo.AssessableResultsVO in project OpenOLAT by OpenOLAT.
the class CourseAssessmentWebService method getCourseResults.
/**
* Returns the results of the course.
* @response.representation.200.qname {http://www.example.com}assessableResultsVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc Array of results for the whole the course
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_ASSESSABLERESULTSVOes}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course not found
* @param courseId The course resourceable's id
* @param httpRequest The HTTP request
* @param request The REST request
* @return
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getCourseResults(@PathParam("courseId") Long courseId, @Context HttpServletRequest httpRequest, @Context Request request) {
if (!RestSecurityHelper.isAuthor(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
ICourse course = CoursesWebService.loadCourse(courseId);
if (course == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
// fxdiff VCRP-1,2: access control of resources
List<Identity> courseUsers = loadUsers(course);
int i = 0;
Date lastModified = null;
AssessableResultsVO[] results = new AssessableResultsVO[courseUsers.size()];
for (Identity courseUser : courseUsers) {
AssessableResultsVO result = getRootResult(courseUser, course);
if (lastModified == null || (result.getLastModifiedDate() != null && lastModified.before(result.getLastModifiedDate()))) {
lastModified = result.getLastModifiedDate();
}
results[i++] = result;
}
if (lastModified != null) {
Response.ResponseBuilder response = request.evaluatePreconditions(lastModified);
if (response != null) {
return response.build();
}
return Response.ok(results).lastModified(lastModified).cacheControl(cc).build();
}
return Response.ok(results).build();
}
use of org.olat.restapi.support.vo.AssessableResultsVO in project OpenOLAT by OpenOLAT.
the class CourseAssessmentWebService method getAssessableResults.
/**
* Exports results for an assessable course node for all students.
* @response.representation.200.qname {http://www.example.com}assessableResultsVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc Export all results of all user of the course
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_ASSESSABLERESULTSVOes}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course not found
* @param courseId The course resourceable's id
* @param nodeId The id of the course building block
* @param httpRequest The HTTP request
* @param request The REST request
* @return
*/
@GET
@Path("{nodeId}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getAssessableResults(@PathParam("courseId") Long courseId, @PathParam("nodeId") Long nodeId, @Context HttpServletRequest httpRequest, @Context Request request) {
if (!RestSecurityHelper.isAuthor(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
ICourse course = CoursesWebService.loadCourse(courseId);
if (course == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
} else if (!isAuthorEditor(course, httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
// fxdiff VCRP-1,2: access control of resources
List<Identity> courseUsers = loadUsers(course);
int i = 0;
Date lastModified = null;
AssessableResultsVO[] results = new AssessableResultsVO[courseUsers.size()];
for (Identity courseUser : courseUsers) {
AssessableResultsVO result = getNodeResult(courseUser, course, nodeId);
if (lastModified == null || (result.getLastModifiedDate() != null && lastModified.before(result.getLastModifiedDate()))) {
lastModified = result.getLastModifiedDate();
}
results[i++] = result;
}
if (lastModified != null) {
Response.ResponseBuilder response = request.evaluatePreconditions(lastModified);
if (response != null) {
return response.build();
}
return Response.ok(results).lastModified(lastModified).cacheControl(cc).build();
}
return Response.ok(results).build();
}
use of org.olat.restapi.support.vo.AssessableResultsVO in project openolat by klemens.
the class CourseAssessmentWebService method getCourseNodeResultsForNode.
/**
* Returns the results of a student at a specific assessable node
* @response.representation.200.qname {http://www.example.com}assessableResultsVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The result of a user at a specific node
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_ASSESSABLERESULTSVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The identity or the course not found
* @param courseId The course resourceable's id
* @param nodeId The ident of the course building block
* @param identityKey The id of the user
* @param httpRequest The HTTP request
* @param request The REST request
* @return
*/
@GET
@Path("{nodeId}/users/{identityKey}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getCourseNodeResultsForNode(@PathParam("courseId") Long courseId, @PathParam("nodeId") Long nodeId, @PathParam("identityKey") Long identityKey, @Context HttpServletRequest httpRequest, @Context Request request) {
if (!RestSecurityHelper.isAuthor(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
try {
Identity userIdentity = BaseSecurityManager.getInstance().loadIdentityByKey(identityKey, false);
if (userIdentity == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
ICourse course = CoursesWebService.loadCourse(courseId);
if (course == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
AssessableResultsVO results = getNodeResult(userIdentity, course, nodeId);
if (results.getLastModifiedDate() != null) {
Response.ResponseBuilder response = request.evaluatePreconditions(results.getLastModifiedDate());
if (response != null) {
return response.build();
}
return Response.ok(results).lastModified(results.getLastModifiedDate()).cacheControl(cc).build();
}
return Response.ok(results).build();
} catch (Throwable e) {
throw new WebApplicationException(e);
}
}
Aggregations