Menu Semestre => Modifier le semestre => Publication" soit cochée. // Code contribué par Yann Leboulanger (Université Paris 10), Juin 2013 // et modifié par Pascal Legrand (Nov 2017) // // Exemple publication des bulletins de notes vers les étudiants // L'étudiant est authenfié via le CAS // Le bulletin est récupéré en format XML en interrogeant ScoDoc // // Il faut créer un utilisateur ScoDoc n'ayant que des droits de lecture. // // A adapter à  vos besoins locaux. include_once 'CAS.php'; // *********************************************** CONFIGURATION *************************************************** phpCAS::client(CAS_VERSION_2_0,'URL_CAS',443,''); phpCAS::setNoCasServerValidation(); phpCAS::forceAuthentication(); $nip = phpCAS::getUser(); // Login information of a scodoc user that can access notes $sco_user = 'USER'; $sco_pw = 'PASS'; $sco_url = 'https://SERVEUR/ScoDoc/'; // URL où sont stockées les photos, si celle-ci diffère de "$sco_url". // Cette valeur est concaténée avec la valeur de "etudiant['photo_url']". (/ScoDoc/static/photos/.....) $photo_url = 'https://SERVEUR/ScoDoc/'; // *********************************************** CONFIGURATION *************************************************** // ************************************************* FONCTIONS ***************************************************** // Définition de la fonction d'encodage des headers function http_build_headers( $headers ) { $headers_brut = ''; foreach( $headers as $nom => $valeur ) { $headers_brut .= $nom . ': ' . $valeur . "\r\n"; } return $headers_brut; } // Récupération du département function get_dept($nip) { global $sco_url; $dept = file_get_contents( $sco_url . 'get_etud_dept?code_nip=' . $nip); return ($dept); } function get_EtudInfos_page($nip, $dept) { // Récupération des informations concernant l'étudiant. // Nécessite une authentification avec sco_user et sco_pw - Il est possible de choisir le format XML ou JSON. // etud_info // Paramètres: etudid ou code_nip ou code_ine // Résultat: informations sur cet étudiant et les semestres dans lesquels il est (ou a été) inscrit. // Exemple: etud_info?format=json&etudid=12345 global $sco_user; global $sco_pw; global $sco_url; $donnees = array('format' => 'xml', 'code_nip' => $nip, '__ac_name' => $sco_user, '__ac_password' => $sco_pw); // Création du contenu brut de la requête $contenu = http_build_query($donnees); // Définition des headers $headers = http_build_headers(array('Content-Type' => 'application/x-www-form-urlencoded', 'Content-Length' => strlen( $contenu))); // Définition du contexte $options = array('http' => array('method' => 'POST', 'content' => $contenu, 'header' => $headers)); // Création du contexte $contexte = stream_context_create($options); // Envoi du formulaire POST $retour = file_get_contents($sco_url . $dept . '/Scolarite/Notes/etud_info', false, $contexte); return ($retour); } function get_all_semestres($xml_data) // Tous les semestres suivis par l'étudiant { $data = array(); $xml = simplexml_load_string($xml_data); foreach ($xml->insemestre as $s) { $sem = (array) $s['formsemestre_id']; $data[] = $sem[0]; } return $data; } function get_current_semestre($xml_data) // Semestre courrant suivi par l'étudiant { $xml = simplexml_load_string($xml_data); foreach ($xml->insemestre as $s) { if ($s['current'] == 1) $sem = (array) $s['formsemestre_id']; return ($sem[0]); } } function get_semestre_info($sem, $dept) { // Renvoi les informations détaillées d'un semestre // Ne nécessite pas d'authentification avec sco_user et sco_pw - Il est possible de choisir le format XML ou JSON. // formsemestre_list // Paramètres (tous optionnels): formsemestre_id, formation_id, etape_apo // Résultat: liste des semestres correspondant. // Exemple: formsemestre_list?format=xml&etape_apo=V1RT global $sco_pw; global $sco_user; global $sco_url; $donnees = array('format' => 'xml', 'formsemestre_id' => $sem, '__ac_name' => $sco_user, '__ac_password' => $sco_pw); // Création du contenu brut de la requête $contenu = http_build_query( $donnees ); // Définition des headers $headers = http_build_headers( array('Content-Type' => 'application/x-www-form-urlencoded', 'Content-Length' => strlen( $contenu) ) ); // Définition du contexte $options = array( 'http' => array('method' => 'POST', 'content' => $contenu, 'header' => $headers ) ); // Création du contexte $contexte = stream_context_create($options); // Envoi du formulaire POST $retour = file_get_contents( $sco_url . $dept . '/Scolarite/Notes/formsemestre_list', false, $contexte ); /* echo '

'; echo 'get_semestre_info : '; echo '
' . htmlentities($retour) . '
'; echo '
'; */ return ($retour); } function print_semestres_list($sems, $dept, $sem) { // Affiche le nom (titre_num) de tous les semestres suivis par l'étudiant dans un formulaire echo '
' . "\n"; echo '
' . "\n"; echo ' Liste des semestres' . "\n"; echo '

' . "\n"; echo ' ' . "\n"; echo '
' . "\n"; echo '
' . "\n"; echo '

' . "\n"; echo '

