function referentiel_modifier_evaluation_codes_item($bareme, $refrefid, $liste_competences, $liste_evaluations = '', $is_task = false, $id_activite = 0, $comportement = '', $fonction = 0)
{
    // MODIF JF 2013/05/29
    // La liste est au format
    // codeItem1:indexbareme/codeItem2:indexbareme...
    // A.1-1:-1/A.1-2:2/A.1-3:1/A.1-4:0/A.1-5:0/A.2-1:-1/A.2-2:-1/A.2-3:-1/A.3-1:-1/A.3-2:-1/A.3-3:-1/A.3-4:-1/B.1-1:-1/B.1-2:-1/B.1-3:-1/B.2-1:-1/B.2-2:-1/B.2-3:-1/B.2-4:-1/B.2-5:-1/B.3-1:-1/B.3-2:-1/B.3-3:-1/B.3-4:-1/B.3-5:-1/B.4-1:-1/B.4-2:-1/B.4-3:-1/
    // avec un bareme [NonPertinent, NonValidé, Validé] cela corrspond à
    // A.1-1:INDEFINI
    // A.1-2:Validé
    // A.1-3:NonValidé
    // A.1-4:NonPertinent
    // etc.
    global $OK_REFERENTIEL_DATA;
    global $t_domaine;
    global $t_domaine_coeff;
    global $t_domaine_description;
    // COMPETENCES
    global $t_competence;
    global $t_competence_coeff;
    global $t_competence_description;
    // ITEMS
    global $t_item_code;
    global $t_item_coeff;
    // coefficient poids determine par le modele de calcul (soit poids soit poids / empreinte)
    global $t_item_domaine;
    // index du domaine associe a un item
    global $t_item_competence;
    // index de la competence associee a un item
    global $t_item_poids;
    // poids
    global $t_item_empreinte;
    global $t_nb_item_domaine;
    global $t_nb_item_competence;
    global $t_item_description_competence;
    $maxnbitem = 10;
    // number max of items by competencies
    $s = '';
    $separateur = '/';
    $nl = '';
    $tgraduation = array();
    $tscales = array();
    $ticons = array();
    $tlabels = array();
    if (!empty($bareme)) {
        // DEBUG
        //echo "<br />DEBUG :: lib_bareme.php :: 218 :: BAREME UTILISE";
        //print_object($bareme);
        $tscales = explode(',', $bareme->scale);
        $ticons = explode(',', $bareme->icons);
        $tlabels = explode(',', $bareme->labels);
        $seuil = $bareme->threshold;
        $maxoptions = $bareme->maxscale + 1;
        if ($id_activite == 0) {
            /*	    
                        $s1='<input type="checkbox" id="code_item_';
                        $s2='" name="code_item[]" value="';
                        $s3='"';
                        $s4=' />';
            */
            $s5 = '<label for="code_item_';
            $s6 = '">';
            $s7 = '</label> &nbsp; &nbsp; ' . "\n";
        } else {
            /*
                        $s1='<input type="checkbox" id="code_item_'.$id_activite.'_';
                        $s2='" name="code_item_'.$id_activite.'[]" value="';
                        $s3='"';
                        if (!empty($comportement)){
                            $s4=' '.$comportement.' />';
                        }
                        else{
                            $s4=' />';
                        }
            */
            $s5 = '<label for="code_item_' . $id_activite . '_';
            $s6 = '">';
            $s7 = '</label> &nbsp; &nbsp;' . "\n";
        }
        $checked = ' checked="checked"';
        /*
        	$tl=explode($separateur, $liste_complete);
        */
        if ($refrefid) {
            if (!isset($OK_REFERENTIEL_DATA) || $OK_REFERENTIEL_DATA == false) {
                $OK_REFERENTIEL_DATA = referentiel_initialise_data_referentiel($refrefid);
            }
            if (isset($OK_REFERENTIEL_DATA) && $OK_REFERENTIEL_DATA == true) {
                $tl = $t_item_code;
                $maxnbitem = referentiel_get_maxnbitem($refrefid);
                //				$liste_saisie2=$liste_saisie;
                //              $liste_saisie=preg_replace("/:\d*/", "", $liste_saisie);
                //				$liste_saisie=trim(strtr($liste_saisie, '.', '_'));
                //				$liste_saisie2=trim(strtr($liste_saisie2, '.', '_'));
                //echo "<br />DEBUG :: 980 :: COMPETENCES : $liste_competences<br />\n";
                //echo "<br />DEBUG :: 981 :: EVALUATIONS : $liste_evaluations<br />\n";
                $liste_saisie = strtr($liste_competences, $separateur, ' ');
                $liste_saisie = trim(strtr($liste_saisie, '.', '_'));
                //echo "<br />DEBUG :: 964 :: INPUT : $liste_saisie<br />\n";
                if (!empty($liste_evaluations)) {
                    $liste_bareme = preg_replace("/:\\d*/", "", $liste_evaluations);
                    $liste_a_evaluer = trim(strtr($liste_evaluations, '.', '_'));
                    //echo "<br />DEBUG :: 990 :: INPUT : $liste_bareme<br />\n";
                    //echo "<br />DEBUG :: 991 :: INPUT : $liste_a_evaluer<br />\n";
                    // recupérer la competences declarées
                    if ($input_data = explode('/', $liste_evaluations)) {
                        while (list($key, $val) = each($input_data)) {
                            if (!empty($val)) {
                                //echo "<br>$key => $val ; \n";
                                if ($titem = explode(':', $val)) {
                                    if (isset($titem[1])) {
                                        $tgraduation[$titem[0]] = $titem[1];
                                    }
                                }
                            }
                        }
                    }
                }
                // DEBUG
                //echo "<br />ITEM EVALUES : <br />\n";
                //print_object($tgraduation);
                //echo "<br />\n";
                //exit;
                $ne = count($tl);
                $select = '';
                $index_code_domaine = $t_item_domaine[0];
                $code_domaine = $t_domaine[$index_code_domaine];
                $index_code_competence = $t_item_competence[0];
                $code_competence = $t_competence[$index_code_competence];
                // Moodle 2.7
                $s .= '<table><tr><td colspan="' . $maxnbitem . '">' . "\n";
                $s .= '&nbsp; &nbsp; &nbsp; <span class="bold">' . $code_domaine . '</span> : ' . $t_domaine_description[$index_code_domaine] . "\n";
                // ouvrir domaine
                $s .= '<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <i>' . $code_competence . '</i> : <span class="small">' . $t_competence_description[$index_code_competence] . '</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' . "\n";
                // ouvrir competence
                $s .= '</td></tr></table>' . "\n";
                $s .= '<table><tr>' . "\n";
                $i = 0;
                while ($i < $ne) {
                    //echo $code_domaine.' '.$code_competence;
                    //echo $t_item_domaine[$i].' '.$t_item_competence[$i];
                    // domaine
                    if ($t_item_domaine[$i] != $index_code_domaine) {
                        $index_code_domaine = $t_item_domaine[$i];
                        $code_domaine = $t_domaine[$index_code_domaine];
                        $s .= '</tr></table>' . "\n";
                        $s .= '<table><tr><td colspan="' . $maxnbitem . '">' . "\n";
                        // competence
                        $s .= '<br /> &nbsp; &nbsp; &nbsp; <span class="bold">' . $code_domaine . '</span> : ' . $t_domaine_description[$index_code_domaine] . "\n";
                        // nouveau domaine
                        // nouvelle competence
                        $index_code_competence = $t_item_competence[$i];
                        $code_competence = $t_competence[$index_code_competence];
                        $s .= '<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <i>' . $code_competence . '</i> : <span class="small">' . $t_competence_description[$index_code_competence] . '</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' . "\n";
                        $s .= '</td></tr></table>' . "\n";
                        $s .= '<table><tr>' . "\n";
                    }
                    // competence
                    if ($t_item_competence[$i] != $index_code_competence) {
                        $index_code_competence = $t_item_competence[$i];
                        $code_competence = $t_competence[$index_code_competence];
                        $s .= '</tr></table>' . "\n";
                        $s .= '<table><tr><td colspan="' . $maxnbitem . '">' . "\n";
                        $s .= '<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <i>' . $code_competence . '</i> : <span class="small">' . $t_competence_description[$index_code_competence] . '</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' . "\n";
                        $s .= '</td></tr></table>' . "\n";
                        $s .= '<table><tr>' . "\n";
                    }
                    // item
                    $code = trim($tl[$i]);
                    $le_code = referentiel_affiche_overlib_un_item($separateur, $code);
                    $s .= '<td>' . "\n";
                    $s .= "\n" . '<input type="hidden" name="code_code[]" value="' . $code . '" />' . "\n";
                    if ($code != "") {
                        $code_search = strtr($code, '.', '_');
                        //echo "----- $code_search ";
                        if (stristr($liste_saisie, $code_search)) {
                            if (isset($tgraduation[$code])) {
                                //echo "----- $code_search ".$tgraduation[$code]."<br>";
                                $s .= referentiel_formate_saisie_bareme($id_activite . '_' . $i, $code, $tgraduation[$code], $tscales, $tlabels, $maxoptions, $checked);
                            } else {
                                // MODIF JF 2013/10/07
                                // $s.=referentiel_formate_saisie_bareme($id_activite.'_'.$i, $code, 0, $tscales, $tlabels, $maxoptions, $checked);
                                // echo "<br /> DEBUG :: lib_bareme.php :: 1138 :: <br />----- $code_search ".$tgraduation[$code]."<br>";
                                $s .= referentiel_formate_saisie_bareme($id_activite . '_' . $i, $code, -1, $tscales, $tlabels, $maxoptions, $checked);
                            }
                            //$s.= $s1.$i.$s2.$code.$s3.$checked.$s4.
                            $s .= $s5 . $i . $s6 . '<span class="surligne">' . $le_code . '</span>' . $s7;
                        } else {
                            if (!$is_task) {
                                // MODIF JF 2013/10/07
                                // $s.=referentiel_formate_saisie_bareme($id_activite.'_'.$i, $code, 0, $tscales, $tlabels, $maxoptions, '');
                                $s .= referentiel_formate_saisie_bareme($id_activite . '_' . $i, $code, -1, $tscales, $tlabels, $maxoptions, '');
                                // $s.=$s1.$i.$s2.$code.$s3.$s4.$s5.$i.$s6.$le_code.$s7;
                                $s .= $s5 . $i . $s6 . $le_code . $s7;
                            } else {
                                $s .= ' &nbsp; ' . $s5 . $i . $s6 . $le_code . $s7;
                            }
                        }
                    }
                    $s .= '</td>' . "\n";
                    $i++;
                }
                $s .= '</tr></table>' . "\n";
                $s .= "\n" . '<input type="hidden" name="userbareme" value="1" />' . "\n";
                $s .= '<input type="hidden" name="nbitems" value="' . $i . '" />' . "\n";
                $s .= '<input type="hidden" name="seuil" value="' . $bareme->threshold . '" />' . "\n";
                $s .= '<input type="hidden" name="baremeid" value="' . $bareme->id . '" />' . "\n";
            }
        }
    }
    if ($fonction) {
        return $s;
    } else {
        echo $s;
    }
}
                        } else {
                            $date_modif_info = '';
                        }
                        // MODIF JF 27/10/2009
                        $date_modif_student = $record->date_modif_student;
                        if ($date_modif_student != 0) {
                            $date_modif_student_info = userdate($date_modif_student);
                        } else {
                            $date_modif_student_info = '';
                        }
                        $link_documents = referentiel_get_liens_documents($activite_id, $userid, $context);
                        if ($link_documents) {
                            echo '<br />' . "\n";
                        }
                        // preparer les variables globales pour Overlib
                        referentiel_initialise_data_referentiel($ref_referentiel);
                        $jauge_activite_declarees = referentiel_print_jauge_activite($userid, $ref_referentiel);
                        if ($jauge_activite_declarees) {
                            print_string('competences_declarees', 'referentiel', referentiel_get_user_info($userid));
                            //echo '<br />DEBUT DEBUG'."\n";
                            echo $jauge_activite_declarees . "\n";
                            //echo '<br />FIN DEBUG'."\n";
                        }
                        echo '<div class="ref_saisie1">
