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
b0c13118
Commit
b0c13118
authored
Oct 12, 2014
by
Sola
Committed by
Piotr Mitros
Oct 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed up up feedback, only for upvote at the moment
parent
f02485cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
83 deletions
+29
-83
crowdxblock/crowdxblock.py
+4
-1
crowdxblock/static/js/src/crowdxblock.js
+25
-82
No files found.
crowdxblock/crowdxblock.py
View file @
b0c13118
...
@@ -277,7 +277,10 @@ class CrowdXBlock(XBlock):
...
@@ -277,7 +277,10 @@ class CrowdXBlock(XBlock):
"""
"""
hint_rating
=
{}
hint_rating
=
{}
if
data
[
'student_answer'
]
==
'Flagged'
:
if
data
[
'student_answer'
]
==
'Flagged'
:
return
'0'
hint_rating
[
'rating'
]
=
0
hint_rating
[
'student_ansxwer'
]
=
'Flagged'
hint_rating
[
'hint_used'
]
=
data
[
'hint_used'
]
return
hint_rating
temporary_dictionary
=
str
(
self
.
hint_database
[
data
[
'student_answer'
]])
temporary_dictionary
=
str
(
self
.
hint_database
[
data
[
'student_answer'
]])
temporary_dictionary
=
(
ast
.
literal_eval
(
temporary_dictionary
))
temporary_dictionary
=
(
ast
.
literal_eval
(
temporary_dictionary
))
hint_rating
[
'rating'
]
=
temporary_dictionary
[
data
[
'hint_used'
]]
hint_rating
[
'rating'
]
=
temporary_dictionary
[
data
[
'hint_used'
]]
...
...
crowdxblock/static/js/src/crowdxblock.js
View file @
b0c13118
...
@@ -5,6 +5,7 @@ var issubmitting = 0;
...
@@ -5,6 +5,7 @@ var issubmitting = 0;
var
issubmittinghint
=
0
;
var
issubmittinghint
=
0
;
function
CrowdXBlock
(
runtime
,
element
){
function
CrowdXBlock
(
runtime
,
element
){
var
isStaff
=
false
;
$
(
".HintsToUse"
,
element
).
text
(
""
);
$
(
".HintsToUse"
,
element
).
text
(
""
);
clearvariables
();
clearvariables
();
//repeat counter is used to counteract a bug caused by switching units
//repeat counter is used to counteract a bug caused by switching units
...
@@ -12,7 +13,6 @@ function CrowdXBlock(runtime, element){
...
@@ -12,7 +13,6 @@ function CrowdXBlock(runtime, element){
repeatcounter
+=
1
;
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
;
var
isStaff
=
false
;
Logger
.
listen
(
'seq_next'
,
null
,
clearingvariables
);
Logger
.
listen
(
'seq_next'
,
null
,
clearingvariables
);
Logger
.
listen
(
'seq_goto'
,
null
,
clearingvariables
);
Logger
.
listen
(
'seq_goto'
,
null
,
clearingvariables
);
...
@@ -69,9 +69,8 @@ function CrowdXBlock(runtime, element){
...
@@ -69,9 +69,8 @@ function CrowdXBlock(runtime, element){
url
:
runtime
.
handlerUrl
(
element
,
'is_user_staff'
),
url
:
runtime
.
handlerUrl
(
element
,
'is_user_staff'
),
data
:
JSON
.
stringify
({}),
data
:
JSON
.
stringify
({}),
success
:
function
(
result
)
{
success
:
function
(
result
)
{
console
.
log
(
result
);
if
(
result
[
'is_user_staff'
])
{
if
(
result
[
'is_user_staff'
])
{
i
f
Staff
=
true
;
i
s
Staff
=
true
;
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'get_feedback'
),
url
:
runtime
.
handlerUrl
(
element
,
'get_feedback'
),
...
@@ -95,52 +94,42 @@ function CrowdXBlock(runtime, element){
...
@@ -95,52 +94,42 @@ function CrowdXBlock(runtime, element){
//show hint to student
//show hint to student
$
(
'.HintsToUse'
,
element
).
text
(
result
.
HintsToUse
);
$
(
'.HintsToUse'
,
element
).
text
(
result
.
HintsToUse
);
}
}
function
showHintInfo
(
hint_used
,
student_answer
){
var
hint_rating
=
0
;
$
.
ajax
({
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'get_ratings'
),
data
:
JSON
.
stringify
({
"student_answer"
:
student_answer
,
"hint_used"
:
hint_used
}),
success
:
function
(
result
)
{
HintInfo
=
String
(
"<div class=
\"
hint_value
\"
value =
\"
"
+
hint_used
+
"
\"
>"
+
"<div role=
\"
button
\"
class=
\"
upvote_hint
\"
data-rate=
\"
1
\"
data-icon=
\"
arrow-u
\"
aria-label=
\"
upvote
\"
><b>↑</b></div>"
+
"<div class =
\"
rating
\"
>"
+
result
+
hint_used
+
"</div>"
+
"<div role=
\"
button
\"
class=
\"
downvote_hint
\"
data-rate=
\"
-1
\"
aria-label=
\"
downvote
\"
><b>↓</b></div> </div>"
);
}
});
return
HintInfo
;
}
function
appendHint
(
result
){
function
appendHint
(
result
){
$
(
".hints_for_"
+
result
.
student_answer
,
element
).
append
(
"<div class=
\"
hint_value
\"
value =
\"
"
+
result
.
hint_used
+
"
\"
>"
+
$
(
".student_answer"
,
element
).
each
(
function
(){
if
(
$
(
this
).
find
(
"span"
).
text
()
==
result
.
student_answer
){
$
(
this
).
append
(
"<div class=
\"
hint_value
\"
value =
\"
"
+
result
.
hint_used
+
"
\"
>"
+
"<div role=
\"
button
\"
class=
\"
upvote_hint
\"
data-rate=
\"
1
\"
data-icon=
\"
arrow-u
\"
aria-label=
\"
upvote
\"
><b>↑</b></div>"
+
"<div role=
\"
button
\"
class=
\"
upvote_hint
\"
data-rate=
\"
1
\"
data-icon=
\"
arrow-u
\"
aria-label=
\"
upvote
\"
><b>↑</b></div>"
+
"<div class =
\"
rating
\"
>"
+
result
.
rating
+
result
.
hint_used
+
"</div>"
+
"<div class =
\"
rating
\"
>"
+
result
.
rating
+
"</div><div class=
\"
hint_used
\"
>"
+
""
+
result
.
hint_used
+
"</div>"
+
"<div role=
\"
button
\"
class=
\"
downvote_hint
\"
data-rate=
\"
-1
\"
aria-label=
\"
downvote
\"
><b>↓</b></div> </div>"
);
"<div role=
\"
button
\"
class=
\"
downvote_hint
\"
data-rate=
\"
-1
\"
aria-label=
\"
downvote
\"
><b>↓</b></div> </div>"
);
}
});
}
}
function
appendFlagged
(
result
){
function
appendFlagged
(
result
){
$
(
"flagged_hints"
,
element
).
append
(
"<div class=
\"
hint_value
\"
value =
\"
"
+
result
.
hint_used
+
"
\"
>"
+
$
(
"
.
flagged_hints"
,
element
).
append
(
"<div class=
\"
hint_value
\"
value =
\"
"
+
result
.
hint_used
+
"
\"
>"
+
"<div role=
\"
button
\"
class=
\"
upvote_hint
\"
data-rate=
\"
1
\"
data-icon=
\"
arrow-u
\"
aria-label=
\"
upvote
\"
><b>↑</b></div>"
+
"<div role=
\"
button
\"
class=
\"
upvote_hint
\"
data-rate=
\"
1
\"
data-icon=
\"
arrow-u
\"
aria-label=
\"
upvote
\"
><b>↑</b></div>"
+
"<div class =
\"
rating
\"
>"
+
result
.
rating
+
result
.
hint_used
+
"</div>"
+
"<div class =
\"
rating
\"
>"
+
result
.
rating
+
"</div><div class=
\"
hint_used
\"
>"
+
""
+
result
.
hint_used
+
"</div>"
+
"<div role=
\"
button
\"
class=
\"
downvote_hint
\"
data-rate=
\"
-1
\"
aria-label=
\"
downvote
\"
><b>↓</b></div> </div>"
);
"<div role=
\"
button
\"
class=
\"
downvote_hint
\"
data-rate=
\"
-1
\"
aria-label=
\"
downvote
\"
><b>↓</b></div> </div>"
);
}
}
function
getFeedback
(
result
){
function
getFeedback
(
result
){
if
(
isStaff
){
$
(
'.feedback'
,
element
).
append
(
"<div class=
\"
flagged_hints
\"
><span>Flagged</span></div>"
);
}
$
.
each
(
result
,
function
(
index
,
value
)
{
$
.
each
(
result
,
function
(
index
,
value
)
{
//data of student answer and hints are stored in the paragraphs/buttons
//data of student answer and hints are stored in the paragraphs/buttons
//so that when a button is clicked, the answer and hint can be sent to the python script
//so that when a button is clicked, the answer and hint can be sent to the python script
student_answer
=
value
;
student_answer
=
value
;
hint_used
=
index
;
hint_used
=
index
;
if
(
isStaff
==
true
){
//check if div for a student answer already exists (if length = 0, it doesn't)
$
(
'.feedback'
,
element
).
append
(
"<p class=
\"
flagged_hints
\"
Flagged Hints </p>"
);
if
(
student_answer
!=
"Flagged"
){
}
if
(
$
(
".student_answer"
,
element
).
find
(
"span"
).
text
()
!=
student_answer
){
if
(
student_answer
!=
"Flagged"
&&
$
(
".hints_for_"
+
student_answer
,
element
).
length
==
0
){
$
(
'.feedback'
,
element
).
append
(
"<div class=
\"
student_answer
\"
><span>"
+
student_answer
+
"</span></div>"
);
$
(
'.feedback'
,
element
).
append
(
"<p class=
\"
hints_for_"
+
student_answer
+
"
\"
Answer-specific hints for "
}
+
student_answer
+
" </p>"
);
}
}
if
(
$
(
".hints_for_"
+
student_answer
,
element
).
length
!=
0
){
if
(
student_answer
!=
"Flagged"
){
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'get_ratings'
),
url
:
runtime
.
handlerUrl
(
element
,
'get_ratings'
),
...
@@ -156,47 +145,11 @@ function CrowdXBlock(runtime, element){
...
@@ -156,47 +145,11 @@ function CrowdXBlock(runtime, element){
success
:
appendFlagged
success
:
appendFlagged
});
});
}
}
/*
if (isStaff == true && student_answer == "Flagged") {
$('.feedback', element).append("<p class=\"flagged_hints\"</p>");
if (student_answer == "Flagged") {
$(".flagged_hints", element).append("<div class=" + hint_used + "><div role=\"button\" class=\"return_hint\"" +
" aria-label=\"return\"><b>O</b></div><div>" + hint_used +
"</div> <div role=\"button\" class=\"purge_hint\" aria-label=\"purge\"><b>X</b></div></div>")
}
}
else if($(".submit"+student_answer).length == 0){
$('.feedback', element).append("<p class=\"submit" + student_answer + "\"</p>");
$(".submit"+student_answer, element).append("<b>Answer-specific hints for \b" + " " + student_answer + "<p><input id=\"submitbuttonfor" + student_answer + "\" style=\"float: right; float: top;\" type=\"button\" class=\"submitbutton\" value=\"Submit a hint\"><p class=\"showHintsFor" + student_answer + "\"> </p></div>");
}
//get_feedback will send "There are no hints for" + student_answer if no hints exist
//slice to determine this
if(hint_used.slice(0,22) != "There are no hints for"){
$('.showHintsFor'+student_answer, element).append(
"<p \" class =\"votingFor" + hint_used + "\">" +
"<div data-value=\"" + student_answer + "\" id=\"" + hint_used +"\" role=\"button\" class=\"upvote_hint\"" +
"data-rate=\"1\" data-icon=\"arrow-u\" aria-label=\"upvote\"><b>↑</b></div>" +
"<div class = \"" + hint_used + "rating\">" + hint_used + "</div>" +
"<div data-value=\"" + student_answer + "\" id=\"" + hint_used + "\" role=\"button\" class=\"downvote_hint\"" +
"data-rate=\"-1\" aria-label=\"downvote\"><b>↓</b>" +
"</div> </p>");
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'get_ratings'),
data: JSON.stringify({"student_answer": student_answer, "hint_used": hint_used}),
success: show_ratings
});
}else{
$('.showHintsFor'+student_answer).empty();
$('.showHintsFor'+student_answer).append("<p class=\".showHintsFor" + student_answer + "\"data-value=\"" + student_answer + "\"> <b>No hints exist in the database. (You received a default hint)</p> <p id=\"" + hint_used + "\"data-value=\"" + student_answer + "\" </p>");
}*/
});
});
}
}
function
show_ratings
(
result
)
{
function
show_ratings
(
result
)
{
$
.
each
(
result
,
function
(
index
,
value
)
{
$
.
each
(
result
,
function
(
index
,
value
)
{
console
.
log
(
index
);
console
.
log
(
value
);
$
(
"."
+
index
+
"rating"
).
append
(
value
+
" "
+
index
);
$
(
"."
+
index
+
"rating"
).
append
(
value
+
" "
+
index
);
})
})
}
}
...
@@ -246,30 +199,20 @@ function CrowdXBlock(runtime, element){
...
@@ -246,30 +199,20 @@ function CrowdXBlock(runtime, element){
}
}
})
})
$
(
document
).
on
(
'click'
,
'.upvote_hint'
,
function
(){
//upvote
$
(
document
).
on
(
'click'
,
'.upvote_hint'
,
function
(){
canhint
=
0
;
used_hint
=
$
(
this
).
parent
().
find
(
".hint_used"
).
text
();
id
=
this
.
id
;
student_answer
=
$
(
this
).
parent
().
parent
().
find
(
"span"
).
text
();
$
(
'.hintbutton'
).
each
(
function
(){
if
(
$
(
this
).
attr
(
'id'
)
==
String
(
id
)){
$
(
this
).
hide
();
}
});
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'rate_hint'
),
url
:
runtime
.
handlerUrl
(
element
,
'rate_hint'
),
data
:
JSON
.
stringify
({
"student_rating"
:
$
(
this
).
attr
(
'data-rate'
),
"used_hint"
:
$
(
this
).
attr
(
'id'
),
"student_answer"
:
$
(
this
).
attr
(
'data-value'
)
}),
data
:
JSON
.
stringify
({
"student_rating"
:
$
(
this
).
attr
(
'data-rate'
),
"used_hint"
:
used_hint
,
"student_answer"
:
student_answer
}),
success
:
finish
success
:
finish
});
});
})
})
$
(
document
).
on
(
'click'
,
'.downvote_hint'
,
function
(){
//upvote
$
(
document
).
on
(
'click'
,
'.downvote_hint'
,
function
(){
canhint
=
0
;
canhint
=
0
;
id
=
this
.
id
;
id
=
this
.
id
;
$
(
'.hintbutton'
).
each
(
function
(){
if
(
$
(
this
).
attr
(
'id'
)
==
String
(
id
)){
$
(
this
).
hide
();
}
});
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'rate_hint'
),
url
:
runtime
.
handlerUrl
(
element
,
'rate_hint'
),
...
@@ -278,7 +221,7 @@ function CrowdXBlock(runtime, element){
...
@@ -278,7 +221,7 @@ function CrowdXBlock(runtime, element){
});
});
})
})
$
(
document
).
on
(
'click'
,
'.flag_hint'
,
function
(){
//upvote
$
(
document
).
on
(
'click'
,
'.flag_hint'
,
function
(){
canhint
=
0
;
canhint
=
0
;
id
=
this
.
id
;
id
=
this
.
id
;
$
(
'.hintbutton'
).
each
(
function
(){
$
(
'.hintbutton'
).
each
(
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