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
52594186
Commit
52594186
authored
Aug 08, 2012
by
John Hess
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basic survey module
parent
ebd0458d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
1 deletions
+100
-1
common/lib/xmodule/setup.py
+1
-0
common/lib/xmodule/xmodule/survey_module.py
+98
-0
lms/templates/problem.html
+1
-1
No files found.
common/lib/xmodule/setup.py
View file @
52594186
...
@@ -31,6 +31,7 @@ setup(
...
@@ -31,6 +31,7 @@ setup(
"section = xmodule.backcompat_module:SemanticSectionDescriptor"
,
"section = xmodule.backcompat_module:SemanticSectionDescriptor"
,
"sequential = xmodule.seq_module:SequenceDescriptor"
,
"sequential = xmodule.seq_module:SequenceDescriptor"
,
"slides = xmodule.backcompat_module:TranslateCustomTagDescriptor"
,
"slides = xmodule.backcompat_module:TranslateCustomTagDescriptor"
,
"survey = xmodule.survey_module:SurveyDescriptor"
,
"vertical = xmodule.vertical_module:VerticalDescriptor"
,
"vertical = xmodule.vertical_module:VerticalDescriptor"
,
"video = xmodule.video_module:VideoDescriptor"
,
"video = xmodule.video_module:VideoDescriptor"
,
"videodev = xmodule.backcompat_module:TranslateCustomTagDescriptor"
,
"videodev = xmodule.backcompat_module:TranslateCustomTagDescriptor"
,
...
...
common/lib/xmodule/xmodule/survey_module.py
0 → 100644
View file @
52594186
import
datetime
import
dateutil
import
dateutil.parser
import
json
import
logging
import
traceback
import
re
from
datetime
import
timedelta
from
lxml
import
etree
from
pkg_resources
import
resource_string
from
xmodule.capa_module
import
CapaModule
,
only_one
,
ComplexEncoder
from
xmodule.raw_module
import
RawDescriptor
from
xmodule.exceptions
import
NotFoundError
from
progress
import
Progress
from
capa.capa_problem
import
LoncapaProblem
from
capa.responsetypes
import
StudentInputError
log
=
logging
.
getLogger
(
__name__
)
class
SurveyModule
(
CapaModule
):
"""This is a subclass of CapaModule that sets sensible
default behavior of a problem for surveying students
Defaults:
-Never Show Answer, no max attempts
-No due date unless specified
-Only show save button or no buttons
"""
def
__init__
(
self
,
system
,
location
,
definition
,
instance_state
=
None
,
shared_state
=
None
,
**
kwargs
):
CapaModule
.
__init__
(
self
,
system
,
location
,
definition
,
instance_state
,
shared_state
,
**
kwargs
)
# no maximum number of attempts so students can
# always answer surveys
# if we're interested in cut-off dates, we can use
# the "modified" field from the database
self
.
max_attempts
=
None
# there is no correct answer, never show one or the button
self
.
show_answer
=
"never"
def
get_problem_html
(
self
,
encapsulate
=
True
):
'''Similiar to the parent class method from CapaModule
but never shows "check answer"
'''
try
:
html
=
self
.
lcp
.
get_html
()
except
Exception
,
err
:
if
self
.
system
.
DEBUG
:
log
.
exception
(
err
)
msg
=
(
'[courseware.capa.capa_module] <font size="+1" color="red">'
'Failed to generate HTML for problem
%
s</font>'
%
(
self
.
location
.
url
()))
msg
+=
'<p>Error:</p><p><pre>
%
s</pre></p>'
%
str
(
err
)
.
replace
(
'<'
,
'<'
)
msg
+=
'<p><pre>
%
s</pre></p>'
%
traceback
.
format_exc
()
.
replace
(
'<'
,
'<'
)
html
=
msg
else
:
raise
content
=
{
'name'
:
self
.
metadata
[
'display_name'
],
'html'
:
html
,
'weight'
:
self
.
weight
,
}
check_button
=
False
reset_button
=
False
save_button
=
True
# If we're after deadline survey is read-only.
if
self
.
closed
():
save_button
=
False
context
=
{
'problem'
:
content
,
'id'
:
self
.
id
,
'check_button'
:
check_button
,
'reset_button'
:
reset_button
,
'save_button'
:
save_button
,
'answer_available'
:
self
.
answer_available
(),
'ajax_url'
:
self
.
system
.
ajax_url
,
'attempts_used'
:
self
.
attempts
,
'attempts_allowed'
:
self
.
max_attempts
,
'progress'
:
self
.
get_progress
(),
}
html
=
self
.
system
.
render_template
(
'problem.html'
,
context
)
if
encapsulate
:
html
=
'<div id="problem_{id}" class="problem" data-url="{ajax_url}">'
.
format
(
id
=
self
.
location
.
html_id
(),
ajax_url
=
self
.
system
.
ajax_url
)
+
html
+
"</div>"
return
self
.
system
.
replace_urls
(
html
,
self
.
metadata
[
'data_dir'
])
class
SurveyDescriptor
(
RawDescriptor
):
module_class
=
SurveyModule
lms/templates/problem.html
View file @
52594186
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
<h2
class=
"problem-header"
>
<h2
class=
"problem-header"
>
${ problem['name'] }
${ problem['name'] }
% if problem['weight'] !=
1
:
% if problem['weight'] !=
None
:
: ${ problem['weight'] } points
: ${ problem['weight'] } points
% endif
% endif
</h2>
</h2>
...
...
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