Setting the value of a variable to an assignment operator

I wanna set the value of a variable to an assignment operator like “=”. And then wanna compare it using if statement whether it is equal or not if it is, I move to the next chapter. It’s inside a Listbox.
<<listbox “$response2”>>
<<option “=”>>
<<option “not equals”>>
<<option “<”>>
<<option “>”>>
<>
<< if $response2 is “=”>>
[[CORRECT|Chapter 2]]

Please use the Preformatted text </> option when including a code example in a comment.
I believed your example was meant to look something like…

<<listbox "$response2">>
	<<option "=">>
	<<option "not equals">>
	<<option "<">>
	<<option ">">>
<</listbox>>
<<if $response2 is "=">>
[[CORRECT|Chapter 2]]
<</if>>

There are two issues with the above code:

1: The <<if>> macro will be evaluate before the end-user has had a chance to interact with the listbox.

The entire content of a Passage is processed before the HTML elements that are generated are added to the Page, and conditional expressions are not re-evaluated when an associated variable changes its value.

To overcome this fact you will need to place your <> macro call within an interactive component like a <> like so…

<<link "Check Answer">>
	<<if $response2 is "=">>
		/* do something. */
	<</if>>
<</link>>

2: The argument parser of the <<if>> macro will display an error message if is finds an assignment operator (like =) within the arguments being passed to the macro, this is to stop Authors from making mistakes like <<if $varaiable = "value">>, which would result in the current value of the $variable being changed to be “value”.

To overcome this issue you can assign the String “=” to another variable and then compare the to variables.

The following example uses the above information, along with Custom Style markup to create an area to display an outcome and the <<replace>> macro to insert the outcome into that area.

<<set _equalSign to "=">>
<<listbox "$response2">>
	<<option _equalSign>>
	<<option "not equals">>
	<<option "<">>
	<<option ">">>
<</listbox>>

<<link "Check Answer">>
	<<if $response2 is _equalSign>>
		<<replace "#outcome">>[[CORRECT|Chapter 2]]<</replace>>
	<<else>>
		<<replace "#outcome">>TRY AGAIN<</replace>>
	<</if>>
<</link>>

@@#outcome;@@

Thanks a lot!!!