-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create training app, models and fixtures
- Loading branch information
Showing
13 changed files
with
258 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from django.contrib import admin | ||
from training import models | ||
|
||
|
||
class ContentBlockInline(admin.StackedInline): | ||
model = models.ContentBlock | ||
extra = 1 | ||
|
||
|
||
class QuizChoiceInline(admin.TabularInline): | ||
model = models.QuizChoice | ||
extra = 1 | ||
|
||
|
||
class QuizInline(admin.StackedInline): | ||
model = models.Quiz | ||
inlines = [QuizChoiceInline, ] | ||
extra = 1 | ||
|
||
|
||
@admin.register(models.Quiz) | ||
class QuizAdmin(admin.ModelAdmin): | ||
list_display = ('training', 'question', 'order') | ||
inlines = [QuizChoiceInline, ] | ||
|
||
|
||
@admin.register(models.OnPlatformTraining) | ||
class OnPlatformTrainingAdmin(admin.ModelAdmin): | ||
list_display = ('training', 'version') | ||
inlines = [ContentBlockInline, QuizInline] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class TrainingConfig(AppConfig): | ||
name = 'training' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
[ | ||
{ | ||
"model": "training.onplatformtraining", | ||
"pk": 1, | ||
"fields": { | ||
"training": 2, | ||
"version": 1.0 | ||
} | ||
}, | ||
{ | ||
"model": "training.contentblock", | ||
"pk": 1, | ||
"fields": { | ||
"training": 1, | ||
"body": "Content Body 1", | ||
"order": 1 | ||
} | ||
}, | ||
{ | ||
"model": "training.contentblock", | ||
"pk": 2, | ||
"fields": { | ||
"training": 1, | ||
"body": "Content Body 2", | ||
"order": 3 | ||
} | ||
}, | ||
{ | ||
"model": "training.quiz", | ||
"pk": 1, | ||
"fields": { | ||
"training": 1, | ||
"question": "Which of this is not a country in America?", | ||
"order": 2 | ||
} | ||
}, | ||
{ | ||
"model": "training.quizchoice", | ||
"pk": 1, | ||
"fields": { | ||
"quiz": 1, | ||
"body": "Canada", | ||
"is_correct": false | ||
} | ||
}, | ||
{ | ||
"model": "training.quizchoice", | ||
"pk": 2, | ||
"fields": { | ||
"quiz": 1, | ||
"body": "Spain", | ||
"is_correct": true | ||
} | ||
}, | ||
{ | ||
"model": "training.quizchoice", | ||
"pk": 3, | ||
"fields": { | ||
"quiz": 1, | ||
"body": "Cuba", | ||
"is_correct": false | ||
} | ||
}, | ||
{ | ||
"model": "training.quizchoice", | ||
"pk": 4, | ||
"fields": { | ||
"quiz": 1, | ||
"body": "Mexico", | ||
"is_correct": false | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Generated by Django 4.1.5 on 2023-02-28 14:29 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import project.modelcomponents.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('user', '0052_alter_trainingtype_required_field'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='OnPlatformTraining', | ||
fields=[ | ||
('id', models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('version', models.FloatField(default=1.0, unique=True)), | ||
('training', models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name='op_trainings', to='user.trainingtype')), | ||
], | ||
options={ | ||
'default_permissions': ('change',), | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Quiz', | ||
fields=[ | ||
('id', models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('question', project.modelcomponents.fields.SafeHTMLField()), | ||
('order', models.PositiveIntegerField()), | ||
('training', models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name='quizzes', to='training.onplatformtraining')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='QuizChoice', | ||
fields=[ | ||
('id', models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('body', models.TextField()), | ||
('is_correct', models.BooleanField(default=False, verbose_name='Correct Choice?')), | ||
('quiz', models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name='choices', to='training.quiz')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='ContentBlock', | ||
fields=[ | ||
('id', models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('body', project.modelcomponents.fields.SafeHTMLField()), | ||
('order', models.PositiveIntegerField()), | ||
('training', models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name='contents', to='training.onplatformtraining')), | ||
], | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from django.db import models | ||
|
||
from project.modelcomponents.fields import SafeHTMLField | ||
|
||
|
||
class OnPlatformTraining(models.Model): | ||
training = models.ForeignKey('user.TrainingType', | ||
on_delete=models.CASCADE, related_name='op_trainings') | ||
version = models.FloatField(default=1.0, unique=True) | ||
|
||
class Meta: | ||
default_permissions = ('change',) | ||
|
||
|
||
class Quiz(models.Model): | ||
question = SafeHTMLField() | ||
training = models.ForeignKey('training.OnPlatformTraining', | ||
on_delete=models.CASCADE, related_name='quizzes') | ||
order = models.PositiveIntegerField() | ||
|
||
|
||
class ContentBlock(models.Model): | ||
training = models.ForeignKey('training.OnPlatformTraining', | ||
on_delete=models.CASCADE, related_name='contents') | ||
body = SafeHTMLField() | ||
order = models.PositiveIntegerField() | ||
|
||
|
||
class QuizChoice(models.Model): | ||
quiz = models.ForeignKey('training.Quiz', | ||
on_delete=models.CASCADE, related_name='choices') | ||
body = models.TextField() | ||
is_correct = models.BooleanField('Correct Choice?', default=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.shortcuts import render | ||
|
||
# write your views here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
physionet-django/user/migrations/0052_alter_trainingtype_required_field.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 4.1.5 on 2023-02-18 02:12 | ||
|
||
from django.db import migrations, models | ||
import user.enums | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('user', '0051_credentialapplication_auto_rejection_reason'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='trainingtype', | ||
name='required_field', | ||
field=models.PositiveSmallIntegerField( | ||
choices=[(0, 'DOCUMENT'), (1, 'URL'), (2, 'PLATFORM')], | ||
default=user.enums.RequiredField['DOCUMENT']), | ||
), | ||
] |