<form name="form" method="post" action="' . s("activite.php?id={$cm->id}") . '">
<span class="bold">' . get_string('id', 'referentiel') . '</span>';
                        echo $activite_id;
                        echo '<span class="bold">' . get_string('type_activite', 'referentiel') . '</span>' . s($type_activite) . '
<br /><span class="bold">' . get_string('auteur', 'referentiel') . '</span>' . s($user_info);
                        echo ' <span class="bold">' . get_string('date_creation', 'referentiel') . '</span>' . s($date_creation_info);
                        echo '<br />' . "\n";
function referentiel_affiche_protocole($refrefid, $instanceid = 0)
{
    // tables de protocoles (seuils, item obligatoires, etc.
    // recupere les labels des domaine, compoetence, item
    if (!empty($instanceid)) {
        $labels = referentiel_get_labels_instance($instanceid);
    } else {
        $labels = referentiel_get_labels_occurrence($refrefid);
    }
    global $protocol_seuil_referentiel;
    global $protocol_minima_referentiel;
    global $protocol_t_domaines_oblig;
    global $protocol_t_domaines_seuil;
    global $protocol_t_domaines_minima;
    global $protocol_t_competences_oblig;
    global $protocol_t_competences_seuil;
    global $protocol_t_competences_minima;
    global $protocol_t_items_oblig;
    global $protocol_commentaire;
    global $protocol_timemodified;
    global $protocol_actif;
    global $OK_REFERENTIEL_PROTOCOLE;
    // les données du protocole sont disponibles
    global $OK_REFERENTIEL_DATA;
    // les données du certificat sont disponibles
    // REFERENTIEL
    global $max_minimum_referentiel;
    global $max_seuil_referentiel;
    // DOMAINES
    global $t_domaine;
    global $t_domaine_coeff;
    // COMPETENCES
    global $t_competence;
    global $t_competence_coeff;
    // ITEMS
    global $t_item_code;
    global $t_item_coeff;
    // coefficient poids determine par le modele de calcul (soit poids soit poids / empreinte)
    global $t_item_domaine;
    // index du domaine associe a un item
    global $t_item_competence;
    // index de la competence associee a un item
    global $t_item_poids;
    // poids
    global $t_item_empreinte;
    global $t_nb_item_domaine;
    // Ajout pour le protocole des minimas
    global $t_competence_domaine;
    // index du domaine assicie a une competence
    global $t_nb_competence_domaine;
    // nombre de competences par domaine
    global $t_nb_item_competence;
    // nombre d'item par competences
    global $t_competence_minima;
    // INUTILE ?
    global $t_domaine_minima;
    // INUTILE ?
    $s = '';
    $separateur1 = '/';
    $separateur2 = ':';
    if (!isset($OK_REFERENTIEL_DATA) || $OK_REFERENTIEL_DATA == false) {
        $OK_REFERENTIEL_DATA = referentiel_initialise_data_referentiel($refrefid);
    }
    if (!isset($OK_REFERENTIEL_PROTOCOLE) || $OK_REFERENTIEL_PROTOCOLE == false) {
        $OK_REFERENTIEL_PROTOCOLE = referentiel_initialise_protocole_referentiel($refrefid);
    }
    if (isset($OK_REFERENTIEL_DATA) && $OK_REFERENTIEL_DATA == true && isset($OK_REFERENTIEL_PROTOCOLE) && $OK_REFERENTIEL_PROTOCOLE == true) {
        if (!empty($protocol_t_items_oblig) && !empty($protocol_t_competences_oblig) && !empty($protocol_t_domaines_oblig) && !empty($protocol_t_competences_seuil) && !empty($protocol_t_domaines_seuil)) {
            if (empty($protocol_commentaire)) {
                $protocol_commentaire = get_string('aide_protocole_completer', 'referentiel');
            }
            // Mise en page du tableau
            $nbmaxlignes = 20;
            if ($max_minimum_referentiel >= 60) {
                $nbmaxlignes = 30;
            }
            $nlig = $max_minimum_referentiel;
            $maxlig = min($nbmaxlignes, round($nlig / 2, 0));
            $ncol = round($nlig / $maxlig, 0);
            $nligc = count($protocol_t_competences_oblig);
            $ncolc = round($nligc / $maxlig, 0);
            $ncol += $ncolc;
            $nligd = count($protocol_t_domaines_oblig);
            $ncold = round($nligd / $maxlig, 0);
            $ncol += $ncold;
            $s .= '<div align="center">' . "\n";
            if ($protocol_actif) {
                if ($protocol_timemodified) {
                    $s .= '<span class="surligne">' . get_string('protocole_active', 'referentiel') . ' ' . get_string('depuis', 'referentiel', userdate($protocol_timemodified)) . '</span>' . "\n";
                } else {
                    $s .= '<span class="surligne">' . get_string('protocole_active', 'referentiel') . '</span>' . "\n";
                }
            } else {
                if ($protocol_timemodified) {
                    $s .= '<span class="surligne">' . get_string('protocole_desactive', 'referentiel') . ' ' . get_string('depuis', 'referentiel', userdate($protocol_timemodified)) . '</span>' . "\n";
                } else {
                    $s .= '<span class="surligne">' . get_string('protocole_desactive', 'referentiel') . '</span>' . "\n";
                }
            }
            $s .= '<table class="centree">' . "\n";
            $s .= '<tr valign="top">
<th>' . get_string('minima_certificat', 'referentiel') . '</th></tr>' . "\n";
            $s .= '<tr valign="top">
            <td>
<b>' . $protocol_minima_referentiel . '</b> / <i>' . $max_minimum_referentiel . '</i> &nbsp; &nbsp; &nbsp; (' . get_string('aide_minima', 'referentiel') . ')';
            $s .= '</td></tr>';
            $s .= '<tr valign="top">
<th>' . get_string('seuil_certificat', 'referentiel') . '</th>
</tr>
<tr valign="top">
<td>
<b>' . $protocol_seuil_referentiel . '</b> / <i>' . $max_seuil_referentiel . '</i> &nbsp; &nbsp; &nbsp; (' . get_string('aide_seuil', 'referentiel') . ')
</td></tr>
<tr valign="top">
<th colspan="' . $ncol . '">' . get_string('commentaire', 'referentiel') . '</th></tr>' . "\n";
            $s .= '<tr valign="top">
<td colspan="' . $ncol . '">
' . nl2br(stripslashes($protocol_commentaire)) . "\n";
            $s .= '</td></tr>' . "\n";
            $s .= '</table>' . "\n";
            // ITEMS
            $label_i = $labels->item;
            $expression = str_replace(get_string('itemo', 'referentiel'), $label_i, get_string('item_obligatoires', 'referentiel'));
            $s .= '<table>' . "\n";
            $s .= '<tr valign="top"><td>' . "\n";
            $s .= '<table class="referentiel">
<tr valign="top">
<th colspan="4" class="item">' . $expression . '</th>
</tr>' . "\n";
            $i = 0;
            $k = 0;
            $n = count($protocol_t_items_oblig);
            while ($i < $n) {
                $t_oblig = explode($separateur2, $protocol_t_items_oblig[$i]);
                if (!empty($t_oblig[1])) {
                    $s .= '<tr valign="top"><td>' . $t_oblig[0] . '</td><td><i>' . get_string('yes') . '</i></td>' . "\n";
                } else {
                    $s .= '<tr valign="top"><td>' . $t_oblig[0] . '</td><td><i>' . get_string('no') . '</i></td>' . "\n";
                }
                $s .= '<td><i>' . $t_item_poids[$i] . '</i></td><td>' . $t_item_empreinte[$i] . '</td></tr>' . "\n";
                $i++;
                $k++;
                if ($k == $maxlig && $i < $n) {
                    $s .= '</table></td><td>' . "\n";
                    $s .= '<table class="referentiel">
<tr valign="top">
<th colspan="4" class="item">' . $expression . '</th>
</tr>' . "\n";
                    $k = 0;
                }
            }
            $s .= '</table></td><td>' . "\n";
            // COMPETENCES
            $label_c = $labels->competence;
            $expression = str_replace(get_string('compo', 'referentiel'), $label_c, get_string('competences_oblig_seuil', 'referentiel'));
            $comp_th = str_replace('[', '<th colspan="2">', $expression);
            $comp_th = str_replace(']', '</th>', $comp_th);
            $s .= '<table class="activite">
<tr>' . $comp_th . '</tr>' . "\n";
            $i = 0;
            $k = 0;
            $n = count($protocol_t_competences_oblig);
            while ($i < $n) {
                $t_oblig = explode($separateur2, $protocol_t_competences_oblig[$i]);
                $t_minima = explode($separateur2, $protocol_t_competences_minima[$i]);
                $t_seuil = explode($separateur2, $protocol_t_competences_seuil[$i]);
                $s .= '<tr valign="top"><td>' . $t_oblig[0] . '</td><td>';
                if (!empty($t_oblig[1])) {
                    $s .= '<i>' . get_string('yes') . '</i>';
                } else {
                    $s .= '<i>' . get_string('no') . '</i>';
                }
                $s .= '</td>';
                if ($t_minima[1] > 0) {
                    $s .= '<td class="blue">';
                } else {
                    $s .= '<td>';
                }
                $s .= $t_minima[1] . "\n";
                $s .= '</td><td><i>' . $t_nb_item_competence[$i] . '</i>';
                $s .= '</td>';
                if ($t_seuil[1] > 0) {
                    $s .= '<td class="blue">';
                } else {
                    $s .= '<td>';
                }
                $s .= $t_seuil[1] . "\n";
                $s .= '</td><td><i>' . $t_competence_coeff[$i] . '</i>';
                $s .= '</td></tr>' . "\n";
                $i++;
                $k++;
                if ($k == $maxlig && $i < $n) {
                    $s .= '</table></td><td>' . "\n";
                    $s .= '<table class="activite">
<tr valign="top">
<tr>' . $comp_th . '</tr>
</tr>' . "\n";
                    $k = 0;
                }
            }
            $s .= '</table></td><td>' . "\n";
            // DOMAINES
            $label_d = $labels->domaine;
            $expression = str_replace(get_string('domo', 'referentiel'), $label_d, get_string('domaines_oblig_seuil', 'referentiel'));
            $dom_th = str_replace('[', '<th colspan="2">', $expression);
            $dom_th = str_replace(']', '</th>', $dom_th);
            $s .= '<table class="domaine">
<tr>' . $dom_th . '</tr>' . "\n";
            $i = 0;
            $k = 0;
            $n = count($protocol_t_domaines_oblig);
            while ($i < $n) {
                $t_oblig = explode($separateur2, $protocol_t_domaines_oblig[$i]);
                $t_minima = explode($separateur2, $protocol_t_domaines_minima[$i]);
                $t_seuil = explode($separateur2, $protocol_t_domaines_seuil[$i]);
                $s .= '<tr valign="top"><td>' . $t_oblig[0] . '</td><td>';
                if (!empty($t_oblig[1])) {
                    $s .= '<i>' . get_string('yes') . '</i>';
                } else {
                    $s .= '<i>' . get_string('no') . '</i>';
                }
                $s .= '</td>';
                if ($t_minima[1] > 0) {
                    $s .= '<td class="green">';
                } else {
                    $s .= '<td>';
                }
                $s .= $t_minima[1] . "\n";
                $s .= '</td><td><i>' . $t_nb_competence_domaine[$i] . '</i>';
                $s .= '</td>';
                if ($t_seuil[1] > 0) {
                    $s .= '<td class="green">';
                } else {
                    $s .= '<td>';
                }
                $s .= $t_seuil[1] . "\n";
                $s .= '</td><td><i>' . $t_domaine_coeff[$i] . '</i>';
                $s .= '</td></tr>' . "\n";
                $i++;
                $k++;
                if ($k == $maxlig && $i < $n) {
                    $s .= '</table></td><td>' . "\n";
                    $s .= '<table class="domaine">
<tr valign="top">
<tr>' . $dom_th . '</tr>' . "\n";
                    $k = 0;
                }
            }
            $s .= '</table>
</td></tr>' . "\n";
            $s .= '</table>' . "\n";
            $s .= '</div>' . "\n";
        }
    }
    return $s;
}
示例#4
0
 function certificat_pourcentage($liste_code, $ref_referentiel)
 {
     // retourne les pourcentages par competence
     $separateur1 = '/';
     $separateur2 = ':';
     global $OK_REFERENTIEL_DATA;
     global $t_domaine;
     global $t_domaine_coeff;
     // COMPETENCES
     global $t_competence;
     global $t_competence_coeff;
     // ITEMS
     global $t_item_code;
     global $t_item_coeff;
     // coefficient poids determine par le modele de calcul (soit poids soit poids / empreinte)
     global $t_item_domaine;
     // index du domaine associé à un item
     global $t_item_competence;
     // index de la competence associée à un item
     global $t_item_poids;
     // poids
     global $t_item_empreinte;
     global $t_nb_item_domaine;
     global $t_nb_item_competence;
     $t_certif_item_valeur = array();
     // table des nombres d'items valides
     $t_certif_item_coeff = array();
     // somme des poids du domaine
     $t_certif_competence_poids = array();
     // somme des poids de la competence
     $t_certif_domaine_poids = array();
     // poids certifies
     for ($i = 0; $i < count($t_item_code); $i++) {
         $t_certif_item_valeur[$i] = 0.0;
         $t_certif_item_coeff[$i] = 0.0;
     }
     for ($i = 0; $i < count($t_competence); $i++) {
         $t_certif_competence_poids[$i] = 0.0;
     }
     for ($i = 0; $i < count($t_domaine); $i++) {
         $t_certif_domaine_poids[$i] = 0.0;
     }
     // affichage
     $s = '';
     // donnees globales du referentiel
     if ($ref_referentiel) {
         if (!isset($OK_REFERENTIEL_DATA) || $OK_REFERENTIEL_DATA == false) {
             $OK_REFERENTIEL_DATA = referentiel_initialise_data_referentiel($ref_referentiel);
         }
         if (isset($OK_REFERENTIEL_DATA) && $OK_REFERENTIEL_DATA == true) {
             // DEBUG
             // echo "<br />CODE <br />\n";
             // referentiel_affiche_data_referentiel($ref_referentiel, $params);
             // recuperer les items valides
             $tc = array();
             $liste_code = referentiel_purge_dernier_separateur($liste_code, $separateur1);
             // DEBUG
             // echo "<br />DEBUG :: print_lib_certificat.php :: 917 :: LISTE : $liste_code<br />\n";
             if (!empty($liste_code) && $separateur1 != "" && $separateur2 != "") {
                 $tc = explode($separateur1, $liste_code);
                 for ($i = 0; $i < count($t_item_domaine); $i++) {
                     $t_certif_domaine_poids[$i] = 0.0;
                 }
                 for ($i = 0; $i < count($t_item_competence); $i++) {
                     $t_certif_competence_poids[$i] = 0.0;
                 }
                 $i = 0;
                 while ($i < count($tc)) {
                     $t_cc = explode($separateur2, $tc[$i]);
                     // tableau des items valides
                     if (isset($t_cc[1])) {
                         if (isset($t_item_poids[$i]) && isset($t_item_empreinte[$i])) {
                             if ($t_item_poids[$i] > 0 && $t_item_empreinte[$i] > 0) {
                                 // echo "<br />".min($t_cc[1],$t_item_empreinte[$i]);
                                 $t_certif_item_valeur[$i] = min($t_cc[1], $t_item_empreinte[$i]);
                                 // calculer le taux
                                 $coeff = (double) $t_certif_item_valeur[$i] * (double) $t_item_coeff[$i];
                                 // stocker la valeur pour l'item
                                 $t_certif_item_coeff[$i] = $coeff;
                                 // stocker le taux pour la competence
                                 $t_certif_domaine_poids[$t_item_domaine[$i]] += $coeff;
                                 // stocker le taux pour le domaine
                                 $t_certif_competence_poids[$t_item_competence[$i]] += $coeff;
                             } else {
                                 // echo "<br />".min($t_cc[1],$t_item_empreinte[$i]);
                                 $t_certif_item_valeur[$i] = 0.0;
                                 $t_certif_item_coeff[$i] = 0.0;
                                 // $t_certif_domaine_poids[$t_item_domaine[$i]]+=0.0;
                                 // $t_certif_competence_poids[$t_item_competence[$i]]+=0.0;
                             }
                         }
                     }
                     $i++;
                 }
                 /*
                         	for ($i=0; $i<count($t_domaine_coeff); $i++){
                 				if ($t_domaine_coeff[$i]){
                 					$s.=$t_domaine[$i].';';
                 				}
                 				else{
                 					$s.=$t_domaine[$i].';';
                 				}
                 			}
                 			$s.="\n";
                 */
                 $s .= "<domaines>\n";
                 for ($i = 0; $i < count($t_domaine_coeff); $i++) {
                     $s .= '<domaine code="' . $t_domaine[$i] . '" pourcent=';
                     if ($t_domaine_coeff[$i]) {
                         $s .= '"' . referentiel_pourcentage($t_certif_domaine_poids[$i], $t_domaine_coeff[$i]) . '%" ';
                     } else {
                         $s .= '"0%" ';
                     }
                     $s .= "/>\n";
                 }
                 $s .= "</domaines>\n";
                 /*
                 for ($i=0; $i<count($t_competence); $i++){
                 		$s.=$t_competence[$i].';';
                 }
                 $s.="\n";
                 */
                 $s .= "<competences>\n";
                 for ($i = 0; $i < count($t_competence); $i++) {
                     $s .= '<competence code="' . $t_competence[$i] . '" pourcent=';
                     if ($t_competence_coeff[$i]) {
                         $s .= '"' . referentiel_pourcentage($t_certif_competence_poids[$i], $t_competence_coeff[$i]) . '%" ';
                     } else {
                         $s .= '"0%" ';
                     }
                     $s .= "/>\n";
                 }
                 $s .= "</competences>\n";
                 // ITEMS
                 /*
                 			for ($i=0; $i<count($t_item_code); $i++){
                 				if ($t_item_empreinte[$i]){
                 					if ($t_certif_item_valeur[$i]>=$t_item_empreinte[$i])
                 						$s.=$t_item_code[$i].';';
                 					else
                 						$s.=$t_item_code[$i].';';
                 				}
                 				else{
                 					$s.=';';
                 				}
                 			}
                 			$s.="\n";
                 */
                 $s .= "<items>\n";
                 for ($i = 0; $i < count($t_item_coeff); $i++) {
                     if ($t_item_empreinte[$i]) {
                         $s .= '<item code="' . $t_item_code[$i] . '" pourcent=';
                         if ($t_certif_item_valeur[$i] >= $t_item_empreinte[$i]) {
                             $s .= '"100%" ';
                         } else {
                             $s .= '"' . referentiel_pourcentage($t_certif_item_valeur[$i], $t_item_empreinte[$i]) . '%" ';
                         }
                         $s .= "/>\n";
                     }
                 }
                 $s .= "</items>\n";
             }
         }
     }
     return $s;
 }
