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
5bf39fef
Commit
5bf39fef
authored
Nov 19, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cherry pick the test-cleanup parts of e2826cb.
- look up test courses by id, not name
parent
4f359ea5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
28 deletions
+33
-28
common/lib/xmodule/xmodule/modulestore/__init__.py
+13
-0
lms/djangoapps/courseware/tests/tests.py
+5
-14
lms/djangoapps/instructor/tests.py
+13
-12
lms/djangoapps/instructor/views.py
+2
-2
No files found.
common/lib/xmodule/xmodule/modulestore/__init__.py
View file @
5bf39fef
...
@@ -339,6 +339,12 @@ class ModuleStore(object):
...
@@ -339,6 +339,12 @@ class ModuleStore(object):
'''
'''
raise
NotImplementedError
raise
NotImplementedError
def
get_course
(
self
,
course_id
):
'''
Look for a specific course id. Returns the course descriptor, or None if not found.
'''
raise
NotImplementedError
def
get_parent_locations
(
self
,
location
):
def
get_parent_locations
(
self
,
location
):
'''Find all locations that are the parents of this location. Needed
'''Find all locations that are the parents of this location. Needed
for path_to_location().
for path_to_location().
...
@@ -399,3 +405,10 @@ class ModuleStoreBase(ModuleStore):
...
@@ -399,3 +405,10 @@ class ModuleStoreBase(ModuleStore):
errorlog
=
self
.
_get_errorlog
(
location
)
errorlog
=
self
.
_get_errorlog
(
location
)
return
errorlog
.
errors
return
errorlog
.
errors
def
get_course
(
self
,
course_id
):
"""Default impl--linear search through course list"""
for
c
in
self
.
get_courses
():
if
c
.
id
==
course_id
:
return
c
return
None
lms/djangoapps/courseware/tests/tests.py
View file @
5bf39fef
...
@@ -288,14 +288,10 @@ class TestNavigation(PageLoader):
...
@@ -288,14 +288,10 @@ class TestNavigation(PageLoader):
def
setUp
(
self
):
def
setUp
(
self
):
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
courses
=
modulestore
()
.
get_courses
()
def
find_course
(
course_id
):
"""Assumes the course is present"""
return
[
c
for
c
in
courses
if
c
.
id
==
course_id
][
0
]
self
.
full
=
find_course
(
"edX/full/6.002_Spring_2012"
)
# Assume courses are there
self
.
toy
=
find_course
(
"edX/toy/2012_Fall"
)
self
.
full
=
modulestore
()
.
get_course
(
"edX/full/6.002_Spring_2012"
)
self
.
toy
=
modulestore
()
.
get_course
(
"edX/toy/2012_Fall"
)
# Create two accounts
# Create two accounts
self
.
student
=
'view@test.com'
self
.
student
=
'view@test.com'
...
@@ -346,14 +342,9 @@ class TestViewAuth(PageLoader):
...
@@ -346,14 +342,9 @@ class TestViewAuth(PageLoader):
def
setUp
(
self
):
def
setUp
(
self
):
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
courses
=
modulestore
()
.
get_courses
()
def
find_course
(
course_id
):
"""Assumes the course is present"""
return
[
c
for
c
in
courses
if
c
.
id
==
course_id
][
0
]
self
.
full
=
find
_course
(
"edX/full/6.002_Spring_2012"
)
self
.
full
=
modulestore
()
.
get
_course
(
"edX/full/6.002_Spring_2012"
)
self
.
toy
=
find
_course
(
"edX/toy/2012_Fall"
)
self
.
toy
=
modulestore
()
.
get
_course
(
"edX/toy/2012_Fall"
)
# Create two accounts
# Create two accounts
self
.
student
=
'view@test.com'
self
.
student
=
'view@test.com'
...
...
lms/djangoapps/instructor/tests.py
View file @
5bf39fef
...
@@ -33,12 +33,8 @@ class TestInstructorDashboardGradeDownloadCSV(ct.PageLoader):
...
@@ -33,12 +33,8 @@ class TestInstructorDashboardGradeDownloadCSV(ct.PageLoader):
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
courses
=
modulestore
()
.
get_courses
()
courses
=
modulestore
()
.
get_courses
()
def
find_course
(
name
):
self
.
full
=
modulestore
()
.
get_course
(
"edX/full/6.002_Spring_2012"
)
"""Assumes the course is present"""
self
.
toy
=
modulestore
()
.
get_course
(
"edX/toy/2012_Fall"
)
return
[
c
for
c
in
courses
if
c
.
location
.
course
==
name
][
0
]
self
.
full
=
find_course
(
"full"
)
self
.
toy
=
find_course
(
"toy"
)
# Create two accounts
# Create two accounts
self
.
student
=
'view@test.com'
self
.
student
=
'view@test.com'
...
@@ -49,9 +45,12 @@ class TestInstructorDashboardGradeDownloadCSV(ct.PageLoader):
...
@@ -49,9 +45,12 @@ class TestInstructorDashboardGradeDownloadCSV(ct.PageLoader):
self
.
activate_user
(
self
.
student
)
self
.
activate_user
(
self
.
student
)
self
.
activate_user
(
self
.
instructor
)
self
.
activate_user
(
self
.
instructor
)
group_name
=
_course_staff_group_name
(
self
.
toy
.
location
)
def
make_instructor
(
course
):
g
=
Group
.
objects
.
create
(
name
=
group_name
)
group_name
=
_course_staff_group_name
(
course
.
location
)
g
.
user_set
.
add
(
ct
.
user
(
self
.
instructor
))
g
=
Group
.
objects
.
create
(
name
=
group_name
)
g
.
user_set
.
add
(
ct
.
user
(
self
.
instructor
))
make_instructor
(
self
.
toy
)
self
.
logout
()
self
.
logout
()
self
.
login
(
self
.
instructor
,
self
.
password
)
self
.
login
(
self
.
instructor
,
self
.
password
)
...
@@ -67,9 +66,9 @@ class TestInstructorDashboardGradeDownloadCSV(ct.PageLoader):
...
@@ -67,9 +66,9 @@ class TestInstructorDashboardGradeDownloadCSV(ct.PageLoader):
self
.
assertEqual
(
response
[
'Content-Type'
],
'text/csv'
,
msg
)
self
.
assertEqual
(
response
[
'Content-Type'
],
'text/csv'
,
msg
)
cdisp
=
response
[
'Content-Disposition'
]
.
replace
(
'TT_2012'
,
'2012'
)
# jenkins course_id is TT_2012_Fall instead of 2012_Fall?
cdisp
=
response
[
'Content-Disposition'
]
msg
+=
"
cdisp = '{0}'
\n
"
.
format
(
cdisp
)
msg
+=
"
Content-Disposition = '
%
s'
\n
"
%
cdisp
self
.
assertEqual
(
cdisp
,
'attachment; filename=grades_edX/toy/2012_Fall.csv'
,
msg
)
self
.
assertEqual
(
cdisp
,
'attachment; filename=grades_{0}.csv'
.
format
(
course
.
id
),
msg
)
body
=
response
.
content
.
replace
(
'
\r
'
,
''
)
body
=
response
.
content
.
replace
(
'
\r
'
,
''
)
msg
+=
"body = '{0}'
\n
"
.
format
(
body
)
msg
+=
"body = '{0}'
\n
"
.
format
(
body
)
...
@@ -77,6 +76,8 @@ class TestInstructorDashboardGradeDownloadCSV(ct.PageLoader):
...
@@ -77,6 +76,8 @@ class TestInstructorDashboardGradeDownloadCSV(ct.PageLoader):
expected_body
=
'''"ID","Username","Full Name","edX email","External email","HW 01","HW 02","HW 03","HW 04","HW 05","HW 06","HW 07","HW 08","HW 09","HW 10","HW 11","HW 12","HW Avg","Lab 01","Lab 02","Lab 03","Lab 04","Lab 05","Lab 06","Lab 07","Lab 08","Lab 09","Lab 10","Lab 11","Lab 12","Lab Avg","Midterm","Final"
expected_body
=
'''"ID","Username","Full Name","edX email","External email","HW 01","HW 02","HW 03","HW 04","HW 05","HW 06","HW 07","HW 08","HW 09","HW 10","HW 11","HW 12","HW Avg","Lab 01","Lab 02","Lab 03","Lab 04","Lab 05","Lab 06","Lab 07","Lab 08","Lab 09","Lab 10","Lab 11","Lab 12","Lab Avg","Midterm","Final"
"2","u2","Fred Weasley","view2@test.com","","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0.0","0.0"
"2","u2","Fred Weasley","view2@test.com","","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0.0","0.0"
'''
'''
# All the not-actually-in-the-course hw and labs come from the
# default grading policy string in graders.py
self
.
assertEqual
(
body
,
expected_body
,
msg
)
self
.
assertEqual
(
body
,
expected_body
,
msg
)
FORUM_ROLES
=
[
FORUM_ROLE_ADMINISTRATOR
,
FORUM_ROLE_MODERATOR
,
FORUM_ROLE_COMMUNITY_TA
]
FORUM_ROLES
=
[
FORUM_ROLE_ADMINISTRATOR
,
FORUM_ROLE_MODERATOR
,
FORUM_ROLE_COMMUNITY_TA
]
...
...
lms/djangoapps/instructor/views.py
View file @
5bf39fef
...
@@ -90,7 +90,7 @@ def instructor_dashboard(request, course_id):
...
@@ -90,7 +90,7 @@ def instructor_dashboard(request, course_id):
try
:
try
:
group
=
Group
.
objects
.
get
(
name
=
staffgrp
)
group
=
Group
.
objects
.
get
(
name
=
staffgrp
)
except
Group
.
DoesNotExist
:
except
Group
.
DoesNotExist
:
group
=
Group
(
name
=
staffgrp
)
# create the group
group
=
Group
(
name
=
staffgrp
)
# create the group
group
.
save
()
group
.
save
()
return
group
return
group
...
@@ -380,7 +380,7 @@ def get_student_grade_summary_data(request, course, course_id, get_grades=True,
...
@@ -380,7 +380,7 @@ def get_student_grade_summary_data(request, course, course_id, get_grades=True,
enrolled_students
=
User
.
objects
.
filter
(
courseenrollment__course_id
=
course_id
)
.
prefetch_related
(
"groups"
)
.
order_by
(
'username'
)
enrolled_students
=
User
.
objects
.
filter
(
courseenrollment__course_id
=
course_id
)
.
prefetch_related
(
"groups"
)
.
order_by
(
'username'
)
header
=
[
'ID'
,
'Username'
,
'Full Name'
,
'edX email'
,
'External email'
]
header
=
[
'ID'
,
'Username'
,
'Full Name'
,
'edX email'
,
'External email'
]
if
get_grades
:
if
get_grades
and
enrolled_students
.
count
()
>
0
:
# just to construct the header
# just to construct the header
gradeset
=
grades
.
grade
(
enrolled_students
[
0
],
request
,
course
,
keep_raw_scores
=
get_raw_scores
)
gradeset
=
grades
.
grade
(
enrolled_students
[
0
],
request
,
course
,
keep_raw_scores
=
get_raw_scores
)
# log.debug('student {0} gradeset {1}'.format(enrolled_students[0], gradeset))
# log.debug('student {0} gradeset {1}'.format(enrolled_students[0], gradeset))
...
...
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