コード例 #1
0
def create_student():
    classes_list = Classes.get_obj_list()
    for k, obj in enumerate(classes_list):
        print(
            k, '\033[33;1m班级名:[%s] 学校:[%s] 地址:[%s] 课程:[%s] 讲师:[%s]\033[0m ' %
            (obj.name, obj.school_id.get_obj_uuid().name,
             obj.school_id.get_obj_uuid().addr,
             obj.course_teacher_id.get_obj_uuid().
             course_id.get_obj_uuid().name, obj.course_teacher_id.get_obj_uuid(
             ).teacher_id.get_obj_uuid().name))
    choose = input('选择班级 >> ').strip()
    if choose.isdigit():
        choose = int(choose)
        if choose < len(Classes.get_obj_list()):
            choose_classes = classes_list[choose]
            name = input('输入学生名字 >> ').strip()
            pas = input('输入学生密码 >> ').strip()
            age = input('输入学生年龄 >> ').strip()
            student_list = [obj.name for obj in Student.get_obj_list()]
            if name in student_list:
                print('\033[31;学生 [%s] 已存在,不可重复创建0m\033[0m' % name)
            else:
                student = Student(name, pas, age,
                                  choose_classes.nid)  # 需要存一个nid
                student.save()
                print('\033[32;1m学生 [%s] 创建成功\033[0m' % name)
        else:
            print('\033[31;1m 没有此班级,请重新选择\033[0m')
コード例 #2
0
def create_classes():
    try:
        print('创建班级'.center(60, '-'))
        course_list = Course.get_all_obj_list()
        for k, obj in enumerate(course_list):
            print(k, obj, obj.name)
        sid = int(input('请选择课程:'))
        course_obj = course_list[sid]
        name = input('请输入班级名:').strip()
        tuition = input('请输入学费:').strip()

        classes_name_list = [obj.name for obj in Classes.get_all_obj_list()]
        if name in classes_name_list:
            raise Exception('\033[43;1m班级[%s] 已存在,不可重复创建\033[0m' % name)
        obj = Classes(name, tuition, course_obj.nid)
        obj.save()
        status = True
        error = ''
        data = '\033[33;1m班级[%s] 学费[%s] 创建成功\033[0m' % (obj.name, obj.tuition)

    except Exception as e:
        status = False
        error = str(e)
        data = ''
    return {'status': status, 'error': error, 'data': data}
コード例 #3
0
 def post_class(payload):
     try:
         data = request.get_json()
         name = data['class_name']
         address = data['address']
         inst = data['instructor']
         new_class = Classes(class_name=name,
                             address=address,
                             instructor=inst)
         new_class.insert()
     except Exception:
         abort(400)
     return jsonify({'success': True, 'classes': new_class.format()})
コード例 #4
0
ファイル: test_flaskr.py プロジェクト: kefeh/distant_learning
 def test_get_timetable_class_id_and_accepted(self):
     """ Test for get Timetable with class id and accepted"""
     resp_register = self.register_user(self, '*****@*****.**',
                                        '123456')
     a_class = Classes(name="Default test class", )
     a_class.insert()
     some_class = Classes.query.filter(
         Classes.name == "Default test class").first()
     user = User.query.filter(User.email == '*****@*****.**').first()
     response1 = self.client().post('/login',
                                    json={
                                        "email": '*****@*****.**',
                                        "password": '******'
                                    },
                                    content_type='application/json')
     response3 = self.client().post(
         '/timetable',
         headers=dict(
             Authorization='Bearer' +
             json.loads(resp_register.data.decode())['auth_token']),
         json={
             "name": 'Mathematics Trigonometry',
             "time": '2020-06-17 15:00',
             "teacher_id": user.id,
             "class_id": some_class.id,
             "link": 'somezoomlink.com'
         },
         content_type='application/json')
     print(json.loads(response3.data.decode()))
     response4 = self.client().put(
         '/timetable/accept',
         headers=dict(
             Authorization='Bearer' +
             json.loads(resp_register.data.decode())['auth_token']),
         json={
             "teacher_id": user.id,
             "id": json.loads(response3.data.decode())['id'],
         },
     )
     response = self.client().get(
         '/timetable?class_id={}&accepted={}'.format(some_class.id, True),
         headers=dict(
             Authorization='Bearer' +
             json.loads(resp_register.data.decode())['auth_token']),
         content_type='application/json')
     data = json.loads(response.data.decode())
     self.assertTrue(data['status'] == 'success')
     self.assertTrue(len(data['data']) >= 1)
     self.assertEqual(response.status_code, 200)
コード例 #5
0
    def create_class(payload):
        name = request.get_json()['name']
        start_time = request.get_json()['start_time']
        teacher_id = request.get_json()['teacher_id']
        course_id = request.get_json()['course_id']
        try:
            claass = Classes(name=name,
                             start_time=start_time,
                             teacher_id=teacher_id,
                             course_id=course_id)
            claass.insert()

            return jsonify({"success": True, "Courses": claass.format()})
        except BaseException:
            abort(422)
