[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-20 7:25:23
Message-ID: E1djKbr-000322-O5 () code ! kde ! org
[Download RAW message or body]

Git commit abfae71c78a39b966150b1175536e08151e70258 by Rudra Nil Basu.
Committed on 20/08/2017 at 06:47.
Pushed by rudranilbasu into branch 'gsoc_pulkit_digital_electricity'.

digital_electricity: use 7 segment display in level 22

Level 22: The output of the BCD counter is displayed on the seven
segment display via the BCD to seven segment component.

Answer is checked by comparing the values of the BCD counter and that of
the BCD to seven segment display and by checking if all of the terminals
of the components are connected (they may both be = 0 if not connected)

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

M  +10   -11   src/activities/digital_electricity/Dataset.qml
M  +7    -6    src/activities/digital_electricity/digital_electricity.js

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

diff --git a/src/activities/digital_electricity/Dataset.qml \
b/src/activities/digital_electricity/Dataset.qml index 937c037f..438dd160 100644
--- a/src/activities/digital_electricity/Dataset.qml
+++ b/src/activities/digital_electricity/Dataset.qml
@@ -163,7 +163,7 @@ QtObject {
             playAreaComponentPositionY: [0.3, 0.3],
             type: [problemType.lightTheBulb],
             introMessage: [
-                qsTr("The AND Gate produces an output of one when both of its input \
terminal are of value 1"), +                qsTr("The AND Gate produces an output of \
                one when both of its input terminals are of value 1"),
                 qsTr("Turn the Digital light on using an AND gate and the inputs \
provided")  ]
         },
@@ -217,7 +217,7 @@ QtObject {
             playAreaComponentPositionY: [0.0, 0.8, 0.3, 0.6, 0.4],
             type: [problemType.equation2Variables],
             introMessage: [
-                qsTr("Light the bulb using both the switches such that the bulb will \
glow when only one of the switches are turned on") +                qsTr("Light the \
bulb using both the switches such that the bulb will glow only when either the first \
switch is on and the second switch is off or the first switch is off and the second \
switch is on.")  ]
         },
         // level 7
@@ -431,17 +431,16 @@ QtObject {
         // level 22
         {
             inputComponentList: [one, switchKey, nandGate, norGate, andGate, orGate, \
                notGate],
-            playAreaComponentList: [signalGenerator, bcdCounter, digitalLight, \
                digitalLight, digitalLight, digitalLight],
-            determiningComponentsIndex: [1, 2, 3, 4, 5],
-            wires: [  ],
-            playAreaComponentPositionX: [0.1, 0.3, 0.7, 0.7, 0.7, 0.7],
-            playAreaComponentPositionY: [0.2, 0.5, 0.2, 0.4, 0.6, 0.8],
+            playAreaComponentList: [signalGenerator, bcdCounter, bcdToSevenSegment, \
sevenSegmentDisplay], +            determiningComponentsIndex: [1, 2],
+            wires: [ [2, 0, 3, 0], [2, 1, 3, 1], [2, 2, 3, 2], [2, 3, 3, 3], [2, 4, \
3, 4], [2, 5, 3, 5], [2, 6, 3, 6] ], +            playAreaComponentPositionX: [0.0, \
0.1, 0.4, 0.8], +            playAreaComponentPositionY: [0.2, 0.6, 0.2, 0.2],
             type: [problemType.others],
             introMessage: [
-                qsTr("The signal generator on the left is used to generate \
alternating signals between 0 and 1 in a given time period take as input. The time \
                period by default is 1 second, but it can be changed between 0.25 and \
                2s"),
-                qsTr("The BCD counter placed next to it is a special type of counter \
                which can count from 0 to 10 and back to 0 on application of a clock \
                signal."),
-                qsTr("The value of the counter is in the form a BCD number in the \
                output of the BCD counter, with 'A' representing the least \
                significant bit."),
-                qsTr("Connect the components to make sure that the count of 0 to 10 \
is visible in the digital lights provided.") +                qsTr("The signal \
generator on the left is used to generate alternating signals between 0 and 1 in a \
given time period taken as input. The time period by default is 1 second, but it can \
be changed between 0.25 and 2s"), +                qsTr("The BCD counter placed under \
it is a special type of counter which can count from 0 to 9 and back to 0 on \
application of a clock signal."), +                qsTr("Connect the components to \
make sure that the count of 0 to 9 is visible in the seven segment dispay provided.") \
]  }
     ]
diff --git a/src/activities/digital_electricity/digital_electricity.js \
b/src/activities/digital_electricity/digital_electricity.js index cce53fae..0c87d25b \
                100644
--- a/src/activities/digital_electricity/digital_electricity.js
+++ b/src/activities/digital_electricity/digital_electricity.js
@@ -305,11 +305,12 @@ function checkAnswer() {
                     bcdCounter.outputTerminals.itemAt(1).value * 4 +
                     bcdCounter.outputTerminals.itemAt(0).value * 8
 
-            var digitalLightOutput =
-                    determiningComponents[4].inputTerminals.itemAt(0).value +
-                    determiningComponents[3].inputTerminals.itemAt(0).value * 2 +
-                    determiningComponents[2].inputTerminals.itemAt(0).value * 4 +
-                    determiningComponents[1].inputTerminals.itemAt(0).value * 8
+            var bcdToSevenSegment = determiningComponents[1]
+            var decimalValue =
+                    bcdToSevenSegment.inputTerminals.itemAt(3).value +
+                    (bcdToSevenSegment.inputTerminals.itemAt(2).value * 2) +
+                    (bcdToSevenSegment.inputTerminals.itemAt(1).value * 4) +
+                    (bcdToSevenSegment.inputTerminals.itemAt(0).value * 8)
 
             if (bcdCounter.inputTerminals.itemAt(0).wires.length == 0 ||
                     bcdCounter.outputTerminals.itemAt(0).wires.length == 0 ||
@@ -320,7 +321,7 @@ function checkAnswer() {
                 processingAnswer = false
                 return
             }
-            if ((bcdOutput == digitalLightOutput) && \
(bcdCounter.inputTerminals.itemAt(0).wires.length != 0) ) { +            if \
((bcdOutput == decimalValue) && (bcdCounter.inputTerminals.itemAt(0).wires.length != \
0) ) {  items.bonus.good('tux')
                 return
             }


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

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