Search in sources :

Example 11 with Formula

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

the class CriteriaFinaltermInputActivity 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 {
        if (Integer.parseInt(txtTotalPercent.getText().toString().split("%")[0]) != 100) {
            cardViewFailed.setVisibility(View.VISIBLE);
            return;
        }
        Log.i("LAPTOP", teacher.getId() + "");
        Log.i("LAPTOP", subject.getId() + "");
        Log.i("LAPTOP", isExist + "");
        if (!isExist)
            _formula = new FormulaServiceImpl().addFormula(_formula, subject.getId(), teacher.getId(), 2);
        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());
        finish();
    } else
        Toast.makeText(CriteriaFinaltermInputActivity.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 12 with Formula

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

the class ActivityGradeActivity 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.getActivityPercentage() / 100) * grade.getActivityScore();
                        grade.setTotalScore(totalScore);
                        grade.setStudent(student);
                        Log.i("SOMETHINGGG", "totalScore" + formula.getActivityPercentage());
                        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)

Example 13 with Formula

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

the class ActivityGradeAssignment 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.getAssignmentPercentage() / 100) * grade.getAssignmentScore();
                        grade.setTotalScore(totalScore);
                        grade.setStudent(student);
                        Log.i("SOMETHINGGG", "totalScore" + formula.getAssignmentPercentage());
                        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)

Example 14 with Formula

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

the class ActivityGradeQuiz 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.getQuizPercentage() / 100) * grade.getQuizScore();
                        grade.setTotalScore(totalScore);
                        grade.setStudent(student);
                        Log.i("SOMETHINGGG", "totalScore" + formula.getQuizPercentage());
                        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)

Example 15 with Formula

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

the class FormulaDaoImpl method getFormulaBySubjectAndTeacherId.

@Override
public Formula getFormulaBySubjectAndTeacherId(long subjectId, long teacherId, long termId) throws GradingFactorException {
    Session session = sessionFactory.openSession();
    session.beginTransaction();
    try {
        String hql = "from Formula where subject.id = :subjectId and teacher.id = :teacherId and term.id = :termId";
        Query query = session.createQuery(hql);
        query.setParameter("subjectId", subjectId);
        query.setParameter("teacherId", teacherId);
        query.setParameter("termId", termId);
        Formula formula;
        if (query.list().size() < 1)
            throw new GradingFactorDaoException("Formula with subjectId : " + subjectId + ", teacherId : " + teacherId + " or termId : " + termId + " does not exist");
        formula = (Formula) query.list().get(0);
        session.getTransaction().commit();
        session.close();
        return formula;
    } 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) GradingFactorDaoException(com.remswork.project.alice.dao.exception.GradingFactorDaoException) Session(org.hibernate.Session)

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