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
37753c86
Commit
37753c86
authored
Oct 19, 2014
by
Sola
Committed by
Piotr Mitros
Oct 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed feedback bugs
parent
0f34a814
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
53 deletions
+26
-53
crowdxblock/crowdxblock.py
+3
-2
crowdxblock/static/html/crowdxblock.html
+1
-0
crowdxblock/static/js/src/crowdxblock.js
+22
-51
No files found.
crowdxblock/crowdxblock.py
View file @
37753c86
...
@@ -68,6 +68,7 @@ class CrowdXBlock(XBlock):
...
@@ -68,6 +68,7 @@ class CrowdXBlock(XBlock):
"""
"""
html
=
self
.
resource_string
(
"static/html/crowdxblockstudio.html"
)
html
=
self
.
resource_string
(
"static/html/crowdxblockstudio.html"
)
frag
=
Fragment
(
html
.
format
(
self
=
self
))
frag
=
Fragment
(
html
.
format
(
self
=
self
))
frag
.
add_javascript_url
(
'//cdnjs.cloudflare.com/ajax/libs/mustache.js/0.8.1/mustache.min.js'
)
frag
.
add_css
(
self
.
resource_string
(
"static/css/crowdxblock.css"
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/crowdxblock.css"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/crowdxblock.js"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/crowdxblock.js"
))
frag
.
initialize_js
(
'CrowdXBlock'
)
frag
.
initialize_js
(
'CrowdXBlock'
)
...
@@ -430,8 +431,8 @@ class CrowdXBlock(XBlock):
...
@@ -430,8 +431,8 @@ class CrowdXBlock(XBlock):
data['submission']: This is the text of the new hint that the student has submitted.
data['submission']: This is the text of the new hint that the student has submitted.
data['answer']: This is the incorrect answer for which the student is submitting a new hint.
data['answer']: This is the incorrect answer for which the student is submitting a new hint.
"""
"""
submission
=
data
[
'submission'
]
.
replace
(
'ddeecciimmaallppooiinntt'
,
'.'
)
submission
=
data
[
'submission'
]
answer
=
data
[
'answer'
]
.
replace
(
'ddeecciimmaallppooiinntt'
,
'.'
)
answer
=
data
[
'answer'
]
if
str
(
submission
)
not
in
self
.
hint_database
[
str
(
answer
)]:
if
str
(
submission
)
not
in
self
.
hint_database
[
str
(
answer
)]:
temporary_dictionary
=
str
(
self
.
hint_database
[
str
(
answer
)])
temporary_dictionary
=
str
(
self
.
hint_database
[
str
(
answer
)])
temporary_dictionary
=
(
ast
.
literal_eval
(
temporary_dictionary
))
temporary_dictionary
=
(
ast
.
literal_eval
(
temporary_dictionary
))
...
...
crowdxblock/static/html/crowdxblock.html
View file @
37753c86
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
<span
class=
'Thankyou'
></span>
<span
class=
'Thankyou'
></span>
</p>
</p>
<div
class=
"feedback"
>
<div
class=
"feedback"
>
</div>
</div>
...
...
crowdxblock/static/js/src/crowdxblock.js
View file @
37753c86
var
repeating
=
0
;
var
repeatcounter
=
0
;
var
canhint
=
0
;
var
canhint
=
0
;
var
issubmitting
=
0
;
var
issubmittinghint
=
0
;
function
CrowdXBlock
(
runtime
,
element
){
function
CrowdXBlock
(
runtime
,
element
){
var
isStaff
=
false
;
var
isStaff
=
false
;
$
(
".HintsToUse"
,
element
).
text
(
""
);
$
(
".HintsToUse"
,
element
).
text
(
""
);
clearvariables
();
//repeat counter is used to counteract a bug caused by switching units
//after switching units all logger.listen events would trigger multiple times
repeatcounter
+=
1
;
//use to determine whether or not to initialize hint feedback
//use to determine whether or not to initialize hint feedback
var
hasReceivedHint
=
false
;
var
hasReceivedHint
=
false
;
Logger
.
listen
(
'seq_next'
,
null
,
clearingvariables
);
Logger
.
listen
(
'seq_next'
,
null
,
stopScript
);
Logger
.
listen
(
'seq_goto'
,
null
,
clearingvariables
);
Logger
.
listen
(
'seq_goto'
,
null
,
stopScript
);
function
clearingvariables
(
event_type
,
data
,
element
){
//stop this script if units are switched to prevent data errors/duplication
clearvariables
(
data
);
function
stopScript
(
event_type
,
data
,
element
){
return
;
}
}
function
clearvariables
(
data
){
repeating
=
0
;
}
function
logError
(
details
)
{
function
logError
(
details
)
{
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
...
@@ -37,25 +26,16 @@ function CrowdXBlock(runtime, element){
...
@@ -37,25 +26,16 @@ function CrowdXBlock(runtime, element){
//read the data from the problem_graded event here
//read the data from the problem_graded event here
function
get_event_data
(
event_type
,
data
,
element
){
function
get_event_data
(
event_type
,
data
,
element
){
repeating
+=
1
;
if
(
repeating
!=
repeatcounter
){
console
.
debug
(
repeating
);
}
else
{
check_correct
(
event_type
,
data
,
element
);
check_correct
(
event_type
,
data
,
element
);
}
}
}
$
(
document
).
on
(
'click'
,
'.check.Check'
,
function
(){
repeating
=
0
;
});
function
check_correct
(
var_event_type
,
var_data
,
var_element
){
function
check_correct
(
var_event_type
,
var_data
,
var_element
){
//check that problem wasn't correctly answered
//check that problem wasn't correctly answered
if
(
var_data
[
1
].
search
(
/class="correct/
)
===
-
1
){
if
(
var_data
[
1
].
search
(
/class="correct/
)
===
-
1
){
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'get_hint'
),
url
:
runtime
.
handlerUrl
(
element
,
'get_hint'
),
data
:
JSON
.
stringify
({
"submittedanswer"
:
var_data
[
0
]
}),
data
:
JSON
.
stringify
({
"submittedanswer"
:
unescape
(
var_data
[
0
])
}),
success
:
seehint
success
:
seehint
});
});
hasReceivedHint
=
true
;
hasReceivedHint
=
true
;
...
@@ -98,10 +78,10 @@ function CrowdXBlock(runtime, element){
...
@@ -98,10 +78,10 @@ function CrowdXBlock(runtime, element){
function
appendHint
(
result
){
function
appendHint
(
result
){
$
(
".student_answer"
,
element
).
each
(
function
(){
$
(
".student_answer"
,
element
).
each
(
function
(){
if
(
$
(
this
).
find
(
"span"
).
text
()
==
result
.
student_answer
){
if
(
$
(
this
).
find
(
"span"
).
text
()
==
result
.
student_answer
){
$
(
this
).
append
(
"<div class=
\"
hint_value
\"
value =
\"
"
+
result
.
hint_used
+
"
\"
>"
+
$
(
this
).
append
(
unescape
(
"<div class=
\"
hint_value
\"
value =
\"
"
+
result
.
hint_used
+
"
\"
>"
+
"<div role=
\"
button
\"
class=
\"
rate_hint
\"
data-rate=
\"
1
\"
data-icon=
\"
arrow-u
\"
aria-label=
\"
upvote
\"
><b>↑</b></div>"
+
"<div role=
\"
button
\"
class=
\"
rate_hint
\"
data-rate=
\"
1
\"
data-icon=
\"
arrow-u
\"
aria-label=
\"
upvote
\"
><b>↑</b></div>"
+
"<div class =
\"
rating
\"
>"
+
result
.
rating
+
"</div><div class=
\"
hint_used
\"
>"
+
""
+
result
.
hint_used
+
"</div>"
+
"<div class =
\"
rating
\"
>"
+
result
.
rating
+
"</div><div class=
\"
hint_used
\"
>"
+
""
+
result
.
hint_used
+
"</div>"
+
"<div role=
\"
button
\"
class=
\"
rate_hint
\"
data-rate=
\"
-1
\"
aria-label=
\"
downvote
\"
><b>↓</b></div> </div>"
);
"<div role=
\"
button
\"
class=
\"
rate_hint
\"
data-rate=
\"
-1
\"
aria-label=
\"
downvote
\"
><b>↓</b></div> </div>"
)
)
;
}
}
});
});
}
}
...
@@ -114,6 +94,7 @@ function CrowdXBlock(runtime, element){
...
@@ -114,6 +94,7 @@ function CrowdXBlock(runtime, element){
}
}
function
getFeedback
(
result
){
function
getFeedback
(
result
){
console
.
log
(
"feedback"
);
if
(
isStaff
){
if
(
isStaff
){
$
(
'.feedback'
,
element
).
append
(
"<div class=
\"
flagged_hints
\"
><span>Flagged</span></div>"
);
$
(
'.feedback'
,
element
).
append
(
"<div class=
\"
flagged_hints
\"
><span>Flagged</span></div>"
);
}
}
...
@@ -126,20 +107,19 @@ function CrowdXBlock(runtime, element){
...
@@ -126,20 +107,19 @@ function CrowdXBlock(runtime, element){
if
(
student_answer
!=
"Flagged"
){
if
(
student_answer
!=
"Flagged"
){
if
(
$
(
'.student_answer'
,
element
).
length
==
0
){
if
(
$
(
'.student_answer'
,
element
).
length
==
0
){
$
(
'.feedback'
,
element
).
append
(
"<div class=
\"
student_answer
\"
><span><b>"
+
student_answer
+
"</b></span>"
+
$
(
'.feedback'
,
element
).
append
(
"<div class=
\"
student_answer
\"
><span><b>"
+
student_answer
+
"</b></span>"
+
"<div><input type =
\"
button
\"
class=
\"
s
ubmit_hint
\"
value=
\"
Submit a new hint for this answer.
\"
</input></div></div>"
);
"<div><input type =
\"
button
\"
class=
\"
s
tudent_hint_creation
\"
value=
\"
Submit a new hint for this answer.
\"
</input></div></div>"
);
}
}
else
{
else
{
//cycle through each .student_answer to check if this answer has been accounted for
//cycle through each .student_answer to check if this answer has been accounted for
answerShown
=
false
;
answerShown
=
false
;
$
(
".student_answer"
,
element
).
each
(
function
(){
$
(
".student_answer"
,
element
).
each
(
function
(){
console
.
log
(
$
(
this
).
find
(
"span"
).
text
());
if
(
$
(
this
).
find
(
"span"
).
text
()
==
student_answer
){
if
(
$
(
this
).
find
(
"span"
).
text
()
==
student_answer
){
answerShown
=
true
;
answerShown
=
true
;
}
}
});
});
if
(
answerShown
==
false
){
if
(
answerShown
==
false
){
$
(
'.feedback'
,
element
).
append
(
"<div class=
\"
student_answer
\"
><span><b>"
+
student_answer
+
"</b></span>"
+
$
(
'.feedback'
,
element
).
append
(
"<div class=
\"
student_answer
\"
><span><b>"
+
student_answer
+
"</b></span>"
+
"<div><input type =
\"
button
\"
class=
\"
s
ubmit_hint
\"
value=
\"
Submit a new hint for this answer.
\"
</input></div></div>"
);
"<div><input type =
\"
button
\"
class=
\"
s
tudent_hint_creation
\"
value=
\"
Submit a new hint for this answer.
\"
</input></div></div>"
);
}
}
}
}
}
}
...
@@ -170,40 +150,31 @@ function CrowdXBlock(runtime, element){
...
@@ -170,40 +150,31 @@ function CrowdXBlock(runtime, element){
});
});
}
}
$
(
document
).
on
(
'click'
,
'.submit_hint'
,
function
(){
$
(
document
).
on
(
'click'
,
'.student_hint_creation'
,
function
(){
$
(
'.math'
).
remove
();
$
(
'.submit_new'
).
remove
();
student_answer
=
$
(
this
).
parent
().
parent
().
find
(
"span"
).
text
();
student_answer
=
$
(
this
).
parent
().
parent
().
find
(
"span"
).
text
();
$
(
".student_answer"
,
element
).
each
(
function
(){
$
(
".student_answer"
,
element
).
each
(
function
(){
if
(
$
(
this
).
find
(
"span"
).
text
()
==
student_answer
){
if
(
$
(
this
).
find
(
"span"
).
text
()
==
student_answer
){
$
(
this
).
prepend
(
"<p><input type=
\"
text
\"
name=
\"
studentinput
\"
class=
\"
math
\"
size=
\"
40
\"
><input
type=
\"
button
\"
class=
\"
button
\"
value=
\"
Submit Hint
\"
> </p>"
);
$
(
this
).
prepend
(
"<p><input type=
\"
text
\"
name=
\"
studentinput
\"
class=
\"
math
\"
size=
\"
40
\"
><input
id=
\"
"
+
student_answer
+
"
\"
type=
\"
button
\"
class=
\"
submit_new
\"
value=
\"
Submit Hint
\"
> </p>"
);
}
}
});
});
})
})
$
(
document
).
on
(
'click'
,
'#submit'
,
function
(){
$
(
document
).
on
(
'click'
,
'.submit_new'
,
function
(){
issubmittinghint
+=
1
;
if
(
$
(
this
).
parent
().
find
(
'.math'
).
val
()
!=
null
){
if
(
issubmittinghint
==
repeatcounter
){
var
answerdata
=
unescape
(
$
(
this
).
attr
(
'id'
));
if
(
$
(
'.math'
).
val
()
!=
null
){
var
newhint
=
unescape
(
$
(
'.math'
).
val
());
var
answerdata
=
String
;
issubmitting
=
0
;
$
(
'#submit'
).
each
(
function
(){
answerdata
=
$
(
'.math'
).
attr
(
'id'
);
});
$
(
'.submitbutton'
).
show
();
$
(
'.submitbutton'
).
show
();
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'give_hint'
),
url
:
runtime
.
handlerUrl
(
element
,
'give_hint'
),
data
:
JSON
.
stringify
({
"submission"
:
$
(
'.math'
).
val
()
,
"answer"
:
answerdata
}),
//give hin for first incorrect answer
data
:
JSON
.
stringify
({
"submission"
:
newhint
,
"answer"
:
answerdata
}),
//give hin for first incorrect answer
//success: finish
//success: finish
});
});
$
(
"#answer"
).
val
(
''
);
$
(
this
).
parent
(
'p'
).
remove
();
$
(
this
).
remove
();
//$('.math').remove();
$
(
'.math'
).
remove
();
document
.
getElementById
(
"submitbuttonfor"
+
answerdata
).
remove
();
$
(
'#submitbuttonfor'
+
answerdata
).
remove
();
$
(
'#'
+
answerdata
).
remove
();
$
(
'#submit'
+
answerdata
).
prepend
(
'Thankyou for your hint!'
);
}
}
}
})
})
$
(
document
).
on
(
'click'
,
'.rate_hint'
,
function
(){
$
(
document
).
on
(
'click'
,
'.rate_hint'
,
function
(){
...
...
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