' . "\n"; echo '
' . "\n"; } function get_bulletinetud_page($nip, $sem, $dept) { // formsemestre_bulletinetud // Paramètres: formsemestre_id, etudid, format (xml ou json), version (short, selectedevalsou long) // Résultat: bulletin de notes // Exemple: ici au format JSON, pour une version courte (version=short) global $sco_user; global $sco_pw; global $sco_url; $donnees = array('format' => 'xml', 'code_nip' => $nip, 'formsemestre_id' => $sem, 'version' => 'long', '__ac_name' => $sco_user, '__ac_password' => $sco_pw ); // Création du contenu brut de la requête $contenu = http_build_query( $donnees ); // Définition des headers $headers = http_build_headers( array('Content-Type' => 'application/x-www-form-urlencoded', 'Content-Length' => strlen( $contenu) ) ); // Définition du contexte $options = array( 'http' => array('method' => 'POST', 'content' => $contenu, 'header' => $headers ) ); // Création du contexte $contexte = stream_context_create($options); // Envoi du formulaire POST $retour = file_get_contents( $sco_url . $dept . '/Scolarite/Notes/formsemestre_bulletinetud', false, $contexte ); return ($retour); } function print_semestre($xml_data, $sem, $dept, $show_moy) { global $photo_url; $xml = simplexml_load_string($xml_data); echo '

' . $xml->etudiant['sexe'] . ' ' . $xml->etudiant['prenom'] . ' ' . $xml->etudiant['nom'] . '

' . "\n" . '
' . "\n"; $retour = get_semestre_info($sem, $dept); $xml2 = simplexml_load_string($retour); $publie= $xml2->formsemestre['bul_hide_xml']; if (isset($xml->absences)) { (isset($xml->absences['nbabs'])) ? $nbabs = $xml->absences['nbabs']: $nbabs = 0; (isset($xml->absences['nbabsjust'])) ? $nbabsjust = $xml->absences['nbabsjust']: $nbabsjust = 0; echo ' Vous avez à  ce jour ' . $nbabs . ' demi-journée(s) d\'absences, dont ' . $nbabsjust . ' justifiée(s)
' . "\n"; } else { echo ' Les absences ne sont pas saisies.
' . "\n"; } echo '

' . htmlentities($xml2->formsemestre['titre_num']) . '

' . "\n"; if ($publie == 1) { echo ' Publication des notes non activée sur ScoDoc pour ce semestre
' . "\n"; } else { echo '
' . "\n"; echo '
' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; if ($show_moy) { echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; } foreach ($xml->ue as $ue) { $coef = 0; foreach ($ue->module as $mod) { $coef += (float) $mod['coefficient']; } echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; if ($show_moy) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } echo ' ' . "\n"; foreach ($ue->module as $mod) { echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; if ($show_moy) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } echo ' ' . "\n"; echo ' ' . "\n"; if (!$show_moy) { foreach ($mod->evaluation as $eval) { echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; } } } } echo '
UEModuleEvaluationNote/20Coef
Moyenne générale:' . $xml->note['value'] . '
' . $ue['acronyme'] . '
' . htmlentities($ue['titre']) . '
' . $ue->note['value'] . '' . $coef . '
' . htmlentities($mod['titre']) . '' . $mod->note['value'] . '' . $mod['coefficient'] . '
' . htmlentities($eval['description']) . '' . $eval->note['value'] . '
' . "\n"; echo '
' . "\n"; echo '
' . "\n"; if ($show_moy) { echo $xml->situation . "\n"; } } } // ************************************************* FONCTIONS ***************************************************** // ************************************************** HTML ***************************************************** echo' Bulletins de notes '; $dept = get_dept($nip); if ($dept) { $etud_info = get_EtudInfos_page($nip, $dept); $sems = get_all_semestres($etud_info); $sem_current = get_current_semestre($etud_info); // (Condition) ? : (isset($_POST['sem'])) ? $sem = $_POST['sem']:$sem = $sem_current; print_semestres_list($sems, $dept, $sem); (!isset($_POST['notes_moy'])) ? $_POST['notes_moy']='notes':''; echo '
Affichage des ' . ucfirst($_POST['notes_moy']) . '' . "\n";; $bulletin_page = get_bulletinetud_page($nip, $sem, $dept); ($_POST['notes_moy'] == 'notes') ? print_semestre($bulletin_page, $sem, $dept, False):print_semestre($bulletin_page, $sem, $dept, True); // ($sem == $sem_current) ? print_semestre($bulletin_page, $sem, $dept, False):print_semestre($bulletin_page, $sem, $dept, True); } else { echo ' Numéro étudiant inconnu : ' . $nip . ' - Contactez votre Chef de département
' . "\n"; } $erreur=0; // Tout est OK /* echo '

'; echo 'get_etud_info : '; echo '
' . htmlentities($etud_info) . '
'; echo 'sems : '; echo '
' . print_r($sems) . '
'; echo 'sem_current : '; echo '
' . htmlentities($sem_current) . '
'; echo 'get_bulletinetud_page : '; echo '
' . htmlentities($bulletin_page) . '
'; echo '
'; */ echo '' . "\n"; echo '' . "\n"; // ************************************************** HTML ***************************************************** ?>