first working version

This commit is contained in:
howard
2025-10-22 20:14:31 +08:00
parent c9767b830b
commit 8dc869634e
118 changed files with 22518 additions and 0 deletions

View File

@@ -0,0 +1,297 @@
{
"examId": "cpp-easy-v1",
"title": "C++ Fundamentals - Easy Level",
"subject": "C++",
"difficulty": "beginner",
"durationMinutes": 40,
"passingScore": 70,
"sections": [
{
"id": "basics",
"title": "C++ Basics & Syntax",
"questions": [
{
"id": "q1",
"type": "single_choice",
"prompt": "What is the correct file extension for a C++ source file?",
"choices": [
{ "key": "A", "text": ".c" },
{ "key": "B", "text": ".cpp" },
{ "key": "C", "text": ".cxx" },
{ "key": "D", "text": "Both B and C are correct" }
],
"answer": "D",
"allowIDK": true,
"points": 5
},
{
"id": "q2",
"type": "true_false",
"prompt": "In C++, every program must have a main() function.",
"answer": true,
"allowIDK": true,
"points": 5
},
{
"id": "q3",
"type": "single_choice",
"prompt": "Which header file is required to use cout in C++?",
"choices": [
{ "key": "A", "text": "#include <stdio.h>" },
{ "key": "B", "text": "#include <iostream>" },
{ "key": "C", "text": "#include <conio.h>" },
{ "key": "D", "text": "#include <stream>" }
],
"answer": "B",
"allowIDK": true,
"points": 5
},
{
"id": "q4",
"type": "multiple_choices",
"prompt": "Which of the following are valid C++ data types? (Select all that apply)",
"choices": [
{ "key": "A", "text": "int" },
{ "key": "B", "text": "boolean" },
{ "key": "C", "text": "float" },
{ "key": "D", "text": "char" }
],
"answer": ["A", "C", "D"],
"partialCredit": true,
"allowIDK": true,
"points": 10
},
{
"id": "q5",
"type": "true_false",
"prompt": "C++ is case-sensitive, meaning 'Variable' and 'variable' are different identifiers.",
"answer": true,
"allowIDK": true,
"points": 5
}
]
},
{
"id": "variables_operators",
"title": "Variables & Operators",
"questions": [
{
"id": "q6",
"type": "single_choice",
"prompt": "Which operator is used to assign a value to a variable in C++?",
"choices": [
{ "key": "A", "text": "==" },
{ "key": "B", "text": "=" },
{ "key": "C", "text": "===" },
{ "key": "D", "text": ":=" }
],
"answer": "B",
"allowIDK": true,
"points": 5
},
{
"id": "q7",
"type": "multiple_choices",
"prompt": "Which of the following are arithmetic operators in C++? (Select all that apply)",
"choices": [
{ "key": "A", "text": "+" },
{ "key": "B", "text": "%" },
{ "key": "C", "text": "&&" },
{ "key": "D", "text": "*" }
],
"answer": ["A", "B", "D"],
"partialCredit": true,
"allowIDK": true,
"points": 10
},
{
"id": "q8",
"type": "true_false",
"prompt": "In C++, you must declare a variable before using it.",
"answer": true,
"allowIDK": true,
"points": 5
},
{
"id": "q9",
"type": "single_choice",
"prompt": "What is the result of: 10 % 3 in C++?",
"choices": [
{ "key": "A", "text": "3" },
{ "key": "B", "text": "1" },
{ "key": "C", "text": "3.33" },
{ "key": "D", "text": "0" }
],
"answer": "B",
"allowIDK": true,
"points": 5
}
]
},
{
"id": "control_flow",
"title": "Control Flow & Loops",
"questions": [
{
"id": "q10",
"type": "single_choice",
"prompt": "Which keyword is used for conditional statements in C++?",
"choices": [
{ "key": "A", "text": "when" },
{ "key": "B", "text": "if" },
{ "key": "C", "text": "check" },
{ "key": "D", "text": "condition" }
],
"answer": "B",
"allowIDK": true,
"points": 5
},
{
"id": "q11",
"type": "true_false",
"prompt": "A 'while' loop checks the condition before executing the loop body.",
"answer": true,
"allowIDK": true,
"points": 5
},
{
"id": "q12",
"type": "multiple_choices",
"prompt": "Which are valid loop types in C++? (Select all that apply)",
"choices": [
{ "key": "A", "text": "for loop" },
{ "key": "B", "text": "while loop" },
{ "key": "C", "text": "do-while loop" },
{ "key": "D", "text": "repeat-until loop" }
],
"answer": ["A", "B", "C"],
"partialCredit": true,
"allowIDK": true,
"points": 10
},
{
"id": "q13",
"type": "single_choice",
"prompt": "What does the 'break' statement do in a loop?",
"choices": [
{ "key": "A", "text": "Skips the current iteration" },
{ "key": "B", "text": "Exits the loop completely" },
{ "key": "C", "text": "Pauses the loop" },
{ "key": "D", "text": "Restarts the loop" }
],
"answer": "B",
"allowIDK": true,
"points": 5
}
]
},
{
"id": "functions_arrays",
"title": "Functions & Arrays",
"questions": [
{
"id": "q14",
"type": "true_false",
"prompt": "A function in C++ can return only one value.",
"answer": true,
"allowIDK": true,
"points": 5
},
{
"id": "q15",
"type": "single_choice",
"prompt": "How do you declare a function that doesn't return any value?",
"choices": [
{ "key": "A", "text": "int functionName()" },
{ "key": "B", "text": "void functionName()" },
{ "key": "C", "text": "null functionName()" },
{ "key": "D", "text": "empty functionName()" }
],
"answer": "B",
"allowIDK": true,
"points": 5
},
{
"id": "q16",
"type": "multiple_choices",
"prompt": "Which statements about arrays in C++ are true? (Select all that apply)",
"choices": [
{ "key": "A", "text": "Array indices start at 0" },
{ "key": "B", "text": "Arrays have fixed size once declared" },
{ "key": "C", "text": "You can store different data types in the same array" },
{ "key": "D", "text": "Arrays are stored in contiguous memory locations" }
],
"answer": ["A", "B", "D"],
"partialCredit": true,
"allowIDK": true,
"points": 10
},
{
"id": "q17",
"type": "single_choice",
"prompt": "What is the correct way to declare an integer array of size 5 in C++?",
"choices": [
{ "key": "A", "text": "int arr[5];" },
{ "key": "B", "text": "array int arr[5];" },
{ "key": "C", "text": "int[5] arr;" },
{ "key": "D", "text": "int arr{5};" }
],
"answer": "A",
"allowIDK": true,
"points": 5
}
]
},
{
"id": "pointers_basics",
"title": "Pointers & References Basics",
"questions": [
{
"id": "q18",
"type": "true_false",
"prompt": "A pointer stores the memory address of another variable.",
"answer": true,
"allowIDK": true,
"points": 5
},
{
"id": "q19",
"type": "single_choice",
"prompt": "Which operator is used to get the address of a variable?",
"choices": [
{ "key": "A", "text": "*" },
{ "key": "B", "text": "&" },
{ "key": "C", "text": "@" },
{ "key": "D", "text": "#" }
],
"answer": "B",
"allowIDK": true,
"points": 5
},
{
"id": "q20",
"type": "multiple_choices",
"prompt": "Which are true about references in C++? (Select all that apply)",
"choices": [
{ "key": "A", "text": "References must be initialized when declared" },
{ "key": "B", "text": "References can be reassigned to refer to different variables" },
{ "key": "C", "text": "References are aliases for existing variables" },
{ "key": "D", "text": "References cannot be NULL" }
],
"answer": ["A", "C", "D"],
"partialCredit": true,
"allowIDK": true,
"points": 10
}
]
}
],
"metadata": {
"version": "1.0.0",
"createdAt": "2025-10-21T12:00:00Z",
"createdBy": "system",
"tags": ["cpp", "c++", "fundamentals", "beginner", "auto-graded"],
"description": "Comprehensive C++ fundamentals exam covering basics, variables, operators, control flow, functions, arrays, and pointer basics."
}
}

