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();
}
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();
}
}
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();
}
}
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();
}
}
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());
}
}
Aggregations