From 013ef8a595b817c106c48151a5286365b2f9629f Mon Sep 17 00:00:00 2001 From: janmax <mail-github@jmx.io> Date: Tue, 7 Mar 2017 16:27:05 +0100 Subject: [PATCH] feedback form is now working --- core/admin.py | 3 +- core/forms.py | 12 +- core/migrations/0011_auto_20170306_1327.py | 34 +++++ core/migrations/0012_auto_20170306_1450.py | 20 +++ core/migrations/0013_auto_20170306_1452.py | 19 +++ core/migrations/0014_auto_20170306_1504.py | 25 ++++ core/migrations/0015_auto_20170306_1525.py | 41 ++++++ core/migrations/0016_auto_20170306_1535.py | 21 ++++ core/migrations/0017_auto_20170306_1550.py | 25 ++++ core/migrations/0018_auto_20170306_1605.py | 25 ++++ core/models.py | 60 +++++++-- core/templates/base.html | 76 +++++------ core/templates/core/feedback_create.html | 20 +++ core/templates/core/feedback_form.html | 18 +++ core/templates/core/tutor_startpage.html | 20 +-- core/urls.py | 1 + core/views.py | 40 +++++- populatedb.py | 139 +++++++++++++++++++-- requirements.txt | 3 +- 19 files changed, 529 insertions(+), 73 deletions(-) create mode 100644 core/migrations/0011_auto_20170306_1327.py create mode 100644 core/migrations/0012_auto_20170306_1450.py create mode 100644 core/migrations/0013_auto_20170306_1452.py create mode 100644 core/migrations/0014_auto_20170306_1504.py create mode 100644 core/migrations/0015_auto_20170306_1525.py create mode 100644 core/migrations/0016_auto_20170306_1535.py create mode 100644 core/migrations/0017_auto_20170306_1550.py create mode 100644 core/migrations/0018_auto_20170306_1605.py create mode 100644 core/templates/core/feedback_create.html create mode 100644 core/templates/core/feedback_form.html diff --git a/core/admin.py b/core/admin.py index 78a851f3..94af7694 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from .models import SubmissionType, Feedback, Student, Submission +from .models import SubmissionType, Feedback, Student, Submission, SubmissionStatus # Register your models here. @@ -7,3 +7,4 @@ admin.site.register(SubmissionType) admin.site.register(Feedback) admin.site.register(Student) admin.site.register(Submission) +admin.site.register(SubmissionStatus) diff --git a/core/forms.py b/core/forms.py index 2e1c0dba..c4ba3fc0 100644 --- a/core/forms.py +++ b/core/forms.py @@ -1,6 +1,10 @@ -from django import forms +from django.forms import ModelForm, HiddenInput from core.models import Feedback, Submission -class CorrectionForm(forms.Form): - comments = forms.TextField() - score = forms.PositiveIntegerField(initial=0) + +class FeedbackForm(ModelForm): + + class Meta: + model = Feedback + fields = ('text', 'score', 'of_submission', 'of_tutor') + widgets = {'of_submission': HiddenInput, "of_tutor": HiddenInput} diff --git a/core/migrations/0011_auto_20170306_1327.py b/core/migrations/0011_auto_20170306_1327.py new file mode 100644 index 00000000..e7dcdce7 --- /dev/null +++ b/core/migrations/0011_auto_20170306_1327.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.6 on 2017-03-06 13:27 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0010_auto_20170304_1741'), + ] + + operations = [ + migrations.CreateModel( + name='SubmissionStatus', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('status', models.CharField(choices=[('NF', 'NO_FEEDBACK'), ('CP', 'CORRECTION IN PROGRESS'), ('FL', 'FEEDBACK_LIMIT_REACHED'), ('RE', 'REVIEWED')], default='NF', max_length=2)), + ('feedback_counter', models.PositiveIntegerField(default=0, editable=False)), + ('final_feedback', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Feedback')), + ], + ), + migrations.RemoveField( + model_name='submission', + name='final_feedback', + ), + migrations.AddField( + model_name='submissionstatus', + name='submission', + field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='core.Submission'), + ), + ] diff --git a/core/migrations/0012_auto_20170306_1450.py b/core/migrations/0012_auto_20170306_1450.py new file mode 100644 index 00000000..40238686 --- /dev/null +++ b/core/migrations/0012_auto_20170306_1450.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.6 on 2017-03-06 14:50 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0011_auto_20170306_1327'), + ] + + operations = [ + migrations.AlterField( + model_name='submissionstatus', + name='status', + field=models.CharField(choices=[('R', 'READY'), ('CP', 'CORRECTION_IN_PROGRESS'), ('FL', 'FEEDBACK_LIMIT_REACHED'), ('RE', 'REVIEWED')], default=('R', 'READY'), max_length=2), + ), + ] diff --git a/core/migrations/0013_auto_20170306_1452.py b/core/migrations/0013_auto_20170306_1452.py new file mode 100644 index 00000000..f3c20ee5 --- /dev/null +++ b/core/migrations/0013_auto_20170306_1452.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.6 on 2017-03-06 14:52 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0012_auto_20170306_1450'), + ] + + operations = [ + migrations.AlterModelOptions( + name='submissionstatus', + options={'verbose_name': 'Submission Status', 'verbose_name_plural': 'Submission Status Set'}, + ), + ] diff --git a/core/migrations/0014_auto_20170306_1504.py b/core/migrations/0014_auto_20170306_1504.py new file mode 100644 index 00000000..4e58b7f6 --- /dev/null +++ b/core/migrations/0014_auto_20170306_1504.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.6 on 2017-03-06 15:04 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0013_auto_20170306_1452'), + ] + + operations = [ + migrations.RemoveField( + model_name='submissiontype', + name='type_id', + ), + migrations.AddField( + model_name='submissiontype', + name='id', + field=models.AutoField(auto_created=True, default=123, primary_key=True, serialize=False, verbose_name='ID'), + preserve_default=False, + ), + ] diff --git a/core/migrations/0015_auto_20170306_1525.py b/core/migrations/0015_auto_20170306_1525.py new file mode 100644 index 00000000..6d651557 --- /dev/null +++ b/core/migrations/0015_auto_20170306_1525.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.6 on 2017-03-06 15:25 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0014_auto_20170306_1504'), + ] + + operations = [ + migrations.AlterModelOptions( + name='student', + options={'verbose_name': 'Student', 'verbose_name_plural': 'Student Set'}, + ), + migrations.AlterModelOptions( + name='submission', + options={'verbose_name': 'Submission', 'verbose_name_plural': 'Submission Set'}, + ), + migrations.AlterModelOptions( + name='submissionstatus', + options={'verbose_name': 'Submission Status', 'verbose_name_plural': 'SubmissionStatus Set'}, + ), + migrations.AlterModelOptions( + name='submissiontype', + options={'verbose_name': 'SubmissionType', 'verbose_name_plural': 'SubmissionType Set'}, + ), + migrations.RemoveField( + model_name='submissionstatus', + name='submission', + ), + migrations.AddField( + model_name='submission', + name='submission_status', + field=models.OneToOneField(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.SubmissionStatus'), + ), + ] diff --git a/core/migrations/0016_auto_20170306_1535.py b/core/migrations/0016_auto_20170306_1535.py new file mode 100644 index 00000000..79cf897c --- /dev/null +++ b/core/migrations/0016_auto_20170306_1535.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.6 on 2017-03-06 15:35 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0015_auto_20170306_1525'), + ] + + operations = [ + migrations.AlterField( + model_name='submission', + name='submission_status', + field=models.OneToOneField(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='submission', to='core.SubmissionStatus'), + ), + ] diff --git a/core/migrations/0017_auto_20170306_1550.py b/core/migrations/0017_auto_20170306_1550.py new file mode 100644 index 00000000..3d962950 --- /dev/null +++ b/core/migrations/0017_auto_20170306_1550.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.6 on 2017-03-06 15:50 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0016_auto_20170306_1535'), + ] + + operations = [ + migrations.AlterField( + model_name='submissionstatus', + name='feedback_counter', + field=models.PositiveIntegerField(default=0), + ), + migrations.AlterField( + model_name='submissionstatus', + name='status', + field=models.CharField(choices=[('R', 'READY'), ('CP', 'CORRECTION_IN_PROGRESS'), ('FL', 'FEEDBACK_LIMIT_REACHED'), ('RE', 'REVIEWED')], default='R', max_length=2), + ), + ] diff --git a/core/migrations/0018_auto_20170306_1605.py b/core/migrations/0018_auto_20170306_1605.py new file mode 100644 index 00000000..9e1cbd3c --- /dev/null +++ b/core/migrations/0018_auto_20170306_1605.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.6 on 2017-03-06 16:05 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0017_auto_20170306_1550'), + ] + + operations = [ + migrations.RenameField( + model_name='submissiontype', + old_name='correction_guideline', + new_name='guideline', + ), + migrations.AlterField( + model_name='submissionstatus', + name='status', + field=models.PositiveIntegerField(choices=[(0, 'READY'), (1, 'IN_PROGRESS'), (2, 'LIMIT_REACHED'), (3, 'REVIEWED')], default=0), + ), + ] diff --git a/core/models.py b/core/models.py index 9b1c319b..fa64afdd 100644 --- a/core/models.py +++ b/core/models.py @@ -9,15 +9,14 @@ from django.template.defaultfilters import slugify class SubmissionType(models.Model): # Fields - type_id = models.CharField(primary_key=True, max_length=20) name = models.CharField(max_length=50) full_score = models.PositiveIntegerField(default=0) correct_solution = models.TextField() - correction_guideline = models.TextField() + guideline = models.TextField() class Meta: verbose_name = "SubmissionType" - verbose_name_plural = "SubmissionTypes" + verbose_name_plural = "SubmissionType Set" def __str__(self): return self.name @@ -26,13 +25,15 @@ class SubmissionType(models.Model): class Student(models.Model): # Fields - user = models.OneToOneField( - User, on_delete=models.CASCADE, limit_choices_to={'groups__name': 'Students'}) matrikel_no = models.PositiveIntegerField(unique=True, default=0) + user = models.OneToOneField( + User, on_delete=models.CASCADE, + limit_choices_to={'groups__name': 'Students'} + ) class Meta: verbose_name = "Student" - verbose_name_plural = "Students" + verbose_name_plural = "Student Set" def __str__(self): return "{} ({})".format(self.user.username, self.matrikel_no) @@ -41,15 +42,27 @@ class Student(models.Model): class Submission(models.Model): # Fields - submission_type = models.ForeignKey(SubmissionType, related_name='submissions') + submission_type = models.ForeignKey( + SubmissionType, + related_name='submissions' + ) + submission_status = models.OneToOneField( + 'SubmissionStatus', + null=True, editable=False, + related_name='submission', + on_delete=models.CASCADE + ) submission_text = models.TextField() pre_corrections = models.TextField(blank=True) - final_feedback = models.OneToOneField('Feedback', null=True, blank=True) - student = models.ForeignKey (Student) + student = models.ForeignKey(Student) class Meta: verbose_name = "Submission" - verbose_name_plural = "Submissions" + verbose_name_plural = "Submission Set" + + def save(self, *args, **kwargs): + self.submission_status = SubmissionStatus.objects.create() + super(Submission, self).save(*args, **kwargs) def __str__(self): return "Submission of type '{}' from Student '{}'".format( @@ -58,6 +71,33 @@ class Submission(models.Model): ) + +class SubmissionStatus(models.Model): + + READY, IN_PROGRESS, LIMIT_REACHED, REVIEWED = range(4) + STATUS = ( + (READY, 'READY'), + (IN_PROGRESS, 'IN_PROGRESS'), + (LIMIT_REACHED, 'LIMIT_REACHED'), + (REVIEWED, 'REVIEWED'), + ) + + # Fields + status = models.PositiveIntegerField( + choices=STATUS, + default=READY, + ) + feedback_counter = models.PositiveIntegerField(default=0) + final_feedback = models.OneToOneField('Feedback', null=True, blank=True) + + class Meta: + verbose_name = "Submission Status" + verbose_name_plural = "SubmissionStatus Set" + + def __str__(self): + return "Status is {}".format(self.status) + + class Feedback(models.Model): # Fields diff --git a/core/templates/base.html b/core/templates/base.html index 0c13885a..499426b9 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -1,47 +1,51 @@ <!DOCTYPE html> <html lang="en"> - <head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <meta name="description" content=""> - <meta name="author" content=""> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <meta name="description" content=""> + <meta name="author" content=""> - <title>Grady - {% block title %}Wellcome to correction hell!{% endblock %}</title> + <title>Grady - {% block title %}Wellcome to correction hell!{% endblock %}</title> - <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous"> - </head> + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous"> +</head> - <nav class="navbar navbar-toggleable-md navbar-light bg-faded"> - <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> - <span class="navbar-toggler-icon"></span> - </button> - <a class="navbar-brand" href="/">Grady</a> +<nav class="navbar navbar-toggleable-md navbar-light bg-faded"> + <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> + <span class="navbar-toggler-icon"></span> + </button> + <a class="navbar-brand" href="/">Grady</a> - <div class="collapse navbar-collapse" id="navbarSupportedContent"> - <ul class="navbar-nav mr-auto"> - {% if user.is_authenticated %} - <li class="nav-item"><a class="nav-link" href="{% url 'logout' %}">Logout</a></li> - {% else %} - <li class="nav-item"><a class="nav-link" href="{% url 'login' %}">Login</a></li> - {% endif %} - </ul> - </div> - </nav> + <ul class="nav nav-pills mr-auto"> + <li class="nav-item"><div class="nav-text">{% block nav_title %}{% endblock nav_title %}</div></li> + </ul> - <body> - <div class="container-fluid"> - <div class="row"> - <div class="col-sm-3 col-md-2 sidebar"> - {% block side_block %} - {% endblock %} - </div> - <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> - <div> - {% block body_block %} - {% endblock %} - </div> + <ul class="nav nav-pills"> + {% if user.is_authenticated %} + <li class="nav-item"><a class="nav-link">{{ user.username }}</a></li> + <li class="nav-item"><a class="btn navbar-btn btn-primary" href="{% url 'logout' %}" role="button">Logout</a></li> + {% else %} + <li class="nav-item"><a class="btn navbar-btn btn-primary" href="{% url 'login' %}" role="button">Login</a></li> + {% endif %} + </ul> + +</nav> + +<body> + <div class="container-fluid"> + <div class="row"> + <div class="col-sm-3 col-md-2 sidebar"> + {% block side_block %} + {% endblock %} + </div> + <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> + <div> + {% block body_block %} + {% endblock %} </div> </div> </div> - </body> + </div> +</body> </html> diff --git a/core/templates/core/feedback_create.html b/core/templates/core/feedback_create.html new file mode 100644 index 00000000..60bcdd79 --- /dev/null +++ b/core/templates/core/feedback_create.html @@ -0,0 +1,20 @@ +{% extends 'base.html' %} + +{% load staticfiles %} + +{% block title %} Create Feedback {% endblock %} + +{% block body_block %} + <div class="page-header"> + <h1>Create Feedback</h1> + </div> + + <pre> + {{ submission.submission_text }} + </pre> + + <div> + {{ feedback_form }} + </div> + +{% endblock %} diff --git a/core/templates/core/feedback_form.html b/core/templates/core/feedback_form.html new file mode 100644 index 00000000..0b31bb67 --- /dev/null +++ b/core/templates/core/feedback_form.html @@ -0,0 +1,18 @@ +{% extends "base.html" %} + +{% block nav_title %} Create -- Feedback {% endblock nav_title %} + +{% block title %} {% endblock %} + +{% block body_block %} + <div class="page-header"> + <h1>Creating shit</h1> + </div> + + <form action="" method="post"> + {% csrf_token %} + {{ form.as_p }} + <input type="submit" value="Submit"> + </form> + +{% endblock %} diff --git a/core/templates/core/tutor_startpage.html b/core/templates/core/tutor_startpage.html index c79ab959..afd1dbd7 100644 --- a/core/templates/core/tutor_startpage.html +++ b/core/templates/core/tutor_startpage.html @@ -1,11 +1,12 @@ -<html> -<head> - <meta charset="UTF-8"> - <title>Tutor Startpage</title> -</head> -<body> - <h1>Hello {{tutor_name}}! </h1> +{% extends 'base.html' %} +{% load staticfiles %} + +{% block nav_title %} Ready for an exam, commander? {% endblock nav_title %} + +{% block title %} Grady -- Login {% endblock %} + +{% block body_block %} {% if feedback_list|length == 0 %} <h2>You havn't provided any feedback yet. Sad. Get to work!</h2> {% else %} @@ -21,6 +22,5 @@ </ul> {% endif %} - <p><a href="/logout/">Logout</a></p> -</body> -</html> + <a role="button" class="btn btn-danger btn-xl" href="/feedback/create/">Give me work</a> +{% endblock body_block %} diff --git a/core/urls.py b/core/urls.py index 3c162974..7980d5b7 100644 --- a/core/urls.py +++ b/core/urls.py @@ -6,5 +6,6 @@ urlpatterns = [ url(r'^login/$', views.user_login, name='login'), url(r'^logout/$', views.user_logout, name='logout'), url(r'^tutor/$', views.tutor_startpage, name='tutor'), + url(r'^feedback/create/$', views.FeedbackCreate.as_view(), name='FeedbackCreate'), url(r'^feedback/(?P<feedback_slug>\w+)/$', views.feedback, name='feedback'), ] diff --git a/core/views.py b/core/views.py index 60a4d816..cdc3154e 100644 --- a/core/views.py +++ b/core/views.py @@ -3,12 +3,17 @@ from django.contrib.auth.models import User, Group from django.contrib.auth.decorators import user_passes_test, login_required from django.http import HttpResponseRedirect, HttpResponse from django.shortcuts import render +from django.views.generic.edit import CreateView -from core.models import Submission, SubmissionType, Feedback +from core.models import Submission, SubmissionType, Feedback, SubmissionStatus +from core.forms import FeedbackForm +from random import sample + # Create your views here. + def index(request): context = { 'boldmessage': 'Delbert Grady says hey there world!', @@ -76,3 +81,36 @@ def feedback(request, feedback_slug): # Go render the response and return it to the client. return render(request, 'core/feedback.html', context) + + +class FeedbackCreate(CreateView): + + """docstring for FeedbackCreate""" + + model = Feedback + form_class = FeedbackForm + success_url = '/tutor/' + + def __init__(self, **kwargs): + for key, value in kwargs.items(): + setattr(self, key, value) + + # Get a submission from the submission set + submission_status = SubmissionStatus.objects.filter( + status=SubmissionStatus.READY)[0] + submission_status.status = submission_status.IN_PROGRESS + submission_status.save() + + self.submission = submission_status.submission + + def get_initial(self): + return { + 'of_submission': self.submission, + 'of_tutor': self.request.user, + } + + def get_context_data(self, **kwargs): + return { + 'submission': self.submission, + 'submission_type': self.submission.submission_type, + } diff --git a/populatedb.py b/populatedb.py index 086d2cc1..2c050691 100644 --- a/populatedb.py +++ b/populatedb.py @@ -1,4 +1,5 @@ -import os, random +import os +import random os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'grady.settings') import django @@ -8,10 +9,98 @@ from core.models import Submission, SubmissionType, Student, Feedback from django.contrib.auth.models import User, Group +blob1 = """ # '\[gap\]([\w\W]+?)\[\/gap\]' +# '\[select\]([\w\W]+?)\[\/select\]' +# '\[numeric\]([\w\W]+?)\[\/numeric\]' +# We match against one big regex that consists of three smaller ones (see above) +_all = re.compile('(\[numeric\]([\w\W]+?)\[\/numeric\]|\[select\]([\w\W]+?)\[\/select\]|\[gap\]([\w\W]+?)\[\/gap\])', re.MULTILINE) +for m in re.finditer(_all, task): + print(m.span()) + """ +blob2 = """ #include <stdio.h> +#include <stdlib.h> +#include <assert.h> + +const char str[] = "Is it constant?"; + +int main(int argc, char const *argv[]) +{ + printf("%s\n", str); + + char *p = (char *) str; + + p[2] = '9'; + + printf("%s\n", str); +} """ +blob3 = """ public Linie() { + System.out.println(":)"); + } + } + + public static void main(String[] args) { + int x; + if (7 == 0) { + return; + } else { + System.out.println(123); + } + + Linie l = new Linie(); + l.x = 3; + System.out.println("Bye." + l.x); + } +} """ +blob4 = """ class Uhrzeit implements Comparable<Uhrzeit> { + private int stunde; // Stundenangabe + private int minute; // Minutenangabe + public Uhrzeit(int stunde, int minute) { // nur sinnvolle Zeitangaben .. + if ( 0 <= stunde && stunde <= 23 && // .. behandeln + 0 <= minute && minute <= 59) { + this.stunde = stunde; // Stundenangabe zuweisen + this.minute = minute; // Minutenangabe zuweisen + } else throw new RuntimeException("Ungültige Zeitangabe!"); + } + + public String toString() { // String-Darstellung in der Form: + return stunde + " Uhr und " + minute + " Minute(n)"; // <Stundenangabe> Uhr und <Minutenangabe> Minuten + } """ +blob5 = """ -rw-r--r-- 1 doncamillo staff 499B 1 Mar 15:08 lala.cc +35015309 -rwxr-xr-x 1 doncamillo staff 60K 1 Mar 15:08 lala.o +34389884 drwxr-xr-x 34 doncamillo staff 1.1K 17 Feb 09:50 lci/ +18040235 -rw-r--r-- 1 doncamillo staff 3.0K 15 Jun 2016 mensabot.py + 9923840 -rw-r--r-- 1 doncamillo staff 192B 20 Mar 2015 minmax.py +35166931 drwxr-xr-x 4 doncamillo staff 136B 2 Mar 16:53 mydockerbuild/ +32581151 drwxr-xr-x 29 doncamillo staff 986B 30 Dec 03:22 mypy/ +32674577 -rw-r--r-- 1 doncamillo staff 56B 1 Jan 03:34 num.py +32674574 -rw-r--r-- 1 doncamillo staff 3.7K 1 Jan 03:34 num.txt +16672100 drwxr-xr-x 7 doncamillo staff 238B 4 May 2016 ophase-shirt/ +20108315 drwxr-xr-x 7 doncamillo staff 238B 30 Jul 2016 orni/ +30452432 -rw-r--r-- 1 doncamillo staff 1.6K 9 Dec 13:50 out.csv +32495350 -rw-r--r-- 1 doncamillo staff 962B 28 Dec 01:09 out.zip + 9923841 -rw-r--r-- 1 doncamillo staff 59B 15 Jul 2015 packing.py +18450212 -rw-r--r-- 1 doncamillo staff 5.4K 28 Jun 2016 punkte02.csv +29250808 drwxr-xr-x 20 doncamillo staff 680B 14 Nov 17:16 python-weka-wrapper/ +17702721 -rw-r--r-- 1 doncamillo staff 525B 23 Jun 2016 reverse.class +17702665 -rw-r--r-- 1 doncamillo staff 711B 23 Jun 2016 reverse.java +33930378 drwxr-xr-x 8 doncamillo staff 272B 6 Feb 09:44 rust/ +34209249 -rw-r--r-- 1 doncamillo staff 2.2K 6 Feb 09:44 rust.tar.gz +32494205 -rw-r--r-- 1 doncamillo staff 271B 28 Dec 00:56 scriptll.py +13587552 -rw-r--r-- 1 doncamillo staff 985B 9 Mar 2016 second.java +20108498 -rw-r-----@ 1 doncamillo staff 2.3K 30 Jul 2016 speech_api_key.json +32488712 -rw-r--r-- 1 doncamillo staff 160B 27 Dec 23:55 suppe.py +33496687 drwxr-xr-x 5 doncamillo staff 170B 24 Jan 18:28 tcpi.py/ +33446903 drwxr-xr-x 4 doncamillo staff 136B 23 Jan 13:51 temp/ +18772243 -rwxr-xr-x 1 doncamillo staff 8.4K 5 Jul 2016 test +30907796 drwxr-xr-x 5 doncamillo staff """ + + def populate(): - if User.objects.get(username='doncamillo'): - print("Was already created. Aborting...") - return + try: + User.objects.create_superuser( + username='doncamillo', password='octoputz', email='a@b.com') + except Exception as e: + print("- Superuser was already created.") student_group = add_group('Students') tutor_group = add_group('Tutors') @@ -19,19 +108,49 @@ def populate(): add_user('Test_Tutor', tutor_group) add_user('Test_Reviewer', reviewer_group) - add_student('Test_Student1') - add_student('Test_Student2') - add_student('Test_Student3') + s1 = add_student('Test_Student1') + s2 = add_student('Test_Student2') + s3 = add_student('Test_Student3') + + sub_t1 = add_submission_type("Irgendwas Sortieren", 10) + sub_t2 = add_submission_type("Irgendwas Mischen", 20) + sub_t3 = add_submission_type("Irgendwas Hacken", 30) + + add_submission(sub_t1, blob1, s1) + add_submission(sub_t2, blob2, s1) + add_submission(sub_t3, blob3, s2) + add_submission(sub_t1, blob4, s2) + add_submission(sub_t3, blob5, s3) + + +def add_submission_type(name, score): + task = SubmissionType() + task.name = name + task.full_score = score + task.correct_solution = "So sollte das mal aussehen" + task.guideline = "So solltest du das programmieren" + task.save() + return task + + +def add_submission(type, text, student, pre="Vorgabe"): + sub = Submission() + sub.submission_type = type + sub.submission_text = text + sub.pre_corrections = pre + sub.student = student + sub.save() + return sub -def add_submission_type(name, score, solution): - SubmissionType(name=name, score=score) def add_student(name): student_group = Group.objects.get(name='Students') student_user = add_user(name, student_group) - student = Student(user=student_user, matrikel_no=20000000 + random.randrange(21343)) + student = Student( + user=student_user, matrikel_no=20000000 + random.randrange(21343)) student.save() + return student def add_user(username, group, password='password'): diff --git a/requirements.txt b/requirements.txt index f7017739..9ed0f4a2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -Django~=1.10.6 \ No newline at end of file +Django~=1.10.6 +django-annoying~=0.10.3 -- GitLab