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
cd45bc0a
Commit
cd45bc0a
authored
Nov 24, 2014
by
solashirai
Committed by
Piotr Mitros
Oct 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing hint flagging
parent
4d6e4c0f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
42 deletions
+45
-42
crowdsourcehinter/crowdsourcehinter.py
+15
-20
crowdsourcehinter/static/css/crowdsourcehinter.css
+10
-5
crowdsourcehinter/static/html/crowdsourcehinter.html
+13
-9
crowdsourcehinter/static/js/src/crowdsourcehinter.js
+7
-8
No files found.
crowdsourcehinter/crowdsourcehinter.py
View file @
cd45bc0a
...
...
@@ -38,10 +38,10 @@ class CrowdsourceHinter(XBlock):
# i believe this will also prevent students from voting again on a particular hint if they were to return to
# a particular problem later
Voted
=
List
(
default
=
[],
scope
=
Scope
.
user_state
)
# This is a dictionary of hints that have been flagged. the
key
s represent the incorrect answer submission, and the
#
values are the hints the corresponding hints. even if a hint is flagged, if the hint shows up for a different
#
incorrect answer, i believe that the hint will still be able to show for a student
Flagged
=
Dict
(
default
=
{
"
answer2"
:
"This is a hint that should be flagged
"
},
scope
=
Scope
.
user_state_summary
)
# This is a dictionary of hints that have been flagged. the
value
s represent the incorrect answer submission, and the
#
keys are the hints the corresponding hints. hints with identical text for differing answers will all not show up for the
#
student.
Flagged
=
Dict
(
default
=
{
"
This is a hint that should be flagged"
:
"answer2
"
},
scope
=
Scope
.
user_state_summary
)
# This string determines whether or not to show only the best (highest rated) hint to a student
# When set to 'True' only the best hint will be shown to the student.
# Details on operation when set to 'False' are to be finalized.
...
...
@@ -185,7 +185,7 @@ class CrowdsourceHinter(XBlock):
return
str
(
0
)
for
hint_keys
in
self
.
hint_database
[
str
(
answer
)]:
for
flagged_keys
in
self
.
Flagged
:
if
str
(
hint_keys
)
==
str
(
flagged_keys
)
:
if
hint_keys
==
flagged_keys
:
isflagged
.
append
(
hint_keys
)
if
str
(
hint_keys
)
in
self
.
Used
:
isused
+=
1
...
...
@@ -218,11 +218,9 @@ class CrowdsourceHinter(XBlock):
for
hints
in
self
.
hint_database
[
str
(
answer_keys
)]:
if
len
(
self
.
Flagged
)
!=
0
:
for
flagged_hints
in
self
.
Flagged
:
if
str
(
hints
)
!=
self
.
Flagged
[
flagged_hints
]:
feedback_data
[
str
(
hints
)]
=
str
(
answer_keys
)
else
:
if
str
(
hints
)
==
flagged_hints
:
feedback_data
[
str
(
hints
)]
=
str
(
"Flagged"
)
else
:
if
hints
not
in
feedback_data
.
keys
()
:
feedback_data
[
str
(
hints
)]
=
str
(
answer_keys
)
else
:
feedback_data
[
None
]
=
str
(
answer_keys
)
...
...
@@ -308,27 +306,25 @@ class CrowdsourceHinter(XBlock):
"rating": The rating of the hint.
"""
answer_data
=
data
[
'student_answer'
]
# answer_data is manipulated to remove symbols to prevent errors that
# might arise due to certain symbols. I don't think I have this fully working but am not sure.
data_rating
=
data
[
'student_rating'
]
data_hint
=
data
[
'hint'
]
if
data
[
'student_rating'
]
==
'unflag'
:
for
flagged_hints
in
self
.
Flagged
:
if
self
.
Flagged
[
str
(
flagged_hints
)]
==
data_hint
:
del
self
.
Flagged
[
flagged_hints
]
if
flagged_hints
==
data_hint
:
self
.
Flagged
.
pop
(
data_hint
,
None
)
return
{
'rating'
:
'unflagged'
}
if
data
[
'student_rating'
]
==
'remove'
:
for
flagged_
answer
in
self
.
Flagged
:
if
self
.
Flagged
[
flagged_answer
]
==
data_hint
:
temporary_dict
=
str
(
self
.
hint_database
[
s
tr
(
flagged_answer
)
])
for
flagged_
hints
in
self
.
Flagged
:
if
data_hint
==
flagged_hints
:
temporary_dict
=
str
(
self
.
hint_database
[
s
elf
.
Flagged
[
data_hint
]
])
temporary_dict
=
(
ast
.
literal_eval
(
temporary_dict
))
temporary_dict
.
pop
(
data_hint
,
None
)
self
.
hint_database
[
s
tr
(
flagged_answer
)
]
=
temporary_dict
del
self
.
Flagged
[
flagged_answer
]
self
.
hint_database
[
s
elf
.
Flagged
[
data_hint
]
]
=
temporary_dict
self
.
Flagged
.
pop
(
data_hint
,
None
)
return
{
'rating'
:
'removed'
}
if
data
[
'student_rating'
]
==
'flag'
:
# add hint to Flagged dictionary
self
.
Flagged
[
str
(
answer_data
)]
=
data_hint
self
.
Flagged
[
str
(
data_hint
)]
=
answer_data
return
{
"rating"
:
'flagged'
,
'hint'
:
data_hint
}
if
str
(
data_hint
)
not
in
self
.
Voted
:
self
.
Voted
.
append
(
str
(
data_hint
))
# add data to Voted to prevent multiple votes
...
...
@@ -339,7 +335,6 @@ class CrowdsourceHinter(XBlock):
return
{
"rating"
:
str
(
rating
),
'hint'
:
data_hint
}
else
:
return
{
"rating"
:
str
(
'voted'
),
'hint'
:
data_hint
}
self
.
Flagged
[
str
(
data_hint
)]
=
str
(
answer_data
)
def
change_rating
(
self
,
data_hint
,
data_rating
,
answer_data
):
"""
...
...
crowdsourcehinter/static/css/crowdsourcehinter.css
View file @
cd45bc0a
...
...
@@ -14,25 +14,30 @@
.csh_hint_value
{
display
:
flex
;
margin-left
:
10px
;
flex-flow
:
column
;
column-count
:
2
;
}
.csh_hint_used
{
flex-direction
:
row
;
.csh_rating_data
{
width
:
3%
;
vertical-align
:
middle
;
}
.crowdsourcehinter_block
.csh_HintsToUse
{
background-color
:
#FF8
;
}
.csh_hint_data
{
width
:
97%
;
}
.csh_rate_hint
{
width
:
100%
;
margin-left
:
auto
;
margin-right
:
auto
;
}
div
[
data-rate
=
"flag"
]
{
float
:
right
;
div
[
data-rate
=
"flag"
]
{
float
:
center
;
}
div
[
data-rate
=
"upvote"
]
{
...
...
crowdsourcehinter/static/html/crowdsourcehinter.html
View file @
cd45bc0a
<script
type=
'x-tmpl/mustache'
id=
'show_hint_feedback'
>
<
div
class
=
'csh_hint_value'
value
=
"{{hintvalue}}"
>
<
div
role
=
"button"
class
=
"csh_rate_hint"
data
-
rate
=
"upvote"
data
-
icon
=
"arrow-u"
aria
-
label
=
"upvote"
>
<
b
>
↑
<
/b
>
<
div
class
=
'csh_rating_data'
>
<
div
role
=
"button"
class
=
"csh_rate_hint"
data
-
rate
=
"upvote"
data
-
icon
=
"arrow-u"
aria
-
label
=
"upvote"
>
<
b
>
↑
<
/b
>
<
/div
>
<
div
class
=
"csh_rating"
>
{{
rating
}}
<
/div
>
<
div
role
=
"button"
class
=
"csh_rate_hint"
data
-
rate
=
"downvote"
aria
-
label
=
"downvote"
>
<
b
>
↓
<
/b
>
<
/div
>
<
/div
>
<
div
class
=
"csh_rating"
>
{{
rating
}}
<
/div
>
<
div
class
=
"csh_hint"
>
{{
hint
}}
<
/div
>
<
div
role
=
"button"
class
=
"csh_rate_hint"
data
-
rate
=
"downvote"
aria
-
label
=
"downvote"
>
<
b
>
↓
<
/b
>
<
/div
>
<
div
role
=
"button"
class
=
"csh_rate_hint"
data
-
rate
=
"flag"
data
-
icon
=
"flag"
aria
-
label
=
"flag"
>
<
b
>
Report
this
hint
<
/b
>
<
div
class
=
'csh_hint_data'
>
<
div
class
=
"csh_hint"
>
{{
hint
}}
<
/div
>
<
div
role
=
"button"
class
=
"csh_rate_hint"
data
-
rate
=
"flag"
data
-
icon
=
"flag"
aria
-
label
=
"flag"
>
<
b
>
Report
this
hint
<
/b
>
<
/div
>
<
/div
>
<
/div
>
</script>
...
...
crowdsourcehinter/static/js/src/crowdsourcehinter.js
View file @
cd45bc0a
...
...
@@ -147,7 +147,6 @@ function CrowdsourceHinter(runtime, element){
html
=
Mustache
.
render
(
template
,
data
);
});
$
(
this
).
append
(
html
);
// $(this).append("<div class=\"csh_hint_value\" value=\"There are no answer-specific hints for this answer.\"></div>");
}
});
}
...
...
@@ -191,7 +190,6 @@ function CrowdsourceHinter(runtime, element){
html
=
Mustache
.
render
(
template
,
data
);
});
$
(
this
).
append
(
html
);
//$(this).append("<p><input type=\"text\" name=\"studentinput\" class=\"csh_student_text_input\" size=\"40\"><input answer=\""+student_answer+"\" type=\"button\" class=\"csh_submit_new\" value=\"Submit Hint\"> </p>");
}
});
})
...
...
@@ -224,8 +222,8 @@ function CrowdsourceHinter(runtime, element){
$
(
element
).
on
(
'click'
,
'.csh_rate_hint'
,
function
(){
//Click event to change the rating/flag a hint. The attribute 'data-rate' within each .rate_hint button is used
//to determine whether the student is upvoting, downvoting, or flagging the hint.
hint
=
$
(
this
).
parent
().
find
(
".csh_hint"
).
text
();
student_answer
=
$
(
this
).
parent
().
parent
().
find
(
"span"
).
text
();
hint
=
$
(
this
).
parent
().
parent
().
find
(
".csh_hint"
).
text
();
student_answer
=
$
(
this
).
parent
().
parent
().
parent
().
find
(
"span"
).
text
();
Logger
.
log
(
'crowd_hinter.rate_hint.click.event'
,
{
"hint"
:
hint
,
"student_answer"
:
student_answer
,
"rating"
:
$
(
this
).
attr
(
'data-rate'
)});
$
.
ajax
({
type
:
"POST"
,
...
...
@@ -233,13 +231,14 @@ function CrowdsourceHinter(runtime, element){
data
:
JSON
.
stringify
({
"student_rating"
:
$
(
this
).
attr
(
'data-rate'
),
"hint"
:
hint
,
"student_answer"
:
student_answer
}),
success
:
function
(
result
){
if
(
result
.
rating
==
"flagged"
){
$
(
this
).
parent
().
hide
();
$
(
this
).
parent
().
remove
();
//hide hint if it was flagged by the student
$
(
this
).
parent
().
parent
().
hide
();
$
(
this
).
parent
().
parent
().
remove
();
}
else
if
(
result
.
rating
!=
"voted"
){
$
(
".csh_hint"
,
element
).
each
(
function
(){
if
(
$
(
this
).
parent
().
find
(
".csh_hint"
).
text
()
==
hint
&&
$
(
this
).
parent
().
parent
().
find
(
"span"
).
text
()
==
student_answer
){
$
(
this
).
parent
().
find
(
'.csh_rating'
).
text
(
result
.
rating
);
if
(
$
(
this
).
parent
().
parent
().
find
(
".csh_hint"
).
text
()
==
hint
&&
$
(
this
).
parent
(
).
parent
().
parent
().
find
(
"span"
).
text
()
==
student_answer
){
$
(
this
).
parent
().
parent
().
find
(
'.csh_rating'
).
text
(
result
.
rating
);
}
})
}
...
...
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