Commit c5f9d94c by Vik Paruchuri

Add in comments, fix behavior

parent c91fa2f4
...@@ -90,6 +90,11 @@ def staff_grading(request, course_id): ...@@ -90,6 +90,11 @@ def staff_grading(request, course_id):
'staff_access': True, }) 'staff_access': True, })
def find_peer_grading_module(course): def find_peer_grading_module(course):
"""
Given a course, finds the first peer grading module in it.
@param course: A course object.
@return: boolean found_module, string problem_url
"""
#Reverse the base course url #Reverse the base course url
base_course_url = reverse('courses') base_course_url = reverse('courses')
found_module = False found_module = False
...@@ -117,7 +122,7 @@ def find_peer_grading_module(course): ...@@ -117,7 +122,7 @@ def find_peer_grading_module(course):
@cache_control(no_cache=True, no_store=True, must_revalidate=True) @cache_control(no_cache=True, no_store=True, must_revalidate=True)
def peer_grading(request, course_id): def peer_grading(request, course_id):
''' '''
Show a peer grading interface Show a peer grading interface to the student. The interface is linked to from the button.
''' '''
#Get the current course #Get the current course
...@@ -153,7 +158,8 @@ def generate_problem_url(problem_url_parts, base_course_url): ...@@ -153,7 +158,8 @@ def generate_problem_url(problem_url_parts, base_course_url):
@cache_control(no_cache=True, no_store=True, must_revalidate=True) @cache_control(no_cache=True, no_store=True, must_revalidate=True)
def student_problem_list(request, course_id): def student_problem_list(request, course_id):
''' '''
Show a student problem list Show a student problem list to a student. Fetch the list from the grading controller server, get some metadata,
and then show it to the student.
''' '''
course = get_course_with_access(request.user, course_id, 'load') course = get_course_with_access(request.user, course_id, 'load')
student_id = unique_id_for_user(request.user) student_id = unique_id_for_user(request.user)
...@@ -175,6 +181,8 @@ def student_problem_list(request, course_id): ...@@ -175,6 +181,8 @@ def student_problem_list(request, course_id):
else: else:
problem_list = problem_list_dict['problem_list'] problem_list = problem_list_dict['problem_list']
#A list of problems to remove (problems that can't be found in the course)
list_to_remove = []
for i in xrange(0, len(problem_list)): for i in xrange(0, len(problem_list)):
try: try:
#Try to load each problem in the courseware to get links to them #Try to load each problem in the courseware to get links to them
...@@ -184,6 +192,8 @@ def student_problem_list(request, course_id): ...@@ -184,6 +192,8 @@ def student_problem_list(request, course_id):
#Continue with the rest of the location to construct the list #Continue with the rest of the location to construct the list
error_message = "Could not find module for course {0} at location {1}".format(course.id, problem_list[i]['location']) error_message = "Could not find module for course {0} at location {1}".format(course.id, problem_list[i]['location'])
log.error(error_message) log.error(error_message)
#Mark the problem for removal from the list
list_to_remove.append(i)
continue continue
problem_url = generate_problem_url(problem_url_parts, base_course_url) problem_url = generate_problem_url(problem_url_parts, base_course_url)
problem_list[i].update({'actual_url': problem_url}) problem_list[i].update({'actual_url': problem_url})
...@@ -214,6 +224,8 @@ def student_problem_list(request, course_id): ...@@ -214,6 +224,8 @@ def student_problem_list(request, course_id):
log.error("Problem with results from external grading service for open ended.") log.error("Problem with results from external grading service for open ended.")
success = False success = False
#Remove problems that cannot be found in the courseware from the list
problem_list = [problem_list[i] for i in xrange(0,len(problem_list)) if i not in list_to_remove]
ajax_url = _reverse_with_slash('open_ended_problems', course_id) ajax_url = _reverse_with_slash('open_ended_problems', course_id)
return render_to_response('open_ended_problems/open_ended_problems.html', { return render_to_response('open_ended_problems/open_ended_problems.html', {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment