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
20d3c860
Commit
20d3c860
authored
Jul 15, 2014
by
Sola
Committed by
Piotr Mitros
Oct 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no longer crash when hints run dry (gives "no more hints" instead)
parent
143c40ab
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
9 deletions
+5
-9
crowdxblock/crowdxblock.py
+2
-4
crowdxblock/crowdxblock.pyc
+0
-0
crowdxblock/crowdxblock.py~
+3
-5
No files found.
crowdxblock/crowdxblock.py
View file @
20d3c860
...
...
@@ -60,11 +60,11 @@ class CrowdXBlock(XBlock):
return
{
'HintsToUse'
:
max
(
self
.
HintsToUse
.
iteritems
(),
key
=
operator
.
itemgetter
(
1
))[
0
]}
else
:
NotUsed
=
random
.
choice
(
self
.
HintsToUse
.
keys
())
if
len
(
self
.
HintsToUse
)
!=
len
(
self
.
Used
):
if
len
(
self
.
HintsToUse
)
>
len
(
self
.
Used
):
while
NotUsed
in
self
.
Used
:
NotUsed
=
random
.
choice
(
self
.
HintsToUse
.
keys
())
#Choose random hint that hasn't already been Used
elif
len
(
self
.
Used
)
>
0
:
return
{
'HintsToUse'
:
random
.
choice
(
self
.
HintsToUse
.
keys
())
}
return
{
'HintsToUse'
:
"Sorry, there are no more hints for this answer."
}
self
.
Used
.
append
(
NotUsed
)
return
{
'HintsToUse'
:
NotUsed
}
#note to self dont let python get into endless notused loop
...
...
@@ -147,8 +147,6 @@ class CrowdXBlock(XBlock):
data
[
'id'
]
=
data
[
'id'
]
.
replace
(
'ddeecciimmaallppooiinntt'
,
'.'
)
if
self
.
Voted
==
0
:
for
key
in
self
.
hints
:
print
(
str
(
key
))
print
(
"still working here"
)
if
str
(
key
)
==
self
.
WrongAnswers
[
self
.
Used
.
index
(
str
(
data
[
'id'
]))]:
if
str
(
data
[
'submission'
])
not
in
self
.
hints
[
str
(
key
)]:
tempdict
=
str
(
self
.
hints
[
str
(
key
)])
#rate hint that is in hints
...
...
crowdxblock/crowdxblock.pyc
View file @
20d3c860
No preview for this file type
crowdxblock/crowdxblock.py~
View file @
20d3c860
...
...
@@ -60,11 +60,11 @@ class CrowdXBlock(XBlock):
return {'HintsToUse': max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0]}
else:
NotUsed = random.choice(self.HintsToUse.keys())
if len(self.HintsToUse)
!=
len(self.Used):
if len(self.HintsToUse)
>
len(self.Used):
while NotUsed in self.Used:
NotUsed = random.choice(self.HintsToUse.keys()) #Choose random hint that hasn't already been Used
elif len(self.Used) > 0:
return {'HintsToUse':
random.choice(self.HintsToUse.keys())
}
return {'HintsToUse':
"Sorry, there are no more hints."
}
self.Used.append(NotUsed)
return {'HintsToUse': NotUsed} #note to self dont let python get into endless notused loop
...
...
@@ -144,11 +144,9 @@ class CrowdXBlock(XBlock):
@XBlock.json_handler
def give_hint(self, data, suffix=''): #add student-made hint into hints
data['submission'] = data['submission'].replace('ddeecciimmaallppooiinntt', '.')
data['id'] = data['id'].replace('
qquueessttiioonnmmaarrkk', '?
')
data['id'] = data['id'].replace('
ddeecciimmaallppooiinntt', '.
')
if self.Voted == 0:
for key in self.hints:
print(str(key))
print("still working here")
if str(key) == self.WrongAnswers[self.Used.index(str(data['id']))]:
if str(data['submission']) not in self.hints[str(key)]:
tempdict = str(self.hints[str(key)]) #rate hint that is in hints
...
...
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