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
22189661
Commit
22189661
authored
May 13, 2012
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor courseware cleanups. Pushing file system refs out
parent
8989605c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
12 deletions
+13
-12
djangoapps/courseware/capa/capa_problem.py
+2
-1
djangoapps/courseware/capa/responsetypes.py
+7
-7
djangoapps/courseware/modules/capa_module.py
+4
-4
No files found.
djangoapps/courseware/capa/capa_problem.py
View file @
22189661
...
...
@@ -79,13 +79,14 @@ html_skip = ["numericalresponse", "customresponse", "schematicresponse", "formul
# }
class
LoncapaProblem
(
object
):
def
__init__
(
self
,
fileobject
,
id
,
state
=
None
,
seed
=
None
):
def
__init__
(
self
,
fileobject
,
id
,
state
=
None
,
seed
=
None
,
system
=
None
):
## Initialize class variables from state
self
.
seed
=
None
self
.
student_answers
=
dict
()
self
.
correct_map
=
dict
()
self
.
done
=
False
self
.
problem_id
=
id
self
.
system
=
system
if
seed
!=
None
:
self
.
seed
=
seed
...
...
djangoapps/courseware/capa/responsetypes.py
View file @
22189661
...
...
@@ -78,7 +78,7 @@ class MultipleChoiceResponse(GenericResponse):
TODO: handle direction and randomize
'''
def
__init__
(
self
,
xml
,
context
):
def
__init__
(
self
,
xml
,
context
,
system
=
None
):
self
.
xml
=
xml
self
.
correct_choices
=
xml
.
xpath
(
'//*[@id=$id]//choice[@correct="true"]'
,
id
=
xml
.
get
(
'id'
))
...
...
@@ -134,7 +134,7 @@ class TrueFalseResponse(MultipleChoiceResponse):
class
NumericalResponse
(
GenericResponse
):
def
__init__
(
self
,
xml
,
context
):
def
__init__
(
self
,
xml
,
context
,
system
=
None
):
self
.
xml
=
xml
self
.
correct_answer
=
contextualize_text
(
xml
.
get
(
'answer'
),
context
)
try
:
...
...
@@ -212,7 +212,7 @@ def sympy_check2():
</customresponse>
'''
def
__init__
(
self
,
xml
,
context
):
def
__init__
(
self
,
xml
,
context
,
system
=
None
):
self
.
xml
=
xml
## CRITICAL TODO: Should cover all entrytypes
## NOTE: xpath will look at root of XML tree, not just
...
...
@@ -256,7 +256,7 @@ class ExternalResponse(GenericResponse):
Typically used by coding problems.
'''
def
__init__
(
self
,
xml
,
context
):
def
__init__
(
self
,
xml
,
context
,
system
=
None
):
self
.
xml
=
xml
self
.
answer_ids
=
xml
.
xpath
(
'//*[@id=$id]//textbox/@id|//*[@id=$id]//textline/@id'
,
id
=
xml
.
get
(
'id'
))
...
...
@@ -316,7 +316,7 @@ class StudentInputError(Exception):
#-----------------------------------------------------------------------------
class
FormulaResponse
(
GenericResponse
):
def
__init__
(
self
,
xml
,
context
):
def
__init__
(
self
,
xml
,
context
,
system
=
None
):
self
.
xml
=
xml
self
.
correct_answer
=
contextualize_text
(
xml
.
get
(
'answer'
),
context
)
self
.
samples
=
contextualize_text
(
xml
.
get
(
'samples'
),
context
)
...
...
@@ -397,7 +397,7 @@ class FormulaResponse(GenericResponse):
#-----------------------------------------------------------------------------
class
SchematicResponse
(
GenericResponse
):
def
__init__
(
self
,
xml
,
context
):
def
__init__
(
self
,
xml
,
context
,
system
=
None
):
self
.
xml
=
xml
self
.
answer_ids
=
xml
.
xpath
(
'//*[@id=$id]//schematic/@id'
,
id
=
xml
.
get
(
'id'
))
...
...
@@ -442,7 +442,7 @@ class ImageResponse(GenericResponse):
</imageresponse>
"""
def
__init__
(
self
,
xml
,
context
):
def
__init__
(
self
,
xml
,
context
,
system
=
None
):
self
.
xml
=
xml
self
.
context
=
context
self
.
ielements
=
xml
.
findall
(
'imageinput'
)
...
...
djangoapps/courseware/modules/capa_module.py
View file @
22189661
...
...
@@ -193,7 +193,7 @@ class Module(XModule):
seed
=
1
else
:
seed
=
None
self
.
lcp
=
LoncapaProblem
(
self
.
filestore
.
open
(
self
.
filename
),
self
.
item_id
,
state
,
seed
=
seed
)
self
.
lcp
=
LoncapaProblem
(
self
.
filestore
.
open
(
self
.
filename
),
self
.
item_id
,
state
,
seed
=
seed
,
system
=
self
.
system
)
def
handle_ajax
(
self
,
dispatch
,
get
):
'''
...
...
@@ -300,11 +300,11 @@ class Module(XModule):
lcp_id
=
self
.
lcp
.
problem_id
correct_map
=
self
.
lcp
.
grade_answers
(
answers
)
except
StudentInputError
as
inst
:
self
.
lcp
=
LoncapaProblem
(
self
.
filestore
.
open
(
self
.
filename
),
id
=
lcp_id
,
state
=
old_state
)
self
.
lcp
=
LoncapaProblem
(
self
.
filestore
.
open
(
self
.
filename
),
id
=
lcp_id
,
state
=
old_state
,
system
=
self
.
system
)
traceback
.
print_exc
()
return
json
.
dumps
({
'success'
:
inst
.
message
})
except
:
self
.
lcp
=
LoncapaProblem
(
self
.
filestore
.
open
(
self
.
filename
),
id
=
lcp_id
,
state
=
old_state
)
self
.
lcp
=
LoncapaProblem
(
self
.
filestore
.
open
(
self
.
filename
),
id
=
lcp_id
,
state
=
old_state
,
system
=
self
.
system
)
traceback
.
print_exc
()
raise
return
json
.
dumps
({
'success'
:
'Unknown Error'
})
...
...
@@ -381,7 +381,7 @@ class Module(XModule):
self
.
lcp
.
questions
=
dict
()
# Detailed info about questions in problem instance. TODO: Should be by id and not lid.
self
.
lcp
.
seed
=
None
self
.
lcp
=
LoncapaProblem
(
self
.
filestore
.
open
(
self
.
filename
),
self
.
item_id
,
self
.
lcp
.
get_state
())
self
.
lcp
=
LoncapaProblem
(
self
.
filestore
.
open
(
self
.
filename
),
self
.
item_id
,
self
.
lcp
.
get_state
()
,
system
=
self
.
system
)
event_info
[
'new_state'
]
=
self
.
lcp
.
get_state
()
self
.
tracker
(
'reset_problem'
,
event_info
)
...
...
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