function referentiel_traitement_notations() { // genere des declarations d'activites "fictives" a partir des notation par objectif // sur les activites du cours global $CFG; global $DB; global $scales; // all users that are subscribed to any post that needs sending $notations = array(); $scales = array(); $n_activites = 0; // Enregistrements anterieurs � 2 jours non traites. This is to avoid the problem where // cron has not been running for a long time $timenow = time(); if (NOTIFICATION_DELAI) { $endtime = $timenow - $CFG->maxeditingtime; } else { $endtime = $timenow; } // Enregistrements anterieurs a NOTIFICATION_INTERVALLE_JOUR jours non traites. // This is to avoid the problem where cron has not been running for a long time if (REFERENTIEL_DEBUG) { $starttime = $endtime - NOTIFICATION_INTERVALLE_JOUR * 7 * 24 * 3600; // Two weeks earlier } else { $starttime = $endtime - NOTIFICATION_INTERVALLE_JOUR * 24 * 3600; // n days earlier } $cron_timestamp = referentiel_get_cron_timestamp(); if (!empty($cron_timestamp)) { if (REFERENTIEL_DEBUG) { $starttime = min($starttime, $cron_timestamp - 60); } else { $starttime = max($starttime, $cron_timestamp - 60); } } $scales_list = ''; // for items with a scaleid // users $users = array(); $users_list = ''; // JF // DEBUG mtrace("\nDEBUT CRON OBJECTIFS."); mtrace("\nSTART TIME : " . date("Y/m/d H:i:s", $starttime) . " END TIME : " . date("Y/m/d H:i:s", $endtime)); $notations = referentiel_get_outcomes($starttime, $endtime); //$notations=referentiel_get_outcomes_old($endtime); if ($notations) { foreach ($notations as $notation) { if ($notation) { if (OUTCOMES_SUPER_DEBUG) { mtrace("\nDEBUG :: grade/cron_outcomes.php Line 102 :: USERID " . $notation->userid . " ; COURSEID " . $notation->courseid . "\nNOTATION :\n"); print_r($notation); } if (!empty($notation->scaleid) && !preg_match("/ " . $notation->scaleid . "\\,/", $scales_list)) { $scales_list .= " {$notation->scaleid},"; } if (!empty($notation->userid) && !empty($notation->courseid)) { if (!preg_match("/ " . $notation->userid . "\\,/", $users_list)) { $users_list .= " {$notation->userid},"; $user = new Object(); $user->userid = $notation->userid; $user->courses = array(); $user->course_list = ''; $users[$notation->userid] = $user; } if (!preg_match("/ " . $notation->courseid . "\\,/", $users[$notation->userid]->course_list)) { $users[$notation->userid]->course_list .= " {$notation->courseid},"; $course = new Object(); $course->courseid = $notation->courseid; $course->referentiel_list = ''; $course->referentiels = array(); $users[$notation->userid]->courses[$notation->courseid] = $course; } if (!preg_match("/ " . $notation->referentiel_instanceid . "\\,/", $users[$notation->userid]->courses[$notation->courseid]->referentiel_list)) { $users[$notation->userid]->courses[$notation->courseid]->referentiel_list = " {$notation->referentiel_instanceid},"; $referentiel = new object(); $referentiel->referentiel_instanceid = $notation->referentiel_instanceid; $referentiel->ref_referentiel = $notation->ref_referentiel; $referentiel->module_list = ''; $referentiel->modules = array(); // $referentiel->referentiels[$notation->referentiel_instanceid]->outcome_list = ''; $users[$notation->userid]->courses[$notation->courseid]->referentiels[$notation->referentiel_instanceid] = $referentiel; } if (empty($users[$notation->userid]->courses[$notation->courseid]->referentiels[$notation->referentiel_instanceid]->module_list) || !preg_match("/ " . $notation->module . ":" . $notation->moduleinstance . "\\,/", $users[$notation->userid]->courses[$notation->courseid]->referentiels[$notation->referentiel_instanceid]->module_list)) { $users[$notation->userid]->courses[$notation->courseid]->referentiels[$notation->referentiel_instanceid]->module_list .= " {$notation->module}:{$notation->moduleinstance},"; $module = new object(); $module->modulename = $notation->module; $module->moduleinstance = $notation->moduleinstance; $module->teacherid = $notation->teacherid; // MODIF JF 2012/01/31 $module->outcome_list = ''; $module->scaleid_list = ''; $module->timemodified_list = ''; $users[$notation->userid]->courses[$notation->courseid]->referentiels[$notation->referentiel_instanceid]->modules[$notation->moduleinstance] = $module; } if (!empty($users[$notation->userid]->courses[$notation->courseid]->referentiels[$notation->referentiel_instanceid]->modules[$notation->moduleinstance])) { // les notes if ($notation->outcomeshortname != '') { $users[$notation->userid]->courses[$notation->courseid]->referentiels[$notation->referentiel_instanceid]->modules[$notation->moduleinstance]->outcome_list .= " {$notation->outcomeshortname}:{$notation->finalgrade},"; $users[$notation->userid]->courses[$notation->courseid]->referentiels[$notation->referentiel_instanceid]->modules[$notation->moduleinstance]->scaleid_list .= " {$notation->scaleid},"; $users[$notation->userid]->courses[$notation->courseid]->referentiels[$notation->referentiel_instanceid]->modules[$notation->moduleinstance]->timemodified_list .= " {$notation->timemodified},"; } } } } } } if (!empty($users)) { // DEBUG if (OUTCOMES_SUPER_DEBUG) { mtrace("\nDEBUG :: grade/cron_outcomes.php Line 171 :: USERS \n"); print_r($users); } foreach ($users as $user) { if (OUTCOMES_SUPER_DEBUG) { mtrace("\nDEBUG :: grade/cron_outcomes.php Line 178 :: USER \n"); print_r($user); } foreach ($user->courses as $course) { // echo "<br />COURSE_ID $course->courseid; \n"; foreach ($course->referentiels as $referentiel) { // echo "<br />REFERENTIEL_INSTANCE $referentiel->referentiel_instanceid; REFERENTIEL_ID $referentiel->ref_referentiel\n"; // MODIF JF 2013/08/05 // bareme $threshold = -1; if ($CFG->referentiel_use_scale) { if ($bareme = referentiel_get_bareme_occurrence($referentiel->ref_referentiel)) { $threshold = $bareme->threshold; } } foreach ($referentiel->modules as $module) { // echo "<br />MODULE $module->modulename ; Instance $module->moduleinstance ; \n"; // preparer l'enregistrement // DEBUG // echo "<br />DEBUG :: 180 ; MODULE : $module->modulename, INSTANCE : $module->moduleinstance, COURS : $course->courseid\n"; if ($module && !empty($module->modulename) && !empty($module->moduleinstance) && !empty($course->courseid)) { $m = referentiel_get_module_info($module->modulename, $module->moduleinstance, $course->courseid); /* // module $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; */ // DEBUG if (OUTCOMES_SUPER_DEBUG) { mtrace("\nDEBUG :: grade/cron_outcomes.php Line 184 :: MODULE \n"); print_r($m); } $activite = new Object(); $activite->type_activite = '[' . get_string('outcome_type', 'referentiel') . ' ' . get_string('modulename', $m->type) . ' ' . $m->ref_activite . '] ' . get_string('outcome_date', 'referentiel') . ' ' . $m->userdate; $activite->description_activite = get_string('outcome_description', 'referentiel', $m); $activite->competences_activite = ''; $activite->commentaire_activite = ''; $activite->bareme_activite = ''; $activite->ref_instance = $referentiel->referentiel_instanceid; $activite->ref_referentiel = $referentiel->ref_referentiel; $activite->ref_course = $course->courseid; $activite->userid = $user->userid; $activite->teacherid = $module->teacherid; // MODIF JF 2013/02/04 $activite->date_creation = $m->date; $activite->date_modif_student = 0; $activite->date_modif = $m->date; $activite->approved = 1; // approuve par defaut $activite->ref_task = 0; // DEBUG /* if (OUTCOMES_SUPER_DEBUG){ mtrace("DEBUG :: grade/cron_outcomes.php Line 181 :: TIMEMODIFIED_LIST $module->timemodified_list\n"); } */ $t_datemodif = explode(',', $module->timemodified_list); sort($t_datemodif); $imax = count($t_datemodif) - 1; $timemodified = $t_datemodif[$imax]; if ($timemodified > $activite->date_creation) { //$activite->date_modif_student=$timemodified; $activite->date_modif = $timemodified; } // echo "<br />SCALE_LIST $module->scaleid_list\n"; $t_scales = explode(',', $module->scaleid_list); // echo "<br />OUTCOME_LIST $module->outcome_list\n"; $t_outcomes = explode(',', $module->outcome_list); $n = count($t_outcomes); if ($n > 0) { $i = 0; if (OUTCOMES_SUPER_DEBUG) { mtrace("\nDEBUG :: grade/cron_outcomes.php Line 264"); } $liste_bareme_activite = ''; while ($i < $n) { if ($t_outcomes[$i] != '') { list($cle, $val) = explode(':', $t_outcomes[$i]); $cle = trim($cle); $val = trim($val); $scaleid = $t_scales[$i]; if (OUTCOMES_SUPER_DEBUG) { mtrace("\nCODE : {$cle} ; VALEUR : {$val} ;"); } if ($threshold == -1) { $scale = referentiel_get_scale($scaleid); if ($val >= $scale->grademax) { // pas de bareme $activite->competences_activite .= $cle . '/'; if (OUTCOMES_SUPER_DEBUG) { mtrace(" ---> VALIDE \n"); } } } else { if ($val > $threshold) { // baremes $activite->competences_activite .= $cle . '/'; if (OUTCOMES_SUPER_DEBUG) { mtrace(" ---> VALIDE \n"); } } } $liste_bareme_activite .= $cle . ':' . (int) $val . '/'; } $i++; } } } // MODIF JF 2014/02/05 // completer avec des informations obtenues dans l'activite $mdata = NULL; if ($m && $m->type == 'assign') { $mdata = referentiel_get_assign($m, $user->userid); if (!empty($mdata)) { // DEBUG if (OUTCOMES_SUPER_DEBUG) { mtrace("\nDEBUG :: grade/cron_outcomes.php Line 226 :: MODULE \n"); print_r($mdata); } } } // enregistrer l'activite // DEBUG if (OUTCOMES_SUPER_DEBUG) { mtrace("\nDEBUG :: grade/cron_outcomes.php Line 313 ; ACTIVITE\n"); print_r($activite); } if (referentiel_activite_outcomes($activite, $m, $liste_bareme_activite, $mdata)) { if (OUTCOMES_SUPER_DEBUG) { mtrace("\nDEBUG :: grade/cron_outcomes.php Line 265\n-----------------\nACTIVITE ENREGISTREE\n"); } $n_activites++; } } } } } } // echo "<br />\n"; mtrace($n_activites . ' ACTIVITES CREES OU MODIFIEES.'); mtrace('FIN CRON REFERENTIEL OBJECTIFS.'); }
$occurrence_object = new occurrence($params); require_capability('mod/referentiel:export', $context); if (empty($exportfilename)) { $exportfilename = "compfrwrk_" . referentiel_default_export_filename($occurrence_object->referentiel->code_referentiel) . '-comma_separated.csv'; } // $systemcontext = get_context_instance(CONTEXT_SYSTEM); header("Content-Type: text/csv; charset=utf-8"); header("Content-Disposition: attachment; filename={$exportfilename}"); // sending header with clear names, to make 'what is what' as easy as possible to understand //$header = array('outcome_name', 'outcome_shortname', 'outcome_description', 'scale_name', 'scale_items', 'scale_description'); $header = array("Parent id number", "Id number", 'Shortname', 'Description', "Description format", "Scale values", "Scale configuration", "Rule type (optional)", "Rule outcome (optional)", "Rule config (optional)", "Cross referenced competency id numbers", "Exported id (optional)", "Is framework", 'Taxonomy'); echo format_csv($header, ',', '"'); // scale used with these outcomes $scale_info = referentiel_get_scale_info($occurrence_object->referentiel->id); $outcomes = array(); $outcomes = referentiel_get_outcomes($occurrence_object->referentiel, $scale_info); /* "Parent id number","Id number",Shortname,Description,"Description format","Scale values","Scale configuration","Rule type (optional)","Rule outcome (optional)","Rule config (optional)","Cross referenced competency id numbers","Exported id (optional)","Is framework",Taxonomy ,C2i0,C2i,"<p>Certification Internet<br></p>",1,"Non pertinent,Non validé,Validé","[{""scaleid"":""1""},{""id"":2,""scaledefault"":1,""proficient"":0},{""id"":3,""scaledefault"":0,""proficient"":1}]",,,,,,1,"domain,competency,skill,value" ,C2i0ET,"Environnement de travail","<p>Maîtrise de l'environnement de travail personnel<br /></p>",1,"Non pertinent,Non validé,Validé","[{""scaleid"":""1""},{""id"":2,""scaledefault"":1,""proficient"":0},{""id"":3,""scaledefault"":0,""proficient"":1}]","core_competency\competency_rule_points",2,"{""base"":{""points"":2},""competencies"":[{""id"":2,""points"":2,""required"":1}]}",,1,, C2i0ET,C2i0ETPoste,"Gestion du poste de travail","<p>Je sais allumer, éteindre et entretenir mon poste de travail<br /></p>",1,,,"core_competency\competency_rule_points",2,"{""base"":{""points"":2},""competencies"":[{""id"":3,""points"":1,""required"":1},{""id"":4,""points"":1,""required"":1}]}",,2,, C2i0ETPoste,C2i0ETPosteFichiers,"Gestion des fichiers","<p>Je sais organiser , déposer et retrouver mes données et fichiers<br></p>",1,,,,0,null,,3,, C2i0ETPoste,C2i0ETGestionReseau,"Travail en réseau","<p>Je sais me connecter au réseau et échanger des fichiers<br></p>",1,,,,0,null,,4,, */ foreach ($outcomes as $outcome) { $line = array(); // purger les caracteres separateurs qui seraint dans les textes $line[] = $outcome->parentid; // 1 $line[] = $outcome->idnumber; // 2
} */ // ensure the files area exists for this course // Inutile car pas de sauvegarde dans les donn�es du cours. // make_upload_directory( "$course->id/$CFG->moddata/referentiel" ); if (empty($exportfilename)) { $exportfilename = "outcomes_" . referentiel_default_export_filename($referentiel_referentiel->code_referentiel) . '.csv'; } $systemcontext = context_system::instance(); header("Content-Type: text/csv; charset=utf-8"); header("Content-Disposition: attachment; filename={$exportfilename}"); // sending header with clear names, to make 'what is what' as easy as possible to understand $header = array('outcome_name', 'outcome_shortname', 'outcome_description', 'scale_name', 'scale_items', 'scale_description'); echo format_csv($header, ';', '"'); $outcomes = array(); $outcomes = referentiel_get_outcomes($referentiel_referentiel); // scale used with these outcomes $scale_info = referentiel_get_scale_info($referentiel_referentiel->id); /* outcome_name;outcome_shortname;outcome_description;scale_name;scale_items;scale_description; C2i2e A.1.1;A.1.1;A.1.1 : Identifier les personnes ressources TIC et leurs rôles respectifs dans l'école ou l'établissement, et en dehors (circonscription, bassin, Académie, niveau national...) ;Item référentiel;Non acquis,En cours d'acquisition,Acquis;Ce barème est destiné à évaluer (noter) les items de compétences du module référentiel. C2i2e A.1.2 A.1.2 A.1.2 S'approprier les différentes composantes informatiques (lieux, outils...) de son environnement professionnel Item référentiel Non acquis,En cours d'acquisition,Acquis Ce barème est destiné à évaluer (noter) les items de compétences du module référentiel. */ foreach ($outcomes as $outcome) { $line = array(); // purger les caracteres separateurs $line[] = str_replace(';', ',', $outcome->name); $line[] = str_replace(';', ',', $outcome->shortname); $line[] = str_replace(';', ',', $outcome->description); $line[] = $scale_info->name; $line[] = $scale_info->grades;
} require_login($course); $params = array("blockid" => $blockid, "courseid" => $courseid, "occurrenceid" => $occurrenceid); $occurrence_object = new occurrence($params); require_capability('mod/referentiel:export', $context); if (empty($exportfilename)) { $exportfilename = "outcomes_" . referentiel_default_export_filename($occurrence_object->referentiel->code_referentiel) . '.csv'; } // $systemcontext = get_context_instance(CONTEXT_SYSTEM); header("Content-Type: text/csv; charset=utf-8"); header("Content-Disposition: attachment; filename={$exportfilename}"); // sending header with clear names, to make 'what is what' as easy as possible to understand $header = array('outcome_name', 'outcome_shortname', 'outcome_description', 'scale_name', 'scale_items', 'scale_description'); echo format_csv($header, ';', '"'); $outcomes = array(); $outcomes = referentiel_get_outcomes($occurrence_object->referentiel); // scale used with these outcomes $scale_info = referentiel_get_scale_info($occurrence_object->referentiel->id); /* outcome_name;outcome_shortname;outcome_description;scale_name;scale_items;scale_description; C2i2e A.1.1;A.1.1;A.1.1 : Identifier les personnes ressources TIC et leurs rôles respectifs dans l'école ou l'établissement, et en dehors (circonscription, bassin, Académie, niveau national...) ;Item référentiel;Non acquis,En cours d'acquisition,Acquis;Ce barème est destiné à évaluer (noter) les items de compétences du module référentiel. C2i2e A.1.2 A.1.2 A.1.2 S'approprier les différentes composantes informatiques (lieux, outils...) de son environnement professionnel Item référentiel Non acquis,En cours d'acquisition,Acquis Ce barème est destiné à évaluer (noter) les items de compétences du module référentiel. */ foreach ($outcomes as $outcome) { $line = array(); // purger les caracteres separateurs $line[] = str_replace(';', ',', $outcome->name); $line[] = str_replace(';', ',', $outcome->shortname); $line[] = str_replace(';', ',', $outcome->description); $line[] = $scale_info->name; $line[] = $scale_info->grades;