Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit 2611048

Browse files
author
Bradley Miller
committed
download log for your course
1 parent 9ab989f commit 2611048

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

controllers/admin.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from runestone import cmap
1010
from rs_grading import send_lti_grades
1111
from dateutil.parser import parse
12+
import pandas as pd
1213

1314
import logging
1415

@@ -1639,6 +1640,24 @@ def reorder_assignment_questions():
16391640
return json.dumps("Reordered in DB")
16401641

16411642

1643+
@auth.requires(lambda: verifyInstructorStatus(auth.user.course_name, auth.user), requires_login=True)
1644+
def courselog():
1645+
thecourse = db(db.courses.id == auth.user.course_id).select().first()
1646+
course = auth.user.course_name
1647+
1648+
data = pd.read_sql_query("""
1649+
select sid, useinfo.timestamp, event, div_id, chapter, subchapter
1650+
from useinfo left outer join questions on div_id = name and questions.base_course = '{}'
1651+
where course_id = 'fopp'
1652+
order by useinfo.id
1653+
""".format(thecourse.base_course, course), settings.database_uri)
1654+
data = data[~data.sid.str.contains('@')]
1655+
1656+
1657+
response.headers['Content-Type']='application/vnd.ms-excel'
1658+
response.headers['Content-Disposition']= 'attachment; filename=data_for_{}.csv'.format(auth.user.course_name)
1659+
return data.to_csv(na_rep=" ")
1660+
16421661
def killer():
16431662
print(routes_onerror)
16441663
x = 5 / 0

views/admin/admin.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ <h4 style="text-align: center" class="list-group-item-heading">Manage Students</
1717
<a id="AddInstructorTab" data-toggle="tab" href="#AddInstructor" class="list-group-item">
1818
<h4 style="text-align: center" class="list-group-item-heading">Add TA</h4>
1919
</a>
20+
<a id="courselog" href="/{{=request.application}}/admin/courselog" class="list-group-item">
21+
<h4 style="text-align: center" class="list-group-item-heading">Download Log</h4>
22+
</a>
2023
<a id="DeleteTab" data-toggle="tab" href="#Delete" class="list-group-item">
2124
<h4 style="text-align: center" class="list-group-item-heading">Delete</h4>
2225
</a>

0 commit comments

Comments
 (0)