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
c1d59878
Commit
c1d59878
authored
Sep 09, 2014
by
Sola
Committed by
Piotr Mitros
Oct 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated some functions to remove self.Used
parent
31d29b2f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
42 deletions
+37
-42
crowdxblock/crowdxblock.py
+32
-29
test_crowdxblock.py.orig
+0
-0
tests.py
+0
-13
tests.py.orig
+5
-0
No files found.
crowdxblock/crowdxblock.py
View file @
c1d59878
...
...
@@ -21,7 +21,7 @@ class CrowdXBlock(XBlock):
"""
# Database of hints. hints are stored as such: {"incorrect_answer": {"hint": rating}}. each key (incorrect answer)
# has a corresponding dictionary (in which hints are keys and the hints' ratings are the values).
hint_database
=
Dict
(
default
=
{
'answer'
:
{
'hint'
:
1
},
scope
=
Scope
.
user_state_summary
)
hint_database
=
Dict
(
default
=
{
'answer'
:
{
'hint'
:
5
}
},
scope
=
Scope
.
user_state_summary
)
# This is a dictionary of hints that will be used to determine what hints to show a student.
# flagged hints are not included in this dictionary of hints
HintsToUse
=
Dict
({},
scope
=
Scope
.
user_state
)
...
...
@@ -31,7 +31,7 @@ class CrowdXBlock(XBlock):
# A dictionary of default hints. default hints will be shown to students when there are no matches with the
# student's incorrect answer within the hint_database dictionary (i.e. no students have made hints for the
# particular incorrect answer)
DefaultHints
=
Dict
(
default
=
{},
scope
=
Scope
.
content
)
DefaultHints
=
Dict
(
default
=
{
'default_hint'
:
0
},
scope
=
Scope
.
content
)
# List of which hints from the HintsToUse dictionary have been shown to the student
# this list is used to prevent the same hint from showing up to a student (if they submit the same incorrect answers
# multiple times)
...
...
@@ -317,21 +317,26 @@ class CrowdXBlock(XBlock):
The rating associated with the hint is returned. This rating is identical
to what would be found under self.hint_database[answer_string[hint_string]]
"""
for
hint_keys
in
self
.
Used
:
if
str
(
hint_keys
)
==
str
(
answer_data
):
# use index of hint used to find the hint within self.hint_database
answer
=
self
.
Used
.
index
(
str
(
answer_data
))
for
answer_keys
in
self
.
hint_database
:
temporary_dictionary
=
str
(
self
.
hint_database
[
str
(
answer_keys
)])
temporary_dictionary
=
(
ast
.
literal_eval
(
temporary_dictionary
))
# if I remember correctly, changing the rating values in self.hint_database
# didn't work correctly for some reason, so instead I manipulated this
# temporary dictionary and then set self.hint_database to equal it.
# probably due to scope error (which also is affecting the studio interactions)
if
str
(
answer_keys
)
==
str
(
self
.
WrongAnswers
[
answer
]):
temporary_dictionary
[
self
.
Used
[
int
(
answer
)]]
+=
int
(
data_rating
)
self
.
hint_database
[
str
(
answer_keys
)]
=
temporary_dictionary
return
str
(
temporary_dictionary
[
self
.
Used
[
int
(
answer
)]])
temporary_dictionary
=
str
(
self
.
hint_database
[
str
(
answer_data
)])
temporary_dictionary
=
(
ast
.
literal_eval
(
temporary_dictionary
))
temporary_dictionary
[
str
(
data_value
)]
+=
int
(
data_rating
)
self
.
hint_database
[
str
(
answer_data
)]
=
temporary_dictionary
return
str
(
temporary_dictionary
[
str
(
data_value
)])
# for hint_keys in self.Used:
# if str(hint_keys) == str(answer_data):
# # use index of hint used to find the hint within self.hint_database
# answer = self.Used.index(str(answer_data))
# for answer_keys in self.hint_database:
# temporary_dictionary = str(self.hint_database[str(answer_keys)])
# temporary_dictionary = (ast.literal_eval(temporary_dictionary))
## # if I remember correctly, changing the rating values in self.hint_database
# # didn't work correctly for some reason, so instead I manipulated this
# # temporary dictionary and then set self.hint_database to equal it.
# # probably due to scope error (which also is affecting the studio interactions)
# if str(answer_keys) == str(self.WrongAnswers[answer]):
# temporary_dictionary[self.Used[int(answer)]] += int(data_rating)
# self.hint_database[str(answer_keys)] = temporary_dictionary
# return str(temporary_dictionary[self.Used[int(answer)]])
def
remove_symbols
(
self
,
answer_data
):
"""
...
...
@@ -383,9 +388,9 @@ class CrowdXBlock(XBlock):
data['answer']: This is the incorrect answer for which the student is submitting a new hint.
"""
submission
=
data
[
'submission'
]
.
replace
(
'ddeecciimmaallppooiinntt'
,
'.'
)
hint_id
=
data
[
'answer'
]
.
replace
(
'ddeecciimmaallppooiinntt'
,
'.'
)
answer
=
data
[
'answer'
]
.
replace
(
'ddeecciimmaallppooiinntt'
,
'.'
)
for
answer_keys
in
self
.
hint_database
:
if
str
(
answer_keys
)
==
s
elf
.
WrongAnswers
[
self
.
Used
.
index
(
hint_id
)]
:
if
str
(
answer_keys
)
==
s
tr
(
answer
)
:
# find the answer for which a hint is being submitted
if
str
(
submission
)
not
in
self
.
hint_database
[
str
(
answer_keys
)]:
temporary_dictionary
=
str
(
self
.
hint_database
[
str
(
answer_keys
)])
...
...
@@ -398,17 +403,15 @@ class CrowdXBlock(XBlock):
return
else
:
# if the hint exists already, simply upvote the previously entered hint
hint_index
=
self
.
Used
.
index
(
submission
)
for
default_hints
in
self
.
DefaultHints
:
if
default_hints
==
self
.
Used
[
int
(
hint_index
)]:
self
.
DefaultHints
[
str
(
default_hints
)]
+=
int
(
1
)
return
for
answer_keys
in
self
.
hint_database
:
temporary_dictionary
=
str
(
self
.
hint_database
[
str
(
answer_keys
)])
if
str
(
submission
)
in
self
.
DefaultHints
:
self
.
DefaultHints
[
str
(
submission
)]
+=
int
(
1
)
return
else
:
temporary_dictionary
=
str
(
self
.
hint_database
[
str
(
answer
)])
temporary_dictionary
=
(
ast
.
literal_eval
(
temporary_dictionary
))
if
str
(
answer_keys
)
==
str
(
self
.
WrongAnswers
[
int
(
hint_index
)]):
temporary_dictionary
[
self
.
Used
[
int
(
hint_index
)]]
+=
int
(
data
[
'rating'
])
self
.
hint_database
[
str
(
answer_keys
)]
=
temporary_dictionary
temporary_dictionary
[
str
(
submission
)]
+=
int
(
data
[
'rating'
])
self
.
hint_database
[
str
(
answer
)]
=
temporary_dictionary
return
@XBlock.json_handler
def
studiodata
(
self
,
data
,
suffix
=
''
):
...
...
test_crowdxblock.py
→
test_crowdxblock.py
.orig
View file @
c1d59878
File moved
tests.py
deleted
100644 → 0
View file @
31d29b2f
def
test_rate_hint
(
self
):
'''
This test should test the rate_hint in crowdxblock,
in the event that the rating increases by 1.
'''
resp
=
self
.
call_event
(
'rate_hint'
,
{
'student_rating'
:
1
,
'value'
:
'hint'
,
'answer'
:
'answer
}
)
self.assertEqual(resp['
rating
'], 2)
tests.py.orig
0 → 100644
View file @
c1d59878
<<<<<<< HEAD
def test_
=======
>>>>>>> a516fdcde03b0e9b01eb6618b4a24754e5b52783
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