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
95ef1216
Commit
95ef1216
authored
Feb 03, 2013
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extend conditional module to add require_attempted
parent
1d29e1f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
common/lib/xmodule/xmodule/capa_module.py
+4
-0
common/lib/xmodule/xmodule/conditional_module.py
+17
-2
No files found.
common/lib/xmodule/xmodule/capa_module.py
View file @
95ef1216
...
...
@@ -403,6 +403,10 @@ class CapaModule(XModule):
# return self.answer_available()
return
self
.
lcp
.
done
def
is_attempted
(
self
):
# used by conditional module
return
self
.
attempts
>
0
def
answer_available
(
self
):
''' Is the user allowed to see an answer?
'''
...
...
common/lib/xmodule/xmodule/conditional_module.py
View file @
95ef1216
...
...
@@ -19,6 +19,10 @@ class ConditionalModule(XModule):
<video url_name="secret_video" />
</conditional>
<conditional condition="require_attempted" required="tag/url_name1&tag/url_name2">
<video url_name="secret_video" />
</conditional>
'''
js
=
{
'coffee'
:
[
resource_string
(
__name__
,
'js/src/conditional/display.coffee'
),
...
...
@@ -67,6 +71,18 @@ class ConditionalModule(XModule):
else
:
log
.
debug
(
'conditional module:
%
s IS completed'
%
module
)
return
True
elif
self
.
condition
==
'require_attempted'
:
# all required modules must be attempted, as determined by
# the modules .is_attempted() method
for
module
in
self
.
required_modules
:
if
not
hasattr
(
module
,
'is_attempted'
):
raise
Exception
(
'Error in conditional module: required module
%
s has no .is_attempted() method'
%
module
)
if
not
module
.
is_attempted
():
log
.
debug
(
'conditional module:
%
s not completed'
%
module
)
return
False
else
:
log
.
debug
(
'conditional module:
%
s IS completed'
%
module
)
return
True
else
:
raise
Exception
(
'Error in conditional module: unknown condition "
%
s"'
%
self
.
condition
)
...
...
@@ -128,4 +144,4 @@ class ConditionalDescriptor(SequenceDescriptor):
"""Returns a list of XModuleDescritpor instances upon which this module depends, but are
not children of this module"""
return
[
self
.
system
.
load_item
(
loc
)
for
loc
in
self
.
required_module_locations
]
\ No newline at end of file
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