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
7667b206
Commit
7667b206
authored
Apr 13, 2015
by
solashirai
Committed by
Piotr Mitros
Oct 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code improvement
parent
14587bca
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
8 deletions
+8
-8
crowdsourcehinter/crowdsourcehinter.py
+7
-7
crowdsourcehinter/static/html/crowdsourcehinter.html
+1
-1
crowdsourcehinter/static/js/src/crowdsourcehinter.js
+0
-0
No files found.
crowdsourcehinter/crowdsourcehinter.py
View file @
7667b206
...
...
@@ -102,7 +102,7 @@ class CrowdsourceHinter(XBlock):
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/crowdsourcehinter.css"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/crowdsourcehinter.js"
))
frag
.
initialize_js
(
'CrowdsourceHinter'
,
{
'hinting_element'
:
self
.
Element
,
'isStaff'
:
self
.
Element
})
frag
.
initialize_js
(
'CrowdsourceHinter'
,
{
'hinting_element'
:
self
.
Element
,
'isStaff'
:
self
.
xmodule_runtime
.
user_is_staff
})
return
frag
@XBlock.json_handler
...
...
@@ -115,7 +115,7 @@ class CrowdsourceHinter(XBlock):
data['submittedanswer']: The string of text that the student submits for a problem.
returns:
'Hints
ToUse
': the highest rated hint for an incorrect answer
'Hints': the highest rated hint for an incorrect answer
or another random hint for an incorrect answer
or 'Sorry, there are no more hints for this answer.' if no more hints exist
"""
...
...
@@ -146,12 +146,12 @@ class CrowdsourceHinter(XBlock):
# currently set by default to True
if
best_hint
not
in
self
.
Reported
.
keys
():
self
.
Used
.
append
(
best_hint
)
return
{
'Hints
ToUse
'
:
best_hint
,
"StudentAnswer"
:
answer
}
return
{
'Hints'
:
best_hint
,
"StudentAnswer"
:
answer
}
if
best_hint
not
in
self
.
Used
:
# choose highest rated hint for the incorrect answer
if
best_hint
not
in
self
.
Reported
.
keys
():
self
.
Used
.
append
(
best_hint
)
return
{
'Hints
ToUse
'
:
best_hint
,
"StudentAnswer"
:
answer
}
return
{
'Hints'
:
best_hint
,
"StudentAnswer"
:
answer
}
# choose another random hint for the answer.
temporary_hints_list
=
[]
for
hint_keys
in
self
.
hint_database
[
str
(
answer
)]:
...
...
@@ -160,16 +160,16 @@ class CrowdsourceHinter(XBlock):
temporary_hints_list
.
append
(
str
(
hint_keys
))
not_used
=
random
.
choice
(
temporary_hints_list
)
self
.
Used
.
append
(
not_used
)
return
{
'Hints
ToUse
'
:
not_used
,
"StudentAnswer"
:
answer
}
return
{
'Hints'
:
not_used
,
"StudentAnswer"
:
answer
}
# find generic hints for the student if no specific hints exist
if
len
(
self
.
generic_hints
)
!=
0
:
not_used
=
random
.
choice
(
self
.
generic_hints
)
self
.
Used
.
append
(
not_used
)
return
{
'Hints
ToUse
'
:
not_used
,
"StudentAnswer"
:
answer
}
return
{
'Hints'
:
not_used
,
"StudentAnswer"
:
answer
}
else
:
# if there are no more hints left in either the database or defaults
self
.
Used
.
append
(
str
(
"There are no hints for"
+
" "
+
answer
))
return
{
'Hints
ToUse
'
:
"Sorry, there are no hints for this answer."
,
"StudentAnswer"
:
answer
}
return
{
'Hints'
:
"Sorry, there are no hints for this answer."
,
"StudentAnswer"
:
answer
}
def
find_hints
(
self
,
answer
):
"""
...
...
crowdsourcehinter/static/html/crowdsourcehinter.html
View file @
7667b206
...
...
@@ -62,7 +62,7 @@
<div
class=
"crowdsourcehinter_block"
>
<div
class=
'csh_hint_reveal'
>
<div
class=
'csh_Hints
ToUse
'
student_answer =
''
hint_received=
''
>
<div
class=
'csh_Hints'
student_answer =
''
hint_received=
''
>
</div>
<div
class=
'csh_HintQuickFeedback'
>
<div
role=
"button"
class=
"csh_rate_hint"
data-rate=
"upvote"
title=
"This hint was helpful!"
>
...
...
crowdsourcehinter/static/js/src/crowdsourcehinter.js
View file @
7667b206
This diff is collapsed.
Click to expand it.
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