function referentiel_get_scale_info($refrefid) { global $CFG; global $DB; $scale_info = new stdClass(); // Default values $scale_info->name = get_string('nom_bareme', 'referentiel'); $scale_info->grades = get_string('bareme', 'referentiel'); $scale_info->description = get_string('description_bareme', 'referentiel'); if ($CFG->referentiel_use_scale) { if ($baremeid = referentiel_get_bareme_id_occurrence($refrefid)) { if ($sbareme = $DB->get_record('referentiel_scale', array('id' => $baremeid))) { if ($scale = $DB->get_record('scale', array('id' => $sbareme->scaleid))) { // DEBUG // echo "<br />export_grade_outcomes.php :: 296 :: SCALE<br />\n"; // print_object($scale); $scale_info->name = $scale->name; $scale_info->grades = $scale->scale; $scale_info->description = mb_substr(strip_tags($scale->description), 0, 60); $scale_info->description = mb_substr($scale_info->description, 0, strrpos($scale_info->description, " ")); $scale_info->description .= ' (...)'; } } } } return $scale_info; }
/** * Given an object containing all the necessary data, * this function will create a new activity and return the id number * * @param object $activite: a special referentiel_activite object * @param object $m a secial module object * @return int The id of the newly inserted record **/ function referentiel_activite_outcomes($activite, $m, $liste_bareme_evaluations = '', $mdata = NULL) { // creation / mise a jour activite par objectif global $CFG; global $DB; $activite_id = 0; if (OUTCOMES_SUPER_DEBUG) { // DEBUG mtrace("\nDEBUG :: referentiel_activite_outcomes :: 715\nDEMANDE MISE A JOUR\n"); print_r($activite); mtrace("\n"); print_r($m); mtrace("\n " . $liste_bareme_evaluations); mtrace("\n"); } $activite->type_activite = addslashes($activite->type_activite); $activite->mailnow = 0; $activite->mailed = 1; // ne pas notifier. /* $m->id; $m->type=$modulename; $m->instance=$moduleinstance; $m->course=$courseid; $m->date=$cm->added; $m->userdate=userdate($cm->added); $m->ref_activite=$mid; $m->name=$mname; $m->description=$mdescription; $m->link=$mlink; */ // cette activite est-elle enregistree ? $params = array("ref_instance" => "{$activite->ref_instance}", "ref_referentiel" => "{$activite->ref_referentiel}", "ref_course" => "{$activite->ref_course}", "userid" => "{$activite->userid}", "type" => "{$m->type}", "moduleid" => "{$m->id}", "ref_activite" => "{$m->ref_activite}"); $sql = "SELECT * FROM {referentiel_activite_modules}\n WHERE ref_instance=:ref_instance\n AND ref_referentiel=:ref_referentiel AND ref_course=:ref_course\n AND userid=:userid\n AND type=:type\n AND moduleid=:moduleid\n AND ref_activite=:ref_activite "; if (OUTCOMES_SUPER_DEBUG) { mtrace("\nVERIF table referentiel_activite_modules\n"); print_r($params); mtrace("\nSQL:\n{$sql}\n"); } $r_activite_outcomes = $DB->get_record_sql($sql, $params); if ($r_activite_outcomes) { if (OUTCOMES_SUPER_DEBUG) { // DEBUG mtrace("\nDEBUG :: referentiel_activite_outcomes :: 761\n**** Activité déjà enregistrée *** \n"); print_r($r_activite_outcomes); mtrace("\n"); } // cet utilisateur est deja reference pour cette activite $activite_old = $DB->get_record("referentiel_activite", array("id" => "{$r_activite_outcomes->activiteid}")); if ($activite_old) { if (OUTCOMES_SUPER_DEBUG) { // DEBUG mtrace("\nDEBUG :: grade/cron_outcomes/referentiel_activite_outcomes :: 772\nOLD\n"); print_r($activite_old); mtrace("\n"); } // Verifier /* $mdata->submission=''; $mdata->comment=array(); $mdata->feedback=''; $mdata->file=array(); $mdata->link=array(); */ if (!empty($mdata)) { if (!empty($mdata->submission)) { if (!strpos($mdata->submission, $activite_old->description_activite)) { $activite->description_activite .= "\n" . get_string('submission', 'referentiel') . ' ' . $mdata->submission; } } if (!empty($mdata->comment)) { foreach ($mdata->comment as $acomment) { if (!strpos($acomment, $activite_old->description_activite)) { $activite->description_activite .= "\n" . $acomment; } } } if (!empty($mdata->feedback)) { if (!empty($activite_old->commentaire_activite)) { if (!strpos($mdata->feedback, $activite_old->commentaire_activite)) { $activite->commentaire_activite .= "\n" . $mdata->feedback; } } else { $activite->commentaire_activite .= $mdata->feedback; } } } $activite->description_activite = addslashes($activite->description_activite); $activite->commentaire_activite = addslashes($activite->commentaire_activite); // fusionner l'activite $activite->id = $activite_old->id; $activite->date_modif_student = $activite_old->date_modif_student; if (!$activite->date_modif) { $activite->date_modif = time(); } // $activite->approved=$activite_old->approved; $activite->approved = 1; if (empty($activite_old->date_modif) || $activite_old->date_modif < $activite->date_modif) { // DEBUG // print_object($activite); // echo "<br />"; if ($DB->update_record("referentiel_activite", $activite)) { referentiel_mise_a_jour_competences_certificat_user($activite_old->competences_activite, $activite->competences_activite, $activite->userid, $activite->ref_referentiel, $activite->approved, true, $activite->approved); $activite_id = $activite->id; // Bareme if ($CFG->referentiel_use_scale && !empty($liste_bareme_evaluations)) { if (OUTCOMES_SUPER_DEBUG) { // DEBUG mtrace("\nLINE 802 :: BAREME :: {$liste_bareme_evaluations}"); } referentiel_enregistrer_ce_bareme_activite($liste_bareme_evaluations, referentiel_get_liste_codes_competence($activite->ref_referentiel), $activite_id, referentiel_get_bareme_id_occurrence($activite->ref_referentiel)); } if (!empty($mdata)) { if (!empty($mdata->link)) { // Portland version of assign mahara plugin foreach ($mdata->link as $alink) { if (!empty($alink)) { if (OUTCOMES_SUPER_DEBUG) { // DEBUG mtrace("\nDEBUG :: grade/cron_outcomes/referentiel_activite_outcomes :: 1129 :: link DOCUMENT \n"); print_r($alink); } $url = addslashes(referentiel_get_mahara_link($alink)); if (!($document_old = $DB->get_record("referentiel_document", array("url_document" => $url, "ref_activite" => $activite_id)))) { $document = new object(); $document->url_document = $url; $document->type_document = addslashes(substr(get_string('mahara', 'referentiel'), 0, 20)); $document->description_document = get_string('mahara', 'referentiel'); $document->ref_activite = $activite_id; $document->cible_document = 1; $document->etiquette_document = addslashes($alink->title); // DEBUG // print_r($document); // echo "<br />"; $document_id = $DB->insert_record("referentiel_document", $document); // echo "DOCUMENT ID / $document_id<br />"; } } } } if (!empty($mdata->file)) { foreach ($mdata->file as $afile) { if (!empty($afile) && $afile->filename != '.' && $afile->filesize > 0) { if (OUTCOMES_SUPER_DEBUG) { // DEBUG mtrace("\nDEBUG :: grade/cron_outcomes/referentiel_activite_outcomes :: 1104 :: FILE DOCUMENT \n"); print_r($afile); } $url = addslashes(referentiel_url_file($afile)); if (!($document_old = $DB->get_record("referentiel_document", array("url_document" => $url, "ref_activite" => $activite_id)))) { $document = new object(); $document->url_document = $url; $document->type_document = addslashes(substr(get_string('document', 'referentiel'), 0, 20)); $document->description_document = get_string('assignementdoc', 'referentiel'); $document->ref_activite = $activite_id; $document->cible_document = 1; $document->etiquette_document = addslashes($afile->filename); // DEBUG // print_r($document); // echo "<br />"; $document_id = $DB->insert_record("referentiel_document", $document); // echo "DOCUMENT ID / $document_id<br />"; } } } } } return true; } } } else { // Cette activite a ete supprimee // Supprimer la ligne qui n'a plus de correspondance dans les activites $DB->delete_records("referentiel_activite_modules", array("id" => "{$r_activite_outcomes->id}")); } } else { if (OUTCOMES_SUPER_DEBUG) { // DEBUG mtrace("\nDEBUG :: grade/cron_outcomes/referentiel_activite_outcomes :: 786 :: NEW ACTIVITY\n"); print_r($activite); mtrace("\n"); } /* $mdata->submission=''; $mdata->comment=array(); $mdata->feedback=''; $mdata->file=array(); */ if (!empty($mdata)) { if (!empty($mdata->submission)) { $activite->description_activite .= "\n" . get_string('submission', 'referentiel') . ' ' . $mdata->submission; } if (!empty($mdata->comment)) { foreach ($mdata->comment as $acomment) { $activite->description_activite .= "\n" . $acomment; } } if (!empty($mdata->feedback)) { $activite->commentaire_activite .= $mdata->feedback; } } $activite->description_activite = addslashes($activite->description_activite); $activite->commentaire_activite = addslashes($activite->commentaire_activite); // inserer l'activité $activite_id = referentiel_insert_activite_controlee($activite); //if (($activite_id>0) && ($activite->competences_activite!='')){ if ($activite_id > 0) { // mise a jour du certificat referentiel_mise_a_jour_competences_certificat_user('', $activite->competences_activite, $activite->userid, $activite->ref_referentiel, $activite->approved, true, false); // Bareme if ($CFG->referentiel_use_scale && !empty($liste_bareme_evaluations)) { if (OUTCOMES_SUPER_DEBUG) { // DEBUG mtrace("\nLINE 838 :: BAREME :: {$liste_bareme_evaluations}"); } referentiel_enregistrer_ce_bareme_activite($liste_bareme_evaluations, referentiel_get_liste_codes_competence($activite->ref_referentiel), $activite_id, referentiel_get_bareme_id_occurrence($activite->ref_referentiel)); } } else { // inutile de créer cette activité car aucune compétence n'est validée if (OUTCOMES_SUPER_DEBUG) { // DEBUG mtrace("\nDEBUG :: grade/cron_outcomes/referentiel_activite_outcomes :: 848 :: \nINSERTION INUTILE CETTE ACTIVITE \n"); print_r($activite); mtrace("\n"); } } // Rajouter le lien if (isset($activite_id) && $activite_id > 0 && (isset($m->link) && !empty($m->link) || isset($m->name) && !empty($m->description))) { $document = new object(); $document->url_document = $m->link; $document->type_document = addslashes(substr(get_string('modulename', $m->type), 0, 20)); $document->description_document = get_string('assignementdoc', 'referentiel'); // addslashes($m->description); $document->ref_activite = $activite_id; $document->cible_document = 1; $document->etiquette_document = addslashes($m->name); $document_id = $DB->insert_record("referentiel_document", $document); } if (!empty($mdata)) { if (!empty($mdata->link)) { // portland version of assign mahara plugin foreach ($mdata->link as $alink) { if (!empty($alink)) { if (OUTCOMES_SUPER_DEBUG) { // DEBUG mtrace("\nDEBUG :: grade/cron_outcomes/referentiel_activite_outcomes :: 1263 :: link DOCUMENT \n"); print_r($alink); } $document = new object(); $document->url_document = addslashes(referentiel_get_mahara_link($alink)); $document->type_document = addslashes(substr(get_string('mahara', 'referentiel'), 0, 20)); $document->description_document = get_string('mahara', 'referentiel'); // addslashes($m->description); $document->ref_activite = $activite_id; $document->cible_document = 1; $document->etiquette_document = addslashes($alink->title); $document_id = $DB->insert_record("referentiel_document", $document); } } } if (!empty($mdata->file)) { foreach ($mdata->file as $afile) { if (!empty($afile) && $afile->filename != '.' && $afile->filesize > 0) { if (OUTCOMES_SUPER_DEBUG) { // DEBUG mtrace("\nDEBUG :: grade/cron_outcomes/referentiel_activite_outcomes :: 1216 :: FILE DOCUMENT \n"); print_r($afile); } $document = new object(); $document->url_document = addslashes(referentiel_url_file($afile)); $document->type_document = addslashes(substr(get_string('document', 'referentiel'), 0, 20)); $document->description_document = get_string('assignementdoc', 'referentiel'); // addslashes($m->description); $document->ref_activite = $activite_id; $document->cible_document = 1; $document->etiquette_document = addslashes($afile->filename); $document_id = $DB->insert_record("referentiel_document", $document); } } } } // if (isset($activite_id) && $activite_id > 0) { // $r_a_outcomes = new object(); $r_a_outcomes->activiteid = $activite_id; $r_a_outcomes->ref_course = $activite->ref_course; $r_a_outcomes->ref_instance = $activite->ref_instance; $r_a_outcomes->ref_referentiel = $activite->ref_referentiel; $r_a_outcomes->userid = $activite->userid; $r_a_outcomes->type = $m->type; $r_a_outcomes->moduleid = $m->id; $r_a_outcomes->ref_activite = $m->ref_activite; $DB->insert_record("referentiel_activite_modules", $r_a_outcomes); return true; } } return false; }
function referentiel_get_scale_info($occurrenceid) { global $CFG; global $DB; $scale_info = new stdClass(); // Default values $scale_info->name = get_string('nom_bareme', 'referentiel'); $scale_info->grades = get_string('bareme', 'referentiel'); $scale_info->description = get_string('description_bareme', 'referentiel'); $scale_info->nbvalues = 3; $scale_info->values = array(); $agrade = new stdClass(); $agrade->default = 0; $agrade->proficient = 0; $scale_info->values[] = $agrade; $agrade = new stdClass(); $agrade->default = 0; $agrade->proficient = 0; $scale_info->values[] = $agrade; $agrade = new stdClass(); $agrade->default = 1; // la valeur par defaut en cas de validation automatique $agrade->proficient = 1; // le seul qui valide la competence $scale_info->values[] = $agrade; if ($CFG->referentiel_use_scale) { // Bareme if ($baremeid = referentiel_get_bareme_id_occurrence($occurrenceid)) { if ($sbareme = $DB->get_record('referentiel_scale', array('id' => $baremeid))) { if ($scale = $DB->get_record('scale', array('id' => $sbareme->scaleid))) { // DEBUG // echo "<br />export_grade_outcomes.php :: 296 :: SCALE<br />\n"; // print_object($scale); $scale_info->name = $scale->name; $scale_info->grades = $scale->scale; $scale_info->description = mb_substr(strip_tags($scale->description), 0, 60); $scale_info->description = mb_substr($scale_info->description, 0, strrpos($scale_info->description, " ")); $scale_info->description .= ' (...)'; // Competency Framework needs more information // print_object($sbareme); $scale_info->values = array(); if ($grades = explode(',', $sbareme->scale)) { $scale_info->nbvalues = count($grades); for ($i = 0; $i < $scale_info->nbvalues; $i++) { $agrade = new stdClass(); if ($i >= $sbareme->threshold) { if ($i == $sbareme->threshold) { $agrade->default = 1; // la valeur par defaut en cas de validation automatique } else { $agrade->default = 0; } $agrade->proficient = 1; } else { $agrade->default = 0; $agrade->proficient = 0; } $scale_info->values[] = $agrade; // le seuil qui valide la competence } } } } } } return $scale_info; }