Search in sources :

Example 31 with GradingFactorException

use of com.remswork.project.alice.exception.GradingFactorException in project classify-system by anverliedoit.

the class QuizResource method updateQuizById.

@PUT
@Path("{quizId}")
public Response updateQuizById(@PathParam("quizId") long id, Quiz newQuiz) {
    try {
        QuizResourceLinks resourceLinks = new QuizResourceLinks(uriInfo);
        ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
        Quiz quiz;
        if (termId > 0)
            quiz = quizService.updateQuizById(id, newQuiz, classId, termId);
        else
            quiz = quizService.updateQuizById(id, newQuiz, classId);
        quiz.addLink(resourceLinks.self(quiz.getId()));
        if (quiz.get_class() != null)
            quiz.get_class().addLink(classResourceLinks.self(quiz.get_class().getId()));
        return Response.status(Response.Status.OK).entity(quiz).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) Quiz(com.remswork.project.alice.model.Quiz) Message(com.remswork.project.alice.model.support.Message) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) QuizResourceLinks(com.remswork.project.alice.resource.links.QuizResourceLinks)

Example 32 with GradingFactorException

use of com.remswork.project.alice.exception.GradingFactorException 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 33 with GradingFactorException

use of com.remswork.project.alice.exception.GradingFactorException 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 34 with GradingFactorException

use of com.remswork.project.alice.exception.GradingFactorException 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 35 with GradingFactorException

use of com.remswork.project.alice.exception.GradingFactorException 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)

Aggregations

GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)302 Message (com.remswork.project.alice.model.support.Message)178 GradingFactorDaoException (com.remswork.project.alice.dao.exception.GradingFactorDaoException)104 Session (org.hibernate.Session)104 AsyncTask (android.os.AsyncTask)102 Gson (com.google.gson.Gson)102 IOException (java.io.IOException)102 InputStream (java.io.InputStream)102 HttpURLConnection (java.net.HttpURLConnection)102 URL (java.net.URL)102 ExecutionException (java.util.concurrent.ExecutionException)102 ArrayList (java.util.ArrayList)71 Query (org.hibernate.Query)64 ClassResourceLinks (com.remswork.project.alice.resource.links.ClassResourceLinks)35 JSONArray (org.json.JSONArray)32 JSONException (org.json.JSONException)32 Grade (com.remswork.project.alice.model.Grade)25 BufferedWriter (java.io.BufferedWriter)21 OutputStream (java.io.OutputStream)21 OutputStreamWriter (java.io.OutputStreamWriter)21