diff --git a/core/forms.py b/core/forms.py index 3528f937b7b3d6183e7a9c47dc7f23ddf602439d..f7d468315e9def1aeb078730762d721c1527e289 100644 --- a/core/forms.py +++ b/core/forms.py @@ -42,8 +42,4 @@ class FeedbackForm(ModelForm): class Meta: model = Feedback auto_id = False - fields = ('text', 'score', 'of_submission', 'of_tutor') - widgets = { - 'of_submission': HiddenInput, - 'of_tutor': HiddenInput, - } + fields = ('text', 'score') diff --git a/core/migrations/0003_auto_20170330_1709.py b/core/migrations/0003_auto_20170330_1709.py new file mode 100644 index 0000000000000000000000000000000000000000..2f6ed701f64be236d606caf90e1c864ea6bfdfa6 --- /dev/null +++ b/core/migrations/0003_auto_20170330_1709.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.6 on 2017-03-30 17:09 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0002_auto_20170323_0026'), + ] + + operations = [ + migrations.AddField( + model_name='feedback', + name='origin', + field=models.CharField(choices=[('E', 'was empty'), ('UT', 'passed unittests'), ('CF', 'did not compile'), ('M', 'created by a human. yak!')], default='M', max_length=2), + ), + migrations.AlterField( + model_name='submission', + name='text', + field=models.TextField(blank=True), + ), + ] diff --git a/core/models.py b/core/models.py index 41673e0295204574469b98708a63a66c90d1ae3c..276399c3706280cf54dbc22454d3bd4f70f29267 100644 --- a/core/models.py +++ b/core/models.py @@ -113,6 +113,7 @@ class Submission(models.Model): submission = ready[0] feedback = Feedback() + feedback.origin = Feedback.MANUAL feedback.of_tutor = tutor feedback.of_submission = submission feedback.save() @@ -141,6 +142,23 @@ class Feedback(models.Model): blank=True, null=True ) + # adding an origin + WAS_EMPTY = 'E' + PASSED_UNIT_TESTS = 'UT' + DID_NOT_COMPILE = 'CF' + MANUAL = 'M' + ORIGIN = ( + (WAS_EMPTY, 'was empty'), + (PASSED_UNIT_TESTS, 'passed unittests'), + (DID_NOT_COMPILE, 'did not compile'), + (MANUAL, 'created by a human. yak!'), + ) + origin = models.CharField( + max_length=2, + choices=ORIGIN, + default=MANUAL, + ) + class Meta: verbose_name = "Feedback" verbose_name_plural = "Feedback Set" diff --git a/core/static/lib/css/custom.css b/core/static/lib/css/custom.css index 5ef326e0009cc70f9ccb1de5b70cbab91b301ac4..76c2162c9518149860e6b83d4642f65d80b4977d 100644 --- a/core/static/lib/css/custom.css +++ b/core/static/lib/css/custom.css @@ -12,16 +12,23 @@ pre { padding: 0; } -.editor-code { +.editor { position: relative; top: 0; right: 0; bottom: 0; left: 0; - height: 500px; width: auto; } +.editor-code { + height: 500px; +} + +.editor-pre { + height: 200px; +} + .nopadding-right { padding-right: 0 !important; } diff --git a/core/templates/core/feedback_form.html b/core/templates/core/feedback_form.html index e11ec4428121e259d132d0c691273d93a61d3dd2..628fe5e8fb09aa3a999f5136aa68532ebcc28415 100644 --- a/core/templates/core/feedback_form.html +++ b/core/templates/core/feedback_form.html @@ -13,11 +13,22 @@ <div class="card mb-2"> <h4 class="card-header">{{feedback.of_submission.type.name}}</h4> <div class="card-block"> - <div id="student_text" class="editor-code">{{feedback.of_submission.text}}</div> + <div id="student_text" class="editor editor-code">{{feedback.of_submission.text}}</div> + </div> + </div> + + {# Custom feedback seems too complicated #} + <div class="card my-1"> + <a data-toggle="collapse" href="#collapse4"> + <h5 class="card-header">Custom Feedback</h5> + </a> + <div id="collapse4" class="collapse show" role="tabpanel"> + <div class="card-block m-2"> + <div id="pre_corrections" class="editor editor-pre">{{feedback.of_submission.pre_corrections}}</div> + </div> </div> </div> - {% include "core/feedback_card.html" with unique="4" header="Custom Feedback" content=feedback.of_submission.pre_corrections expanded="show" %} {% include "core/feedback_card.html" with unique="1" header="Description" content=feedback.of_submission.type.task_description expanded="hide" %} {% include "core/feedback_card.html" with unique="2" header="Solution" content=feedback.of_submission.type.possible_solution expanded="hide" %} {% include "core/feedback_card.html" with unique="3" header="Correction Guideline" content=feedback.of_submission.type.correction_guideline expanded="hide" %} @@ -32,7 +43,7 @@ <div class="card"> <h4 class="card-header">Please provide your feedback</h4> <div class="card-block"> - <div class="editor-code" id="tutor_text" autofocus>{{feedback.text}}</div> + <div class="editor editor-code" id="tutor_text" autofocus>{{feedback.text}}</div> </div> </div> <form action="{% url 'FeedbackEdit' feedback.slug %}" method="post" id="form1"> @@ -66,12 +77,12 @@ {% endfor %} </div> </form> - {# This is where all the messages pop up #} - {% include "core/message_box.html" %} + {# This is where all the messages pop up #} + {% include "core/message_box.html" %} </div> </div> - </div> +</div> </div> {% endblock %} @@ -93,8 +104,18 @@ }) }); + // we need this one for the student readonly + var editor_pre = ace.edit("pre_corrections"); + editor_pre.setOptions({ + readOnly: true, + showGutter: false, + }) + // we need this one for the student readonly var editor_student = ace.edit("student_text"); + editor_student.setOptions({ + readOnly: true, + }) // we need this one for the tutor var editor_tutor = ace.edit("tutor_text"); @@ -104,9 +125,6 @@ editor_tutor.getSession().on("change", function () { textarea.val(editor_tutor.getSession().getValue()); }); - editor_student.setOptions({ - readOnly: true, - }) {% if feedback.final %} editor_tutor.setOptions({ readOnly: true, diff --git a/populatedb.py b/populatedb.py index 45421e969d67c03849e0af5d5bd81f1c9bb4da5b..6faf2e6a8483602132555e8b6d8406203a6f6b43 100644 --- a/populatedb.py +++ b/populatedb.py @@ -58,6 +58,7 @@ def add_empty_feedback(submission): feedback.text = "--- You have not submitted any code for this task ---" feedback.final = True feedback.empty = False + feedback.origin = Feedback.WAS_EMPTY feedback.of_submission = submission feedback.of_tutor = auto_correct feedback.save()