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
b729434e
Commit
b729434e
authored
Nov 01, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work on save functionality
parent
0739d3ba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
18 deletions
+13
-18
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
+1
-3
common/lib/xmodule/xmodule/self_assessment_module.py
+12
-15
No files found.
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
View file @
b729434e
...
...
@@ -8,9 +8,7 @@ $(document).on('click', 'section.sa-wrapper input#show', ( ->
alert
(
"posted"
)
if
response
.
success
alert
(
response
.
rubric
)
$
(
'section.sa-wrapper p#rubric'
).
replace
(
response
.
rubric
)
alert
(
"save"
)
$
(
'section.sa-wrapper p#rubric'
).
append
(
response
.
rubric
)
));
$
(
document
).
on
(
'click'
,
'section.sa-wrapper input#save'
,
(
->
...
...
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
b729434e
...
...
@@ -6,6 +6,8 @@ import sys
from
lxml
import
etree
from
lxml.html
import
rewrite_links
from
path
import
path
import
json
from
progress
import
Progress
from
.x_module
import
XModule
from
pkg_resources
import
resource_string
...
...
@@ -36,6 +38,12 @@ def only_one(lst, default="", process=lambda x: x):
else
:
raise
Exception
(
'Malformed XML'
)
class
ComplexEncoder
(
json
.
JSONEncoder
):
def
default
(
self
,
obj
):
if
isinstance
(
obj
,
complex
):
return
"{real:.7g}{imag:+.7g}*j"
.
format
(
real
=
obj
.
real
,
imag
=
obj
.
imag
)
return
json
.
JSONEncoder
.
default
(
self
,
obj
)
class
SelfAssessmentModule
(
XModule
):
js
=
{
'coffee'
:
[
resource_string
(
__name__
,
'js/src/javascript_loader.coffee'
),
...
...
@@ -53,42 +61,31 @@ class SelfAssessmentModule(XModule):
instance_state
=
None
,
shared_state
=
None
,
**
kwargs
):
XModule
.
__init__
(
self
,
system
,
location
,
definition
,
descriptor
,
instance_state
,
shared_state
,
**
kwargs
)
dom2
=
etree
.
fromstring
(
"<selfassessment>"
+
self
.
definition
[
'data'
]
+
"</selfassessment>"
)
self
.
rubric
=
''
.
join
([
etree
.
tostring
(
child
)
for
child
in
only_one
(
dom2
.
xpath
(
'rubric'
))])
self
.
problem
=
''
.
join
([
etree
.
tostring
(
child
)
for
child
in
only_one
(
dom2
.
xpath
(
'problem'
))])
problem_form
=
(
'<section class="sa-wrapper"><input type="text" name="answer" '
'id="answer"/><br/>'
'<input type="button" value="Check" id ="show" name="show" url="{0}"/>'
'<p id="rubric"></p></section>'
)
.
format
(
self
.
location
)
self
.
problem
=
''
.
join
([
self
.
problem
,
problem_form
])
self
.
rubric
=
''
.
join
([
self
.
rubric
,
rubric_form
])
#print(etree.tostring(rubric))
#print(etree.tostring(problem))
self
.
html
=
self
.
problem
self
.
answers
=
{}
self
.
score
=
0
self
.
max_score
=
1
self
.
top_score
=
1
def
get_score
(
self
):
return
self
.
score
def
max_score
(
self
):
return
self
.
max
_score
return
self
.
top
_score
def
get_progress
(
self
):
''' For now, just return score / max_score
'''
score
=
self
.
get_score
()
score
=
d
[
'score'
]
total
=
self
.
max_score
()
if
total
>
0
:
try
:
...
...
@@ -130,7 +127,7 @@ class SelfAssessmentModule(XModule):
def
show_rubric
(
self
,
get
):
return
{
'success'
:
True
,
'rubric'
:
rubric_form
}
return
{
'success'
:
True
,
'rubric'
:
self
.
rubric
}
def
save_problem
(
self
,
get
):
...
...
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