Beispiel #1
0
def teacherManage(request, *args):
    '''
    教师管理
    :param request:
    :param args:
    :return:
    '''
    if request.method == 'GET':
        username = request.session.get('username', None)
        userprofile = models.UserProfile.objects.filter(
            user__username=username).values().first()
        teacher = {
            'username': '',
        }
        id = args[0] if args[0] != '' else 0
        admin = Users.SuperAdmin()
        if id == 0:
            return render(request, 'MicroCourseAdmin/teacherManage.html', {
                'id': id,
                'teacher': teacher,
                'userprofile': userprofile
            })
        teacher = admin._selectTeacher(id)
        if teacher != 'notExist':
            return render(request, 'MicroCourseAdmin/teacherManage.html', {
                'id': id,
                'teacher': teacher,
                'userprofile': userprofile
            })
        else:
            return redirect('/teachers/')
    if request.method == 'POST':
        admin = Users.SuperAdmin()
        return admin._teacherManage(request)  #创建或者更新教师信息
Beispiel #2
0
def gradeManage(request, *args):
    '''
    管理年级信息
    :param request:
    :param args:
    :return:
    '''
    if request.method == 'GET':
        username = request.session.get('username', None)
        userprofile = models.UserProfile.objects.filter(
            user__username=username).values().first()
        grade = {
            'name': '',
            'description': '',
        }
        id = args[0] if args[0] != '' else 0
        if id == 0:
            return render(request, 'MicroCourseAdmin/gradeManage.html', {
                'id': id,
                'grade': grade,
                'userprofile': userprofile
            })
        admin = Users.SuperAdmin()
        grade = admin._selectGrade(id)
        if grade != 'notExist':
            return render(request, 'MicroCourseAdmin/gradeManage.html', {
                'id': id,
                'grade': grade,
                'userprofile': userprofile
            })
        else:
            return redirect('/grades/')
    if request.method == 'POST':
        admin = Users.SuperAdmin()
        return admin._gradeManage(request)  #创建或者修改年级信息
Beispiel #3
0
def selectUnitCourse(request):
    admin = Users.SuperAdmin()
    username = request.session.get('username', None)
    userprofile = models.UserProfile.objects.filter(
        user__username=username).values().first()
    if request.method == 'GET':
        user = Users.SuperAdmin()
        feedback = user._getGrade2Class_Course(request)
        return feedback
    elif request.method == 'POST':
        if request.POST.get('action') == 'getUnits':
            courseId = request.POST.get('courseId')
            unitCourses = admin._getUnitCoursesByCourseId(courseId)
            return HttpResponse(json.dumps(list(unitCourses)),
                                content_type="application/json")
Beispiel #4
0
def myStudentManage(request, *args):
    '''
    学生管理
    :param request:
    :return:
    '''
    if request.method == 'GET':
        username = request.session.get('username', None)
        userprofile = models.UserProfile.objects.filter(
            user__username=username).values().first()
        student = {
            'username': '',
        }
        id = args[0] if args[0] != '' else 0
        teacher = Users.Teacher()
        if id == 0:
            return render(request, 'MicroCourseAdmin/myStudentManage.html', {
                'id': id,
                'student': student,
                'userprofile': userprofile
            })
        student = teacher._selectStudent(id)
        if student != 'notExist':
            return render(request, 'MicroCourseAdmin/myStudentManage.html', {
                'id': id,
                'student': student,
                'userprofile': userprofile
            })
        else:
            return redirect('/myStudents/')
    if request.method == 'POST':
        admin = Users.SuperAdmin()
        return admin._studentManage(request)  #创建或者更新教师信息
Beispiel #5
0
def teachers(request):
    '''
    展示所有的教师信息
    :param request:
    :return:
    '''
    if request.method == 'GET':
        user = Users.SuperAdmin()
        return user._showAllTeachers(request)
Beispiel #6
0
def courseInfo(request):
    '''
    课程信息
    :param request:
    :return:
    '''
    if request.method == 'GET':
        admin = Users.SuperAdmin()
        return admin._showAllCourses(request)  #展示所有的课程信息
