0 votes
in SoSci Survey (dt.) by s113495 (135 points)
edited by s139847

Guten Tag,

in meiner Studie werden 60 Bilder (in 3 Kategorien) in zufälliger Reihenfolge gezeigt,
und auf Valenz und Arousal (Likert Skalen) und manchmal auch auf Distanz zwischen den Personen (Visual analogue scale) bewertet.

Funktioniert alles gut, aber wenn mal eine Antwort nicht gegeben wird, gibt es Fehlermeldungen.

Wie behebe ich das?

Vielen Dank im Voraus.

LG

CODE ZUM ERSTELLEN DER LISTEN

    // list of question IDs and images belonging to them
$list_pics_and_ques = array(  
    array('Type' => 'Alone', 'Valence' => 'RV01', 'Arousal' => 'RA01', 'Distance' => 'RD01', 'Picture' => 'pro://Beach_4.jpg'),
    array('Type' => 'Alone', 'Valence' => 'RV02', 'Arousal' => 'RA02', 'Distance' => 'RD02', 'Picture' etcetera.....);

$total_pictures = count($list_pics_and_ques) ; 
registerVariable('total_pictures');

// randomize list
shuffle($list_pics_and_ques);  
registerVariable('list_pics_and_ques');

// get names 
$list_names;
$list_val;
$list_aro;
$list_dis;
$list_type;
$i = 0;
foreach ($list_pics_and_ques as $arr) {
  if ($i == 0){
      $list_names = substr($arr["Picture"], 6) . ",";
      $list_val = $arr["Valence"] . ",";
      $list_aro = $arr["Arousal"] . ",";
      $list_dis = $arr["Distance"] . ",";
      $list_type = $arr["Type"] . ",";
      $i = $i + 1;
    } else {
      $list_names .= substr($arr["Picture"], 6) . ",";
      $list_val .= $arr["Valence"] . ",";
      $list_aro .= $arr["Arousal"] . ",";
      $list_dis .= $arr["Distance"] . ",";
      $list_type .= $arr["Type"] . ",";
      $i = $i + 1;
    }
}
$list_names = trim($list_names, ',');//removes the final comma 
$list_val = trim($list_val, ',');//removes the final comma 
$list_aro = trim($list_aro, ',');//removes the final comma 
$list_dis = trim($list_dis, ',');//removes the final comma 
$list_type = trim($list_type, ',');//removes the final comma 

// back to arrays
$list_names_array = explode(",", $list_names);
$list_val_array = explode(",", $list_val);
$list_aro_array = explode(",", $list_aro);
$list_dis_array = explode(",", $list_dis);
$list_type_array = explode(",", $list_type);

registerVariable('list_names_array');
registerVariable('list_val_array');
registerVariable('list_aro_array');
registerVariable('list_dis_array');
registerVariable('list_type_array');



$cnt_i = 1; 
registerVariable('cnt_i');

registerVariable('fig_name');
registerVariable('fig_num');
registerVariable('category');
registerVariable('trialnum');





CODE ZUM ZEIGEN VON BILDERN UND RATING SKALEN

    $i = loopPage(1,$total_pictures);

$shuffled = 'NO';
$bubu = 0;
option('progress', $i/$total_pictures*60);

if ($i == $cnt_i){
  
  $bubu = sprintf("%01d",   ($i == $cnt_i)  );
  option('progress', $i/$total_pictures*60);  // to indicate the progress of the rating

   $fig_name = $list_names_array[$i-1];
   $sec_id_valence = $list_val_array[$i-1];
   $sec_id_arousal = $list_aro_array[$i-1];
   $sec_id_distance = $list_dis_array[$i-1];
   $sec_id_type = $list_type_array[$i-1];

  $cnt_i++;
}


// now put the picture
$real_fig_name = "pro://".$fig_name;
html('
   <div class="spacing" style="text-align:center;margin-bottom:10px;">
      <img src="'.$real_fig_name .'" alt="pic not found">
   </div>
');

// and the rating
question($sec_id_valence);  // Valence
question($sec_id_arousal);  // Arousal
if  ($sec_id_type == "Alone")  {
} else {
	question($sec_id_distance);  // Distance
}




FEHLERMELDUNG:

    There is an error in the PHP code:
Questionnaire Error: The PHP variable $sec_id_type has been used but the variable is yet undefined (the variable has no value).

PHP code

040 ');
041 
042 
043 question($sec_id_valence);  
044 question($sec_id_arousal);  
045 if  ($sec_id_type == "Alone")  {
046 } else {
Questionnaire Error: The PHP variable $sec_id_arousal has been used but the variable is yet undefined (the variable has no value).

PHP code

041 
042 
043 question($sec_id_valence);  
044 question($sec_id_arousal);  
045 if  ($sec_id_type == "Alone")  {
046 } else {
047 	question($sec_id_distance);  
Questionnaire Error: The PHP variable $sec_id_type has been used but the variable is yet undefined (the variable has no value).

PHP code

042 
043 question($sec_id_valence);  
044 question($sec_id_arousal);  
045 if  ($sec_id_type == "Alone")  {
046 } else {
047 	question($sec_id_distance);  
048 }
Questionnaire Error: The PHP variable $sec_id_distance has been used but the variable is yet undefined (the variable has no value).

PHP code

044 question($sec_id_arousal);  
045 if  ($sec_id_type == "Alone")  {
046 } else {
047 	question($sec_id_distance);  
048 }
049 
050 

1 Answer

0 votes
by s139847 (2.7k points)

Hallo,

es sieht so aus, als würde der Fehler geworfen, weil bei einer Nicht-Beantwortung einer Frage für die entsprechenden Arrays in der if Bedingung

if ($i == $cnt_i){}

kein Wert gesetzt wird, der ja dann später natürlich auch nich ausgelesen werden kann. Sie können also hier entweder eine else-clause einfügen, der einen Standardwert in Ihr Array schreibt, wenn es keine Antwort gibt oder unten dafür sorgen, dass in dem Fall die Frage gar nicht erst versucht wird aufzurufen.

Viele Grüße

by s113495 (135 points)
edited by s139847
Danke für die Antwort.

Jetzt verstehe ich zwar, dass der Fehler daher kommt, dass bei nicht Beantwortung $cnt_i schon eins weiter ist, währen $i gleich geblieben ist.

Aber leider ist mir immer noch nicht klar, wie ich das Problem umgehen kann.

Wenn ich nämlich die if Bedingung erst nach dem Anzeigen des Bildes und der ratings schliesse, gibt es zwar keine Fehler mehr, dafür aber auch kein Wiederholen der Frage bei Nicht-Beantwortung.

Gibt es im Forum schon eine ähnliche Situation mit loopPage, von der ich lernen könnte?

Danke

LG

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...