alpha du modul studenteval

This commit is contained in:
Ambulance Clerc
2023-08-11 19:20:59 +02:00
parent a4b8f41851
commit 0cbb72dfa2
6 changed files with 90 additions and 18 deletions

View File

@@ -47,6 +47,7 @@ INSTALLED_APPS = [
'vehicles.apps.VehiclesConfig', 'vehicles.apps.VehiclesConfig',
'collabs.apps.CollabsConfig', 'collabs.apps.CollabsConfig',
'mycaldav.apps.CaldavConfig', 'mycaldav.apps.CaldavConfig',
'studenteval.apps.StudentevalConfig',
'custom_admin.apps.CustomAdminConfig', 'custom_admin.apps.CustomAdminConfig',
'rangefilter', 'rangefilter',
'django.contrib.admin', 'django.contrib.admin',

View File

@@ -29,6 +29,7 @@ urlpatterns = [
path('caldav/', include('mycaldav.urls')), path('caldav/', include('mycaldav.urls')),
#path('collabs_hour/', include('collabs.urls')), #path('collabs_hour/', include('collabs.urls')),
path('carnet_rouge/', include('carnet_rouge.urls')), path('carnet_rouge/', include('carnet_rouge.urls')),
path('student_eval/', include('studenteval.urls')),
path('summernote/', include('django_summernote.urls')), path('summernote/', include('django_summernote.urls')),
path('editor/', include('django_summernote.urls')), path('editor/', include('django_summernote.urls')),
] ]

View File

@@ -1,5 +1,50 @@
from django.contrib import admin from django.contrib import admin
from studenteval.models import cl_Student_eval from studenteval.models import cl_Student_eval
class _cl_Student_eval_admin(admin.ModelAdmin):
list_display = ('uuid', 'sStudent', "get_ref_of_eval", "nEval_Type", "nEval_Mode", "sAuthor")
search_fields = ['Student']
#fields = ["Vehicle", "nType",'sTitle', "sDesc","dtStart", "dtEnd", "Author"]
fieldsets = (
('Informations générales', {
'fields': ('Student','nEval_Type','dtDate')
}),
("Information propre à l'intervention ou exercice", {
'fields': ('sRef','sInter_Desc', 'nInter_Nature', 'nInter_Priority', 'nInter_Complexity', 'nStudent_Role')
}),
("Appréciation de l'étudiant/stagiaire", {
'fields': ("nEval_Mode", "sDesc_neg", 'sDesc_pos', "sDesc_global")
}),
("Co-écriture du suivi", {
'fields': ("Author_2e",)
}),
)
def save_model(self, request, obj, form, change):
obj.Author = request.user
obj.sAuthor = request.user.first_name + " " + request.user.last_name
print("pass-Save")
print(obj.Student)
obj.sStudent = obj.Student.first_name + " " + obj.Student.last_name
print(f"sStudent = {obj.sStudent}")
if obj.Author_2e is not None:
obj.sAuthor_2e = obj.Author_2e.first_name + " " + obj.Author_2e.last_name
obj.save()
# Register your models here. # Register your models here.
admin.site.register(cl_Student_eval) admin.site.register(cl_Student_eval, _cl_Student_eval_admin)

View File

