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
27bebaf6
Commit
27bebaf6
authored
Apr 19, 2015
by
solashirai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more naming fixes, removal of redundancies
parent
28c85d5f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
59 deletions
+65
-59
crowdsourcehinter/static/css/crowdsourcehinter.css
+4
-3
crowdsourcehinter/static/html/crowdsourcehinter.html
+2
-2
crowdsourcehinter/static/js/src/crowdsourcehinter.js
+59
-54
No files found.
crowdsourcehinter/static/css/crowdsourcehinter.css
View file @
27bebaf6
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
align-self
:
flex-end
;
align-self
:
flex-end
;
}
}
.csh_rate_hint
{
.csh_rate_hint
,
.csh_report_hint
,
.csh_rate_hint_completed
{
margin-right
:
15px
;
margin-right
:
15px
;
margin-top
:
5px
;
margin-top
:
5px
;
align-self
:
flex-end
;
align-self
:
flex-end
;
...
@@ -59,12 +59,12 @@ background-clip: padding-box;
...
@@ -59,12 +59,12 @@ background-clip: padding-box;
font-size
:
0.8125em
;
font-size
:
0.8125em
;
}
}
div
[
data-rate
=
"upvote"
]
{
.csh_rate_hint
[
data-rate
=
"upvote"
]
{
color
:
green
;
color
:
green
;
font-weight
:
bold
;
font-weight
:
bold
;
}
}
div
[
data-rate
=
"downvote"
]
{
.csh_rate_hint
[
data-rate
=
"downvote"
]
{
color
:
red
;
color
:
red
;
font-weight
:
bold
;
font-weight
:
bold
;
}
}
...
@@ -86,6 +86,7 @@ div[data-rate="downvote"] {
...
@@ -86,6 +86,7 @@ div[data-rate="downvote"] {
}
}
.csh_rate_hint
{
cursor
:
pointer
}
.csh_rate_hint
{
cursor
:
pointer
}
.csh_report_hint
{
cursor
:
pointer
}
.csh_staff_rate
{
cursor
:
pointer
}
.csh_staff_rate
{
cursor
:
pointer
}
.csh_rate_hint
{
color
:
#948f8f
;
}
.csh_rate_hint
{
color
:
#948f8f
;
}
...
...
crowdsourcehinter/static/html/crowdsourcehinter.html
View file @
27bebaf6
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<
div
role
=
"button"
class
=
"csh_rate_hint"
data
-
rate
=
"downvote"
>
<
div
role
=
"button"
class
=
"csh_rate_hint"
data
-
rate
=
"downvote"
>
<
b
>
Rate
as
Unhelpful
<
/b
>
<
b
>
Rate
as
Unhelpful
<
/b
>
<
/div
>
<
/div
>
<
div
role
=
"button"
class
=
"csh_r
ate_hint"
data
-
rate
=
"repor
t"
data
-
icon
=
"report"
title
=
"Report this hint."
>
<
div
role
=
"button"
class
=
"csh_r
eport_hin
t"
data
-
icon
=
"report"
title
=
"Report this hint."
>
<
b
>
⚑
<
/b
>
<
b
>
⚑
<
/b
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
@@ -71,7 +71,7 @@
...
@@ -71,7 +71,7 @@
<div
role=
"button"
class=
"csh_rate_hint"
data-rate=
"downvote"
title=
"This hint was not very helpful."
>
<div
role=
"button"
class=
"csh_rate_hint"
data-rate=
"downvote"
title=
"This hint was not very helpful."
>
<b>
-
</b>
<b>
-
</b>
</div>
</div>
<div
role=
"button"
class=
"csh_r
ate_hint"
data-rate=
"repor
t"
title=
"Report this hint"
>
<div
role=
"button"
class=
"csh_r
eport_hin
t"
title=
"Report this hint"
>
<b>
⚑
</b>
<b>
⚑
</b>
</div>
</div>
</div>
</div>
...
...
crowdsourcehinter/static/js/src/crowdsourcehinter.js
View file @
27bebaf6
function
CrowdsourceHinter
(
runtime
,
element
,
data
){
function
CrowdsourceHinter
(
runtime
,
element
,
data
){
var
executeHinter
=
true
;
var
onHinterPage
=
true
;
//We don't do hinter logic if we're on a differ tab in a sequential.
var
isShowingHintFeedback
=
false
;
var
voted
=
false
;
var
voted
=
false
;
$
(
".crowdsourcehinter_block"
,
element
).
hide
();
$
(
".crowdsourcehinter_block"
,
element
).
hide
();
if
(
!
executeHinter
){
if
(
!
onHinterPage
){
return
;
return
;
}
}
/**
/**
* Set
executeHinter
to false, disabling the hinter xblock. Triggered by switching units
* Set
onHinterPage
to false, disabling the hinter xblock. Triggered by switching units
* in edX course.
* in edX course.
* This is a workaround for when a student switches to/from a unit and causes multiple
* This is a workaround for when a student switches to/from a unit and causes multiple
* instances of the hinter to be running.
* instances of the hinter to be running.
*/
*/
function
stopScript
(){
function
stopScript
(){
executeHinter
=
false
;
onHinterPage
=
false
;
}
}
Logger
.
listen
(
'seq_next'
,
null
,
stopScript
);
Logger
.
listen
(
'seq_next'
,
null
,
stopScript
);
Logger
.
listen
(
'seq_prev'
,
null
,
stopScript
);
Logger
.
listen
(
'seq_prev'
,
null
,
stopScript
);
...
@@ -26,7 +25,7 @@ function CrowdsourceHinter(runtime, element, data){
...
@@ -26,7 +25,7 @@ function CrowdsourceHinter(runtime, element, data){
/**
/**
* Get a hint from the server to show to the student after incorrectly answering a
* Get a hint from the server to show to the student after incorrectly answering a
* question. On success, continue to showHint.
* question. On success, continue to showHint.
* @param
data
is data generated by the problem_graded event
* @param
problemGradedEvent
is data generated by the problem_graded event
*/
*/
function
getHint
(
problemGradedEvent
){
function
getHint
(
problemGradedEvent
){
$
(
".crowdsourcehinter_block"
,
element
).
show
();
$
(
".crowdsourcehinter_block"
,
element
).
show
();
...
@@ -47,13 +46,15 @@ function CrowdsourceHinter(runtime, element, data){
...
@@ -47,13 +46,15 @@ function CrowdsourceHinter(runtime, element, data){
function
startHintContribution
(){
function
startHintContribution
(){
$
(
'.csh_correct'
,
element
).
show
();
$
(
'.csh_correct'
,
element
).
show
();
$
(
".csh_hint_reveal"
,
element
).
hide
();
$
(
".csh_hint_reveal"
,
element
).
hide
();
if
(
$
(
'.csh_hint_creation'
,
element
)){
//send empty data for ajax call because not having a data field causes error
//send empty data for ajax call because not having a data field causes error
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'get_feedback'
),
url
:
runtime
.
handlerUrl
(
element
,
'get_feedback'
),
data
:
JSON
.
stringify
({}),
data
:
JSON
.
stringify
({}),
success
:
setStudentContribution
success
:
setHintContributionDivs
});
});
}
}
}
/**
/**
...
@@ -98,7 +99,7 @@ function CrowdsourceHinter(runtime, element, data){
...
@@ -98,7 +99,7 @@ function CrowdsourceHinter(runtime, element, data){
}
}
/**
/**
* Called by set
StudentContribution
to append hints into divs created by
* Called by set
HintContributionDivs
to append hints into divs created by
* showStudentSubmissoinHistory, after the student answered the question correctly.
* showStudentSubmissoinHistory, after the student answered the question correctly.
* Feedback on hints at this stage consists of upvote/downvote/report buttons.
* Feedback on hints at this stage consists of upvote/downvote/report buttons.
* @param hint is the first hint that was shown to the student
* @param hint is the first hint that was shown to the student
...
@@ -135,17 +136,15 @@ function CrowdsourceHinter(runtime, element, data){
...
@@ -135,17 +136,15 @@ function CrowdsourceHinter(runtime, element, data){
}
}
/**
/**
* Set up student
feedback on hints and contribution of new hints. Incorrect answer(s)
and the
* Set up student
/staff voting on hints and contribution of new hints. The original incorrect answer
and the
* the corresponding hint
(s) shown to the student are
displayed. Students can upvote/downvote/report
* the corresponding hint
shown to the student is
displayed. Students can upvote/downvote/report
*
hints or contribute a new hint for their incorrect answer(s)
.
*
the hint or contribute a new hint for their incorrect answer
.
* Only one incorrect answer and hint will be shown when the hinter is set to show best.
* Only one incorrect answer and hint will be shown when the hinter is set to show best.
* @param result is a dictionary of incorrect answers and hints, with the index being the hint and the value
* @param result is a dictionary of incorrect answers and hints, with the index being the hint and the value
* being the incorrect answer
* being the incorrect answer
*/
*/
function
setStudentContribution
(
result
){
function
setHintContributionDivs
(
result
){
//Set up the student feedback stage. Each student answer and all answer-specific hints for that answer are shown
if
(
data
.
isStaff
){
//allow staff to see and remove/return reported hints to/from the hint pool for a problem
//to the student, as well as an option to create a new hint for an answer.
if
(
data
.
isStaff
){
$
(
'.crowdsourcehinter_block'
,
element
).
attr
(
'class'
,
'crowdsourcehinter_block_is_staff'
);
$
(
'.crowdsourcehinter_block'
,
element
).
attr
(
'class'
,
'crowdsourcehinter_block_is_staff'
);
$
.
each
(
result
,
function
(
index
,
value
)
{
$
.
each
(
result
,
function
(
index
,
value
)
{
if
(
value
==
"Reported"
)
{
if
(
value
==
"Reported"
)
{
...
@@ -154,27 +153,22 @@ function CrowdsourceHinter(runtime, element, data){
...
@@ -154,27 +153,22 @@ function CrowdsourceHinter(runtime, element, data){
}
}
});
});
}
}
if
(
!
isShowingHintFeedback
){
$
.
each
(
result
,
function
(
index
,
value
)
{
$
.
each
(
result
,
function
(
index
,
value
)
{
if
(
value
!=
"Reported"
){
if
(
value
!=
"Reported"
){
showStudentSubmissionHistory
(
value
);
showStudentSubmissionHistory
(
value
);
student_answer
=
value
;
student_answer
=
value
;
hint
=
index
;
hint
=
index
;
//hints return null if no answer-specific hints exist
//hints return null if no answer-specific hints exist
if
(
hint
===
"null"
){
if
(
hint
===
"null"
)
{
var
noHintsTemplate
=
$
(
Mustache
.
render
(
$
(
'#show_no_hints'
).
html
(),
{}));
var
noHintsTemplate
=
$
(
Mustache
.
render
(
$
(
'#show_no_hints'
).
html
(),
{}));
$
(
'.csh_student_answer'
,
element
).
append
(
noHintsTemplate
);
$
(
'.csh_student_answer'
,
element
).
append
(
noHintsTemplate
);
var
hintCreationTemplate
=
$
(
Mustache
.
render
(
$
(
'#add_hint_creation'
).
html
(),
{}));
var
hintCreationTemplate
=
$
(
Mustache
.
render
(
$
(
'#add_hint_creation'
).
html
(),
{}));
$
(
'.csh_student_answer'
,
element
).
append
(
hintCreationTemplate
);
$
(
'.csh_student_answer'
,
element
).
append
(
hintCreationTemplate
);
}
}
else
{
//reported hints have their corresponding answer set to "Reported"
else
{
showStudentHintContribution
(
hint
,
student_answer
);
showStudentHintContribution
(
hint
,
student_answer
);
}
}
}
}
});
});
isShowingHintFeedback
=
true
;
}
}
}
/**
/**
...
@@ -212,7 +206,9 @@ function CrowdsourceHinter(runtime, element, data){
...
@@ -212,7 +206,9 @@ function CrowdsourceHinter(runtime, element, data){
type
:
"POST"
,
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'add_new_hint'
),
url
:
runtime
.
handlerUrl
(
element
,
'add_new_hint'
),
data
:
JSON
.
stringify
({
"submission"
:
newHint
,
"answer"
:
studentAnswer
}),
data
:
JSON
.
stringify
({
"submission"
:
newHint
,
"answer"
:
studentAnswer
}),
success
:
Logger
.
log
(
'crowd_hinter.submit_new.click.event'
,
{
"student_answer"
:
studentAnswer
,
"new_hint_submission"
:
newHint
})
success
:
function
()
{
Logger
.
log
(
'crowd_hinter.submit_new.click.event'
,
{
"student_answer"
:
studentAnswer
,
"new_hint_submission"
:
newHint
})
}
});
});
$
(
'.csh_student_text_input'
,
element
).
remove
();
$
(
'.csh_student_text_input'
,
element
).
remove
();
$
(
submitHintButtonHTML
.
currentTarget
).
remove
();
$
(
submitHintButtonHTML
.
currentTarget
).
remove
();
...
@@ -228,34 +224,43 @@ function CrowdsourceHinter(runtime, element, data){
...
@@ -228,34 +224,43 @@ function CrowdsourceHinter(runtime, element, data){
*/
*/
function
rate_hint
(){
return
function
(
rateHintButtonHTML
){
function
rate_hint
(){
return
function
(
rateHintButtonHTML
){
rating
=
rateHintButtonHTML
.
currentTarget
.
attributes
[
'data-rate'
].
value
;
rating
=
rateHintButtonHTML
.
currentTarget
.
attributes
[
'data-rate'
].
value
;
if
(
!
voted
||
rating
==
"report"
){
hint
=
$
(
'.csh_hint_text'
,
element
).
attr
(
'hint_received'
);
if
(
rating
==
"report"
){
student_answer
=
$
(
'.csh_hint_text'
,
element
).
attr
(
'student_answer'
);
alert
(
"This hint has been reported for review."
);
$
.
ajax
({
}
type
:
"POST"
,
hint
=
$
(
'.csh_hint_text'
,
element
).
attr
(
'hint_received'
);
url
:
runtime
.
handlerUrl
(
element
,
'rate_hint'
),
student_answer
=
$
(
'.csh_hint_text'
,
element
).
attr
(
'student_answer'
);
data
:
JSON
.
stringify
({
"student_rating"
:
rating
,
"hint"
:
hint
,
"student_answer"
:
student_answer
}),
$
.
ajax
({
success
:
function
()
{
type
:
"POST"
,
Logger
.
log
(
'crowd_hinter.rate_hint.click.event'
,
{
"hint"
:
hint
,
"student_answer"
:
student_answer
,
"rating"
:
rating
})
url
:
runtime
.
handlerUrl
(
element
,
'rate_hint'
),
$
(
'.csh_rate_hint'
,
element
).
attr
(
'class'
,
'csh_rate_hint_completed'
);
data
:
JSON
.
stringify
({
"student_rating"
:
rating
,
"hint"
:
hint
,
"student_answer"
:
student_answer
}),
success
:
Logger
.
log
(
'crowd_hinter.rate_hint.click.event'
,
{
"hint"
:
hint
,
"student_answer"
:
student_answer
,
"rating"
:
rating
})
});
voted
=
true
;
}
}
});
}}
}}
$
(
element
).
on
(
'click'
,
'.csh_rate_hint'
,
rate_hint
(
$
(
this
)));
$
(
element
).
on
(
'click'
,
'.csh_rate_hint'
,
rate_hint
(
$
(
this
)));
function
report_hint
(){
return
function
(
reportHintButtonHTML
){
hint
=
$
(
'.csh_hint_text'
,
element
).
attr
(
'hint_received'
);
student_answer
=
$
(
'.csh_hint_text'
,
element
).
attr
(
'student_answer'
);
$
.
ajax
({
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'rate_hint'
),
data
:
JSON
.
stringify
({
"student_rating"
:
"report"
,
"hint"
:
hint
,
"student_answer"
:
student_answer
}),
success
:
function
()
{
Logger
.
log
(
'crowd_hinter.report_hint.click.event'
,
{
"hint"
:
hint
,
"student_answer"
:
student_answer
})
}
});
}}
$
(
element
).
on
(
'click'
,
'.csh_report_hint'
,
report_hint
(
$
(
this
)));
/**
/**
* Remove a reported hint from the reported
feedback
area (for staff only). Hints
* Remove a reported hint from the reported
moderation
area (for staff only). Hints
* are removed from the
feedback
area regardless of whether they are to be permanently removed
* are removed from the
moderation
area regardless of whether they are to be permanently removed
* from the hint pool or not. Called by staff_rate_hint.
* from the hint pool or not. Called by staff_rate_hint.
*/
*/
function
removeFeedback
(){
function
removeReportedHint
(){
$
(
'.csh_hint_value'
,
element
).
each
(
function
(){
Logger
.
log
(
'crowd_hinter.staff_rate_hint.click.event'
,
{
"hint"
:
hint
,
"student_answer"
:
student_answer
,
"rating"
:
rating
});
if
(
$
(
this
).
attr
(
'value'
)
==
hint
){
//TODO: change if statement, just find .csh_hint_value with attribute of hint
$
(
this
).
remove
();
$
(
".csh_hint_value[value='"
+
hint
+
"']"
,
element
).
remove
();
}
});
}
}
/**
/**
...
@@ -272,7 +277,7 @@ function CrowdsourceHinter(runtime, element, data){
...
@@ -272,7 +277,7 @@ function CrowdsourceHinter(runtime, element, data){
type
:
"POST"
,
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
'rate_hint'
),
url
:
runtime
.
handlerUrl
(
element
,
'rate_hint'
),
data
:
JSON
.
stringify
({
"student_rating"
:
rating
,
"hint"
:
hint
,
"student_answer"
:
student_answer
}),
data
:
JSON
.
stringify
({
"student_rating"
:
rating
,
"hint"
:
hint
,
"student_answer"
:
student_answer
}),
success
:
remove
Feedback
()
success
:
remove
ReportedHint
()
});
});
}}
}}
$
(
element
).
on
(
'click'
,
'.csh_staff_rate'
,
staff_rate_hint
(
$
(
this
)));
$
(
element
).
on
(
'click'
,
'.csh_staff_rate'
,
staff_rate_hint
(
$
(
this
)));
...
...
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