mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
fix: Application des périodes à un studentCompetency lors de la création
d'une nouvelle compétence
This commit is contained in:
@ -33,6 +33,10 @@ from N3wtSchool.bdd import delete_object, getAllObjects, getObject
|
|||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from Subscriptions.models import Student, StudentCompetency
|
from Subscriptions.models import Student, StudentCompetency
|
||||||
|
from Subscriptions.util import getCurrentSchoolYear
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@method_decorator(csrf_protect, name='dispatch')
|
@method_decorator(csrf_protect, name='dispatch')
|
||||||
@method_decorator(ensure_csrf_cookie, name='dispatch')
|
@method_decorator(ensure_csrf_cookie, name='dispatch')
|
||||||
@ -478,6 +482,7 @@ class CompetencyDetailView(APIView):
|
|||||||
@method_decorator(ensure_csrf_cookie, name='dispatch')
|
@method_decorator(ensure_csrf_cookie, name='dispatch')
|
||||||
class EstablishmentCompetencyListCreateView(APIView):
|
class EstablishmentCompetencyListCreateView(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
|
logger.info('coucou')
|
||||||
establishment_id = request.GET.get('establishment_id')
|
establishment_id = request.GET.get('establishment_id')
|
||||||
cycle = request.GET.get('cycle')
|
cycle = request.GET.get('cycle')
|
||||||
if not establishment_id or not cycle:
|
if not establishment_id or not cycle:
|
||||||
@ -581,7 +586,6 @@ class EstablishmentCompetencyListCreateView(APIView):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
category = Category.objects.get(id=category_id)
|
category = Category.objects.get(id=category_id)
|
||||||
# Vérifier si une compétence custom du même nom existe déjà pour cet établissement et cette catégorie
|
|
||||||
ec_exists = EstablishmentCompetency.objects.filter(
|
ec_exists = EstablishmentCompetency.objects.filter(
|
||||||
establishment_id=establishment_id,
|
establishment_id=establishment_id,
|
||||||
competency__isnull=True,
|
competency__isnull=True,
|
||||||
@ -598,12 +602,31 @@ class EstablishmentCompetencyListCreateView(APIView):
|
|||||||
custom_category=category,
|
custom_category=category,
|
||||||
is_required=False
|
is_required=False
|
||||||
)
|
)
|
||||||
# Associer à tous les élèves de l'établissement
|
|
||||||
|
# Récupérer l'établissement et sa fréquence d'évaluation
|
||||||
|
establishment = ec.establishment
|
||||||
|
evaluation_frequency = establishment.evaluation_frequency # 1=Trimestre, 2=Semestre, 3=Année
|
||||||
|
|
||||||
|
# Déterminer l'année scolaire courante
|
||||||
|
school_year = getCurrentSchoolYear()
|
||||||
|
|
||||||
|
# Générer les périodes selon la fréquence
|
||||||
|
periods = []
|
||||||
|
if evaluation_frequency == 1: # Trimestre
|
||||||
|
periods = [f"T{i+1}_{school_year}" for i in range(3)]
|
||||||
|
elif evaluation_frequency == 2: # Semestre
|
||||||
|
periods = [f"S{i+1}_{school_year}" for i in range(2)]
|
||||||
|
elif evaluation_frequency == 3: # Année
|
||||||
|
periods = [f"A_{school_year}"]
|
||||||
|
|
||||||
|
# Associer à tous les élèves de l'établissement pour chaque période
|
||||||
students = Student.objects.filter(associated_class__establishment_id=establishment_id)
|
students = Student.objects.filter(associated_class__establishment_id=establishment_id)
|
||||||
for student in students:
|
for student in students:
|
||||||
|
for period in periods:
|
||||||
StudentCompetency.objects.get_or_create(
|
StudentCompetency.objects.get_or_create(
|
||||||
student=student,
|
student=student,
|
||||||
establishment_competency=ec
|
establishment_competency=ec,
|
||||||
|
period=period
|
||||||
)
|
)
|
||||||
|
|
||||||
created.append({
|
created.append({
|
||||||
|
|||||||
@ -147,7 +147,7 @@ export default function ValidateSubscription({
|
|||||||
{allTemplates[currentTemplateIndex].name || 'Document sans nom'}
|
{allTemplates[currentTemplateIndex].name || 'Document sans nom'}
|
||||||
</h3>
|
</h3>
|
||||||
<iframe
|
<iframe
|
||||||
src={`${BASE_URL}/${allTemplates[currentTemplateIndex].file}`}
|
src={`${BASE_URL}${allTemplates[currentTemplateIndex].file}`}
|
||||||
title={
|
title={
|
||||||
allTemplates[currentTemplateIndex].type === 'main'
|
allTemplates[currentTemplateIndex].type === 'main'
|
||||||
? 'Document Principal'
|
? 'Document Principal'
|
||||||
|
|||||||
Reference in New Issue
Block a user