wiki->UserIsAdmin() || $this->wiki->UserIsInGroup('indicateurs')) { $period = $this->getGlobalPeriod(); $this->communities = [ 'doctorants' => [ 'title'=> "Doctorants", 'idcommu'=>'Doc', 'indicators' => [], ], 'ecocloud' => [ 'title'=> "Ecocloud", 'idcommu'=>'EcoC', 'indicators' => [], ], 'ingetech' => [ 'title'=> "IngéTech", 'idcommu'=>'IngeTech', 'indicators' => [], ], 'shs' => [ 'title'=> "Sciences Humaines et Sociales", 'idcommu'=>'SHS', 'indicators' => [], ], 'fabadd' => [ 'title'=> "FabAdd-Académie", 'idcommu'=>'FabAdd', 'indicators' => [], ], 'reseaucentral' => [ 'title'=> "Réseau central", 'idcommu'=>'ResC', 'indicators' => [], ] ]; $community = $this->wiki->GetParameter('community'); // on vide les autres commus if (!empty($community) and in_array($community, array_keys($this->communities))) { $onlyCommunity = $this->communities[$community]; $this->communities = []; $this->communities[$community] = $onlyCommunity; } $this->indicateurs = [ 'nb_annuaire' => [ 'name' => '👫🏻👩🏻‍🤝‍👩🏾👨🏾‍🤝‍👨🏽 Nombre d\'inscrits de l\'annuaire', 'formsIds' => [60,18,54,15,57], 'queries' => ['checkboxListeCommunautesbf_checkbox_inscription_commus' => '{idcommu}'], 'type' => 'bazar' ], 'nb_annuaire_ecocloud' => [ 'name' => '👫🏻👩🏻‍🤝‍👩🏾👨🏾‍🤝‍👨🏽 Nombre d\'inscrits de l\'annuaire du wiki Ecocloud', 'url' => 'https://ecocloud.s-mart.fr/?api/forms/1/entries', 'type' => 'bazarapi', 'onlyfor' => 'ecocloud' ], 'nb_besoins_non-resolus' => [ 'name' => '🙏🏻 Nombre de besoins Non résolus déposés', 'formsIds' => [51,53,22,58], 'queries' => [ 'checkboxListeCommunautesbf_checkbox_besoin_commu' => '{idcommu}', "listeListeEtatDuBesoinbesoin_etat" => "NR", ], 'type' => 'bazar' ], 'nb_besoins_en-cours-resolution' => [ 'name' => '🙏🏻 Nombre de besoins En cours de résolution déposés', 'formsIds' => [51,53,22,58], 'queries' => [ 'checkboxListeCommunautesbf_checkbox_besoin_commu' => '{idcommu}', "listeListeEtatDuBesoinbesoin_etat" => "ECR", ], 'type' => 'bazar' ], 'nb_besoins_part-resolus' => [ 'name' => '🙏🏻 Nombre de besoins Partiellement résolus déposés', 'formsIds' => [51,53,22,58], 'queries' => [ 'checkboxListeCommunautesbf_checkbox_besoin_commu' => '{idcommu}', "listeListeEtatDuBesoinbesoin_etat" => "PR", ], 'type' => 'bazar' ], 'nb_besoins_resolus' => [ 'name' => '🙏🏻 Nombre de besoins résolus déposés', 'formsIds' => [51,53,22,58], 'queries' => [ 'checkboxListeCommunautesbf_checkbox_besoin_commu' => '{idcommu}', "listeListeEtatDuBesoinbesoin_etat" => "R", ], 'type' => 'bazar' ], 'nb_besoins_total' => [ 'name' => '🙏🏻 Nombre total de besoins déposés', 'formsIds' => [51,53,22,58], 'queries' => [ 'checkboxListeCommunautesbf_checkbox_besoin_commu' => '{idcommu}', ], 'type' => 'bazar' ], 'nb_ressources_tech' => [ 'name' => '📚 Nombre de ressources Techno déposées', 'formsIds' => [4,24,61,21,20,23,55], 'queries' => [ 'checkboxListeCommunautesbf_checkbox_commu_ress' => '{idcommu}', 'checkboxListeConditionnelleRessourcebf_checkbox_categorie_ressource' => 'Tech' ], 'type' => 'bazar' ], 'nb_ressources_peda' => [ 'name' => '📚 Nombre de ressources Pédagogiques déposées', 'formsIds' => [4,24,61,21,20,23,55], 'queries' => [ 'checkboxListeCommunautesbf_checkbox_commu_ress' => '{idcommu}', 'checkboxListeConditionnelleRessourcebf_checkbox_categorie_ressource' => 'Peda' ], 'type' => 'bazar' ], 'nb_ressources_science' => [ 'name' => '📚 Nombre de ressources Scientifiques déposées', 'formsIds' => [4,24,61,21,20,23,55], 'queries' => [ 'checkboxListeCommunautesbf_checkbox_commu_ress' => '{idcommu}', 'checkboxListeConditionnelleRessourcebf_checkbox_categorie_ressource' => 'Sci' ], 'type' => 'bazar' ], 'nb_ressources_autres' => [ 'name' => '📚 Nombre de ressources autres déposées', 'formsIds' => [4,24,61,21,20,23,55], 'queries' => [ 'checkboxListeCommunautesbf_checkbox_commu_ress' => '{idcommu}', 'checkboxListeConditionnelleRessourcebf_checkbox_categorie_ressource' => 'Other' ], 'type' => 'bazar' ], 'nb_ressources_total' => [ 'name' => '📚 Nombre total de ressources déposées', 'formsIds' => [4,24,61,21,20,23,55], 'queries' => [ 'checkboxListeCommunautesbf_checkbox_commu_ress' => '{idcommu}', ], 'type' => 'bazar' ], 'nb_agenda' => [ 'name' => '📆 Nombre total d\'événements déposés dans l\'agenda', 'formsIds' => [2,59,17,13,56], 'queries' => [ 'checkboxListeCommunautesbf_checkbox_evenement_commu' => '{idcommu}', ], 'type' => 'bazar' ], 'nb_amelioration_total' => [ 'name' => '🛠️ Nombre total d’améliorations du site déposées', 'url' => 'https://reseau.s-mart.fr/doctorants/?api/forms/23/entries', 'type' => 'bazarapi', 'onlyfor' => 'doctorants' ], 'nb_amelioration_non_resolu' => [ 'name' => '🛠️ Nombre d’améliorations du site non-résolues', 'url' => 'https://reseau.s-mart.fr/doctorants/?api/forms/23/entries&query=listeListeSuggestionStatusbf_statut_improvement=U', 'type' => 'bazarapi', 'onlyfor' => 'doctorants' ], 'nb_amelioration_dev' => [ 'name' => '🛠️ Nombre d’améliorations du site "demander aux développeurs"', 'url' => 'https://reseau.s-mart.fr/doctorants/?api/forms/23/entries&query=listeListeSuggestionStatusbf_statut_improvement=AD', 'type' => 'bazarapi', 'onlyfor' => 'doctorants' ], 'nb_amelioration_resolu' => [ 'name' => '🛠️ Nombre d’améliorations du site résolus', 'url' => 'https://reseau.s-mart.fr/doctorants/?api/forms/23/entries&query=listeListeSuggestionStatusbf_statut_improvement=OK', 'type' => 'bazarapi', 'onlyfor' => 'doctorants' ], 'nb_contribs-page_total' => [ 'name' => '📝 Nombre de contributions aux pages', 'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE user IN {commuusers}', 'type' => 'sql', ], 'nb_contribs-page_total' => [ 'name' => '📝 Nombre total de contributions aux pages', 'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE 1', 'type' => 'sql', ], 'nb_contribs-page_ariane' => [ 'name' => '📝 Nombre de contributions aux pages par le groupe Ariane', 'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE user IN {groupariane}', 'type' => 'sql', ], 'nb_contribs-page_anim' => [ 'name' => '📝 Nombre de contributions aux pages par le groupe Animateurs', 'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE user IN {groupanim}', 'type' => 'sql', ], 'nb_contribs-page_other' => [ 'name' => '📝 Nombre de contributions aux pages par d\'autres contributeurs', 'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE user NOT IN {groupanim} AND user NOT IN {groupariane}', 'type' => 'sql', ], 'nb_comments-total' => [ 'name' => '💬 Nombre total de commentaires', 'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE 1', 'type' => 'sql', ], 'nb_comments-ressources' => [ 'name' => '💬 Nombre de commentaires sur les ressources', 'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE comment_on != ""', 'type' => 'sql', ], //todo 'nb_reactions-ressources-total' => [ 'name' => '📚 Nombre total de ressources qualifiées', 'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE 1', 'type' => 'sql', ], 'nb_reactions-ressources-relues' => [ 'name' => '📚 Nombre total de ressources relues', 'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE 1', 'type' => 'sql', ], 'nb_reactions-ressources-reutilisees' => [ 'name' => '📚 Nombre total de ressources réutilisées', 'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE 1', 'type' => 'sql', ], 'nb_reactions-meme-besoin' => [ 'name' => '🙏🏻 Nombre de "J\'ai le même besoin"', 'sql_query' => 'SELECT count(id) FROM '.$this->wiki->config['table_prefix'].'pages WHERE 1', 'type' => 'sql', ], // - Nombre de téléchargements des ressources de cette communauté Se baser sur bf_checkbox_commu_ress + bf_fichier_ressource // - Nombre de vues de l'ensemble des ressources directement intégrées aux fiches ressources réaction « relue » Se baser sur bf_checkbox_commu_ress + nb de clics sur les fiches du formulaire ressource / communauté ET checkbox_besoin_commu + besoins/communauté // - Nombre de clics sur liens web des ressources Se baser sur bf_checkbox_commu_ress + bf_url_ressource // Commentaires - Sur améliorations du site Commentaires des fiches du formulaire 23 dans le wiki Doctorants // Partage et diffusion des ressources // - - Delta qualifiées/non qualifiées // TODO : // finir les stats // modification par la commu des pages du wiki central // verifier si table des pages avec nb contrib nb commentaires et nb reactions // mettre les affichages par communautés // Emoji https://reseau.s-mart.fr/?RecupererLesLiensDesFluxRssDeMonChoixS // revoir les ecarts type mensuel ]; $period = [ 'deb'=> $_GET['datedeb'] ?? $period['deb'], 'end' => $_GET['datefin'] ?? $period['end'] ]; foreach($this->communities as $k => $com) { foreach($this->indicateurs as $i => $ind) { if ($ind['type'] == 'bazar') { $this->calculateBazarIndicators($i, $k, $period); } if ($ind['type'] == 'bazarapi') { if ($ind['onlyfor'] == $k) { $this->calculateBazarApiIndicators($i, $k, $period); } } if ($ind['type'] == 'sql') { $this->calculateSqlIndicators($i, $k, $period); } } } $total = []; if (count($this->communities) > 1) { $total = $this->calculateTotal(); } return $this->render('@templates/tablestats.twig', [ 'indicateurs'=> $this->indicateurs, 'communities'=> $this->communities, 'period' => $period, 'selecteddatedeb' => $_GET['datedeb'] ?? $period['deb'], 'selecteddatefin' => $_GET['datefin'] ?? $period['end'], 'total' => $total, 'wiki' => $_GET['wiki'] ?? $this->wiki->getPageTag() ]); } else { return $this->render('@templates/alert-message.twig', [ 'type'=>'danger', 'message'=> _t('Page réservée aux admins') ]); } } public function calculateTotal() { $total = []; foreach($this->communities['reseaucentral']['indicators'] as $k => $ind) { $valcommuperiod = [ $this->communities['doctorants']['indicators'][$k]['periodvalue'], $this->communities['ecocloud']['indicators'][$k]['periodvalue'], $this->communities['ingetech']['indicators'][$k]['periodvalue'], $this->communities['shs']['indicators'][$k]['periodvalue'], $this->communities['fabadd']['indicators'][$k]['periodvalue'], $this->communities['reseaucentral']['indicators'][$k]['periodvalue'], ]; $valcommutotal = [ $this->communities['doctorants']['indicators'][$k]['totalvalue'], $this->communities['ecocloud']['indicators'][$k]['totalvalue'], $this->communities['ingetech']['indicators'][$k]['totalvalue'], $this->communities['shs']['indicators'][$k]['totalvalue'], $this->communities['fabadd']['indicators'][$k]['totalvalue'], $this->communities['reseaucentral']['indicators'][$k]['totalvalue'], ]; $total[$k]['title'] = $ind['title']; $total[$k]['periodvalue'] = array_sum($valcommuperiod); $total[$k]['ecarttype'] = $this->calculateEcartType($valcommuperiod); $total[$k]['moyenne'] = $this->calculateMoyenne($valcommuperiod); $total[$k]['totalvalue'] = array_sum($valcommutotal); $total[$k]['totalecarttype'] = $this->calculateEcartType($valcommutotal); $total[$k]['totalmoyenne'] = $this->calculateMoyenne($valcommutotal); } return $total; } public function calculateBazarIndicators($idIndicator, $community, $period) { $indic = $this->indicateurs[$idIndicator]; foreach($indic['queries'] as $id => $val) { $indic['queries'][$id] = str_replace('{idcommu}', $this->communities[$community]['idcommu'], $val); } $res = $this->getService(EntryManager::class)->search($indic); $filterPeriod = []; foreach($res as $i => $f) { $deb = new DateTime($period['deb']); $end = new DateTime($period['end']); $fiche = new DateTime($f['date_creation_fiche']); if ($deb < $fiche && $fiche < $end) { $filterPeriod[$i] = $f; } }; $this->communities[$community]['indicators'][$idIndicator]['periodvalue'] = count($filterPeriod); $this->communities[$community]['indicators'][$idIndicator]['totalvalue'] = count($res); $this->communities[$community]['indicators'][$idIndicator]['title'] = $indic['name']; } public function calculateBazarApiIndicators($idIndicator, $community, $period) { $indic = $this->indicateurs[$idIndicator]; $json = file_get_contents($indic['url']); $res = json_decode($json,true); $filterPeriod = []; foreach($res as $i => $f) { $deb = new DateTime($period['deb']); $end = new DateTime($period['end']); $fiche = new DateTime($f['date_creation_fiche']); if ($deb < $fiche && $fiche < $end) { $filterPeriod[$i] = $f; } }; $this->communities[$community]['indicators'][$idIndicator]['periodvalue'] = count($filterPeriod); $this->communities[$community]['indicators'][$idIndicator]['totalvalue'] = count($res); $this->communities[$community]['indicators'][$idIndicator]['title'] = $indic['name']; } public function calculateSqlIndicators($idIndicator, $community, $period) { $indic = $this->indicateurs[$idIndicator]; $res = []; $filterPeriod = []; foreach($res as $i => $f) { $deb = new DateTime($period['deb']); $end = new DateTime($period['end']); $fiche = new DateTime($f['time']); if ($deb < $fiche && $fiche < $end) { $filterPeriod[$i] = $f; } }; $this->communities[$community]['indicators'][$idIndicator]['periodvalue'] = rand(0,3); $this->communities[$community]['indicators'][$idIndicator]['totalvalue'] = rand(0,10); $this->communities[$community]['indicators'][$idIndicator]['title'] = $indic['name']; } public function getGlobalPeriod() { $sql = 'select date(min(time)) as deb, date(max(time)) as end from '.$this->wiki->config['table_prefix'].'pages'; return $this->getService(DbService::class)->loadSingle($sql); } public function getAllMonthsUntilToday($startDate) { $start = (new DateTime($startDate))->modify('first day of this month'); $end = (new DateTime('today'))->modify('first day of next month'); $interval = DateInterval::createFromDateString('1 month'); $period = new DatePeriod($start, $interval, $end); return $period; } public function arrondi($value, $precision = 4) { round((float) $value, $precision); } public function calculateMoyenne($values) { return array_sum($values) / count($values); } public function calculateEcartType($values) { $moyenne = $this->calculateMoyenne($values); $variances = []; foreach($values as $key => $val) { $variances[$key] = pow($val - $moyenne, 2); } $p =(count($values) - 1); if ($p >= 1) { return sqrt(array_sum($variances) / $p); } return null; } }