Numerous improvements to case questions
This commit is contained in:
+32
-13
@@ -521,9 +521,9 @@ SeriesImageFormSet = inlineformset_factory(
|
||||
|
||||
class JsonAnswerForm(Form):
|
||||
json_answer = JSONSchemaField(
|
||||
schema = "schema/report.json",
|
||||
schema = {},
|
||||
#options = 'schema/options.json'
|
||||
options = {}
|
||||
options = 'schema/options.json'
|
||||
)
|
||||
class Meta:
|
||||
fields = ["json_answer"]
|
||||
@@ -531,16 +531,11 @@ class JsonAnswerForm(Form):
|
||||
def __init__(self, *args, case_detail, **kwargs):
|
||||
super(JsonAnswerForm, self).__init__(*args, **kwargs)
|
||||
if case_detail.question_schema is not None:
|
||||
self.fields["json_answer"] = JSONSchemaField(schema=case_detail.question_schema, options={})
|
||||
self.fields["json_answer"] = JSONSchemaField(schema=case_detail.question_schema, options='schema/options.json')
|
||||
|
||||
class BaseReportAnswerForm(ModelForm):
|
||||
json_answer = JSONSchemaField(
|
||||
schema = "schema/report.json",
|
||||
#options = 'schema/options.json'
|
||||
options = {}
|
||||
)
|
||||
class Meta:
|
||||
fields = ["answer", "json_answer"]
|
||||
fields = ["answer"]
|
||||
|
||||
widgets = {
|
||||
# "normal": RadioSelect(
|
||||
@@ -548,7 +543,7 @@ class BaseReportAnswerForm(ModelForm):
|
||||
# (False, 'No')])
|
||||
# "findings": TinyMCE(attrs={"cols": 80, "rows": 20}),
|
||||
# "mark_scheme": TinyMCE(attrs={"cols": 80, "rows": 30}),
|
||||
"answer": Textarea(attrs={"cols": 100, "rows": 5}),
|
||||
"answer": Textarea(attrs={"cols": 100, "rows": 5, "placeholder":"Report text"}),
|
||||
}
|
||||
|
||||
# help_texts = {
|
||||
@@ -558,9 +553,26 @@ class BaseReportAnswerForm(ModelForm):
|
||||
def __init__(self, *args, case_detail, **kwargs):
|
||||
super(BaseReportAnswerForm, self).__init__(*args, **kwargs)
|
||||
self.fields["answer"].required = False
|
||||
|
||||
class BaseQuestionAnswerForm(ModelForm):
|
||||
json_answer = JSONSchemaField(
|
||||
schema = {},
|
||||
options = 'schema/options.json'
|
||||
)
|
||||
class Meta:
|
||||
fields = ["json_answer"]
|
||||
labels = {"json_answer": ""}
|
||||
|
||||
# help_texts = {
|
||||
# "answer": "Write your answer in here."
|
||||
# }
|
||||
|
||||
def __init__(self, *args, case_detail, **kwargs):
|
||||
super(BaseQuestionAnswerForm, self).__init__(*args, **kwargs)
|
||||
#self.fields["json_answer"].schema = case_detail.question_schema
|
||||
if case_detail.question_schema is not None:
|
||||
self.fields["json_answer"] = JSONSchemaField(schema=case_detail.question_schema, options={})
|
||||
self.fields["json_answer"] = JSONSchemaField(schema=case_detail.question_schema, options="schema/options.json")
|
||||
self.fields["json_answer"].label = ""
|
||||
|
||||
|
||||
class CidReportAnswerForm(BaseReportAnswerForm):
|
||||
@@ -571,6 +583,14 @@ class UserReportAnswerForm(BaseReportAnswerForm):
|
||||
class Meta(BaseReportAnswerForm.Meta):
|
||||
model = UserReportAnswer
|
||||
|
||||
class CidQuestionAnswerForm(BaseQuestionAnswerForm):
|
||||
class Meta(BaseQuestionAnswerForm.Meta):
|
||||
model = CidReportAnswer
|
||||
|
||||
class UserQuestionAnswerForm(BaseQuestionAnswerForm):
|
||||
class Meta(BaseQuestionAnswerForm.Meta):
|
||||
model = UserReportAnswer
|
||||
|
||||
class CidReportAnswerMarkForm(ModelForm):
|
||||
class Meta:
|
||||
model = CidReportAnswer
|
||||
@@ -732,8 +752,7 @@ class AnswerJSONForm(Form):
|
||||
|
||||
json = JSONSchemaField(
|
||||
schema = 'schema/schema.json',
|
||||
#options = 'schema/options.json'
|
||||
options = {}
|
||||
options = 'schema/options.json'
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user