Search in sources :

Example 61 with Student

use of com.remswork.project.alice.model.Student 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();
            }
        }
    });
}
Also used : Assignment(com.remswork.project.alice.model.Assignment) Button(android.widget.Button) ToggleButton(android.widget.ToggleButton) CompoundButton(android.widget.CompoundButton) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) ArrayList(java.util.ArrayList) List(java.util.List) Grade(com.remswork.project.alice.model.Grade) Student(com.remswork.project.alice.model.Student) View(android.view.View) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException)

Example 62 with Student

use of com.remswork.project.alice.model.Student in project classify-system by anverliedoit.

the class AttendanceInputActivity method init.

public void init() {
    try {
        hidesomthing = (CardView) findViewById(R.id.input_attendance_hide_save);
        editTextName = (TextView) findViewById(R.id.input_attendance_name);
        textViewDate = (TextView) findViewById(R.id.txtv_date3);
        btnBack = (Button) findViewById(R.id.input_back3);
        buttonSubmit = (Button) findViewById(btn_submit3_attendance);
        btnSelectAll = (Button) findViewById(R.id.btn_selectall3);
        recyclerViewStudentInput = (RecyclerView) findViewById(R.id.recyclerview_view3attendance);
        cardmessage = (CardView) findViewById(R.id.card_message_status);
        txMessageStatus = (TextView) findViewById(R.id.card_message_status_text);
        rlDisruptor = (RelativeLayout) findViewById(R.id.disruptor_loading);
        cardViewSucces = (CardView) findViewById(R.id.input_succes3);
        cardViewFailed = (CardView) findViewById(R.id.input_failed3);
        btnTryagain = (Button) findViewById(R.id.input_tryagain3);
        btnOk = (Button) findViewById(R.id.input_ok3);
        rlDisruptor.setVisibility(View.GONE);
        cardViewSucces.setVisibility(View.GONE);
        cardViewFailed.setVisibility(View.GONE);
        for (Student s : classService.getStudentList(classId)) studentList.add(s);
        attendanceInputAdapter = new AttendanceInputAdapter(this, studentList);
        listener = attendanceInputAdapter;
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerViewStudentInput.setAdapter(attendanceInputAdapter);
        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);
        btnSelectAll.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                listener.onSelect(toggleMark);
                if (toggleMark) {
                    btnSelectAll.setText("All unselect");
                    toggleMark = false;
                } else {
                    btnSelectAll.setText("All select");
                    toggleMark = true;
                }
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Student(com.remswork.project.alice.model.Student) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) AttendanceInputAdapter(com.lieverandiver.thesisproject.adapter.AttendanceInputAdapter)

Example 63 with Student

use of com.remswork.project.alice.model.Student in project classify-system by anverliedoit.

the class AttendanceInputActivityF method init.

public void init() {
    try {
        hidesomthing = (CardView) findViewById(R.id.input_attendance_hide_save);
        editTextName = (TextView) findViewById(R.id.input_attendance_name);
        textViewDate = (TextView) findViewById(R.id.txtv_date3);
        btnBack = (Button) findViewById(R.id.input_back3);
        buttonSubmit = (Button) findViewById(btn_submit3_attendance);
        btnSelectAll = (Button) findViewById(R.id.btn_selectall3);
        recyclerViewStudentInput = (RecyclerView) findViewById(R.id.recyclerview_view3attendance);
        cardmessage = (CardView) findViewById(R.id.card_message_status);
        txMessageStatus = (TextView) findViewById(R.id.card_message_status_text);
        rlDisruptor = (RelativeLayout) findViewById(R.id.disruptor_loading);
        cardViewSucces = (CardView) findViewById(R.id.input_succes3);
        cardViewFailed = (CardView) findViewById(R.id.input_failed3);
        btnTryagain = (Button) findViewById(R.id.input_tryagain3);
        btnOk = (Button) findViewById(R.id.input_ok3);
        rlDisruptor.setVisibility(View.GONE);
        cardViewSucces.setVisibility(View.GONE);
        cardViewFailed.setVisibility(View.GONE);
        for (Student s : classService.getStudentList(classId)) studentList.add(s);
        attendanceInputAdapter = new AttendanceInputAdapter(this, studentList);
        listener = attendanceInputAdapter;
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerViewStudentInput.setAdapter(attendanceInputAdapter);
        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);
        btnSelectAll.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                listener.onSelect(toggleMark);
                if (toggleMark) {
                    btnSelectAll.setText("All unselect");
                    toggleMark = false;
                } else {
                    btnSelectAll.setText("All select");
                    toggleMark = true;
                }
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Student(com.remswork.project.alice.model.Student) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) AttendanceInputAdapter(com.lieverandiver.thesisproject.adapter.AttendanceInputAdapter)

Example 64 with Student

use of com.remswork.project.alice.model.Student in project classify-system by anverliedoit.

the class AttendanceInputActivityF 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(AttendanceInputActivityF.this, AttendanceAddActivityF.class);
            startActivity(intent);
            finish();
        }
    });
    btnOk.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent intent = getIntent().setClass(AttendanceInputActivityF.this, AttendanceAddActivityF.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, 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 < 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;
                                                                Log.i("Attendance[" + i + "] :", fAttendance[i] + "");
                                                            }
                                                            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);
                                            // txMessageStatus.setText("Success");
                                            Toast.makeText(AttendanceInputActivityF.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;
            }
        }
    });
}
Also used : Attendance(com.remswork.project.alice.model.Attendance) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) Handler(android.os.Handler) Intent(android.content.Intent) Grade(com.remswork.project.alice.model.Grade) Student(com.remswork.project.alice.model.Student) View(android.view.View) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) Button(android.widget.Button)

Example 65 with Student

use of com.remswork.project.alice.model.Student 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();
    }
}
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

Student (com.remswork.project.alice.model.Student)82 GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)29 CompoundButton (android.widget.CompoundButton)22 Message (com.remswork.project.alice.model.support.Message)21 Grade (com.remswork.project.alice.model.Grade)20 ArrayList (java.util.ArrayList)19 StudentException (com.remswork.project.alice.exception.StudentException)17 CardView (android.support.v7.widget.CardView)15 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)15 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)15 RecyclerView (android.support.v7.widget.RecyclerView)15 View (android.view.View)15 TextView (android.widget.TextView)15 ClassException (com.remswork.project.alice.exception.ClassException)14 Button (android.widget.Button)13 List (java.util.List)13 ToggleButton (android.widget.ToggleButton)11 Client (javax.ws.rs.client.Client)10 WebTarget (javax.ws.rs.client.WebTarget)10 Response (javax.ws.rs.core.Response)10