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
25662db9
Commit
25662db9
authored
Aug 07, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lazily loading capa problems (for faster grading).
parent
ec04b0cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
common/lib/xmodule/xmodule/capa_module.py
+17
-9
No files found.
common/lib/xmodule/xmodule/capa_module.py
View file @
25662db9
...
...
@@ -11,13 +11,14 @@ from datetime import timedelta
from
lxml
import
etree
from
pkg_resources
import
resource_string
from
xmodule.x_module
import
XModule
from
xmodule.raw_module
import
RawDescriptor
from
xmodule.exceptions
import
NotFoundError
from
progress
import
Progress
from
capa.capa_problem
import
LoncapaProblem
from
capa.responsetypes
import
StudentInputError
from
capa.util
import
convert_files_to_filenames
from
progress
import
Progress
from
util.decorators
import
lazyproperty
from
xmodule.x_module
import
XModule
from
xmodule.raw_module
import
RawDescriptor
from
xmodule.exceptions
import
NotFoundError
log
=
logging
.
getLogger
(
"mitx.courseware"
)
...
...
@@ -118,9 +119,11 @@ class CapaModule(XModule):
if
self
.
show_answer
==
""
:
self
.
show_answer
=
"closed"
if
instance_state
is
not
None
:
instance_state
=
json
.
loads
(
instance_state
)
self
.
_instance_state
=
instance_state
# We will need this later to lazily load lcp
if
instance_state
is
not
None
and
'attempts'
in
instance_state
:
self
.
attempts
=
instance_state
[
'attempts'
]
...
...
@@ -132,16 +135,20 @@ class CapaModule(XModule):
else
:
self
.
weight
=
None
@lazyproperty
def
lcp
(
self
):
if
self
.
rerandomize
==
'never'
:
seed
=
1
elif
self
.
rerandomize
==
"per_student"
and
hasattr
(
system
,
'id'
):
seed
=
system
.
id
else
:
seed
=
None
try
:
self
.
lcp
=
LoncapaProblem
(
self
.
definition
[
'data'
],
self
.
location
.
html_id
(),
instance_state
,
seed
=
seed
,
system
=
self
.
system
)
return
LoncapaProblem
(
self
.
definition
[
'data'
],
self
.
location
.
html_id
(),
self
.
_
instance_state
,
seed
=
seed
,
system
=
self
.
system
)
except
Exception
as
err
:
msg
=
'cannot create LoncapaProblem {loc}: {err}'
.
format
(
loc
=
self
.
location
.
url
(),
err
=
err
)
...
...
@@ -158,12 +165,13 @@ class CapaModule(XModule):
problem_text
=
(
'<problem><text><font color="red" size="+2">'
'Problem
%
s has an error:</font>
%
s</text></problem>'
%
(
self
.
location
.
url
(),
msg
))
self
.
lcp
=
LoncapaProblem
(
return
LoncapaProblem
(
problem_text
,
self
.
location
.
html_id
(),
instance_state
,
seed
=
seed
,
system
=
self
.
system
)
else
:
# add extra info and raise
raise
Exception
(
msg
),
None
,
sys
.
exc_info
()[
2
]
@property
def
rerandomize
(
self
):
...
...
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