Ejemplo n.º 1
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)  #创建或者更新教师信息
Ejemplo n.º 2
0
def addTestPaper(request, *args):
    teacher = Users.Teacher()
    if request.method == 'GET':
        username = request.session.get('username', None)
        userprofile = models.UserProfile.objects.filter(
            user__username=username).values().first()
        allTasks = teacher._formatAllTasks(request)
        return render(request, 'MicroCourseAdmin/addTestPaper.html', {
            'allTasks': allTasks,
            'userprofile': userprofile
        })
    if request.method == 'POST':
        action = request.POST.get('action')
        if action == 'query':
            taskName = request.POST.get('taskName')
            type = request.POST.get('type')
            if taskName == '' or taskName == None:
                tasks = []
            else:
                tasks = teacher._getTasksByNameAndType(taskName, type)
            return HttpResponse(json.dumps(list(tasks)),
                                content_type="application/json")
        elif action == 'submit':
            id = teacher._createTestPaper(request)
            return HttpResponse(id)
Ejemplo n.º 3
0
def taskDetail(request, *args):
    if request.method == 'GET':
        teacher = Users.Teacher()
        id = args[0] if args[0] != '' else 0
        if id == 0:
            return redirect('/allTasks/')
        return teacher._renderTaskOfAll(request, id)
Ejemplo n.º 4
0
def myTests(request):
    teacher = Users.Teacher()
    if request.method == 'GET':
        feedback = teacher._getMyTests(request)
        return feedback
    elif request.method == 'POST':
        feedback = teacher._updateTestStatus(request)
        return feedback
Ejemplo n.º 5
0
def getMyStudents(request):
    '''
    获取当前教师的所有学生信息
    :param request:
    :return:
    '''
    if request.method == 'GET':
        teacher = Users.Teacher()
        return teacher._showMyStudents(request)
Ejemplo n.º 6
0
def allTasks(request):
    if request.method == 'GET':
        username = request.session.get('username', None)
        userprofile = models.UserProfile.objects.filter(
            user__username=username).values().first()
        teacher = Users.Teacher()
        allTasks = teacher._formatAllTasks(request)
        return render(request, 'MicroCourseAdmin/allTasks.html', {
            'allTasks': allTasks,
            'userprofile': userprofile
        })
Ejemplo n.º 7
0
def UnitCourseManage(request, *args):
    teacher = Users.Teacher()
    if request.method == 'GET':
        id = int(args[0]) if args[0] != '' else 0
        print(id)
        print(type(id))
        if id > 0:
            feedback = teacher._getUnitById(request, id)
            return feedback
        else:
            return redirect('/404/')
Ejemplo n.º 8
0
def testPaperDetail(request, *args):
    teacher = Users.Teacher()
    if request.method == 'GET':
        username = request.session.get('username', None)
        userprofile = models.UserProfile.objects.filter(
            user__username=username).values().first()
        id = args[0]
        feedback = teacher._getTestPaperDetail(request, id)
        return feedback
    elif request.method == 'POST':
        URL = request.POST.get('url')
        testPaperid = URL.split('/')[-1]
        feedback = teacher._createTest(testPaperid, request)
        return feedback
Ejemplo n.º 9
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)  #创建或者更新教师信息
Ejemplo n.º 10
0
def testPapers(request):
    teacher = Users.Teacher()
    callback = teacher._fetchAllTestPapers(request)
    return callback
Ejemplo n.º 11
0
def myTasks(request):
    if request.method == 'GET':
        teacher = Users.Teacher()
        return teacher._showMyTasks(request)