Search in sources :

Example 6 with GradeService

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

Aggregations

Class (com.remswork.project.alice.model.Class)6 Formula (com.remswork.project.alice.model.Formula)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 FormulaServiceImpl (com.remswork.project.alice.service.impl.FormulaServiceImpl)6 GradeServiceImpl (com.remswork.project.alice.service.impl.GradeServiceImpl)6 DI (io.classify.DI)1 Mark (io.classify.model.Mark)1 MarkDto (io.classify.model.MarkDto)1