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
a0a51672
Commit
a0a51672
authored
Nov 28, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hook up testing for self assessment modules
parent
ba9280f3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
20 deletions
+46
-20
common/lib/xmodule/xmodule/self_assessment_module.py
+8
-17
common/lib/xmodule/xmodule/tests/__init__.py
+1
-1
common/lib/xmodule/xmodule/tests/test_progress.py
+2
-2
common/lib/xmodule/xmodule/tests/test_self_assessment.py
+35
-0
No files found.
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
a0a51672
...
@@ -109,15 +109,13 @@ class SelfAssessmentModule(XModule):
...
@@ -109,15 +109,13 @@ class SelfAssessmentModule(XModule):
self
.
state
=
instance_state
.
get
(
'state'
,
'initial'
)
self
.
state
=
instance_state
.
get
(
'state'
,
'initial'
)
self
.
attempts
=
instance_state
.
get
(
'attempts'
,
0
)
self
.
max_attempts
=
int
(
self
.
metadata
.
get
(
'attempts'
,
MAX_ATTEMPTS
))
# Used for progress / grading. Currently get credit just for
# Used for progress / grading. Currently get credit just for
# completion (doesn't matter if you self-assessed correct/incorrect).
# completion (doesn't matter if you self-assessed correct/incorrect).
self
.
_max_score
=
int
(
self
.
metadata
.
get
(
'max_score'
,
MAX_SCORE
))
self
.
_max_score
=
int
(
self
.
metadata
.
get
(
'max_score'
,
MAX_SCORE
))
self
.
attempts
=
instance_state
.
get
(
'attempts'
,
0
)
self
.
max_attempts
=
int
(
self
.
metadata
.
get
(
'attempts'
,
MAX_ATTEMPTS
))
self
.
rubric
=
definition
[
'rubric'
]
self
.
rubric
=
definition
[
'rubric'
]
self
.
prompt
=
definition
[
'prompt'
]
self
.
prompt
=
definition
[
'prompt'
]
self
.
submit_message
=
definition
[
'submitmessage'
]
self
.
submit_message
=
definition
[
'submitmessage'
]
...
@@ -149,26 +147,19 @@ class SelfAssessmentModule(XModule):
...
@@ -149,26 +147,19 @@ class SelfAssessmentModule(XModule):
# cdodge: perform link substitutions for any references to course static content (e.g. images)
# cdodge: perform link substitutions for any references to course static content (e.g. images)
return
rewrite_links
(
html
,
self
.
rewrite_content_links
)
return
rewrite_links
(
html
,
self
.
rewrite_content_links
)
def
get_score
(
self
):
"""
Returns dict with 'score' key
"""
return
{
'score'
:
self
.
get_last_score
()}
def
max_score
(
self
):
def
max_score
(
self
):
"""
"""
Return max_score
Return max_score
"""
"""
return
self
.
_max_score
return
self
.
_max_score
def
get_
last_
score
(
self
):
def
get_score
(
self
):
"""
"""
Returns the last score in the list
Returns the last score in the list
"""
"""
last_score
=
0
if
len
(
self
.
scores
)
>
0
:
if
(
len
(
self
.
scores
)
>
0
):
return
self
.
scores
[
-
1
]
last_score
=
self
.
scores
[
len
(
self
.
scores
)
-
1
]
return
0
return
last_score
def
get_progress
(
self
):
def
get_progress
(
self
):
'''
'''
...
@@ -176,7 +167,7 @@ class SelfAssessmentModule(XModule):
...
@@ -176,7 +167,7 @@ class SelfAssessmentModule(XModule):
'''
'''
if
self
.
_max_score
>
0
:
if
self
.
_max_score
>
0
:
try
:
try
:
return
Progress
(
self
.
get_
last_
score
(),
self
.
_max_score
)
return
Progress
(
self
.
get_score
(),
self
.
_max_score
)
except
Exception
as
err
:
except
Exception
as
err
:
log
.
exception
(
"Got bad progress"
)
log
.
exception
(
"Got bad progress"
)
return
None
return
None
...
...
common/lib/xmodule/xmodule/tests/__init__.py
View file @
a0a51672
...
@@ -19,7 +19,7 @@ import xmodule
...
@@ -19,7 +19,7 @@ import xmodule
from
xmodule.x_module
import
ModuleSystem
from
xmodule.x_module
import
ModuleSystem
from
mock
import
Mock
from
mock
import
Mock
i4xs
=
ModuleSystem
(
test_system
=
ModuleSystem
(
ajax_url
=
'courses/course_id/modx/a_location'
,
ajax_url
=
'courses/course_id/modx/a_location'
,
track_function
=
Mock
(),
track_function
=
Mock
(),
get_module
=
Mock
(),
get_module
=
Mock
(),
...
...
common/lib/xmodule/xmodule/tests/test_progress.py
View file @
a0a51672
...
@@ -5,7 +5,7 @@ import unittest
...
@@ -5,7 +5,7 @@ import unittest
from
xmodule.progress
import
Progress
from
xmodule.progress
import
Progress
from
xmodule
import
x_module
from
xmodule
import
x_module
from
.
import
i4xs
from
.
import
test_system
class
ProgressTest
(
unittest
.
TestCase
):
class
ProgressTest
(
unittest
.
TestCase
):
''' Test that basic Progress objects work. A Progress represents a
''' Test that basic Progress objects work. A Progress represents a
...
@@ -133,6 +133,6 @@ class ModuleProgressTest(unittest.TestCase):
...
@@ -133,6 +133,6 @@ class ModuleProgressTest(unittest.TestCase):
'''
'''
def
test_xmodule_default
(
self
):
def
test_xmodule_default
(
self
):
'''Make sure default get_progress exists, returns None'''
'''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
()
p
=
xm
.
get_progress
()
self
.
assertEqual
(
p
,
None
)
self
.
assertEqual
(
p
,
None
)
common/lib/xmodule/xmodule/tests/test_self_assessment.py
0 → 100644
View file @
a0a51672
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
=
{}
descriptor
=
Mock
()
def
test_import
(
self
):
state
=
json
.
dumps
({
'student_answers'
:
[],
'scores'
:
[],
'hints'
:
[],
'state'
:
'initial'
,
'attempts'
:
0
})
module
=
SelfAssessmentModule
(
test_system
,
self
.
location
,
self
.
definition
,
self
.
descriptor
,
state
,
{})
self
.
assertEqual
(
module
.
get_score
(),
0
)
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