Search in sources :

Example 1 with QuizResultResourceLinks

use of com.remswork.project.alice.resource.links.QuizResultResourceLinks in project classify-system by anverliedoit.

the class QuizResultResource method getQuizResult.

@GET
public Response getQuizResult(@PathParam("quizId") long quizId) {
    try {
        QuizResultResourceLinks resultResourceLinks = new QuizResultResourceLinks(uriInfo);
        QuizResult result = quizService.getQuizResultByQuizAndStudentId(quizId, studentId);
        result.addLink(resultResourceLinks.self(result.getId()));
        return Response.status(Response.Status.OK).entity(result).build();
    } catch (GradingFactorException e) {
        e.printStackTrace();
        Message message = new Message(404, "Not Found", e.getMessage());
        return Response.status(Response.Status.NOT_FOUND).entity(message).build();
    }
}
Also used : QuizResultResourceLinks(com.remswork.project.alice.resource.links.QuizResultResourceLinks) Message(com.remswork.project.alice.model.support.Message) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) QuizResult(com.remswork.project.alice.model.QuizResult)

Example 2 with QuizResultResourceLinks

use of com.remswork.project.alice.resource.links.QuizResultResourceLinks in project classify-system by anverliedoit.

the class QuizResultResource method addQuizResult.

@POST
public Response addQuizResult(@QueryParam("score") int score, @PathParam("quizId") long quizId) {
    try {
        QuizResultResourceLinks resultResourceLinks = new QuizResultResourceLinks(uriInfo);
        QuizResult result = quizService.addQuizResult(score, quizId, studentId);
        result.addLink(resultResourceLinks.self(result.getId()));
        return Response.status(Response.Status.OK).entity(result).build();
    } catch (GradingFactorException e) {
        e.printStackTrace();
        Message message = new Message(404, "Not Found", e.getMessage());
        return Response.status(Response.Status.NOT_FOUND).entity(message).build();
    }
}
Also used : QuizResultResourceLinks(com.remswork.project.alice.resource.links.QuizResultResourceLinks) Message(com.remswork.project.alice.model.support.Message) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) QuizResult(com.remswork.project.alice.model.QuizResult)

Example 3 with QuizResultResourceLinks

use of com.remswork.project.alice.resource.links.QuizResultResourceLinks in project classify-system by anverliedoit.

the class QuizResultResource method updateQuizResult.

@PUT
public Response updateQuizResult(@PathParam("quizId") long quizId, @QueryParam("score") int score) {
    try {
        QuizResultResourceLinks resultResourceLinks = new QuizResultResourceLinks(uriInfo);
        QuizResult result = quizService.updateQuizResultByQuizAndStudentId(score, quizId, studentId);
        result.addLink(resultResourceLinks.self(result.getId()));
        return Response.status(Response.Status.OK).entity(result).build();
    } catch (GradingFactorException e) {
        e.printStackTrace();
        Message message = new Message(400, "Bad Request", e.getMessage());
        return Response.status(Response.Status.NOT_FOUND).entity(message).build();
    }
}
Also used : QuizResultResourceLinks(com.remswork.project.alice.resource.links.QuizResultResourceLinks) Message(com.remswork.project.alice.model.support.Message) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) QuizResult(com.remswork.project.alice.model.QuizResult)

Example 4 with QuizResultResourceLinks

use of com.remswork.project.alice.resource.links.QuizResultResourceLinks in project classify-system by anverliedoit.

the class QuizResultResource method deleteQuizResult.

@DELETE
public Response deleteQuizResult(@PathParam("quizId") long quizId) {
    try {
        QuizResultResourceLinks resultResourceLinks = new QuizResultResourceLinks(uriInfo);
        QuizResult result = quizService.deleteQuizResultByQuizAndStudentId(quizId, studentId);
        result.addLink(resultResourceLinks.self(result.getId()));
        return Response.status(Response.Status.OK).entity(result).build();
    } catch (GradingFactorException e) {
        e.printStackTrace();
        Message message = new Message(400, "Bad Request", e.getMessage());
        return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
    }
}
Also used : QuizResultResourceLinks(com.remswork.project.alice.resource.links.QuizResultResourceLinks) Message(com.remswork.project.alice.model.support.Message) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) QuizResult(com.remswork.project.alice.model.QuizResult)

Aggregations

GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)4 QuizResult (com.remswork.project.alice.model.QuizResult)4 Message (com.remswork.project.alice.model.support.Message)4 QuizResultResourceLinks (com.remswork.project.alice.resource.links.QuizResultResourceLinks)4