Hi so in the following block of code I am being returned a value I should not be, specifically the variable $j. It is returning $j as 1 instead of 3 which I want it too. What is the problem?
// START CODE BLOCK
That’s correct! Now let’s assume we want to know the reliability of the process at five given times (1, 5, 10, 30, 60 minutes). First input the MTTF you calculated in the last step, and then calculate the reliability at each time t (minutes).
CHECKPOINT START
MTTF: <<textbox “$mttf” “”>>
<<set $i=3>>
<<link “CHECK MY OBSERVATIONS”>><<replace “#test”>>
<<if 20 <= $mttf && $mttf <= 60>>
<<if $i == 3>>
<<set $scores = $scores + 1.0>>
<>
<<set $scores = $scores + 0>>
<>
<<set $r1 = Math.exp((1/$mttf)(1))>>
<<set $r5 = Math.exp((1/$mttf)(5))>>
<<set $r10 = Math.exp((1/$mttf)(10))>>
<<set $r30 = Math.exp((1/$mttf)(30))>>
<<set $r60 = Math.exp((1/$mttf)*(60))>>
Great! Now fill in the corresponding reliability for each given time:
Time t (minutes):
t = 1 minute:
Reliability = <<textbox “$response1” “”>>
t = 5 minutes:
Reliability = <<textbox “$response2” “”>>
t = 10 minutes:
Reliability = <<textbox “$response3” “”>>
t = 30 minutes:
Reliability = <<textbox “$response4” “”>>
t = 60 minutes:
Reliability = <<textbox “$response5” “”>>
<<if $visited == 1>>
<<set $j=3>>
<>
You have $j chances total. // THIS LINE RETURNS J = 1
<<if $j eq 0>>
[[CORRECT|Chapter64.2]]
<>
/* **** set up the limitations *** */
<<if $j gte 0>>
<<set $visited = 0>>
<<set $j = $j-1>>
<<button “Submit”>>
<<replace “#choice”>><<print "Your answer: ">>
$response1
<<if $response1 gte ($r1 - 0.05) and $response1 lte ($r1 + 0.05) and $response2 gte ($r5 - 0.05) and $response2 lte ($r5 + 0.05) and $response3 gte ($10 - 0.05) and $response3 lte ($r10 + 0.05) and $response4 gte ($r30 - 0.05) and $response4 lte ($r30 + 0.05) and $response5 gte ($r60 - 0.05) and $response5 lte ($r60 + 0.05)>>
/**** Add the score here **** */
<<set $chance = $j>>
<<if $j eq 2>>
<<set $scores = $scores + 5>>
<<elseif $j eq 1>>
<<set $scores = $scores + 4>>
<<elseif $j eq 0>>
<<set $scores = $scores + 3>>
<>
\
[[CORRECT|Chapter64.2]]
<>
[[INCORRECT|Chapter63.2.1]]
<>
<>
<>
<>
<>
<<popover ‘noclick’>>Sorry, please try again.<>
<>
<<set $i = $i - 1>>
<><>
// END CODE BLOCK