@@ -1,10 +1,11 @@
from django.db import models from django.db import models
from django.conf import settings from django.conf import settings
from django.utils import timezone from django.utils import timezone
from django.contrib import admin
import uuid import uuid
EVAL_TYPE = [ EVAL_TYPE = [
('1', 'Intervention'), ('1', 'Intervention/Exercice'),
('2', 'Journée'), ('2', 'Journée'),
] ]
INTER_NATURE = [ INTER_NATURE = [
@@ -30,42 +31,49 @@ INTER_COMPLEXITY = [
STUDENT_ROLE = [ STUDENT_ROLE = [
('1', 'Leader'), ('1', 'Leader'),
('2', 'Équipier'), ('2', 'Équipier'),
('3', '3e position (observateur'), ('3', '3e position (observateur)'),
] ]
EVAL_MODE = [ EVAL_MODE = [
('1', 'Auto-évaluation'), ('1', 'Auto-évaluation'),
('2', 'Ecadrant'), ('2', 'Encadrant'),
] ]
def increment_ID():
last_id = cl_Student_eval.objects.all().order_by('ID').last()
if not last_id:
return 1
last_id = last_id.ID
return last_id + 1
class cl_Student_eval(models.Model): class cl_Student_eval(models.Model):
uuid = models.UUIDField(default=uuid.uuid4(), editable=False, primary_key=True) uuid = models.UUIDField(default=uuid.uuid4(), editable=False, primary_key=True)
#ID = models.IntegerField("ID du Suivi", editable=False, unique=True, default=increment_ID)
# Informations sur l'auteur # Informations sur l'auteur
Author = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name="Auteur", on_delete=models.SET_NULL, null=True, related_name="eval_author") Author = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name="Auteur", on_delete=models.SET_NULL, null=True, related_name="eval_author")
sAuthor = models.CharField("Auteur", max_length=120) sAuthor = models.CharField("Auteur", max_length=120)
Author_2e = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name="Second auteur", on_delete=models.SET_NULL, null=True, related_name="eval_second_author") Author_2e = models.ForeignKey(settings.AUTH_USER_MODEL,limit_choices_to={'groups__name': "FI-Encadrants"}, verbose_name="Second auteur", on_delete=models.SET_NULL, null=True, related_name="eval_second_author", blank=True,)
sAuthor_2e = models.CharField("Second auteur", max_length=120) sAuthor_2e = models.CharField("Second auteur", max_length=120, blank=True,)
#Information sur l 'étudiant/stagiaire #Information sur l 'étudiant/stagiaire
Student = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name="Nom du stagiaire/étudaint", on_delete=models.SET_NULL, null=True) Student = models.ForeignKey(settings.AUTH_USER_MODEL,limit_choices_to={'groups__name': "FI-Étudiants"}, verbose_name="Nom du stagiaire/étudaint", on_delete=models.SET_NULL, null=True)
sStudent = models.CharField("Nom de l'étudiant/stagiaire", max_length=120) sStudent = models.CharField("Nom de l'étudiant/stagiaire", max_length=120)
#Information sur le suivi #Information sur le suivi
nEval_Type = models.CharField('Type de suivi', max_length=1, choices=EVAL_TYPE, default=1) nEval_Type = models.CharField('Type de suivi', max_length=1, choices=EVAL_TYPE, default=1)
dtDate = models.DateField("Date", default=timezone.now) dtDate = models.DateField("Date concernée", default=timezone.now)
sRef = models.CharField("N° de référence / FIP", max_length=120) sRef = models.CharField("N° de référence / FIP", max_length=120, blank=True,)
nEval_Mode = models.CharField('Mode de suivi ', max_length=1, choices=EVAL_MODE, default=1) nEval_Mode = models.CharField('Mode de suivi ', max_length=1, choices=EVAL_MODE, default=1)
sDesc_neg = models.TextField("Points à améliorer") sDesc_neg = models.TextField("Points à améliorer")
sDesc_pos = models.TextField("Points positifs") sDesc_pos = models.TextField("Points positifs")
sDesc_global = models.TextField("Avis global sur l'intervention/journée/exercice") sDesc_global = models.TextField("Avis global sur l'intervention/journée/exercice")
#Information sur l'intervention #Information sur l'intervention
nInter_Nature = models.CharField('Nature', max_length=1, choices=INTER_NATURE, default=1) nInter_Nature = models.CharField('Nature', max_length=1, choices=INTER_NATURE, default=1, blank=True,)
nInter_Priority = models.CharField('Priorité', max_length=1, choices=INTER_PRIORITY, default=1) nInter_Priority = models.CharField('Priorité', max_length=1, choices=INTER_PRIORITY, default=1, blank=True,)
nInter_Complexity = models.CharField('Nature de complexité', max_length=1, choices=INTER_COMPLEXITY, default=1) nInter_Complexity = models.CharField('Nature de complexité', max_length=1, choices=INTER_COMPLEXITY, default=1, blank=True,)
sInter_Desc = models.TextField("Description courte") sInter_Desc = models.TextField("Description courte", blank=True,)
nStudent_Roles = models.CharField("Rôle de l'étudiant/stagiaire", max_length=1, choices=STUDENT_ROLE, default=1) nStudent_Role = models.CharField("Rôle de l'étudiant/stagiaire", max_length=1, choices=STUDENT_ROLE, default=1, blank=True,)
#Automatic data #Automatic data
@@ -76,6 +84,19 @@ class cl_Student_eval(models.Model):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.a_evals = None self.a_evals = None
@admin.display(description='Référence du suivi')
def get_ref_of_eval(self):
sRet = ""
if int(self.nEval_Type) == 1:
sRet = self.sRef
elif int(self.nEval_Type) == 2:
sRet = self.dtDate.strftime("%d.%b.%Y")
print(sRet)
print(f"Eval_Type = {self.nEval_Type} => {int(self.nEval_Type)-1}")
return f"{EVAL_TYPE[int(self.nEval_Type)-1][1]}: {sRet}"
def get_all_evals_for_student(self,sStudent): def get_all_evals_for_student(self,sStudent):
@@ -93,7 +114,7 @@ class cl_Student_eval(models.Model):
def __str__(self): def __str__(self):
return f"{ self.sStudent } => {self.sRef} ({ EVAL_MODE[self.nEval_Mode]})" return f"{ self.sStudent } => {self.sRef} ({ self.nEval_Mode})"
class Meta: class Meta:
verbose_name = "Suivi étudiants - stagiaires" verbose_name = "Suivi étudiants - stagiaires"

View File

@@ -3,15 +3,15 @@ from django.urls import path
from . import views from . import views
'''
app_name = "studenteval" app_name = "studenteval"
urlpatterns = [ urlpatterns = [
#path('vhc', views.view_vhc, name='view_vhc'), path('student/<string>', views.student, name='views.student'),
#path('peremptions', views.view_peremptions, name='view_peremptions'), #path('peremptions', views.view_peremptions, name='view_peremptions'),
] ]
'''

View File

@@ -1,3 +1,7 @@
from django.http import HttpResponse
from django.shortcuts import render from django.shortcuts import render
# Create your views here. # Create your views here.
def student(request, sStudent):
response = "You're looking at the results of question %s."
return HttpResponse(response % question_id)