Search in sources :

Example 6 with Formula

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

the class ActivityGradeProject 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 actScore = ((double) formula.getProjectPercentage() / 100) * grade.getProjectScore();
                        grade.setTotalScore(actScore);
                        grade.setStudent(student);
                        Log.i("SOMETHINGGG", "actScore" + formula.getProjectPercentage());
                        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)

Example 7 with Formula

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

the class SubjectViewActivity method init.

private void init() {
    imageViewBackButton = (Button) findViewById(R.id.add_backsubject);
    imageViewBackButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            finish();
        }
    });
    linearLayoutm = (LinearLayout) findViewById(R.id.midterm_setting);
    linearLayoutf = (LinearLayout) findViewById(R.id.finals_setting);
    name = (TextView) findViewById(R.id.a_class_f_view_subject_name);
    code = (TextView) findViewById(R.id.a_class_f_view_subject_code);
    desc = (TextView) findViewById(R.id.a_class_f_view_subject_desc);
    unit = (TextView) findViewById(R.id.a_class_f_view_subject_unit);
    toggleButtonM = (ToggleButton) findViewById(toggle_midview);
    toggleButtonF = (ToggleButton) findViewById(toggle_finview);
    textViewMidtermPercent = (TextView) findViewById(R.id.midterm_percent_sub_view);
    textViewFinalsPercent = (TextView) findViewById(R.id.finals_percent_sub_view);
    recyclerViewMidterm = (RecyclerView) findViewById(R.id.midterm_recycleview);
    recyclerViewFinals = (RecyclerView) findViewById(R.id.finals_recycleview);
    recyclerViewFinals.setVisibility(View.GONE);
    recyclerViewMidterm.setVisibility(View.GONE);
    new Handler(getMainLooper()).post(new Runnable() {

        @Override
        public void run() {
            try {
                recyclerViewMidterm.setVisibility(View.GONE);
                recyclerViewFinals.setVisibility(View.GONE);
                toggleButtonM.setOnCheckedChangeListener(SubjectViewActivity.this);
                toggleButtonF.setOnCheckedChangeListener(SubjectViewActivity.this);
                linearLayoutm.setOnClickListener(SubjectViewActivity.this);
                linearLayoutf.setOnClickListener(SubjectViewActivity.this);
                name.setText(subject.getName());
                code.setText(subject.getCode());
                desc.setText(subject.getDescription());
                unit.setText(String.valueOf(subject.getUnit()));
                Formula formula = formulaService.getFormulaBySubjectAndTeacherId(subject.getId(), teacher.getId(), 1);
                if (formula != null && formula.getSubject() != null) {
                    if (formula.getSubject().getId() == subject.getId()) {
                        formulaMidterm = formula;
                        String[] percents = new String[6];
                        percents[0] = formula.getActivityPercentage() + "%";
                        percents[1] = formula.getAssignmentPercentage() + "%";
                        percents[2] = formula.getAttendancePercentage() + "%";
                        percents[3] = formula.getExamPercentage() + "%";
                        percents[4] = formula.getProjectPercentage() + "%";
                        percents[5] = formula.getQuizPercentage() + "%";
                        CriteriaAdapter2 criteriaAdapter = new CriteriaAdapter2(SubjectViewActivity.this, percents);
                        LinearLayoutManager layoutManager = new LinearLayoutManager(SubjectViewActivity.this);
                        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                        recyclerViewMidterm.setAdapter(criteriaAdapter);
                        recyclerViewMidterm.setLayoutManager(layoutManager);
                        recyclerViewMidterm.setItemAnimator(new DefaultItemAnimator());
                    }
                }
                formula = formulaService.getFormulaBySubjectAndTeacherId(subject.getId(), teacher.getId(), 2);
                if (formula != null && formula.getSubject() != null) {
                    if (formula.getSubject().getId() == subject.getId()) {
                        formulaFinalterm = formula;
                        String[] percents = new String[6];
                        percents[0] = formula.getActivityPercentage() + "%";
                        percents[1] = formula.getAssignmentPercentage() + "%";
                        percents[2] = formula.getAttendancePercentage() + "%";
                        percents[3] = formula.getExamPercentage() + "%";
                        percents[4] = formula.getProjectPercentage() + "%";
                        percents[5] = formula.getQuizPercentage() + "%";
                        CriteriaAdapter2 criteriaAdapter = new CriteriaAdapter2(SubjectViewActivity.this, percents);
                        LinearLayoutManager layoutManager = new LinearLayoutManager(SubjectViewActivity.this);
                        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                        recyclerViewFinals.setAdapter(criteriaAdapter);
                        recyclerViewFinals.setLayoutManager(layoutManager);
                        recyclerViewFinals.setItemAnimator(new DefaultItemAnimator());
                    }
                }
            } catch (GradingFactorException e) {
                e.printStackTrace();
            }
        }
    });
}
Also used : Formula(com.remswork.project.alice.model.Formula) CriteriaAdapter2(com.lieverandiver.thesisproject.adapter.CriteriaAdapter2) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) Handler(android.os.Handler) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 8 with Formula

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

