diff --git a/TasksType.json b/TasksType.json new file mode 100644 index 0000000..b1156f8 --- /dev/null +++ b/TasksType.json @@ -0,0 +1,78 @@ +[ + { + "model": "lessons.TaskType", + "pk":1, + "fields" : { + "name":"прочитать текст" + } + }, + { + "model": "lessons.TaskType", + "pk":10, + "fields" : { + "name":"выбрать правильный вариант ответа" + } + }, + { + "model": "lessons.TaskType", + "pk":9, + "fields" : { + "name":"расставить заголвки" + + } + }, + { + "model": "lessons.TaskType", + "pk":8, + "fields": { + "name":"правда/ложь" + } + }, + { + "model": "lessons.TaskType", + "pk":7, + "fields" : { + "name":"краткий письменный ответ" + + } + }, + { + "model": "lessons.TaskType", + "pk":6, + "fields" : { + "name":"опишите устно изображение" + + } + }, + { + "model": "lessons.TaskType", + "pk":5, + "fields" : { + "name":"установите соответствия" + + } + }, + { + "model": "lessons.TaskType", + "pk":4, + "fields" : { + "name":"расширенный письменный ответ" + } + }, + { + "model": "lessons.TaskType", + "pk":3, + "fields" : { + "name":"монологическое высказывание на выбранную тему" + + } + }, + { + "model": "lessons.TaskType", + "pk":2, + "fields" : { + "name":"загрузка файла" + + } + } +] \ No newline at end of file diff --git a/lessons/__pycache__/gqlTypes.cpython-37.pyc b/lessons/__pycache__/gqlTypes.cpython-37.pyc index 5a5d4c0..258ea64 100644 Binary files a/lessons/__pycache__/gqlTypes.cpython-37.pyc and b/lessons/__pycache__/gqlTypes.cpython-37.pyc differ diff --git a/lessons/__pycache__/models.cpython-37.pyc b/lessons/__pycache__/models.cpython-37.pyc index 809b587..faf1e7e 100644 Binary files a/lessons/__pycache__/models.cpython-37.pyc and b/lessons/__pycache__/models.cpython-37.pyc differ diff --git a/lessons/__pycache__/schema.cpython-37.pyc b/lessons/__pycache__/schema.cpython-37.pyc index 072efcc..a3bbac1 100644 Binary files a/lessons/__pycache__/schema.cpython-37.pyc and b/lessons/__pycache__/schema.cpython-37.pyc differ diff --git a/lessons/gqlTypes.py b/lessons/gqlTypes.py index 1d444d5..f201eff 100644 --- a/lessons/gqlTypes.py +++ b/lessons/gqlTypes.py @@ -1,7 +1,7 @@ import graphene import graphene_django -from .models import Subject, Lesson, SubjectClassLocal, Tests, Task, AnswerSheet, Answer, Materials +from .models import Subject, Lesson, SubjectClassLocal, Tests, Task, AnswerSheet, Answer, Materials, TaskType as taskType from organisations.gqlTypes import ChildType, TeacherType from organisations.models import Organisation, Group, Child, Teacher @@ -16,6 +16,11 @@ from django.db.models import Model class Material(graphene_django.DjangoObjectType): class Meta: model = Materials + interfaces = (relay.Node,) + filter_fields = { + "name": ("exact",) + } + class AnswerType(graphene_django.DjangoObjectType): class Meta: @@ -144,3 +149,8 @@ class LocalSubjectType(graphene_django.DjangoObjectType): return len(self.lesson_set.all()) +class TaskTypeType(graphene_django.DjangoObjectType): + class Meta: + model = taskType + interfaces = (relay.Node,) + filter_fields = {} \ No newline at end of file diff --git a/lessons/migrations/0001_initial.py b/lessons/migrations/0001_initial.py index 7f712da..72c728f 100644 --- a/lessons/migrations/0001_initial.py +++ b/lessons/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2021-01-08 20:17 +# Generated by Django 3.1.5 on 2021-02-05 08:53 from django.db import migrations, models import django.db.models.deletion @@ -9,10 +9,20 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('organisations', '0004_auto_20210108_2013'), + ('organisations', '0005_auto_20210120_1944'), ] operations = [ + migrations.CreateModel( + name='Lesson', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.TextField(default='')), + ('descr', models.TextField(default='')), + ('content', models.TextField(default='')), + ('time_lesson', models.DateTimeField(auto_now=True)), + ], + ), migrations.CreateModel( name='Subject', fields=[ @@ -22,6 +32,50 @@ class Migration(migrations.Migration): ('teachers_give', models.ManyToManyField(to='organisations.Teacher')), ], ), + migrations.CreateModel( + name='Task', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('theory', models.TextField()), + ('practise', models.TextField()), + ('number', models.IntegerField()), + ('max_score', models.IntegerField(default=0)), + ], + ), + migrations.CreateModel( + name='Type', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.TextField(max_length=150)), + ], + ), + migrations.CreateModel( + name='Theme', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=150)), + ('tasks', models.ManyToManyField(to='lessons.Task')), + ], + ), + migrations.CreateModel( + name='Tests', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=150)), + ('deadline', models.DateTimeField()), + ('lesson', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.lesson')), + ], + ), + migrations.AddField( + model_name='task', + name='test', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.tests'), + ), + migrations.AddField( + model_name='task', + name='types', + field=models.ManyToManyField(to='lessons.Type'), + ), migrations.CreateModel( name='SubjectClassLocal', fields=[ @@ -32,4 +86,40 @@ class Migration(migrations.Migration): ('teachers', models.ManyToManyField(to='organisations.Teacher')), ], ), + migrations.CreateModel( + name='Materials', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('link', models.URLField()), + ('name', models.CharField(blank=True, max_length=100)), + ('data', models.TextField(blank=True)), + ('Type', models.CharField(default='link', max_length=100)), + ('lesson', models.ForeignKey(default=3, on_delete=django.db.models.deletion.CASCADE, to='lessons.lesson')), + ], + ), + migrations.AddField( + model_name='lesson', + name='type_lesson', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.subjectclasslocal'), + ), + migrations.CreateModel( + name='AnswerSheet', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('completed', models.BooleanField(default=False)), + ('child', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.child')), + ('test', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.tests')), + ], + ), + migrations.CreateModel( + name='Answer', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('content', models.TextField()), + ('number', models.IntegerField()), + ('completed', models.BooleanField(default=False)), + ('score', models.IntegerField(default=0)), + ('sheet', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.answersheet')), + ], + ), ] diff --git a/lessons/migrations/0002_auto_20210109_1220.py b/lessons/migrations/0002_auto_20210109_1220.py deleted file mode 100644 index 566d0ec..0000000 --- a/lessons/migrations/0002_auto_20210109_1220.py +++ /dev/null @@ -1,91 +0,0 @@ -# Generated by Django 3.1.5 on 2021-01-09 12:20 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('organisations', '0004_auto_20210108_2013'), - ('lessons', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='Lesson', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('type_lesson', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.subjectclasslocal')), - ], - ), - migrations.CreateModel( - name='Materials', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('link', models.URLField()), - ('name', models.CharField(blank=True, max_length=100)), - ], - ), - migrations.CreateModel( - name='Task', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('theory', models.TextField()), - ('practise', models.TextField()), - ('number', models.IntegerField()), - ], - ), - migrations.CreateModel( - name='Type', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.TextField(max_length=150)), - ], - ), - migrations.CreateModel( - name='Theme', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=150)), - ('tasks', models.ManyToManyField(to='lessons.Task')), - ], - ), - migrations.CreateModel( - name='Tests', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=150)), - ('deadline', models.DateTimeField()), - ('lesson', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.lesson')), - ], - ), - migrations.AddField( - model_name='task', - name='test', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.tests'), - ), - migrations.AddField( - model_name='task', - name='type', - field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='lessons.type'), - ), - migrations.CreateModel( - name='AnswerSheet', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('completed', models.BooleanField(default=False)), - ('child', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.child')), - ('test', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.tests')), - ], - ), - migrations.CreateModel( - name='Answer', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('content', models.TextField()), - ('number', models.IntegerField()), - ('sheet', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.answersheet')), - ], - ), - ] diff --git a/lessons/migrations/0002_auto_20210205_1326.py b/lessons/migrations/0002_auto_20210205_1326.py new file mode 100644 index 0000000..ce7fa14 --- /dev/null +++ b/lessons/migrations/0002_auto_20210205_1326.py @@ -0,0 +1,38 @@ +# Generated by Django 3.1.5 on 2021-02-05 10:26 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('lessons', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='task', + name='Type', + field=models.CharField(default='line', max_length=150), + ), + migrations.AddField( + model_name='task', + name='autoCheckData', + field=models.TextField(blank=True), + ), + migrations.AddField( + model_name='task', + name='is_autoCheck', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='task', + name='is_timing', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='task', + name='time', + field=models.IntegerField(default=30), + ), + ] diff --git a/lessons/migrations/0003_auto_20210205_1541.py b/lessons/migrations/0003_auto_20210205_1541.py new file mode 100644 index 0000000..e22c6ea --- /dev/null +++ b/lessons/migrations/0003_auto_20210205_1541.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.5 on 2021-02-05 12:41 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('lessons', '0002_auto_20210205_1326'), + ] + + operations = [ + migrations.CreateModel( + name='TaskType', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.TextField()), + ], + ), + migrations.AlterField( + model_name='task', + name='Type', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.tasktype'), + ), + ] diff --git a/lessons/migrations/0004_answer_completed.py b/lessons/migrations/0004_answer_completed.py deleted file mode 100644 index ab1334f..0000000 --- a/lessons/migrations/0004_answer_completed.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.5 on 2021-01-13 20:17 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('lessons', '0003_auto_20210113_2224'), - ] - - operations = [ - migrations.AddField( - model_name='answer', - name='completed', - field=models.BooleanField(default=False), - ), - ] diff --git a/lessons/migrations/0004_auto_20210205_1543.py b/lessons/migrations/0004_auto_20210205_1543.py new file mode 100644 index 0000000..643b2a9 --- /dev/null +++ b/lessons/migrations/0004_auto_20210205_1543.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.5 on 2021-02-05 12:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('lessons', '0003_auto_20210205_1541'), + ] + + operations = [ + migrations.AlterField( + model_name='task', + name='Type', + field=models.CharField(default='line', max_length=150), + ), + ] diff --git a/lessons/migrations/0005_auto_20210117_1752.py b/lessons/migrations/0005_auto_20210117_1752.py deleted file mode 100644 index 08be77e..0000000 --- a/lessons/migrations/0005_auto_20210117_1752.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 3.1.5 on 2021-01-17 14:52 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('lessons', '0004_answer_completed'), - ] - - operations = [ - migrations.AddField( - model_name='answer', - name='score', - field=models.IntegerField(default=0), - ), - migrations.AddField( - model_name='task', - name='max_score', - field=models.IntegerField(default=0), - ), - ] diff --git a/lessons/migrations/0005_auto_20210205_1544.py b/lessons/migrations/0005_auto_20210205_1544.py new file mode 100644 index 0000000..a2ec8ed --- /dev/null +++ b/lessons/migrations/0005_auto_20210205_1544.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.5 on 2021-02-05 12:44 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('lessons', '0004_auto_20210205_1543'), + ] + + operations = [ + migrations.AlterField( + model_name='task', + name='Type', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.tasktype'), + ), + ] diff --git a/lessons/migrations/0006_auto_20210117_2008.py b/lessons/migrations/0006_auto_20210117_2008.py deleted file mode 100644 index eb57052..0000000 --- a/lessons/migrations/0006_auto_20210117_2008.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 3.1.5 on 2021-01-17 17:08 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('lessons', '0005_auto_20210117_1752'), - ] - - operations = [ - migrations.AddField( - model_name='lesson', - name='descr', - field=models.TextField(default=''), - ), - migrations.AddField( - model_name='lesson', - name='name', - field=models.TextField(default=''), - ), - ] diff --git a/lessons/migrations/0006_auto_20210205_1848.py b/lessons/migrations/0006_auto_20210205_1848.py new file mode 100644 index 0000000..f1facd5 --- /dev/null +++ b/lessons/migrations/0006_auto_20210205_1848.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.5 on 2021-02-05 15:48 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('lessons', '0005_auto_20210205_1544'), + ] + + operations = [ + migrations.AlterField( + model_name='task', + name='test', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='lessons.tests'), + ), + ] diff --git a/lessons/migrations/0007_auto_20210205_1857.py b/lessons/migrations/0007_auto_20210205_1857.py new file mode 100644 index 0000000..7de23c4 --- /dev/null +++ b/lessons/migrations/0007_auto_20210205_1857.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.5 on 2021-02-05 15:57 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('lessons', '0006_auto_20210205_1848'), + ] + + operations = [ + migrations.AlterField( + model_name='task', + name='test', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.tests'), + ), + ] diff --git a/lessons/migrations/0007_lesson_time_lesson.py b/lessons/migrations/0007_lesson_time_lesson.py deleted file mode 100644 index fd7f7d3..0000000 --- a/lessons/migrations/0007_lesson_time_lesson.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.5 on 2021-01-30 11:27 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('lessons', '0006_auto_20210117_2008'), - ] - - operations = [ - migrations.AddField( - model_name='lesson', - name='time_lesson', - field=models.DateTimeField(auto_now=True), - ), - ] diff --git a/lessons/migrations/0003_auto_20210113_2224.py b/lessons/migrations/0008_auto_20210205_1858.py similarity index 57% rename from lessons/migrations/0003_auto_20210113_2224.py rename to lessons/migrations/0008_auto_20210205_1858.py index 489da99..f838a94 100644 --- a/lessons/migrations/0003_auto_20210113_2224.py +++ b/lessons/migrations/0008_auto_20210205_1858.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2021-01-13 19:24 +# Generated by Django 3.1.5 on 2021-02-05 15:58 from django.db import migrations, models @@ -6,17 +6,17 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('lessons', '0002_auto_20210109_1220'), + ('lessons', '0007_auto_20210205_1857'), ] operations = [ migrations.RemoveField( model_name='task', - name='type', + name='test', ), migrations.AddField( model_name='task', - name='types', - field=models.ManyToManyField(to='lessons.Type'), + name='test', + field=models.ManyToManyField(to='lessons.Tests'), ), ] diff --git a/lessons/migrations/0008_materials_lesson.py b/lessons/migrations/0008_materials_lesson.py deleted file mode 100644 index d25cff8..0000000 --- a/lessons/migrations/0008_materials_lesson.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 3.1.5 on 2021-01-30 12:39 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('lessons', '0007_lesson_time_lesson'), - ] - - operations = [ - migrations.AddField( - model_name='materials', - name='lesson', - field=models.ForeignKey(default=3, on_delete=django.db.models.deletion.CASCADE, to='lessons.lesson'), - ), - ] diff --git a/lessons/migrations/0009_lesson_content.py b/lessons/migrations/0009_lesson_content.py deleted file mode 100644 index e953d8d..0000000 --- a/lessons/migrations/0009_lesson_content.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.5 on 2021-01-30 17:08 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('lessons', '0008_materials_lesson'), - ] - - operations = [ - migrations.AddField( - model_name='lesson', - name='content', - field=models.TextField(default=''), - ), - ] diff --git a/lessons/migrations/0010_auto_20210203_0122.py b/lessons/migrations/0010_auto_20210203_0122.py deleted file mode 100644 index 19e1dc5..0000000 --- a/lessons/migrations/0010_auto_20210203_0122.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 3.1.5 on 2021-02-02 22:22 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('lessons', '0009_lesson_content'), - ] - - operations = [ - migrations.AddField( - model_name='materials', - name='Type', - field=models.CharField(default='link', max_length=100), - ), - migrations.AddField( - model_name='materials', - name='data', - field=models.TextField(blank=True), - ), - ] diff --git a/lessons/migrations/__pycache__/0001_initial.cpython-36.pyc b/lessons/migrations/__pycache__/0001_initial.cpython-36.pyc deleted file mode 100644 index caf0e16..0000000 Binary files a/lessons/migrations/__pycache__/0001_initial.cpython-36.pyc and /dev/null differ diff --git a/lessons/migrations/__pycache__/0001_initial.cpython-37.pyc b/lessons/migrations/__pycache__/0001_initial.cpython-37.pyc index 70f812a..53b04df 100644 Binary files a/lessons/migrations/__pycache__/0001_initial.cpython-37.pyc and b/lessons/migrations/__pycache__/0001_initial.cpython-37.pyc differ diff --git a/lessons/migrations/__pycache__/0002_auto_20210109_1220.cpython-36.pyc b/lessons/migrations/__pycache__/0002_auto_20210109_1220.cpython-36.pyc deleted file mode 100644 index 2918d86..0000000 Binary files a/lessons/migrations/__pycache__/0002_auto_20210109_1220.cpython-36.pyc and /dev/null differ diff --git a/lessons/migrations/__pycache__/0002_auto_20210109_1220.cpython-37.pyc b/lessons/migrations/__pycache__/0002_auto_20210109_1220.cpython-37.pyc deleted file mode 100644 index 44cfe0d..0000000 Binary files a/lessons/migrations/__pycache__/0002_auto_20210109_1220.cpython-37.pyc and /dev/null differ diff --git a/lessons/migrations/__pycache__/0002_auto_20210205_1326.cpython-37.pyc b/lessons/migrations/__pycache__/0002_auto_20210205_1326.cpython-37.pyc new file mode 100644 index 0000000..0a4fff6 Binary files /dev/null and b/lessons/migrations/__pycache__/0002_auto_20210205_1326.cpython-37.pyc differ diff --git a/lessons/migrations/__pycache__/0003_auto_20210113_2224.cpython-37.pyc b/lessons/migrations/__pycache__/0003_auto_20210113_2224.cpython-37.pyc deleted file mode 100644 index d0de32f..0000000 Binary files a/lessons/migrations/__pycache__/0003_auto_20210113_2224.cpython-37.pyc and /dev/null differ diff --git a/lessons/migrations/__pycache__/0003_auto_20210205_1541.cpython-37.pyc b/lessons/migrations/__pycache__/0003_auto_20210205_1541.cpython-37.pyc new file mode 100644 index 0000000..6cbefb9 Binary files /dev/null and b/lessons/migrations/__pycache__/0003_auto_20210205_1541.cpython-37.pyc differ diff --git a/lessons/migrations/__pycache__/0004_answer_completed.cpython-37.pyc b/lessons/migrations/__pycache__/0004_answer_completed.cpython-37.pyc deleted file mode 100644 index 99d4fc0..0000000 Binary files a/lessons/migrations/__pycache__/0004_answer_completed.cpython-37.pyc and /dev/null differ diff --git a/lessons/migrations/__pycache__/0004_auto_20210205_1543.cpython-37.pyc b/lessons/migrations/__pycache__/0004_auto_20210205_1543.cpython-37.pyc new file mode 100644 index 0000000..87ae46f Binary files /dev/null and b/lessons/migrations/__pycache__/0004_auto_20210205_1543.cpython-37.pyc differ diff --git a/lessons/migrations/__pycache__/0005_auto_20210117_1752.cpython-37.pyc b/lessons/migrations/__pycache__/0005_auto_20210117_1752.cpython-37.pyc deleted file mode 100644 index 5c051e7..0000000 Binary files a/lessons/migrations/__pycache__/0005_auto_20210117_1752.cpython-37.pyc and /dev/null differ diff --git a/lessons/migrations/__pycache__/0005_auto_20210205_1544.cpython-37.pyc b/lessons/migrations/__pycache__/0005_auto_20210205_1544.cpython-37.pyc new file mode 100644 index 0000000..d41a24f Binary files /dev/null and b/lessons/migrations/__pycache__/0005_auto_20210205_1544.cpython-37.pyc differ diff --git a/lessons/migrations/__pycache__/0006_auto_20210117_2008.cpython-37.pyc b/lessons/migrations/__pycache__/0006_auto_20210117_2008.cpython-37.pyc deleted file mode 100644 index 248be89..0000000 Binary files a/lessons/migrations/__pycache__/0006_auto_20210117_2008.cpython-37.pyc and /dev/null differ diff --git a/lessons/migrations/__pycache__/0006_auto_20210205_1848.cpython-37.pyc b/lessons/migrations/__pycache__/0006_auto_20210205_1848.cpython-37.pyc new file mode 100644 index 0000000..1b67022 Binary files /dev/null and b/lessons/migrations/__pycache__/0006_auto_20210205_1848.cpython-37.pyc differ diff --git a/lessons/migrations/__pycache__/0007_auto_20210205_1857.cpython-37.pyc b/lessons/migrations/__pycache__/0007_auto_20210205_1857.cpython-37.pyc new file mode 100644 index 0000000..c367c80 Binary files /dev/null and b/lessons/migrations/__pycache__/0007_auto_20210205_1857.cpython-37.pyc differ diff --git a/lessons/migrations/__pycache__/0007_lesson_time_lesson.cpython-37.pyc b/lessons/migrations/__pycache__/0007_lesson_time_lesson.cpython-37.pyc deleted file mode 100644 index 6012566..0000000 Binary files a/lessons/migrations/__pycache__/0007_lesson_time_lesson.cpython-37.pyc and /dev/null differ diff --git a/lessons/migrations/__pycache__/0008_auto_20210205_1858.cpython-37.pyc b/lessons/migrations/__pycache__/0008_auto_20210205_1858.cpython-37.pyc new file mode 100644 index 0000000..16f57ce Binary files /dev/null and b/lessons/migrations/__pycache__/0008_auto_20210205_1858.cpython-37.pyc differ diff --git a/lessons/migrations/__pycache__/0008_materials_lesson.cpython-37.pyc b/lessons/migrations/__pycache__/0008_materials_lesson.cpython-37.pyc deleted file mode 100644 index 7199082..0000000 Binary files a/lessons/migrations/__pycache__/0008_materials_lesson.cpython-37.pyc and /dev/null differ diff --git a/lessons/migrations/__pycache__/0009_lesson_content.cpython-37.pyc b/lessons/migrations/__pycache__/0009_lesson_content.cpython-37.pyc deleted file mode 100644 index c6cb4a2..0000000 Binary files a/lessons/migrations/__pycache__/0009_lesson_content.cpython-37.pyc and /dev/null differ diff --git a/lessons/migrations/__pycache__/0010_auto_20210203_0122.cpython-37.pyc b/lessons/migrations/__pycache__/0010_auto_20210203_0122.cpython-37.pyc deleted file mode 100644 index a755b90..0000000 Binary files a/lessons/migrations/__pycache__/0010_auto_20210203_0122.cpython-37.pyc and /dev/null differ diff --git a/lessons/migrations/__pycache__/__init__.cpython-36.pyc b/lessons/migrations/__pycache__/__init__.cpython-36.pyc deleted file mode 100644 index 62c0def..0000000 Binary files a/lessons/migrations/__pycache__/__init__.cpython-36.pyc and /dev/null differ diff --git a/lessons/migrations/__pycache__/__init__.cpython-37.pyc b/lessons/migrations/__pycache__/__init__.cpython-37.pyc index 8a59067..f976b03 100644 Binary files a/lessons/migrations/__pycache__/__init__.cpython-37.pyc and b/lessons/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/lessons/models.py b/lessons/models.py index 0c255df..aa6f0aa 100644 --- a/lessons/models.py +++ b/lessons/models.py @@ -44,16 +44,28 @@ class Tests(models.Model): class Type(models.Model): name = models.TextField(max_length=150) + +class TaskType(models.Model): + name = models.TextField() + class Task(models.Model): theory = models.TextField() practise = models.TextField() - test = models.ForeignKey(Tests, on_delete=models.CASCADE) + test = models.ManyToManyField(Tests) types = models.ManyToManyField(Type) number = models.IntegerField() max_score = models.IntegerField(default=0) + is_timing = models.BooleanField(default=False) + time = models.IntegerField(default=30) + Type = models.ForeignKey(TaskType, on_delete=models.CASCADE) + is_autoCheck = models.BooleanField(default=False) + autoCheckData = models.TextField(blank=True) + + + class Theme(models.Model): tasks = models.ManyToManyField(Task) name = models.CharField(max_length=150) @@ -78,8 +90,8 @@ def _post_save_receiver_(sender, instance, created, **kwargs): for child in instance.lesson.type_lesson.group.child_set.all(): AnswerSheet.objects.create(child=child, completed=False, test=instance) -@receiver(post_save, sender=Task) +'''@receiver(post_save, sender=Task) def _post_save_receiver(sender, instance, created, **kwargs): if created: for child in instance.test.lesson.type_lesson.group.child_set.all(): - Answer.objects.create(number=instance.number, sheet=child.answersheet_set.all().filter(test=instance.test)[0], content="") \ No newline at end of file + Answer.objects.create(number=instance.number, sheet=child.answersheet_set.all().filter(test=instance.test)[0], content="")''' \ No newline at end of file diff --git a/lessons/schema.py b/lessons/schema.py index 60692ab..20186b3 100644 --- a/lessons/schema.py +++ b/lessons/schema.py @@ -38,7 +38,7 @@ class UpdateLessonRegistration(graphene.Mutation): ok = graphene.Boolean() def mutate(self, info, id, descr=None, name=None): - lesson = Lesson.objects.get(id=id) or None + lesson = Lesson.objects.get(id=from_global_id(id)[1]) or None if lesson == None: return UpdateLessonRegistration(ok=False) descr_upd = lesson.descr name_upd = lesson.name @@ -71,7 +71,7 @@ class CreateTest(graphene.Mutation): test = graphene.Field(TestsType) def mutate(self, info, lesson_id, name, deadline=None): - lesson = Lesson.objects.get(id=lesson_id) + lesson = Lesson.objects.get(id=from_global_id(lesson_id)[1]) t = Tests.objects.create(name=name, lesson=lesson, deadline=datetime.datetime.now()) return CreateTest(test=t) @@ -129,17 +129,23 @@ class createTask(graphene.Mutation): practise = graphene.String() number = graphene.Int() max_score = graphene.Int() + Type = graphene.String() task = graphene.Field(TaskType) - def mutate(self, info, test_id, theory, practise, number, max_score): + def mutate(self, info, test_id, theory, practise, number, max_score, Type): + task = Tests.objects.get(id=from_global_id(test_id)[1]) + print(task) m = createModel(model=Task, fields = { - "test": Tests.objects.get(id=test_id), "theory": theory, "practise": practise, "number": number, - "max_score": max_score + "max_score": max_score, + "Type" : taskType(id=from_global_id(Type)[1]) }) + print(m) + m.test.set([task]) + m.save() return createTask(task=m) class updateTask(graphene.Mutation): @@ -149,15 +155,26 @@ class updateTask(graphene.Mutation): practise = graphene.String() number = graphene.Int() max_score = graphene.Int() + Type = graphene.ID() + autoCheck = graphene.Boolean() + autoCheckData = graphene.String() + is_time = graphene.Boolean() + time = graphene.Int() task = graphene.Field(TaskType) - def mutate(self, info, task_id, theory=None, practise=None, number=None, max_score=None): - task = Task.objects.get(id=task_id) + def mutate(self, info, task_id, theory=None, practise=None, number=None, max_score=None, + Type=None, autoCheck=None, autoCheckData=None, is_time=None, time=None): + task = Task.objects.get(id=from_global_id(task_id)[1]) m = updateModel(Task, task, { "theory": [theory, task.theory], "practise": [practise, task.practise], "number": [number, task.number], - "max_score": [max_score, task.max_score] + "max_score": [max_score, task.max_score], + "Type": [taskType(from_global_id(Type)), task.Type], + "is_autoCheck": [autoCheck, task.is_autoCheck], + "autoCheckData": [autoCheckData, task.autoCheckData], + "is_timing": [is_time, task.is_timing], + "time" : [time, task.time] }) return updateTask(task=m) @@ -328,18 +345,52 @@ class CreateMaterial(graphene.Mutation): lesson_id = graphene.ID() data = graphene.String() name = graphene.String() + lessonType = graphene.String() material = graphene.Field(Material) - def mutate(self, info, lesson_id, data, name): + def mutate(self, info, lesson_id, data, name, lessonType): lessonId = from_global_id(lesson_id)[1] print(lessonId) lesson = Lesson.objects.get(id=lessonId) - material = Materials.objects.create(lesson=lesson, data=data, link="google.com", name=name) + material = Materials.objects.create(lesson=lesson, data=data, link="google.com", name=name, Type=lessonType) return CreateMaterial(material=material) +class DeleteMaterial(graphene.Mutation): + class Arguments: + material_id = graphene.ID() + + ok = graphene.Boolean() + + + def mutate(self, info, material_id): + material_id = from_global_id(material_id)[1] + + Materials.objects.get(id=material_id).delete() + return DeleteMaterial(ok=True) + + +class ChangeMaterail(graphene.Mutation): + class Arguments: + material_id = graphene.ID() + data = graphene.String() + name = graphene.String() + + material = graphene.Field(Material) + + + def mutate(self, info, material_id, data, name): + material_id = from_global_id(material_id)[1] + material = Materials.objects.get(id=material_id) + material.name = name or material.name + material.data = data or material.data + material.save() + return ChangeMaterail(material=material) + + + class Mutation(graphene.ObjectType): create_lesson = CreateLesson.Field() update_lesson_registration = UpdateLessonRegistration.Field() @@ -371,6 +422,8 @@ class Mutation(graphene.ObjectType): create_material = CreateMaterial.Field() + deleteMaterial = DeleteMaterial.Field() + changeMaterial = ChangeMaterail.Field() class Query(graphene.ObjectType): @@ -380,8 +433,7 @@ class Query(graphene.ObjectType): all_subject = DjangoFilterConnectionField(SubjectType) subject = relay.Node.Field(SubjectType) - task = relay.Node.Field(TaskType) - all_task = DjangoFilterConnectionField(TaskType) + answer_sheet = relay.Node.Field(AnswerSheetType) all_answer_sheet = DjangoFilterConnectionField(AnswerSheetType) @@ -395,4 +447,16 @@ class Query(graphene.ObjectType): subject_class = relay.Node.Field(LocalSubjectType) subject_classes = DjangoFilterConnectionField(LocalSubjectType) + + materials = DjangoFilterConnectionField(Material) + material = relay.Node.Field(Material) + + gettaskType = relay.Node.Field(TaskTypeType) + taskTypes = DjangoFilterConnectionField(TaskTypeType) + + + tasks = DjangoFilterConnectionField(TaskType) + task = relay.Node.Field(TaskType) + + schema = graphene.Schema(query=Query) \ No newline at end of file