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
8660c9a7
Commit
8660c9a7
authored
May 15, 2013
by
Brian Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check descriptor to identify problems that don't support regrading.
parent
73b25e1f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
15 deletions
+29
-15
common/lib/xmodule/xmodule/capa_module.py
+2
-2
common/lib/xmodule/xmodule/tests/test_capa_module.py
+2
-3
lms/djangoapps/courseware/task_queue.py
+25
-10
No files found.
common/lib/xmodule/xmodule/capa_module.py
View file @
8660c9a7
...
@@ -823,7 +823,7 @@ class CapaModule(CapaFields, XModule):
...
@@ -823,7 +823,7 @@ class CapaModule(CapaFields, XModule):
{'success' : 'correct' | 'incorrect' | AJAX alert msg string }
{'success' : 'correct' | 'incorrect' | AJAX alert msg string }
Raises NotFoundError if called on a problem that has not yet been
Raises NotFoundError if called on a problem that has not yet been
answered, or if it's a problem that cannot be regraded.
answered, or
NotImplementedError
if it's a problem that cannot be regraded.
Returns the error messages for exceptions occurring while performing
Returns the error messages for exceptions occurring while performing
the regrading, rather than throwing them.
the regrading, rather than throwing them.
...
@@ -835,7 +835,7 @@ class CapaModule(CapaFields, XModule):
...
@@ -835,7 +835,7 @@ class CapaModule(CapaFields, XModule):
if
not
self
.
lcp
.
supports_regrading
():
if
not
self
.
lcp
.
supports_regrading
():
event_info
[
'failure'
]
=
'unsupported'
event_info
[
'failure'
]
=
'unsupported'
self
.
system
.
track_function
(
'problem_regrade_fail'
,
event_info
)
self
.
system
.
track_function
(
'problem_regrade_fail'
,
event_info
)
raise
Not
FoundError
(
'Problem does not support regrading'
)
raise
Not
ImplementedError
(
"Problem's definition does not support regrading"
)
if
not
self
.
done
:
if
not
self
.
done
:
event_info
[
'failure'
]
=
'unanswered'
event_info
[
'failure'
]
=
'unanswered'
...
...
common/lib/xmodule/xmodule/tests/test_capa_module.py
View file @
8660c9a7
...
@@ -642,13 +642,12 @@ class CapaModuleTest(unittest.TestCase):
...
@@ -642,13 +642,12 @@ class CapaModuleTest(unittest.TestCase):
module
.
regrade_problem
()
module
.
regrade_problem
()
def
test_regrade_problem_not_supported
(
self
):
def
test_regrade_problem_not_supported
(
self
):
# Simulate that the problem is NOT done
module
=
CapaFactory
.
create
(
done
=
True
)
module
=
CapaFactory
.
create
(
done
=
True
)
# Try to regrade the problem, and get exception
# Try to regrade the problem, and get exception
with
patch
(
'capa.capa_problem.LoncapaProblem.supports_regrading'
)
as
mock_supports_regrading
:
with
patch
(
'capa.capa_problem.LoncapaProblem.supports_regrading'
)
as
mock_supports_regrading
:
mock_supports_regrading
.
return_value
=
False
mock_supports_regrading
.
return_value
=
False
with
self
.
assertRaises
(
xmodule
.
exceptions
.
NotFoun
dError
):
with
self
.
assertRaises
(
NotImplemente
dError
):
module
.
regrade_problem
()
module
.
regrade_problem
()
def
test_regrade_problem_error
(
self
):
def
test_regrade_problem_error
(
self
):
...
@@ -668,7 +667,7 @@ class CapaModuleTest(unittest.TestCase):
...
@@ -668,7 +667,7 @@ class CapaModuleTest(unittest.TestCase):
# Expect an AJAX alert message in 'success'
# Expect an AJAX alert message in 'success'
expected_msg
=
'Error: test error'
expected_msg
=
'Error: test error'
self
.
assertEqual
(
expected_msg
,
result
[
'success'
]
)
self
.
assertEqual
(
result
[
'success'
],
expected_msg
)
# Expect that the number of attempts is NOT incremented
# Expect that the number of attempts is NOT incremented
self
.
assertEqual
(
module
.
attempts
,
1
)
self
.
assertEqual
(
module
.
attempts
,
1
)
...
...
lms/djangoapps/courseware/task_queue.py
View file @
8660c9a7
...
@@ -297,6 +297,26 @@ def _get_task_completion_message(course_task_log_entry):
...
@@ -297,6 +297,26 @@ def _get_task_completion_message(course_task_log_entry):
########### Add task-submission methods here:
########### Add task-submission methods here:
def
_check_arguments_for_regrading
(
course_id
,
problem_url
):
"""
Do simple checks on the descriptor to confirm that it supports regrading.
Confirms first that the problem_url is defined (since that's currently typed
in). An ItemNotFoundException is raised if the corresponding module
descriptor doesn't exist. NotImplementedError is returned if the
corresponding module doesn't support regrading calls.
"""
descriptor
=
modulestore
()
.
get_instance
(
course_id
,
problem_url
)
supports_regrade
=
False
if
hasattr
(
descriptor
,
'module_class'
):
module_class
=
descriptor
.
module_class
if
hasattr
(
module_class
,
'regrade_problem'
):
supports_regrade
=
True
if
not
supports_regrade
:
msg
=
"Specified module does not support regrading."
raise
NotImplementedError
(
msg
)
def
submit_regrade_problem_for_student
(
request
,
course_id
,
problem_url
,
student
):
def
submit_regrade_problem_for_student
(
request
,
course_id
,
problem_url
,
student
):
"""
"""
...
@@ -309,10 +329,8 @@ def submit_regrade_problem_for_student(request, course_id, problem_url, student)
...
@@ -309,10 +329,8 @@ def submit_regrade_problem_for_student(request, course_id, problem_url, student)
An exception is thrown if the problem doesn't exist, or if the particular
An exception is thrown if the problem doesn't exist, or if the particular
problem is already being regraded for this student.
problem is already being regraded for this student.
"""
"""
# check arguments: make sure that the problem_url is defined
# check arguments: let exceptions return up to the caller.
# (since that's currently typed in). If the corresponding module descriptor doesn't exist,
_check_arguments_for_regrading
(
course_id
,
problem_url
)
# an exception will be raised. Let it pass up to the caller.
modulestore
()
.
get_instance
(
course_id
,
problem_url
)
task_name
=
'regrade_problem'
task_name
=
'regrade_problem'
...
@@ -341,14 +359,11 @@ def submit_regrade_problem_for_all_students(request, course_id, problem_url):
...
@@ -341,14 +359,11 @@ def submit_regrade_problem_for_all_students(request, course_id, problem_url):
An exception is thrown if the problem doesn't exist, or if the particular
An exception is thrown if the problem doesn't exist, or if the particular
problem is already being regraded.
problem is already being regraded.
"""
"""
# check arguments: make sure that the problem_url is defined
# check arguments: let exceptions return up to the caller.
# (since that's currently typed in). If the corresponding module descriptor doesn't exist,
_check_arguments_for_regrading
(
course_id
,
problem_url
)
# an exception will be raised. Let it pass up to the caller.
modulestore
()
.
get_instance
(
course_id
,
problem_url
)
task_name
=
'regrade_problem'
# check to see if task is already running, and reserve it otherwise
# check to see if task is already running, and reserve it otherwise
task_name
=
'regrade_problem'
course_task_log
=
_reserve_task
(
course_id
,
task_name
,
problem_url
,
request
.
user
)
course_task_log
=
_reserve_task
(
course_id
,
task_name
,
problem_url
,
request
.
user
)
# Submit task:
# Submit task:
...
...
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