Search in sources :

Example 21 with Student

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();
            }
        }
    });
}
Also used : Button(android.widget.Button) ToggleButton(android.widget.ToggleButton) CompoundButton(android.widget.CompoundButton) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) AppCompatActivity(android.support.v7.app.AppCompatActivity) Activity(com.remswork.project.alice.model.Activity) 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 22 with Student

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();
    }
}
Also used : Student(com.remswork.project.alice.model.Student) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) CompoundButton(android.widget.CompoundButton) AssignmentInputAdapterF(com.lieverandiver.thesisproject.adapter.AssignmentInputAdapterF) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException)

Example 23 with Student

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;
            }
        }
    });
}
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 24 with Student

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();
            }
        }
    });
}
Also used : Project(com.remswork.project.alice.model.Project) 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 25 with Student

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();
    }
}
Also used : Student(com.remswork.project.alice.model.Student) ProjectInputAdapterF(com.lieverandiver.thesisproject.adapter.ProjectInputAdapterF) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) CompoundButton(android.widget.CompoundButton) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException)

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