Exemple #1
0
def addclass():
    class_info = json.loads(request.data)
    cohort_name = (class_info.get("cohort")).get("name")
    teacher_id = session['user']
    cohort_id = api.add_new_cohort(cohort_name, teacher_id)
    list_of_students = class_info.get("students")
    for student in list_of_students:
        user_type = "student"
        first_name = student.get("first_name")
        last_name = student.get("last_name")
        student_id = api.create_student(user_type, first_name, last_name)
        api.add_student_to_cohort(student_id, cohort_id)
    return "Success"
Exemple #2
0
def addclass():
    class_info = json.loads(request.data)
    cohort_name = (class_info.get("cohort")).get("name")
    teacher_id = session['user']
    cohort_id = api.add_new_cohort(cohort_name, teacher_id)
    list_of_students = class_info.get("students")
    for student in list_of_students:
        user_type = "student"
        first_name = student.get("first_name")
        last_name = student.get("last_name")
        student_id = api.create_student(user_type, first_name, last_name)
        api.add_student_to_cohort(student_id, cohort_id)
    return "Success"
Exemple #3
0
def upload_class_file():
    if request.method == 'POST':
        csvfile = request.files['studentfile']
        if csvfile and allowed_file(csvfile.filename):
            filename = secure_filename(csvfile.filename)
            file_path = app.config['UPLOAD_FOLDER'] + filename
            csvfile.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
    class_name = request.form.get("class_name")
    teacher_id = session['user']
    cohort_id = api.add_new_cohort(class_name, teacher_id)
    user_type = "student"
    api.create_student_from_csv(file_path, cohort_id, user_type)

    return redirect("/#/reports/")
Exemple #4
0
def upload_class_file():
    if request.method == 'POST':
        csvfile = request.files['studentfile']
        if csvfile and allowed_file(csvfile.filename):
            filename = secure_filename(csvfile.filename)
            file_path = app.config['UPLOAD_FOLDER'] + filename
            csvfile.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
    class_name = request.form.get("class_name")
    teacher_id = session['user']
    cohort_id = api.add_new_cohort(class_name, teacher_id)
    user_type = "student"
    api.create_student_from_csv(file_path, cohort_id, user_type)

    return redirect("/#/reports/")
Exemple #5
0
 def testAddCohort(self):
     name = "TestClass"
     teacher_id = 85
     self.assertEqual(api.add_new_cohort(name, teacher_id), 7)