+xSome clarification...
In this part of the script, it should randomly pick 4 items from the list (after removing all significant items). I think the mistake is there maybe...
/ ontrialend = [
var i = 0;
while (i < item.Lastnames.itemcount){
i += 1;
list.controlLastname.appenditem(i);
};
item.controlItems.appenditem(item.Lastnames.item(list.controlLastname.nextvalue));
item.controlItems.appenditem(item.Lastnames.item(list.controlLastname.nextvalue));
item.controlItems.appenditem(item.Lastnames.item(list.controlLastname.nextvalue));
item.controlItems.appenditem(item.Lastnames.item(list.controlLastname.nextvalue));
]
</surveypage>
<list controlLastname>
/ selectionrate = always
</list>
Your logic for removing items is flawed. When you remove item 1 from the item element, what was previously item 2 is item number 1 after the removal of the first item.
So, this whole section here
/ ontrialend = [
if(checkboxes.significantLastname.checked.1) {
item.Lastnames.removeitem(1);
};
if(checkboxes.significantLastname.checked.2) {
item.Lastnames.removeitem(2);
};
if(checkboxes.significantLastname.checked.3) {
item.Lastnames.removeitem(3);
};
if(checkboxes.significantLastname.checked.4) {
item.Lastnames.removeitem(4);
};
if(checkboxes.significantLastname.checked.5) {
item.Lastnames.removeitem(5);
};
if(checkboxes.significantLastname.checked.6) {
item.Lastnames.removeitem(6);
};
if(checkboxes.significantLastname.checked.7) {
item.Lastnames.removeitem(7);
};
if(checkboxes.significantLastname.checked.8) {
item.Lastnames.removeitem(8);
};
if(checkboxes.significantLastname.checked.9) {
item.Lastnames.removeitem(9);
};
if(checkboxes.significantLastname.checked.10) {
item.Lastnames.removeitem(10);
};
if(checkboxes.significantLastname.checked.11) {
item.Lastnames.removeitem(11);
};
if(checkboxes.significantLastname.checked.12) {
item.Lastnames.removeitem(12);
};
if(checkboxes.significantLastname.checked.13) {
item.Lastnames.removeitem(13);
};
if(checkboxes.significantLastname.checked.14) {
item.Lastnames.removeitem(14);
};
if(checkboxes.significantLastname.checked.15) {
item.Lastnames.removeitem(15);
};
if(checkboxes.significantLastname.checked.16) {
item.Lastnames.removeitem(16);
};
]
will in effect remove the wrong items.
Consider this simple example, removing items 1 and 2 -- in this order -- from the item element.
<block myblock>
/ onblockbegin = [
item.myitem.removeitem(1);
item.myitem.removeitem(2);
]
/ postinstructions = (end)
</block>
<item myitem>
/ 1 = "a"
/ 2 = "b"
/ 3 = "c"
/ 4 = "d"
</item>
<page end>
Items left in item element:
<%item.myitem.item(1)%>
<%item.myitem.item(2)%>
</page>
You might think this would result in the removal of item "a" and "b", but that's wrong. It will remove item "a". Item "b" then immediately is the new item 1, and the new item 2, "c" will be removed.
The simple fix to this is to work backwards:
<block myblock>
/ onblockbegin = [
item.myitem.removeitem(2);
item.myitem.removeitem(1);
]
/ postinstructions = (end)
</block>
<item myitem>
/ 1 = "a"
/ 2 = "b"
/ 3 = "c"
/ 4 = "d"
</item>
<page end>
Items left in item element:
<%item.myitem.item(1)%>
<%item.myitem.item(2)%>
</page>