[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [gcompris/gsoc_pulkit_digital_electricity] src/activities/digital_electricity: digital_electricity: 
From:       Rudra Nil Basu <null () kde ! org>
Date:       2017-08-15 14:11:29
Message-ID: E1dhcZ7-0008HM-CL () code ! kde ! org
[Download RAW message or body]

Git commit c7331e4e1a72cf895e0323a6224c2384225e33c6 by Rudra Nil Basu.
Committed on 15/08/2017 at 14:00.
Pushed by rudranilbasu into branch 'gsoc_pulkit_digital_electricity'.

digital_electricity: level 12: NOT gate using NAND

Level 12 is aimed at teaching the user to create one gate using other
gates. In this level, the user is asked to create a NOT gate using a
NAND gate only.

For dfbce1eb "digital_electricity: Update answer checking" fixed problem
of result not showing up and switches not setting up to correct values
on wrong answer. This is fixed by added:

  updateComponent(switch3.index)
  items.bonus.bad('tux')

for each of the above levels.

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

M  +13   -1    src/activities/digital_electricity/Dataset.qml
M  +27   -1    src/activities/digital_electricity/digital_electricity.js

https://commits.kde.org/gcompris/c7331e4e1a72cf895e0323a6224c2384225e33c6

diff --git a/src/activities/digital_electricity/Dataset.qml \
b/src/activities/digital_electricity/Dataset.qml index 5415bc1c..e0e24fa7 100644
--- a/src/activities/digital_electricity/Dataset.qml
+++ b/src/activities/digital_electricity/Dataset.qml
@@ -233,10 +233,22 @@ QtObject {
             playAreaComponentPositionX: [0.6, 0.8],
             playAreaComponentPositionY: [0.5, 0.5],
             introMessage: [
-                qsTr("A NOT gate takes 2 binary input and outputs 1 if both of them \
are 0, otherwise produces an output of 1."), +                qsTr("A NOR gate takes \
2 binary input and outputs 1 if both of them are 0, otherwise produces an output of \
                1."),
                 qsTr("For a more detailed description about the gate, select it and \
click on the info button."),  qsTr("Light the bulb using the NOR gate provided.")
             ]
+        },
+        // level 12
+        {
+            inputComponentList: [nandGate],
+            playAreaComponentList: [one, switchKey, digitalLight],
+            determiningComponentsIndex: [1, 2],
+            wires: [ [0, 0, 1, 0] ],
+            playAreaComponentPositionX: [0.1, 0.3, 0.8],
+            playAreaComponentPositionY: [0.5, 0.5, 0.5],
+            introMessage: [
+                qsTr("Use the gates such that the bulb will glow only when the \
switch is turned off and remain off when the switch is turned on.") +            ]
         }
     ]
 }
diff --git a/src/activities/digital_electricity/digital_electricity.js \
b/src/activities/digital_electricity/digital_electricity.js index dc2eade0..66feb19e \
                100644
--- a/src/activities/digital_electricity/digital_electricity.js
+++ b/src/activities/digital_electricity/digital_electricity.js
@@ -250,7 +250,7 @@ function isTutorialMode() {
 
 function checkAnswer() {
     // for levels with single light
-    if (currentLevel != 6 && currentLevel != 8 && currentLevel != 10) {
+    if (currentLevel != 6 && currentLevel != 8 && currentLevel != 10 && currentLevel \
!= 12) {  if (determiningComponents[0].inputTerminals.itemAt(0).value == 1)
             items.bonus.good('tux')
         else
@@ -314,6 +314,8 @@ function checkAnswer() {
                         switch3.imgSrc = switch3InitialState
                         updateComponent(switch1.index)
                         updateComponent(switch2.index)
+                        updateComponent(switch3.index)
+                        items.bonus.bad('tux')
                         return
                     }
                 }
@@ -350,12 +352,36 @@ function checkAnswer() {
                         switch3.imgSrc = switch3InitialState
                         updateComponent(switch1.index)
                         updateComponent(switch2.index)
+                        updateComponent(switch3.index)
+                        items.bonus.bad('tux')
                         return
                     }
                 }
             }
         }
         items.bonus.good('tux')
+    } else if (currentLevel == 12) {
+        var switch1 = determiningComponents[0]
+
+        var digitalLight = determiningComponents[1]
+
+        var switch1InitialState = switch1.imgSrc
+
+        for (var A = 0; A <= 1; A++) {
+            switch1.imgSrc = A == 1 ? "switchOn.svg" : "switchOff.svg"
+
+            updateComponent(switch1.index)
+
+            var operationResult = !A
+
+            if (operationResult != digitalLight.inputTerminals.itemAt(0).value) {
+                switch1.imgSrc = switch1InitialState
+                updateComponent(switch1.index)
+                items.bonus.bad('tux')
+                return
+            }
+        }
+        items.bonus.good('tux')
     }
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic