Skip to content

Commit

Permalink
Merge pull request #238 from Rajan-SCS/16_mig_exam
Browse files Browse the repository at this point in the history
[16.0] [MIG] Exam
  • Loading branch information
AnuKPatel authored Feb 3, 2023
2 parents 21116da + 59d8092 commit bf695d1
Show file tree
Hide file tree
Showing 15 changed files with 146 additions and 740 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Build Status](https://travis-ci.org/JayVora-SerpentCS/OdooEduERP.svg?branch=14.0)](https://travis-ci.org/JayVora-SerpentCS/OdooEduERP)
[![Build Status](https://travis-ci.org/JayVora-SerpentCS/OdooEduERP.svg?branch=16.0)](https://travis-ci.org/JayVora-SerpentCS/OdooEduERP)

# EduERPv14
Education ERP v14
# EduERPv16
Education ERP v16
Serpent Consulting Services Pvt Ltd, the Official Odoo GOLD partner has here contributed the Education ERP.

Help us do better by donating to us and motivating us : http://www.serpentcs.com/page/donate-to-serpentcs
Expand Down
68 changes: 31 additions & 37 deletions exam/models/exam.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def check_teacher_room(self):
and rec.table_id.timetable_type == "exam"
and rec.class_room_id == record.class_room_id
and rec.start_time == record.start_time
and rec.exm_date == record.exm_date
):
raise ValidationError(_("The room is occupied!"))

Expand Down Expand Up @@ -280,9 +281,7 @@ def check_active(self):
"Active", default="True", help="Activate/Deactivate record"
)
name = fields.Char("Exam Name", required=True, help="Name of Exam")
exam_code = fields.Char(
"Exam Code", required=True, readonly=True, help="Code of exam"
)
exam_code = fields.Char("Exam Code", readonly=True, help="Code of exam")
standard_id = fields.Many2many(
"standard.standard",
"standard_standard_exam_rel",
Expand Down Expand Up @@ -449,7 +448,7 @@ def _compute_color_name(self):
"Additional Exam Name", required=True, help="Name of Exam"
)
addtional_exam_code = fields.Char(
"Exam Code", required=True, help="Exam Code", readonly=True
"Exam Code", help="Exam Code", readonly=True
)
standard_id = fields.Many2one(
"school.standard", "Standard", help="Select standard for exam"
Expand Down Expand Up @@ -597,7 +596,6 @@ def _compute_result(self):
("confirm", "Confirm"),
("re-evaluation", "Re-Evaluation"),
("re-evaluation_confirm", "Re-Evaluation Confirm"),
("done", "Done"),
],
"State",
readonly=True,
Expand Down Expand Up @@ -690,30 +688,6 @@ def result_re_evaluation(self):
line.marks_reeval = line.obtain_marks
rec.state = "re-evaluation"

def set_done(self):
"""Method to obtain history of student"""
history_obj = self.env["student.history"]
for rec in self:
vals = {
"student_id": rec.student_id.id,
"academice_year_id": rec.student_id.year.id,
"standard_id": rec.standard_id.id,
"percentage": rec.percentage,
"result": rec.result,
}
history_rec = history_obj.search(
[
("student_id", "=", rec.student_id.id),
("academice_year_id", "=", rec.student_id.year.id),
("standard_id", "=", rec.standard_id.id),
]
)
if history_rec:
history_obj.write(vals)
elif not history_rec:
history_obj.create(vals)
rec.state = "done"


class ExamGradeLine(models.Model):
"""Defining model for Exam Grade Line."""
Expand Down Expand Up @@ -745,13 +719,22 @@ def _compute_grade(self):
if rec.exam_id and rec.exam_id.student_id and grade_lines:
for grade_id in grade_lines:
b_id = rec.obtain_marks <= grade_id.to_mark
if rec.obtain_marks > 0:
if rec.obtain_marks >= grade_id.from_mark and b_id:
rec.grade_line_id = grade_id
if rec.marks_reeval and rec.obtain_marks >= 0.0:
r_id = rec.marks_reeval <= grade_id.to_mark
if rec.marks_reeval >= grade_id.from_mark and r_id:
if rec.state not in [
"re-evaluation",
"re-evaluation_confirm",
]:
if (
rec.obtain_marks >= 0
and rec.obtain_marks >= grade_id.from_mark
and b_id
):
rec.grade_line_id = grade_id
else:
if (rec.marks_reeval and rec.obtain_marks >= 0.0) and (
rec.marks_reeval >= grade_id.from_mark
and rec.marks_reeval <= grade_id.to_mark
):
rec.grade_line_id = grade_id.id

exam_id = fields.Many2one("exam.result", "Result", help="Select exam")
state = fields.Selection(
Expand Down Expand Up @@ -830,7 +813,11 @@ def _compute_student_result(self):
)
roll_no = fields.Integer("Roll No", readonly=True, help="Student rol no.")
standard_id = fields.Many2one(
"school.standard", "Standard", readonly=True, help="School Standard"
"school.standard",
"Standard",
related="a_exam_id.standard_id",
store=True,
help="School Standard",
)
obtain_marks = fields.Float("Obtain Marks", help="Marks obtain in exam")
result = fields.Char(
Expand All @@ -843,6 +830,14 @@ def _compute_student_result(self):
"Active", default=True, help="Activate/Deactivate record"
)

_sql_constraints = [
(
"additional_exam_result_unique",
"unique(a_exam_id,student_id)",
"Student is not repeated in same exam!",
)
]

def _update_student_vals(self, vals):
"""This is the common method to update student
record at creation and updation of the exam record"""
Expand Down Expand Up @@ -872,7 +867,6 @@ def write(self, vals):
@api.onchange("student_id")
def onchange_student(self):
""" Method to get student roll no and standard by selecting student"""
self.standard_id = self.student_id.standard_id.id
self.roll_no = self.student_id.roll_no

@api.constrains("obtain_marks")
Expand Down
46 changes: 0 additions & 46 deletions exam/report/add_exam_result.py

This file was deleted.

6 changes: 3 additions & 3 deletions exam/report/additional_exam_report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<b>Subject Name</b>
</td>
<td align="center" style="font-family: 'Helvetica';font-size: 18px;border: 2px solid black;">
<b>Maximum marks</b>
<b>Maximum Marks</b>
</td>
<td align="center" style="font-family: 'Helvetica';font-size: 18px;border: 2px solid black;">
<b>Minimum Marks</b>
Expand All @@ -94,10 +94,10 @@
<span t-field="result.a_exam_id.subject_id.name"></span>
</td>
<td align="center" style="font-family: 'Helvetica';font-size: 16px;border: 2px solid black;">
<span t-field="result.a_exam_id.subject_id.maximum_marks"></span>
<span t-field="result.a_exam_id.maximum_marks"></span>
</td>
<td align="center" style="font-family: 'Helvetica';font-size: 16px;border: 2px solid black;">
<span t-field="result.a_exam_id.subject_id.minimum_marks"></span>
<span t-field="result.a_exam_id.minimum_marks"></span>
</td>
<td align="center" style="font-family: 'Helvetica';font-size: 16px;border: 2px solid black;">
<span t-field="result.obtain_marks"></span>
Expand Down
33 changes: 16 additions & 17 deletions exam/report/batch_result_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,38 @@ def pass_student(self, year, standard_id):
("state", "=", "finished"),
]
)
exam_result_rec = exam_result_pass_rec = exam_result_fail_rec = []
result_obj = self.env["exam.result"]
for rec in exam_rec:
exam_result_rec = result_obj.search(
exam_result_rec += result_obj.search(
[("s_exam_ids", "=", rec.id), ("state", "!=", "draft")]
)
exam_result_pass_rec = result_obj.search(
exam_result_pass_rec += result_obj.search(
[
("s_exam_ids", "=", rec.id),
("result", "=", "Pass"),
("state", "!=", "draft"),
]
)
exam_result_fail_rec = result_obj.search(
exam_result_fail_rec += result_obj.search(
[
("s_exam_ids", "=", rec.id),
("result", "=", "Fail"),
("state", "!=", "draft"),
]
)
std_pass = ""
if len(exam_result_pass_rec.ids) > 0:
# Calculate percentage of students who pass the exams
std_pass = (100 * len(exam_result_pass_rec.ids)) / len(
exam_result_rec.ids
)
return [
{
"student_appear": len(exam_result_rec.ids) or 0.0,
"studnets": len(exam_result_pass_rec.ids) or 0.0,
"pass_std": std_pass or 0.0,
"fail_student": len(exam_result_fail_rec.ids) or 0.0,
}
]
std_pass = ""
if len(exam_result_pass_rec) > 0:
# Calculate percentage of students who pass the exams
std_pass = (100 * len(exam_result_pass_rec)) / len(exam_result_rec)
return [
{
"student_appear": len(exam_result_rec) or 0.0,
"studnets": len(exam_result_pass_rec) or 0.0,
"pass_std": std_pass or 0.0,
"fail_student": len(exam_result_fail_rec) or 0.0,
}
]

@api.model
def _get_report_values(self, docids, data=None):
Expand Down
30 changes: 4 additions & 26 deletions exam/report/result_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,22 @@ def get_lines(self, result_id, student):
list_result = []
for sub_id in result_id:
for sub in sub_id.result_ids:
obtain_mark = sub.obtain_marks
if sub_id.state in ["re-evaluation", "re-evaluation_confirm"]:
obtain_mark = sub.marks_reeval
list_result.append(
{
"standard_id": sub_id.standard_id.standard_id.name,
"name": sub.subject_id.name,
"code": sub.subject_id.code,
"maximum_marks": sub.maximum_marks,
"minimum_marks": sub.minimum_marks,
"obtain_marks": sub.obtain_marks,
"obtain_marks": obtain_mark,
"s_exam_ids": sub_id.s_exam_ids.name,
}
)
return list_result

@api.model
def get_exam_data(self, result_id, student):
"""Method to get the exam info of student"""
list_exam = []
value = {}
final_total = 0
per = 0.0
obtain_marks = 0.0
maximum_marks = 0.0
for res in result_id:
obtain_marks = float(
sum(res_data.obtain_marks for res_data in res.result_ids)
)
maximum_marks = float(
sum(res_data.obtain_marks for res_data in res.result_ids)
)
per += obtain_marks * 100 / maximum_marks
final_total = final_total + res.total
value.update(
{"result": res.result, "percentage": per, "total": final_total}
)
list_exam.append(value)
return list_exam

@api.model
def _get_report_values(self, docids, data=None):
"""Inherited method to get report values"""
Expand All @@ -86,5 +65,4 @@ def _get_report_values(self, docids, data=None):
"data": data,
"docs": docs,
"get_lines": self.get_lines,
"get_exam_data": self.get_exam_data,
}
Loading

0 comments on commit bf695d1

Please sign in to comment.