use of com.remswork.project.alice.model.Student in project classify-system by anverliedoit.
the class ActivityInputActivityF method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_z_input_activity);
init();
buttonSubmit.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
final long classId = getIntent().getExtras().getLong("classId");
try {
Activity activity = new Activity();
activity.setTitle(!editTextName.getText().toString().trim().isEmpty() ? editTextName.getText().toString().trim() : "Activity");
activity.setDate(textViewDate.getText().toString());
if (editTextTotal.getText().toString().equals("")) {
toggleButtonhideandshow.setChecked(false);
getDialogEmptyTotal.setVisibility(View.VISIBLE);
recyclerViewStudentInput.setVisibility(View.GONE);
return;
} else {
activity.setItemTotal(Integer.parseInt(editTextTotal.getText().toString()));
}
studentAdapter.setTotalItem(activity.getItemTotal());
studentAdapter.onValidate(true);
if (studentAdapter.isNoError()) {
activity = activityService.addActivity(activity, 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);
activityService.addActivityResult(score, activity.getId(), student.getId());
// Adding Grade for activity
new Thread(new Runnable() {
@Override
public void run() {
try {
final List<Activity> activityList = activityService.getActivityListByClassId(classId);
final double[] fActivity = new double[activityList.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();
Log.i("STUDENT ID :", sId + "");
Log.i("Grade ID :", gradeId + "");
for (int i = 0; i < fActivity.length; i++) {
final double total = activityList.get(i).getItemTotal();
final double score = activityService.getActivityResultByActivityAndStudentId(activityList.get(i).getId(), sId).getScore();
fActivity[i] = (score / total) * 100;
Log.i("Activity[" + i + "] :", fActivity[i] + "");
}
for (int i = 0; i < fActivity.length; i++) tempTotal += fActivity[i];
// after looping
if (fActivity.length > 0)
tempTotal /= fActivity.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(ActivityInputActivityF.this, "Success", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(ActivityInputActivityF.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 AssignmentInputActivityF method init.
public void init() {
try {
editTextName = (EditText) findViewById(R.id.input_name2);
editTextTotal = (EditText) findViewById(R.id.input_total2);
textViewDate = (TextView) findViewById(R.id.input_date2);
buttonSubmit = (ToggleButton) findViewById(R.id.input_submit2);
btnBack = (Button) findViewById(input_back2);
dialogFailed = (CardView) findViewById(R.id.input_failed2);
dialogSucces = (CardView) findViewById(R.id.input_succes2);
btnOk = (Button) findViewById(input_ok2);
btnTryAgain = (Button) findViewById(input_tryagain2);
getDialogEmptyTotal = (CardView) findViewById(R.id.input_failedemp2);
getBtnTryAgainEmptyTotal = (Button) findViewById(input_tryagainemp2);
toggleButtonhideandshow = (ToggleButton) findViewById(R.id.input_hideandshow2);
frameLayouthideandshow = (FrameLayout) findViewById(R.id.input_detailts2);
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_recyclerview2);
recyclerViewStudentInput.setVisibility(View.VISIBLE);
for (Student s : classService.getStudentList(getIntent().getExtras().getLong("classId"))) studentList.add(s);
studentAdapter = new AssignmentInputAdapterF(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 AttendanceInputActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_z_input_attendace);
classId = getIntent().getExtras().getLong("classId");
termId = getIntent().getExtras().getLong("termId");
init();
btnBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = getIntent().setClass(AttendanceInputActivity.this, AttendanceAddActivity.class);
startActivity(intent);
finish();
}
});
btnOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = getIntent().setClass(AttendanceInputActivity.this, AttendanceAddActivity.class);
startActivity(intent);
finish();
}
});
btnTryagain.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
cardmessage.setVisibility(View.GONE);
cardViewFailed.setVisibility(View.GONE);
hidesomthing.setVisibility(View.VISIBLE);
}
});
buttonSubmit.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
switch(v.getId()) {
case btn_submit3_attendance:
new Thread(new Runnable() {
@Override
public void run() {
new Handler(getMainLooper()).post(new Runnable() {
@Override
public void run() {
try {
Attendance attendance = new Attendance();
attendance.setTitle(!editTextName.getText().toString().trim().isEmpty() ? editTextName.getText().toString().trim() : "Attendance");
attendance.setDate(textViewDate.getText().toString());
listener.onValidate();
if (attendanceInputAdapter.getErrorCount() == 0) {
rlDisruptor.setVisibility(View.VISIBLE);
attendance = attendanceService.addAttendance(attendance, classId, termId);
for (int i = 0; i < studentList.size(); i++) {
final long studentId = studentList.get(i).getId();
int status = attendanceInputAdapter.getStatus(i);
Student student = studentList.get(i);
attendanceService.addAttendanceResult(status, attendance.getId(), student.getId());
// Adding Grade for activity
new Thread(new Runnable() {
@Override
public void run() {
try {
final List<Attendance> attendanceList = attendanceService.getAttendanceListByClassId(classId);
final double[] fAttendance = new double[attendanceList.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();
for (int i = 0; i < fAttendance.length; i++) {
final double total = 1;
final double status = attendanceService.getAttendanceResultByAttendanceAndStudentId(attendanceList.get(i).getId(), sId).getStatus();
final double score = (status == 1 ? 1 : 0);
fAttendance[i] = (score / total) * 100;
}
for (int i = 0; i < fAttendance.length; i++) tempTotal += fAttendance[i];
// after looping
if (fAttendance.length > 0)
tempTotal /= fAttendance.length;
else
tempTotal = 0;
lGrade.setActivityScore(tempTotal);
lGrade.setTotalScore(lGrade.getTotalScore() + tempTotal);
gradeService.updateGradeById(gradeId, lGrade);
} catch (GradingFactorException e) {
e.printStackTrace();
}
}
}).start();
}
cardmessage.setVisibility(View.VISIBLE);
Toast.makeText(AttendanceInputActivity.this, "Success", Toast.LENGTH_LONG).show();
cardViewSucces.setVisibility(View.VISIBLE);
} else {
cardmessage.setVisibility(View.VISIBLE);
txMessageStatus.setText("Found " + attendanceInputAdapter.getErrorCount() + " errors");
cardViewFailed.setVisibility(View.VISIBLE);
hidesomthing.setVisibility(View.GONE);
}
rlDisruptor.setVisibility(View.GONE);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}).start();
break;
}
}
});
}
use of com.remswork.project.alice.model.Student in project classify-system by anverliedoit.
the class ProjectInputActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_z_input_project);
init();
buttonSubmit.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
final long classId = getIntent().getExtras().getLong("classId");
try {
Project project = new Project();
project.setTitle(!editTextName.getText().toString().trim().isEmpty() ? editTextName.getText().toString().trim() : "Project");
project.setDate(textViewDate.getText().toString());
if (editTextTotal.getText().toString().equals("")) {
toggleButtonhideandshow.setChecked(false);
getDialogEmptyTotal.setVisibility(View.VISIBLE);
recyclerViewStudentInput.setVisibility(View.GONE);
return;
} else {
project.setItemTotal(Integer.parseInt(editTextTotal.getText().toString()));
}
studentAdapter.setTotalItem(project.getItemTotal());
studentAdapter.onValidate(true);
if (studentAdapter.isNoError()) {
project = projectService.addProject(project, 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);
projectService.addProjectResult(score, project.getId(), student.getId());
// Adding Grade for project
new Thread(new Runnable() {
@Override
public void run() {
try {
final List<Project> projectList = projectService.getProjectListByClassId(classId);
final double[] fProject = new double[projectList.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();
for (int i = 0; i < fProject.length; i++) {
final double total = projectList.get(i).getItemTotal();
final double score = projectService.getProjectResultByProjectAndStudentId(projectList.get(i).getId(), sId).getScore();
fProject[i] = (score / total) * 100;
}
for (int i = 0; i < fProject.length; i++) tempTotal += fProject[i];
// after looping
if (fProject.length > 0)
tempTotal /= fProject.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(ProjectInputActivity.this, "Success", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(ProjectInputActivity.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 ProjectInputActivityF method init.
public void init() {
try {
editTextName = (EditText) findViewById(R.id.input_name5);
editTextTotal = (EditText) findViewById(R.id.input_total5);
textViewDate = (TextView) findViewById(R.id.input_date5);
buttonSubmit = (ToggleButton) findViewById(R.id.input_submit5);
btnBack = (Button) findViewById(input_back5);
dialogFailed = (CardView) findViewById(R.id.input_failed5);
dialogSucces = (CardView) findViewById(R.id.input_succes5);
btnOk = (Button) findViewById(input_ok5);
btnTryAgain = (Button) findViewById(input_tryagain5);
getDialogEmptyTotal = (CardView) findViewById(R.id.input_failedemp5);
getBtnTryAgainEmptyTotal = (Button) findViewById(input_tryagainemp5);
toggleButtonhideandshow = (ToggleButton) findViewById(R.id.input_hideandshow5);
frameLayouthideandshow = (FrameLayout) findViewById(R.id.input_detailts5);
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_recyclerview5);
recyclerViewStudentInput.setVisibility(View.VISIBLE);
for (Student s : classService.getStudentList(getIntent().getExtras().getLong("classId"))) studentList.add(s);
studentAdapter = new ProjectInputAdapterF(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();
}
}
Aggregations