Пример #1
0
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;
    }
}
 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++;
             }
         }
     }
 }