コード例 #6
0
def addclass(studentcount,techniquecount):
    sarray = []
    tarray = []
    for i in range(1,studentcount+1):
        sarray.append(i)
    for i in range(1, techniquecount+1):
        tarray.append(i)
    techs = Techniques.query.all()
    membs = Members.query.all()
    if request.method == 'POST':
        classdate = request.form['classdate']
        newclass = Classes(date=classdate)
        db.session.add(newclass)
        db.session.commit()
        for i in range(1, studentcount + 1):
            membername = request.form[str(i)]
            newinteresct = ClassesMember(class_id = newclass.id, member_id = Members.query.
                                         filter_by(name=membername).first().id)
            db.session.add(newinteresct)
            db.session.commit()
        for i in range(1, techniquecount + 1):
            techniquename = request.form[str(i)+"a"]
            newinteresct = ClassesTechnique(class_id = newclass.id, technique_id = Techniques.query.
                                            filter_by(name=techniquename).first().id)
            db.session.add(newinteresct)
            db.session.commit()
        return redirect('/viewclass/0/0')
    return render_template('addclass.html', studentcount=sarray,techniquecount=tarray,techniques=techs,
                           students=membs)
コード例 #7
0
def create_course_to_teacher():

    print('课程导师'.center(60, '='))
    course_list = Course.get_all_obj_list()
    for k, obj in enumerate(course_list):
        print(k, obj, obj.name)
    sid = int(input('请选择课程: '))
    course_obj = course_list[sid]

    teacher_list = Teacher.get_all_obj_list()
    for k, obj in enumerate(teacher_list):
        print(k, obj, obj.name)
    sid = int(input('请选择关联导师: '))
    teacher_obj = teacher_list[sid]

    classes_list = Classes.get_all_obj_list()
    for k, obj in enumerate(classes_list):
        print(k, obj, obj.name)
    sid = int(input('请选择负责班级: '))
    classes_obj = classes_list[sid]

    obj = Course_to_teacher(course_obj.nid, teacher_obj.nid, classes_obj.nid)
    obj.save()
    status = True
    error = ''
    data = '\033[33;1m课程[%s] 班级[%s] 导师[%s] 分配成功\033[0m' % (
        course_obj.name, classes_obj.name, teacher_obj.name)
    return {'status': status, 'error': error, 'data': data}
コード例 #8
0
def teacher_dashboard():
    class_obj = Classes.query.filter_by(
        professor_id=current_user.user_id)

    class_list = []
    for c in class_obj:
        class_info = (c.get_id(), c.get_name(), c.get_section())
        class_list.append(class_info)

    if request.method == 'POST':
        # if add_class is clicked
        # get class name and section, generate registration code, and add a new class to database, redirect
        if 'add_class' in request.form:
            # generate random registration code
            registration_code = get_code()

            # add class to database
            new_class = Classes(
                name=request.form['class_name'],
                section=request.form['class_section'],
                enrollment_code=registration_code,
                professor_id=current_user.user_id
            )
            db.session.add(new_class)
            db.session.commit()

            class_added = Classes.query.filter_by(
                professor_id=current_user.user_id, name=new_class.name, section=new_class.section).first()
            class_id = class_added.get_id()
            return redirect(url_for('auth.teacher_class_page', id=class_id))
        else:
            class_id = request.form[class_id]
            return redirect(url_for('auth.teacher_class_page', id=class_id))
    return render_template('teacher_dashboard.html', title='Teacher Dashboard', class_list=class_list)
コード例 #9
0
def show_classes():
    for obj in Classes.get_obj_list():
        print('\033[33;1m班级名:[%s] 学校:[%s] 地址:[%s] 课程:[%s] 讲师:[%s]\033[0m ' % (
            obj.name, obj.school_id.get_obj_uuid().name,
            obj.school_id.get_obj_uuid().addr,
            obj.course_teacher_id.get_obj_uuid().course_id.get_obj_uuid().name,
            obj.course_teacher_id.get_obj_uuid().teacher_id.get_obj_uuid().name
        ))
コード例 #10
0
 def show_classes_info(self):
     # username = input(' username >> ')
     classes_info = Classes.get_obj_list()
     count = 0
     for obj in classes_info:
         teacher = obj.course_teacher_id.get_obj_uuid().teacher_id.get_obj_uuid().name
         if self.username == teacher:
             print('\033[36;1m讲师:%s 班级:%s 学校[%s]-地址[%s] 课程:[%s]\033[0m' % (teacher, obj.name, obj.school_id.get_obj_uuid().name, obj.school_id.get_obj_uuid().addr,
                   obj.course_teacher_id.get_obj_uuid().course_id.get_obj_uuid().name))
             count += 1
     print('\033[32;1m count: %s\033[0m' % count)
コード例 #11
0
def create_class():
    """ Create a class """
    data = request.get_json()
    new_id = uuid4()
    new_class = Classes(id=new_id, name=data['name'])
    db.session.add(new_class)
    db.session.commit()
    return jsonify({
        'message': 'New Class created!',
        'id': new_id
    })
