function referentiel_select_users_pedagogie($record_users, $appli = 'pedagogie.php', $mode = 'listpedago', $userid = 0, $select_all = 0) { global $cm; global $course; $maxcol = MAXBOITESSELECTION; $s = ""; $t_users = array(); if ($record_users) { foreach ($record_users as $record_u) { // liste d'id users // $t_users[] = array('id' => $record_u->userid, 'lastname' => referentiel_get_user_nom($record_u->userid), 'firstname' => referentiel_get_user_prenom($record_u->userid)); $t_users_id[] = $record_u->userid; $t_users_lastname[] = referentiel_get_user_nom($record_u->userid); $t_users_firstname[] = referentiel_get_user_prenom($record_u->userid); } array_multisort($t_users_lastname, SORT_ASC, $t_users_firstname, SORT_ASC, $t_users); $n = count($t_users); // How many boxes ? $size = 4; $n = count($t_users); if ($n >= 48) { $l = $maxcol; $c = (int) ($n / $l); $size = 8; } elseif ($n >= 18) { $l = $maxcol; $c = (int) ($n / $l); $size = 6; } elseif ($n >= 6) { $l = $maxcol - 2; $c = (int) ($n / $l); } else { $l = 1; $c = (int) $n; } if ($c * $l == $n) { $reste = false; } else { $reste = true; } $i = 0; $s .= '<table class="selection"><tr valign="top"><td>'; for ($j = 0; $j < $l; $j++) { $s .= '<div style="max-width:250px;padding: 2px 2px 2px 2px;float:left;">' . "\n"; $s .= "\n" . '<form name="form" method="post" action="' . $appli . '?id=' . $cm->id . '&action=selectuser">' . "\n"; $s .= '<select name="userid" id="userid" size="' . $size . '">' . "\n"; if ($j < $l - 1) { if ($userid == '' || $userid == 0) { $s .= '<option value="0" selected="selected">' . get_string('choisir', 'referentiel') . '</option>' . "\n"; } else { $s .= '<option value="0">' . get_string('choisir', 'referentiel') . '</option>' . "\n"; } } else { if ($reste) { if ($userid == '' || $userid == 0) { $s .= '<option value="0" selected="selected">' . get_string('choisir', 'referentiel') . '</option>' . "\n"; } else { $s .= '<option value="0">' . get_string('choisir', 'referentiel') . '</option>' . "\n"; } } else { if ($userid == '' || $userid == 0) { $s .= '<option value="0" selected="selected">' . get_string('tous', 'referentiel') . '</option>' . "\n"; } else { $s .= '<option value="0">' . get_string('tous', 'referentiel') . '</option>' . "\n"; } } } for ($k = 0; $k < $c; $k++) { if ($userid == $t_users[$i]['id']) { $s .= '<option value="' . $t_users[$i]['id'] . '" selected="selected">' . referentiel_nom_prenom($t_users[$i]['lastname'], $t_users[$i]['firstname']) . '</option>' . "\n"; } else { $s .= '<option value="' . $t_users[$i]['id'] . '">' . referentiel_nom_prenom($t_users[$i]['lastname'], $t_users[$i]['firstname']) . '</option>' . "\n"; } $i++; } $s .= '</select>' . "\n"; $s .= '<br /><input type="submit" value="' . get_string('select', 'referentiel') . '" />' . "\n"; $s .= ' <!-- tous les certificats --> <input type="hidden" name="select_all" value="' . $select_all . '" /> <!-- accompagnement --> <!-- These hidden variables are always the same --> <input type="hidden" name="course" value="' . $course->id . '" /> <input type="hidden" name="sesskey" value="' . sesskey() . '" /> <input type="hidden" name="mode" value="' . $mode . '" /> </form>' . "\n"; $s .= '</div>'; } if ($i < $n) { $s .= '<div style="max-width:250px;padding: 2px 2px 2px 2px;float:left;">' . "\n"; $s .= '<form name="form" method="post" action="' . $appli . '?id=' . $cm->id . '&action=selectuser">' . "\n"; $s .= '<select name="userid" id="userid" size="' . $size . '">' . "\n"; if ($userid == '' || $userid == 0) { $s .= '<option value="0" selected="selected">' . get_string('tous', 'referentiel') . '</option>' . "\n"; } else { $s .= '<option value="0">' . get_string('tous', 'referentiel') . '</option>' . "\n"; } while ($i < $n) { if ($userid == $t_users[$i]['id']) { $s .= '<option value="' . $t_users[$i]['id'] . '" selected="selected">' . referentiel_nom_prenom($t_users[$i]['lastname'], $t_users[$i]['firstname']) . '</option>' . "\n"; } else { $s .= '<option value="' . $t_users[$i]['id'] . '">' . referentiel_nom_prenom($t_users[$i]['lastname'], $t_users[$i]['firstname']) . '</option>' . "\n"; } $i++; } $s .= '</select>' . "\n"; $s .= '<br /><input type="submit" value="' . get_string('select', 'referentiel') . '" />' . "\n"; $s .= ' <!-- tous les certificats --> <input type="hidden" name="select_all" value="' . $select_all . '" /> <!-- These hidden variables are always the same --> <input type="hidden" name="course" value="' . $course->id . '" /> <input type="hidden" name="sesskey" value="' . sesskey() . '" /> <input type="hidden" name="mode" value="' . $mode . '" /> </form>' . "\n"; $s .= '</div>'; } $s .= '</td></tr></table>' . "\n"; } return $s; }
function referentiel_select_users_activite_2_tab($record_users, $userid = 0, $select_acc = 0, $mode = 'listactivity', $initiales = '', $data_f = NULL) { // SELECT INPUT ALPHABETIQUE global $CFG; global $cm; global $course; $maxcol = MAXBOITESSELECTION; $s = ""; $t_users = array(); $t_users_id = array(); $t_users_firstname = array(); $t_users_lastname = array(); if ($record_users) { // $s.='<option value="0" selected="selected">'.get_string('choisir', 'referentiel').'</option>'."\n"; foreach ($record_users as $record_u) { // liste d'id users // if (!empty($record_u->userid)) { $firstname = referentiel_get_user_prenom($record_u->userid); $lastname = referentiel_get_user_nom($record_u->userid); $initiale = mb_strtoupper(substr($lastname, 0, 1), 'UTF-8'); $t_users[] = array('id' => $record_u->userid, 'lastname' => $lastname, 'firstname' => $firstname, 'initiale' => $initiale); $t_users_id[] = $record_u->userid; $t_users_lastname[] = $lastname; $t_users_firstname[] = $firstname; } } array_multisort($t_users_lastname, SORT_ASC, $t_users_firstname, SORT_ASC, $t_users); $alpha = explode(',', get_string('alphabet', 'referentiel')); foreach ($t_users as $an_user) { if (!empty($an_user)) { // print_object($an_user); $t_alphabetique[$an_user['initiale']][] = $an_user['id'] . "," . $an_user['firstname'] . "," . $an_user['lastname']; if (!isset($t_id_alphabetique[$an_user['initiale']])) { $t_id_alphabetique[$an_user['initiale']] = $an_user['id']; } else { $t_id_alphabetique[$an_user['initiale']] .= '_' . $an_user['id']; } } } // Should use this variable so that we don't break stuff every time a variable is added or changed. $baseurl = $CFG->wwwroot . '/mod/referentiel/activite.php?id=' . $cm->id . '&action=selectuser&initiale='; $baseurl1 = '&userids='; $baseurl2 = '&select_acc=' . $select_acc . '&mode=' . $mode . '&courseid=' . $course->id . '&sesskey=' . sesskey(); if (!empty($data_f)) { $baseurl3 = '&f_auteur=' . $data_f->f_auteur . '&f_referent=' . $data_f->f_referent . '&f_validation=' . $data_f->f_validation . '&f_date_modif=' . $data_f->f_date_modif . '&f_date_modif_student=' . $data_f->f_date_modif_student; } else { $baseurl3 = ''; } // alphabetic selection alphabetique $s .= '<div align="center">' . "\n"; $s .= '<a class="select" href="' . $baseurl . $baseurl1 . $baseurl2 . $baseurl3 . '">' . get_string('tous', 'referentiel') . '</a> ' . "\n"; foreach ($alpha as $letter) { if (!empty($t_alphabetique[$letter])) { $s .= '<a class="select" href="' . $baseurl . $letter . $baseurl1 . $t_id_alphabetique[$letter] . $baseurl2 . $baseurl3 . '">' . $letter . '</a> ' . "\n"; } else { $s .= '' . $letter . ' ' . "\n"; } } $s .= '</div><br />' . "\n"; $s .= '<div align="center">' . "\n"; // How many boxes ? $size = 4; $n = count($t_users); if ($n >= 48) { $l = $maxcol; $c = (int) ($n / $l); $size = 8; } elseif ($n >= 18) { $l = $maxcol; $c = (int) ($n / $l); $size = 6; } elseif ($n >= 6) { $l = $maxcol - 2; $c = (int) ($n / $l); } else { $l = 1; $c = (int) $n; } if ($c * $l == $n) { $reste = false; } else { $reste = true; } $i = 0; $s .= '<table class="selection">' . "\n"; $s .= '<tr valign="top">' . "\n"; for ($j = 0; $j < $l; $j++) { $s .= '<td>' . "\n"; $s .= "\n" . '<form name="form" method="post" action="activite.php?id=' . $cm->id . '&action=selectuser">' . "\n"; $s .= '<select name="userid" id="userid" size="' . $size . '">' . "\n"; if ($j < $l - 1) { if ($userid == '' || $userid == 0) { $s .= '<option value="0" selected="selected">' . get_string('choisir', 'referentiel') . '</option>' . "\n"; } else { $s .= '<option value="0">' . get_string('choisir', 'referentiel') . '</option>' . "\n"; } } else { if ($reste) { if ($userid == '' || $userid == 0) { $s .= '<option value="0" selected="selected">' . get_string('choisir', 'referentiel') . '</option>' . "\n"; } else { $s .= '<option value="0">' . get_string('choisir', 'referentiel') . '</option>' . "\n"; } } else { if ($userid == '' || $userid == 0) { $s .= '<option value="0" selected="selected">' . get_string('tous', 'referentiel') . '</option>' . "\n"; } else { $s .= '<option value="0">' . get_string('tous', 'referentiel') . '</option>' . "\n"; } } } for ($k = 0; $k < $c; $k++) { if ($userid == $t_users[$i]['id']) { $s .= '<option value="' . $t_users[$i]['id'] . '" selected="selected">' . referentiel_nom_prenom($t_users[$i]['lastname'], $t_users[$i]['firstname']) . '</option>' . "\n"; } else { $s .= '<option value="' . $t_users[$i]['id'] . '">' . referentiel_nom_prenom($t_users[$i]['lastname'], $t_users[$i]['firstname']) . '</option>' . "\n"; } $i++; } $s .= '</select>' . "\n"; if (!empty($data_f)) { $s .= ' <input type="hidden" name="f_auteur" value="' . $data_f->f_auteur . '" /> <input type="hidden" name="f_validation" value="' . $data_f->f_validation . '" /> <input type="hidden" name="f_referent" value="' . $data_f->f_referent . '" /> <input type="hidden" name="f_date_modif" value="' . $data_f->f_date_modif . '" /> <input type="hidden" name="f_date_modif_student" value="' . $data_f->f_date_modif_student . '" /> '; } $s .= '<br /><input type="submit" value="' . get_string('select', 'referentiel') . '" />' . "\n"; $s .= ' <!-- accompagnement --> <input type="hidden" name="select_acc" value="' . $select_acc . '" /> <!-- These hidden variables are always the same --> <input type="hidden" name="courseid" value="' . $course->id . '" /> <input type="hidden" name="sesskey" value="' . sesskey() . '" /> <input type="hidden" name="mode" value="' . $mode . '" />' . "\n"; $s .= '</form>' . "\n"; $s .= '</td>' . "\n"; } if ($i < $n) { $s .= '<td>'; $s .= '<form name="form" method="post" action="activite.php?id=' . $cm->id . '&action=selectuser">' . "\n"; $s .= '<select name="userid" id="userid" size="' . $size . '">' . "\n"; if ($userid == '' || $userid == 0) { $s .= '<option value="0" selected="selected">' . get_string('tous', 'referentiel') . '</option>' . "\n"; } else { $s .= '<option value="0">' . get_string('tous', 'referentiel') . '</option>' . "\n"; } while ($i < $n) { if ($userid == $t_users[$i]['id']) { $s .= '<option value="' . $t_users[$i]['id'] . '" selected="selected">' . referentiel_nom_prenom($t_users[$i]['lastname'], $t_users[$i]['firstname']) . '</option>' . "\n"; } else { $s .= '<option value="' . $t_users[$i]['id'] . '">' . referentiel_nom_prenom($t_users[$i]['lastname'], $t_users[$i]['firstname']) . '</option>' . "\n"; } $i++; } $s .= '</select>' . "\n"; if (!empty($data_f)) { $s .= ' <input type="hidden" name="f_auteur" value="' . $data_f->f_auteur . '" /> <input type="hidden" name="f_validation" value="' . $data_f->f_validation . '" /> <input type="hidden" name="f_referent" value="' . $data_f->f_referent . '" /> <input type="hidden" name="f_date_modif" value="' . $data_f->f_date_modif . '" /> <input type="hidden" name="f_date_modif_student" value="' . $data_f->f_date_modif_student . '" /> '; } $s .= '<br /><input type="submit" value="' . get_string('select', 'referentiel') . '" />' . "\n"; $s .= ' <!-- accompagnement --> <input type="hidden" name="select_acc" value="' . $select_acc . '" /> <!-- These hidden variables are always the same --> <input type="hidden" name="select_acc" value="' . $select_acc . '" /> <input type="hidden" name="courseid" value="' . $course->id . '" /> <input type="hidden" name="sesskey" value="' . sesskey() . '" /> <input type="hidden" name="mode" value="' . $mode . '" />' . "\n"; $s .= '</form>' . "\n"; $s .= '</td>'; } $s .= '</tr></table>' . "\n"; $s .= '</div>' . "\n"; } return $s; }
function referentiel_select_users_etudiant($record_users, $mode, $userid = 0, $initiales = '', $select_acc = 0, $select_all = 0) { global $cm; global $course; $maxcol = MAXBOITESSELECTION; $s = ""; $t_users = array(); $appli = "etudiant.php"; if ($record_users) { // $s.='<option value="0" selected="selected">'.get_string('choisir', 'referentiel').'</option>'."\n"; foreach ($record_users as $record_u) { // liste d'id users // $firstname = referentiel_get_user_prenom($record_u->userid); $lastname = referentiel_get_user_nom($record_u->userid); $initiale = mb_strtoupper(mb_substr($lastname, 0, 1), 'UTF-8'); $t_users[] = array('id' => $record_u->userid, 'lastname' => $lastname, 'firstname' => $firstname, 'initiale' => $initiale); $t_users_id[] = $record_u->userid; $t_users_lastname[] = $lastname; $t_users_firstname[] = $firstname; } array_multisort($t_users_lastname, SORT_ASC, $t_users_firstname, SORT_ASC, $t_users); // // echo "<br />Debug :: print_lib_etudiant.php :: 1419 ::<br />\n"; // print_r($t_users); // exit; $alpha = explode(',', get_string('alphabet', 'referentiel')); /* print_r($alpha); echo "<br /><br />\n"; */ foreach ($t_users as $an_user) { if (!empty($an_user)) { // print_object($an_user); $t_alphabetique[$an_user['initiale']][] = $an_user['id'] . "," . $an_user['firstname'] . "," . $an_user['lastname']; if (!isset($t_id_alphabetique[$an_user['initiale']])) { $t_id_alphabetique[$an_user['initiale']] = $an_user['id']; } else { $t_id_alphabetique[$an_user['initiale']] .= '_' . $an_user['id']; } } } // Should use this variable so that we don't break stuff every time a variable is added or changed. //http://localhost/moodle/mod/referentiel/certificat.php?d=1&mode=editcertif&sesskey=yvj43gJOTd?id=2&userid=6&select_acc=0&action=selectuser&initiale=D&userids=7&select_all=0&mode=editcertif&course=2&sesskey=yvj43gJOTd $baseurl = $appli . '?id=' . $cm->id . '&select_acc=' . $select_acc . '&action=selectuser&initiale='; $baseurl1 = '&userids='; $baseurl2 = '&select_all=' . $select_all . '&mode=' . $mode . '&course=' . $course->id . '&sesskey=' . sesskey(); if (!empty($userid)) { $baseurl3 = '&userid=' . $userid; } else { $baseurl3 = ''; } // http://localhost/moodle/mod/referentiel/certificat.php?id=2&select_acc=0&action=selectuser&initiale=A&userids=6&select_all=0&mode=listcertif&course=2&sesskey=yvj43gJOTd // http://localhost/moodle/mod/referentiel/certificat.php?d=1&mode=editcertif&sesskey=yvj43gJOTd?id=2&select_acc=0&action=selectuser&initiale=A&userids=6&select_all=0&mode=editcertif&course=2&sesskey=yvj43gJOTd // http://localhost/moodle/mod/referentiel/certificat.php?d=1&mode=editcertif&sesskey=yvj43gJOTd?id=2&select_acc=0&action=selectuser&initiale=&userids=&select_all=0&mode=editcertif&course=2&sesskey=yvj43gJOTd // selection alphabetique $s .= '<div align="center">' . "\n"; $s .= '<a class="select" href="' . $baseurl . '' . $baseurl1 . '' . $baseurl2 . $baseurl3 . '">' . get_string('tous', 'referentiel') . '</a> ' . "\n"; foreach ($alpha as $letter) { if (!empty($t_alphabetique[$letter])) { $s .= '<a class="select" href="' . $baseurl . $letter . $baseurl1 . $t_id_alphabetique[$letter] . $baseurl2 . $baseurl3 . '">' . $letter . '</a> ' . "\n"; } else { $s .= $letter . ' ' . "\n"; } } $s .= '</div><br />' . "\n"; // Formulaire de selection individuelle $n = count($t_users); // How many boxes ? $size = 4; $n = count($t_users); if ($n >= 48) { $l = $maxcol; $c = (int) ($n / $l); $size = 8; } elseif ($n >= 18) { $l = $maxcol; $c = (int) ($n / $l); $size = 6; } elseif ($n >= 6) { $l = $maxcol - 2; $c = (int) ($n / $l); } else { $l = 1; $c = (int) $n; } if ($c * $l == $n) { $reste = false; } else { $reste = true; } $i = 0; $s .= '<table class="selection"><tr valign="top"><td>' . "\n"; for ($j = 0; $j < $l; $j++) { $s .= '<div style="max-width:250px;padding: 2px 2px 2px 2px;float:left;">' . "\n"; if (!empty($userid)) { $s .= "\n" . '<form name="form" method="post" action="' . $appli . '?id=' . $cm->id . '&userid=' . $userid . '&select_acc=' . $select_acc . '&action=selectuser">' . "\n"; } else { $s .= "\n" . '<form name="form" method="post" action="' . $appli . '?id=' . $cm->id . '&select_acc=' . $select_acc . '&action=selectuser">' . "\n"; } $s .= '<select name="userid" id="userid" size="' . $size . '">' . "\n"; if ($j < $l - 1) { if ($userid == '' || $userid == 0) { $s .= '<option value="0" selected="selected">' . get_string('choisir', 'referentiel') . '</option>' . "\n"; } else { $s .= '<option value="0">' . get_string('choisir', 'referentiel') . '</option>' . "\n"; } } else { if ($reste) { if ($userid == '' || $userid == 0) { $s .= '<option value="0" selected="selected">' . get_string('choisir', 'referentiel') . '</option>' . "\n"; } else { $s .= '<option value="0">' . get_string('choisir', 'referentiel') . '</option>' . "\n"; } } else { if ($userid == '' || $userid == 0) { $s .= '<option value="0" selected="selected">' . get_string('tous', 'referentiel') . '</option>' . "\n"; } else { $s .= '<option value="0">' . get_string('tous', 'referentiel') . '</option>' . "\n"; } } } for ($k = 0; $k < $c; $k++) { if ($userid == $t_users[$i]['id']) { $s .= '<option value="' . $t_users[$i]['id'] . '" selected="selected">' . referentiel_nom_prenom($t_users[$i]['lastname'], $t_users[$i]['firstname']) . '</option>' . "\n"; } else { $s .= '<option value="' . $t_users[$i]['id'] . '">' . referentiel_nom_prenom($t_users[$i]['lastname'], $t_users[$i]['firstname']) . '</option>' . "\n"; } $i++; } $s .= '</select>' . "\n"; $s .= '<br /><input type="submit" value="' . get_string('select', 'referentiel') . '" />' . "\n"; $s .= ' <!-- tous les certificats --> <input type="hidden" name="select_all" value="' . $select_all . '" /> <!-- accompagnement --> <input type="hidden" name="select_acc" value="' . $select_acc . '" /> <!-- These hidden variables are always the same --> <input type="hidden" name="courseid" value="' . $course->id . '" /> <input type="hidden" name="sesskey" value="' . sesskey() . '" /> <input type="hidden" name="mode" value="' . $mode . '" /> </form>' . "\n"; $s .= '</div>'; } if ($i < $n) { $s .= '<div style="max-width:250px;padding: 2px 2px 2px 2px;float:left;">' . "\n"; if (!empty($userid)) { $s .= "\n" . '<form name="form" method="post" action="' . $appli . '?id=' . $cm->id . '&userid=' . $userid . '&select_acc=' . $select_acc . '&action=selectuser">' . "\n"; } else { $s .= "\n" . '<form name="form" method="post" action="' . $appli . '?id=' . $cm->id . '&select_acc=' . $select_acc . '&action=selectuser">' . "\n"; } $s .= '<select name="userid" id="userid" size="' . $size . '">' . "\n"; if ($userid == '' || $userid == 0) { $s .= '<option value="0" selected="selected">' . get_string('tous', 'referentiel') . '</option>' . "\n"; } else { $s .= '<option value="0">' . get_string('tous', 'referentiel') . '</option>' . "\n"; } while ($i < $n) { if ($userid == $t_users[$i]['id']) { $s .= '<option value="' . $t_users[$i]['id'] . '" selected="selected">' . referentiel_nom_prenom($t_users[$i]['lastname'], $t_users[$i]['firstname']) . '</option>' . "\n"; } else { $s .= '<option value="' . $t_users[$i]['id'] . '">' . referentiel_nom_prenom($t_users[$i]['lastname'], $t_users[$i]['firstname']) . '</option>' . "\n"; } $i++; } $s .= '</select>' . "\n"; $s .= '<br /><input type="submit" value="' . get_string('select', 'referentiel') . '" />' . "\n"; $s .= ' <!-- tous les certificats --> <input type="hidden" name="select_all" value="' . $select_all . '" /> <!-- accompagnement --> <input type="hidden" name="select_acc" value="' . $select_acc . '" /> <!-- These hidden variables are always the same --> <input type="hidden" name="select_acc" value="' . $select_acc . '" /> <input type="hidden" name="courseid" value="' . $course->id . '" /> <input type="hidden" name="sesskey" value="' . sesskey() . '" /> <input type="hidden" name="mode" value="' . $mode . '" /> </form>' . "\n"; $s .= '</div>'; } $s .= '</td></tr></table>' . "\n"; } return $s; }