the class Teacher_Activity_View_Subject_Datails method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.teacher_activity_view_subject_datails);
    try {
        subject = new SubjectServiceImpl().getSubjectById(getIntent().getExtras().getLong("subjectId"));
    } catch (SubjectException e) {
        e.printStackTrace();
    }
    textViewMidtermPercent = (TextView) findViewById(R.id.midterm_percent_sub_view);
    textViewMidtermPercent = (TextView) findViewById(R.id.finals_percent_sub_view);
    recyclerViewMidterm = (RecyclerView) findViewById(R.id.midterm_recycleview);
    recyclerViewFinals = (RecyclerView) findViewById(R.id.finals_recycleview);
    linearLayoutm = (LinearLayout) findViewById(R.id.midterm_setting);
    linearLayoutf = (LinearLayout) findViewById(R.id.finals_setting);
    name = (TextView) findViewById(R.id.a_class_f_view_subject_name);
    code = (TextView) findViewById(R.id.a_class_f_view_subject_code);
    desc = (TextView) findViewById(R.id.a_class_f_view_subject_desc);
    unit = (TextView) findViewById(R.id.a_class_f_view_subject_unit);
    toggleButtonM = (ToggleButton) findViewById(R.id.toggle_midview);
    toggleButtonF = (ToggleButton) findViewById(R.id.toggle_finview);
    recyclerViewMidterm.setVisibility(View.GONE);
    recyclerViewFinals.setVisibility(View.GONE);
    toggleButtonM.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                recyclerViewMidterm.setVisibility(View.VISIBLE);
            } else {
                recyclerViewMidterm.setVisibility(View.GONE);
            }
        }
    });
    toggleButtonF.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                recyclerViewFinals.setVisibility(View.VISIBLE);
            } else {
                recyclerViewFinals.setVisibility(View.GONE);
            }
        }
    });
    name.setText(subject.getName());
    code.setText(subject.getCode());
    desc.setText(subject.getDescription());
    unit.setText(subject.getUnit() + "");
    try {
        Formula formula = new FormulaHelper(this).getFormula("1-midterm");
        if (formula != null && formula.getSubject() != null) {
            if (formula.getSubject().getId() == subject.getId()) {
                recyclerViewMidterm.setVisibility(View.VISIBLE);
                String[] key = new String[6];
                key[0] = formula.getActivityPercentage() + "%";
                key[1] = formula.getAssignmentPercentage() + "%";
                key[2] = formula.getAttendancePercentage() + "%";
                key[3] = formula.getExamPercentage() + "%";
                key[4] = formula.getProjectPercentage() + "%";
                key[5] = formula.getQuizPercentage() + "%";
                List<String> datas = new ArrayList<>();
                for (String s : key) datas.add(s);
                CriteriaAdapter criteriaAdapter = new CriteriaAdapter(this, datas);
                LinearLayoutManager layoutManager = new LinearLayoutManager(this);
                layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                recyclerViewMidterm.setAdapter(criteriaAdapter);
                recyclerViewMidterm.setLayoutManager(layoutManager);
                recyclerViewMidterm.setItemAnimator(new DefaultItemAnimator());
            }
        }
    } catch (GradingFactorException e) {
        e.printStackTrace();
    }
    linearLayoutm.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent intent = new Intent(Teacher_Activity_View_Subject_Datails.this, Teacher_GradingFactor_Activity_Midterm.class);
            intent.putExtra("subjectId", subject.getId());
            startActivity(intent);
            finish();
        }
    });
    linearLayoutf.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent intent = new Intent(Teacher_Activity_View_Subject_Datails.this, Teacher_GradingFactor_Activity_Finals.class);
            startActivity(intent);
            finish();
        }
    });
}
Also used : GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) ArrayList(java.util.ArrayList) SubjectException(com.remswork.project.alice.exception.SubjectException) Intent(android.content.Intent) FormulaHelper(com.lieverandiver.thesisproject.helper.FormulaHelper) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Formula(com.remswork.project.alice.model.Formula) CriteriaAdapter(com.lieverandiver.thesisproject.adapter.CriteriaAdapter) SubjectServiceImpl(com.remswork.project.alice.service.impl.SubjectServiceImpl) CompoundButton(android.widget.CompoundButton)

