Commit 480e97a3 by Vik Paruchuri

Cleanup and change attribute names

parent d17486a9
...@@ -13,7 +13,7 @@ import textwrap ...@@ -13,7 +13,7 @@ import textwrap
log = logging.getLogger("mitx.courseware") log = logging.getLogger("mitx.courseware")
V1_SETTINGS_ATTRIBUTES = ["display_name", "attempts", "is_graded", "accept_file_upload", V1_SETTINGS_ATTRIBUTES = ["display_name", "max_attempts", "graded", "accept_file_upload",
"skip_spelling_checks", "due", "graceperiod", "weight"] "skip_spelling_checks", "due", "graceperiod", "weight"]
V1_STUDENT_ATTRIBUTES = ["current_task_number", "task_states", "state", V1_STUDENT_ATTRIBUTES = ["current_task_number", "task_states", "state",
...@@ -172,7 +172,7 @@ class CombinedOpenEndedFields(object): ...@@ -172,7 +172,7 @@ class CombinedOpenEndedFields(object):
display_name = String( display_name = String(
display_name="Display Name", display_name="Display Name",
help="This name appears in the horizontal navigation at the top of the page.", help="This name appears in the horizontal navigation at the top of the page.",
default="Open Ended Grading", default="Open Response Assessment",
scope=Scope.settings scope=Scope.settings
) )
current_task_number = Integer( current_task_number = Integer(
...@@ -189,6 +189,12 @@ class CombinedOpenEndedFields(object): ...@@ -189,6 +189,12 @@ class CombinedOpenEndedFields(object):
default="initial", default="initial",
scope=Scope.user_state scope=Scope.user_state
) )
graded = Boolean(
display_name="Graded",
help='Defines whether the student gets credit for grading this problem.',
default=False,
scope=Scope.settings
)
student_attempts = Integer( student_attempts = Integer(
help="Number of attempts taken by the student on this problem", help="Number of attempts taken by the student on this problem",
default=0, default=0,
...@@ -199,19 +205,13 @@ class CombinedOpenEndedFields(object): ...@@ -199,19 +205,13 @@ class CombinedOpenEndedFields(object):
default=False, default=False,
scope=Scope.user_state scope=Scope.user_state
) )
attempts = Integer( max_attempts = Integer(
display_name="Maximum Attempts", display_name="Maximum Attempts",
help="The number of times the student can try to answer this problem.", help="The number of times the student can try to answer this problem.",
default=1, default=1,
scope=Scope.settings, scope=Scope.settings,
values={"min" : 1 } values={"min" : 1 }
) )
is_graded = Boolean(
display_name="Graded",
help="Whether or not the problem is graded.",
default=False,
scope=Scope.settings
)
accept_file_upload = Boolean( accept_file_upload = Boolean(
display_name="Allow File Uploads", display_name="Allow File Uploads",
help="Whether or not the student can submit files as a response.", help="Whether or not the student can submit files as a response.",
...@@ -339,37 +339,9 @@ class CombinedOpenEndedModule(CombinedOpenEndedFields, XModule): ...@@ -339,37 +339,9 @@ class CombinedOpenEndedModule(CombinedOpenEndedFields, XModule):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
Definition file should have one or many task blocks, a rubric block, and a prompt block: Definition file should have one or many task blocks, a rubric block, and a prompt block.
Sample file: See DEFAULT_DATA for a sample.
<combinedopenended attempts="10000">
<rubric>
Blah blah rubric.
</rubric>
<prompt>
Some prompt.
</prompt>
<task>
<selfassessment>
<hintprompt>
What hint about this problem would you give to someone?
</hintprompt>
<submitmessage>
Save Succcesful. Thanks for participating!
</submitmessage>
</selfassessment>
</task>
<task>
<openended min_score_to_attempt="1" max_score_to_attempt="1">
<openendedparam>
<initial_display>Enter essay here.</initial_display>
<answer_display>This is the answer.</answer_display>
<grader_payload>{"grader_settings" : "ml_grading.conf",
"problem_id" : "6.002x/Welcome/OETest"}</grader_payload>
</openendedparam>
</openended>
</task>
</combinedopenended>
""" """
XModule.__init__(self, *args, **kwargs) XModule.__init__(self, *args, **kwargs)
...@@ -450,6 +422,11 @@ class CombinedOpenEndedDescriptor(CombinedOpenEndedFields, RawDescriptor): ...@@ -450,6 +422,11 @@ class CombinedOpenEndedDescriptor(CombinedOpenEndedFields, RawDescriptor):
js_module_name = "OpenEndedMarkdownEditingDescriptor" js_module_name = "OpenEndedMarkdownEditingDescriptor"
css = {'scss': [resource_string(__name__, 'css/editor/edit.scss'), resource_string(__name__, 'css/combinedopenended/edit.scss')]} css = {'scss': [resource_string(__name__, 'css/editor/edit.scss'), resource_string(__name__, 'css/combinedopenended/edit.scss')]}
metadata_translations = {
'is_graded': 'graded',
'attempts': 'max_attempts',
}
def get_context(self): def get_context(self):
_context = RawDescriptor.get_context(self) _context = RawDescriptor.get_context(self)
_context.update({'markdown': self.markdown, _context.update({'markdown': self.markdown,
......
...@@ -78,37 +78,7 @@ class CombinedOpenEndedV1Module(): ...@@ -78,37 +78,7 @@ class CombinedOpenEndedV1Module():
instance_state=None, shared_state=None, metadata=None, static_data=None, **kwargs): instance_state=None, shared_state=None, metadata=None, static_data=None, **kwargs):
""" """
Definition file should have one or many task blocks, a rubric block, and a prompt block: Definition file should have one or many task blocks, a rubric block, and a prompt block. See DEFAULT_DATA in combined_open_ended_module for a sample.
Sample file:
<combinedopenended attempts="10000">
<rubric>
Blah blah rubric.
</rubric>
<prompt>
Some prompt.
</prompt>
<task>
<selfassessment>
<hintprompt>
What hint about this problem would you give to someone?
</hintprompt>
<submitmessage>
Save Succcesful. Thanks for participating!
</submitmessage>
</selfassessment>
</task>
<task>
<openended min_score_to_attempt="1" max_score_to_attempt="1">
<openendedparam>
<initial_display>Enter essay here.</initial_display>
<answer_display>This is the answer.</answer_display>
<grader_payload>{"grader_settings" : "ml_grading.conf",
"problem_id" : "6.002x/Welcome/OETest"}</grader_payload>
</openendedparam>
</openended>
</task>
</combinedopenended>
""" """
...@@ -131,8 +101,8 @@ class CombinedOpenEndedV1Module(): ...@@ -131,8 +101,8 @@ class CombinedOpenEndedV1Module():
# Allow reset is true if student has failed the criteria to move to the next child task # Allow reset is true if student has failed the criteria to move to the next child task
self.ready_to_reset = instance_state.get('ready_to_reset', False) self.ready_to_reset = instance_state.get('ready_to_reset', False)
self.attempts = self.instance_state.get('attempts', MAX_ATTEMPTS) self.max_attempts = self.instance_state.get('max_attempts', MAX_ATTEMPTS)
self.is_scored = self.instance_state.get('is_graded', IS_SCORED) in TRUE_DICT self.is_scored = self.instance_state.get('graded', IS_SCORED) in TRUE_DICT
self.accept_file_upload = self.instance_state.get('accept_file_upload', ACCEPT_FILE_UPLOAD) in TRUE_DICT self.accept_file_upload = self.instance_state.get('accept_file_upload', ACCEPT_FILE_UPLOAD) in TRUE_DICT
self.skip_basic_checks = self.instance_state.get('skip_spelling_checks', SKIP_BASIC_CHECKS) in TRUE_DICT self.skip_basic_checks = self.instance_state.get('skip_spelling_checks', SKIP_BASIC_CHECKS) in TRUE_DICT
...@@ -153,7 +123,7 @@ class CombinedOpenEndedV1Module(): ...@@ -153,7 +123,7 @@ class CombinedOpenEndedV1Module():
# Static data is passed to the child modules to render # Static data is passed to the child modules to render
self.static_data = { self.static_data = {
'max_score': self._max_score, 'max_score': self._max_score,
'max_attempts': self.attempts, 'max_attempts': self.max_attempts,
'prompt': definition['prompt'], 'prompt': definition['prompt'],
'rubric': definition['rubric'], 'rubric': definition['rubric'],
'display_name': self.display_name, 'display_name': self.display_name,
......
...@@ -19,32 +19,27 @@ from django.utils.timezone import UTC ...@@ -19,32 +19,27 @@ from django.utils.timezone import UTC
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
USE_FOR_SINGLE_LOCATION = False
LINK_TO_LOCATION = ""
MAX_SCORE = 1
IS_GRADED = False
EXTERNAL_GRADER_NO_CONTACT_ERROR = "Failed to contact external graders. Please notify course staff." EXTERNAL_GRADER_NO_CONTACT_ERROR = "Failed to contact external graders. Please notify course staff."
class PeerGradingFields(object): class PeerGradingFields(object):
use_for_single_location = Boolean( use_for_single_location = Boolean(
display_name="Show Single Problem", display_name="Show Single Problem",
help='When True, only the single problem specified by "Link to Problem Location" is shown. ' help='When True, only the single problem specified by "Link to Problem Location" is shown. '
'When False, a panel is displayed with all problems available for peer grading.', 'When False, a panel is displayed with all problems available for peer grading.',
default=USE_FOR_SINGLE_LOCATION, default=False,
scope=Scope.settings scope=Scope.settings
) )
link_to_location = String( link_to_location = String(
display_name="Link to Problem Location", display_name="Link to Problem Location",
help='The location of the problem being graded. Only used when "Show Single Problem" is True.', help='The location of the problem being graded. Only used when "Show Single Problem" is True.',
default=LINK_TO_LOCATION, default="",
scope=Scope.settings scope=Scope.settings
) )
is_graded = Boolean( graded = Boolean(
display_name="Graded", display_name="Graded",
help='Defines whether the student gets credit for grading this problem. Only used when "Show Single Problem" is True.', help='Defines whether the student gets credit for grading this problem. Only used when "Show Single Problem" is True.',
default=IS_GRADED, default=False,
scope=Scope.settings scope=Scope.settings
) )
due_date = Date( due_date = Date(
...@@ -56,12 +51,6 @@ class PeerGradingFields(object): ...@@ -56,12 +51,6 @@ class PeerGradingFields(object):
default=None, default=None,
scope=Scope.settings scope=Scope.settings
) )
max_grade = Integer(
help="The maximum grade that a student can receive for this problem.",
default=MAX_SCORE,
scope=Scope.settings,
values={"min": 0}
)
student_data_for_location = Dict( student_data_for_location = Dict(
help="Student data for a given peer grading problem.", help="Student data for a given peer grading problem.",
scope=Scope.user_state scope=Scope.user_state
...@@ -136,10 +125,6 @@ class PeerGradingModule(PeerGradingFields, XModule): ...@@ -136,10 +125,6 @@ class PeerGradingModule(PeerGradingFields, XModule):
if not self.ajax_url.endswith("/"): if not self.ajax_url.endswith("/"):
self.ajax_url = self.ajax_url + "/" self.ajax_url = self.ajax_url + "/"
# Integer could return None, so keep this check.
if not isinstance(self.max_grade, int):
raise TypeError("max_grade needs to be an integer.")
def closed(self): def closed(self):
return self._closed(self.timeinfo) return self._closed(self.timeinfo)
...@@ -232,7 +217,7 @@ class PeerGradingModule(PeerGradingFields, XModule): ...@@ -232,7 +217,7 @@ class PeerGradingModule(PeerGradingFields, XModule):
'score': score, 'score': score,
'total': max_score, 'total': max_score,
} }
if not self.use_for_single_location or not self.is_graded: if not self.use_for_single_location or not self.graded:
return score_dict return score_dict
try: try:
...@@ -253,7 +238,7 @@ class PeerGradingModule(PeerGradingFields, XModule): ...@@ -253,7 +238,7 @@ class PeerGradingModule(PeerGradingFields, XModule):
self.student_data_for_location = response self.student_data_for_location = response
score = int(count_graded >= count_required and count_graded > 0) * float(weight) score = int(count_graded >= count_required and count_graded > 0) * float(weight)
total = self.max_grade * float(weight) total = float(weight)
score_dict['score'] = score score_dict['score'] = score
score_dict['total'] = total score_dict['total'] = total
...@@ -266,8 +251,8 @@ class PeerGradingModule(PeerGradingFields, XModule): ...@@ -266,8 +251,8 @@ class PeerGradingModule(PeerGradingFields, XModule):
randomization, and 5/7 on another randomization, and 5/7 on another
''' '''
max_grade = None max_grade = None
if self.use_for_single_location and self.is_graded: if self.use_for_single_location and self.graded:
max_grade = self.max_grade max_grade = self.weight
return max_grade return max_grade
def get_next_submission(self, data): def get_next_submission(self, data):
...@@ -634,9 +619,13 @@ class PeerGradingDescriptor(PeerGradingFields, RawDescriptor): ...@@ -634,9 +619,13 @@ class PeerGradingDescriptor(PeerGradingFields, RawDescriptor):
#Specify whether or not to pass in open ended interface #Specify whether or not to pass in open ended interface
needs_open_ended_interface = True needs_open_ended_interface = True
metadata_translations = {
'is_graded': 'graded',
'attempts': 'max_attempts',
}
@property @property
def non_editable_metadata_fields(self): def non_editable_metadata_fields(self):
non_editable_fields = super(PeerGradingDescriptor, self).non_editable_metadata_fields non_editable_fields = super(PeerGradingDescriptor, self).non_editable_metadata_fields
non_editable_fields.extend([PeerGradingFields.due_date, PeerGradingFields.grace_period_string, non_editable_fields.extend([PeerGradingFields.due_date, PeerGradingFields.grace_period_string])
PeerGradingFields.max_grade])
return non_editable_fields return non_editable_fields
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment