1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
| with cte_classements as (
select srs.line_id, srs.student_id, nullif(srs.classement_final, 0) as classement_final
from auriga.t_scola_result_entetes sre
join t_scola_result_students srs on (srs.calcul_id, srs.line_id) = (sre.calcul_id, sre.line_id)
where sre.calcul_id = ($P{Parametres}::hstore->'calcul_id')::integer
),
q1 as (
-- (R.1)
select
apprenant.objet_id as id_interne_aurion,
module.code AS "Période",
apprenant.ind_nom AS "Nom",
apprenant.ind_prenom AS "Prénom",
inscription_module.moyenne AS "Moyenne",
inscription_module.classement AS "Classement",
inscription_module.nombre_credits_potentiels AS "Crédits potentiels",
inscription_module.nombre_credits_obtenus AS "Crédits obtenus",
inscription_module.taux_credits_obtenus AS "Taux crédits obtenus/crédits potentiels",
apprenant.ind_date_naissance AS "Date naissance.Apprenant"
from (select o.* from auriga.t_individus o where true and o.est_apprenant) apprenant
left join auriga.t_inscriptions_module inscription_module on inscription_module.apprenant_id = apprenant.objet_id
left join auriga.t_modules module on module.objet_id = inscription_module.module_id
where (true
and (module.code = 'S7')
)
)
, q2 as (
-- BULATS (R.4)
select
apprenant.objet_id as id_interne_aurion,
type_evenement.code AS "Code.Type d'événement",
D1.attribut_valfloat AS "SCORE.Attestation de niveau de langue"
from (select o.* from auriga.t_individus o where true and o.est_apprenant and exists (select 1 from q1 where id_interne_aurion = o.objet_id)) apprenant
left join auriga.t_apprenants_evenements R1 on R1.apprenant_id = apprenant.objet_id
left join auriga.t_evenements evenement on evenement.objet_id = R1.evenement_id
left join auriga.t_types_evenement type_evenement on type_evenement.objet_id = evenement.type_evenement_id
left join auriga.t_relations R2 on R2.source_id = evenement.objet_id and R2.relation_nom = 'evenement-type_evenement_7'
left join auriga.t_objets type_evenement_7 on type_evenement_7.objet_id = R2.dest_id and type_evenement_7.type = 'type_evenement_7' and not (type_evenement_7.efface or type_evenement_7.obsolete)
left join auriga.t_donnees D1 on (D1.objet_id, D1.attribut_id) = (type_evenement_7.objet_id, 246292)
where (true
and (type_evenement.code = 'ATTEST_NIV_LANGUE')
)
)
, q3 as (
-- bonif SP (R.3)
select
apprenant.objet_id as id_interne_aurion,
cours.code AS "Cours Bonif SP",
inscription_cours.nombre_credits_obtenus AS "Crédits Bonif SP"
from (select o.* from auriga.t_individus o where true and o.est_apprenant and exists (select 1 from q1 where id_interne_aurion = o.objet_id)) apprenant
left join auriga.t_inscriptions_cours inscription_cours on inscription_cours.apprenant_id = apprenant.objet_id
left join auriga.t_cours cours on cours.objet_id = inscription_cours.cours_id
where (true
and (cours.code = '12_SP_BONIF_E1')
)
)
, q4 as (
-- bonif SA (R.2)
select
apprenant.objet_id as id_interne_aurion,
cours.code AS "Cours Bonif SA",
inscription_cours.nombre_credits_obtenus AS "Crédits bonif SA"
from (select o.* from auriga.t_individus o where true and o.est_apprenant and exists (select 1 from q1 where id_interne_aurion = o.objet_id)) apprenant
left join auriga.t_inscriptions_cours inscription_cours on inscription_cours.apprenant_id = apprenant.objet_id
left join auriga.t_cours cours on cours.objet_id = inscription_cours.cours_id
where (true
and (cours.code = '12_SA_BONIF_E1')
)
)
(
select
(array_agg(distinct id_interne_aurion))[1] as id_interne_aurion,
q1."Période",
q1."Nom",0,
q1."Prénom",
q4."Cours Bonif SA",
q3."Cours Bonif SP",
0,
q2."Code.Type d'événement",
'','',
q1."Date naissance.Apprenant",
q1."Classement",
'','',
0,0,0,0,'',0,'',0,
q1."Moyenne",
'','',
q1."Crédits potentiels",
q1."Crédits obtenus",
q1."Taux crédits obtenus/crédits potentiels",
q4."Crédits bonif SA",
0,
q3."Crédits Bonif SP",
(max(q2."SCORE.Attestation de niveau de langue")) as "Meilleur score au Bulats",0,0,0,
q1."Date naissance.Apprenant",
q1."Date naissance.Apprenant",
q3."Crédits Bonif SP",0,q1."Date naissance.Apprenant",0,q1."Date naissance.Apprenant",
q3."Crédits Bonif SP",q3."Crédits Bonif SP",'','',q3."Crédits Bonif SP",0,q3."Crédits Bonif SP",true,true,'',0,true,true,'',true,true,q3."Crédits Bonif SP",q3."Crédits Bonif SP",q3."Crédits Bonif SP",q3."Crédits Bonif SP",0,0,'',0
from q1 full join q2 using (id_interne_aurion) full join q3 using (id_interne_aurion) full join q4 using (id_interne_aurion)
where true and id_interne_aurion= any(('{' || $P{ObjectID_List} || '}')::integer[])
and q1.id_interne_aurion is not null
group by q1."Période", q1."Nom", q1."Prénom", q1."Moyenne", q1."Classement", q1."Crédits potentiels", q1."Crédits obtenus", q1."Taux crédits obtenus/crédits potentiels", q4."Cours Bonif SA", q4."Crédits bonif SA", q3."Cours Bonif SP", q3."Crédits Bonif SP", q2."Code.Type d'événement",q1."Date naissance.Apprenant"
order by q1."Classement" asc, q1."Moyenne" asc
)
union all
select bulletin.*, classement.classement_final as classement_racine
from bulletin(
('{' || $P{ApprenantIDs} || '}')::integer[],
($P{Parametres}::text ||
',"avec_arborescence"=>"no"
,"avec_epreuves"=>"yes"
,"avec_appreciations_groupe"=>"no"
,"avec_appreciations_modules"=>"no"
,"avec_appreciations_cours"=>"no"
,"avec_appreciations_notes"=>"no"
,"avec_traduction_lignes"=>"yes"')::hstore
-- Activer cette ligne et renseigner "${langue_id}" si on veut forcer l'utilisation d'une langue ayant l'id "id_langue"
-- || ('"langue_id"=>${langue_id}')::hstore
) bulletin
-- classement
left join cte_classements classement on classement.student_id = bulletin.apprenant_id
order by classement.classement_final, apprenant_nom, bulletin.apprenant_prenom, bulletin.destinataire_id, bulletin.adresse_id, bulletin.ligne_ordre; |
Partager