def execute(filters=None):
    if not filters: filters = {}

    from_date = get_first_day(filters["month"] + '-' + filters["year"])
    to_date = get_last_day(filters["month"] + '-' + filters["year"])
    total_days_in_month = date_diff(to_date, from_date) + 1
    columns = get_columns(total_days_in_month)
    students = get_student_group_students(filters.get("student_group"))
    students_list = get_students_list(students)
    att_map = get_attendance_list(from_date, to_date,
                                  filters.get("student_group"), students_list)
    data = []
    for stud in students:
        row = [stud.student, stud.student_name]
        date = from_date
        total_p = total_a = 0.0
        for day in range(total_days_in_month):
            status = "None"
            if att_map.get(stud.student):
                status = att_map.get(stud.student).get(date, "None")
            status_map = {"Present": "P", "Absent": "A", "None": ""}
            row.append(status_map[status])
            if status == "Present":
                total_p += 1
            elif status == "Absent":
                total_a += 1
            date = add_days(date, 1)
        row += [total_p, total_a]
        data.append(row)
    return columns, data
def execute(filters=None):
	if not filters: filters = {}

	from_date = get_first_day(filters["month"] + '-' + filters["year"])
	to_date = get_last_day(filters["month"] + '-' + filters["year"])
	total_days_in_month = date_diff(to_date, from_date) +1
	columns = get_columns(total_days_in_month)
	students = get_student_group_students(filters.get("student_group"),1)
	students_list = get_students_list(students)
	att_map = get_attendance_list(from_date, to_date, filters.get("student_group"), students_list)
	data = []
	for stud in students:
		row = [stud.student, stud.student_name]
		student_status = frappe.db.get_value("Student", stud.student, "enabled")
		date = from_date
		total_p = total_a = 0.0
		for day in range(total_days_in_month):
			status="None"
			if att_map.get(stud.student):
				status = att_map.get(stud.student).get(date, "None")
			elif not student_status:
				status = "Inactive"
			else:
				status = "None"
			status_map = {"Present": "P", "Absent": "A", "None": "", "Inactive":"-"}
			row.append(status_map[status])
			if status == "Present":
				total_p += 1
			elif status == "Absent":
				total_a += 1
			date = add_days(date, 1)
		row += [total_p, total_a]
		data.append(row)
	return columns, data
예제 #3
0
	def validate_student(self):
		if self.course_schedule:
			student_group = frappe.db.get_value("Course Schedule", self.course_schedule, "student_group")
		else:
			student_group = self.student_group
		student_group_students = [d.student for d in get_student_group_students(student_group)]
		if student_group and self.student not in student_group_students:
			frappe.throw(_('''Student {0}: {1} does not belong to Student Group {2}'''.format(self.student, self.student_name, student_group)))
예제 #4
0
def mark_student_attendance(current_date):
    status = ["Present", "Absent"]
    for d in frappe.db.get_list("Student Group",
                                filters={"group_based_on": "Batch"}):
        students = get_student_group_students(d.name)
        for stud in students:
            make_attendance_records(stud.student, stud.student_name,
                                    status[weighted_choice([9, 4])], None,
                                    d.name, current_date)
예제 #5
0
def mark_student_attendance(current_date):
    status = ["Present", "Absent"]
    for d in frappe.db.get_list("Course Schedule",
                                filters={"schedule_date": current_date},
                                fields=("name", "student_group")):
        students = get_student_group_students(d.student_group)
        for stud in students:
            make_attendance_records(stud.student, stud.student_name, d.name,
                                    status[weighted_choice([9, 4])])
예제 #6
0
	def validate_student(self):
		if self.course_schedule:
			student_group = frappe.db.get_value("Course Schedule", self.course_schedule, "student_group")
			student_group_students = []
			for d in get_student_group_students(student_group):
				student_group_students.append(d.student)
			if student_group and self.student not in student_group_students:
				frappe.throw(_("""Student {0}: {1} does not belong to Student Group {2}""".format(self.student, self.student_name, student_group)))
		else:
			student_batch_students = []
			for d in get_student_batch_students(self.student_batch):
				student_batch_students.append(d.student)
			if self.student not in student_batch_students:
				frappe.throw(_("""Student {0}: {1} does not belong to Student Batch {2}""".format(self.student, self.student_name, self.student_batch)))
예제 #7
0
def mark_student_attendance(current_date):
	status = ["Present", "Absent"]
	for d in frappe.db.get_list("Student Group", filters={"group_based_on": "Batch"}):
		students = get_student_group_students(d.name)
		for stud in students:
			make_attendance_records(stud.student, stud.student_name, status[weighted_choice([9,4])], None, d.name, current_date)
예제 #8
0
def mark_student_attendance(current_date):
	status = ["Present", "Absent"]
	for d in frappe.db.get_list("Course Schedule", filters={"schedule_date": current_date}, fields=("name", "student_group")):
		students = get_student_group_students(d.student_group)
		for stud in students:
			make_attendance_records(stud.student, stud.student_name, d.name, status[weighted_choice([9,4])])