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
e61f2c64
Commit
e61f2c64
authored
Jul 31, 2015
by
solashirai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small code cleanup
parent
2de82982
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
crowdsourcehinter/crowdsourcehinter.py
+12
-10
No files found.
crowdsourcehinter/crowdsourcehinter.py
View file @
e61f2c64
...
...
@@ -12,6 +12,7 @@ from xblock.fragment import Fragment
log
=
logging
.
getLogger
(
__name__
)
class
CrowdsourceHinter
(
XBlock
):
"""
This is the Crowdsource Hinter XBlock. This Xblock seeks to provide students with hints
...
...
@@ -80,7 +81,7 @@ class CrowdsourceHinter(XBlock):
"""
initial
=
ast
.
literal_eval
(
str
(
data
[
'initial_hints'
]))
generic
=
ast
.
literal_eval
(
str
(
data
[
'generic_hints'
]))
if
(
type
(
generic
)
is
list
and
type
(
initial
)
is
dict
)
:
if
type
(
generic
)
is
list
and
type
(
initial
)
is
dict
:
self
.
initial_hints
=
initial
self
.
generic_hints
=
generic
self
.
Element
=
str
(
data
[
'element'
])
...
...
@@ -135,9 +136,10 @@ class CrowdsourceHinter(XBlock):
self
.
hint_database
[
answers
]
=
{}
if
self
.
initial_hints
[
answers
]
not
in
self
.
hint_database
[
answers
]:
self
.
hint_database
[
answers
]
.
update
({
self
.
initial_hints
[
answers
]:
0
})
#self.hint_database = copy.copy(self.initial_hints)
answer
=
str
(
data
[
"submittedanswer"
])
answer
=
answer
.
lower
()
# for analyzing the student input string I make it lower case.
# put the student's answer to lower case so that differences in capitalization don't make
# different groups of hints. this is sloppy and the execution should probably be changed.
answer
=
answer
.
lower
()
found_equal_sign
=
0
remaining_hints
=
int
(
0
)
best_hint
=
""
...
...
@@ -156,8 +158,8 @@ class CrowdsourceHinter(XBlock):
if
remaining_hints
!=
str
(
0
):
for
hint
in
self
.
hint_database
[
str
(
answer
)]:
if
hint
not
in
self
.
reported_hints
.
keys
():
#if best_hint hasn't been set yet or the rating of hints is greater than the rating of best_hint
if
(
best_hint
==
""
or
self
.
hint_database
[
str
(
answer
)][
hint
]
>
self
.
hint_database
[
str
(
answer
)][
str
(
best_hint
)])
:
#
if best_hint hasn't been set yet or the rating of hints is greater than the rating of best_hint
if
best_hint
==
""
or
self
.
hint_database
[
str
(
answer
)][
hint
]
>
self
.
hint_database
[
str
(
answer
)][
str
(
best_hint
)]
:
best_hint
=
hint
self
.
used
.
append
(
best_hint
)
return
{
'BestHint'
:
best_hint
,
"StudentAnswer"
:
answer
}
...
...
@@ -180,7 +182,7 @@ class CrowdsourceHinter(XBlock):
Returns 0 if no hints to show exist
"""
isreported
=
[]
self
.
incorrect_answers
.
append
(
str
(
answer
))
# add the student's input to the temporary list
self
.
incorrect_answers
.
append
(
str
(
answer
))
if
str
(
answer
)
not
in
self
.
hint_database
:
# add incorrect answer to hint_database if no precedent exists
self
.
hint_database
[
str
(
answer
)]
=
{}
...
...
@@ -230,8 +232,8 @@ class CrowdsourceHinter(XBlock):
self
.
incorrect_answers
=
[]
self
.
used
=
[]
return
used_hint_answer_text
self
.
incorrect_answers
=
[]
self
.
used
=
[]
self
.
incorrect_answers
=
[]
self
.
used
=
[]
return
used_hint_answer_text
@XBlock.json_handler
...
...
@@ -267,7 +269,7 @@ class CrowdsourceHinter(XBlock):
# add hint to Reported dictionary
self
.
reported_hints
[
str
(
data_hint
)]
=
answer_data
return
{
"rating"
:
'reported'
,
'hint'
:
data_hint
}
rating
=
self
.
change_rating
(
data_hint
,
data_rating
,
answer_data
)
# change hint rating
rating
=
self
.
change_rating
(
data_hint
,
data_rating
,
answer_data
)
return
{
"rating"
:
str
(
rating
),
'hint'
:
data_hint
}
def
change_rating
(
self
,
data_hint
,
data_rating
,
answer_data
):
...
...
@@ -333,7 +335,7 @@ class CrowdsourceHinter(XBlock):
</crowdsourcehinter>
</verticaldemo>
"""
)
,
)
]
@classmethod
...
...
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