function referentiel_print_liste_tasks($mode, $referentiel_instance, $userid_filtre = 0)
{
    global $CFG;
    global $USER;
    static $isteacher = false;
    static $isauthor = false;
    static $iseditor = false;
    static $referentiel_id = NULL;
    global $DB;
    if (!empty($referentiel_instance)) {
        $cm = get_coursemodule_from_instance('referentiel', $referentiel_instance->id);
        $course = $DB->get_record("course", array("id" => "{$cm->course}"));
        if (empty($cm) or empty($course)) {
            print_error('REFERENTIEL_ERROR 5 :: print_lib_task.php :: 568 :: You cannot call this script in that way');
        }
        $context = context_module::instance($cm->id);
        $records = array();
        $referentiel_id = $referentiel_instance->ref_referentiel;
        $isauthor = has_capability('mod/referentiel:addtask', $context);
        $isstudent = has_capability('mod/referentiel:selecttask', $context) && !$isauthor;
        $iseditor = has_capability('mod/referentiel:writereferentiel', $context);
        if (isset($referentiel_id) && $referentiel_id > 0) {
            $referentiel_referentiel = referentiel_get_referentiel_referentiel($referentiel_id);
            if (!$referentiel_referentiel) {
                if ($iseditor) {
                    print_error(get_string('creer_referentiel', 'referentiel'), "edit.php?d={$referentiel_instance->id}&amp;mode=editreferentiel&amp;sesskey=" . sesskey());
                } else {
                    print_error(get_string('creer_referentiel', 'referentiel'), "../../course/view.php?id={$course->id}&amp;sesskey=" . sesskey());
                }
            }
            // preparer les variables globales pour Overlib
            referentiel_initialise_data_referentiel($referentiel_referentiel->id);
            $record_tasks = referentiel_get_all_tasks($course->id, $referentiel_instance->id);
            // toutes les taches
            if ($record_tasks) {
                // Afficher
                if (isset($mode) && $mode == 'listtasksingle') {
                } else {
                    echo referentiel_print_entete_task();
                }
                $num = 0;
                foreach ($record_tasks as $record) {
                    // afficher les taches
                    if (!$record->tache_masquee || $isauthor) {
                        if (isset($mode) && $mode == 'listtasksingle') {
                            referentiel_print_task_detail($record, $context, 1, $num);
                            referentiel_menu_task_detail($context, $record->id, $referentiel_instance->id, $record->date_fin < time(), $record->tache_masquee);
                        } else {
                            if ($isstudent) {
                                echo referentiel_print_task($record, $context, $USER->id);
                            } else {
                                echo referentiel_print_task($record, $context);
                            }
                        }
                        $num++;
                    }
                }
                // Afficher
                if (isset($mode) && $mode == 'listtasksingle') {
                } else {
                    echo referentiel_print_enqueue_task();
                }
                echo '<br /><br />' . "\n";
            }
        }
    }
}
 function modifier_selection_codes_item_hierarchique($mform, $refrefid, $liste_saisie, $is_task = false, $id_activite = 0, $comportement = '')
 {
     // version locale
     // input : liste de code de la forme 'CODE''SEPARATEUR'
     // input : liste2 de code de la forme 'CODE''SEPARATEUR' codes declares
     // retourne le selecteur
     // DEBUG
     // echo "$liste_saisie<br />\n";
     global $OK_REFERENTIEL_DATA;
     global $t_domaine;
     global $t_domaine_coeff;
     global $t_domaine_description;
     // COMPETENCES
     global $t_competence;
     global $t_competence_coeff;
     global $t_competence_description;
     // ITEMS
     global $t_item_code;
     global $t_item_coeff;
     // coefficient poids determine par le modele de calcul (soit poids soit poids / empreinte)
     global $t_item_domaine;
     // index du domaine associe a un item
     global $t_item_competence;
     // index de la competence associee a un item
     global $t_item_poids;
     // poids
     global $t_item_empreinte;
     global $t_nb_item_domaine;
     global $t_nb_item_competence;
     global $t_item_description_competence;
     $separateur = '/';
     $nl = '';
     if ($id_activite == 0) {
         /*
                     $s1='<input type="checkbox" id="code_item_';
                     $s2='" name="code_item[]" value="';
                     $s3='"';
                     $s4=' />';
                     $s5='<label for="code_item_';
                     $s6='">';
                     $s7='</label> '."\n";
         */
         $id = 'code_item_';
         $name = 'code_item[]';
         $s5 = ' <label for="code_item_';
         $s6 = '">';
         $s7 = '</label> ' . "\n";
     } else {
         /*
                     $s1='<input type="checkbox" id="code_item_'.$id_activite.'_';
                     $s2='" name="code_item_'.$id_activite.'[]" value="';
                     $s3='"';
                     if (!empty($comportement)){
                         $s4=' '.$comportement.' />';
                     }
                     else{
                         $s4=' />';
                     }
                     $s5='<label for="code_item_'.$id_activite.'_';
         	   	    $s6='">';
         		    $s7='</label> '."\n";
         */
         $id = 'code_item_' . $id_activite . '_';
         $name = 'code_item_' . $id_activite . '[]';
         if (!empty($comportement)) {
             $s4 = ' ' . $comportement . ' />';
         } else {
             $s4 = ' />';
         }
         $s5 = ' <label for="code_item_' . $id_activite . '_';
         $s6 = '">';
         $s7 = '</label> ' . "\n";
     }
     $checked = ' checked="checked"';
     /*
     $tl=explode($separateur, $liste_complete);
     */
     if ($refrefid) {
         if (!isset($OK_REFERENTIEL_DATA) || $OK_REFERENTIEL_DATA == false) {
             $OK_REFERENTIEL_DATA = referentiel_initialise_data_referentiel($refrefid);
         }
         if (isset($OK_REFERENTIEL_DATA) && $OK_REFERENTIEL_DATA == true) {
             // DEBUG
             /*
             echo "<br />DEBUG :: input_activity_form.php :: 227\n";
             echo "<br /> T_ITEM_CODE<br />\n";
             print_object($t_item_code);
             */
             $tl = $t_item_code;
             $liste_saisie = strtr($liste_saisie, $separateur, ' ');
             $liste_saisie = trim(strtr($liste_saisie, '.', '_'));
             // echo "<br />DEBUG :: 201 :: $liste_saisie<br />\n";
             $ne = count($tl);
             $select = '';
             $index_code_domaine = $t_item_domaine[0];
             $code_domaine = $t_domaine[$index_code_domaine];
             $index_code_competence = $t_item_competence[0];
             $code_competence = $t_competence[$index_code_competence];
             $s = '&nbsp; &nbsp; &nbsp; <b>' . $code_domaine . '</b> : ' . $t_domaine_description[$index_code_domaine] . "\n";
             // ouvrir domaine
             $s .= '<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <i>' . $code_competence . '</i> : <span class="small">' . $t_competence_description[$index_code_competence] . '</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' . "\n";
             // ouvrir competence
             $mform->addElement('html', $s);
             $i = 0;
             while ($i < $ne) {
                 //echo $code_domaine.' '.$code_competence;
                 //echo $t_item_domaine[$i].' '.$t_item_competence[$i];
                 // domaine
                 if ($t_item_domaine[$i] != $index_code_domaine) {
                     $index_code_domaine = $t_item_domaine[$i];
                     $code_domaine = $t_domaine[$index_code_domaine];
                     // competence
                     $mform->addElement('html', '<br /> &nbsp; &nbsp; &nbsp; <b>' . $code_domaine . '</b> : ' . $t_domaine_description[$index_code_domaine] . "\n");
                     // nouveau domaine
                     // nouvelle competence
                     $index_code_competence = $t_item_competence[$i];
                     $code_competence = $t_competence[$index_code_competence];
                     $mform->addElement('html', '<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <i>' . $code_competence . '</i> : <span class="small">' . $t_competence_description[$index_code_competence] . '</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' . "\n");
                 }
                 // competence
                 if ($t_item_competence[$i] != $index_code_competence) {
                     $index_code_competence = $t_item_competence[$i];
                     $code_competence = $t_competence[$index_code_competence];
                     $mform->addElement('html', '<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <i>' . $code_competence . '</i> : <span class="small">' . $t_competence_description[$index_code_competence] . '</span><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' . "\n");
                 }
                 // item
                 $code = trim($tl[$i]);
                 $le_code = referentiel_affiche_overlib_un_item($separateur, $code);
                 if ($code != "") {
                     // $code_search='/'.strtr($code, '.', '_').'/';
                     // echo "RECHERCHE '$code_search' dans '$liste_saisie'<br />\n";
                     // echo "<br />DEBUG :: print_lib_activite :: 213 :: $code_search<br />\n";
                     // if (preg_match($code_search, $liste_saisie)){
                     $code_search = strtr($code, '.', '_');
                     // if (eregi($code_search, $liste_saisie)){
                     if (stristr($liste_saisie, $code_search)) {
                         /*
                         
                         				$s.= $s1.$i.$s2.$code.$s3.$checked.$s4.$s5.$i.$s6.$le_code.$s7;
                         */
                         $mform->addElement('checkbox', "code_item[]", $i, $s5 . $i . $s6 . $le_code . $s7);
                         $mform->setDefault("code_item[]", 1);
                         // checked
                     } else {
                         /*
                                     $id='code_item_'.$id_activite.'_';
                                     $name='code_item_'.$id_activite.'[]';
                                     if (!empty($comportement)){
                                         $s4=' '.$comportement.' />';
                                     }
                                     else{
                                         $s4=' />';
                                     }
                                     $s5='<label for="code_item_'.$id_activite.'_';
                         	   	    $s6='">';
                         		    $s7='</label> '."\n";
                         */
                         if (!$is_task) {
                             //$s.=$s1.$i.$s2.$code.$s3.$s4.$s5.$i.$s6.$le_code.$s7;
                             $mform->addElement('checkbox', "code_item[]", $i, $s5 . $i . $s6 . $le_code . $s7);
                             $mform->setDefault("code_item[]", 0);
                             // unchecked
                         } else {
                             //$s.=' &nbsp; '. $s5.$i.$s6.$le_code.$s7;
                             $mform->addElement('checkbox', "code_item[]", $i, $s5 . $i . $s6 . $le_code . $s7);
                             $mform->setDefault("code_item[]", 0);
                             // unchecked
                         }
                     }
                 }
                 $i++;
             }
         }
     }
 }