View File

@@ -0,0 +1,118 @@
{
"examId": "cpp-intermediate-v1",
"title": "C++ Intermediate - OOP & Practical Coding",
"subject": "C++",
"difficulty": "intermediate",
"durationMinutes": 90,
"passingScore": 70,
"sections": [
{
"id": "theory",
"title": "OOP Theory & Concepts",
"questions": [
{
"id": "q1",
"type": "single_choice",
"prompt": "In C++, what is the correct way to prevent a derived class from overriding a virtual function?",
"choices": [
{ "key": "A", "text": "Use the 'final' keyword" },
{ "key": "B", "text": "Make it private" },
{ "key": "C", "text": "Use the 'sealed' keyword" },
{ "key": "D", "text": "Remove the virtual keyword" }
],
"answer": "A",
"allowIDK": true,
"points": 10
},
{
"id": "q2",
"type": "multiple_choices",
"prompt": "Which are true about the Rule of Five in modern C++? (Select all that apply)",
"choices": [
{ "key": "A", "text": "Includes copy constructor" },
{ "key": "B", "text": "Includes move constructor" },
{ "key": "C", "text": "Includes move assignment operator" },
{ "key": "D", "text": "Includes default constructor" }
],
"answer": ["A", "B", "C"],
"partialCredit": true,
"allowIDK": true,
"points": 15
},
{
"id": "q3",
"type": "true_false",
"prompt": "In C++, a pure virtual function must be implemented in the base class.",
"answer": false,
"allowIDK": true,
"points": 10
}
]
},
{
"id": "coding",
"title": "Practical Coding Tasks",
"questions": [
{
"id": "q4",
"type": "code_simple",
"prompt": "Write a function 'factorial' that computes the factorial of a non-negative integer n recursively. Return the result as an unsigned long long.",
"language": "cpp",
"tests": [
{ "input": "0", "expected": "1", "visibility": "public" },
{ "input": "1", "expected": "1", "visibility": "public" },
{ "input": "5", "expected": "120", "visibility": "public" },
{ "input": "10", "expected": "3628800", "visibility": "hidden" }
],
"points": 20
},
{
"id": "q5",
"type": "code_simple",
"prompt": "Implement a function 'isPalindrome' that takes a std::string and returns true if it's a palindrome (reads the same forwards and backwards), false otherwise. Ignore case and spaces.",
"language": "cpp",
"tests": [
{ "input": "\"racecar\"", "expected": "true", "visibility": "public" },
{ "input": "\"hello\"", "expected": "false", "visibility": "public" },
{ "input": "\"A man a plan a canal Panama\"", "expected": "true", "visibility": "public" },
{ "input": "\"Race Car\"", "expected": "true", "visibility": "hidden" }
],
"points": 25
},
{
"id": "q6",
"type": "code_exercise",
"prompt": "Create a class 'Vector2D' that represents a 2D vector with x and y components. Implement:\n- Constructor taking x and y\n- operator+ for vector addition\n- operator* for dot product (returns double)\n- magnitude() method returning the length\n- normalize() method returning a unit vector\n\nExample:\nVector2D v1(3, 4);\nVector2D v2(1, 2);\nVector2D v3 = v1 + v2; // Should be (4, 6)\ndouble dot = v1 * v2; // Should be 11\ndouble mag = v1.magnitude(); // Should be 5",
"language": "cpp",
"tests": [
{ "input": "Vector2D(3, 4); Vector2D(1, 2); v1 + v2", "expected": "Vector2D(4, 6)", "visibility": "public" },
{ "input": "Vector2D(3, 4); Vector2D(1, 2); v1 * v2", "expected": "11", "visibility": "public" },
{ "input": "Vector2D(3, 4); v.magnitude()", "expected": "5", "visibility": "public" },
{ "input": "Vector2D(6, 8); v.normalize().magnitude()", "expected": "1", "visibility": "hidden", "weight": 2 }
],
"rubric": {
"criteria": [
{ "name": "Constructor implementation", "weight": 0.2 },
{ "name": "operator+ overloading", "weight": 0.2 },
{ "name": "operator* overloading (dot product)", "weight": 0.2 },
{ "name": "magnitude() method", "weight": 0.2 },
{ "name": "normalize() method", "weight": 0.2 }
],
"maxPoints": 30
},
"starterCode": "class Vector2D {\nprivate:\n double x, y;\npublic:\n // Your implementation here\n};",
"points": 30
}
]
}
],
"metadata": {
"version": "1.0.0",
"createdAt": "2025-10-21T17:00:00Z",
"createdBy": "system",
"tags": ["cpp", "c++", "intermediate", "oop", "coding", "manual-grading"],
"description": "Intermediate C++ exam covering OOP concepts with three practical coding tasks: recursion, string manipulation, and class design with operator overloading.",
"gradingNotes": "Theory questions (q1-q3) are auto-graded. Coding tasks (q4-q6) require manual review and grading based on rubrics and test cases."
}
}