Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
crowdsourcehinter
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
OpenEdx
crowdsourcehinter
Commits
38496af0
Commit
38496af0
authored
Nov 18, 2014
by
solashirai
Committed by
Piotr Mitros
Oct 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trying to implement minimal example
parent
a0dd62da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
21 deletions
+30
-21
crowdsourcehinter/static/html/crowdsourcehinter.html
+7
-6
crowdsourcehinter/static/js/src/crowdsourcehinter.js
+23
-15
No files found.
crowdsourcehinter/static/html/crowdsourcehinter.html
View file @
38496af0
...
@@ -26,11 +26,12 @@
...
@@ -26,11 +26,12 @@
<
/div
>
<
/div
>
</script>
</script>
<script
id=
"testingID"
type=
"x-tmpl-mustache"
>
<script
type=
"x-tmpl/mustache"
id=
"s1"
>
<
h1
>
{{
firstName
}}
{{
lastName
}}
<
/h1
>
Sample
template
1
is
{{
var
}}
<
p
>
Test
<
a
href
=
"{{testvar}}"
>
{{
testvar
}}
<
/a></
p
>
</script>
<script
type=
"x-tmpl/mustache"
id=
"s2"
>
Sample
template
2
is
{{
var
}}
</script>
</script>
<script
type=
"x-tmpl-mustache"
id=
"show_answer_feedback"
>
<script
type=
"x-tmpl-mustache"
id=
"show_answer_feedback"
>
<
div
class
=
"csh_student_answer"
>
<
div
class
=
"csh_student_answer"
>
<
span
><
b
>
{{
answer
}}
<
/b></
span
>
<
span
><
b
>
{{
answer
}}
<
/b></
span
>
...
@@ -45,7 +46,6 @@
...
@@ -45,7 +46,6 @@
<p>
<span
class=
'csh_HintsToUse'
></span>
<p>
<span
class=
'csh_HintsToUse'
></span>
</p>
</p>
<div
id=
"sampleArea"
></div>
<div
class=
"crowdsourcehinter_block"
>
<div
class=
"crowdsourcehinter_block"
>
...
@@ -54,7 +54,8 @@
...
@@ -54,7 +54,8 @@
<span
class=
'Thankyou'
></span>
<span
class=
'Thankyou'
></span>
</p>
</p>
<div
class=
"sample1"
></div>
<div
class=
"sample2"
></div>
<div
class=
"csh_feedback"
>
<div
class=
"csh_feedback"
>
<div
class=
"csh_flagged_hints"
>
<div
class=
"csh_flagged_hints"
>
<span>
Flagged
</span>
<span>
Flagged
</span>
...
...
crowdsourcehinter/static/js/src/crowdsourcehinter.js
View file @
38496af0
...
@@ -21,15 +21,6 @@ function CrowdsourceHinter(runtime, element){
...
@@ -21,15 +21,6 @@ function CrowdsourceHinter(runtime, element){
//data about the problem obtained from Logger.listen('problem_graded') is passed on to the onStudentSubmission.
//data about the problem obtained from Logger.listen('problem_graded') is passed on to the onStudentSubmission.
//directly passing data to onStudentSubmission does not work for unknown reasons (to be fixed?)
//directly passing data to onStudentSubmission does not work for unknown reasons (to be fixed?)
function
get_event_data
(
event_type
,
data
,
element
){
function
get_event_data
(
event_type
,
data
,
element
){
//below is minimal mustache template usage attempt
var
options
=
{
firstName
:
"Sola"
,
lastName
:
"Shirai"
,
testvar
:
"Hello"
};
var
template
=
$
(
Mustache
.
render
(
$
(
"#testingID"
).
html
(),
options
));
$
(
'#sampleArea'
).
html
(
template
);
onStudentSubmission
(
data
);
onStudentSubmission
(
data
);
}
}
Logger
.
listen
(
'problem_graded'
,
null
,
get_event_data
);
Logger
.
listen
(
'problem_graded'
,
null
,
get_event_data
);
...
@@ -37,6 +28,21 @@ function CrowdsourceHinter(runtime, element){
...
@@ -37,6 +28,21 @@ function CrowdsourceHinter(runtime, element){
function
onStudentSubmission
(
problem_graded_event_data
){
function
onStudentSubmission
(
problem_graded_event_data
){
//This function will determine whether or not the student correctly answered the question.
//This function will determine whether or not the student correctly answered the question.
//If it was correctly answered it will begin the process for giving feedback on hints.
//If it was correctly answered it will begin the process for giving feedback on hints.
$
(
function
(){
// Simple example
$
(
".sample1"
).
html
(
Mustache
.
render
(
unescape
(
$
(
"#s1"
).
html
()),
{
var
:
"rendered"
}));
// Broken out to show pieces. You can add console.log() to inspect these individually.
// It will be easiest, probably, to cut-and-paste pieces like this into the JavaScript console in Chrome, and seeing what they do in the interpretter
var
template
=
$
(
"#s2"
).
html
();
console
.
log
(
template
);
var
parameters
=
{
var
:
"also rendered"
};
console
.
log
(
parameters
);
var
rendered_html
=
Mustache
.
render
(
template
,
parameters
);
console
.
log
(
rendered_html
);
$
(
".sample2"
).
html
(
rendered_html
);
});
//end of sample code
if
(
problem_graded_event_data
[
1
].
search
(
/class="correct/
)
===
-
1
){
if
(
problem_graded_event_data
[
1
].
search
(
/class="correct/
)
===
-
1
){
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
...
@@ -85,12 +91,14 @@ function CrowdsourceHinter(runtime, element){
...
@@ -85,12 +91,14 @@ function CrowdsourceHinter(runtime, element){
//This appended div includes upvote/downvote/flagging buttons, the hint, and the hint's rating
//This appended div includes upvote/downvote/flagging buttons, the hint, and the hint's rating
$
(
".csh_student_answer"
,
element
).
each
(
function
(){
$
(
".csh_student_answer"
,
element
).
each
(
function
(){
if
(
$
(
this
).
find
(
"span"
).
text
()
==
result
.
student_answer
){
if
(
$
(
this
).
find
(
"span"
).
text
()
==
result
.
student_answer
){
/*var template = $('#show_hint_feedback').html();
/*$(function(){
var data = {
var template = $('#show_hint_feedback').html();
hint: result.hint,
var data = {
rating: result.rating
hint: result.hint,
};
rating: result.rating
$(this).append(Mustache.render(template, data));*/
};
$(this).append(Mustache.render(template, data));
});*/
$
(
this
).
append
(
unescape
(
"<div class=
\"
csh_hint_value
\"
value =
\"
"
+
result
.
hint
+
"
\"
>"
+
$
(
this
).
append
(
unescape
(
"<div class=
\"
csh_hint_value
\"
value =
\"
"
+
result
.
hint
+
"
\"
>"
+
"<div role=
\"
button
\"
class=
\"
csh_rate_hint
\"
data-rate=
\"
upvote
\"
data-icon=
\"
arrow-u
\"
aria-label=
\"
upvote
\"
><b>↑</b></div>"
+
"<div role=
\"
button
\"
class=
\"
csh_rate_hint
\"
data-rate=
\"
upvote
\"
data-icon=
\"
arrow-u
\"
aria-label=
\"
upvote
\"
><b>↑</b></div>"
+
"<div class =
\"
csh_rating
\"
>"
+
result
.
rating
+
"</div>"
+
"<div class =
\"
csh_rating
\"
>"
+
result
.
rating
+
"</div>"
+
...
...
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