Example 9 with Formula

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

the class Teacher_GradingFactor_Activity_Midterm method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.teacher_gradingfactor_activity_midterm);
    final Subject subject;
    final Teacher teacher;
    try {
        subject = new SubjectServiceImpl().getSubjectById(getIntent().getExtras().getLong("subjectId"));
        teacher = new TeacherHelper(this).loadUser().get();
        linearLayoutm = (LinearLayout) findViewById(R.id.midterm_save);
        // textViewm1 = (TextView) findViewById(R.id.midterm_subjectname);
        // textViewm2 = (TextView) findViewById(R.id.txtv_midterm_percent);
        // spinnerm = (Spinner) findViewById(R.id.midterm_spinner_percent);
        textViewm3 = (TextView) findViewById(R.id.total_percentm);
        textViewm1.setText(subject.getName());
        seekBar1 = (SeekBar) findViewById(R.id.activity_seekbarm);
        seekBar1.setMax(100);
        seekBar1.setProgress(progress);
        seekBar2 = (SeekBar) findViewById(R.id.assignment_seekbarm);
        seekBar2.setMax(100);
        seekBar2.setProgress(progress);
        seekBar3 = (SeekBar) findViewById(R.id.attendance_seekbarm);
        seekBar3.setMax(100);
        seekBar3.setProgress(progress);
        seekBar4 = (SeekBar) findViewById(R.id.exam_seekbarm);
        seekBar4.setMax(100);
        seekBar4.setProgress(progress);
        seekBar5 = (SeekBar) findViewById(R.id.project_seekbarm);
        seekBar5.setMax(100);
        seekBar5.setProgress(progress);
        seekBar6 = (SeekBar) findViewById(R.id.quiz_seekbarm);
        seekBar6.setMax(100);
        seekBar6.setProgress(progress);
        textView1 = (TextView) findViewById(R.id.activity_percent_textm);
        textView2 = (TextView) findViewById(R.id.assignment_percent_textm);
        textView3 = (TextView) findViewById(R.id.attendance_percent_textm);
        textView4 = (TextView) findViewById(R.id.exam_percent_textm);
        textView5 = (TextView) findViewById(R.id.project_percent_textm);
        textView6 = (TextView) findViewById(R.id.quiz_percent_textm);
        aSwitch1 = (Switch) findViewById(R.id.activity_switch_redm);
        aSwitch2 = (Switch) findViewById(R.id.assignment_switch_redm);
        aSwitch3 = (Switch) findViewById(R.id.attendance_switch_redm);
        aSwitch4 = (Switch) findViewById(R.id.exam_switch_redm);
        aSwitch5 = (Switch) findViewById(R.id.project_switch_redm);
        aSwitch6 = (Switch) findViewById(R.id.quiz_switch_redm);
        linearLayout1 = (LinearLayout) findViewById(R.id.activty_linearm);
        linearLayout1.setVisibility(View.GONE);
        linearLayout2 = (LinearLayout) findViewById(R.id.assignment_linearm);
        linearLayout2.setVisibility(View.GONE);
        linearLayout3 = (LinearLayout) findViewById(R.id.attendance_linearm);
        linearLayout3.setVisibility(View.GONE);
        linearLayout4 = (LinearLayout) findViewById(R.id.exam_linearm);
        linearLayout4.setVisibility(View.GONE);
        linearLayout5 = (LinearLayout) findViewById(R.id.project_linearm);
        linearLayout5.setVisibility(View.GONE);
        linearLayout6 = (LinearLayout) findViewById(R.id.quiz_linearm);
        linearLayout6.setVisibility(View.GONE);
        seekBar1.setKeyProgressIncrement(5);
        seekBar2.setKeyProgressIncrement(5);
        seekBar3.setKeyProgressIncrement(5);
        seekBar4.setKeyProgressIncrement(5);
        seekBar5.setKeyProgressIncrement(5);
        seekBar6.setKeyProgressIncrement(5);
        linearLayoutm.setOnClickListener(new Button.OnClickListener() {

            @Override
            public void onClick(View v) {
                Formula formula = new Formula();
                formula.setActivityPercentage(percent[0]);
                formula.setAssignmentPercentage(percent[1]);
                formula.setAttendancePercentage(percent[2]);
                formula.setExamPercentage(percent[3]);
                formula.setProjectPercentage(percent[4]);
                formula.setQuizPercentage(percent[5]);
                try {
                    formula = new FormulaServiceImpl().addFormula(formula, subject.getId(), teacher.getId());
                } catch (GradingFactorException e) {
                    e.printStackTrace();
                }
                if (formula != null) {
                    new FormulaHelper(Teacher_GradingFactor_Activity_Midterm.this).saveUser(teacher.getId() + "-midterm", formula.getId());
                    Intent intent = new Intent(Teacher_GradingFactor_Activity_Midterm.this, SubjectViewActivity.class);
                    intent.putExtra("subjectId", subject.getId());
                    startActivity(intent);
                    finish();
                } else
                    Toast.makeText(Teacher_GradingFactor_Activity_Midterm.this, "Please try again", Toast.LENGTH_SHORT).show();
            }
        });
        ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, values);
        spinnerm.setAdapter(spinnerAdapter);
        aSwitch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // do something when check is selected
                    linearLayout1.setVisibility(View.VISIBLE);
                } else {
                    // do something when unchecked
                    linearLayout1.setVisibility(View.GONE);
                }
                int x = 0;
                percent[0] = 0;
                for (int i = 0; i < percent.length; i++) x += percent[i];
                textViewm3.setText(x + "%");
                seekBar1.setProgress(0);
            }
        });
        aSwitch2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // do something when check is selected
                    linearLayout2.setVisibility(View.VISIBLE);
                } else {
                    // do something when unchecked
                    linearLayout2.setVisibility(View.GONE);
                }
                int x = 0;
                percent[1] = 0;
                for (int i = 0; i < percent.length; i++) x += percent[i];
                textViewm3.setText(x + "%");
                seekBar2.setProgress(0);
            }
        });
        aSwitch3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // do something when check is selected
                    linearLayout3.setVisibility(View.VISIBLE);
                } else {
                    // do something when unchecked
                    linearLayout3.setVisibility(View.GONE);
                }
                int x = 0;
                percent[2] = 0;
                for (int i = 0; i < percent.length; i++) x += percent[i];
                textViewm3.setText(x + "%");
                seekBar3.setProgress(0);
            }
        });
        aSwitch4.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // do something when check is selected
                    linearLayout4.setVisibility(View.VISIBLE);
                } else {
                    // do something when unchecked
                    linearLayout4.setVisibility(View.GONE);
                }
                int x = 0;
                percent[3] = 0;
                for (int i = 0; i < percent.length; i++) x += percent[i];
                textViewm3.setText(x + "%");
                seekBar4.setProgress(0);
            }
        });
        aSwitch5.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // do something when check is selected
                    linearLayout5.setVisibility(View.VISIBLE);
                } else {
                    // do something when unchecked
                    linearLayout5.setVisibility(View.GONE);
                }
                int x = 0;
                percent[4] = 0;
                for (int i = 0; i < percent.length; i++) x += percent[i];
                textViewm3.setText(x + "%");
                seekBar5.setProgress(0);
            }
        });
        aSwitch6.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // do something when check is selected
                    linearLayout6.setVisibility(View.VISIBLE);
                } else {
                    // do something when unchecked
                    linearLayout6.setVisibility(View.GONE);
                }
                int x = 0;
                percent[5] = 0;
                for (int i = 0; i < percent.length; i++) x += percent[i];
                textViewm3.setText(x + "%");
                seekBar6.setProgress(0);
            }
        });
        seekBar1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                int x = 0;
                for (int count = 0; count < percent.length; count++) {
                    if (count == 0)
                        continue;
                    x += percent[count];
                }
                if ((x + i) <= 100) {
                    percent[0] = i;
                    textView1.setText(i + "");
                    ;
                    textViewm3.setText(x + percent[0] + "%");
                } else if ((x + i) > 100) {
                    percent[0] = 100 - x;
                    textView1.setText(percent[0] + "");
                    ;
                    textViewm3.setText((x + percent[0]) + "%");
                    seekBar.setProgress(percent[0]);
                } else
                    percent[0] = 0;
            }

            @Override
            public void onStartTrackingTouch(SeekBar bar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar bar) {
            }
        });
        seekBar2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                int x = 0;
                for (int count = 0; count < percent.length; count++) {
                    if (count == 1)
                        continue;
                    x += percent[count];
                }
                if ((x + i) <= 100) {
                    percent[1] = i;
                    textView2.setText(i + "");
                    ;
                    textViewm3.setText(x + percent[1] + "%");
                } else if ((x + i) > 100) {
                    percent[1] = 100 - x;
                    textView2.setText(percent[1] + "");
                    ;
                    textViewm3.setText((x + percent[1]) + "%");
                    seekBar.setProgress(percent[1]);
                } else
                    percent[1] = 0;
            }

            @Override
            public void onStartTrackingTouch(SeekBar bar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar bar) {
            }
        });
        seekBar3.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                int x = 0;
                for (int count = 0; count < percent.length; count++) {
                    if (count == 2)
                        continue;
                    x += percent[count];
                }
                if ((x + i) <= 100) {
                    percent[2] = i;
                    textView3.setText(i + "");
                    ;
                    textViewm3.setText(x + percent[2] + "%");
                } else if ((x + i) > 100) {
                    percent[2] = 100 - x;
                    textView3.setText(percent[2] + "");
                    ;
                    textViewm3.setText((x + percent[2]) + "%");
                    seekBar.setProgress(percent[2]);
                } else
                    percent[2] = 0;
            }

            @Override
            public void onStartTrackingTouch(SeekBar bar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar bar) {
            }
        });
        seekBar4.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                int x = 0;
                for (int count = 0; count < percent.length; count++) {
                    if (count == 3)
                        continue;
                    x += percent[count];
                }
                if ((x + i) <= 100) {
                    percent[3] = i;
                    textView4.setText(i + "");
                    ;
                    textViewm3.setText(x + percent[3] + "%");
                } else if ((x + i) > 100) {
                    percent[3] = 100 - x;
                    textView4.setText(percent[3] + "");
                    ;
                    textViewm3.setText((x + percent[3]) + "%");
                    seekBar.setProgress(percent[3]);
                } else
                    percent[3] = 0;
            }

            @Override
            public void onStartTrackingTouch(SeekBar bar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar bar) {
            }
        });
        seekBar5.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                int x = 0;
                for (int count = 0; count < percent.length; count++) {
                    if (count == 4)
                        continue;
                    x += percent[count];
                }
                if ((x + i) <= 100) {
                    percent[4] = i;
                    textView5.setText(i + "");
                    ;
                    textViewm3.setText(x + percent[4] + "%");
                } else if ((x + i) > 100) {
                    percent[4] = 100 - x;
                    textView5.setText(percent[4] + "");
                    ;
                    textViewm3.setText((x + percent[4]) + "%");
                    seekBar.setProgress(percent[4]);
                } else
                    percent[4] = 0;
            }

            @Override
            public void onStartTrackingTouch(SeekBar bar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar bar) {
            }
        });
        seekBar6.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                int x = 0;
                for (int count = 0; count < percent.length; count++) {
                    if (count == 5)
                        continue;
                    x += percent[count];
                }
                if ((x + i) <= 100) {
                    percent[5] = i;
                    textView6.setText(i + "");
                    ;
                    textViewm3.setText(x + percent[5] + "%");
                } else if ((x + i) > 100) {
                    percent[5] = 100 - x;
                    textView6.setText(percent[5] + "");
                    ;
                    textViewm3.setText((x + percent[5]) + "%");
                    seekBar.setProgress(percent[5]);
                } else
                    percent[5] = 0;
            }

            @Override
            public void onStartTrackingTouch(SeekBar bar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar bar) {
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : SeekBar(android.widget.SeekBar) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) Teacher(com.remswork.project.alice.model.Teacher) Intent(android.content.Intent) FormulaHelper(com.lieverandiver.thesisproject.helper.FormulaHelper) TextView(android.widget.TextView) View(android.view.View) Subject(com.remswork.project.alice.model.Subject) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) Formula(com.remswork.project.alice.model.Formula) CompoundButton(android.widget.CompoundButton) Button(android.widget.Button) SubjectServiceImpl(com.remswork.project.alice.service.impl.SubjectServiceImpl) TeacherHelper(com.lieverandiver.thesisproject.helper.TeacherHelper) FormulaServiceImpl(com.remswork.project.alice.service.impl.FormulaServiceImpl) ArrayAdapter(android.widget.ArrayAdapter) CompoundButton(android.widget.CompoundButton)

