Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
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-ora2
Commits
2c2192b7
Commit
2c2192b7
authored
Feb 02, 2015
by
Usman Khalid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update student training examples format for multiple answers.
TNL-708
parent
5afc5007
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
107 additions
and
18 deletions
+107
-18
openassessment/assessment/api/student_training.py
+25
-5
openassessment/assessment/serializers/training.py
+5
-1
openassessment/xblock/data_conversion.py
+39
-2
openassessment/xblock/openassessmentblock.py
+3
-2
openassessment/xblock/test/data/student_training.xml
+5
-2
openassessment/xblock/test/data/student_training_due.xml
+5
-2
openassessment/xblock/test/data/student_training_future.xml
+5
-2
openassessment/xblock/test/data/student_training_mixin.json
+8
-1
openassessment/xblock/test/test_data_conversion.py
+12
-1
No files found.
openassessment/assessment/api/student_training.py
View file @
2c2192b7
...
...
@@ -146,14 +146,14 @@ def validate_training_examples(rubric, examples):
>>>
>>> examples = [
>>> {
>>> 'answer':
u'Lorem ipsum'
,
>>> 'answer':
{'parts': [{'text': u'Lorem ipsum'}]}
,
>>> 'options_selected': {
>>> 'vocabulary': 'good',
>>> 'grammar': 'excellent'
>>> }
>>> },
>>> {
>>> 'answer':
u'Doler'
,
>>> 'answer':
{'parts': [{'text': u'Doler'}]}
,
>>> 'options_selected': {
>>> 'vocabulary': 'good',
>>> 'grammar': 'poor'
...
...
@@ -312,7 +312,15 @@ def get_training_example(submission_uuid, rubric, examples):
>>> examples = [
>>> {
>>> 'answer': u'Doler',
>>> 'answer': {
>>> 'parts': {
>>> [
>>> {'text:' 'Answer part 1'},
>>> {'text:' 'Answer part 2'},
>>> {'text:' 'Answer part 3'}
>>> ]
>>> }
>>> },
>>> 'options_selected': {
>>> 'vocabulary': 'good',
>>> 'grammar': 'poor'
...
...
@@ -322,9 +330,21 @@ def get_training_example(submission_uuid, rubric, examples):
>>>
>>> get_training_example("5443ebbbe2297b30f503736e26be84f6c7303c57", rubric, examples)
{
'answer': u'Lorem ipsum',
'answer': {
'parts': {
[
{'text:' 'Answer part 1'},
{'text:' 'Answer part 2'},
{'text:' 'Answer part 3'}
]
}
},
'rubric': {
"prompts": [{"description": "Write an essay!"}],
"prompts": [
{"description": "Prompt 1"},
{"description": "Prompt 2"},
{"description": "Prompt 3"}
],
"criteria": [
{
"order_num": 0,
...
...
openassessment/assessment/serializers/training.py
View file @
2c2192b7
...
...
@@ -107,7 +107,11 @@ def deserialize_training_examples(examples, rubric_dict):
>>> ]
>>>
>>> rubric = {
>>> "prompts": [{"description": "Write an essay!"}],
>>> "prompts": [
>>> {"description": "Prompt 1"}
>>> {"description": "Prompt 2"}
>>> {"description": "Prompt 3"}
>>> ],
>>> "criteria": [
>>> {
>>> "order_num": 0,
...
...
openassessment/xblock/data_conversion.py
View file @
2c2192b7
...
...
@@ -20,7 +20,15 @@ def convert_training_examples_list_to_dict(examples_list):
Example:
>>> examples = [
>>> {
>>> "answer": "This is my response",
>>> "answer": {
>>> "parts": {
>>> [
>>> {"text:" "Answer part 1"},
>>> {"text:" "Answer part 2"},
>>> {"text:" "Answer part 3"}
>>> ]
>>> }
>>> },
>>> "options_selected": [
>>> {
>>> "criterion": "Ideas",
...
...
@@ -36,7 +44,15 @@ def convert_training_examples_list_to_dict(examples_list):
>>> convert_training_examples_list_to_dict(examples)
[
{
'answer': 'This is my response',
'answer': {
'parts': {
[
{'text:' 'Answer part 1'},
{'text:' 'Answer part 2'},
{'text:' 'Answer part 3'}
]
}
},
'options_selected': {
'Ideas': 'Fair',
'Content': 'Good'
...
...
@@ -57,6 +73,27 @@ def convert_training_examples_list_to_dict(examples_list):
]
def
update_assessments_format
(
assessments
):
"""
For each example update 'answer' to newer format.
Args:
assessments (list): list of assessments
Returns:
list of dict
"""
for
assessment
in
assessments
:
if
'examples'
in
assessment
:
for
example
in
assessment
[
'examples'
]:
if
isinstance
(
example
[
'answer'
],
unicode
)
or
isinstance
(
example
[
'answer'
],
str
):
example
[
'answer'
]
=
{
'parts'
:
[
{
'text'
:
example
[
'answer'
]}
]
}
return
assessments
def
create_prompts_list
(
prompt_or_serialized_prompts
):
"""
Construct a list of prompts.
...
...
openassessment/xblock/openassessmentblock.py
View file @
2c2192b7
...
...
@@ -32,7 +32,7 @@ from openassessment.workflow.errors import AssessmentWorkflowError
from
openassessment.xblock.student_training_mixin
import
StudentTrainingMixin
from
openassessment.xblock.validation
import
validator
from
openassessment.xblock.resolve_dates
import
resolve_dates
,
DISTANT_PAST
,
DISTANT_FUTURE
from
openassessment.xblock.data_conversion
import
create_prompts_list
,
create_rubric_dict
from
openassessment.xblock.data_conversion
import
create_prompts_list
,
create_rubric_dict
,
update_assessments_format
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -491,10 +491,11 @@ class OpenAssessmentBlock(
list
"""
return
[
_valid_assessments
=
[
asmnt
for
asmnt
in
self
.
rubric_assessments
if
asmnt
.
get
(
'name'
)
in
VALID_ASSESSMENT_TYPES
]
return
update_assessments_format
(
copy
.
deepcopy
(
_valid_assessments
))
@property
def
assessment_steps
(
self
):
...
...
openassessment/xblock/test/data/student_training.xml
View file @
2c2192b7
<openassessment>
<title>
Student training test
</title>
<prompt>
Test prompt
</prompt>
<prompts>
<prompt>
<description>
Given the state of the world today, what do you think should be done to combat poverty?
</description>
</prompt>
</prompts>
<rubric>
<prompt>
Test rubric prompt
</prompt>
<criterion>
<name>
Vocabulary
</name>
<prompt>
How varied is the vocabulary?
</prompt>
...
...
openassessment/xblock/test/data/student_training_due.xml
View file @
2c2192b7
<openassessment>
<title>
Student training test
</title>
<prompt>
Test prompt
</prompt>
<prompts>
<prompt>
<description>
Given the state of the world today, what do you think should be done to combat poverty?
</description>
</prompt>
</prompts>
<rubric>
<prompt>
Test rubric prompt
</prompt>
<criterion>
<name>
Vocabulary
</name>
<prompt>
How varied is the vocabulary?
</prompt>
...
...
openassessment/xblock/test/data/student_training_future.xml
View file @
2c2192b7
<openassessment>
<title>
Student training test
</title>
<prompt>
Test prompt
</prompt>
<prompts>
<prompt>
<description>
Given the state of the world today, what do you think should be done to combat poverty?
</description>
</prompt>
</prompts>
<rubric>
<prompt>
Test rubric prompt
</prompt>
<criterion>
<name>
Vocabulary
</name>
<prompt>
How varied is the vocabulary?
</prompt>
...
...
openassessment/xblock/test/data/student_training_mixin.json
View file @
2c2192b7
...
...
@@ -5,7 +5,14 @@
"training_num_completed"
:
0
,
"training_num_current"
:
1
,
"training_num_available"
:
2
,
"training_essay"
:
"This is my answer."
,
"training_essay"
:
{
"answer"
:
{
"parts"
:
[
{
"prompt"
:
"Given the state of the world today, what do you think should be done to combat poverty?"
,
"text"
:
"This is my answer."
}
]}
},
"allow_latex"
:
false
,
"training_rubric"
:
{
"criteria"
:
[
...
...
openassessment/xblock/test/test_data_conversion.py
View file @
2c2192b7
...
...
@@ -9,7 +9,7 @@ import mock
from
django.test
import
TestCase
from
openassessment.xblock.data_conversion
import
(
create_prompts_list
,
create_submission_dict
,
prepare_submission_for_serialization
create_prompts_list
,
create_submission_dict
,
prepare_submission_for_serialization
,
update_assessments_format
)
@ddt.ddt
...
...
@@ -52,3 +52,14 @@ class DataConversionTest(TestCase):
@ddt.unpack
def
test_prepare_submission_for_serialization
(
self
,
input
,
output
):
self
.
assertEqual
(
prepare_submission_for_serialization
(
input
),
output
)
@ddt.data
(
([{
'answer'
:
'Ans'
}],
[{
'answer'
:
{
'parts'
:
[{
'text'
:
'Ans'
}]}}]),
)
@ddt.unpack
def
test_update_assessments_format
(
self
,
input
,
output
):
self
.
assertEqual
(
update_assessments_format
([{
'examples'
:
input
,
}]),
[{
'examples'
:
output
,
}])
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