digital_electricity: Update answer checking

Authored by rudranilbasu on Aug 14 2017, 1:33 PM.

Description

digital_electricity: Update answer checking

The answer checking has been changed from random test cases to all the
possible test cases.

For few levels, the answer checking is simply to check if the bulb is
glowing or not, for those, we are checking the value of:

determiningComponents[0].inputTerminals.itemAt(0).value

If it is 1, then the answer is correct, else false

For the others, primarily we are storing the values of the initial state
of the switches (to restore it back later) in:

var switch1InitialState = switch1.imgSrc
...

We then traverse through all the possible scenarios, for each of the
cases we are checking if the actual answer (stored in "operationResult")
is the same as the answer provided (denoted by whether the light is
glowing or not, determined by the value of
digitalLight.inputTerminals.itemAt(0).value)

If they do not match, we display that the answer is incorrect and reset
the values of the switces, as it was stored in switchxInitialState. If it
passes all the test cases, we display that the answer is correct and
move on to the next level

Also updated few intromessage for few levels, fixing grammatical errors

Signed-off-by: Rudra Nil Basu <rudra.nil.basu.1996@gmail.com>

Details

Committed
rudranilbasuAug 14 2017, 1:33 PM
Parents
R2:39ecb0ed0b96: digital_electricity: level 8 added
Branches
Unknown
Tags
Unknown
Restricted Application added a subscriber: jjazeix. ยท View Herald TranscriptAug 14 2017, 8:57 PM
jjazeix added inline comments.Aug 15 2017, 5:54 PM
/src/activities/digital_electricity/digital_electricity.js
298

is there a way to factorise it, as it is the same as below except for the operationResult? (above is the same with only 2 switches too, it may be trickier to factorise)

rudranilbasu added inline comments.Aug 15 2017, 6:29 PM
/src/activities/digital_electricity/digital_electricity.js
298

yes, I kept it like this for now because I am not sure about whether the answer checking will take a different route once
we move on to other components like BCD counter, etc. After implementing the levels for the tutorial mode, it will be
easier to generalise the answer checking algorithm.

rudranilbasu added inline comments.Aug 18 2017, 9:04 PM
/src/activities/digital_electricity/digital_electricity.js
298

I have updated the answer checking process, in which the similar levels are grouped together
and a total of 5 groups are created, each of these groups having a generalised checking of
the answer.
Commit links: 08d66bb and 0a79ffc