Beispiel #7
0
def classInfo(request):
    '''
    班级信息
    :param request:
    :return:
    '''
    if request.method == 'GET':
        admin = Users.SuperAdmin()
        return admin._showAllClasses(request)  #展示所有的班级信息
Beispiel #8
0
def gradeInfo(request):
    '''
    年级信息
    :param request:
    :return:
    '''
    if request.method == 'GET':
        admin = Users.SuperAdmin()  #实例化一个管理员
        return admin._showAllGrades(request)  #展示所有的年级信息
Beispiel #9
0
def classManage(request, *args):
    '''
    管理班级信息
    :param request:
    :param args:
    :return:
    '''
    if request.method == 'GET':
        username = request.session.get('username', None)
        userprofile = models.UserProfile.objects.filter(
            user__username=username).values().first()
        class1 = {
            'name': '',
            'description': '',
        }
        id = args[0] if args[0] != '' else 0
        admin = Users.SuperAdmin()
        grades = admin._getAllGrades()
        if id == 0:
            return render(
                request, 'MicroCourseAdmin/classManage.html', {
                    'id': id,
                    'class1': class1,
                    'grades': grades,
                    'userprofile': userprofile
                })
        class1 = admin._selectClass(id)
        if class1 != 'notExist':
            return render(
                request, 'MicroCourseAdmin/classManage.html', {
                    'id': id,
                    'class1': class1,
                    'grades': grades,
                    'userprofile': userprofile
                })
        else:
            return redirect('/classes/')
    if request.method == 'POST':
        admin = Users.SuperAdmin()
        return admin._classManage(request)  #创建或者修改班级信息
Beispiel #10
0
def myTaskManage(request, *args):
    if request.method == 'GET':
        username = request.session.get('username', None)
        userprofile = models.UserProfile.objects.filter(
            user__username=username).values().first()
        task = {
            'name': '',
            'type': '单选题',
        }
        id = args[0] if args[0] != '' else 0
        teacher = Users.Teacher()
        if id == 0:
            return render(request, 'MicroCourseAdmin/myTaskManage.html', {
                'id': id,
                'task': task,
                'userprofile': userprofile
            })
        return teacher._renderTask(request, id)
    if request.method == 'POST':
        admin = Users.SuperAdmin()
        return admin._myTaskManage(request)  #创建或者更新教师信息
Beispiel #11
0
def courseManage(request, *args):
    '''
    管理课程信息
    :param request:
    :param args:
    :return:
    '''
    admin = Users.SuperAdmin()
    username = request.session.get('username', None)
    userprofile = models.UserProfile.objects.filter(
        user__username=username).values().first()
    grades = admin._getAllGrades()
    if request.method == 'GET':
        course = {
            'name': '',
            'description': '',
        }
        id = args[0] if args[0] != '' else 0
        if id == 0:
            return render(
                request, 'MicroCourseAdmin/courseManage.html', {
                    'id': id,
                    'course': course,
                    'grades': grades,
                    'userprofile': userprofile
                })
        course = admin._selectCourse(id)
        unitCourses = admin._getUnitCoursesByCourseId(id)
        if course != 'notExist':
            return render(
                request, 'MicroCourseAdmin/courseManage.html', {
                    'id': id,
                    'course': course,
                    'grades': grades,
                    'unitCourses': unitCourses,
                    'userprofile': userprofile
                })
        else:
            return redirect('/classes/')
    if request.method == 'POST':
        if request.POST.get('addUnit') == 'addUnit':
            name = request.POST.get('unitName')
            des = request.POST.get('unitDes')
            id = request.POST.get('courseId')
            course = admin._selectCourse(id)
            unitCourses = admin._getUnitCoursesByCourseId(id)
            feedback = admin._createUnitCourse(name, des, id)
            error = ''
            if feedback != 'success':
                error = feedback
            return render(
                request, 'MicroCourseAdmin/courseManage.html', {
                    'id': id,
                    'course': course,
                    'grades': grades,
                    'unitCourses': unitCourses,
                    'userprofile': userprofile,
                    'error': error
                })
        else:
            admin = Users.SuperAdmin()
            return admin._courseManage(request)  #创建或者更新课程信息