Beispiel #1
0
def student_account_settings(request):
	if (request.user.is_authenticated() and request.user.is_type("Student")):
		name = request.user.first_name + " " + request.user.last_name
        elements = get_header_navbar("Student",name,"Account Settings")
        context = Context( { 
			        		'menu' : get_template("student_menu.html").render(Context({ 'assignments' : getStudentAssignments(request.user.user_id)})),
			        		'header' : elements['header'],
                            'navbar' : elements['navbar'],
                            'id' : request.user.user_id,
                            'type': 'student'
		        	})
        return HttpResponse(get_template("account_settings.html").render(context))
	return HttpResponseRedirect("/")
Beispiel #2
0
def class_settings(request):
	if (request.user.is_authenticated() and request.user.is_type("Teacher")):
		name = request.user.first_name + " " + request.user.last_name
        elements = get_header_navbar("Teacher",name,"Class Settings")
        context = Context( { 
			        		'menu' : get_template("teacher_menu.html").render(Context()),
			        		'header' : elements['header'],
			        		'teaching_hierarchy': get_courses(request.user.user_id),
                            'navbar' : elements['navbar'],
                            'add_student' : AddStudentForm(),
                            'years' : range(1,13) #should be added later from DB
		        	})
        return HttpResponse(get_template("class_settings.html").render(context))
	return HttpResponseRedirect("/")
Beispiel #3
0
def teacher_account_settings(request):
	if (request.user.is_authenticated() and request.user.is_type("Teacher")):
		name = request.user.first_name + " " + request.user.last_name
        elements = get_header_navbar("Teacher",name,"Account Settings")
        context = Context( { 
			        		'menu' : get_template("teacher_menu.html").render(Context()),
			        		'header' : elements['header'],
                            'navbar' : elements['navbar'],
                            'id' : request.user.user_id,
                            'type': 'teacher'
		        	})
        settings_page = get_template("account_settings.html").render(context)
        return HttpResponse(settings_page)
	return HttpResponseRedirect("/")	
Beispiel #4
0
def view_spec(request):
	if (request.user.is_authenticated() and request.user.is_type("Teacher")) :
		template = get_template("view_spec.html")
		name = request.user.first_name + " " + request.user.last_name
		elements = get_header_navbar("Teacher",name,"View Specification")
		context = Context(
				{ 'header' : elements['header'],
				  'navbar' : elements['navbar'],
				  'menu' : get_template("teacher_menu.html").render(Context({"page":"view_spec"})),
				  'editor' : SubmitCodeForm(),
				  'assignment_book': get_all_exercises()
				})
		return HttpResponse(template.render(context))
	return HttpResponseRedirect("/")
def add_new_exercise(request):
	if (request.user.is_authenticated()):
		menu = get_template("teacher_menu.html").render(Context({ 'page':'add_ex'}))
		elements = get_header_navbar("Teacher",request.user.first_name + " " + request.user.last_name,"Add New Exercise")
		template = get_template("add_new_exercise.html")
		new_ex_form = NewExerciseForm()
		context =  Context({ 'header' : elements['header'],
                            'navbar' : elements['navbar'],
                            'menu' : menu,
                            'new_ex' : new_ex_form
                           });
		context.update(csrf(request))
		return HttpResponse(template.render(context));
	return HttpResponseBadRequest()
def get_teacher_view(request):

    # at this point it should be a guaranteed that the session has
    # a key named 'user_id' representing a teacher
    if (request.user.is_authenticated() and request.user.is_type("Teacher")):
        name = request.user.first_name + " " + request.user.last_name
        teaching_hierarchy = get_courses_with_assignments2(request.user.user_id)
        template = get_template("teacher_view.html")
        elements = get_header_navbar("Teacher",name,"Teaching Overview")
        context = Context( {'header' : elements['header'],
                            'navbar' : elements['navbar'],
                            'teaching_hierarchy': teaching_hierarchy,
                            'menu' : get_template("teacher_menu.html").render(Context({"page":"overview"})),
                            })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect("/")
def get_student_view(request):
    if (request.user.is_type("Student")):
        assignments = __get_assignments_book(request.user.user_id)
        menu = get_template("student_menu.html").render(Context({ 'assignments' : assignments, 'page':'code'}))
        elements = get_header_navbar("Student",request.user.first_name + " " + request.user.last_name,"Student Overview")
        context = Context({ 'header' : elements['header'],
                            'navbar' : elements['navbar'],
                            'menu': menu,
                            'id': request.user.user_id,
                            'form':SubmitCodeForm(),
                            'assignments' : assignments
                        })
        context.update(csrf(request))
        template = get_template("student_home.html")
        return HttpResponse(template.render(context))
    return HttpResponseRedirect("/")
