Student group creation (#10308)
* auto-fills groups with students * improvised and rectified tests * increased timer to avoid rare failures * removed duplicate code * requested changes implemented * changes implemented
This commit is contained in:
parent
3a4b6c2cba
commit
40343da1b0
@ -68,7 +68,8 @@ def get_students(academic_year, group_based_on, academic_term=None, program=None
|
||||
student_list.append(s)
|
||||
return student_list
|
||||
else:
|
||||
frappe.throw(_("No students found"))
|
||||
frappe.msgprint(_("No students found"))
|
||||
return []
|
||||
|
||||
def get_program_enrollment(academic_year, academic_term=None, program=None, batch=None, course=None):
|
||||
|
||||
|
@ -5,50 +5,59 @@ QUnit.test('Test: Student Group', function(assert){
|
||||
assert.expect(2);
|
||||
let done = assert.async();
|
||||
let instructor_code;
|
||||
let loop = ["test-batch-wise-group", "test-course-wise-group"];
|
||||
let group_based_on = ["test-batch-wise-group", "test-course-wise-group"];
|
||||
let tasks = [];
|
||||
|
||||
frappe.run_serially([
|
||||
// Saving Instructor code beforehand
|
||||
() => frappe.set_route('List', 'Instructor'),
|
||||
() => frappe.timeout(0.5),
|
||||
() => frappe.tests.click_link('Instructor 1'),
|
||||
() => frappe.timeout(0.5),
|
||||
() => {instructor_code = frappe.get_route()[2];},
|
||||
() => frappe.db.get_value('Instructor', {'instructor_name': 'Instructor 1'}, 'name'),
|
||||
(instructor) => {instructor_code = instructor.message.name;},
|
||||
|
||||
// Creating a Batch and Course based group
|
||||
() => {
|
||||
loop.forEach(index => {
|
||||
tasks.push(() => {
|
||||
return frappe.tests.make('Student Group', [
|
||||
{academic_year: '2016-17'},
|
||||
{academic_term: '2016-17 (Semester 1)'},
|
||||
{program: "Standard Test"},
|
||||
{group_based_on: 'Batch'},
|
||||
{student_group_name: index},
|
||||
{max_strength: 10},
|
||||
{batch: 'A'},
|
||||
{instructors: [
|
||||
[
|
||||
{instructor: instructor_code}
|
||||
]
|
||||
]}
|
||||
]);
|
||||
});
|
||||
});
|
||||
return frappe.run_serially(tasks);
|
||||
return frappe.tests.make('Student Group', [
|
||||
{academic_year: '2016-17'},
|
||||
{academic_term: '2016-17 (Semester 1)'},
|
||||
{program: "Standard Test"},
|
||||
{group_based_on: 'Batch'},
|
||||
{student_group_name: group_based_on[0]},
|
||||
{max_strength: 10},
|
||||
{batch: 'A'},
|
||||
{instructors: [
|
||||
[
|
||||
{instructor: instructor_code}
|
||||
]
|
||||
]}
|
||||
]);
|
||||
},
|
||||
() => {
|
||||
return frappe.tests.make('Student Group', [
|
||||
{academic_year: '2016-17'},
|
||||
{academic_term: '2016-17 (Semester 1)'},
|
||||
{program: "Standard Test"},
|
||||
{group_based_on: 'Course'},
|
||||
{student_group_name: group_based_on[1]},
|
||||
{max_strength: 10},
|
||||
{batch: 'A'},
|
||||
{course: 'Test_Sub'},
|
||||
{instructors: [
|
||||
[
|
||||
{instructor: instructor_code}
|
||||
]
|
||||
]}
|
||||
]);
|
||||
},
|
||||
|
||||
// Populating the created group with Students
|
||||
() => {
|
||||
tasks = [];
|
||||
loop.forEach(index => {
|
||||
group_based_on.forEach(index => {
|
||||
tasks.push(
|
||||
() => frappe.timeout(0.3),
|
||||
() => frappe.timeout(0.5),
|
||||
() => frappe.set_route("Form", ('Student Group/' + index)),
|
||||
() => frappe.timeout(0.3),
|
||||
() => frappe.timeout(0.5),
|
||||
() => frappe.tests.click_button('Get Students'),
|
||||
() => frappe.timeout(0.2),
|
||||
() => frappe.timeout(0.5),
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.students.length, 5, 'Successfully fetched list of students');
|
||||
},
|
||||
|
@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from erpnext.schools.doctype.student_group.student_group import get_students
|
||||
|
||||
class StudentGroupCreationTool(Document):
|
||||
def get_courses(self):
|
||||
@ -67,6 +68,10 @@ class StudentGroupCreationTool(Document):
|
||||
student_group.max_strength = d.max_strength
|
||||
student_group.academic_term = self.academic_term
|
||||
student_group.academic_year = self.academic_year
|
||||
student_list = get_students(self.academic_year, d.group_based_on, self.academic_term, self.program, d.batch, d.course)
|
||||
|
||||
for student in student_list:
|
||||
student_group.append('students', student)
|
||||
student_group.save()
|
||||
|
||||
frappe.msgprint(_("{0} Student Groups created.".format(l)))
|
||||
frappe.msgprint(_("{0} Student Groups created.".format(l)))
|
@ -7,11 +7,8 @@ QUnit.test('Test: Student Group Creation Tool', function(assert){
|
||||
|
||||
frappe.run_serially([
|
||||
// Saving Instructor code beforehand
|
||||
() => frappe.set_route('List', 'Instructor'),
|
||||
() => frappe.timeout(0.5),
|
||||
() => frappe.tests.click_link('Instructor 1'),
|
||||
() => frappe.timeout(0.5),
|
||||
() => {instructor_code = frappe.get_route()[2];},
|
||||
() => frappe.db.get_value('Instructor', {'instructor_name': 'Instructor 1'}, 'name'),
|
||||
(instructor) => {instructor_code = instructor.message.name;},
|
||||
|
||||
// Setting up the creation tool to generate and save Student Group
|
||||
() => frappe.set_route('Form', 'Student Group Creation Tool'),
|
||||
@ -57,15 +54,13 @@ QUnit.test('Test: Student Group Creation Tool', function(assert){
|
||||
|
||||
// Goin to the generated group to set up student and instructor list
|
||||
() => {
|
||||
let loop = ['Student Group/test-batch-wise-group-2', 'Student Group/test-course-wise-group-2'];
|
||||
let group_name = ['Student Group/test-batch-wise-group-2', 'Student Group/test-course-wise-group-2'];
|
||||
let tasks = [];
|
||||
loop.forEach(index => {
|
||||
group_name.forEach(index => {
|
||||
tasks.push(
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.set_route("Form", index),
|
||||
() => frappe.timeout(0.5),
|
||||
() => frappe.tests.click_button("Get Students"),
|
||||
() => frappe.timeout(0.5),
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.students.length, 5, 'Successfully fetched list of students');
|
||||
},
|
||||
|
@ -6,11 +6,8 @@ QUnit.test('Test: Student Log', function(assert){
|
||||
let done = assert.async();
|
||||
let student_code;
|
||||
frappe.run_serially([
|
||||
() => frappe.set_route("List", "Student"),
|
||||
() => frappe.timeout(0.5),
|
||||
() => frappe.tests.click_link('Fname Mname Lname'),
|
||||
() => frappe.timeout(0.5),
|
||||
() => {student_code = frappe.get_route()[2];},
|
||||
() => frappe.db.get_value('Student', {'student_email_id': 'test2@testmail.com'}, 'name'),
|
||||
(student) => {student_code = student.message.name;},
|
||||
() => {
|
||||
return frappe.tests.make("Student Log", [
|
||||
{student: student_code},
|
||||
|
Loading…
x
Reference in New Issue
Block a user