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
5858ec5e
Commit
5858ec5e
authored
Dec 28, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Begin making integrated module
parent
60f9143f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
0 deletions
+91
-0
common/lib/xmodule/xmodule/combined_open_ended_module.py
+91
-0
No files found.
common/lib/xmodule/xmodule/combined_open_ended_module.py
0 → 100644
View file @
5858ec5e
import
copy
from
fs.errors
import
ResourceNotFoundError
import
itertools
import
json
import
logging
from
lxml
import
etree
from
lxml.html
import
rewrite_links
from
path
import
path
import
os
import
sys
from
pkg_resources
import
resource_string
from
.capa_module
import
only_one
,
ComplexEncoder
from
.editing_module
import
EditingDescriptor
from
.html_checker
import
check_html
from
progress
import
Progress
from
.stringify
import
stringify_children
from
.x_module
import
XModule
from
.xml_module
import
XmlDescriptor
from
xmodule.modulestore
import
Location
import
self_assessment_module
log
=
logging
.
getLogger
(
"mitx.courseware"
)
# Set the default number of max attempts. Should be 1 for production
# Set higher for debugging/testing
# attempts specified in xml definition overrides this.
MAX_ATTEMPTS
=
1
# Set maximum available number of points.
# Overriden by max_score specified in xml.
MAX_SCORE
=
1
class
CombinedOpenEndedModule
(
XModule
):
pass
class
CombinedOpenEndedDescriptor
(
XmlDescriptor
,
EditingDescriptor
):
"""
Module for adding self assessment questions to courses
"""
mako_template
=
"widgets/html-edit.html"
module_class
=
CombinedOpenEndedModule
filename_extension
=
"xml"
stores_state
=
True
has_score
=
True
template_dir_name
=
"combinedopenended"
js
=
{
'coffee'
:
[
resource_string
(
__name__
,
'js/src/html/edit.coffee'
)]}
js_module_name
=
"HTMLEditingDescriptor"
@classmethod
def
definition_from_xml
(
cls
,
xml_object
,
system
):
"""
Pull out the rubric, prompt, and submitmessage into a dictionary.
Returns:
{
'rubric': 'some-html',
'prompt': 'some-html',
'submitmessage': 'some-html'
'hintprompt': 'some-html'
}
"""
expected_children
=
[
'task'
]
for
child
in
expected_children
:
if
len
(
xml_object
.
xpath
(
child
))
==
0
:
raise
ValueError
(
"Combined Open Ended definition must include at least one '{0}' tag"
.
format
(
child
))
def
parse
(
k
):
"""Assumes that xml_object has child k"""
return
stringify_children
(
xml_object
.
xpath
(
k
)[
0
])
return
{
'task'
:
parse
(
'task'
)}
def
definition_to_xml
(
self
,
resource_fs
):
'''Return an xml element representing this definition.'''
elt
=
etree
.
Element
(
'selfassessment'
)
def
add_child
(
k
):
child_str
=
'<{tag}>{body}</{tag}>'
.
format
(
tag
=
k
,
body
=
self
.
definition
[
k
])
child_node
=
etree
.
fromstring
(
child_str
)
elt
.
append
(
child_node
)
for
child
in
[
'task'
]:
add_child
(
child
)
return
elt
\ 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