示例#7
0
function referentiel_affiche_data_referentiel($referentiel_referentiel_id, $params = NULL)
{
    //
    global $OK_REFERENTIEL_DATA;
    global $t_domaine;
    global $t_domaine_coeff;
    // COMPETENCES
    global $t_competence;
    global $t_competence_coeff;
    // ITEMS
    global $t_item_code;
    global $t_item_description_competence;
    global $t_item_coeff;
    // poids / empreinte
    global $t_item_domaine;
    // index du domaine associé à un item
    global $t_item_competence;
    // index de la competence associée à un item
    if (!isset($OK_REFERENTIEL_DATA) || $OK_REFERENTIEL_DATA == false) {
        $OK_REFERENTIEL_DATA = referentiel_initialise_data_referentiel($referentiel_referentiel_id);
    }
    if (isset($OK_REFERENTIEL_DATA) && $OK_REFERENTIEL_DATA == true) {
        $label_d = "";
        $label_c = "";
        $label_i = "";
        if (isset($params) && !empty($params)) {
            if (isset($params->label_domaine)) {
                $label_d = $params->label_domaine;
            }
            if (isset($params->label_competence)) {
                $label_c = $params->label_competence;
            }
            if (isset($params->label_item)) {
                $label_i = $params->label_item;
            }
        }
        // affichage
        // DOMAINES
        echo "<br />DOMAINES<br />\n";
        if (!empty($label_d)) {
            p($label_d);
        } else {
            p(get_string('domaine', 'referentiel'));
        }
        echo '<br />' . "\n";
        referentiel_affiche_tableau_1d($t_domaine);
        echo "<br />DOMAINES COEFF\n";
        referentiel_affiche_tableau_1d($t_domaine_coeff);
        echo "<br />COMPETENCES\n";
        if (!empty($label_c)) {
            p($label_c);
        } else {
            p(get_string('competence', 'referentiel'));
        }
        echo '<br />' . "\n";
        referentiel_affiche_tableau_1d($t_competence);
        echo "<br />COMPETENCES COEFF\n";
        referentiel_affiche_tableau_1d($t_competence_coeff);
        // ITEMS
        echo "<br />ITEMS\n";
        if (!empty($label_i)) {
            p($label_i);
        } else {
            p(get_string('item_competence', 'referentiel'));
        }
        echo '<br />' . "\n";
        echo "<br />CODES ITEM\n";
        referentiel_affiche_tableau_1d($t_item_code);
        echo "<br />DESCRIPTION ITEM\n";
        referentiel_affiche_tableau($t_item_description_competence);
        echo "<br />COMPETENCES COEFF\n";
        referentiel_affiche_tableau_1d($t_item_coeff);
        echo "<br />POIDS ITEM\n";
        referentiel_affiche_tableau_1d($t_item_poids);
        echo "<br />EMPREINTES ITEM\n";
        referentiel_affiche_tableau_1d($t_item_empreinte);
    }
}
示例#8
0
 function affiche_certificat_consolide($separateur1, $separateur2, $liste_code, $ref_referentiel, $bgcolor, $params = NULL)
 {
     // ce certificat comporte des pourcentages par domaine et competence
     global $OK_REFERENTIEL_DATA;
     global $t_domaine;
     global $t_domaine_coeff;
     // COMPETENCES
     global $t_competence;
     global $t_competence_coeff;
     // ITEMS
     global $t_item_code;
     global $t_item_coeff;
     // coefficient poids determeine par le modele de calcul (soit poids soit poids / empreinte)
     global $t_item_domaine;
     // index du domaine associ� � un item
     global $t_item_competence;
     // index de la competence associ�e � un item
     global $t_item_poids;
     // poids
     global $t_item_empreinte;
     global $t_nb_item_domaine;
     global $t_nb_item_competence;
     // nom des domaines, comp�tences, items
     $label_d = "";
     $label_c = "";
     $label_i = "";
     if (isset($params) && !empty($params)) {
         if (isset($params->label_domaine)) {
             $label_d = $params->label_domaine;
         }
         if (isset($params->label_competence)) {
             $label_c = $params->label_competence;
         }
         if (isset($params->label_item)) {
             $label_i = $params->label_item;
         }
     }
     $t_certif_item_valeur = array();
     // table des nombres d'items valides
     $t_certif_item_coeff = array();
     // somme des poids du domaine
     $t_certif_competence_poids = array();
     // somme des poids de la competence
     $t_certif_domaine_poids = array();
     // poids certifies
     for ($i = 0; $i < count($t_item_code); $i++) {
         $t_certif_item_valeur[$i] = 0.0;
         $t_certif_item_coeff[$i] = 0.0;
     }
     for ($i = 0; $i < count($t_competence); $i++) {
         $t_certif_competence_poids[$i] = 0.0;
     }
     for ($i = 0; $i < count($t_domaine); $i++) {
         $t_certif_domaine_poids[$i] = 0.0;
     }
     // affichage
     $s = '';
     // donnees globales du referentiel
     if ($ref_referentiel) {
         if (!isset($OK_REFERENTIEL_DATA) || $OK_REFERENTIEL_DATA == false) {
             $OK_REFERENTIEL_DATA = referentiel_initialise_data_referentiel($ref_referentiel);
         }
         if (isset($OK_REFERENTIEL_DATA) && $OK_REFERENTIEL_DATA == true) {
             // DEBUG
             // echo "<br />CODE <br />\n";
             // referentiel_affiche_data_referentiel($ref_referentiel, $params);
             // recuperer les items valides
             $tc = array();
             $liste_code = referentiel_purge_dernier_separateur($liste_code, $separateur1);
             // DEBUG
             // echo "<br />DEBUG :: print_lib_certificat.php :: 917 :: LISTE : $liste_code<br />\n";
             if (!empty($liste_code) && $separateur1 != "" && $separateur2 != "") {
                 $tc = explode($separateur1, $liste_code);
                 // DEBUG
                 /*
                 echo "<br />DEBUG print_lib_certificat_.php :: Ligne 1090 <br />LISTE DECOMPOSEE CODE :: $liste_code<br />\n";
                 print_r($tc);
                 echo "<br />POIDS<br />\n";
                 print_r($t_item_poids);
                 echo "<br />EMPREINTES<br />\n";
                 print_r($t_item_empreinte);
                 echo "<br /><br />\n";
                 
                 echo "<br />INNDEX DOMAINES<br />\n";
                 print_r($t_item_domaine);
                 echo "<br />INDEX COMPETENCE<br />\n";
                 print_r($t_item_competence);
                 // exit;
                 */
                 for ($i = 0; $i < count($t_item_domaine); $i++) {
                     $t_certif_domaine_poids[$i] = 0.0;
                 }
                 for ($i = 0; $i < count($t_item_competence); $i++) {
                     $t_certif_competence_poids[$i] = 0.0;
                 }
                 $i = 0;
                 while ($i < count($tc)) {
                     // CODE1:N1
                     // DEBUG
                     // echo "<br />".$tc[$i]." <br />\n";
                     // exit;
                     $t_cc = explode($separateur2, $tc[$i]);
                     // tableau des items valides
                     // print_r($t_cc);
                     // echo "<br />\n";
                     // exit;
                     if (isset($t_cc[1])) {
                         if (isset($t_item_poids[$i]) && isset($t_item_empreinte[$i])) {
                             if ($t_item_poids[$i] > 0 && $t_item_empreinte[$i] > 0) {
                                 // echo "<br />".min($t_cc[1],$t_item_empreinte[$i]);
                                 $t_certif_item_valeur[$i] = min($t_cc[1], $t_item_empreinte[$i]);
                                 // calculer le taux
                                 $coeff = (double) $t_certif_item_valeur[$i] * (double) $t_item_coeff[$i];
                                 // stocker la valeur pour l'item
                                 $t_certif_item_coeff[$i] = $coeff;
                                 // stocker le taux pour la competence
                                 $t_certif_domaine_poids[$t_item_domaine[$i]] += $coeff;
                                 // stocker le taux pour le domaine
                                 $t_certif_competence_poids[$t_item_competence[$i]] += $coeff;
                             } else {
                                 // echo "<br />".min($t_cc[1],$t_item_empreinte[$i]);
                                 $t_certif_item_valeur[$i] = 0.0;
                                 $t_certif_item_coeff[$i] = 0.0;
                                 // $t_certif_domaine_poids[$t_item_domaine[$i]]+=0.0;
                                 // $t_certif_competence_poids[$t_item_competence[$i]]+=0.0;
                             }
                         }
                     }
                     $i++;
                 }
                 // DEBUG
                 /*
                 echo "<br />DEBUG :: Ligne :: 1107<br />\n";
                 echo "<br />Liste des items valides <br />\n";
                 print_r($t_certif_item_valeur);
                 echo "<br />Taux : poids / empreinte<br />\n";
                 print_r($t_certif_item_coeff);
                 echo "<br /><br />\n";
                 print_r($t_certif_domaine_poids);
                 echo "<br /><br />\n";
                 print_r($t_certif_competence_poids);
                 exit;
                 */
                 // DOMAINES
                 // $s.= '<table width="100%" cellspacing="0" cellpadding="2"><tr valign="top" >'."\n";
                 // if (!empty($label_d)){
                 //	$s.='<td  width="5%">'.$label_d.'</td>';
                 //}
                 // else {
                 //	$s.='<td $t_certif_item_coeff width="5%">'.get_string('domaine','referentiel').'</td>';
                 //}
                 for ($i = 0; $i < count($t_domaine_coeff); $i++) {
                     if ($t_domaine_coeff[$i]) {
                         $s .= $t_domaine[$i] . ';';
                     } else {
                         $s .= $t_domaine[$i] . ';';
                     }
                 }
                 $s .= "\n";
                 for ($i = 0; $i < count($t_domaine_coeff); $i++) {
                     if ($t_domaine_coeff[$i]) {
                         $s .= referentiel_pourcentage($t_certif_domaine_poids[$i], $t_domaine_coeff[$i]) . '%;';
                     } else {
                         $s .= '0%;';
                     }
                 }
                 $s .= "\n";
                 /*
                 if (!empty($label_c)){
                 	$s.='<td  width="5%">'.$label_c.'</td>'."\n";
                 }
                 else {
                 	$s.='<td  width="5%">'.get_string('competence','referentiel').'</td>'."\n";
                 }
                 */
                 for ($i = 0; $i < count($t_competence); $i++) {
                     if ($t_competence_coeff[$i]) {
                         $s .= $t_competence[$i] . ';';
                     } else {
                         $s .= $t_competence[$i] . ';';
                     }
                 }
                 $s .= "\n";
                 for ($i = 0; $i < count($t_competence); $i++) {
                     if ($t_competence_coeff[$i]) {
                         $s .= referentiel_pourcentage($t_certif_competence_poids[$i], $t_competence_coeff[$i]) . '%;';
                     } else {
                         $s .= '0%;';
                     }
                 }
                 $s .= "\n";
                 // ITEMS
                 // $s.= '<tr valign="top" >'."\n";
                 /*
                 if (!empty($label_i)){
                 	$s.='<td  width="5%">'.$label_i.'</td>'."\n";
                 }
                 else {
                 	$s.='<td  width="5%">'.get_string('item','referentiel').'</td>'."\n";
                 }
                 */
                 for ($i = 0; $i < count($t_item_code); $i++) {
                     if ($t_item_empreinte[$i]) {
                         if ($t_certif_item_valeur[$i] >= $t_item_empreinte[$i]) {
                             $s .= $t_item_code[$i] . ';';
                         } else {
                             $s .= $t_item_code[$i] . ';';
                         }
                     } else {
                         $s .= ';';
                     }
                 }
                 $s .= "\n";
                 // <td  width="5%">'.get_string('coeff','referentiel').'</td>'."\n";
                 for ($i = 0; $i < count($t_item_coeff); $i++) {
                     if ($t_item_empreinte[$i]) {
                         if ($t_certif_item_valeur[$i] >= $t_item_empreinte[$i]) {
                             $s .= '100%;';
                         } else {
                             $s .= referentiel_pourcentage($t_certif_item_valeur[$i], $t_item_empreinte[$i]) . '%;';
                         }
                     } else {
                         $s .= ';';
                     }
                 }
                 $s .= "\n";
                 /* 
                 			$s.='</tr><tr valign="top">'."\n";
                 			$s.='<td  width="5%">'.get_string('item_poids','referentiel').'</td>';
                 			for ($i=0; $i<count($t_item_poids); $i++){
                 				$s.='<td >'.$t_item_poids[$i].'</td>';
                 			}
                 			$s.='</tr><tr valign="top">'."\n";
                 			$s.='<td  width="5%">'.get_string('item_empreinte','referentiel').'</td>';		
                 			for ($i=0; $i<count($t_item_empreinte); $i++){
                 				$s.='<td >'.$t_item_empreinte[$i].'</td>';
                 			}
                 */
                 $s .= "\n";
             }
         }
     }
     return $s;
 }
