Search in sources :

Example 1 with Formula

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

the class FormulaResource method getFormulaById.

@GET
@Path("{formulaId}")
public Response getFormulaById(@PathParam("formulaId") long id) {
    try {
        FormulaResourceLinks resourceLinks = new FormulaResourceLinks(uriInfo);
        SubjectResourceLinks subjectResourceLinks = new SubjectResourceLinks(uriInfo);
        TeacherResourceLinks teacherResourceLinks = new TeacherResourceLinks(uriInfo);
        Formula formula = formulaService.getFormulaById(id);
        formula.addLink(resourceLinks.self(id));
        if (formula.getSubject() != null)
            formula.getSubject().addLink(subjectResourceLinks.self(formula.getSubject().getId()));
        if (formula.getTeacher() != null)
            formula.getTeacher().addLink(teacherResourceLinks.self(formula.getTeacher().getId()));
        return Response.status(Response.Status.OK).entity(formula).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 : Formula(com.remswork.project.alice.model.Formula) SubjectResourceLinks(com.remswork.project.alice.resource.links.SubjectResourceLinks) FormulaResourceLinks(com.remswork.project.alice.resource.links.FormulaResourceLinks) Message(com.remswork.project.alice.model.support.Message) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) TeacherResourceLinks(com.remswork.project.alice.resource.links.TeacherResourceLinks)

Example 2 with Formula

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

the class FormulaDaoImpl method getFormulaList.

@Override
public List<Formula> getFormulaList() throws GradingFactorException {
    Session session = sessionFactory.openSession();
    session.beginTransaction();
    try {
        List<Formula> formulaList = new ArrayList<>();
        Query query = session.createQuery("from Formula");
        for (Object objFormula : query.list()) formulaList.add((Formula) objFormula);
        session.getTransaction().commit();
        session.close();
        return formulaList;
    } catch (GradingFactorDaoException e) {
        session.close();
        throw new GradingFactorException(e.getMessage());
    }
}
Also used : Formula(com.remswork.project.alice.model.Formula) Query(org.hibernate.Query) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) ArrayList(java.util.ArrayList) GradingFactorDaoException(com.remswork.project.alice.dao.exception.GradingFactorDaoException) Session(org.hibernate.Session)

Example 3 with Formula

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

the class CriteriaMidtermInputActivity method onClick.

@Override
public void onClick(View v) {
    Formula _formula = new Formula();
    _formula.setActivityPercentage(percent[0]);
    _formula.setAssignmentPercentage(percent[1]);
    _formula.setAttendancePercentage(percent[2]);
    _formula.setExamPercentage(percent[3]);
    _formula.setProjectPercentage(percent[4]);
    _formula.setQuizPercentage(percent[5]);
    try {
        /**
         *TODO
         */
        if (Integer.parseInt(txtTotalPercent.getText().toString().split("%")[0]) != 100) {
            cardViewFailed.setVisibility(View.VISIBLE);
            return;
        }
        if (!isExist)
            _formula = new FormulaServiceImpl().addFormula(_formula, subject.getId(), teacher.getId(), 1);
        else
            _formula = new FormulaServiceImpl().updateFormulaById(formula.getId(), _formula, 0, 0, 0);
    } catch (GradingFactorException e) {
        e.printStackTrace();
    }
    if (_formula != null) {
        getIntent().setClass(this, SubjectViewActivity.class);
        startActivity(getIntent());
        this.finish();
    } else
        Toast.makeText(CriteriaMidtermInputActivity.this, "Please try again", Toast.LENGTH_SHORT).show();
}
Also used : Formula(com.remswork.project.alice.model.Formula) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) FormulaServiceImpl(com.remswork.project.alice.service.impl.FormulaServiceImpl)

Example 4 with Formula

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

the class GradeResultActivity2 method load.

