Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
544aa55e
Commit
544aa55e
authored
Jul 19, 2013
by
Felix Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added comments to explain confusing field names in crowdsource_hinter.
Fixed some pep8 errors.
parent
e2aea75f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
26 deletions
+9
-26
common/lib/xmodule/xmodule/crowdsource_hinter.py
+8
-21
common/lib/xmodule/xmodule/tests/test_crowdsource_hinter.py
+1
-5
No files found.
common/lib/xmodule/xmodule/crowdsource_hinter.py
View file @
544aa55e
...
...
@@ -16,10 +16,9 @@ from xmodule.x_module import XModule
from
xmodule.raw_module
import
RawDescriptor
from
xblock.core
import
Scope
,
String
,
Integer
,
Boolean
,
Dict
,
List
from
capa.responsetypes
import
FormulaResponse
,
StudentInputError
from
capa.responsetypes
import
FormulaResponse
from
calc
import
evaluator
,
UndefinedVariable
from
pyparsing
import
ParseException
from
calc
import
UndefinedVariable
from
django.utils.html
import
escape
...
...
@@ -43,9 +42,13 @@ class CrowdsourceHinterFields(object):
default
=
{})
hint_pk
=
Integer
(
help
=
'Used to index hints.'
,
scope
=
Scope
.
content
,
default
=
0
)
# A list of previous
answers this student made to this problem
.
# A list of previous
hints that a student viewed
.
# Of the form [answer, [hint_pk_1, ...]] for each problem.
# Sorry about the variable name - I know it's confusing.
previous_answers
=
List
(
help
=
'A list of hints viewed.'
,
scope
=
Scope
.
user_state
,
default
=
[])
# user_submissions actually contains a list of previous answers submitted.
# (Originally, preivous_answers did this job, hence the name confusion.)
user_submissions
=
List
(
help
=
'A list of previous submissions'
,
scope
=
Scope
.
user_state
,
default
=
[])
user_voted
=
Boolean
(
help
=
'Specifies if the user has voted on this problem or not.'
,
scope
=
Scope
.
user_state
,
default
=
False
)
...
...
@@ -231,22 +234,6 @@ class CrowdsourceHinterModule(CrowdsourceHinterFields, XModule):
return
{
'hints'
:
hints
,
'answer'
:
answer
}
# rand_hint_1 = ''
# rand_hint_2 = ''
# if n_hints == 2:
# best_hint = matching_hints.values()[0][0]
# best_hint_index = matching_hints.keys()[0]
# rand_hint_1 = matching_hints.values()[1][0]
# hint_index_1 = matching_hints.keys()[1]
# rand_hint_2 = ''
# self.previous_answers += [[answer, [best_hint_index, hint_index_1]]]
# else:
# (hint_index_1, rand_hint_1), (hint_index_2, rand_hint_2) =\
# random.sample(matching_hints.items(), 2)
# rand_hint_1 = rand_hint_1[0]
# rand_hint_2 = rand_hint_2[0]
# self.previous_answers += [[answer, [best_hint_index, hint_index_1, hint_index_2]]]
def
get_feedback
(
self
,
data
):
"""
The student got it correct. Ask him to vote on hints, or submit a hint.
...
...
@@ -295,7 +282,7 @@ class CrowdsourceHinterModule(CrowdsourceHinterFields, XModule):
'pk_list': A list of [answer, pk] pairs, each of which representing a hint.
We will return a list of how many votes each hint in the list has so far.
It's up to the browser to specify which hints to return vote counts for.
Returns key 'hint_and_votes', a list of (hint_text, #votes) pairs.
"""
if
self
.
user_voted
:
...
...
common/lib/xmodule/xmodule/tests/test_crowdsource_hinter.py
View file @
544aa55e
...
...
@@ -9,8 +9,6 @@ import copy
from
xmodule.crowdsource_hinter
import
CrowdsourceHinterModule
from
xmodule.vertical_module
import
VerticalModule
,
VerticalDescriptor
from
capa.responsetypes
import
StudentInputError
from
.
import
get_test_system
import
json
...
...
@@ -328,7 +326,6 @@ class CrowdsourceHinterTest(unittest.TestCase):
self
.
assertTrue
(
mock_module
.
previous_answers
==
old_answers
)
self
.
assertTrue
(
mock_module
.
user_submissions
==
old_user_submissions
)
def
test_gethint_1hint
(
self
):
"""
Someone asks for a hint, with exactly one hint in the database.
...
...
@@ -462,7 +459,6 @@ class CrowdsourceHinterTest(unittest.TestCase):
self
.
assertTrue
([
'Best hint'
,
41
]
in
hint_and_votes
)
self
.
assertTrue
(
len
(
hint_and_votes
)
==
1
)
def
test_submithint_nopermission
(
self
):
"""
A user tries to submit a hint, but he has already voted.
...
...
@@ -489,7 +485,7 @@ class CrowdsourceHinterTest(unittest.TestCase):
A user submits a hint to an answer that has other hints
already.
"""
mock_module
=
CHModuleFactory
.
create
(
previous_answers
=
[[
'25.0'
,
[
1
,
None
,
None
]]])
mock_module
=
CHModuleFactory
.
create
(
previous_answers
=
[[
'25.0'
,
[
1
,
None
,
None
]]])
json_in
=
{
'answer'
:
'25.0'
,
'hint'
:
'This is a new hint.'
}
mock_module
.
submit_hint
(
json_in
)
# Make a hint request.
...
...
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