Added instructor tools for resetting attempts on a single student's problem to 0 and for getting student's progress page
This commit is contained in:
@@ -7,6 +7,7 @@ import logging
|
||||
import os
|
||||
import requests
|
||||
import urllib
|
||||
import json
|
||||
|
||||
from StringIO import StringIO
|
||||
|
||||
@@ -25,6 +26,7 @@ from django_comment_client.models import Role, FORUM_ROLE_ADMINISTRATOR, FORUM_R
|
||||
from django_comment_client.utils import has_forum_access
|
||||
from psychometrics import psychoanalyze
|
||||
from student.models import CourseEnrollment, CourseEnrollmentAllowed
|
||||
from courseware.models import StudentModule
|
||||
from xmodule.course_module import CourseDescriptor
|
||||
from xmodule.modulestore import Location
|
||||
from xmodule.modulestore.django import modulestore
|
||||
@@ -172,6 +174,56 @@ def instructor_dashboard(request, course_id):
|
||||
track.views.server_track(request, 'dump-answer-dist-csv', {}, page='idashboard')
|
||||
return return_csv('answer_dist_{0}.csv'.format(course_id), get_answers_distribution(request, course_id))
|
||||
|
||||
elif "Reset student's attempts" in action:
|
||||
# get the form data
|
||||
unique_student_identifier=request.POST.get('unique_student_identifier','')
|
||||
problem_to_reset=request.POST.get('problem_to_reset','')
|
||||
|
||||
if problem_to_reset[-4:]==".xml":
|
||||
problem_to_reset=problem_to_reset[:-4]
|
||||
|
||||
# try to uniquely id student by email address or username
|
||||
try:
|
||||
if "@" in unique_student_identifier:
|
||||
student_to_reset=User.objects.get(email=unique_student_identifier)
|
||||
else:
|
||||
student_to_reset=User.objects.get(username=unique_student_identifier)
|
||||
msg+="Found a single student to reset. "
|
||||
except:
|
||||
msg+="<font color='red'>Couldn't find student to reset. </font>"
|
||||
|
||||
# find the module in question
|
||||
try:
|
||||
module_to_reset=StudentModule.objects.get(student_id=student_to_reset.id, course_id=course_id, module_state_key__iendswith="/problem/"+problem_to_reset)
|
||||
msg+="Found module to reset. "
|
||||
except Exception as e:
|
||||
msg+="<font color='red'>Couldn't find module to reset. </font>"
|
||||
|
||||
# modify the problem's state
|
||||
try:
|
||||
# load the state json
|
||||
problem_state=json.loads(module_to_reset.state)
|
||||
problem_state["attempts"]=0
|
||||
|
||||
# save
|
||||
module_to_reset.state=json.dumps(problem_state)
|
||||
module_to_reset.save()
|
||||
msg+="<font color='green'>Module state successfully reset!</font>"
|
||||
except:
|
||||
msg+="<font color='red'>Couldn't reset module state. </font>"
|
||||
|
||||
|
||||
elif "Get link to student's progress page" in action:
|
||||
unique_student_identifier=request.POST.get('unique_student_identifier','')
|
||||
try:
|
||||
if "@" in unique_student_identifier:
|
||||
student_to_reset=User.objects.get(email=unique_student_identifier)
|
||||
else:
|
||||
student_to_reset=User.objects.get(username=unique_student_identifier)
|
||||
msg+="<a href='./progress/{0}' target='_blank'> Progress page for username: {1} with email address: {2}</a>.".format(str(student_to_reset.id),student_to_reset.username,student_to_reset.email)
|
||||
except:
|
||||
msg+="<font color='red'>Couldn't find student with that username. </font>"
|
||||
|
||||
#----------------------------------------
|
||||
# export grades to remote gradebook
|
||||
|
||||
|
||||
@@ -138,6 +138,11 @@ function goto( mode)
|
||||
|
||||
%endif
|
||||
|
||||
<H2>Student-specific grade inspection and adjustment</h2>
|
||||
<p>edX email address or their username: </p>
|
||||
<p><input type="text" name="unique_student_identifier"> <input type="submit" name="action" value="Get link to student's progress page"></p>
|
||||
<p>and, if you want to reset the number of attempts for a problem, the urlname of that problem</p>
|
||||
<p> <input type="text" name="problem_to_reset"> <input type="submit" name="action" value="Reset student's attempts"> </p>
|
||||
%endif
|
||||
|
||||
##-----------------------------------------------------------------------------
|
||||
@@ -260,6 +265,9 @@ function goto( mode)
|
||||
|
||||
</form>
|
||||
|
||||
%if msg:
|
||||
<p></p><p>${msg}</p>
|
||||
%endif
|
||||
##-----------------------------------------------------------------------------
|
||||
##-----------------------------------------------------------------------------
|
||||
|
||||
@@ -312,9 +320,6 @@ function goto( mode)
|
||||
##-----------------------------------------------------------------------------
|
||||
## always show msg
|
||||
|
||||
%if msg:
|
||||
<p>${msg}</p>
|
||||
%endif
|
||||
|
||||
##-----------------------------------------------------------------------------
|
||||
%if modeflag.get('Admin'):
|
||||
|
||||
Reference in New Issue
Block a user