public void load() {
    try {
        final FormulaService formulaService = new FormulaServiceImpl();
        final GradeService gradeService = new GradeServiceImpl();
        final long termId = getIntent().getExtras().getLong("termId");
        final long classId = getIntent().getExtras().getLong("classId");
        final Class _class = classService.getClassById(classId);
        final long subjectId = _class.getSubject() != null ? _class.getSubject().getId() : 0;
        final long teacherId = _class.getTeacher() != null ? _class.getTeacher().getId() : 0;
        final Formula formula = formulaService.getFormulaBySubjectAndTeacherId(subjectId, teacherId, termId);
        Log.i("SOMETHINGGG", "CLASSID" + classId + " FORMULAID" + formula.getId());
        final io.classify.service.GradeService gr = new DI().getRetrofit().create(io.classify.service.GradeService.class);
        for (final Student student : classService.getStudentListOrdered(classId)) {
            Log.i("TATATE", String.format("test/total/class/{%d}/term/{%d}/teacher/{%d}/subject/{%d}/student/{%d}", classId, termId, teacherId, subjectId, student.getId()));
            gr.findAll(classId, teacherId, subjectId, student.getId()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<MarkDto>() {

                @Override
                public void accept(MarkDto result) throws Exception {
                    if (!result.getMidterm().equals("NaN")) {
                        Grade grade = new Grade();
                        grade.setStudent(student);
                        grade.setTotalScore(Double.parseDouble(result.getMidterm()));
                        Grade grade2 = new Grade();
                        grade2.setStudent(student);
                        grade2.setTotalScore(Double.parseDouble(result.getFinalterm()));
                        Mark mark = new Mark();
                        mark.setMidterm(grade);
                        mark.setFinalterm(grade2);
                        gradeList.add(mark);
                        notifyChange();
                    }
                }
            }, new Consumer<Throwable>() {

                @Override
                public void accept(Throwable throwable) throws Exception {
                    Log.i("TAETAE", throwable.toString());
                }
            });
        // final Student cStudent = student;
        // Log.i("SOMETHINGGG", "Student" + student.getId());
        // Log.i("FORMULA",formula.getId()+ "");
        // new Thread(new Runnable() {
        // @Override
        // public void run() {
        // try {
        // long studentId = cStudent.getId();
        // List<Grade> temp = gradeService.getGradeListByClass(classId, studentId, termId);
        // Grade grade = temp.size() > 0 ? temp.get(0) : new Grade();
        // 
        // Log.i("GRADE",grade.getId()+ "");
        // 
        // double actScore = ((double) formula.getActivityPercentage() / 100) * grade.getActivityScore();
        // double assScore = ((double) formula.getAssignmentPercentage() / 100) * grade.getAssignmentScore();
        // double attScore = ((double) formula.getAttendancePercentage() / 100) * grade.getAttendanceScore();
        // double exaScore = ((double) formula.getExamPercentage() / 100) * grade.getExamScore();
        // double proScore = ((double) formula.getProjectPercentage() / 100) * grade.getProjectScore();
        // double quiScore = ((double) formula.getQuizPercentage() / 100) * grade.getQuizScore();
        // 
        // grade.setTotalScore(
        // actScore + assScore + attScore + exaScore + proScore + quiScore
        // );
        // 
        // grade.setStudent(student);
        // 
        // Log.i("SOMETHINGGG", "actScore" + formula.getActivityPercentage());
        // Log.i("SOMETHINGGG", "assScore" + formula.getAssignmentPercentage());
        // Log.i("SOMETHINGGG", "attScore" + formula.getAttendancePercentage());
        // Log.i("SOMETHINGGG", "exaScore" + formula.getExamPercentage());
        // Log.i("SOMETHINGGG", "proScore" + formula.getProjectPercentage());
        // Log.i("SOMETHINGGG", "quiScore" + formula.getQuizPercentage());
        // Log.i("SOMETHINGGG", "Student" + studentId);
        // Log.i("SOMETHINGGG", "Grade" + grade.getId());
        // 
        // gradeList.add(grade);
        // notifyChange();
        // } catch (Exception e) {
        // e.printStackTrace();
        // }
        // }
        // }).start();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : GradeService(com.remswork.project.alice.service.GradeService) FormulaService(com.remswork.project.alice.service.FormulaService) DI(io.classify.DI) Mark(io.classify.model.Mark) Grade(com.remswork.project.alice.model.Grade) Student(com.remswork.project.alice.model.Student) MarkDto(io.classify.model.MarkDto) Formula(com.remswork.project.alice.model.Formula) GradeServiceImpl(com.remswork.project.alice.service.impl.GradeServiceImpl) Class(com.remswork.project.alice.model.Class) FormulaServiceImpl(com.remswork.project.alice.service.impl.FormulaServiceImpl)

Example 5 with Formula

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

the class ActivityGradeExam method load.

public void load() {
    try {
        final FormulaService formulaService = new FormulaServiceImpl();
        final GradeService gradeService = new GradeServiceImpl();
        final long termId = getIntent().getExtras().getLong("termId");
        final long classId = getIntent().getExtras().getLong("classId");
        final Class _class = classService.getClassById(classId);
        final long subjectId = _class.getSubject() != null ? _class.getSubject().getId() : 0;
        final long teacherId = _class.getTeacher() != null ? _class.getTeacher().getId() : 0;
        final Formula formula = formulaService.getFormulaBySubjectAndTeacherId(subjectId, teacherId, termId);
        Log.i("SOMETHINGGG", "CLASSID" + classId + " FORMULAID" + formula.getId());
        for (final Student student : classService.getStudentList(classId)) {
            final Student cStudent = student;
            Log.i("SOMETHINGGG", "Student" + student.getId());
            Log.i("FORMULA", formula.getId() + "");
            new Thread(new Runnable() {

                @Override
                public void run() {
                    try {
                        long studentId = cStudent.getId();
                        List<Grade> temp = gradeService.getGradeListByClass(classId, studentId, termId);
                        Grade grade = temp.size() > 0 ? temp.get(0) : new Grade();
                        Log.i("GRADE", grade.getId() + "");
                        double totalScore = ((double) formula.getExamPercentage() / 100) * grade.getExamScore();
                        grade.setTotalScore(totalScore);
                        grade.setStudent(student);
                        Log.i("SOMETHINGGG", "totalScore" + formula.getExamPercentage());
                        gradeList.add(grade);
                        notifyChange();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }).start();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : GradeService(com.remswork.project.alice.service.GradeService) FormulaService(com.remswork.project.alice.service.FormulaService) Grade(com.remswork.project.alice.model.Grade) Student(com.remswork.project.alice.model.Student) Formula(com.remswork.project.alice.model.Formula) GradeServiceImpl(com.remswork.project.alice.service.impl.GradeServiceImpl) Class(com.remswork.project.alice.model.Class) FormulaServiceImpl(com.remswork.project.alice.service.impl.FormulaServiceImpl)

Aggregations

Formula (com.remswork.project.alice.model.Formula)25 GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)19 FormulaServiceImpl (com.remswork.project.alice.service.impl.FormulaServiceImpl)10 Message (com.remswork.project.alice.model.support.Message)7 GradingFactorDaoException (com.remswork.project.alice.dao.exception.GradingFactorDaoException)6 Class (com.remswork.project.alice.model.Class)6 Grade (com.remswork.project.alice.model.Grade)6 Student (com.remswork.project.alice.model.Student)6 FormulaService (com.remswork.project.alice.service.FormulaService)6 GradeService (com.remswork.project.alice.service.GradeService)6 GradeServiceImpl (com.remswork.project.alice.service.impl.GradeServiceImpl)6 FormulaResourceLinks (com.remswork.project.alice.resource.links.FormulaResourceLinks)5 SubjectResourceLinks (com.remswork.project.alice.resource.links.SubjectResourceLinks)5 TeacherResourceLinks (com.remswork.project.alice.resource.links.TeacherResourceLinks)5 ArrayList (java.util.ArrayList)5 Session (org.hibernate.Session)5 View (android.view.View)4 TextView (android.widget.TextView)4 CompoundButton (android.widget.CompoundButton)3 Subject (com.remswork.project.alice.model.Subject)3