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)
|
student_list.append(s)
|
||||||
return student_list
|
return student_list
|
||||||
else:
|
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):
|
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);
|
assert.expect(2);
|
||||||
let done = assert.async();
|
let done = assert.async();
|
||||||
let instructor_code;
|
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 = [];
|
let tasks = [];
|
||||||
|
|
||||||
frappe.run_serially([
|
frappe.run_serially([
|
||||||
// Saving Instructor code beforehand
|
// Saving Instructor code beforehand
|
||||||
() => frappe.set_route('List', 'Instructor'),
|
() => frappe.db.get_value('Instructor', {'instructor_name': 'Instructor 1'}, 'name'),
|
||||||
() => frappe.timeout(0.5),
|
(instructor) => {instructor_code = instructor.message.name;},
|
||||||
() => frappe.tests.click_link('Instructor 1'),
|
|
||||||
() => frappe.timeout(0.5),
|
|
||||||
() => {instructor_code = frappe.get_route()[2];},
|
|
||||||
|
|
||||||
// Creating a Batch and Course based group
|
// Creating a Batch and Course based group
|
||||||
() => {
|
() => {
|
||||||
loop.forEach(index => {
|
return frappe.tests.make('Student Group', [
|
||||||
tasks.push(() => {
|
{academic_year: '2016-17'},
|
||||||
return frappe.tests.make('Student Group', [
|
{academic_term: '2016-17 (Semester 1)'},
|
||||||
{academic_year: '2016-17'},
|
{program: "Standard Test"},
|
||||||
{academic_term: '2016-17 (Semester 1)'},
|
{group_based_on: 'Batch'},
|
||||||
{program: "Standard Test"},
|
{student_group_name: group_based_on[0]},
|
||||||
{group_based_on: 'Batch'},
|
{max_strength: 10},
|
||||||
{student_group_name: index},
|
{batch: 'A'},
|
||||||
{max_strength: 10},
|
{instructors: [
|
||||||
{batch: 'A'},
|
[
|
||||||
{instructors: [
|
{instructor: instructor_code}
|
||||||
[
|
]
|
||||||
{instructor: instructor_code}
|
]}
|
||||||
]
|
]);
|
||||||
]}
|
},
|
||||||
]);
|
() => {
|
||||||
});
|
return frappe.tests.make('Student Group', [
|
||||||
});
|
{academic_year: '2016-17'},
|
||||||
return frappe.run_serially(tasks);
|
{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
|
// Populating the created group with Students
|
||||||
() => {
|
() => {
|
||||||
tasks = [];
|
tasks = [];
|
||||||
loop.forEach(index => {
|
group_based_on.forEach(index => {
|
||||||
tasks.push(
|
tasks.push(
|
||||||
() => frappe.timeout(0.3),
|
() => frappe.timeout(0.5),
|
||||||
() => frappe.set_route("Form", ('Student Group/' + index)),
|
() => frappe.set_route("Form", ('Student Group/' + index)),
|
||||||
() => frappe.timeout(0.3),
|
() => frappe.timeout(0.5),
|
||||||
() => frappe.tests.click_button('Get Students'),
|
() => 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');
|
assert.equal(cur_frm.doc.students.length, 5, 'Successfully fetched list of students');
|
||||||
},
|
},
|
||||||
|
@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from erpnext.schools.doctype.student_group.student_group import get_students
|
||||||
|
|
||||||
class StudentGroupCreationTool(Document):
|
class StudentGroupCreationTool(Document):
|
||||||
def get_courses(self):
|
def get_courses(self):
|
||||||
@ -67,6 +68,10 @@ class StudentGroupCreationTool(Document):
|
|||||||
student_group.max_strength = d.max_strength
|
student_group.max_strength = d.max_strength
|
||||||
student_group.academic_term = self.academic_term
|
student_group.academic_term = self.academic_term
|
||||||
student_group.academic_year = self.academic_year
|
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()
|
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([
|
frappe.run_serially([
|
||||||
// Saving Instructor code beforehand
|
// Saving Instructor code beforehand
|
||||||
() => frappe.set_route('List', 'Instructor'),
|
() => frappe.db.get_value('Instructor', {'instructor_name': 'Instructor 1'}, 'name'),
|
||||||
() => frappe.timeout(0.5),
|
(instructor) => {instructor_code = instructor.message.name;},
|
||||||
() => frappe.tests.click_link('Instructor 1'),
|
|
||||||
() => frappe.timeout(0.5),
|
|
||||||
() => {instructor_code = frappe.get_route()[2];},
|
|
||||||
|
|
||||||
// Setting up the creation tool to generate and save Student Group
|
// Setting up the creation tool to generate and save Student Group
|
||||||
() => frappe.set_route('Form', 'Student Group Creation Tool'),
|
() => 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
|
// 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 = [];
|
let tasks = [];
|
||||||
loop.forEach(index => {
|
group_name.forEach(index => {
|
||||||
tasks.push(
|
tasks.push(
|
||||||
() => frappe.timeout(1),
|
() => frappe.timeout(1),
|
||||||
() => frappe.set_route("Form", index),
|
() => frappe.set_route("Form", index),
|
||||||
() => frappe.timeout(0.5),
|
() => 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');
|
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 done = assert.async();
|
||||||
let student_code;
|
let student_code;
|
||||||
frappe.run_serially([
|
frappe.run_serially([
|
||||||
() => frappe.set_route("List", "Student"),
|
() => frappe.db.get_value('Student', {'student_email_id': 'test2@testmail.com'}, 'name'),
|
||||||
() => frappe.timeout(0.5),
|
(student) => {student_code = student.message.name;},
|
||||||
() => frappe.tests.click_link('Fname Mname Lname'),
|
|
||||||
() => frappe.timeout(0.5),
|
|
||||||
() => {student_code = frappe.get_route()[2];},
|
|
||||||
() => {
|
() => {
|
||||||
return frappe.tests.make("Student Log", [
|
return frappe.tests.make("Student Log", [
|
||||||
{student: student_code},
|
{student: student_code},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user