コード例 #12
0
ファイル: tests_models.py プロジェクト: ferhas/ziai2015
    def test_children_ask_for_leave_list(self):
      
        sch = School(school_name="_name1", classes_number=100)
        sch.save()

        twz = Classes(class_name="WeizhongTu", children_number=100,schoolkey=sch)
        twz.save()

        children = Children()
        children.Classeskey = twz
        children.nicename = "1"
        children.save() 
   
        children2 = Children()
        children2.Classeskey = twz
        children2.nicename = "2"
        children2.stats= "路途中"
        children2.save() 

        children3 = Children()
        children3.Classeskey = twz
        children3.nicename = "3"
        children3.stats= "已到达"
        children3.save() 

        leave = Children_ask_for_leave()
        leave.begin_time = datetime.datetime.now() - datetime.timedelta(hours=10)
        leave.end_time = datetime.datetime.now() + datetime.timedelta(hours=10)
        leave.Childrenkey_id = 1 
        leave.save()
        print(leave.begin_time)
        print(datetime.datetime.now())
        print(leave.end_time)


        classes = Classes.objects.get(pk=1)
        list = classes.children_ask_for_leave_list()
        list2 = classes.children_arrived_list()
        list3 = classes.children_road_list()
        count = list.count()+list2.count()+list3.count()
        self.assertEqual(list.count(), 1)
コード例 #13
0
def create_classes():
    school_list = School.get_obj_list()  # 所有学校列表
    for k, obj in enumerate(school_list):
        print(k, '学校:[%s]  地址:[%s]' % (obj.name, obj.addr))
    choose = input('选择学校 >> ').strip()
    if choose.isdigit():
        choose = int(choose)
        if choose < len(School.get_obj_list()):
            choose_school = school_list[choose]  # 选择的学校
            name = input('请输入班级名字 >> ')
            classes_list = [obj.name for obj in Classes.get_obj_list()]
            if name in classes_list:
                print('\033[31;1m班级[%s] 已存在\033[0m' % name)
            else:
                course_teacher_list = Course_teacher.get_obj_list()
                for j, ct in enumerate(course_teacher_list):
                    print(j,
                          ct.course_id.get_obj_uuid().name,
                          ct.teacher_id.get_obj_uuid().name)
                choose_course_teacher = input('选择关联的课程讲师 >> ').strip()
                choose_ct_id = course_teacher_list[int(choose_course_teacher)]
                classes = Classes(name, choose_school.nid, choose_ct_id.nid)
                classes.save()
                print('\033[32;1m班级[%s] 创建成功\033[0m' % name)
コード例 #14
0
ファイル: test_flaskr.py プロジェクト: kefeh/distant_learning
 def test_add_timetable(self):
     """ Test for Add Timetable"""
     resp_register = self.register_user(self, '*****@*****.**',
                                        '123456')
     a_class = Classes(name="Default test class", )
     a_class.insert()
     user = User.query.filter(User.email == '*****@*****.**').first()
     response = self.client().post(
         '/timetable',
         headers=dict(
             Authorization='Bearer' +
             json.loads(resp_register.data.decode())['auth_token']),
         json={
             "name": 'Mathematics Trigonometry',
             "time": '2020-06-17 15:00',
             "teacher_id": user.id,
             "class_id": a_class.id,
             "link": 'somezoomlink.com'
         },
         content_type='application/json')
     data = json.loads(response.data.decode())
     print(data)
     self.assertTrue(data['status'] == 'success')
     self.assertEqual(response.status_code, 200)
コード例 #15
0
def create_student():

    print('新生入学'.center(60, '-'))
    classes_list = Classes.get_all_obj_list()
    for k, obj in enumerate(classes_list):
        print(k, obj, obj.name)
    sid = int(input('请选择班级:'))
    classes_obj = classes_list[sid]

    name = input('请输入学生姓名:').strip()
    password = input('请输入登陆密码:').strip()
    age = input('请输入学生年龄:').strip()
    qq = input('请输入学生QQ:').strip()
    score_obj = Score(0)
    score_obj.save()
    obj = Student(name, password, age, qq, classes_obj.nid, score_obj.nid)
    obj.save()
    status = True
    error = ''
    data = '\033[33;1m学生[%s] age[%s] QQ[%s] 录取成功 \033[0m' % (obj.name, obj.age,
                                                             obj.qq)

    return {'status': status, 'error': error, 'data': data}
コード例 #16
0
    def add_class():
        data = request.json
        education_id = data.get('education_id', None)
        sub_category_id = data.get('sub_category_id', None)

        if ((data.get('name', '') == '')):
            abort(422)
        try:
            classes = Classes(name=data.get('name'))
            classes.rank = data.get('rank')
            if education_id or sub_category_id:
                if education_id:
                    classes.education_id = int(data.get('education_id'))
                if sub_category_id:
                    classes.sub_category_id = int(data.get('sub_category_id'))
            else:
                abort(422)
        except Exception:
            abort(422)
        classes.insert()

        return jsonify({'message': 'success', 'id': classes.id})
コード例 #17
0
def show_classes():
    for obj in Classes.get_all_obj_list():
        print('\033[33;1m [%s]课程 班级[%s] 学费[%s]\033[0m'.center(60,'-') \
              %(obj.course_nid.get_obj_by_uuid().name,obj.name,obj.tuition))