add instructor dashboard feature to download profile & problem state
This commit is contained in:
@@ -383,6 +383,46 @@ def instructor_dashboard(request, course_id):
|
||||
user.groups.remove(group)
|
||||
track.views.server_track(request, 'remove-instructor {0}'.format(user), {}, page='idashboard')
|
||||
|
||||
#----------------------------------------
|
||||
# DataDump
|
||||
|
||||
elif 'Download CSV of all student profile data' in action:
|
||||
enrolled_students = User.objects.filter(courseenrollment__course_id=course_id).order_by('username')
|
||||
profkeys = ['name', 'language', 'location', 'year_of_birth', 'gender', 'level_of_education',
|
||||
'mailing_address', 'goals']
|
||||
datatable = {'header': ['username', 'email'] + profkeys}
|
||||
def getdat(u):
|
||||
p = u.profile
|
||||
return [u.username, u.email] + [getattr(p,x,'') for x in profkeys]
|
||||
|
||||
datatable['data'] = [getdat(u) for u in enrolled_students]
|
||||
datatable['title'] = 'Student profile data for course %s' % course_id
|
||||
return return_csv('profiledata_%s.csv' % course_id, datatable)
|
||||
|
||||
|
||||
elif 'Download CSV of all responses to problem' in action:
|
||||
problem_to_dump = request.POST.get('problem_to_dump','')
|
||||
|
||||
if problem_to_dump[-4:]==".xml":
|
||||
problem_to_dump=problem_to_dump[:-4]
|
||||
try:
|
||||
(org, course_name, run)=course_id.split("/")
|
||||
module_state_key="i4x://"+org+"/"+course_name+"/problem/"+problem_to_dump
|
||||
smdat = StudentModule.objects.filter(course_id=course_id,
|
||||
module_state_key=module_state_key)
|
||||
smdat = smdat.order_by('student')
|
||||
msg+="Found module to reset. "
|
||||
except Exception as err:
|
||||
msg+="<font color='red'>Couldn't find module with that urlname. </font>"
|
||||
msg += "<pre>%s</pre>" % escape(err)
|
||||
smdat = []
|
||||
|
||||
if smdat:
|
||||
datatable = {'header': ['username', 'state']}
|
||||
datatable['data'] = [ [x.student.username, x.state] for x in smdat ]
|
||||
datatable['title'] = 'Student state for problem %s' % problem_to_dump
|
||||
return return_csv('student_state_from_%s.csv' % problem_to_dump, datatable)
|
||||
|
||||
#----------------------------------------
|
||||
# Group management
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ function goto( mode)
|
||||
<a href="#" onclick="goto('Admin');" class="${modeflag.get('Admin')}">Admin</a> |
|
||||
<a href="#" onclick="goto('Forum Admin');" class="${modeflag.get('Forum Admin')}">Forum Admin</a> |
|
||||
<a href="#" onclick="goto('Enrollment');" class="${modeflag.get('Enrollment')}">Enrollment</a> |
|
||||
<a href="#" onclick="goto('Data');" class="${modeflag.get('Data')}">DataDump</a> |
|
||||
<a href="#" onclick="goto('Manage Groups');" class="${modeflag.get('Manage Groups')}">Manage Groups</a> ]
|
||||
</h2>
|
||||
|
||||
@@ -269,6 +270,20 @@ function goto( mode)
|
||||
|
||||
##-----------------------------------------------------------------------------
|
||||
|
||||
%if modeflag.get('Data'):
|
||||
<hr width="40%" style="align:left">
|
||||
<p>
|
||||
<input type="submit" name="action" value="Download CSV of all student profile data">
|
||||
</p>
|
||||
<p> Problem urlname:
|
||||
<input type="text" name="problem_to_dump" size="40">
|
||||
<input type="submit" name="action" value="Download CSV of all responses to problem">
|
||||
</p>
|
||||
<hr width="40%" style="align:left">
|
||||
%endif
|
||||
|
||||
##-----------------------------------------------------------------------------
|
||||
|
||||
%if modeflag.get('Manage Groups'):
|
||||
%if instructor_access:
|
||||
<hr width="40%" style="align:left">
|
||||
|
||||
Reference in New Issue
Block a user