use of com.remswork.project.alice.model.Student in project classify-system by anverliedoit.
the class ExamInputActivity method init.
public void init() {
try {
editTextName = (EditText) findViewById(R.id.input_name4);
editTextTotal = (EditText) findViewById(R.id.input_total4);
textViewDate = (TextView) findViewById(R.id.input_date4);
buttonSubmit = (ToggleButton) findViewById(R.id.input_submit4);
btnBack = (Button) findViewById(input_back4);
dialogFailed = (CardView) findViewById(R.id.input_failed4);
dialogSucces = (CardView) findViewById(R.id.input_succes4);
btnOk = (Button) findViewById(input_ok4);
btnTryAgain = (Button) findViewById(input_tryagain4);
getDialogEmptyTotal = (CardView) findViewById(R.id.input_failedemp4);
getBtnTryAgainEmptyTotal = (Button) findViewById(input_tryagainemp4);
toggleButtonhideandshow = (ToggleButton) findViewById(R.id.input_hideandshow4);
frameLayouthideandshow = (FrameLayout) findViewById(R.id.input_detailts4);
toggleButtonhideandshow.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
frameLayouthideandshow.setVisibility(View.GONE);
} else {
frameLayouthideandshow.setVisibility(View.VISIBLE);
}
}
});
getDialogEmptyTotal.setVisibility(View.GONE);
dialogSucces.setVisibility(View.GONE);
dialogFailed.setVisibility(View.GONE);
btnOk.setOnClickListener(this);
btnBack.setOnClickListener(this);
buttonSubmit.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
buttonSubmit.setVisibility(View.GONE);
}
}
});
getBtnTryAgainEmptyTotal.setOnClickListener(this);
btnTryAgain.setOnClickListener(this);
recyclerViewStudentInput = (RecyclerView) findViewById(R.id.input_recyclerview4);
recyclerViewStudentInput.setVisibility(View.VISIBLE);
for (Student s : classService.getStudentList(getIntent().getExtras().getLong("classId"))) studentList.add(s);
studentAdapter = new ExamInputAdapter(this, studentList);
recyclerViewStudentInput.setAdapter(studentAdapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerViewStudentInput.setLayoutManager(layoutManager);
recyclerViewStudentInput.setItemAnimator(new DefaultItemAnimator());
String date = String.format(Locale.ENGLISH, "%02d/%02d/%d", Calendar.getInstance().get(Calendar.MONTH), Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + 1, Calendar.getInstance().get(Calendar.YEAR));
textViewDate.setText(date);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.remswork.project.alice.model.Student in project classify-system by anverliedoit.
the class ExamInputActivityF method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_z_input_exam);
init();
buttonSubmit.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
final long classId = getIntent().getExtras().getLong("classId");
try {
Exam exam = new Exam();
exam.setTitle(!editTextName.getText().toString().trim().isEmpty() ? editTextName.getText().toString().trim() : "Exam");
exam.setDate(textViewDate.getText().toString());
if (editTextTotal.getText().toString().equals("")) {
toggleButtonhideandshow.setChecked(false);
getDialogEmptyTotal.setVisibility(View.VISIBLE);
recyclerViewStudentInput.setVisibility(View.GONE);
return;
} else {
exam.setItemTotal(Integer.parseInt(editTextTotal.getText().toString()));
}
studentAdapter.setTotalItem(exam.getItemTotal());
studentAdapter.onValidate(true);
if (studentAdapter.isNoError()) {
exam = examService.addExam(exam, classId, 1L);
for (int i = 0; i < studentList.size(); i++) {
// Student id
final long studentId = studentList.get(i).getId();
//
int score = studentAdapter.getScore(i);
Student student = studentList.get(i);
examService.addExamResult(score, exam.getId(), student.getId());
// Adding Grade for exam
new Thread(new Runnable() {
@Override
public void run() {
try {
final List<Exam> examList = examService.getExamListByClassId(classId);
final double[] fExam = new double[examList.size()];
final long sId = studentId;
double tempTotal = 0;
try {
List<Grade> tempList = gradeService.getGradeListByClass(classId, sId, 2L);
grade = (tempList.size() > 0 ? tempList.get(0) : null);
} catch (GradingFactorException e) {
e.printStackTrace();
grade = null;
}
if (grade == null) {
Grade _grade = new Grade();
grade = gradeService.addGrade(_grade, classId, studentId, 2L);
}
final Grade lGrade = grade;
final long gradeId = grade.getId();
for (int i = 0; i < fExam.length; i++) {
final double total = examList.get(i).getItemTotal();
final double score = examService.getExamResultByExamAndStudentId(examList.get(i).getId(), sId).getScore();
fExam[i] = (score / total) * 100;
}
for (int i = 0; i < fExam.length; i++) tempTotal += fExam[i];
// after looping
if (fExam.length > 0)
tempTotal /= fExam.length;
else
tempTotal = 0;
lGrade.setActivityScore(tempTotal);
lGrade.setTotalScore(lGrade.getTotalScore() + tempTotal);
gradeService.updateGradeById(gradeId, lGrade);
} catch (GradingFactorException e) {
e.printStackTrace();
}
}
}).start();
}
dialogSucces.setVisibility(View.VISIBLE);
Toast.makeText(ExamInputActivityF.this, "Success", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(ExamInputActivityF.this, "Failed", Toast.LENGTH_LONG).show();
dialogFailed.setVisibility(View.VISIBLE);
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
use of com.remswork.project.alice.model.Student in project classify-system by anverliedoit.
the class ExamInputActivityF method init.
public void init() {
try {
editTextName = (EditText) findViewById(R.id.input_name4);
editTextTotal = (EditText) findViewById(R.id.input_total4);
textViewDate = (TextView) findViewById(R.id.input_date4);
buttonSubmit = (ToggleButton) findViewById(R.id.input_submit4);
btnBack = (Button) findViewById(input_back4);
dialogFailed = (CardView) findViewById(R.id.input_failed4);
dialogSucces = (CardView) findViewById(R.id.input_succes4);
btnOk = (Button) findViewById(input_ok4);
btnTryAgain = (Button) findViewById(input_tryagain4);
getDialogEmptyTotal = (CardView) findViewById(R.id.input_failedemp4);
getBtnTryAgainEmptyTotal = (Button) findViewById(input_tryagainemp4);
toggleButtonhideandshow = (ToggleButton) findViewById(R.id.input_hideandshow4);
frameLayouthideandshow = (FrameLayout) findViewById(R.id.input_detailts4);
toggleButtonhideandshow.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
frameLayouthideandshow.setVisibility(View.GONE);
} else {
frameLayouthideandshow.setVisibility(View.VISIBLE);
}
}
});
getDialogEmptyTotal.setVisibility(View.GONE);
dialogSucces.setVisibility(View.GONE);
dialogFailed.setVisibility(View.GONE);
btnOk.setOnClickListener(this);
btnBack.setOnClickListener(this);
buttonSubmit.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
buttonSubmit.setVisibility(View.GONE);
}
}
});
getBtnTryAgainEmptyTotal.setOnClickListener(this);
btnTryAgain.setOnClickListener(this);
recyclerViewStudentInput = (RecyclerView) findViewById(R.id.input_recyclerview4);
recyclerViewStudentInput.setVisibility(View.VISIBLE);
for (Student s : classService.getStudentList(getIntent().getExtras().getLong("classId"))) studentList.add(s);
studentAdapter = new ExamInputAdapterF(this, studentList);
recyclerViewStudentInput.setAdapter(studentAdapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerViewStudentInput.setLayoutManager(layoutManager);
recyclerViewStudentInput.setItemAnimator(new DefaultItemAnimator());
String date = String.format(Locale.ENGLISH, "%02d/%02d/%d", Calendar.getInstance().get(Calendar.MONTH), Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + 1, Calendar.getInstance().get(Calendar.YEAR));
textViewDate.setText(date);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.remswork.project.alice.model.Student 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();
}
}
use of com.remswork.project.alice.model.Student 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();
}
}
Aggregations