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
e94a78c6
Commit
e94a78c6
authored
Nov 05, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor code to make it simpler, pull out templates
parent
914e9c9b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
37 deletions
+46
-37
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
+1
-1
common/lib/xmodule/xmodule/self_assessment_module.py
+13
-36
lms/templates/self_assessment_prompt.html
+15
-0
lms/templates/self_assessment_rubric.html
+17
-0
No files found.
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
View file @
e94a78c6
...
@@ -2,7 +2,7 @@ $(document).on('click', 'section.sa-wrapper input#show', ( ->
...
@@ -2,7 +2,7 @@ $(document).on('click', 'section.sa-wrapper input#show', ( ->
post_url
=
$
(
'section.sa-wrapper input#ajax_url'
).
attr
(
'url'
)
post_url
=
$
(
'section.sa-wrapper input#ajax_url'
).
attr
(
'url'
)
final_url
=
"
#{
post_url
}
/sa_show"
final_url
=
"
#{
post_url
}
/sa_show"
answer
=
$
(
'section.sa-wrapper textarea#answer'
).
val
()
answer
=
$
(
'section.sa-wrapper textarea#answer'
).
val
()
$
.
post
final_url
,
answer
,
(
response
)
->
$
.
post
final_url
,
{
'student_answer'
:
answer
}
,
(
response
)
->
if
response
.
success
if
response
.
success
$
(
'section.sa-wrapper input#show'
).
remove
()
$
(
'section.sa-wrapper input#show'
).
remove
()
$
(
'section.sa-wrapper textarea#answer'
).
remove
()
$
(
'section.sa-wrapper textarea#answer'
).
remove
()
...
...
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
e94a78c6
...
@@ -108,44 +108,21 @@ class SelfAssessmentModule(XModule):
...
@@ -108,44 +108,21 @@ class SelfAssessmentModule(XModule):
#Do not change ids and names, as javascript (selfassessment/display.coffee) depends on them
#Do not change ids and names, as javascript (selfassessment/display.coffee) depends on them
# TODO: use templates -- system.render_template will pull them from the right place (lms/templates dir)
# TODO: use templates -- system.render_template will pull them from the right place (lms/templates dir)
prompt_form
=
(
'<section class="sa-wrapper"><textarea name="answer" '
'id="answer" cols="50" rows="5"/><br/>'
'<input type="button" value="Check" id ="show" name="show"/>'
'<p id="rubric"></p><input type="hidden" '
'id="ajax_url" name="ajax_url" url="{0}"></section><br/><br/>'
)
.
format
(
system
.
ajax_url
)
rubric_form
=
(
'Please assess your performance given the above rubric: <br/>'
'<section class="sa-wrapper"><select name="assessment" id="assessment">'
'<option value="incorrect">Incorrect</option><option value="correct">'
'Correct</option></select><br/>'
'What hint about this problem would you give to someone?'
'<textarea name="hint" id="hint" cols="50" rows="5"/><br/>'
'<input type="button" value="Save" id="save" name="save"/>'
'<p id="save_message"></p><input type="hidden" '
'id="ajax_url" name="ajax_url" url="{0}">'
'</section><br/><br/>'
)
.
format
(
system
.
ajax_url
)
rubric_header
=
(
'<br/><br/><b>Rubric</b>'
)
# TODO:
# TODO:
#context = {rubric, ..., answer, etc}
previous_answer
=
''
# self.html = self.system.render_template('selfassessment.html', context)
if
len
(
self
.
student_answers
)
>
0
:
previous_answer
=
self
.
student_answers
[
len
(
self
.
student_answers
)
-
1
]
#Combine prompt, rubric, and the forms
if
type
(
self
.
student_answers
)
==
type
([]):
self
.
context
=
{
if
len
(
self
.
student_answers
)
>
0
:
'prompt'
:
self
.
prompt
,
answer_html
=
"<br/>Previous answer: {0}<br/>"
.
format
(
self
.
student_answers
[
len
(
self
.
student_answers
)
-
1
])
'rubric'
:
self
.
rubric
,
self
.
prompt
=
''
.
join
([
self
.
prompt
,
answer_html
,
prompt_form
])
'previous_answer_given'
:
len
(
self
.
student_answers
)
>
0
,
else
:
'previous_answer'
:
previous_answer
,
self
.
prompt
=
''
.
join
([
self
.
prompt
,
prompt_form
])
'ajax_url'
:
system
.
ajax_url
,
else
:
'section_name'
:
'sa-wrapper'
,
self
.
prompt
=
''
.
join
([
self
.
prompt
,
prompt_form
])
}
self
.
html
=
self
.
system
.
render_template
(
'self_assessment_prompt.html'
,
context
)
self
.
rubric
=
''
.
join
([
rubric_header
,
self
.
rubric
,
rubric_form
])
#Display the prompt to the student to begin with
self
.
html
=
self
.
prompt
def
get_score
(
self
):
def
get_score
(
self
):
return
{
'score'
:
self
.
score
}
return
{
'score'
:
self
.
score
}
...
...
lms/templates/self_assessment_prompt.html
0 → 100644
View file @
e94a78c6
<section
class=
"${ section_name }"
>
${ prompt }
% if previous_answer_given
:
<br/>
Previous answer: ${ previous_answer }
<br/>
% endif
<textarea
name=
"answer"
id=
"answer"
cols=
"50"
rows=
"5"
/>
<br/>
<input
type=
"button"
value=
"Check"
id =
"show"
name=
"show"
/>
<p
id=
"rubric"
>
</p>
<input
type=
"hidden"
id=
"ajax_url"
name=
"ajax_url"
url=
"${ ajax_url }"
>
</section>
<br/><br/>
\ No newline at end of file
lms/templates/self_assessment_rubric.html
0 → 100644
View file @
e94a78c6
<section
class=
"${section_name}"
>
<br/><br/><b>
Rubric
</b>
Please assess your performance given the above rubric:
<br/>
<select
name=
"assessment"
id=
"assessment"
>
<option
value=
"incorrect"
>
Incorrect
</option>
<option
value=
"correct"
>
Correct
</option>
</select>
<br/>
What hint about this problem would you give to someone?
<textarea
name=
"hint"
id=
"hint"
cols=
"50"
rows=
"5"
/>
<br/>
<input
type=
"button"
value=
"Save"
id=
"save"
name=
"save"
/>
<p
id=
"save_message"
></p>
<input
type=
"hidden"
id=
"ajax_url"
name=
"ajax_url"
url=
"${ self_assessment['ajax_url']}"
>
</section>
<br/><br/>
\ 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