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