def view_student_submissions(request):
    if request.user.is_authenticated():
        assignments = getStudentAssignments(request.user.user_id)
        menu = get_template("student_menu.html").render(Context({"assignments": assignments, "page": "view_sub"}))
        elements = get_header_navbar(
            "Student", request.user.first_name + " " + request.user.last_name, "Add New Exercise"
        )
        template = get_template("view_submission_student.html")
        context = Context(
            {
                "header": elements["header"],
                "navbar": elements["navbar"],
                "menu": menu,
                "assignments": getStudentAssignments(request.user.user_id),
            }
        )
        return HttpResponse(template.render(context))
    return HttpResponseBadRequest()
def view_submissions_teacher(request):
    if request.user.is_authenticated():
        teaching_hierarchy = get_courses_with_assignments2(request.user.user_id)  # variant to see how this works
        menu = get_template("teacher_menu.html").render(Context({"page": "view_sub"}))
        elements = get_header_navbar(
            "Teacher", request.user.first_name + " " + request.user.last_name, "Submit Feedback"
        )
        template = get_template("view_submission_teacher.html")
        context = Context(
            {
                "header": elements["header"],
                "navbar": elements["navbar"],
                "teaching_hierarchy": teaching_hierarchy,
                "menu": menu,
            }
        )
        return HttpResponse(template.render(context))
    return HttpResponseBadRequest()
def single_exercise_view(request, ex_id):
	if (request.user.is_authenticated()):
		template = get_template("single_exercise.html")
		exercise = get_exercise(ex_id)
		code_form = SubmitCodeForm(initial={'code':exercise[3]},auto_id="id_%s_"+ex_id)
		assignments = getStudentAssignments(request.user.user_id)
		menu = get_template("student_menu.html").render(Context({ 'assignments' : assignments, 'page':'code'}))
		elements = get_header_navbar("Student",request.user.first_name + " " + request.user.last_name,"Student Overview")
		context = Context( {'menu' : menu,
							'header' : elements['header'],
                            'navbar' : elements['navbar'],
							'description' : exercise[4],
							'ex_id' : ex_id,
							'code_form' : code_form
						})
		context.update(csrf(request))
		return HttpResponse(template.render(context))
	return HttpResponse("Not allowed")
Beispiel #11
0
def get_set_exercise_page(request):
	if (request.user.is_authenticated() and request.user.is_type("Teacher")):
		template = get_template("set_exercise.html")
		teaching_hierarchy = get_courses(request.user.user_id)
		vsp_context = Context({'form':ViewSpecificationForm()})
		vsp_context.update(csrf(request))
		view_spec_form = get_template("view_spec_form.html").render(vsp_context)
		name = request.user.first_name + " " + request.user.last_name
		elements = get_header_navbar("Teacher",name,"Teaching Overview")
		context = Context( {'header' : elements['header'], 
							'menu' : get_template("teacher_menu.html").render(Context({"page":"set_ex"})),
							'teaching_hierarchy' : teaching_hierarchy,
							'navbar' : elements['navbar'],
							'assignment_book' : get_all_exercises(),
							'vsp_media' : Template("{{form.media}}").render(vsp_context), 
							'view_spec_form' : view_spec_form})
		return HttpResponse(template.render(context))
	return HttpResponseRedirect("/")
def student_grades_view(request):
	if request.user.is_authenticated():
		NUMBER_PER_PAGES = 10
		assignments = getStudentAssignments(request.user.user_id)
		# pages = range(1,(get_number_of_submissions(request.user.user_id)/NUMBER_PER_PAGES)+1)
		# if not pages:
		# 	pages = None
		pages = None
		menu = get_template("student_menu.html").render(Context({ 'assignments' : assignments, 'page': 'grades'}))
		elements = get_header_navbar("Student",request.user.first_name + " " + request.user.last_name,"Student Overview")
		context = Context( {'header' : elements['header'],
                            'navbar' : elements['navbar'],
							'menu': menu,
							'pages': pages,
							'grades' : get_grades(request.user.user_id, 1, NUMBER_PER_PAGES)
						})
		context.update(csrf(request))
		template = get_template("student_grades.html")
		return HttpResponse(template.render(context))
	return HttpResponseRedirect('/')