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

@@ -1,10 +1,11 @@
from django.db import models
from django.conf import settings
from django.utils import timezone
from django.contrib import admin
import uuid
EVAL_TYPE = [
('1', 'Intervention'),
('1', 'Intervention/Exercice'),
('2', 'Journée'),
]
INTER_NATURE = [
@@ -30,42 +31,49 @@ INTER_COMPLEXITY = [
STUDENT_ROLE = [
('1', 'Leader'),
('2', 'Équipier'),
('3', '3e position (observateur'),
('3', '3e position (observateur)'),
]
EVAL_MODE = [
('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):
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
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)
Author_2e = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name="Second auteur", on_delete=models.SET_NULL, null=True, related_name="eval_second_author")
sAuthor_2e = models.CharField("Second auteur", max_length=120)
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, blank=True,)
#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)
#Information sur le suivi
nEval_Type = models.CharField('Type de suivi', max_length=1, choices=EVAL_TYPE, default=1)
dtDate = models.DateField("Date", default=timezone.now)
sRef = models.CharField("N° de référence / FIP", max_length=120)
dtDate = models.DateField("Date concernée", default=timezone.now)
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)
sDesc_neg = models.TextField("Points à améliorer")
sDesc_pos = models.TextField("Points positifs")
sDesc_global = models.TextField("Avis global sur l'intervention/journée/exercice")
#Information sur l'intervention
nInter_Nature = models.CharField('Nature', max_length=1, choices=INTER_NATURE, default=1)
nInter_Priority = models.CharField('Priorité', max_length=1, choices=INTER_PRIORITY, default=1)
nInter_Complexity = models.CharField('Nature de complexité', max_length=1, choices=INTER_COMPLEXITY, default=1)
sInter_Desc = models.TextField("Description courte")
nStudent_Roles = models.CharField("Rôle de l'étudiant/stagiaire", max_length=1, choices=STUDENT_ROLE, 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, blank=True,)
nInter_Complexity = models.CharField('Nature de complexité', max_length=1, choices=INTER_COMPLEXITY, default=1, blank=True,)
sInter_Desc = models.TextField("Description courte", blank=True,)
nStudent_Role = models.CharField("Rôle de l'étudiant/stagiaire", max_length=1, choices=STUDENT_ROLE, default=1, blank=True,)
#Automatic data
@@ -76,6 +84,19 @@ class cl_Student_eval(models.Model):
super().__init__(*args, **kwargs)
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):
@@ -93,7 +114,7 @@ class cl_Student_eval(models.Model):
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:
verbose_name = "Suivi étudiants - stagiaires"