/**
 * Function set thresholds for an occurrence
 *
 * @param refrefid reference referentiel_referentiel id
 * @return string
 * A.1:0/A.2:0/A.3:0/B.1:0/B.2:0/
 * @todo Finish documenting this function
**/
function referentiel_certificat_valide($competences_certificat, $refrefid)
{
    // ce certificat comporte des pourcentages par domaine et competence
    // affichage sous forme de tableau et span pour les items
    // input competences_certificat
    // A.1-1:0/A.1-2:0/A.1-3:1/A.1-4:0/A.1-5:0/A.2-1:0/A.2-2:0/A.2-3:0/A.3-1:0/A.3-2:1/A.3-3:1/A.3-4:1/B.1-1:0/B.1-2:0/B.1-3:0/B.2-1:0/B.2-2:0/B.2-3:0/B.2-4:0/B.2-5:0/B.3-1:0/B.3-2:0/B.3-3:0/B.3-4:0/B.3-5:0/B.4-1:0/B.4-2:0/B.4-3:0/
    $return_value = -1;
    global $OK_REFERENTIEL_DATA;
    // les données du certificat sont disponibles
    global $OK_REFERENTIEL_PROTOCOLE;
    // les données du protocole sont disponibles
    // DOMAINES
    global $t_domaine;
    global $t_domaine_coeff;
    // COMPETENCES
    global $t_competence;
    global $t_competence_coeff;
    // ITEMS
    global $t_item_code;
    global $t_item_coeff;
    // coefficient poids determine par le modele de calcul (soit poids soit poids / empreinte)
    global $t_item_domaine;
    // index du domaine associe a un item
    global $t_item_competence;
    // index de la competence associee a un item
    global $t_item_poids;
    // poids
    global $t_item_empreinte;
    global $t_nb_item_domaine;
    global $t_nb_item_competence;
    // MODIF JF 2012/03/26
    global $t_competence_domaine;
    // index du domaine associe a une competence
    global $t_nb_competence_domaine;
    // nombre de competence par domaine
    // tables de protocoles (seuils, item obligatoires, etc.
    global $protocol_seuil_referentiel;
    global $protocol_minima_referentiel;
    global $protocol_t_domaines_oblig;
    global $protocol_t_domaines_seuil;
    global $protocol_t_domaines_minima;
    global $protocol_t_competences_oblig;
    global $protocol_t_competences_seuil;
    global $protocol_t_competences_minima;
    global $protocol_t_items_oblig;
    global $protocol_timemodified;
    global $protocol_actif;
    $separateur1 = '/';
    $separateur2 = ':';
    $nb_items_valides = 0;
    // items valides
    $t_certif_item_valeur = array();
    // table des nombres d'items valides
    $t_certif_item_coeff = array();
    // somme des poids du domaine
    $t_certif_competence_poids = array();
    // somme des poids de la competence
    $t_certif_domaine_poids = array();
    // poids certifies
    // MODIF JF 2012/03/26
    $t_certif_competences_valides = array();
    // nombre de competences valides
    $t_certif_domaines_valides = array();
    // nombre de domaines valides
    // donnees globales du referentiel
    if ($refrefid) {
        if (!isset($OK_REFERENTIEL_DATA) || $OK_REFERENTIEL_DATA == false) {
            $OK_REFERENTIEL_DATA = referentiel_initialise_data_referentiel($refrefid);
        }
        if (!isset($OK_REFERENTIEL_PROTOCOLE) || $OK_REFERENTIEL_PROTOCOLE == false) {
            $OK_REFERENTIEL_PROTOCOLE = referentiel_initialise_protocole_referentiel($refrefid);
        }
        if (isset($OK_REFERENTIEL_DATA) && $OK_REFERENTIEL_DATA == true && isset($OK_REFERENTIEL_PROTOCOLE) && $OK_REFERENTIEL_PROTOCOLE == true) {
            // DEBUG
            /*
            echo "<br />DEBUG:: lib_protocol.php :: 318 :: PROTOCOL VARIABLES<br />\n";
            echo "SEUIL : $protocol_seuil_referentiel<br />\n";
            echo "<br />DOMAINES OBLIG<br />\n";
            print_object($protocol_t_domaines_oblig);
            echo "<br />DOMAINES SEUILS<br />\n";
            print_object($protocol_t_domaines_seuil);
            echo "<br />DOMAINES MINIMAS<br />\n";
            print_object($protocol_t_domaines_minima);
            echo "<br />COMPETENCES OBLIG<br />\n";
            print_object($protocol_t_competences_oblig);
            echo "<br />COMPETENCES SEUILS<br />\n";
            print_object($protocol_t_competences_seuil);
            echo "<br />COMPETENCES MINIMAS<br />\n";
            print_object($protocol_t_competences_minima);
            echo "<br />ITEMS OBLIG<br />\n";
            print_object($protocol_t_items_oblig);
            */
            if ($protocol_actif) {
                // Initialisation
                for ($i = 0; $i < count($t_item_code); $i++) {
                    $t_certif_item_valeur[$i] = 0.0;
                    $t_certif_item_coeff[$i] = 0.0;
                }
                for ($i = 0; $i < count($t_competence); $i++) {
                    $t_certif_competence_poids[$i] = 0.0;
                    $t_certif_competences_valides[$i] = 0;
                }
                for ($i = 0; $i < count($t_domaine); $i++) {
                    $t_certif_domaine_poids[$i] = 0.0;
                    $t_certif_domaines_valides[$i] = 0;
                }
                // RECUPERER les pourcentages par competence et domaine
                // en fonction des items valides dans le certificat
                // DEBUG
                // echo "<br />DEBUG :: lib_protocole.php :: 329 :: CODE <br />\n";
                // referentiel_affiche_data_referentiel($refrefid, NULL);
                // recuperer les items valides
                $tc = array();
                $liste_code = referentiel_purge_dernier_separateur($competences_certificat, $separateur1);
                // DEBUG
                // echo "<br />DEBUG :: lib_protocole.php :: 383 :: LISTE : $liste_code<br />\n";
                if (!empty($liste_code) && $separateur1 != "" && $separateur2 != "") {
                    $tc = explode($separateur1, $liste_code);
                    for ($i = 0; $i < count($t_item_domaine); $i++) {
                        $t_certif_domaine_poids[$i] = 0.0;
                    }
                    for ($i = 0; $i < count($t_item_competence); $i++) {
                        $t_certif_competence_poids[$i] = 0.0;
                    }
                    $i = 0;
                    while ($i < count($tc)) {
                        // CODE1:N1
                        // DEBUG
                        // echo "<br />".$tc[$i]." <br />\n";
                        // exit;
                        $t_cc = explode($separateur2, $tc[$i]);
                        // tableau des items valides
                        // print_r($t_cc);
                        // echo "<br />\n";
                        // exit;
                        if (isset($t_cc[1])) {
                            if (isset($t_item_poids[$i]) && isset($t_item_empreinte[$i])) {
                                if ($t_item_poids[$i] > 0 && $t_item_empreinte[$i] > 0) {
                                    // echo "<br />".min($t_cc[1],$t_item_empreinte[$i]);
                                    $t_certif_item_valeur[$i] = min($t_cc[1], $t_item_empreinte[$i]);
                                    // calculer le taux
                                    $coeff = (double) $t_certif_item_valeur[$i] * (double) $t_item_coeff[$i];
                                    // stocker la valeur pour l'item
                                    $t_certif_item_coeff[$i] = $coeff;
                                    // stocker le taux pour la competence
                                    $t_certif_competence_poids[$t_item_competence[$i]] += $coeff;
                                    // stocker le taux pour le domaine
                                    $t_certif_domaine_poids[$t_item_domaine[$i]] += $coeff;
                                    if ($t_certif_item_valeur[$i] >= $t_item_empreinte[$i]) {
                                        $t_certif_competences_valides[$t_item_competence[$i]]++;
                                        $nb_items_valides++;
                                    }
                                } else {
                                    // echo "<br />".min($t_cc[1],$t_item_empreinte[$i]);
                                    $t_certif_item_valeur[$i] = 0.0;
                                    $t_certif_item_coeff[$i] = 0.0;
                                }
                            }
                        }
                        $i++;
                    }
                    /* DOMAINES */
                    // mettre a jour les minimas
                    // compter les competences valides par domaine
                    for ($i = 0; $i < count($t_competence); $i++) {
                        if (isset($t_certif_competences_valides[$t_competence_domaine[$i]])) {
                            $t_certif_domaines_valides[$t_competence_domaine[$i]]++;
                        }
                    }
                    // Verifier si le certificat est valide
                    // Calculer la valeur des items valides
                    $valeur_items_valides = 0.0;
                    for ($i = 0; $i < count($t_certif_item_coeff); $i++) {
                        $valeur_items_valides += $t_certif_item_coeff[$i];
                    }
                    // Vérifier si les minimas sont depassés
                    $ok_minima_competence = true;
                    $ok_minima_domaine = true;
                    // Verifier si le seuil est depassé
                    $ok_seuil = true;
                    $ok_competences = true;
                    $ok_domaines = true;
                    $ok_items = true;
                    // $ok_items=true;   echo "<br />DEBUG:: lib_protocol.php :: 413 :: DEBUG FORCER le test du PROTOCOLE\n";
                    //$ok_items=($protocol_seuil_referentiel>0) && ($nb_items_valides>=$protocol_seuil_referentiel);
                    if ($protocol_seuil_referentiel > 0) {
                        $ok_seuil = $valeur_items_valides >= $protocol_seuil_referentiel;
                    }
                    if ($ok_seuil) {
                        $ok_seuil = $nb_items_valides >= $protocol_minima_referentiel;
                    }
                    // 1) Verifier si tous les items obligatoires sont valides
                    $ok_items = true;
                    if ($ok_items) {
                        $i = 0;
                        while ($i < count($protocol_t_items_oblig) && $ok_items) {
                            $t_oblig = explode($separateur2, $protocol_t_items_oblig[$i]);
                            // echo "<br />ITEM_OBLIG<br />\n";
                            // print_r($t_oblig);
                            if (isset($t_oblig[1])) {
                                if ($t_item_poids[$i] > 0 && $t_item_empreinte[$i] > 0 && $t_oblig[1] > 0) {
                                    $ok_items = $ok_items && $t_certif_item_valeur[$i] >= $t_item_empreinte[$i];
                                }
                            }
                            $i++;
                        }
                    }
                    // 2) Verifier les competences obligatoires
                    $ok_competences_oblig = true;
                    $i = 0;
                    while ($i < count($protocol_t_competences_oblig) && $ok_competences_oblig) {
                        $t_oblig = explode($separateur2, $protocol_t_competences_oblig[$i]);
                        $t_seuil = explode($separateur2, $protocol_t_competences_seuil[$i]);
                        //echo "<br />COMPETENCES_OBLIGS<br />\n";
                        //print_r($t_oblig);
                        //echo "<br />COMPETENCES_SEUILS<br />\n";
                        //print_r($t_seuil);
                        if (isset($t_oblig[1]) && $t_oblig[1] > 0 && isset($t_seuil[1])) {
                            $ok_competences_oblig = $ok_competences_oblig && $t_certif_competence_poids[$i] >= $t_seuil[1];
                        }
                        $i++;
                    }
                    // MODIF JF 2012/03/26
                    // 3) Puis verifier les competences par rapport aux minimas
                    // cela est utile si aucune compétence n'est obligatoire mais qu'il y a une contrainte du style
                    // pas plus de n items invalides par compétence
                    $ok_competences = $ok_competences_oblig;
                    if ($ok_competences) {
                        $i = 0;
                        while ($i < count($protocol_t_competences_seuil) && $ok_competences) {
                            $t_minima = explode($separateur2, $protocol_t_competences_minima[$i]);
                            if (isset($t_minima[1])) {
                                $ok_competences = $ok_competences && $t_certif_competences_valides[$i] >= $t_minima[1];
                            }
                            $i++;
                        }
                    }
                    // 4) Puis verifier les competences par rapport aux seuils
                    // cela est utile si aucune compétence n'est obligatoire mais qu'il y a une contrainte du style
                    // la somme ponderees de items suerieure au seuil de la competence
                    if ($ok_competences) {
                        $i = 0;
                        while ($i < count($protocol_t_competences_seuil) && $ok_competences) {
                            $t_seuil = explode($separateur2, $protocol_t_competences_seuil[$i]);
                            if (isset($t_seuil[1])) {
                                $ok_competences = $ok_competences && $t_certif_competence_poids[$i] >= $t_seuil[1];
                            }
                            $i++;
                        }
                    }
                    // 5) verifier les domaines
                    // if ($ok_competences_oblig){
                    // Verifier les domaines obligatoire par rapport aux seuils
                    $ok_domaines_oblig = true;
                    $i = 0;
                    while ($i < count($protocol_t_domaines_oblig) && $ok_domaines_oblig) {
                        $t_oblig = explode($separateur2, $protocol_t_domaines_oblig[$i]);
                        $t_seuil = explode($separateur2, $protocol_t_domaines_seuil[$i]);
                        //echo "<br />DOMAINES_OBLIGS<br />\n";
                        //print_r($t_oblig);
                        //echo "<br />DOMAINES_SEUILS<br />\n";
                        //print_r($t_seuil);
                        if (isset($t_oblig[1]) && $t_oblig[1] > 0 && isset($t_seuil[1])) {
                            $ok_domaines_oblig = $ok_domaines_oblig && $t_certif_domaine_poids[$i] >= $t_seuil[1];
                        }
                        $i++;
                    }
                    $ok_domaines = $ok_domaines_oblig;
                    // 6) Verifier les domaines par rapport aux minimas
                    // Cela est utile si aucun domaine n'est obligatoire mais qu'il y a une contrainte du style
                    // pas plus de n competences invalides par domaine
                    $ok_domaines = $ok_domaines_oblig;
                    if ($ok_domaines) {
                        $i = 0;
                        while ($i < count($protocol_t_domaines_seuil) && $ok_domaines) {
                            $t_minima = explode($separateur2, $protocol_t_domaines_minima[$i]);
                            if (isset($t_minima[1])) {
                                $ok_domaines = $ok_domaines && $t_certif_domaines_valides[$i] >= $t_minima[1];
                            }
                            $i++;
                        }
                    }
                    // 7) Verifier les domaines par rapport aux les seuils
                    // Cela est utile si aucun domaine n'est obligatoire mais qu'il y a une contrainte du style
                    // pas moins de x pourcentage par rapport au seuil du domaine
                    if ($ok_domaines) {
                        $i = 0;
                        while ($i < count($protocol_t_domaines_seuil) && $ok_domaines) {
                            $t_seuil = explode($separateur2, $protocol_t_domaines_seuil[$i]);
                            if (isset($t_seuil[1])) {
                                $ok_domaines = $ok_domaines && $t_certif_domaine_poids[$i] >= $t_seuil[1];
                            }
                            $i++;
                        }
                    }
                    // DEBUG
                    /*
                    echo "<br />DEBUG :: lib_protocole.php :: 531\n";
                    if ($ok_items) {echo "<br />ITEMS : TRUE";} else {echo "<br />ITEMS : FALSE";}
                    if ($ok_competences) {echo "<br />COMPETENCE: TRUE";} else {echo "<br />COMPETENCE: FALSE";}
                    if ($ok_domaines) {echo "<br />DOMAINE: TRUE";} else {echo "<br />DOMAINE: FALSE";}
                    */
                    if ($ok_seuil && $ok_items && $ok_competences && $ok_domaines) {
                        $return_value = 1;
                    } else {
                        $return_value = 0;
                    }
                }
            }
        }
    }
    return $return_value;
}
            }
            if (!isset($form->modulename)) {
                $form->modulename = 'referentiel';
            }
            // Charger les taches
            // filtres
            $isauthor = has_capability('mod/referentiel:addtask', $context);
            $iseditor = has_capability('mod/referentiel:writereferentiel', $context);
            $liste_codes_competence = referentiel_get_liste_codes_competence($referentiel_referentiel->id);
            $records_task = referentiel_get_all_tasks($course->id, $referentiel->id);
            if ($records_task) {
                // DEBUG
                // echo "<br/>DEBUG ::<br />\n";
                // print_object($records_task);
                // preparer les variables globales pour Overlib
                referentiel_initialise_data_referentiel($referentiel_referentiel->id);
                echo "\n" . '<link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css" media="screen"></link>
<script type="text/javascript" src="dhtmlgoodies_calendar.js"></script>' . "\n";
                foreach ($records_task as $record_t) {
                    $taskid = $record_t->id;
                    $type_task = stripslashes($record_t->type_task);
                    $description_task = stripslashes($record_t->description_task);
                    $competences_task = stripslashes($record_t->competences_task);
                    $criteres_evaluation = stripslashes($record_t->criteres_evaluation);
                    $ref_instance = $record_t->ref_instance;
                    $ref_referentiel = $record_t->ref_referentiel;
                    $ref_course = $record_t->ref_course;
                    $auteurid = $record_t->auteurid;
                    $date_creation = $record_t->date_creation;
                    $date_modif = $record_t->date_modif;
                    $souscription_libre = $record_t->souscription_libre;
function ooffice_referentiel_affiche_certificat_consolide($ref_referentiel, $separateur1, $separateur2, $liste_code, $font1 = 10, $font2 = 9, $font3 = 8, $params = NULL)
{
    // ce certificat comporte des pourcentages par domaine et competence
    // decalque de referentiel_affiche_certificat_consolide() de lib.php
    global $odt;
    global $OK_REFERENTIEL_DATA;
    global $t_domaine;
    global $t_domaine_coeff;
    // COMPETENCES
    global $t_competence;
    global $t_competence_coeff;
    // ITEMS
    global $t_item_code;
    global $t_item_coeff;
    // coefficient poids determeine par le modele de calcul (soit poids soit poids / empreinte)
    global $t_item_domaine;
    // index du domaine associ� � un item
    global $t_item_competence;
    // index de la competence associ�e � un item
    global $t_item_poids;
    // poids
    global $t_item_empreinte;
    global $t_nb_item_domaine;
    global $t_nb_item_competence;
    // nom des domaines, comp�tences, items
    $label_d = "";
    $label_c = "";
    $label_i = "";
    if (isset($params) && !empty($params)) {
        if (isset($params->label_domaine)) {
            $label_d = $params->label_domaine;
        }
        if (isset($params->label_competence)) {
            $label_c = $params->label_competence;
        }
        if (isset($params->label_item)) {
            $label_i = $params->label_item;
        }
    }
    $t_certif_item_valeur = array();
    // table des nombres d'items valides
    $t_certif_item_coeff = array();
    // somme des poids du domaine
    $t_certif_competence_poids = array();
    // somme des poids de la competence
    $t_certif_domaine_poids = array();
    // poids certifies
    for ($i = 0; $i < count($t_item_code); $i++) {
        $t_certif_item_valeur[$i] = 0.0;
        $t_certif_item_coeff[$i] = 0.0;
    }
    for ($i = 0; $i < count($t_competence); $i++) {
        $t_certif_competence_poids[$i] = 0.0;
    }
    for ($i = 0; $i < count($t_domaine); $i++) {
        $t_certif_domaine_poids[$i] = 0.0;
    }
    // affichage
    $s = '';
    // donnees globales du referentiel
    if ($ref_referentiel) {
        if (!isset($OK_REFERENTIEL_DATA) || $OK_REFERENTIEL_DATA == false) {
            $OK_REFERENTIEL_DATA = referentiel_initialise_data_referentiel($ref_referentiel);
        }
        if (isset($OK_REFERENTIEL_DATA) && $OK_REFERENTIEL_DATA == true) {
            // recuperer les items valides
            $tc = array();
            $liste_code = referentiel_purge_dernier_separateur($liste_code, $separateur1);
            if (!empty($liste_code) && $separateur1 != "" && $separateur2 != "") {
                $tc = explode($separateur1, $liste_code);
                for ($i = 0; $i < count($t_item_domaine); $i++) {
                    $t_certif_domaine_poids[$i] = 0.0;
                }
                for ($i = 0; $i < count($t_item_competence); $i++) {
                    $t_certif_competence_poids[$i] = 0.0;
                }
                $i = 0;
                while ($i < count($tc)) {
                    $t_cc = explode($separateur2, $tc[$i]);
                    // tableau des items valides
                    if (isset($t_cc[1])) {
                        if (isset($t_item_poids[$i]) && isset($t_item_empreinte[$i])) {
                            if ($t_item_poids[$i] > 0 && $t_item_empreinte[$i] > 0) {
                                // echo "<br />".min($t_cc[1],$t_item_empreinte[$i]);
                                $t_certif_item_valeur[$i] = min($t_cc[1], $t_item_empreinte[$i]);
                                // calculer le taux
                                $coeff = (double) $t_certif_item_valeur[$i] * (double) $t_item_coeff[$i];
                                // stocker la valeur pour l'item
                                $t_certif_item_coeff[$i] = $coeff;
                                // stocker le taux pour la competence
                                $t_certif_domaine_poids[$t_item_domaine[$i]] += $coeff;
                                // stocker le taux pour le domaine
                                $t_certif_competence_poids[$t_item_competence[$i]] += $coeff;
                            } else {
                                // echo "<br />".min($t_cc[1],$t_item_empreinte[$i]);
                                $t_certif_item_valeur[$i] = 0.0;
                                $t_certif_item_coeff[$i] = 0.0;
                                // $t_certif_domaine_poids[$t_item_domaine[$i]]+=0.0;
                                // $t_certif_competence_poids[$t_item_competence[$i]]+=0.0;
                            }
                        }
                    }
                    $i++;
                }
                // Affichage
                // DOMAINES
                $odt->SetFont('Arial', 'B', $font1);
                $odt->Write(1, recode_utf8_vers_latin1(get_string('domaine', 'referentiel')));
                $odt->Ln(1);
                $nd = count($t_domaine_coeff);
                $espaced = 40 / $nd;
                // $s.= '<table width="100%" cellspacing="0" cellpadding="2"><tr valign="top" >'."\n";
                for ($i = 0; $i < $nd; $i++) {
                    if ($t_domaine_coeff[$i]) {
                        // $s.='<td  align="center" colspan="'.$t_nb_item_domaine[$i].'"><b>'.$t_domaine[$i].'</b> ('.referentiel_pourcentage($t_certif_domaine_poids[$i], $t_domaine_coeff[$i]).'%)</td>';
                        $odt->SetFont('Arial', '', $font2);
                        for ($j = 0; $j < $espaced; $j++) {
                            $odt->Write(1, " ");
                        }
                        $odt->SetFont('Arial', 'B', $font2);
                        $odt->Write(1, $t_domaine[$i]);
                        $odt->SetFont('Arial', '', $font3);
                        $odt->Write(1, " (" . referentiel_pourcentage($t_certif_domaine_poids[$i], $t_domaine_coeff[$i]) . "%) ");
                    } else {
                        // $s.='<td  align="center" colspan="'.$t_nb_item_domaine[$i].'"><b>'.$t_domaine[$i].'</b> (0%)</td>';
                        $odt->SetFont('Arial', '', $font2);
                        for ($j = 0; $j < $espaced; $j++) {
                            $odt->Write(1, "   ");
                        }
                        $odt->SetFont('Arial', 'B', $font2);
                        $odt->Write(1, $t_domaine[$i]);
                        $odt->SetFont('Arial', '', $font3);
                        $odt->Write(1, " (0%) ");
                    }
                }
                //$s.='</tr>'."\n";
                $odt->Ln(1);
                $odt->SetFont('Arial', 'B', $font1);
                $odt->Write(1, recode_utf8_vers_latin1(get_string('competence', 'referentiel')));
                $odt->Ln(1);
                $nc = count($t_competence);
                $espacec = 40 / $nc;
                // $s.=  '<tr valign="top"  >'."\n";
                for ($i = 0; $i < $nc; $i++) {
                    if ($t_competence_coeff[$i]) {
                        // $s.='<td align="center" colspan="'.$t_nb_item_competence[$i].'"><b>'.$t_competence[$i].'</b> ('.referentiel_pourcentage($t_certif_competence_poids[$i], $t_competence_coeff[$i]).'%)</td>'."\n";
                        $odt->SetFont('Arial', '', $font2);
                        for ($j = 0; $j < $espacec; $j++) {
                            $odt->Write(1, " ");
                        }
                        $odt->SetFont('Arial', 'B', $font2);
                        $odt->Write(1, $t_competence[$i]);
                        $odt->SetFont('Arial', '', $font3);
                        $odt->Write(1, " (" . referentiel_pourcentage($t_certif_competence_poids[$i], $t_competence_coeff[$i]) . "%) ");
                    } else {
                        // $s.='<td align="center" colspan="'.$t_nb_item_competence[$i].'"><b>'.$t_competence[$i].'</b> (0%)</td>'."\n";
                        $odt->SetFont('Arial', '', $font2);
                        for ($j = 0; $j < $espacec; $j++) {
                            $odt->Write(1, " ");
                        }
                        $odt->SetFont('Arial', 'B', $font2);
                        $odt->Write(1, $t_competence[$i]);
                        $odt->SetFont('Arial', '', $font3);
                        $odt->Write(1, " (0%) ");
                    }
                }
                // $s.='</tr>'."\n";
                $odt->Ln(1);
                // ITEMS
                $odt->SetFont('Arial', 'B', $font1);
                $odt->Write(1, recode_utf8_vers_latin1(get_string('item', 'referentiel')));
                $odt->Ln(1);
                // $s.= '<tr valign="top" >'."\n";
                for ($i = 0; $i < count($t_item_code); $i++) {
                    if ($t_item_empreinte[$i]) {
                        if ($t_certif_item_valeur[$i] >= $t_item_empreinte[$i]) {
                            // $s.='<td'.$bgcolor.'><span  class="valide">'.$t_item_code[$i].'</span></td>'."\n";
                            $odt->SetFont('Arial', 'B', $font2);
                            $odt->Write(1, $t_item_code[$i] . " ");
                        } else {
                            // $s.='<td'.$bgcolor.'><span class="invalide">'.$t_item_code[$i].'</span></td>'."\n";
                            $odt->SetFont('Arial', '', $font2);
                            $odt->Write(1, $t_item_code[$i] . " ");
                        }
                        if ($t_certif_item_valeur[$i] >= $t_item_empreinte[$i]) {
                            // $s.='<td'.$bgcolor.'><span class="valide">100%</span></td>'."\n";
                            $odt->SetFont('Arial', 'B', $font3);
                            $odt->Write(1, "(100%) ");
                        } else {
                            // $s.='<td'.$bgcolor.'><span class="invalide">'.referentiel_pourcentage($t_certif_item_valeur[$i], $t_item_empreinte[$i]).'%</span></td>'."\n";
                            $odt->SetFont('Arial', '', $font3);
                            $odt->Write(1, "(" . referentiel_pourcentage($t_certif_item_valeur[$i], $t_item_empreinte[$i]) . "%) ");
                        }
                    } else {
                        // $s.='<td class="nondefini"><span class="nondefini"><i>'.$t_item_code[$i].'</i></span></td>'."\n";
                        $odt->SetFont('Arial', 'I', $font2);
                        $odt->Write(1, $t_item_code[$i] . " ");
                    }
                }
                // $s.='</tr><tr valign="top" >'."\n";
                $odt->Ln(1);
                /*
                      // <td  width="5%">'.get_string('coeff','referentiel').'</td>'."\n";
                			for ($i=0; $i<count($t_item_coeff); $i++){
                				if ($t_item_empreinte[$i]){
                					if ($t_certif_item_valeur[$i]>=$t_item_empreinte[$i]){
                						// $s.='<td'.$bgcolor.'><span class="valide">100%</span></td>'."\n";
                				    $odt->SetFont('Arial','B',$font1);
                            $odt->Write(1,"   100% ");				
                					}
                					else{
                						// $s.='<td'.$bgcolor.'><span class="invalide">'.referentiel_pourcentage($t_certif_item_valeur[$i], $t_item_empreinte[$i]).'%</span></td>'."\n";
                				    $odt->SetFont('Arial','',$font1);
                            $odt->Write(1,"    ".referentiel_pourcentage($t_certif_item_valeur[$i], $t_item_empreinte[$i])." ");				
                					}
                				}
                				else {
                					// $s.='<td class="nondefini"><span class="nondefini">&nbsp;</span></td>'."\n";
                				}
                			}
                			// $s.='</tr></table>'."\n";
                */
                $odt->Ln(1);
            }
        }
    }
    return $s;
}
示例#12
0
function referentiel_retourne_certificat_consolide($separateur1, $separateur2, $liste_code, $ref_referentiel, $bgcolor, $params = NULL)
{
    // ce certificat comporte des pourcentages par domaine et competence
    // affichage sous forme de tableau et span pour les items
    // input liste_code
    // A.1-1:0/A.1-2:0/A.1-3:1/A.1-4:0/A.1-5:0/A.2-1:0/A.2-2:0/A.2-3:0/A.3-1:0/A.3-2:1/A.3-3:1/A.3-4:1/B.1-1:0/B.1-2:0/B.1-3:0/B.2-1:0/B.2-2:0/B.2-3:0/B.2-4:0/B.2-5:0/B.3-1:0/B.3-2:0/B.3-3:0/B.3-4:0/B.3-5:0/B.4-1:0/B.4-2:0/B.4-3:0/
    global $OK_REFERENTIEL_DATA;
    global $t_domaine;
    global $t_domaine_coeff;
    // COMPETENCES
    global $t_competence;
    global $t_competence_coeff;
    // ITEMS
    global $t_item_code;
    global $t_item_coeff;
    // coefficient poids determine par le modele de calcul (soit poids soit poids / empreinte)
    global $t_item_domaine;
    // index du domaine associe a un item
    global $t_item_competence;
    // index de la competence associee a un item
    global $t_item_poids;
    // poids
    global $t_item_empreinte;
    global $t_nb_item_domaine;
    global $t_nb_item_competence;
    $s = '';
    // nom des domaines, competences, items
    $label_d = "";
    $label_c = "";
    $label_i = "";
    if (isset($params) && !empty($params)) {
        if (isset($params->label_domaine)) {
            $label_d = $params->label_domaine;
        }
        if (isset($params->label_competence)) {
            $label_c = $params->label_competence;
        }
        if (isset($params->label_item)) {
            $label_i = $params->label_item;
        }
    }
    $t_certif_item_valeur = array();
    // table des nombres d'items valides
    $t_certif_item_coeff = array();
    // somme des poids du domaine
    $t_certif_competence_poids = array();
    // somme des poids de la competence
    $t_certif_domaine_poids = array();
    // poids certifies
    // affichage
    // donnees globales du referentiel
    if ($ref_referentiel) {
        if (!isset($OK_REFERENTIEL_DATA) || $OK_REFERENTIEL_DATA == false) {
            $OK_REFERENTIEL_DATA = referentiel_initialise_data_referentiel($ref_referentiel);
        }
        if (isset($OK_REFERENTIEL_DATA) && $OK_REFERENTIEL_DATA == true) {
            for ($i = 0; $i < count($t_item_code); $i++) {
                $t_certif_item_valeur[$i] = 0.0;
                $t_certif_item_coeff[$i] = 0.0;
            }
            for ($i = 0; $i < count($t_competence); $i++) {
                $t_certif_competence_poids[$i] = 0.0;
            }
            for ($i = 0; $i < count($t_domaine); $i++) {
                $t_certif_domaine_poids[$i] = 0.0;
            }
            // DEBUG
            // echo "<br />CODE <br />\n";
            // referentiel_affiche_data_referentiel($ref_referentiel, $params);
            // recuperer les items valides
            $tc = array();
            $liste_code = referentiel_purge_dernier_separateur($liste_code, $separateur1);
            // DEBUG
            // echo "<br />DEBUG :: print_lib_certificat.php :: 917 :: LISTE : $liste_code<br />\n";
            if (!empty($liste_code) && $separateur1 != "" && $separateur2 != "") {
                $tc = explode($separateur1, $liste_code);
                // DEBUG
                for ($i = 0; $i < count($t_item_domaine); $i++) {
                    $t_certif_domaine_poids[$i] = 0.0;
                }
                for ($i = 0; $i < count($t_item_competence); $i++) {
                    $t_certif_competence_poids[$i] = 0.0;
                }
                $i = 0;
                while ($i < count($tc)) {
                    // CODE1:N1
                    // DEBUG
                    // echo "<br />".$tc[$i]." <br />\n";
                    // exit;
                    $t_cc = explode($separateur2, $tc[$i]);
                    // tableau des items valides
                    // print_r($t_cc);
                    // echo "<br />\n";
                    // exit;
                    if (isset($t_cc[1])) {
                        if (isset($t_item_poids[$i]) && isset($t_item_empreinte[$i])) {
                            if ($t_item_poids[$i] > 0 && $t_item_empreinte[$i] > 0) {
                                // echo "<br />".min($t_cc[1],$t_item_empreinte[$i]);
                                $t_certif_item_valeur[$i] = min($t_cc[1], $t_item_empreinte[$i]);
                                // calculer le taux
                                $coeff = (double) $t_certif_item_valeur[$i] * (double) $t_item_coeff[$i];
                                // stocker la valeur pour l'item
                                $t_certif_item_coeff[$i] = $coeff;
                                // stocker le taux pour la competence
                                $t_certif_domaine_poids[$t_item_domaine[$i]] += $coeff;
                                // stocker le taux pour le domaine
                                $t_certif_competence_poids[$t_item_competence[$i]] += $coeff;
                            } else {
                                // echo "<br />".min($t_cc[1],$t_item_empreinte[$i]);
                                $t_certif_item_valeur[$i] = 0.0;
                                $t_certif_item_coeff[$i] = 0.0;
                                // $t_certif_domaine_poids[$t_item_domaine[$i]]+=0.0;
                                // $t_certif_competence_poids[$t_item_competence[$i]]+=0.0;
                            }
                        }
                    }
                    $i++;
                }
                // DEBUG
                $nlen = strlen($liste_code);
                if ($nlen <= MAXLENCODE) {
                    // sous forme de tableau
                    // DOMAINES
                    $s .= '<table width="100%" cellspacing="0" cellpadding="2"><tr valign="top" >' . "\n";
                    // if (!empty($label_d)){
                    //	$s.='<td  width="5%">'.$label_d.'</td>';
                    //}
                    //  else {
                    //	$s.='<td $t_certif_item_coeff width="5%">'.get_string('domaine','referentiel').'</td>';
                    //}
                    for ($i = 0; $i < count($t_domaine_coeff); $i++) {
                        if ($t_domaine_coeff[$i]) {
                            $s .= '<td  align="center" colspan="' . $t_nb_item_domaine[$i] . '"><b>' . $t_domaine[$i] . '</b> (' . referentiel_pourcentage($t_certif_domaine_poids[$i], $t_domaine_coeff[$i]) . '%)</td>';
                        } else {
                            $s .= '<td  align="center" colspan="' . $t_nb_item_domaine[$i] . '"><b>' . $t_domaine[$i] . '</b> (0%)</td>';
                        }
                    }
                    $s .= '</tr>' . "\n";
                    $s .= '<tr valign="top"  >' . "\n";
                    for ($i = 0; $i < count($t_competence); $i++) {
                        if ($t_competence_coeff[$i]) {
                            $s .= '<td align="center" colspan="' . $t_nb_item_competence[$i] . '"><b>' . $t_competence[$i] . '</b> (' . referentiel_pourcentage($t_certif_competence_poids[$i], $t_competence_coeff[$i]) . '%)</td>' . "\n";
                        } else {
                            $s .= '<td align="center" colspan="' . $t_nb_item_competence[$i] . '"><b>' . $t_competence[$i] . '</b> (0%)</td>' . "\n";
                        }
                    }
                    $s .= '</tr>' . "\n";
                    // ITEMS
                    // DEBUG
                    // echo "<br />$nlen\n";
                    $s .= '<tr valign="top" >' . "\n";
                    for ($i = 0; $i < count($t_item_code); $i++) {
                        if ($t_item_empreinte[$i]) {
                            if (isset($t_certif_item_valeur[$i])) {
                                if ($t_certif_item_valeur[$i] >= $t_item_empreinte[$i]) {
                                    // $s.='<td'.$bgcolor.'><span  class="valide">'.$t_item_code[$i].'</span></td>'."\n";
                                    $s .= '<td class="valide"><span  class="valide">' . $t_item_code[$i] . '</span></td>' . "\n";
                                } else {
                                    //$s.='<td'.$bgcolor.'><span class="invalide">'.$t_item_code[$i].'</span></td>'."\n";
                                    $s .= '<td class="invalide"><span class="invalide">' . $t_item_code[$i] . '</span></td>' . "\n";
                                }
                            }
                        } else {
                            $s .= '<td class="nondefini"><span class="nondefini"><i>' . $t_item_code[$i] . '</i></span></td>' . "\n";
                        }
                    }
                    $s .= '</tr>' . "\n";
                    $s .= '<tr valign="top" >' . "\n";
                    // <td  width="5%">'.get_string('coeff','referentiel').'</td>'."\n";
                    // for ($i=0; $i<count($t_item_coeff); $i++){
                    for ($i = 0; $i < count($t_item_code); $i++) {
                        if ($t_item_empreinte[$i]) {
                            if (isset($t_certif_item_valeur[$i])) {
                                if ($t_certif_item_valeur[$i] >= $t_item_empreinte[$i]) {
                                    // $s.='<td'.$bgcolor.'><span class="valide">100%</span></td>'."\n";
                                    $s .= '<td class="valide"><span class="valide">100%</span></td>' . "\n";
                                } else {
                                    $s .= '<td class="invalide"><span class="invalide">' . referentiel_pourcentage($t_certif_item_valeur[$i], $t_item_empreinte[$i]) . '%</span></td>' . "\n";
                                }
                            }
                        } else {
                            $s .= '<td class="nondefini"><span class="nondefini">&nbsp;</span></td>' . "\n";
                        }
                    }
                    $s .= '</tr></table>' . "\n";
                } else {
                    // DOMAINES
                    $s .= '<table width="100%" cellspacing="0" cellpadding="2">
    <tr valign="top"><td>' . "\n";
                    // if (!empty($label_d)){
                    //	$s.='<td  width="5%">'.$label_d.'</td>';
                    //}
                    //  else {
                    //	$s.='<td $t_certif_item_coeff width="5%">'.get_string('domaine','referentiel').'</td>';
                    //}
                    for ($i = 0; $i < count($t_domaine_coeff); $i++) {
                        if ($t_domaine_coeff[$i]) {
                            $s .= ' <b>' . $t_domaine[$i] . '</b> (' . referentiel_pourcentage($t_certif_domaine_poids[$i], $t_domaine_coeff[$i]) . '%)';
                        } else {
                            $s .= ' <b>' . $t_domaine[$i] . '</b> (0%)</span>';
                        }
                    }
                    $s .= '</td></tr>' . "\n";
                    $s .= '<tr valign="top"><td>' . "\n";
                    for ($i = 0; $i < count($t_competence); $i++) {
                        if ($t_competence_coeff[$i]) {
                            $s .= ' <b>' . $t_competence[$i] . '</b> (' . referentiel_pourcentage($t_certif_competence_poids[$i], $t_competence_coeff[$i]) . '%)' . "\n";
                        } else {
                            $s .= ' <b>' . $t_competence[$i] . '</b> (0%)' . "\n";
                        }
                    }
                    $s .= '</td></tr>' . "\n";
                    $s .= '<tr valign="top" ><td>' . "\n";
                    for ($i = 0; $i < count($t_item_code); $i++) {
                        if ($t_item_empreinte[$i]) {
                            if (isset($t_certif_item_valeur[$i])) {
                                if ($t_certif_item_valeur[$i] >= $t_item_empreinte[$i]) {
                                    $s .= '<span class="deverrouille"><span  class="valide">' . $t_item_code[$i] . ' (100%)</span></span>' . "\n";
                                } else {
                                    $s .= '<span class="verrouille"><span class="invalide">' . $t_item_code[$i] . ' (' . referentiel_pourcentage($t_certif_item_valeur[$i], $t_item_empreinte[$i]) . '%)</span></span>' . "\n";
                                }
                            }
                        } else {
                            $s .= '<span class="nondefini"><i>' . $t_item_code[$i] . '</i></span>' . "\n";
                        }
                    }
                    $s .= '</td></tr></table>' . "\n";
                }
            }
        }
    }
    return $s;
}