function referentiel_update_activity($form) { // MAJ activite + document; global $USER; global $DB; $ok = true; // DEBUG //echo "<br />locallib 492 :: UPDATE ACTIVITY<br />\n"; //print_object($form); //echo "<br />"; if (isset($form->action) && $form->action == "modifier_activite") { //echo "<br />OK1"; // recuperer l'ancien enregistrement pour les mises à jour du certificat $old_liste_competences = ''; if ($form->activite_id) { $record_activite = referentiel_get_activite($form->activite_id); if ($record_activite) { $old_liste_competences = $record_activite->competences_activite; } } if ($old_liste_competences == '' && isset($form->old_liste_competences)) { $old_liste_competences = $form->old_liste_competences; } // activite $activite = new stdClass(); $activite->id = $form->activite_id; $activite->type_activite = $form->type_activite; // Modif jf 2013/12/11 $cf = 'code_item_' . $form->activite_id; //echo '<br/>'.$cf; if (isset($form->{$cf}) && is_array($form->{$cf})) { //print_r ($form->$cf); //exit; $activite->competences_activite = reference_conversion_code_2_liste_competence('/', $form->{$cf}); } else { if (isset($form->code_item) && is_array($form->code_item)) { $activite->competences_activite = reference_conversion_code_2_liste_competence('/', $form->code_item); } else { if (isset($form->competences_activite)) { $activite->competences_activite = $form->competences_activite; } else { $activite->competences_activite = ''; } } } $activite->description_activite = $form->description_activite; $activite->commentaire_activite = $form->commentaire_activite; $activite->ref_instance = $form->instance; $activite->ref_referentiel = $form->ref_referentiel; $activite->ref_course = $form->courseid; $activite->date_creation = $form->date_creation; $activite->approved = $form->approved; $activite->userid = $form->userid; $activite->teacherid = $form->teacherid; $ladate = time(); // MODIF JF 2009/10/27 if ($USER->id == $activite->userid) { $activite->date_modif_student = $ladate; $activite->date_modif = $form->date_modif; $activite->teacherid = $form->teacherid; } else { $activite->date_modif = $ladate; $activite->date_modif_student = $form->date_modif_student; $activite->teacherid = $USER->id; } // MODIF JF 2010/02/11 if (isset($form->mailnow)) { $activite->mailnow = $form->mailnow; if ($form->mailnow == '1') { // renvoyer $activite->mailed = 0; // annuler envoi precedent } } else { $activite->mailnow = 0; } // DEBUG //print_object($activite); //echo "<br />"; //exit; $ok = $ok && $DB->update_record("referentiel_activite", $activite); //echo "DEBUG :: locallib.php :: 572 :: ACTIVITE ID / $activite->id<br />"; // MODIF JF 2009/09/21 // mise a zero du certificat associe a cette personne pour ce referentiel // referentiel_certificat_user_invalider($activite->userid, $activite->ref_referentiel); // referentiel_regenere_certificat_user($activite->userid, $activite->ref_referentiel); if ($ok && $activite->userid > 0) { // mise a jour du certificat referentiel_mise_a_jour_competences_certificat_user($old_liste_competences, $activite->competences_activite, $activite->userid, $activite->ref_referentiel, $activite->approved, true, $activite->approved); } } else { if (isset($form->action) && $form->action == "modifier_document") { $document = new stdClass(); $document->id = $form->document_id; $document->url_document = $form->url_document; $document->type_document = substr($form->type_document, 0, 20); $document->description_document = $form->description_document; $document->ref_activite = $form->ref_activite; if (isset($form->cible_document)) { $document->cible_document = $form->cible_document; } else { $document->cible_document = 1; } if (isset($form->etiquette_document)) { $document->etiquette_document = $form->etiquette_document; } else { $document->etiquette_document = ''; } // Modif JF 2013/02/02 $document->timestamp = time(); // DEBUG // print_object($document); // echo "<br />"; $ok = $ok && $DB->update_record("referentiel_document", $document); if ($ok) { $activite = $DB->get_record('referentiel_activite', array('id' => $document->ref_activite)); if ($activite) { if ($USER->id == $activite->userid) { $ok = $DB->set_field('referentiel_activite', 'date_modif_student', time(), array('id' => $activite->id)); } else { $ok = $DB->set_field('referentiel_activite', 'date_modif', time(), array('id' => $activite->id)); } } } // exit; } else { if (isset($form->action) && $form->action == "creer_document") { $document = new stdClass(); $document->url_document = $form->url_document; $document->type_document = substr($form->type_document, 0, 20); $document->description_document = $form->description_document; $document->ref_activite = $form->ref_activite; if (isset($form->cible_document)) { $document->cible_document = $form->cible_document; } else { $document->cible_document = 1; } if (isset($form->etiquette_document)) { $document->etiquette_document = $form->etiquette_document; } else { $document->etiquette_document = ''; } // Modif JF 2013/02/02 $document->timestamp = time(); // DEBUG // print_object($document); // echo "<br />"; $ok = $DB->insert_record("referentiel_document", $document); // echo "DOCUMENT ID / $ok<br />"; if ($ok) { $activite = $DB->get_record('referentiel_activite', array('id' => $document->ref_activite)); if ($activite) { if ($USER->id == $activite->userid) { $ok = $DB->set_field('referentiel_activite', 'date_modif_student', time(), array('id' => $activite->id)); } else { $ok = $DB->set_field('referentiel_activite', 'date_modif', time(), array('id' => $activite->id)); } } } } } } return $ok; }
function referentiel_activite_id($context, $mode, $cm, $instance, $activite_id, $bareme, $select_acc = 0, $detail = true) { global $COURSE; // Specifique car on a l'id de l'activite if ($activite_id) { $record_a = referentiel_get_activite($activite_id); if (!empty($record_a)) { echo '<div align="center">' . get_string('competences_declarees', 'referentiel', '<span class="bold">' . referentiel_get_user_info($record_a->userid) . '</span>') . "\n" . referentiel_print_jauge_activite($record_a->userid, $instance->ref_referentiel) . '</div>' . "\n"; referentiel_print_activite_detail($bareme, $record_a, $context, true, 0); if (!$record_a->approved) { echo '<div align="center">' . referentiel_ajout_document($record_a, $mode, $select_acc) . "</div>\n"; } // afficher le menu si on l'activité est affichee dans son propre cours de création if ($record_a->ref_course == $COURSE->id) { referentiel_menu_activite($cm, $context, $record_a->id, $record_a->userid, $instance->id, $record_a->approved, 0, $detail, $mode); } else { echo '<div align="center">' . get_string('activite_exterieure', 'referentiel') . '</div>' . "\n"; } } } }