Search in sources :

Example 46 with Message

use of com.remswork.project.alice.model.support.Message 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 47 with Message

use of com.remswork.project.alice.model.support.Message 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 48 with Message

use of com.remswork.project.alice.model.support.Message 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 49 with Message

use of com.remswork.project.alice.model.support.Message in project classify-system by anverliedoit.

the class RecitationResource method updateRecitationById.

@PUT
@Path("{recitationId}")
public Response updateRecitationById(@PathParam("recitationId") long id, Recitation newRecitation) {
    try {
        RecitationResourceLinks resourceLinks = new RecitationResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        Recitation recitation;
        if (termId > 0)
            recitation = recitationService.updateRecitationById(id, newRecitation, classId, termId);
        else
            recitation = recitationService.updateRecitationById(id, newRecitation, classId);
        recitation.addLink(resourceLinks.self(recitation.getId()));
        if (recitation.get_class() != null)
            recitation.get_class().addLink(classResourceLinks.self(recitation.get_class().getId()));
        return Response.status(Response.Status.OK).entity(recitation).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 : ClassResourceLinks(com.remswork.project.alice.resource.links.ClassResourceLinks) Recitation(com.remswork.project.alice.model.Recitation) Message(com.remswork.project.alice.model.support.Message) RecitationResourceLinks(com.remswork.project.alice.resource.links.RecitationResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException)

Example 50 with Message

use of com.remswork.project.alice.model.support.Message in project classify-system by anverliedoit.

the class RecitationResource method addRecitation.

@POST
public Response addRecitation(Recitation recitation) {
    try {
        RecitationResourceLinks resourceLinks = new RecitationResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        if (termId > 0)
            recitation = recitationService.addRecitation(recitation, classId, termId);
        else
            recitation = recitationService.addRecitation(recitation, classId);
        recitation.addLink(resourceLinks.self(recitation.getId()));
        if (recitation.get_class() != null)
            recitation.get_class().addLink(classResourceLinks.self(recitation.get_class().getId()));
        return Response.status(Response.Status.CREATED).entity(recitation).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 : ClassResourceLinks(com.remswork.project.alice.resource.links.ClassResourceLinks) Message(com.remswork.project.alice.model.support.Message) RecitationResourceLinks(com.remswork.project.alice.resource.links.RecitationResourceLinks) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException)

Aggregations

Message (com.remswork.project.alice.model.support.Message)336 GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)178 Gson (com.google.gson.Gson)155 IOException (java.io.IOException)155 InputStream (java.io.InputStream)155 HttpURLConnection (java.net.HttpURLConnection)155 URL (java.net.URL)155 ExecutionException (java.util.concurrent.ExecutionException)155 AsyncTask (android.os.AsyncTask)153 Client (javax.ws.rs.client.Client)58 WebTarget (javax.ws.rs.client.WebTarget)58 Response (javax.ws.rs.core.Response)58 JSONArray (org.json.JSONArray)49 JSONException (org.json.JSONException)49 ClassException (com.remswork.project.alice.exception.ClassException)46 ArrayList (java.util.ArrayList)46 ClassResourceLinks (com.remswork.project.alice.resource.links.ClassResourceLinks)40 OutputStreamWriter (java.io.OutputStreamWriter)36 BufferedWriter (java.io.BufferedWriter)34 OutputStream (java.io.OutputStream)34