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
d42198ad
Commit
d42198ad
authored
Feb 22, 2012
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Plain Diff
Rerandomize patch merged
parents
7b27b016
c9bbc542
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
13 deletions
+24
-13
courseware/capa/capa_problem.py
+8
-1
courseware/modules/capa_module.py
+16
-12
No files found.
courseware/capa/capa_problem.py
View file @
d42198ad
...
...
@@ -53,7 +53,7 @@ html_special_response = {"textline":textline.render,
"schematic"
:
schematic
.
render
}
class
LoncapaProblem
(
object
):
def
__init__
(
self
,
filename
,
id
=
None
,
state
=
None
):
def
__init__
(
self
,
filename
,
id
=
None
,
state
=
None
,
seed
=
None
):
## Initialize class variables from state
self
.
seed
=
None
self
.
student_answers
=
dict
()
...
...
@@ -61,6 +61,9 @@ class LoncapaProblem(object):
self
.
done
=
False
self
.
filename
=
filename
if
seed
!=
None
:
self
.
seed
=
seed
if
id
:
self
.
problem_id
=
id
else
:
...
...
@@ -78,10 +81,14 @@ class LoncapaProblem(object):
if
'done'
in
state
:
self
.
done
=
state
[
'done'
]
# print self.seed
# TODO: Does this deplete the Linux entropy pool? Is this fast enough?
if
not
self
.
seed
:
self
.
seed
=
struct
.
unpack
(
'i'
,
os
.
urandom
(
4
))[
0
]
# print filename, self.seed, seed
## Parse XML file
#log.debug(u"LoncapaProblem() opening file {0}".format(filename))
file_text
=
open
(
filename
)
.
read
()
...
...
courseware/modules/capa_module.py
View file @
d42198ad
...
...
@@ -81,7 +81,7 @@ class Module(XModule):
# User submitted a problem, and hasn't reset. We don't want
# more submissions.
if
self
.
lcp
.
done
and
self
.
rerandomize
:
if
self
.
lcp
.
done
and
self
.
rerandomize
==
"always"
:
#print "!"
check_button
=
False
save_button
=
False
...
...
@@ -95,7 +95,7 @@ class Module(XModule):
attempts_str
=
" ({a}/{m})"
.
format
(
a
=
self
.
attempts
,
m
=
self
.
max_attempts
)
# We don't need a "save" button if infinite number of attempts and non-randomized
if
self
.
max_attempts
==
None
and
self
.
rerandomize
==
False
:
if
self
.
max_attempts
==
None
and
self
.
rerandomize
!=
"always"
:
save_button
=
False
# Check if explanation is available, and if so, give a link
...
...
@@ -164,12 +164,12 @@ class Module(XModule):
self
.
show_answer
=
"closed"
self
.
rerandomize
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@rerandomize'
))
if
self
.
rerandomize
==
""
:
self
.
rerandomize
=
True
elif
self
.
rerandomize
==
"false"
:
self
.
rerandomize
=
False
elif
self
.
rerandomize
==
"
true
"
:
self
.
rerandomize
=
True
if
self
.
rerandomize
==
""
or
self
.
rerandomize
==
"always"
or
self
.
rerandomize
==
"true"
:
self
.
rerandomize
=
"always"
elif
self
.
rerandomize
==
"false"
or
self
.
rerandomize
==
"per_student"
:
self
.
rerandomize
=
"per_student"
elif
self
.
rerandomize
==
"
never
"
:
self
.
rerandomize
=
"never"
else
:
raise
Exception
(
"Invalid rerandomize attribute "
+
self
.
rerandomize
)
...
...
@@ -181,7 +181,11 @@ class Module(XModule):
self
.
filename
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@filename'
))
filename
=
settings
.
DATA_DIR
+
"/problems/"
+
self
.
filename
+
".xml"
self
.
name
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@name'
))
self
.
lcp
=
LoncapaProblem
(
filename
,
self
.
item_id
,
state
)
if
self
.
rerandomize
==
'never'
:
seed
=
1
else
:
seed
=
None
self
.
lcp
=
LoncapaProblem
(
filename
,
self
.
item_id
,
state
,
seed
=
seed
)
def
handle_ajax
(
self
,
dispatch
,
get
):
if
dispatch
==
'problem_get'
:
...
...
@@ -270,7 +274,7 @@ class Module(XModule):
# Problem submitted. Student should reset before checking
# again.
if
self
.
lcp
.
done
and
self
.
rerandomize
:
if
self
.
lcp
.
done
and
self
.
rerandomize
==
"always"
:
event_info
[
'failure'
]
=
'unreset'
self
.
tracker
(
'save_problem_check_fail'
,
event_info
)
print
"cpdr"
...
...
@@ -331,7 +335,7 @@ class Module(XModule):
# Problem submitted. Student should reset before saving
# again.
if
self
.
lcp
.
done
and
self
.
rerandomize
:
if
self
.
lcp
.
done
and
self
.
rerandomize
==
"always"
:
event_info
[
'failure'
]
=
'done'
self
.
tracker
(
'save_problem_fail'
,
event_info
)
return
"Problem needs to be reset prior to save."
...
...
@@ -364,7 +368,7 @@ class Module(XModule):
self
.
lcp
.
student_answers
=
dict
()
if
self
.
rerandomize
:
if
self
.
rerandomize
==
"always"
:
self
.
lcp
.
context
=
dict
()
self
.
lcp
.
questions
=
dict
()
# Detailed info about questions in problem instance. TODO: Should be by id and not lid.
self
.
lcp
.
seed
=
None
...
...
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