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
67ada1fb
Commit
67ada1fb
authored
Feb 08, 2013
by
Vasyl Nakvasiuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add docstrings
parent
f903bc3c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
11 deletions
+17
-11
common/lib/xmodule/xmodule/conditional_module.py
+17
-10
common/lib/xmodule/xmodule/poll_module.py
+0
-1
No files found.
common/lib/xmodule/xmodule/conditional_module.py
View file @
67ada1fb
# -*- coding: utf-8 -*-
"""Conditional module is the xmodule, which you can use for disabling
some xmodules by conditions.
"""
import
json
import
json
import
logging
import
logging
...
@@ -20,7 +22,8 @@ class ConditionalModule(XModule):
...
@@ -20,7 +22,8 @@ class ConditionalModule(XModule):
Example:
Example:
<conditional condition="require_completed" required="tag/url_name1&tag/url_name2">
<conditional sources="i4x://.../problem_1" completed="True">
<show sources="i4x://.../test_6; i4x://.../Avi_resources"/>
<video url_name="secret_video" />
<video url_name="secret_video" />
</conditional>
</conditional>
...
@@ -37,7 +40,9 @@ class ConditionalModule(XModule):
...
@@ -37,7 +40,9 @@ class ConditionalModule(XModule):
contents
=
String
(
scope
=
Scope
.
content
)
contents
=
String
(
scope
=
Scope
.
content
)
# TODO
# Map
# key: <tag attribute in xml>
# value: <name of module attribute>
conditions_map
=
{
conditions_map
=
{
'poll_answer'
:
'poll_answer'
,
# poll_question attr
'poll_answer'
:
'poll_answer'
,
# poll_question attr
'compeleted'
:
'is_competed'
,
# capa_problem attr
'compeleted'
:
'is_competed'
,
# capa_problem attr
...
@@ -45,7 +50,7 @@ class ConditionalModule(XModule):
...
@@ -45,7 +50,7 @@ class ConditionalModule(XModule):
}
}
def
_get_condition
(
self
):
def
_get_condition
(
self
):
#
get first valid contition
#
Get first valid condition.
for
xml_attr
,
attr_name
in
self
.
conditions_map
.
iteritems
():
for
xml_attr
,
attr_name
in
self
.
conditions_map
.
iteritems
():
xml_value
=
self
.
descriptor
.
xml_attributes
.
get
(
xml_attr
)
xml_value
=
self
.
descriptor
.
xml_attributes
.
get
(
xml_attr
)
if
xml_value
:
if
xml_value
:
...
@@ -80,17 +85,19 @@ class ConditionalModule(XModule):
...
@@ -80,17 +85,19 @@ class ConditionalModule(XModule):
})
})
def
handle_ajax
(
self
,
dispatch
,
post
):
def
handle_ajax
(
self
,
dispatch
,
post
):
'''
"""This is called by courseware.moduleodule_render, to handle
This is called by courseware.moduleodule_render, to handle
an AJAX call.
an AJAX call.
'''
"""
if
not
self
.
is_condition_satisfied
():
if
not
self
.
is_condition_satisfied
():
context
=
{
'module'
:
self
}
context
=
{
'module'
:
self
}
html
=
self
.
system
.
render_template
(
'conditional_module.html'
,
context
)
html
=
self
.
system
.
render_template
(
'conditional_module.html'
,
context
)
return
json
.
dumps
({
'html'
:
[
html
]})
return
json
.
dumps
({
'html'
:
[
html
]})
if
self
.
contents
is
None
:
if
self
.
contents
is
None
:
self
.
contents
=
[
self
.
system
.
get_module
(
child_descriptor
.
location
)
.
get_html
()
self
.
contents
=
[
self
.
system
.
get_module
(
child_descriptor
.
location
for
child_descriptor
in
self
.
descriptor
.
get_children
()]
)
.
get_html
()
for
child_descriptor
in
self
.
descriptor
.
get_children
()]
html
=
self
.
contents
html
=
self
.
contents
return
json
.
dumps
({
'html'
:
html
})
return
json
.
dumps
({
'html'
:
html
})
...
...
common/lib/xmodule/xmodule/poll_module.py
View file @
67ada1fb
...
@@ -6,7 +6,6 @@ If student does not yet anwered - Question with set of choices.
...
@@ -6,7 +6,6 @@ If student does not yet anwered - Question with set of choices.
If student have answered - Question with statistics for each answers.
If student have answered - Question with statistics for each answers.
Student can't change his answer.
Student can't change his answer.
"""
"""
import
cgi
import
cgi
...
...
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