Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
dc372692
Commit
dc372692
authored
Oct 14, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP -- figuring out how to add cs50 progress page
parent
4594d37b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
0 deletions
+97
-0
lms/djangoapps/courseware/tabs.py
+13
-0
lms/djangoapps/courseware/views.py
+46
-0
lms/lib/cs50util.py
+33
-0
lms/urls.py
+5
-0
No files found.
lms/djangoapps/courseware/tabs.py
View file @
dc372692
...
...
@@ -97,6 +97,18 @@ def _textbooks(tab, user, course, active_page):
for
index
,
textbook
in
enumerate
(
course
.
textbooks
)]
return
[]
# This is a hack for fall 2012 -- pull cs50 grades from their API when a student
# clicks on the progress tab. This might be a reasonable thing to do more
# broadly later, but will need a well defined and documented API.
def
_cs50_progress
(
tab
,
user
,
course
,
active_page
):
"""
Generates a tab that calls the CS50 gradebook API and renders progress.
"""
link
=
reverse
(
'progress50'
,
args
=
[
course
.
id
])
return
[
CourseTab
(
tab
[
'name'
],
link
,
active_page
==
'progress50'
)]
#### Validators
...
...
@@ -132,6 +144,7 @@ VALID_TAB_TYPES = {
'textbooks'
:
TabImpl
(
null_validator
,
_textbooks
),
'progress'
:
TabImpl
(
need_name
,
_progress
),
'static_tab'
:
TabImpl
(
key_checker
([
'name'
,
'url_slug'
]),
_static_tab
),
'cs50_progress'
:
TabImpl
(
key_checker
([
'name'
,
'link'
]),
_cs50_progress
),
}
...
...
lms/djangoapps/courseware/views.py
View file @
dc372692
...
...
@@ -499,3 +499,49 @@ def progress(request, course_id, student_id=None):
return
render_to_response
(
'courseware/progress.html'
,
context
)
@login_required
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
def
progress50
(
request
,
course_id
,
student_id
=
None
):
"""Show user progress for cs50. (HACK, fall 2012)
Call the cs50 api for this user
"""
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
staff_access
=
has_access
(
request
.
user
,
course
,
'staff'
)
if
student_id
is
None
or
student_id
==
request
.
user
.
id
:
# always allowed to see your own profile
student
=
request
.
user
else
:
# Requesting access to a different student's profile
if
not
staff_access
:
raise
Http404
student
=
User
.
objects
.
get
(
id
=
int
(
student_id
))
# NOTE: To make sure impersonation by instructor works, use
# student instead of request.user in the rest of the function.
# The pre-fetching of groups is done to make auth checks not require an
# additional DB lookup (this kills the Progress page in particular).
student
=
User
.
objects
.
prefetch_related
(
"groups"
)
.
get
(
id
=
student
.
id
)
student_module_cache
=
StudentModuleCache
.
cache_for_descriptor_descendents
(
course_id
,
student
,
course
)
courseware_summary
=
grades
.
progress_summary
(
student
,
request
,
course
,
student_module_cache
)
grade_summary
=
grades
.
grade
(
student
,
request
,
course
,
student_module_cache
)
if
courseware_summary
is
None
:
#This means the student didn't have access to the course (which the instructor requested)
raise
Http404
context
=
{
'course'
:
course
,
'courseware_summary'
:
courseware_summary
,
'grade_summary'
:
grade_summary
,
'staff_access'
:
staff_access
,
}
context
.
update
()
return
render_to_response
(
'courseware/progress.html'
,
context
)
lms/lib/cs50util.py
0 → 100644
View file @
dc372692
import
requests
from
urllib
import
quote_plus
from
pprint
import
pprint
def
get_cs50_grades
(
email
):
"""
"""
base_url
=
'http://apps.cs50.edx.org/'
slug
=
'5075680a-88a0-4562-8e41-7fe30a000204'
s
=
requests
.
session
()
r
=
s
.
post
(
base_url
+
'users/authenticate'
,
data
=
{
'slug'
:
slug
})
if
r
.
json
is
None
or
not
r
.
json
[
'User'
]:
# auth failed
print
"auth failed. Response:"
+
r
.
text
else
:
print
"auth response: "
+
str
(
r
.
json
)
# # What is a suite id?
suite_id
=
7
r
=
s
.
get
(
base_url
+
str
(
suite_id
))
print
'response to suite selection: '
+
r
.
text
[:
200
]
#user_token = quote_plus(r.json['User']['token'])
user_token
=
quote_plus
(
email
)
grades
=
s
.
get
(
base_url
+
"gradebook/grades/user/{0}"
.
format
(
user_token
))
#grades = s.get(base_url + "gradebook/grades/") #/user/{0}".format(user_token))
print
'grades: '
pprint
(
grades
.
json
)
lms/urls.py
View file @
dc372692
...
...
@@ -194,6 +194,11 @@ if settings.COURSEWARE_ENABLED:
'courseware.views.index'
,
name
=
"courseware_position"
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/progress$'
,
'courseware.views.progress'
,
name
=
"progress"
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/progress50$'
,
'courseware.views.progress50'
,
name
=
"progress50"
),
# Takes optional student_id for instructor use--shows profile as that student sees it.
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/progress/(?P<student_id>[^/]*)/$'
,
'courseware.views.progress'
,
name
=
"student_progress"
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment