The problem is that the ifs, thens, and elses don't connect the way you want. In particular you need to be careful about the difference between "else if" and "elif". The first one, "else if", introduces a new statement block that requires more indented 'fi's that match the correct 'if'. The second, "elif", matches the nearest "if" statement, making placement of 'fi's easier (for me at least).
Another problem is that an "else" clause attaches to the nearest "if". Because of that, your template will return 'reader.png' if k does not contain '^Send to Device$' even if it contains '^Kobo Store$'.
Here is my guess for what you want:
Code:
program:
k = field('#kobocoll');
if check_yes_no('#onkobo', 0, 1, 0) then
'sync.png'
elif check_yes_no('#onkobo', 0, 0, 1) then
if list_contains(k, ',', '^Kobo Store$', '1', '') then
'drm-locked.png'
elif list_contains(k, ',', '^Send to Device$', '1', '') then
'sync.png'
else
'reader.png'
fi
fi
I don't have the columns or values so I can't test it.
Question: is #kobocoll tags-like? If not then you can use
Code:
if k == 'Kobo Store' then
instead of list_contains()