summaryrefslogtreecommitdiffstats
path: root/admin/survey/classes/surveyData/class.SurveyDataCollect.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/survey/classes/surveyData/class.SurveyDataCollect.php')
-rw-r--r--admin/survey/classes/surveyData/class.SurveyDataCollect.php490
1 files changed, 297 insertions, 193 deletions
diff --git a/admin/survey/classes/surveyData/class.SurveyDataCollect.php b/admin/survey/classes/surveyData/class.SurveyDataCollect.php
index 75cdd06..6014ca0 100644
--- a/admin/survey/classes/surveyData/class.SurveyDataCollect.php
+++ b/admin/survey/classes/surveyData/class.SurveyDataCollect.php
@@ -36,6 +36,8 @@ class SurveyDataCollect{
private $header_file_name = null; // Ime header datoteke
private $data_file_name = null; // Ime data datoteke
private $data_file_time = null; // datum zadnjega userja v data datoteki
+
+ private $new_line_seperator = null;
private $max_anketa_time = null; // datum zadnje spremembe v anketi
private $max_usr_time = null; // datum zadnje spremembe v tabelu userjev
@@ -189,11 +191,10 @@ class SurveyDataCollect{
$qry_survey = sisplet_query("SELECT *, UNIX_TIMESTAMP(edit_time) AS srv_edit_time FROM srv_anketa WHERE id='".$this->sid."'");
$this->survey = mysqli_fetch_assoc($qry_survey);
+ SurveyInfo::getInstance()->SurveyInit($this->sid);
+
// Aktivne tabele za podatke v bazi
- if ((int)$this->survey['db_table'] == 1)
- $this->db_table = '_active';
- else
- $this->db_table = '';
+ $this->db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString();
// Zadnji cas editiranja ankete
$this->max_anketa_time = (int)$this->survey['srv_edit_time'];
@@ -315,7 +316,7 @@ class SurveyDataCollect{
$_tmpCnt = 0;
// v loopu dodamo podatke v data file
- if ($this->noErrors && count($this->_str_users) > 0) {
+ if ($this->noErrors && is_countable($this->_str_users) && count($this->_str_users) > 0) {
foreach ($this->_str_users AS $c => $string_user) {
@@ -388,7 +389,7 @@ class SurveyDataCollect{
fclose($file_handler_new);
// Pobrisemo staro datoteko
- unlink($file_handler_old);
+ unlink($this->data_file_name);
// Preimenujemo novo datoteko
rename($data_file_name_new, $this->data_file_name);
@@ -475,6 +476,22 @@ class SurveyDataCollect{
$_HEADER['uid']['sequences'] = $sequence;
$sequence++;
$_data_sequence++;
+
+ // status uporabnika
+ $_HEADER['status']= array ('tip'=>'m', 'variable'=>'status', 'naslov' =>$lang['srv_data_status'],
+ 'grids' => array(0 => Array('variables'=>array(0 => Array ('variable'=>'status', 'naslov'=>$lang['srv_data_status'],'spss'=>'F3.0','sequence'=>$sequence))
+ ,'naslov'=>$lang['srv_data_status'],'cnt_vars' => 1)));
+ $_HEADER['status']['sequences'] = $sequence;
+ $sequence++;
+ $_data_sequence++;
+
+ // EMAIL VABILO - invitation
+ $_HEADER['invitation']= array ('tip'=>'m', 'variable'=>'invitation', 'naslov' =>$lang['srv_data_invitation'],
+ 'grids' => array(0 => Array('variables'=>array(0 => Array ('variable'=>'invitation', 'naslov'=>$lang['srv_data_invitation'],'spss'=>'F3.0','sequence'=>$sequence))
+ ,'naslov'=>$lang['srv_data_invitation'],'cnt_vars' => 1)));
+ $_HEADER['invitation']['sequences'] = $sequence;
+ $sequence++;
+ $_data_sequence++;
// ustreznost uporabnika
$_HEADER['relevance']= array ('tip'=>'m', 'variable'=>'relevance', 'naslov' =>$lang['srv_data_relevance'],
@@ -483,22 +500,6 @@ class SurveyDataCollect{
$_HEADER['relevance']['sequences'] = $sequence;
$sequence++;
$_data_sequence++;
-
- // EMAIL VABILO - invitation
- $_HEADER['invitation']= array ('tip'=>'m', 'variable'=>'invitation', 'naslov' =>$lang['srv_data_invitation'],
- 'grids' => array(0 => Array('variables'=>array(0 => Array ('variable'=>'invitation', 'naslov'=>$lang['srv_data_invitation'],'spss'=>'F3.0','sequence'=>$sequence))
- ,'naslov'=>$lang['srv_data_invitation'],'cnt_vars' => 1)));
- $_HEADER['invitation']['sequences'] = $sequence;
- $sequence++;
- $_data_sequence++;
-
- // status uporabnika
- $_HEADER['status']= array ('tip'=>'m', 'variable'=>'status', 'naslov' =>$lang['srv_data_status'],
- 'grids' => array(0 => Array('variables'=>array(0 => Array ('variable'=>'status', 'naslov'=>$lang['srv_data_status'],'spss'=>'F3.0','sequence'=>$sequence))
- ,'naslov'=>$lang['srv_data_status'],'cnt_vars' => 1)));
- $_HEADER['status']['sequences'] = $sequence;
- $sequence++;
- $_data_sequence++;
// ali je uporabnik lurker
$_HEADER['lurker']= array ('tip'=>'m', 'variable'=>'lurker', 'naslov' =>$lang['srv_data_lurker'],
@@ -517,23 +518,23 @@ class SurveyDataCollect{
$_data_sequence++;
// Recnum
- $_HEADER['recnum'] = array('tip'=>'m', 'variable'=>'recnum', 'naslov' =>'Record number',
- 'grids' => array(0 => Array('variables'=>array(0 => Array ('variable'=>'recnum','naslov'=>'Record number','spss'=>'F5.0','sortType'=>'number','sequence'=>$sequence)),
+ $_HEADER['recnum'] = array('tip'=>'m', 'variable'=>'recnum', 'naslov' =>$lang['srv_recnum'],
+ 'grids' => array(0 => Array('variables'=>array(0 => Array ('variable'=>'recnum','naslov'=>$lang['srv_recnum'],'spss'=>'F5.0','sortType'=>'number','sequence'=>$sequence)),
'naslov'=>'recnum','cnt_vars' => 1)));
$_HEADER['recnum']['sequences'] = $sequence;
$sequence++;
$_data_sequence++;
-
+
// Dodamo geslo - code
if ($this->force_show_hiden_system == true) {
- $_HEADER['code'] = array('tip'=>'m', 'variable'=>'code', 'naslov' =>'Geslo',
- 'grids' => array(0 => Array('variables'=>array(0 => Array ('variable'=>'code','naslov'=>'Geslo','spss'=>'A6','sequence'=>$sequence)),
- 'naslov'=>'Geslo','cnt_vars' => 1)));
+ $_HEADER['code'] = array('tip'=>'m', 'variable'=>'code', 'naslov' =>$lang['password'],
+ 'grids' => array(0 => Array('variables'=>array(0 => Array ('variable'=>'code','naslov'=>$lang['password'],'spss'=>'A6','sequence'=>$sequence)),
+ 'naslov'=>$lang['password'],'cnt_vars' => 1)));
$_HEADER['code']['sequences'] = $sequence;
$sequence++;
$_data_sequence++;
}
-
+
// Ce vsebuje testne podatke dodamo tudi to polje
if ($this->has_test_data) {
$_HEADER['testdata']= array ('tip'=>'m', 'variable'=>'testdata', 'naslov' =>$lang['srv_data_test'],
@@ -563,8 +564,6 @@ class SurveyDataCollect{
$_array_vrednosti = $this->get_vrednosti(); // za vrednosti ankete
$_array_gridi = $this->get_gridi(); // za vrednosti ankete
-
- $cntHs = 0;
// Stejemo loope za numeric vprasanje
$num_loop_cnt = array();
@@ -574,22 +573,28 @@ class SurveyDataCollect{
foreach ($this->AllQuestionsOrder AS $_vprasanje_array) {
- $cntHs++;
+ // Ce vrpasanje ni nastavljeno preskocimo
+ if(!isset($this->AllQuestionsData[$_vprasanje_array['id']]))
+ continue;
# dodelimo vrednosti loopa
$rowVprasanje = $this->AllQuestionsData[$_vprasanje_array['id']];
- // nastavimo vrstni red ce loopamo po numericu
- $num_loop_cnt[$_vprasanje_array['id']]++;
+ // nastavimo vrstni red ce loopamo po numericu
+ if(!isset($num_loop_cnt[$_vprasanje_array['id']]))
+ $num_loop_cnt[$_vprasanje_array['id']] = 1;
+ else
+ $num_loop_cnt[$_vprasanje_array['id']]++;
# spremenljivki dodamo loop_id da je konsistentno z podatki
$rowVprasanje['spr_id'] = $rowVprasanje['spr_id'].'_'.$_vprasanje_array['loop_id'];
- $_vrednosti = $this->get_vrednosti($this->_array_loop_on_spr[$rowVprasanje['if_id']]);
- $_loop_vrednost = $this->_array_vre_on_loop[$rowVprasanje['if_id']][$_vprasanje_array['loop_id']];
+ $loop_vre = isset($this->_array_loop_on_spr[$rowVprasanje['if_id']]) ? $this->_array_loop_on_spr[$rowVprasanje['if_id']] : null;
+ $_vrednosti = $this->get_vrednosti($loop_vre);
+ $_loop_vrednost = isset($this->_array_vre_on_loop[$rowVprasanje['if_id']][$_vprasanje_array['loop_id']]) ? $this->_array_loop_on_spr[$rowVprasanje['if_id']] : null;
$spr_id = $rowVprasanje['spr_id'];
$vrednostLoopSufix = '';
-
+
# popravimo ime variable če smo v loopu
if(isset($this->_array_vre_on_loop[$rowVprasanje['if_id']][$_vprasanje_array['loop_id']])) {
@@ -599,23 +604,28 @@ class SurveyDataCollect{
}
else{
# id spremenljivke po kateri loopamo
- $_loop_on_spr_id = $this->_array_loop_on_spr[$rowVprasanje['if_id']];
+ $_loop_on_spr_id = isset($this->_array_loop_on_spr[$rowVprasanje['if_id']]) ? $this->_array_loop_on_spr[$rowVprasanje['if_id']] : null;
#variabla spremenljivke po kateri loopamo
$_loop_on_spr_variable = $this->AllQuestionsData[$_loop_on_spr_id]['variable'];
+
+ if(isset($_vrednosti[$_loop_vrednost])){
+
+ # id variable po kateri loopamo (v okviru $_loop_on_spr_id)
+ $_loop_on_variable_id = $_vrednosti[$_loop_vrednost];
+
+ # naslov variable po keteri loopamo (v okviru $_loop_on_spr_id)
+ $_vrednost_naslov = $_array_vrednosti[$_loop_on_spr_id][$_loop_on_variable_id['id']]['naslov'];
+ $rowVprasanje['variable'] = strip_tags($rowVprasanje['variable'])."_".$_vrednosti[$_loop_vrednost]['variable'];
+ $vrednostLoopSufix = "_".$_vrednosti[$_loop_vrednost]['variable'];
+
+ if ($_vrednost_naslov != '' && $_loop_on_spr_variable != '' && $rowVprasanje['naslov'] != '') {
+ # zamenjamo ime spremenljivke med #q1# (#q1# z naslovom trenutne variable)
+ $rowVprasanje['naslov'] = str_replace("#$_loop_on_spr_variable#", "$_vrednost_naslov", $rowVprasanje['naslov']);
+ }
+ }
- # id variable po kateri loopamo (v okviru $_loop_on_spr_id)
- $_loop_on_variable_id = $_vrednosti[$_loop_vrednost];
-
- # naslov variable po keteri loopamo (v okviru $_loop_on_spr_id)
- $_vrednost_naslov = $_array_vrednosti[$_loop_on_spr_id][$_loop_on_variable_id['id']]['naslov'];
- $rowVprasanje['variable'] = strip_tags($rowVprasanje['variable'])."_".$_vrednosti[$_loop_vrednost]['variable'];
- $vrednostLoopSufix = "_".$_vrednosti[$_loop_vrednost]['variable'];
-
- if ($_vrednost_naslov != '' && $_loop_on_spr_variable != '' && $rowVprasanje['naslov'] != '') {
- # zamenjamo ime spremenljivke med #q1# (#q1# z naslovom trenutne variable)
- $rowVprasanje['naslov'] = str_replace("#$_loop_on_spr_variable#", "$_vrednost_naslov", $rowVprasanje['naslov']);
- }
+
}
}
@@ -648,8 +658,8 @@ class SurveyDataCollect{
# TODO $spss_lngth mora biti enak za vse in sicer je enak največjemu možnemu številu znakov
# TODO zato je potrebno zdužit vse ($spss_lngth, $spss_lngth2, $spss_lngth3)
- $spss_lngth = $this->_array_SPSS[$spr_id]['text'];
- $spss_lngth2 = $this->_array_SPSS[$spr_id]['text2'];
+ $spss_lngth = isset($this->_array_SPSS[$spr_id]['text']) ? $this->_array_SPSS[$spr_id]['text'] : '';
+ $spss_lngth2 = isset($this->_array_SPSS[$spr_id]['text2']) ? $this->_array_SPSS[$spr_id]['text2'] : '';
$spss_lngth3 = isset($this->_array_SPSS[$spr_id]['vrednost']) && $this->_array_SPSS[$spr_id]['vrednost'] != '' ? $this->_array_SPSS[$spr_id]['vrednost'] : 0;
$_HEADER[$spr_data_id] = array('spr_id'=>$spr_id, 'tip'=>$tip, 'variable'=>$spr_variable, 'naslov'=>$spr_naslov, 'sistem'=>$spr_sistem, 'skala'=>$spr_skala, 'naslov_graf'=>$spr_naslov_graf, 'edit_graf'=>$spr_edit_graf, 'wide_graf'=>$spr_wide_graf);
@@ -718,9 +728,9 @@ class SurveyDataCollect{
$_seq_prefix = '_';
$sequence++;
$cnt++;
- $arrayVrednost = $_array_vrednosti[$spr_id];
+ $arrayVrednost = isset($_array_vrednosti[$spr_id]) ? $_array_vrednosti[$spr_id] : null;
- if (count($arrayVrednost)>0) {
+ if (is_countable($arrayVrednost) && count($arrayVrednost)>0) {
foreach ($arrayVrednost as $kid=> $vrednost) {
# dodamo še eno polje za tekstovne odgovore drugo
if ($vrednost['other'] == 1) {
@@ -730,13 +740,21 @@ class SurveyDataCollect{
$_seq_prefix = '_';
$sequence++;
$cnt++;
- $_GRIDS[0]['cnt_other'] += 1;
+
+ if(isset($_GRIDS[0]['cnt_other']))
+ $_GRIDS[0]['cnt_other'] += 1;
+ else
+ $_GRIDS[0]['cnt_other'] = 1;
} // end if
#dodamo opcije (za spss)
if ($vrednost['other'] == 0 || $vrednost['other'] == 1) {
$_HEADER[$spr_data_id]['options'][$vrednost['variable']] = ($vrednost['naslov'] != null) ? $vrednost['naslov'] : $vrednost['variable'];
$_HEADER[$spr_data_id]['options_graf'][$vrednost['variable']] = ($vrednost['naslov_graf'] != null) ? $vrednost['naslov_graf'] : $_HEADER[$spr_data_id]['options'][$vrednost['variable']];
}
+ //dodamo missing values
+ else if($vrednost['naslov'] != null){
+ $_HEADER[$spr_data_id]['missing_values'][$vrednost['other']] = $vrednost['naslov'];
+ }
} // end foreach
} // end if
@@ -755,7 +773,7 @@ class SurveyDataCollect{
case 2:
$arrayVrednost = $_array_vrednosti[$spr_id];
$cnt=0;
- if (count($arrayVrednost)>0) {
+ if (isset($arrayVrednost) && count($arrayVrednost)>0) {
foreach ($arrayVrednost as $vrednost) {
# dodamo header variable samo za ne -missing variable
@@ -773,9 +791,17 @@ class SurveyDataCollect{
$_seq_prefix = '_';
$sequence++;
$cnt++;
- $_GRIDS[0]['cnt_other'] += 1;
+
+ if(isset($_GRIDS[0]['cnt_other']))
+ $_GRIDS[0]['cnt_other'] += 1;
+ else
+ $_GRIDS[0]['cnt_other'] = 1;
} // end if
}
+ //dodamo missing values
+ else if($vrednost['naslov'] != null){
+ $_HEADER[$spr_data_id]['missing_values'][$vrednost['other']] = $vrednost['naslov'];
+ }
} // end foreach
} // end if
@@ -817,7 +843,9 @@ class SurveyDataCollect{
# Pri multigridu je logika obratna. variable predstavljajo podvprašanja, srv_grid pa odgovore
$cntGrid = 0;
$arrayVrednost = $_array_vrednosti[$spr_id];
- if (count($arrayVrednost)>0) {
+
+ if (is_countable($arrayVrednost) && count($arrayVrednost) > 0) {
+
# če imamo dvojni grid gremo 2_skozi
for ($i=1; $i<=$double+1;$i++) {
// for $double
@@ -839,7 +867,7 @@ class SurveyDataCollect{
# dodamo header samo za nemissing variable
if ($vrednost['other'] == 0 || $vrednost['other'] == 1) {
- $cnt = 0;
+ $cnt = 0;
$_GRIDS[$cntGrid]['variables'][$cnt] = array('vr_id'=>$vrednost['id'],
'naslov'=>$vrednost['naslov'],
'naslov2'=>$vrednost['naslov2'],
@@ -858,12 +886,13 @@ class SurveyDataCollect{
$_seq_prefix = '_';
$sequence++;
$cnt++;
- $_GRIDS[$cntGrid]['cnt_other'] += 1;
+ $_GRIDS[$cntGrid]['cnt_other'] = (isset($_GRIDS[$cntGrid]['cnt_other']) ? $_GRIDS[$cntGrid]['cnt_other'] += 1 : 1);
} // end if
$_GRIDS[$cntGrid]['cnt_vars'] = $cnt;
- $_GRIDS[$cntGrid]['naslov'] = $vrednost['variable'].$var_appendix;
+ $_GRIDS[$cntGrid]['naslov'] = $vrednost['variable'].$var_appendix.$vrednostLoopSufix;
$_GRIDS[$cntGrid]['part'] = $i;
- $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
+ if(!isset($_HEADER[$spr_data_id]['cnt_all'])) $_HEADER[$spr_data_id]['cnt_all'] = $cnt;
+ else $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
$cntGrid++;
}
} // end foreach
@@ -873,13 +902,17 @@ class SurveyDataCollect{
#dodamo opcije (za spss)
$arrayGrids = $_array_gridi[$spr_id];
- if (count($arrayGrids) > 0) {
+ if (is_countable($arrayGrids) && count($arrayGrids) > 0) {
foreach ($arrayGrids AS $kid => $grid) {
if ($grid['other'] == 0 || $grid['other'] == 1) {
$_HEADER[$spr_data_id]['options'][$grid['variable']] = ($grid['naslov'] != null) ? $grid['naslov'] : $grid['variable'];
// Opcije za dodaten naslov grida pri grafu
$_HEADER[$spr_data_id]['options_graf'][$grid['variable']] = ($grid['naslov_graf'] != null) ? $grid['naslov_graf'] : $_HEADER[$spr_data_id]['options'][$grid['variable']];
}
+ //dodamo missing values
+ else if($grid['naslov'] != null){
+ $_HEADER[$spr_data_id]['missing_values'][$grid['other']] = $grid['naslov'];
+ }
}
}
@@ -898,7 +931,7 @@ class SurveyDataCollect{
# pri number lahko imamo dve variabli grida, če je size 2
$cnt_v = 0;
$arrayVrednost = $_array_vrednosti[$spr_id];
- if (count($arrayVrednost) > 0) {
+ if (is_countable($arrayVrednost) && count($arrayVrednost) > 0) {
$cnt=0;
foreach ($arrayVrednost as $kid=> $vrednost) {
if ($vrednost['other'] == 0) {
@@ -930,7 +963,8 @@ class SurveyDataCollect{
} // end if
$_GRIDS[0]['enota'] = $spr_variable;
$_HEADER[$spr_data_id]['cnt_grids'] = 1;
- $_HEADER[$spr_data_id]['cnt_all'] += $cnt_v;
+ if(!isset($_HEADER[$spr_data_id]['cnt_all'])) $_HEADER[$spr_data_id]['cnt_all'] = $cnt_v;
+ else $_HEADER[$spr_data_id]['cnt_all'] += $cnt_v;
$_HEADER[$spr_data_id]['sequences'] = $_sequences;
break;
@@ -950,7 +984,8 @@ class SurveyDataCollect{
$_HEADER[$spr_data_id]['cnt_grids'] = 1;
$_GRIDS[0]['cnt_vars'] = $cnt;
$_GRIDS[0]['naslov'] = $spr_variable;
- $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
+ if(!isset($_HEADER[$spr_data_id]['cnt_all'])) $_HEADER[$spr_data_id]['cnt_all'] = $cnt;
+ else $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
$_HEADER[$spr_data_id]['sequences'] = $_sequences;
break;
@@ -976,7 +1011,8 @@ class SurveyDataCollect{
$arrayGrids = $_array_gridi[$spr_id];
$arrayVrednost = $_array_vrednosti[$spr_id];
- if (count($arrayVrednost) > 0) {
+
+ if (is_countable($arrayVrednost) && count($arrayVrednost) > 0) {
foreach ($arrayVrednost as $kid=> $vrednost) {
// Za kombinirane tabele popravimo ime variable
@@ -990,9 +1026,9 @@ class SurveyDataCollect{
if (count($arrayGrids) > 0) {
foreach ($arrayGrids AS $kid => $grid) {
if ($grid['other'] == 0 || $grid['other'] == 1) {
- $_GRIDS[$grid_id]['variables'][$cnt] = array('vr_id'=>$vrednost['id'], 'gr_id'=>$grid['id'], 'naslov'=>$grid['naslov'], 'variable'=>$vrednost['variable'].'_'.$grid['variable'].$vrednostLoopSufix, 'other'=>false, 'text'=>false,'spss'=>$_spss,'sequence'=>$sequence,'naslov_graf'=>$grid['naslov_graf']);
+ $_GRIDS[$grid_id]['variables'][$cnt] = array('vr_id'=>$vrednost['id'], 'gr_id'=>$grid['id'], 'naslov'=>$grid['naslov'].($grid['part'] == '2' ? '_'.$grid['part'] : ''), 'variable'=>$vrednost['variable'].'_'.$grid['variable'].($grid['part'] == '2' ? '_'.$grid['part'] : '').$vrednostLoopSufix, 'other'=>false, 'text'=>false,'spss'=>$_spss,'sequence'=>$sequence,'naslov_graf'=>$grid['naslov_graf']);
- if((int)$is_datum === 1) {
+ if((int)$is_datum === 1) {
$_GRIDS[$grid_id]['variables'][$cnt]['sortType'] ='date';
}
$_sequences .= $_seq_prefix.$sequence;
@@ -1000,6 +1036,10 @@ class SurveyDataCollect{
$sequence++;
$cnt++;
}
+ //dodamo missing values
+ else if($grid['naslov'] != null){
+ $_HEADER[$spr_data_id]['missing_values'][$grid['other']] = $grid['naslov'];
+ }
} // end foreach
if ($vrednost['other'] == 1) {
$_GRIDS[$grid_id]['variables'][$cnt] = array('vr_id'=>$vrednost['id'],'naslov'=>$vrednost['naslov'], 'variable'=>$vrednost['variable'].$vrednostLoopSufix.STR_OTHER_TEXT, 'other'=>true,'text'=>true,'spss'=>'A'.$spss_lngth,'sequence'=>$sequence,'naslov_graf'=>$vrednost['naslov_graf']);
@@ -1016,7 +1056,12 @@ class SurveyDataCollect{
$_GRIDS[$grid_id]['naslov'] = $vrednost['naslov'];
$_GRIDS[$grid_id]['variable'] = $vrednost['variable'];
$_GRIDS[$grid_id]['naslov_graf'] = $vrednost['naslov_graf'];
- $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
+
+ if(!isset($_HEADER[$spr_data_id]['cnt_all']))
+ $_HEADER[$spr_data_id]['cnt_all'] = $cnt;
+ else
+ $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
+
$grid_id++;
} // end foreach
} // end if
@@ -1042,7 +1087,7 @@ class SurveyDataCollect{
$cnt=0;
$arrayVrednost = $_array_vrednosti[$spr_id];
- if (count($arrayVrednost) > 0) {
+ if (is_countable($arrayVrednost) && count($arrayVrednost) > 0) {
foreach ($arrayVrednost as $kid=> $vrednost) {
$_GRIDS[0]['variables'][$cnt] = array('vr_id'=>$vrednost['id'],'naslov'=>$vrednost['naslov'], 'variable'=>$vrednost['variable'].$vrednostLoopSufix, 'other'=>false, 'text'=>false,'spss'=>$_spss,'sequence'=>$sequence,'naslov_graf'=>$vrednost['naslov_graf']);
$_sequences .= $_seq_prefix.$sequence;
@@ -1057,7 +1102,8 @@ class SurveyDataCollect{
$_HEADER[$spr_data_id]['cnt_grids'] = 1;
$_GRIDS[0][ 'cnt_vars'] = $cnt;
$_GRIDS[0]['naslov'] = $spr_variable;
- $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
+ if(!isset($_HEADER[$spr_data_id]['cnt_all'])) $_HEADER[$spr_data_id]['cnt_all'] = $cnt;
+ else $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
$_HEADER[$spr_data_id]['sequences'] = $_sequences;
break;
@@ -1066,7 +1112,7 @@ class SurveyDataCollect{
case 21:
$cnt=0;
$arrayVrednost = $_array_vrednosti[$spr_id];
- if (count($arrayVrednost) > 0) {
+ if (is_countable($arrayVrednost) && count($arrayVrednost) > 0) {
foreach ($arrayVrednost as $kid=> $vrednost) {
if ($vrednost['other'] == 0) {
@@ -1085,7 +1131,8 @@ class SurveyDataCollect{
$_HEADER[$spr_data_id]['cnt_grids'] = 1;
$_GRIDS[0]['cnt_vars'] = $cnt;
$_GRIDS[0]['naslov'] = $spr_variable;
- $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
+ if(!isset($_HEADER[$spr_data_id]['cnt_all'])) $_HEADER[$spr_data_id]['cnt_all'] = $cnt;
+ else $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
$_HEADER[$spr_data_id]['sequences'] = $_sequences;
break;
@@ -1102,7 +1149,8 @@ class SurveyDataCollect{
$_HEADER[$spr_data_id]['cnt_grids'] = 1;
$_GRIDS[0]['cnt_vars'] = $cnt;
$_GRIDS[0]['naslov'] = $spr_variable;
- $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
+ if(!isset($_HEADER[$spr_data_id]['cnt_all'])) $_HEADER[$spr_data_id]['cnt_all'] = $cnt;
+ else $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
$_HEADER[$spr_data_id]['sequences'] = $_sequences;
break;
@@ -1119,7 +1167,8 @@ class SurveyDataCollect{
$_HEADER[$spr_data_id]['cnt_grids'] = 1;
$_GRIDS[0]['cnt_vars'] = $cnt;
$_GRIDS[0]['naslov'] = $spr_variable;
- $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
+ if(!isset($_HEADER[$spr_data_id]['cnt_all'])) $_HEADER[$spr_data_id]['cnt_all'] = $cnt;
+ else $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
$_HEADER[$spr_data_id]['sequences'] = $_sequences;
break;
@@ -1127,8 +1176,8 @@ class SurveyDataCollect{
# SN - IMENA
case 9:
$cnt=0;
- $arrayVrednost = $this->SNVariablesForSpr[$_vprasanje_array['id']];
- if (count($arrayVrednost) > 0) {
+ $arrayVrednost = isset($this->SNVariablesForSpr[$_vprasanje_array['id']]) ? $this->SNVariablesForSpr[$_vprasanje_array['id']] : array();
+ if (is_countable($arrayVrednost) && count($arrayVrednost) > 0) {
foreach ($arrayVrednost as $kid=> $vrednost) {
$_GRIDS[0]['variables'][$cnt] = array('vr_id'=>$vrednost,'naslov'=>($spr_variable.'_'.($cnt+1)), 'variable'=>($spr_variable.'_'.($cnt+1)), 'other'=>false, 'text'=>true,'spss'=>'A'.$spss_lngth,'sequence'=>$sequence);
$_sequences .= $_seq_prefix.$sequence;
@@ -1140,7 +1189,8 @@ class SurveyDataCollect{
$_HEADER[$spr_data_id]['cnt_grids'] = 1;
$_GRIDS[0]['cnt_vars'] = $cnt;
$_GRIDS[0]['naslov'] = $spr_variable;
- $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
+ if(!isset($_HEADER[$spr_data_id]['cnt_all'])) $_HEADER[$spr_data_id]['cnt_all'] = $cnt;
+ else $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
$_HEADER[$spr_data_id]['sequences'] = $_sequences;
break;
@@ -1152,7 +1202,7 @@ class SurveyDataCollect{
if($row['enota'] == 3){
$cnt=0;
$arrayVrednost = $_array_vrednosti[$spr_id];
- if (count($arrayVrednost) > 0) {
+ if (is_countable($arrayVrednost) && count($arrayVrednost) > 0) {
foreach ($arrayVrednost as $kid=> $vrednost) {
if ($vrednost['other'] == 0) {
@@ -1170,7 +1220,8 @@ class SurveyDataCollect{
$_HEADER[$spr_data_id]['cnt_grids'] = 1;
$_GRIDS[0]['cnt_vars'] = $cnt;
$_GRIDS[0]['naslov'] = $spr_variable;
- $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
+ if(!isset($_HEADER[$spr_data_id]['cnt_all'])) $_HEADER[$spr_data_id]['cnt_all'] = $cnt;
+ else $_HEADER[$spr_data_id]['cnt_all'] += $cnt;
$_HEADER[$spr_data_id]['sequences'] = $_sequences;
}
else{
@@ -1223,8 +1274,8 @@ class SurveyDataCollect{
$cnt++;
}
//checkbox vrednosti za imena obmocij
- $arrayVrednost = $_array_vrednosti[$spr_id];
- if (count($arrayVrednost)>0) {
+ $arrayVrednost = isset($_array_vrednosti[$spr_id]) ? $_array_vrednosti[$spr_id] : null;
+ if (is_countable($arrayVrednost) && count($arrayVrednost) > 0) {
foreach ($arrayVrednost as $vrednost) {
# dodamo header variable samo za ne -missing variable
@@ -1262,14 +1313,14 @@ class SurveyDataCollect{
// s katero sekvenco se začnejo meta podatki
$_HEADER['_settings']['metaSequence'] = $sequence;
- $_HEADER['meta'] = array('tip'=>'sm', 'variable'=>'smeta', 'naslov' =>$lang['srv_displaydata_meta'],'cnt_all'=>2);
+ $_HEADER['meta'] = array('tip'=>'sm', 'variable'=>'smeta', 'naslov' =>$lang['srv_displaydata_meta2'],'cnt_all'=>2);
// Datum insert, datum edit, datume in čase za posamezno stran
$_g_cnt = 0;
$_tmp_seq = $sequence;
// Na zacetku prikazemo randomizacijo ce je prisotna pri kaksnem vprasanju ali bloku
- foreach ($this->_array_random as $random_parent) {
+ foreach ($this->_array_random as $parent_id => $random_parent) {
if($random_parent['type'] == 'spr'){
$_HEADER['meta']['grids'][$_g_cnt] = Array('naslov'=>'Random '.$random_parent['variable']);
@@ -1321,16 +1372,24 @@ class SurveyDataCollect{
$page = 1;
foreach ($this->_array_groups as $gid => $grupa) {
- $_HEADER['meta']['grids'][$_g_cnt] = Array('naslov'=>$lang['page'].' '.$page);
+ // Uvod
+ if($gid == '0'){
+ $_HEADER['meta']['grids'][$_g_cnt] = Array('naslov'=>$lang['intro']);
- # date on page
- $_HEADER['meta']['grids'][$_g_cnt]['variables'][0] = Array ('variable'=>'date_'.$page,'naslov'=>'datum_'.$page,'spss'=>'DATETIMEw','sortType'=>'date','sequence'=>$sequence);
- $sequence++;
+ # date on page
+ $_HEADER['meta']['grids'][$_g_cnt]['variables'][0] = Array ('variable'=>'date_0','naslov'=>'datum_0','spss'=>'DATETIMEw','sortType'=>'date','sequence'=>$sequence);
+ }
+ else{
+ $_HEADER['meta']['grids'][$_g_cnt] = Array('naslov'=>$lang['page'].' '.$page);
+ # date on page
+ $_HEADER['meta']['grids'][$_g_cnt]['variables'][0] = Array ('variable'=>'date_'.$page,'naslov'=>'datum_'.$page,'spss'=>'DATETIMEw','sortType'=>'date','sequence'=>$sequence);
+
+ $page++;
+ }
+
$_HEADER['meta']['grids'][$_g_cnt]['cnt_vars'] = 1;
-
- $page++;
- $_g_cnt++;
+ $sequence++; $_g_cnt++;
}
// IP
@@ -1403,7 +1462,7 @@ class SurveyDataCollect{
$_tmpCnt = $c * MAX_USER_PER_LOOP;
- $_dataLine = "";
+ $_dataLine = '';
// Dobimo vse jezike za katere obstaja jezikovna datoteka
include_once($site_path.'lang/jeziki.php');
@@ -1413,7 +1472,7 @@ class SurveyDataCollect{
$jeziki[$lang['id']] = $lang['language'];
if ($this->noErrors) {
-
+
while ($rowUser = mysqli_fetch_assoc($this->_qry_users[$c])) {
#sleep(1);
@@ -1422,9 +1481,9 @@ class SurveyDataCollect{
$uid = $rowUser['usr_id'];
# dodamo usr id k podatkom
$_dataLine .= $rowUser['usr_id'];
-
- # dodamo ustreznost k podatkom - relevance
- $_dataLine .= STR_DLMT. (($rowUser['status'] == 5 || $rowUser['status'] == 6) && $rowUser['lurker'] == 0 ? '1' : '0');
+
+ # dodamo status k podatkom
+ $_dataLine .= STR_DLMT.$rowUser['status'];
# dodamo email (invitation)k podatkom - če je bilo poslano z emailom ali je uporabnik ročno vnesel email
$_dataLine .= STR_DLMT. ((int)$rowUser['inv_res_id'] > 0 || (int)$rowUser['inv_res_id'] == -1
@@ -1436,9 +1495,9 @@ class SurveyDataCollect{
: '2')
# uporabnik ni bil dodan z email vabilom
: '0');
-
- # dodamo status k podatkom
- $_dataLine .= STR_DLMT.$rowUser['status'];
+
+ # dodamo ustreznost k podatkom - relevance
+ $_dataLine .= STR_DLMT. (($rowUser['status'] == 5 || $rowUser['status'] == 6) && $rowUser['lurker'] == 0 ? '1' : '0');
# dodamo lurkerje
$_dataLine .= STR_DLMT.$rowUser['lurker'];
@@ -1474,6 +1533,10 @@ class SurveyDataCollect{
if ($this->noErrors && count($this->AllQuestionsOrder) > 0) {
foreach ($this->AllQuestionsOrder AS $_vprasanje_array) {
+ // Ce vrpasanje ni nastavljeno preskocimo
+ if(!isset($this->AllQuestionsData[$_vprasanje_array['id']]))
+ continue;
+
$rowVprasanje = $this->AllQuestionsData[$_vprasanje_array['id']];
# spremenljivki dodamo loop_id da je konsistentno z podatki
@@ -1614,7 +1677,7 @@ class SurveyDataCollect{
$userAnswerLine .= STR_DLMT.$this->recode_answer($spr_id,$answer,$uid);
// poiščemo polja drugo
- if (count($spr_vrednosti) > 0){
+ if (isset($spr_vrednosti) && is_countable($spr_vrednosti) && count($spr_vrednosti) > 0){
foreach ($spr_vrednosti AS $vid => $vrednost) {
@@ -1732,7 +1795,7 @@ class SurveyDataCollect{
#ce smo meli checkboc obkljukan
if (isset($_tmp_answers[$vid])) {
- $answerOther = ($spr_data_text[$vid]['text'] == "" || $spr_data_text[$vid]['text'] == null) ? $VALUE_FOR_MISSING : $spr_data_text[$vid]['text'];
+ $answerOther = (!isset($spr_data_text[$vid]['text']) || $spr_data_text[$vid]['text'] == "" || $spr_data_text[$vid]['text'] == null) ? $VALUE_FOR_MISSING : $spr_data_text[$vid]['text'];
} else if ($missing_answers !== null) {
// Ce je bil 0 texta ni mogel vnesti in mora bit -2
if($VALUE_FOR_MISSING == -1)
@@ -2293,28 +2356,27 @@ class SurveyDataCollect{
case 9:
# zloopamo skozi podvprašanja in nastavimo izbrane odgovore
- $arrayVrednost = $this->SNVariablesForSpr[$_vprasanje_array['id']];
- if (!is_array($arrayVrednost)) {
- $arrayVrednost = array();
- }
- if(count($spr_vrednosti) > 0)
- foreach ($spr_vrednosti AS $vid => $vrednost) {
- if (in_array($vid,$arrayVrednost)) {
- $answer = null;
- if (isset($spr_data_text[$vid]['text'])) {
- # imamo normalno text vprašanje
- $answer = $spr_data_text[$vid]['text'];
-
- } else if (is_array($spr_data_vred) && count($spr_data_vred) > 0 ) {
- $answer = end($spr_data_vred);
- }
-
- if ($answer == "" || $answer == null) {
- $answer = $VALUE_FOR_MISSING;
- } // end if
- $userAnswerLine .= STR_DLMT.$this->recode_answer($spr_id,$answer,$uid);
-
- }
+ $arrayVrednost = isset($this->SNVariablesForSpr[$_vprasanje_array['id']]) ? $this->SNVariablesForSpr[$_vprasanje_array['id']] : array();
+
+ if(count($spr_vrednosti) > 0){
+ foreach ($spr_vrednosti AS $vid => $vrednost) {
+ if (in_array($vid,$arrayVrednost)) {
+ $answer = null;
+ if (isset($spr_data_text[$vid]['text'])) {
+ # imamo normalno text vprašanje
+ $answer = $spr_data_text[$vid]['text'];
+
+ } else if (is_array($spr_data_vred) && count($spr_data_vred) > 0 ) {
+ $answer = end($spr_data_vred);
+ }
+
+ if ($answer == "" || $answer == null) {
+ $answer = $VALUE_FOR_MISSING;
+ } // end if
+ $userAnswerLine .= STR_DLMT.$this->recode_answer($spr_id,$answer,$uid);
+
+ }
+ }
}
break;
@@ -2376,7 +2438,7 @@ class SurveyDataCollect{
# ce imamo odgovor
if (isset ($spr_data_map)) {
$missing_value_temp = (is_array($spr_data_vred) && count($spr_data_vred) == 1 ) ? end($spr_data_vred) : $VALUE_FOR_MISSING;
- $answerArr = (is_countable($spr_data_map['izpis']) && count($spr_data_map['izpis']) > 0) ? $spr_data_map['izpis'] : $missing_value_temp;
+ $answerArr = (isset($spr_data_map['izpis']) && is_countable($spr_data_map['izpis']) && count($spr_data_map['izpis']) > 0) ? $spr_data_map['izpis'] : $missing_value_temp;
}
else if (is_array($spr_data_map)) {
$key = key($spr_data_map);
@@ -2442,8 +2504,8 @@ class SurveyDataCollect{
$newParams = new enkaParameters($row['params']);
// ce imamo odgovor
- if (isset ($spr_data_heatmap)) {
- $answerArr = (is_countable($spr_data_heatmap['izpis']) && count($spr_data_heatmap['izpis']) > 0) ? $spr_data_heatmap['izpis'] : $VALUE_FOR_MISSING;
+ if (isset ($spr_data_heatmap['izpis'])) {
+ $answerArr = (is_countable($spr_data_heatmap['izpis']) && count($spr_data_heatmap['izpis']) > 0) ? $spr_data_heatmap['izpis'] : $VALUE_FOR_MISSING;
}
else if (is_array($spr_data_heatmap)) {
$key = key($spr_data_heatmap);
@@ -2489,37 +2551,38 @@ class SurveyDataCollect{
$numberOfPointsInside=array();
if (count($spr_vrednosti) > 0) {
- $i=0;
- foreach ($this->_array_data_heatmap_regions[(int)$spr_id] AS $regions){
- $answerReg = null;
- $numberOfPointsInside[$regions['region_name']] = 0; // Belezi stevilo tock znotraj trenutnega obmocja
-
- // Pretvori polje s tockami obmocja v ustrezno obliko
- $poly = $this->convertPolyString($regions['region_coords']);
-
- // preveri, ali je posamezna tocka znotraj trenutnega obmocja
- for ($z=0; $z<sizeof($pointx); $z++){
- $inside = $this->insidePoly($poly, $pointx[$z]["x"], $pointy[$z]["y"]);
- if ($inside == true){
- $numberOfPointsInside[$regions['region_name']]++;
- }
- }
-
- // Priprava odgovora za preglednico s podatki
- // Ce je missing
- if($answerKoo < 0){
- $answerReg = $answerKoo;
+ $i=0;
+ if(isset($this->_array_data_heatmap_regions[(int)$spr_id]))
+ foreach ($this->_array_data_heatmap_regions[(int)$spr_id] AS $regions){
+ $answerReg = null;
+ $numberOfPointsInside[$regions['region_name']] = 0; // Belezi stevilo tock znotraj trenutnega obmocja
+
+ // Pretvori polje s tockami obmocja v ustrezno obliko
+ $poly = $this->convertPolyString($regions['region_coords']);
+
+ // preveri, ali je posamezna tocka znotraj trenutnega obmocja
+ for ($z=0; $z<sizeof($pointx); $z++){
+ $inside = $this->insidePoly($poly, $pointx[$z]["x"], $pointy[$z]["y"]);
+ if ($inside == true){
+ $numberOfPointsInside[$regions['region_name']]++;
+ }
+ }
+
+ // Priprava odgovora za preglednico s podatki
+ // Ce je missing
+ if($answerKoo < 0){
+ $answerReg = $answerKoo;
+ }
+ else{
+ $answerReg = $numberOfPointsInside[$regions['region_name']];
+ }
+
+ $i++;
+
+ // dodamo odgovor s stevilom tock znotraj obmocja
+ $userAnswerLine .= STR_DLMT.$this->recode_answer($spr_id,$answerReg,$uid);
+
}
- else{
- $answerReg = $numberOfPointsInside[$regions['region_name']];
- }
-
- $i++;
-
- // dodamo odgovor s stevilom tock znotraj obmocja
- $userAnswerLine .= STR_DLMT.$this->recode_answer($spr_id,$answerReg,$uid);
-
- }
}
}
//za območja - konec
@@ -2577,7 +2640,7 @@ class SurveyDataCollect{
// Random vrstni redi
- foreach ($this->_array_random as $random_parent) {
+ foreach ($this->_array_random as $parent_id => $random_parent) {
$type = ($random_parent['type'] == 'spr') ? 'spr' : 'block';
$random_data = $this->get_array_data_random($uid, $random_parent['id'], $type);
@@ -2601,9 +2664,10 @@ class SurveyDataCollect{
# strani in časi
foreach ($this->_array_groups AS $gid => $grupa) {
- if ($this->_array_user_grupa[$uid][$gid] != '') {
+ if (isset($this->_array_user_grupa[$uid][$gid]) && $this->_array_user_grupa[$uid][$gid] != '') {
$_dataLine .= STR_DLMT.datetime($this->_array_user_grupa[$uid][$gid]);
- } else {
+ }
+ else {
$_dataLine .= STR_DLMT.'';
}
}
@@ -2643,8 +2707,8 @@ class SurveyDataCollect{
$this->noErrors = false;
}
- $_dataLine = null;
unset($_dataLine);
+ $_dataLine = '';
}
else {
# dodamo v log napako
@@ -2765,6 +2829,13 @@ class SurveyDataCollect{
$cnt = 0;
if ($this->_cnt_groups > 0) {
$this->_array_groups = array();
+
+ // Uvod - ce je prikazan v anketi
+ if($this->survey['show_intro'] == '1'){
+ $this->_array_groups['0'] = '0';
+ $str .= '0,';
+ }
+
$prefix ='';
while ($row = mysqli_fetch_assoc($qry_groups)) {
@@ -2880,7 +2951,7 @@ class SurveyDataCollect{
$rowVprasanja = array();
- if (!is_countable($sgmMap[$rowMainVprasanje['id']]) || count($sgmMap[$rowMainVprasanje['id']]) == 0) {
+ if (!isset($sgmMap[$rowMainVprasanje['id']]) || count($sgmMap[$rowMainVprasanje['id']]) == 0) {
$rowVprasanja[] = $rowMainVprasanje;
}
else {
@@ -2913,12 +2984,12 @@ class SurveyDataCollect{
$this->AllQuestionsData[$rowVprasanje['id']] = array(
'id' => $rowVprasanje['id'],
'spr_id' => $spr_id,
- 'sgm_parrent' => $rowVprasanje['sgm_parrent'],
+ 'sgm_parrent' => isset($rowVprasanje['sgm_parrent']) ? $rowVprasanje['sgm_parrent'] : '',
'tip' => $rowVprasanje['tip'],
'gru_id' => $rowVprasanje['gru_id'],
'variable' => strip_tags($rowVprasanje['variable']),
'naslov' => strip_tags($rowVprasanje['naslov']),
- 'label' => strip_tags($rowVprasanje['label']),
+ 'label' => (isset($rowVprasanje['label']) ? strip_tags($rowVprasanje['label']) : ''),
'size' => $rowVprasanje['size'],
'cela' => $rowVprasanje['cela'],
'grid_subtitle1' => $rowVprasanje['grid_subtitle1'],
@@ -3034,6 +3105,8 @@ class SurveyDataCollect{
$this->_array_loop_on_spr = array();
$this->_array_loop_parent = array();
+ $_cnt_loop = 0;
+
$qryLoop_spr_select = sisplet_query("SELECT l.if_id, l.spr_id
FROM srv_branching AS b, srv_loop AS l
WHERE b.ank_id = '".$this->sid."' AND b.element_if = l.if_id");
@@ -3084,6 +3157,22 @@ class SurveyDataCollect{
foreach ($spr_ids AS $spr_id) {
$this->_array_spr_in_loop[$spr_id] = $lkey;
$this->_array_loop_has_spr[$lkey][] = $spr_id;
+
+ // Pri kombinirani tabeli dodamo v array se podtabele
+ $row = Cache::srv_spremenljivka($spr_id);
+ if($row['tip'] == 24){
+
+ $sqlMT = sisplet_query("SELECT s.id
+ FROM srv_spremenljivka s, srv_grid_multiple mt
+ WHERE mt.ank_id='".$this->sid."' AND mt.parent='".$spr_id."' AND mt.spr_id=s.id
+ ORDER BY mt.vrstni_red ASC
+ ");
+ while ($rowMT = mysqli_fetch_array($sqlMT)) {
+ $this->_array_spr_in_loop[$rowMT['id']] = $lkey;
+ $this->_array_loop_has_spr[$lkey][] = $rowMT['id'];
+ }
+ }
+
}
}
}
@@ -3240,12 +3329,12 @@ class SurveyDataCollect{
}
$this->_array_random = array();
-
+ $i=0;
// Preberemo vsa VPRASANJA ki imajo vklopljeno randomizacijo
$_qry_random_spr = sisplet_query("SELECT s.id, s.variable FROM srv_spremenljivka s, srv_grupa g
WHERE g.ank_id='".$this->sid."' AND s.gru_id=g.id AND s.random='1'
- ORDER BY s.vrstni_red");
+ ORDER BY g.vrstni_red ASC, s.vrstni_red ASC");
if (!$_qry_random_spr) {
$this->trigerError('get_random', mysqli_error($GLOBALS['connect_db']));
}
@@ -3255,11 +3344,14 @@ class SurveyDataCollect{
// Napolnimo array z randomiziranimi vprasanji
if ($cnt_rows > 0) {
+
+
while ($row = mysqli_fetch_array($_qry_random_spr)) {
-
- $this->_array_random[$row['id']]['id'] = $row['id'];
+ $this->_array_random[$row['id']]['id'] = $row['id'];
$this->_array_random[$row['id']]['variable'] = $row['variable'];
$this->_array_random[$row['id']]['type'] = 'spr';
+
+ $i++;
}
}
@@ -3297,7 +3389,9 @@ class SurveyDataCollect{
// Blok ima randomizirana vprasanja
else{
$this->_array_random[$row['id']]['type'] = 'blok_spr';
- }
+ }
+
+ $i++;
}
}
}
@@ -3662,7 +3756,7 @@ class SurveyDataCollect{
if($text == '' || $text == null) $text = '-1';
// Addslashes je potreben za analize
- if($this->_array_data_map[(int)$usr_id][$spr_id.'_'.$loop_id]){
+ if(isset($this->_array_data_map[(int)$usr_id][$spr_id.'_'.$loop_id])){
$this->_array_data_map[(int)$usr_id][$spr_id.'_'.$loop_id]['izpis'][$i] = array(
'address'=>addslashes(strip_tags($address)),
'vrednost'=>addslashes(strip_tags($text)),
@@ -3670,11 +3764,15 @@ class SurveyDataCollect{
}
else{
$this->_array_data_map[(int)$usr_id][$spr_id.'_'.$loop_id] = array(
- 'izpis'=>array(array(
- 'address'=>addslashes(strip_tags($address)),
- 'vrednost'=>addslashes(strip_tags($text)),
- 'koordinate'=>$lat . ', ' . $lng)),
- 'spr_id' => $spr_id, 'usr_id' => $usr_id, 'loop_id' => $loop_id);
+ 'izpis'=>array(
+ array(
+ 'address'=>addslashes(strip_tags($address)),
+ 'vrednost'=>addslashes(strip_tags($text)),
+ 'koordinate'=>$lat . ', ' . $lng
+ )
+ ),
+ 'spr_id' => $spr_id, 'usr_id' => $usr_id, 'loop_id' => $loop_id
+ );
}
$i++;
@@ -3715,19 +3813,24 @@ class SurveyDataCollect{
if($text == '' || $text == null) $text = '-1';
// adslashes je potreben za analize
- if($this->_array_data_heatmap[(int)$usr_id][$spr_id.'_'.$loop_id]){
+ if(isset($this->_array_data_heatmap[(int)$usr_id][$spr_id.'_'.$loop_id])){
$this->_array_data_heatmap[(int)$usr_id][$spr_id.'_'.$loop_id]['izpis'][$i] = array(
'address'=>addslashes(strip_tags($address)),
'vrednost'=>addslashes(strip_tags($text)),
- 'koordinate'=> $lat . ', ' . $lng);
+ 'koordinate'=> $lat . ', ' . $lng
+ );
}
else{
$this->_array_data_heatmap[(int)$usr_id][$spr_id.'_'.$loop_id] = array(
- 'izpis'=>array(array(
- 'address'=>addslashes(strip_tags($address)),
- 'vrednost'=>addslashes(strip_tags($text)),
- 'koordinate'=>$lat . ', ' . $lng)),
- 'spr_id' => $spr_id, 'usr_id' => $usr_id, 'loop_id' => $loop_id);
+ 'izpis'=>array(
+ array(
+ 'address'=>addslashes(strip_tags($address)),
+ 'vrednost'=>addslashes(strip_tags($text)),
+ 'koordinate'=>$lat . ', ' . $lng
+ )
+ ),
+ 'spr_id' => $spr_id, 'usr_id' => $usr_id, 'loop_id' => $loop_id
+ );
}
$i++;
@@ -3860,7 +3963,7 @@ class SurveyDataCollect{
if (mysqli_num_rows($_qry_data_random) > 0) {
while($row2 = mysqli_fetch_array($_qry_data_random)){
-
+
// Zgradimo string z labelami vprasanj za prikaz v podatkih
$vrstni_red_string = '';
@@ -4054,7 +4157,7 @@ class SurveyDataCollect{
// Pripravimo missing vrednosti za anketo
private function setSurveyMissingValues() {
- $smv = new SurveyMissingValues($sid);
+ $smv = new SurveyMissingValues($this->sid);
$smv -> Init();
$_sys_missings = $smv->GetSurveyMissingValues();
@@ -4093,7 +4196,7 @@ class SurveyDataCollect{
return $result;
}
- if ($this->_user_spr_answer_count['last_seen'] == $this->_user_spr_answer_count['cnt']) {
+ if (isset($this->_user_spr_answer_count['last_seen']) && $this->_user_spr_answer_count['last_seen'] == $this->_user_spr_answer_count['cnt']) {
return $result;
}
@@ -4101,12 +4204,12 @@ class SurveyDataCollect{
return $result;
}
- foreach ($this->_user_spr_answer_count['spremenljivke'] AS $cnt) {
-
- if ($this->_user_spr_answer_count['last_seen'] > $result) {
- $result += $cnt;
- }
- }
+ if (isset($this->_user_spr_answer_count['last_seen']))
+ foreach ($this->_user_spr_answer_count['spremenljivke'] AS $cnt) {
+ if ($this->_user_spr_answer_count['last_seen'] > $result) {
+ $result += $cnt;
+ }
+ }
return $this->_user_spr_answer_count['cnt'] - $result;
}
@@ -4189,7 +4292,7 @@ class SurveyDataCollect{
// Pogledamo se ce je respondent videl vprasanje (tudi ce je -1, ker ga potem ne smemo spremenit v -3)
if ($answer == -1 || $answer === '-2d') {
- if (is_array($this->_array_user_grupa[$uid]) && array_key_exists($this->AllQuestionsData[$spr]['gru_id'], $this->_array_user_grupa[$uid])) {
+ if (isset($this->_array_user_grupa[$uid]) && is_array($this->_array_user_grupa[$uid]) && array_key_exists($this->AllQuestionsData[$spr]['gru_id'], $this->_array_user_grupa[$uid])) {
$this->_user_spr_answer_count['last_seen'] = $this->_user_spr_answer_count['cnt'] - 1;
}
}
@@ -4290,7 +4393,8 @@ class SurveyDataCollect{
$coordsWithComma = explode('<br>',$answerKoo);
$pointx = array();
$pointy = array();
-
+ $coords = array();
+
for($i = 1; $i<sizeof($coordsWithComma); $i++){
// Vecdimenzionalno polje