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
82cf37b2
Commit
82cf37b2
authored
Nov 29, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1085 from MITx/feature/victor/fix-self-assessment
Feature/victor/fix self assessment
parents
68158b39
4b58cb95
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
224 additions
and
72 deletions
+224
-72
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
+1
-1
common/lib/xmodule/xmodule/self_assessment_module.py
+138
-53
common/lib/xmodule/xmodule/tests/__init__.py
+4
-3
common/lib/xmodule/xmodule/tests/test_progress.py
+2
-2
common/lib/xmodule/xmodule/tests/test_self_assessment.py
+54
-0
common/lib/xmodule/xmodule/x_module.py
+25
-13
No files found.
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
View file @
82cf37b2
...
...
@@ -120,7 +120,7 @@ class @SelfAssessment
if
@
state
==
'done'
$
.
postWithPrefix
"
#{
@
ajax_url
}
/reset"
,
{},
(
response
)
=>
if
response
.
success
@
answer_area
.
htm
l
(
''
)
@
answer_area
.
va
l
(
''
)
@
rubric_wrapper
.
html
(
''
)
@
hint_wrapper
.
html
(
''
)
@
message_wrapper
.
html
(
''
)
...
...
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
82cf37b2
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/tests/__init__.py
View file @
82cf37b2
...
...
@@ -4,7 +4,7 @@ unittests for xmodule
Run like this:
rake test_common/lib/xmodule
"""
import
unittest
...
...
@@ -19,11 +19,12 @@ import xmodule
from
xmodule.x_module
import
ModuleSystem
from
mock
import
Mock
i4xs
=
ModuleSystem
(
test_system
=
ModuleSystem
(
ajax_url
=
'courses/course_id/modx/a_location'
,
track_function
=
Mock
(),
get_module
=
Mock
(),
render_template
=
Mock
(),
# "render" to just the context...
render_template
=
lambda
template
,
context
:
str
(
context
),
replace_urls
=
Mock
(),
user
=
Mock
(),
filestore
=
Mock
(),
...
...
common/lib/xmodule/xmodule/tests/test_progress.py
View file @
82cf37b2
...
...
@@ -5,7 +5,7 @@ import unittest
from
xmodule.progress
import
Progress
from
xmodule
import
x_module
from
.
import
i4xs
from
.
import
test_system
class
ProgressTest
(
unittest
.
TestCase
):
''' Test that basic Progress objects work. A Progress represents a
...
...
@@ -133,6 +133,6 @@ class ModuleProgressTest(unittest.TestCase):
'''
def
test_xmodule_default
(
self
):
'''Make sure default get_progress exists, returns None'''
xm
=
x_module
.
XModule
(
i4xs
,
'a://b/c/d/e'
,
None
,
{})
xm
=
x_module
.
XModule
(
test_system
,
'a://b/c/d/e'
,
None
,
{})
p
=
xm
.
get_progress
()
self
.
assertEqual
(
p
,
None
)
common/lib/xmodule/xmodule/tests/test_self_assessment.py
0 → 100644
View file @
82cf37b2
import
json
from
mock
import
Mock
import
unittest
from
xmodule.self_assessment_module
import
SelfAssessmentModule
from
xmodule.modulestore
import
Location
from
.
import
test_system
class
SelfAssessmentTest
(
unittest
.
TestCase
):
definition
=
{
'rubric'
:
'A rubric'
,
'prompt'
:
'Who?'
,
'submitmessage'
:
'Shall we submit now?'
,
'hintprompt'
:
'Consider this...'
,
}
location
=
Location
([
"i4x"
,
"edX"
,
"sa_test"
,
"selfassessment"
,
"SampleQuestion"
])
metadata
=
{
'attempts'
:
'10'
}
descriptor
=
Mock
()
def
test_import
(
self
):
state
=
json
.
dumps
({
'student_answers'
:
[
"Answer 1"
,
"answer 2"
,
"answer 3"
],
'scores'
:
[
0
,
1
],
'hints'
:
[
'o hai'
],
'state'
:
SelfAssessmentModule
.
ASSESSING
,
'attempts'
:
2
})
module
=
SelfAssessmentModule
(
test_system
,
self
.
location
,
self
.
definition
,
self
.
descriptor
,
state
,
{},
metadata
=
self
.
metadata
)
self
.
assertEqual
(
module
.
get_score
()[
'score'
],
0
)
self
.
assertTrue
(
'answer 3'
in
module
.
get_html
())
self
.
assertFalse
(
'answer 2'
in
module
.
get_html
())
module
.
save_assessment
({
'assessment'
:
'0'
})
self
.
assertEqual
(
module
.
state
,
module
.
REQUEST_HINT
)
module
.
save_hint
({
'hint'
:
'hint for ans 3'
})
self
.
assertEqual
(
module
.
state
,
module
.
DONE
)
d
=
module
.
reset
({})
self
.
assertTrue
(
d
[
'success'
])
self
.
assertEqual
(
module
.
state
,
module
.
INITIAL
)
# if we now assess as right, skip the REQUEST_HINT state
module
.
save_answer
({
'student_answer'
:
'answer 4'
})
module
.
save_assessment
({
'assessment'
:
'1'
})
self
.
assertEqual
(
module
.
state
,
module
.
DONE
)
common/lib/xmodule/xmodule/x_module.py
View file @
82cf37b2
...
...
@@ -233,17 +233,17 @@ class XModule(HTMLSnippet):
self
.
_loaded_children
=
[
c
for
c
in
children
if
c
is
not
None
]
return
self
.
_loaded_children
def
get_children_locations
(
self
):
'''
Returns the locations of each of child modules.
Overriding this changes the behavior of get_children and
anything that uses get_children, such as get_display_items.
This method will not instantiate the modules of the children
unless absolutely necessary, so it is cheaper to call than get_children
These children will be the same children returned by the
descriptor unless descriptor.has_dynamic_children() is true.
'''
...
...
@@ -288,8 +288,20 @@ class XModule(HTMLSnippet):
return
'{}'
def
get_score
(
self
):
''' Score the student received on the problem.
'''
"""
Score the student received on the problem, or None if there is no
score.
Returns:
dictionary
{'score': integer, from 0 to get_max_score(),
'total': get_max_score()}
NOTE (vshnayder): not sure if this was the intended return value, but
that's what it's doing now. I suspect that we really want it to just
return a number. Would need to change (at least) capa and
modx_dispatch to match if we did that.
"""
return
None
def
max_score
(
self
):
...
...
@@ -319,7 +331,7 @@ class XModule(HTMLSnippet):
get is a dictionary-like object '''
return
""
# cdodge: added to support dynamic substitutions of
# cdodge: added to support dynamic substitutions of
# links for courseware assets (e.g. images). <link> is passed through from lxml.html parser
def
rewrite_content_links
(
self
,
link
):
# see if we start with our format, e.g. 'xasset:<filename>'
...
...
@@ -408,7 +420,7 @@ class XModuleDescriptor(Plugin, HTMLSnippet, ResourceTemplates):
# cdodge: this is a list of metadata names which are 'system' metadata
# and should not be edited by an end-user
system_metadata_fields
=
[
'data_dir'
]
# A list of descriptor attributes that must be equal for the descriptors to
# be equal
equality_attributes
=
(
'definition'
,
'metadata'
,
'location'
,
...
...
@@ -562,18 +574,18 @@ class XModuleDescriptor(Plugin, HTMLSnippet, ResourceTemplates):
self
,
metadata
=
self
.
metadata
)
def
has_dynamic_children
(
self
):
"""
Returns True if this descriptor has dynamic children for a given
student when the module is created.
Returns False if the children of this descriptor are the same
children that the module will return for any student.
children that the module will return for any student.
"""
return
False
# ================================= JSON PARSING ===========================
@staticmethod
...
...
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