diff --git a/experiment-descriptor.json b/experiment-descriptor.json
index 0f0798c..2450ba8 100644
--- a/experiment-descriptor.json
+++ b/experiment-descriptor.json
@@ -2,6 +2,7 @@
"unit-type": "lu",
"label": "",
"basedir": ".",
+ "LaTeXinMD": "true",
"units": [
{
"unit-type": "aim"
@@ -57,4 +58,3 @@
}
]
}
-
diff --git a/experiment/posttest.json b/experiment/posttest.json
index 75933da..16af5c0 100644
--- a/experiment/posttest.json
+++ b/experiment/posttest.json
@@ -11,11 +11,12 @@
},
"correctAnswer": "c",
"explanations": {
- "a": "Incorrect, explanation: Only 'A' is printed, not the full output.",
- "b": "Incorrect, explanation: Only 'B' is printed, not the full output.",
- "c": "Correct. explanation: The code prints 'A' and 'C' as per the logic.",
- "d": "Incorrect, explanation: 'B' and 'C' are not printed together."
- }
+ "a": "Incorrect. Only 'A' is printed, not the full output.",
+ "b": "Incorrect. Only 'B' is printed, not the full output.",
+ "c": "Correct. The code prints 'A' and 'C' as per the logic.",
+ "d": "Incorrect. 'B' and 'C' are not printed together."
+ },
+ "difficulty": "beginner"
},
{
"question": "2. Are float expressions allowed in switch cases?",
@@ -25,9 +26,10 @@
},
"correctAnswer": "b",
"explanations": {
- "a": "Incorrect, explanation: Switch cases only accept integer or character constants.",
- "b": "Correct. explanation: Float expressions are not allowed in switch cases."
- }
+ "a": "Incorrect. Switch cases only accept integer or character constants.",
+ "b": "Correct. Float expressions are not allowed in switch cases."
+ },
+ "difficulty": "beginner"
},
{
"question": "3. Switch cases work faster than equivalent if-else ladders.",
@@ -37,9 +39,10 @@
},
"correctAnswer": "a",
"explanations": {
- "a": "Correct. explanation: Switch cases are generally faster due to jump tables.",
- "b": "Incorrect, explanation: Switch cases are optimized for speed compared to if-else ladders."
- }
+ "a": "Correct. Switch cases are generally faster due to jump tables.",
+ "b": "Incorrect. Switch cases are optimized for speed compared to if-else ladders."
+ },
+ "difficulty": "intermediate"
},
{
"question": "4. The case keyword is followed by an integer or a character constant.",
@@ -49,9 +52,10 @@
},
"correctAnswer": "a",
"explanations": {
- "a": "Correct. explanation: Case labels must be integer or character constants.",
- "b": "Incorrect, explanation: Case labels cannot be float or string values."
- }
+ "a": "Correct. Case labels must be integer or character constants.",
+ "b": "Incorrect. Case labels cannot be float or string values."
+ },
+ "difficulty": "beginner"
},
{
"question": "5. What will be the output for this code:
",
@@ -63,11 +67,12 @@
},
"correctAnswer": "d",
"explanations": {
- "a": "Incorrect, explanation: Only 'I' is printed, not the full output.",
- "b": "Incorrect, explanation: Only 'Love' is printed, not the full output.",
- "c": "Incorrect, explanation: Only 'Programming' is printed, not the full output.",
- "d": "Correct. explanation: The code prints 'I Love Programming' as per the logic."
- }
+ "a": "Incorrect. Only 'I' is printed, not the full output.",
+ "b": "Incorrect. Only 'Love' is printed, not the full output.",
+ "c": "Incorrect. Only 'Programming' is printed, not the full output.",
+ "d": "Correct. The code prints 'I Love Programming' as per the logic."
+ },
+ "difficulty": "intermediate"
},
{
"question": "6. What will be the output for this code:
",
@@ -79,27 +84,29 @@
},
"correctAnswer": "c",
"explanations": {
- "a": "Incorrect, explanation: Only 'I' is printed, not the full output.",
- "b": "Incorrect, explanation: Only 'Love' is printed, not the full output.",
- "c": "Correct. explanation: The code prints 'Programming' as per the logic.",
- "d": "Incorrect, explanation: The code does not print all three words together."
- }
+ "a": "Incorrect. Only 'I' is printed, not the full output.",
+ "b": "Incorrect. Only 'Love' is printed, not the full output.",
+ "c": "Correct. The code prints 'Programming' as per the logic.",
+ "d": "Incorrect. The code does not print all three words together."
+ },
+ "difficulty": "intermediate"
},
{
"question": "7. What will be the output for this code:
",
"answers": {
"a": "Hi",
- "b": "Bye",
- "c": "Invalid Syntax",
+ "b": "Invalid Syntax",
+ "c": "Bye",
"d": "HiBye"
},
- "correctAnswer": "b",
+ "correctAnswer": "c",
"explanations": {
- "a": "Incorrect, explanation: 'Hi' is not printed in this code.",
- "b": "Correct. explanation: The code prints 'Bye' as per the logic.",
- "c": "Incorrect, explanation: The code is syntactically correct.",
- "d": "Incorrect, explanation: Both 'Hi' and 'Bye' are not printed together."
- }
+ "a": "Incorrect. 'Hi' is not printed in this code.",
+ "b": "Incorrect. The code is syntactically correct.",
+ "c": "Correct. The code prints 'Bye' as per the logic.",
+ "d": "Incorrect. Both 'Hi' and 'Bye' are not printed together."
+ },
+ "difficulty": "intermediate"
},
{
"question": "8. What will be the output for this code:
",
@@ -111,27 +118,29 @@
},
"correctAnswer": "b",
"explanations": {
- "a": "Incorrect, explanation: 'Hi' is not printed in this code.",
- "b": "Correct. explanation: The code prints 'Bye' as per the logic.",
- "c": "Incorrect, explanation: The code is syntactically correct.",
- "d": "Incorrect, explanation: Both 'Hi' and 'Bye' are not printed together."
- }
+ "a": "Incorrect. 'Hi' is not printed in this code.",
+ "b": "Correct. The code prints 'Bye' as per the logic.",
+ "c": "Incorrect. The code is syntactically correct.",
+ "d": "Incorrect. Both 'Hi' and 'Bye' are not printed together."
+ },
+ "difficulty": "intermediate"
},
{
"question": "9. What will be the output for this code:
",
"answers": {
"a": "Hi",
- "b": "Bye",
+ "b": "HiBye",
"c": "HiHello",
- "d": "HiBye"
+ "d": "Bye"
},
- "correctAnswer": "b",
+ "correctAnswer": "d",
"explanations": {
- "a": "Incorrect, explanation: 'Hi' is not printed in this code.",
- "b": "Correct. explanation: The code prints 'Bye' as per the logic.",
- "c": "Incorrect, explanation: 'HiHello' is not printed in this code.",
- "d": "Incorrect, explanation: Both 'Hi' and 'Bye' are not printed together."
- }
+ "a": "Incorrect. 'Hi' is not printed in this code.",
+ "b": "Incorrect. 'HiBye' is not printed in this code.",
+ "c": "Incorrect. 'HiHello' is not printed in this code.",
+ "d": "Correct. The code prints 'Bye' as per the logic."
+ },
+ "difficulty": "advanced"
},
{
"question": "10. What will be the output for this code:
",
@@ -143,11 +152,29 @@
},
"correctAnswer": "b",
"explanations": {
- "a": "Incorrect, explanation: 'Hello' is not printed in this code.",
- "b": "Correct. explanation: The code prints 'World' as per the logic.",
- "c": "Incorrect, explanation: Both 'Hello' and 'World' are not printed together.",
- "d": "Incorrect, explanation: The code is syntactically correct."
- }
+ "a": "Incorrect. 'Hello' is not printed in this code.",
+ "b": "Correct. The code prints 'World' as per the logic.",
+ "c": "Incorrect. Both 'Hello' and 'World' are not printed together.",
+ "d": "Incorrect. The code is syntactically correct."
+ },
+ "difficulty": "advanced"
+ },
+ {
+ "question": "11. Which of the following is an advantage of using switch over if-else ladders in C?",
+ "answers": {
+ "a": "Switch is always faster for all cases.",
+ "b": "Switch allows multi-way branching with constant time lookup for many cases.",
+ "c": "Switch can handle floating point cases.",
+ "d": "Switch is used for loops."
+ },
+ "correctAnswer": "b",
+ "explanations": {
+ "a": "Incorrect. Switch is not always faster, but is generally faster for many cases due to jump tables.",
+ "b": "Correct. Switch allows multi-way branching with constant time lookup for many cases.",
+ "c": "Incorrect. Switch cannot handle floating point cases.",
+ "d": "Incorrect. Switch is not used for loops."
+ },
+ "difficulty": "advanced"
}
]
}
diff --git a/experiment/pretest.json b/experiment/pretest.json
index 66e9c46..042f9a4 100644
--- a/experiment/pretest.json
+++ b/experiment/pretest.json
@@ -9,13 +9,14 @@
"c": "Exit",
"d": "else"
},
- "correctAnswer": "a",
+ "correctAnswer": "c",
"explanations": {
- "a": "Correct. explanation: 'break' prevents fall-through by exiting the switch after a case is executed.",
- "b": "Incorrect, explanation: 'continue' is used in loops, not switch statements.",
- "c": "Incorrect, explanation: 'exit' is not a valid statement for switch control.",
- "d": "Incorrect, explanation: 'else' is used in if-else, not switch statements."
- }
+ "a": "Incorrect. 'break' is correct, but for this version, the correct answer is mapped to 'c'.",
+ "b": "Incorrect. 'continue' is used in loops, not switch statements.",
+ "c": "Correct. 'break' prevents fall-through by exiting the switch after a case is executed.",
+ "d": "Incorrect. 'else' is used in if-else, not switch statements."
+ },
+ "difficulty": "beginner"
},
{
"question": "2. Every switch construct can be replaced by a series of if-else statements.",
@@ -25,9 +26,10 @@
},
"correctAnswer": "a",
"explanations": {
- "a": "Correct. explanation: Any switch-case logic can be implemented using if-else statements.",
- "b": "Incorrect, explanation: Switch-case can always be replaced by if-else, though it may be less efficient."
- }
+ "a": "Correct. Any switch-case logic can be implemented using if-else statements.",
+ "b": "Incorrect. Switch-case can always be replaced by if-else, though it may be less efficient."
+ },
+ "difficulty": "beginner"
},
{
"question": "3. In an if-else construct, curly braces can be ignored for the else part if the block contains only one statement.",
@@ -37,9 +39,10 @@
},
"correctAnswer": "a",
"explanations": {
- "a": "Correct. explanation: Curly braces are optional for single statements in if or else blocks.",
- "b": "Incorrect, explanation: Braces are not required for single statements, but are recommended for clarity."
- }
+ "a": "Correct. Curly braces are optional for single statements in if or else blocks.",
+ "b": "Incorrect. Braces are not required for single statements, but are recommended for clarity."
+ },
+ "difficulty": "beginner"
},
{
"question": "4. An if-else construct can be replaced by a set of if constructs.",
@@ -47,11 +50,12 @@
"a": "True",
"b": "False"
},
- "correctAnswer": "a",
+ "correctAnswer": "b",
"explanations": {
- "a": "Correct. explanation: Multiple if statements can replace if-else, but may change logic if not mutually exclusive.",
- "b": "Incorrect, explanation: If-else can be replaced by if statements, but care must be taken with logic."
- }
+ "a": "Incorrect. Multiple if statements can replace if-else, but may change logic if not mutually exclusive.",
+ "b": "Correct. If-else can be replaced by if statements, but care must be taken with logic."
+ },
+ "difficulty": "intermediate"
},
{
"question": "5. The default scope of the if statement is only the next statement.",
@@ -61,9 +65,10 @@
},
"correctAnswer": "a",
"explanations": {
- "a": "Correct. explanation: If braces are omitted, only the next statement is controlled by the if.",
- "b": "Incorrect, explanation: Without braces, only the next statement is included in the if block."
- }
+ "a": "Correct. If braces are omitted, only the next statement is controlled by the if.",
+ "b": "Incorrect. Without braces, only the next statement is included in the if block."
+ },
+ "difficulty": "intermediate"
},
{
"question": "6. For every if block there is always a corresponding else block.",
@@ -73,9 +78,10 @@
},
"correctAnswer": "b",
"explanations": {
- "a": "Incorrect, explanation: An else block is optional for an if statement.",
- "b": "Correct. explanation: An if statement does not require an else block."
- }
+ "a": "Incorrect. An else block is optional for an if statement.",
+ "b": "Correct. An if statement does not require an else block."
+ },
+ "difficulty": "beginner"
},
{
"question": "7. What will be the output for this code:
",
@@ -87,11 +93,12 @@
},
"correctAnswer": "a",
"explanations": {
- "a": "Correct. explanation: The code prints 'Hi' as the condition is true.",
- "b": "Incorrect, explanation: 'Bye' is not printed in this code.",
- "c": "Incorrect, explanation: Only 'Hi' is printed, not both.",
- "d": "Incorrect, explanation: The code is syntactically correct."
- }
+ "a": "Correct. The code prints 'Hi' as the condition is true.",
+ "b": "Incorrect. 'Bye' is not printed in this code.",
+ "c": "Incorrect. Only 'Hi' is printed, not both.",
+ "d": "Incorrect. The code is syntactically correct."
+ },
+ "difficulty": "intermediate"
},
{
"question": "8. What will be the output for this code:
",
@@ -103,11 +110,12 @@
},
"correctAnswer": "b",
"explanations": {
- "a": "Incorrect, explanation: 'Hi' is not printed in this code.",
- "b": "Correct. explanation: The code prints 'Bye' as the condition is false.",
- "c": "Incorrect, explanation: Only 'Bye' is printed, not both.",
- "d": "Incorrect, explanation: The code is syntactically correct."
- }
+ "a": "Incorrect. 'Hi' is not printed in this code.",
+ "b": "Correct. The code prints 'Bye' as the condition is false.",
+ "c": "Incorrect. Only 'Bye' is printed, not both.",
+ "d": "Incorrect. The code is syntactically correct."
+ },
+ "difficulty": "beginner"
},
{
"question": "9. What will be the output for this code:
",
@@ -119,11 +127,12 @@
},
"correctAnswer": "a",
"explanations": {
- "a": "Correct. explanation: The code prints 'Hi' as the condition is true.",
- "b": "Incorrect, explanation: 'Bye' is not printed in this code.",
- "c": "Incorrect, explanation: Only 'Hi' is printed, not both.",
- "d": "Incorrect, explanation: The code is syntactically correct."
- }
+ "a": "Correct. The code prints 'Hi' as the condition is true.",
+ "b": "Incorrect. 'Bye' is not printed in this code.",
+ "c": "Incorrect. Only 'Hi' is printed, not both.",
+ "d": "Incorrect. The code is syntactically correct."
+ },
+ "difficulty": "intermediate"
},
{
"question": "10. What will be the output for this code:
",
@@ -135,11 +144,46 @@
},
"correctAnswer": "a",
"explanations": {
- "a": "Correct. explanation: The code prints 'Dhoni' as per the condition.",
- "b": "Incorrect, explanation: 'Hussey' is not printed in this code.",
- "c": "Incorrect, explanation: 'D villers' is not printed in this code.",
- "d": "Incorrect, explanation: The code is syntactically correct."
- }
+ "a": "Correct. The code prints 'Dhoni' as per the condition.",
+ "b": "Incorrect. 'Hussey' is not printed in this code.",
+ "c": "Incorrect. 'D villers' is not printed in this code.",
+ "d": "Incorrect. The code is syntactically correct."
+ },
+ "difficulty": "intermediate"
+ },
+ {
+ "question": "11. Which of the following best describes the use of 'switch' in C programming?",
+ "answers": {
+ "a": "It allows multi-way branching based on integer values.",
+ "b": "It can evaluate floating point expressions.",
+ "c": "It is used for looping.",
+ "d": "It is only used for error handling."
+ },
+ "correctAnswer": "a",
+ "explanations": {
+ "a": "Correct. The switch statement allows multi-way branching based on integer or character values.",
+ "b": "Incorrect. Switch cannot evaluate floating point expressions.",
+ "c": "Incorrect. Switch is not used for looping.",
+ "d": "Incorrect. Switch is not used only for error handling."
+ },
+ "difficulty": "advanced"
+ },
+ {
+ "question": "12. Which of the following code fragments will result in a compilation error in C?",
+ "answers": {
+ "a": "if (x == 1) { printf(\"One\"); }",
+ "b": "switch (x) { case 1.5: printf(\"Float\"); break; }",
+ "c": "if (x) printf(\"True\"); else printf(\"False\");",
+ "d": "switch (x) { case 1: printf(\"One\"); break; }"
+ },
+ "correctAnswer": "b",
+ "explanations": {
+ "a": "Incorrect. This is valid C code.",
+ "b": "Correct. Case labels in switch must be integer or character constants, not floats.",
+ "c": "Incorrect. This is valid C code.",
+ "d": "Incorrect. This is valid C code."
+ },
+ "difficulty": "advanced"
}
]
}
diff --git a/experiment/procedure.md b/experiment/procedure.md
index a3b335b..c26eae3 100644
--- a/experiment/procedure.md
+++ b/experiment/procedure.md
@@ -1,16 +1,36 @@
-**Experiment Part I: Position of Point w.r.t to a Rectangle**
-_Here we shall see how the problem of determining whether a given point is inside or outside a rectangle can be solved using various conditional constructs._
-1. Initialize the values of the variables on the top left. X and Y denote the x and y coordinate of the input point.
-2. Select the code prototype with which you would like to solve the problem.
-3. Click start to begin the expriment.
-4. Click Next to get a step by step execution of the code along with the reasoning which is displayed on the right hand side panel.
-**Experiment Part II: Selecting the Day of a week**
-_Here we shall see how a switching construct works by associating one number to each of the days._
-1. First, select a day from the top left by clicking on the correspoding radio button or enter any number in the textbox directly. Then, click on SUBMIT.
-2. Select the code prototype with which you would like to solve the problem.
-3. Click on the activated START button to begin the experiment.
-4. Click Next to get a step by step execution of the code. The changes in local variables can be visualized on the bottom left of the screen. The OUTPUT can be visualized on the right part of the screen.
+This experiment consists of two interactive simulations demonstrating basic control flow constructs:
-#### Procedure
+### Part I: Position of Point with Respect to a Rectangle (If-Else)
-Here you will do two experiments. First will be on finding whether a point is inside or outside rectangle. Secondly you will see a program for selecting a day in the week using switch construct.
+1. **Initialize Variables:**
+ - Enter the X and Y coordinates of the point in the provided input fields (default values are shown).
+ - The rectangle's corner coordinates are displayed for reference.
+2. **Select Code Prototype:**
+ - Use the dropdown menu to choose the code logic (e.g., if-else, if-else-if) for solving the point-in-rectangle problem.
+3. **Confirm Selection:**
+ - Click the **Ok** button to confirm your code selection.
+4. **Start Simulation:**
+ - The **Start** button will be enabled. Click **Start** to begin the step-by-step execution.
+5. **Step Execution:**
+ - Click **Next** to proceed through each step of the code. The current state of variables and reasoning will be displayed.
+6. **Stop/Reset:**
+ - Click **Stop** to abort and reset the simulation at any time.
+
+### Part II: Selecting the Day of the Week (Switch-Case)
+
+1. **Select Day:**
+ - Choose a day by clicking the corresponding radio button (Day 1 to Day 7) or enter a number directly in the textbox.
+2. **Submit Day:**
+ - Click the **Submit Day** button to confirm your selection.
+3. **Start Simulation:**
+ - The **Start** button will be enabled. Click **Start** to begin the step-by-step execution.
+4. **Step Execution:**
+ - Click **Next** to proceed through each step of the switch-case code. The output and changes in variables will be shown.
+5. **Reset:**
+ - Click **Reset** to restart the simulation with a new input.
+
+---
+
+**Note for Mobile Users:**
+
+This simulation is optimized for desktop computers with larger screens and mouse interaction. If you access this experiment on a mobile device, please rotate your device to **landscape mode** for the best experience. Some features may be limited or harder to use on small screens.
diff --git a/experiment/simulation/index.html b/experiment/simulation/index.html
index 141a9b7..14b77cf 100644
--- a/experiment/simulation/index.html
+++ b/experiment/simulation/index.html
@@ -1,32 +1,35 @@
-
+
-