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
2aa24350
Commit
2aa24350
authored
Mar 12, 2013
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate the randomize module to the new storage model
parent
222aca70
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
17 deletions
+9
-17
common/lib/xmodule/xmodule/randomize_module.py
+9
-17
No files found.
common/lib/xmodule/xmodule/randomize_module.py
View file @
2aa24350
...
...
@@ -36,29 +36,25 @@ class RandomizeModule(XModule):
modules.
"""
def
__init__
(
self
,
system
,
location
,
definition
,
descriptor
,
instance_state
=
None
,
shared_state
=
None
,
**
kwargs
):
XModule
.
__init__
(
self
,
system
,
location
,
definition
,
descriptor
,
instance_state
,
shared_state
,
**
kwargs
)
choice
=
Integer
(
help
=
"Which random child was chosen"
,
scope
=
Scope
.
student_state
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
XModule
.
__init__
(
self
,
*
args
,
**
kwargs
)
# NOTE: calling self.get_children() creates a circular reference--
# it calls get_child_descriptors() internally, but that doesn't work until
# we've picked a choice
num_choices
=
len
(
self
.
descriptor
.
get_children
())
self
.
choice
=
None
if
instance_state
is
not
None
:
state
=
json
.
loads
(
instance_state
)
self
.
choice
=
state
.
get
(
'choice'
,
None
)
if
self
.
choice
>
num_choices
:
# Oops. Children changed. Reset.
self
.
choice
=
None
if
self
.
choice
>
num_choices
:
# Oops. Children changed. Reset.
self
.
choice
=
None
if
self
.
choice
is
None
:
# choose one based on the system seed, or randomly if that's not available
if
num_choices
>
0
:
if
system
.
seed
is
not
None
:
self
.
choice
=
system
.
seed
%
num_choices
if
s
elf
.
s
ystem
.
seed
is
not
None
:
self
.
choice
=
s
elf
.
s
ystem
.
seed
%
num_choices
else
:
self
.
choice
=
random
.
randrange
(
0
,
num_choices
)
...
...
@@ -73,10 +69,6 @@ class RandomizeModule(XModule):
self
.
child
=
None
def
get_instance_state
(
self
):
return
json
.
dumps
({
'choice'
:
self
.
choice
})
def
get_child_descriptors
(
self
):
"""
For grading--return just the chosen child.
...
...
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