use of com.remswork.project.alice.model.Grade in project classify-system by anverliedoit.
the class GradeResource method updateGradeById.
@PUT
@Path("{gradeId}")
public Response updateGradeById(@PathParam("gradeId") long gradeId, Grade newGrade) {
try {
Grade grade;
if (termId != 0)
grade = gradeService.updateGrade(gradeId, newGrade, classId, studentId, termId);
else if (classId != 0 || studentId != 0)
grade = gradeService.updateGrade(gradeId, newGrade, classId, studentId);
else
grade = gradeService.updateGradeById(gradeId, newGrade);
return Response.status(Response.Status.OK).entity(grade).build();
} catch (GradingFactorException e) {
e.printStackTrace();
Message message = new Message(400, "Bad Request", e.getMessage());
return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
}
}
use of com.remswork.project.alice.model.Grade in project classify-system by anverliedoit.
the class AssignmentInputActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_z_input_assignment);
init();
buttonSubmit.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
final long classId = getIntent().getExtras().getLong("classId");
try {
Assignment assignment = new Assignment();
assignment.setTitle(!editTextName.getText().toString().trim().isEmpty() ? editTextName.getText().toString().trim() : "Assignment");
assignment.setDate(textViewDate.getText().toString());
if (editTextTotal.getText().toString().equals("")) {
toggleButtonhideandshow.setChecked(false);
getDialogEmptyTotal.setVisibility(View.VISIBLE);
recyclerViewStudentInput.setVisibility(View.GONE);
return;
} else {
assignment.setItemTotal(Integer.parseInt(editTextTotal.getText().toString()));
}
studentAdapter.setTotalItem(assignment.getItemTotal());
studentAdapter.onValidate(true);
if (studentAdapter.isNoError()) {
assignment = assignmentService.addAssignment(assignment, 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);
assignmentService.addAssignmentResult(score, assignment.getId(), student.getId());
// Adding Grade for assignment
new Thread(new Runnable() {
@Override
public void run() {
try {
final List<Assignment> assignmentList = assignmentService.getAssignmentListByClassId(classId);
final double[] fAssignment = new double[assignmentList.size()];
final long sId = studentId;
double tempTotal = 0;
try {
List<Grade> tempList = gradeService.getGradeListByClass(classId, sId, 1L);
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, 1L);
}
final Grade lGrade = grade;
final long gradeId = grade.getId();
Log.i("STUDENT ID :", sId + "");
Log.i("Grade ID :", gradeId + "");
for (int i = 0; i < fAssignment.length; i++) {
final double total = assignmentList.get(i).getItemTotal();
final double score = assignmentService.getAssignmentResultByAssignmentAndStudentId(assignmentList.get(i).getId(), sId).getScore();
fAssignment[i] = (score / total) * 100;
Log.i("Assignment[" + i + "] :", fAssignment[i] + "");
}
for (int i = 0; i < fAssignment.length; i++) tempTotal += fAssignment[i];
// after looping
if (fAssignment.length > 0)
tempTotal /= fAssignment.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(AssignmentInputActivity.this, "Success", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(AssignmentInputActivity.this, "Failed", Toast.LENGTH_LONG).show();
dialogFailed.setVisibility(View.VISIBLE);
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
use of com.remswork.project.alice.model.Grade 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.Grade 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.Grade in project classify-system by anverliedoit.
the class AssignmentInputActivityF method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_z_input_assignment);
init();
buttonSubmit.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
final long classId = getIntent().getExtras().getLong("classId");
try {
Assignment assignment = new Assignment();
assignment.setTitle(!editTextName.getText().toString().trim().isEmpty() ? editTextName.getText().toString().trim() : "Assignment");
assignment.setDate(textViewDate.getText().toString());
if (editTextTotal.getText().toString().equals("")) {
toggleButtonhideandshow.setChecked(false);
getDialogEmptyTotal.setVisibility(View.VISIBLE);
recyclerViewStudentInput.setVisibility(View.GONE);
return;
} else {
assignment.setItemTotal(Integer.parseInt(editTextTotal.getText().toString()));
}
studentAdapter.setTotalItem(assignment.getItemTotal());
studentAdapter.onValidate(true);
if (studentAdapter.isNoError()) {
assignment = assignmentService.addAssignment(assignment, classId, 2L);
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);
assignmentService.addAssignmentResult(score, assignment.getId(), student.getId());
// Adding Grade for assignment
new Thread(new Runnable() {
@Override
public void run() {
try {
final List<Assignment> assignmentList = assignmentService.getAssignmentListByClassId(classId);
final double[] fAssignment = new double[assignmentList.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, 1L);
}
final Grade lGrade = grade;
final long gradeId = grade.getId();
for (int i = 0; i < fAssignment.length; i++) {
final double total = assignmentList.get(i).getItemTotal();
final double score = assignmentService.getAssignmentResultByAssignmentAndStudentId(assignmentList.get(i).getId(), sId).getScore();
fAssignment[i] = (score / total) * 100;
}
for (int i = 0; i < fAssignment.length; i++) tempTotal += fAssignment[i];
// after looping
if (fAssignment.length > 0)
tempTotal /= fAssignment.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(AssignmentInputActivityF.this, "Success", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(AssignmentInputActivityF.this, "Failed", Toast.LENGTH_LONG).show();
dialogFailed.setVisibility(View.VISIBLE);
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
Aggregations