Example 10 with Formula

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

the class FormulaServiceImpl method getFormulaList.

@Override
public List<Formula> getFormulaList() throws GradingFactorException {
    final List<Formula> formulaList = new ArrayList<>();
    try {
        return new AsyncTask<String, List<Formula>, List<Formula>>() {

            @Override
            protected List<Formula> doInBackground(String... args) {
                try {
                    String link = "".concat(domain).concat("/").concat(baseUri).concat("/").concat(payload);
                    URL url = new URL(link);
                    Gson gson = new Gson();
                    HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
                    httpURLConnection.setRequestMethod("GET");
                    httpURLConnection.setRequestProperty("Content-Type", "application/json");
                    httpURLConnection.setRequestProperty("Accept", "application/json");
                    httpURLConnection.connect();
                    if (httpURLConnection.getResponseCode() == 200) {
                        InputStream inputStream = httpURLConnection.getInputStream();
                        String jsonData = "";
                        int data;
                        while ((data = inputStream.read()) != -1) {
                            jsonData += (char) data;
                        }
                        JSONArray jsonArray = new JSONArray(jsonData);
                        for (int ctr = 0; ctr < jsonArray.length(); ctr++) {
                            formulaList.add(gson.fromJson(jsonArray.get(ctr).toString(), Formula.class));
                        }
                        return formulaList;
                    } else if (httpURLConnection.getResponseCode() == 404) {
                        InputStream inputStream = httpURLConnection.getInputStream();
                        String jsonData = "";
                        int data;
                        while ((data = inputStream.read()) != -1) {
                            jsonData += (char) data;
                        }
                        Message message = gson.fromJson(jsonData, Message.class);
                        Log.i("ServiceTAG", "Service : Formula");
                        Log.i("ServiceTAG", "Status : " + message.getStatus());
                        Log.i("ServiceTAG", "Type : " + message.getType());
                        Log.i("ServiceTAG", "Message : " + message.getMessage());
                        return formulaList;
                    } else
                        throw new GradingFactorException("Server Error");
                } catch (GradingFactorException e) {
                    e.printStackTrace();
                    return null;
                } catch (IOException e) {
                    e.printStackTrace();
                    return null;
                } catch (JSONException e) {
                    e.printStackTrace();
                    return null;
                }
            }
        }.execute((String) null).get();
    } catch (InterruptedException e) {
        e.printStackTrace();
        return null;
    } catch (ExecutionException e) {
        e.printStackTrace();
        return null;
    }
}
Also used : Message(com.remswork.project.alice.model.support.Message) InputStream(java.io.InputStream) GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) ArrayList(java.util.ArrayList) AsyncTask(android.os.AsyncTask) JSONArray(org.json.JSONArray) Gson(com.google.gson.Gson) JSONException(org.json.JSONException) IOException(java.io.IOException) URL(java.net.URL) Formula(com.remswork.project.alice.model.Formula) HttpURLConnection(java.net.HttpURLConnection) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

Formula (com.remswork.project.alice.model.Formula)25 GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)19 FormulaServiceImpl (com.remswork.project.alice.service.impl.FormulaServiceImpl)10 Message (com.remswork.project.alice.model.support.Message)7 GradingFactorDaoException (com.remswork.project.alice.dao.exception.GradingFactorDaoException)6 Class (com.remswork.project.alice.model.Class)6 Grade (com.remswork.project.alice.model.Grade)6 Student (com.remswork.project.alice.model.Student)6 FormulaService (com.remswork.project.alice.service.FormulaService)6 GradeService (com.remswork.project.alice.service.GradeService)6 GradeServiceImpl (com.remswork.project.alice.service.impl.GradeServiceImpl)6 FormulaResourceLinks (com.remswork.project.alice.resource.links.FormulaResourceLinks)5 SubjectResourceLinks (com.remswork.project.alice.resource.links.SubjectResourceLinks)5 TeacherResourceLinks (com.remswork.project.alice.resource.links.TeacherResourceLinks)5 ArrayList (java.util.ArrayList)5 Session (org.hibernate.Session)5 View (android.view.View)4 TextView (android.widget.TextView)4 CompoundButton (android.widget.CompoundButton)3 Subject (com.remswork.project.alice.model.Subject)3