NxTIC/public_html/test/Lab-Surveys-Import.php

191 lines
4.6 KiB
PHP
Raw Normal View History

<?php
define('__ROOT__', dirname(dirname(dirname(__FILE__))) );
require_once __ROOT__.'/autoloader.php';
use \database\core\Repo;
use \database\core\DatabaseDriver;
use \orm\core\Table;
use \orm\core\Rows;
debug();
/* [2] Requests on lab-surveys
=========================================================*/
2016-11-05 16:41:42 +00:00
function fetchAllData(){
$lisst = Table::get('laboratoires', 'lab-surveys')
->whereIntitule('LISST');
$etudes = Table::get('etudes', 'lab-surveys')
->join('idLaboratoire', $lisst)
->orderby('idEtude')
->unique();
$fiches = Table::get('fiches', 'lab-surveys')
->select('idFiche')
->orderby('idFiche')
->join('idEtude', $etudes);
$questions = Table::get('questionsFiches', 'lab-surveys')
->select('idQuestionFiche')
->select('intitule', null, null, 'question')
->orderby('idQuestionFiche')
->join('idFiche', $fiches);
$repAtt = Table::get('reponsesAttenduesFiches', 'lab-surveys')
->select('intitule', Rows::SEL_CONCAT, null, 'possible')
->join('idQuestionFiche', $questions)
->orderby('idReponseAttendueFiche');
$sujets = Table::get('sujets', 'lab-surveys')
->select('idSujet')
->select('pseudo')
->orderby('idSujet');
$repSuj = Table::get('reponsesFiches', 'lab-surveys')
->select('intitule', null, null, 'reponse')
->join('idSujet', $sujets)
->join('idQuestionFiche', $repAtt);
var_dump( $repSuj->fetch() );
}
function fetchSujets(){
$lisst = Table::get('laboratoires', 'lab-surveys')
->whereIntitule('LISST');
2016-11-05 16:41:42 +00:00
$etudes = Table::get('etudes', 'lab-surveys')
->join('idLaboratoire', $lisst)
->orderby('idEtude')
->unique();
$sujets = Table::get('sujets', 'lab-surveys')
->select('idSujet')
->select('pseudo')
->join('idEtude', $lisst)
->orderby('idSujet');
var_dump( $sujets->fetch() );
}
function fetchNbQuestionsPerFiche(){
$lisst = Table::get('laboratoires', 'lab-surveys')
->whereIntitule('LISST');
2016-11-05 16:41:42 +00:00
$etudes = Table::get('etudes', 'lab-surveys')
->join('idLaboratoire', $lisst)
->orderby('idEtude')
->unique();
2016-11-05 16:41:42 +00:00
$fiches = Table::get('fiches', 'lab-surveys')
->select('idFiche')
->orderby('idFiche')
->join('idEtude', $etudes);
2016-11-05 16:41:42 +00:00
$questions = Table::get('questionsFiches', 'lab-surveys')
->select('idQuestionFiche', Rows::SEL_COUNT)
->join('idFiche', $fiches);
2016-11-05 16:41:42 +00:00
var_dump( $questions->fetch() );
}
function fetchFicheComplete(){
$lisst = Table::get('laboratoires', 'lab-surveys')
->whereIntitule('LISST');
$etudes = Table::get('etudes', 'lab-surveys')
->join('idLaboratoire', $lisst)
->orderby('idEtude')
->unique();
$fiche = Table::get('fiches', 'lab-surveys')
->select('idFiche')
->orderby('idFiche')
->join('idEtude', $etudes)
->unique();
$questions = Table::get('questionsFiches', 'lab-surveys')
->select('idQuestionFiche')
->select('intitule')
->orderby('idQuestionFiche')
->join('idFiche', $fiche);
$rep = Table::get('reponsesAttenduesFiches', 'lab-surveys')
->select('idReponseAttendueFiche', Rows::SEL_CONCAT, null, 'reponsesid')
->select('intitule', Rows::SEL_CONCAT, null, 'reponses')
->orderby('idReponseAttendueFiche')
->join('idQuestionFiche', $questions);
var_dump( $rep->fetch() );
}
function fetchRelations(){
$lisst = Table::get('laboratoires', 'lab-surveys')
->whereIntitule('LISST');
$etudes = Table::get('etudes', 'lab-surveys')
->join('idLaboratoire', $lisst)
->orderby('idEtude')
->unique();
$A = Table::get('sujets', 'lab-surveys')
2016-11-05 18:08:14 +00:00
->select('idSujet')
2016-11-05 16:41:42 +00:00
->join('idEtude', $lisst)
2016-11-05 18:08:14 +00:00
->orderby('idSujet')
->fetch();
$Ain = [];
foreach($A as $i=>$v)
$Ain[] = $v['idSujet'];
2016-11-05 16:41:42 +00:00
$B = Table::get('sujets', 'lab-surveys')
->join('idEtude', $lisst)
->orderby('idSujet');
$cate = Table::get('categoriesRelations', 'lab-surveys')
->select('intitule', null, null, 'categorie');
$rel = Table::get('relations', 'lab-surveys')
2016-11-05 18:08:14 +00:00
->select('idSujetA', Rows::SEL_CONCAT)
->select('idSujetB')
->select('knows')
->select('isEgo')
->where('idSujetA', [$Ain, Rows::COND_IN])
2016-11-05 16:41:42 +00:00
->join('idSujetB', $B)
->join('idCategorieRelation', $cate);
var_dump( $rel->fetch() );
}fetchRelations();
function idQuestionToKey($idQuestion){
switch($idQuestion){
case 3: return 'sexe'; break;
case 6: return 'studies1'; break;
case 5: return 'famsit'; break;
case 12: return 'context'; break;
case 7: return 'reltype'; break;
case 10: return 'dist'; break;
case 15: return 'freq[face]'; break;
case 16: return 'freq[skype]'; break;
case 17: return 'freq[sms]'; break;
case 18: return 'freq[mail]'; break;
case 19: return 'freq[facebook]'; break;
}
}
?>