For what you originally intended to write, you'd want to write it like this:
<<if ($vaara is "vaara") or ($vaara is "VAARA")>>Chest opens. [[Next task|task3]].
<<else>>Chest doesn't open. [[Try something else|returntask2]]?
<</if>>
<<set $visitedluokka to true>>
However, you can simplify that by using the .toLowerCase() method like this:
<<if $vaara.toLowerCase() is "vaara">>Chest opens. [[Next task|task3]].
<<else>>Chest doesn't open. [[Try something else|returntask2]]?
<</if>>
<<set $visitedluokka to true>>
The .toLowerCase() method makes that variable act as though it's all in lowercase, though it doesn't actually change the value of that variable. This means it would match "Vaara", "VAARA", "vAaRa", etc... See the link above for more details on that method.
This code:
<<if $visitedluokka is true>> Random flashback to your childhood.
<</if>>
should work fine. Though, you could shorten that to just this:
<<if $visitedluokka>> Random flashback to your childhood.
<</if>>
If there is any "truthy" value in $visitedluokka, then the code inside the <<if>> there will be executed.
A "truthy" value is any value which is not false, 0 (zero), "" (an empty string), null, undefined, or NaN (Not a Number), which are all of the "falsy" values.
If you were getting an error on that part, then it might be caused by another problem or error earlier in the code there or by a problem within the area of the code where you have "Random flashback to your childhood." inside that <<if>>. If you still have problems with that, then you may need to post more of the code around those lines before we can figure out what went wrong.
Hope that helps! :-)