0 votes
in SoSci Survey (English) by s219203 (310 points)
closed by s219203

I have a set of items (pictures) within a selection sequence question that are rotated and interspersed with other text items. I would like for the participants to know how many picture items they saw over the total number of picture items. In other words, I want a placeholder counting only the picture elements of a bigger selection sequence question. [Using the existing placeholders %i.num% and %i.cnt% consider ALL items (pictures and text), rather than only counting the picture's position from a total of X pictures...]

Looking into the manual, it seems that an internal variable might work, if I can program a new counting variable that starts at zero and increment by 1 when each picture is shown. After which I could add a custom placeholder in the text box of the picture's question, which would consider how many times the "counter" has been used so far. I would insert the placeholder in the picture items only (not the text item)...

I feel this is feasible, looking at articles such as this one, but I'm not savvy enough in Javascript to understand the subtleties. Perhaps there is an easier way as well...

Thank you!

closed with the note: Answered
by SoSci Survey (304k points)
I am not sure, if I understand your question properly. You have all items within a single selection sequence, right? Then using %i.num% should work finde, because it shows the number of the item within the question?!
by s219203 (310 points)
Yes %i.num% does work properly (meaning that it counts correctly the items within the selection sequence). The items in the selection sequence are mixed up as I have pictures and text items. I would only want %i.num% to consider the PICTURES, and sort of "skip" the text items (i.e., not count them in the total %i.cnt% nor increment %i.num%). I still want to present the text items, they are essential to my task, but I don't want them to be associated with a number.

2 Answers

+1 vote
by s219203 (310 points)
 
Best answer

FINAL CODE:

As a PHP code on the page where we want the picture task.

$practice = array_values(valueList('RG04'));
$bogus = array_values(valueList('RG02'));
$items = array_values(valueList('RG01'));
$allItems = array_merge( 
  array_slice($bogus, 0, 1),
  array_slice($practice, 0, 3),  
  [95],
  array_slice($items, 0, 25),
  array_slice($bogus, 1, 1),
  array_slice($items, 25, 25),
  array_slice($bogus, 2, 1),
  array_slice($items, 50, 20),
  array_slice($bogus, 3, 1),
  array_slice($items, 70, 20)
);
$placeholders = [];
$num = 0;
foreach ($allItems as $itemID) {
  if ($itemID <= 90) {
    $num++;
    $placeholders['%num.'.$itemID.'%'] = $num;
  }
}
show('IT03', array_merge(
  $placeholders,
  ['items' => $allItems]
));

Sub-questions in the selection sequence question have been added the text "Image %num.1% of 90" (subsequent sub-questions = num.2, num.3, num.4) - The PHP code takes care of renumbering these elements sequentially as they appear in the questionnaire, according to the requested rotation.

0 votes
by SoSci Survey (304k points)

As none of the automated features will know about your distinction between images and text items, you will have to do the rotation manually.

That means: You disable the automated translation, but instead use an Array and shuffle() to take care of the rotation. Then you place placeholders in each text item, such as num.1 for the first item, num.2 for the second, and so on.

Then you need some more PHP code. That code has to go through the (rotated) list of items, and put a number (i.e., prepare a placeholder) on each text item. That will need a counter variable, and if you put all texts together, it will be easier to distinguish between texts and images.

by s219203 (310 points)
Hum... I'm receiving an error message for each placeholder (i.e., "For the placeholder %num.1% neither an input field by prepare_input() has been created nor any content by using replace().") and the text shows "Image %num.1% of 90".

I copy-pasted the exact PHP code you provided on the page prior to my rotation code, and added %num.1% in item 1, %num.2% in item 2, etc. I did nothing to the rotation code.
by SoSci Survey (304k points)
Are you using the show() function as stated above? This allows to store placeholders without making the storage in the background explode.

Eventually test, what this line says:

debug($placeholders);
by s219203 (310 points)
I did copy the whole code, including show().
But *where* should I put this code?

Here's what the debug($placeholders) shows:
[Note that the "%num.XX%" is superscript before the numbers 1, 2, 3, ...]

Content: %num.75%1, %num.78%2, %num.32%3, %num.86%4, %num.79%5, %num.49%6, %num.88%7, %num.21%8, %num.42%9, %num.40%10, %num.81%11, %num.22%12, %num.6%13, %num.56%14, %num.71%15, %num.20%16, %num.43%17, %num.13%18, %num.85%19, %num.50%20, %num.57%21, %num.90%22, %num.72%23, %num.12%24, %num.25%25, %num.84%26, %num.58%27, %num.74%28, %num.11%29, %num.8%30, %num.30%31, %num.89%32, %num.62%33, %num.17%34, %num.35%35, %num.65%36, %num.60%37, %num.7%38, %num.48%39, %num.4%40, %num.67%41, %num.64%42, %num.16%43, %num.5%44, %num.3%45, %num.69%46, %num.46%47, %num.52%48, %num.2%49, %num.33%50, %num.26%51, %num.53%52, %num.73%53, %num.10%54, %num.39%55, %num.61%56, %num.51%57, %num.87%58, %num.83%59, %num.19%60, %num.14%61, %num.44%62, %num.23%63, %num.59%64, %num.70%65, %num.76%66, %num.29%67, %num.18%68, %num.36%69, %num.15%70, %num.77%71, %num.38%72, %num.31%73, %num.63%74, %num.47%75, %num.24%76, %num.9%77, %num.80%78, %num.45%79, %num.27%80, %num.82%81, %num.34%82, %num.54%83, %num.41%84, %num.68%85, %num.55%86, %num.1%87, %num.28%88, %num.37%89, %num.66%90
by SoSci Survey (304k points)
Looks good.

> But *where* should I put this code?

Instead of
question('IT03', $allItems);
from your original code.
by s219203 (310 points)
Ah! Wonderful! It works!
Many many thanks!

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

...