diff --git a/src/lib/mocks/index.ts b/src/lib/mocks/index.ts
index ea245b49..bb6d4f6f 100644
--- a/src/lib/mocks/index.ts
+++ b/src/lib/mocks/index.ts
@@ -3,6 +3,7 @@ import { CSS_IDS, CSS_TEMPLATES } from './css';
import { calculateTotalPoints, shuffleOptions } from './utils';
import type { ExerciseTemplate } from '$lib/utils/types';
import { JS_IDS, JS_TEMPLATES } from './js';
+import { REACT_IDS, REACT_TEMPLATES } from './react';
import { TS_IDS, TS_TEMPLATES } from './typescript';
export const TAGS = {
@@ -45,6 +46,6 @@ export const TEMPLATES = {
[TAGS.CSS]: generateTemplateForTag(CSS_IDS, CSS_TEMPLATES),
[TAGS.JS]: generateTemplateForTag(JS_IDS, JS_TEMPLATES),
[TAGS.Typescript]: generateTemplateForTag(TS_IDS, TS_TEMPLATES),
- [TAGS.ReactJS]: [],
+ [TAGS.ReactJS]: generateTemplateForTag(REACT_IDS, REACT_TEMPLATES),
[TAGS.VueJS]: []
};
diff --git a/src/lib/mocks/react/001_react_es6.ts b/src/lib/mocks/react/001_react_es6.ts
new file mode 100644
index 00000000..039fd034
--- /dev/null
+++ b/src/lib/mocks/react/001_react_es6.ts
@@ -0,0 +1,119 @@
+import { QuestionTypes } from '../utils';
+
+import type { ExerciseTemplate } from '$lib/utils/types';
+
+const template: ExerciseTemplate = {
+ title: 'React ES6 Classes Quiz',
+ description: 'Test your knowledge of React ES6 classes.',
+ questionnaire: {
+ questions: [
+ {
+ title: 'What is a class in ES6?',
+ name: 'q1',
+ points: 1,
+ order: 0,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'A function', is_correct: false },
+ { label: 'A constructor method', is_correct: false },
+ { label: 'A blueprint for creating objects', is_correct: true },
+ ],
+ },
+ {
+ title: 'What keyword is used to create a class in ES6?',
+ name: 'q2',
+ points: 1,
+ order: 1,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'function', is_correct: false },
+ { label: 'prototype', is_correct: false },
+ { label: 'class', is_correct: true },
+ ],
+ },
+ {
+ title: 'Which method is automatically called when an object is created from a class?',
+ name: 'q3',
+ points: 1,
+ order: 2,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'constructor', is_correct: true },
+ { label: 'initialize', is_correct: false },
+ { label: 'create', is_correct: false },
+ ],
+ },
+ {
+ title: 'What is the purpose of the "render" method in a React component?',
+ name: 'q4',
+ points: 1,
+ order: 3,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'To update state', is_correct: false },
+ { label: 'To render HTML elements', is_correct: true },
+ { label: 'To define props', is_correct: false },
+ ],
+ },
+ {
+ title: 'Which React lifecycle method is used for cleanup activities?',
+ name: 'q5',
+ points: 1,
+ order: 4,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'componentDidMount', is_correct: false },
+ { label: 'componentDidUpdate', is_correct: false },
+ { label: 'componentWillUnmount', is_correct: true },
+ ],
+ },
+ {
+ title: 'Select all valid ways to define props in React.',
+ name: 'q6',
+ points: 1,
+ order: 5,
+ question_type: QuestionTypes[1], // CHECKBOX
+ options: [
+ { label: 'Using the render method', is_correct: false },
+ { label: 'Using the constructor', is_correct: false },
+ { label: 'Using defaultProps', is_correct: true },
+ { label: 'Using propTypes', is_correct: true },
+ ],
+ },
+ {
+ title: 'Write a JSX element representing a React component named "MyComponent".',
+ name: 'q7',
+ points: 1,
+ order: 6,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Explain the purpose of "setState" in React.',
+ name: 'q8',
+ points: 1,
+ order: 7,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What is the purpose of "super()" in a React class constructor?',
+ name: 'q9',
+ points: 1,
+ order: 8,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'List some advantages of using ES6 classes in React development.',
+ name: 'q10',
+ points: 1,
+ order: 9,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ ],
+ },
+};
+
+export default template;
diff --git a/src/lib/mocks/react/002_react_es6ArrowFunctions.ts b/src/lib/mocks/react/002_react_es6ArrowFunctions.ts
new file mode 100644
index 00000000..4b7d4847
--- /dev/null
+++ b/src/lib/mocks/react/002_react_es6ArrowFunctions.ts
@@ -0,0 +1,119 @@
+import { QuestionTypes } from '../utils';
+
+import type { ExerciseTemplate } from '$lib/utils/types';
+
+const template: ExerciseTemplate = {
+ title: 'React ES6 Arrow Functions Quiz',
+ description: 'Test your knowledge of React ES6 arrow functions.',
+ questionnaire: {
+ questions: [
+ {
+ title: 'What is an arrow function in ES6?',
+ name: 'q1',
+ points: 1,
+ order: 0,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'A traditional function', is_correct: false },
+ { label: 'A function expression', is_correct: false },
+ { label: 'A concise way to write functions', is_correct: true },
+ ],
+ },
+ {
+ title: 'Which of the following statements about arrow functions is correct?',
+ name: 'q2',
+ points: 1,
+ order: 1,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Arrow functions can have their own "this" value', is_correct: false },
+ { label: 'Arrow functions cannot have parameters', is_correct: false },
+ { label: 'Arrow functions do not have their own "this" value', is_correct: true },
+ ],
+ },
+ {
+ title: 'How do you write a multi-line arrow function in JavaScript?',
+ name: 'q3',
+ points: 1,
+ order: 2,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Using parentheses around the function body', is_correct: false },
+ { label: 'Using curly braces around the function body', is_correct: true },
+ { label: 'Using square brackets around the function body', is_correct: false },
+ ],
+ },
+ {
+ title: 'What is the main advantage of using arrow functions in React components?',
+ name: 'q4',
+ points: 1,
+ order: 3,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'They have a shorter syntax', is_correct: true },
+ { label: 'They can be asynchronous', is_correct: false },
+ { label: 'They automatically bind "this"', is_correct: false },
+ ],
+ },
+ {
+ title: 'When should you NOT use an arrow function for a class method in React?',
+ name: 'q5',
+ points: 1,
+ order: 4,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'When you want to access "this"', is_correct: true },
+ { label: 'When the method is static', is_correct: false },
+ { label: 'When the method is a constructor', is_correct: false },
+ ],
+ },
+ {
+ title: 'Select all valid use cases for arrow functions in JavaScript.',
+ name: 'q6',
+ points: 1,
+ order: 5,
+ question_type: QuestionTypes[1], // CHECKBOX
+ options: [
+ { label: 'Defining methods in a class', is_correct: true },
+ { label: 'Creating event handlers', is_correct: true },
+ { label: 'Defining constructors', is_correct: false },
+ { label: 'Using in a "for" loop', is_correct: true },
+ ],
+ },
+ {
+ title: 'Write an example of a single-line arrow function in JavaScript.',
+ name: 'q7',
+ points: 1,
+ order: 6,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Explain the concept of lexical scoping in arrow functions.',
+ name: 'q8',
+ points: 1,
+ order: 7,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What is the difference between regular functions and arrow functions in terms of "this" binding?',
+ name: 'q9',
+ points: 1,
+ order: 8,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'List some potential drawbacks of using arrow functions in certain situations.',
+ name: 'q10',
+ points: 1,
+ order: 9,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ ],
+ },
+};
+
+export default template;
diff --git a/src/lib/mocks/react/003_react_es6Variables.ts b/src/lib/mocks/react/003_react_es6Variables.ts
new file mode 100644
index 00000000..b17b2e00
--- /dev/null
+++ b/src/lib/mocks/react/003_react_es6Variables.ts
@@ -0,0 +1,120 @@
+import { QuestionTypes } from '../utils';
+
+import type { ExerciseTemplate } from '$lib/utils/types';
+
+const template: ExerciseTemplate = {
+ title: 'React ES6 Variables Quiz',
+ description: 'Test your knowledge of React ES6 variables.',
+ questionnaire: {
+ questions: [
+ {
+ title: 'What is the difference between "var" and "let" in ES6?',
+ name: 'q1',
+ points: 1,
+ order: 0,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Both "var" and "let" have block scope.', is_correct: false },
+ { label: '"var" has block scope, while "let" has function scope.', is_correct: false },
+ { label: '"var" has function scope, while "let" has block scope.', is_correct: true },
+ ],
+ },
+ {
+ title: 'Which ES6 keyword is used to declare a constant variable?',
+ name: 'q2',
+ points: 1,
+ order: 1,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'const', is_correct: true },
+ { label: 'let', is_correct: false },
+ { label: 'var', is_correct: false },
+ ],
+ },
+ {
+ title: 'What is the value of a variable declared using "const" that is not initialized?',
+ name: 'q3',
+ points: 1,
+ order: 2,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Undefined', is_correct: false },
+ { label: 'null', is_correct: false },
+ { label: 'It throws an error', is_correct: true },
+ ],
+ },
+ {
+ title: 'Which ES6 feature allows you to destructure an object into individual variables?',
+ name: 'q4',
+ points: 1,
+ order: 3,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Spread operator', is_correct: false },
+ { label: 'Rest operator', is_correct: false },
+ { label: 'Object destructuring', is_correct: true },
+ ],
+ },
+ {
+ title: 'What is the purpose of the "let" keyword in ES6?',
+ name: 'q5',
+ points: 1,
+ order: 4,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'To declare variables with block scope', is_correct: true },
+ { label: 'To declare variables with function scope', is_correct: false },
+ { label: 'To declare constant variables', is_correct: false },
+ ],
+ },
+ {
+ title: 'Select all valid data types that can be used with "const" declarations in ES6.',
+ name: 'q6',
+ points: 1,
+ order: 5,
+ question_type: QuestionTypes[1], // CHECKBOX
+ options: [
+ { label: 'Number', is_correct: true },
+ { label: 'String', is_correct: true },
+ { label: 'Array', is_correct: true },
+ { label: 'Object', is_correct: true },
+ { label: 'Function', is_correct: true },
+ ],
+ },
+ {
+ title: 'Write an example of destructuring an object in ES6.',
+ name: 'q7',
+ points: 1,
+ order: 6,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Explain the difference between "var" and "let" in terms of hoisting.',
+ name: 'q8',
+ points: 1,
+ order: 7,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What is the purpose of the "const" keyword in ES6?',
+ name: 'q9',
+ points: 1,
+ order: 8,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'List some common use cases for destructuring in JavaScript.',
+ name: 'q10',
+ points: 1,
+ order: 9,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ ],
+ },
+};
+
+export default template;
diff --git a/src/lib/mocks/react/004_react_es6ArrayMethods.ts b/src/lib/mocks/react/004_react_es6ArrayMethods.ts
new file mode 100644
index 00000000..ca29cce7
--- /dev/null
+++ b/src/lib/mocks/react/004_react_es6ArrayMethods.ts
@@ -0,0 +1,119 @@
+import { QuestionTypes } from '../utils';
+
+import type { ExerciseTemplate } from '$lib/utils/types';
+
+const template: ExerciseTemplate = {
+ title: 'React ES6 Array Methods Quiz',
+ description: 'Test your knowledge of React ES6 array methods.',
+ questionnaire: {
+ questions: [
+ {
+ title: 'What is the purpose of the "map" method in JavaScript?',
+ name: 'q1',
+ points: 1,
+ order: 0,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'To filter elements in an array', is_correct: false },
+ { label: 'To create a new array with the results of calling a provided function on every element', is_correct: true },
+ { label: 'To remove elements from an array', is_correct: false },
+ ],
+ },
+ {
+ title: 'Which of the following array methods is used to filter elements based on a condition?',
+ name: 'q2',
+ points: 1,
+ order: 1,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'forEach', is_correct: false },
+ { label: 'map', is_correct: false },
+ { label: 'filter', is_correct: true },
+ ],
+ },
+ {
+ title: 'What does the "reduce" method do in JavaScript?',
+ name: 'q3',
+ points: 1,
+ order: 2,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Sorts an array in ascending order', is_correct: false },
+ { label: 'Combines all elements in an array into a single value', is_correct: true },
+ { label: 'Removes the last element from an array', is_correct: false },
+ ],
+ },
+ {
+ title: 'Which array method is used to add elements to the end of an array?',
+ name: 'q4',
+ points: 1,
+ order: 3,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'push', is_correct: true },
+ { label: 'pop', is_correct: false },
+ { label: 'shift', is_correct: false },
+ ],
+ },
+ {
+ title: 'What is the purpose of the "find" method in JavaScript arrays?',
+ name: 'q5',
+ points: 1,
+ order: 4,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'To find the index of an element in an array', is_correct: false },
+ { label: 'To find the first element that satisfies a given condition', is_correct: true },
+ { label: 'To remove elements from an array', is_correct: false },
+ ],
+ },
+ {
+ title: 'Select all array methods that modify the original array in place.',
+ name: 'q6',
+ points: 1,
+ order: 5,
+ question_type: QuestionTypes[1], // CHECKBOX
+ options: [
+ { label: 'map', is_correct: false },
+ { label: 'filter', is_correct: false },
+ { label: 'splice', is_correct: true },
+ { label: 'push', is_correct: true },
+ ],
+ },
+ {
+ title: 'Write an example of using the "reduce" method to find the sum of an array of numbers.',
+ name: 'q7',
+ points: 1,
+ order: 6,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Explain the difference between "map" and "forEach" in JavaScript arrays.',
+ name: 'q8',
+ points: 1,
+ order: 7,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What is the purpose of the "some" method in JavaScript?',
+ name: 'q9',
+ points: 1,
+ order: 8,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'List some common use cases for the "filter" method in JavaScript arrays.',
+ name: 'q10',
+ points: 1,
+ order: 9,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ ],
+ },
+};
+
+export default template;
diff --git a/src/lib/mocks/react/005_react_es6Destructuring.ts b/src/lib/mocks/react/005_react_es6Destructuring.ts
new file mode 100644
index 00000000..d3a4ad02
--- /dev/null
+++ b/src/lib/mocks/react/005_react_es6Destructuring.ts
@@ -0,0 +1,115 @@
+import { QuestionTypes } from '../utils';
+
+import type { ExerciseTemplate } from '$lib/utils/types';
+
+const template: ExerciseTemplate = {
+ title: 'React ES6 Destructuring Quiz',
+ description: 'Test your knowledge of React ES6 destructuring.',
+ questionnaire: {
+ questions: [
+ {
+ title: 'What is destructuring in JavaScript?',
+ name: 'q1',
+ points: 1,
+ order: 0,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'A way to create new variables', is_correct: false },
+ { label: 'A way to extract values from objects and arrays into distinct variables', is_correct: true },
+ { label: 'A way to assign values to multiple variables', is_correct: false },
+ ],
+ },
+ {
+ title: 'How do you destructure an object in JavaScript?',
+ name: 'q2',
+ points: 1,
+ order: 1,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Using square brackets', is_correct: false },
+ { label: 'Using curly braces', is_correct: true },
+ { label: 'Using parentheses', is_correct: false },
+ ],
+ },
+ {
+ title: 'Which of the following is a valid use case for array destructuring?',
+ name: 'q3',
+ points: 1,
+ order: 2,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Swapping the values of two variables', is_correct: true },
+ { label: 'Accessing object properties', is_correct: false },
+ { label: 'Defining a function', is_correct: false },
+ ],
+ },
+ {
+ title: 'What happens if you try to destructure a non-existent property from an object?',
+ name: 'q4',
+ points: 1,
+ order: 3,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'An error is thrown', is_correct: false },
+ { label: 'The variable is assigned "undefined"', is_correct: true },
+ { label: 'The variable is assigned "null"', is_correct: false },
+ ],
+ },
+ {
+ title: 'Select all valid methods of destructuring an array in JavaScript.',
+ name: 'q5',
+ points: 1,
+ order: 4,
+ question_type: QuestionTypes[1], // CHECKBOX
+ options: [
+ { label: 'Using square brackets', is_correct: true },
+ { label: 'Using curly braces', is_correct: false },
+ { label: 'Using parentheses', is_correct: false },
+ { label: 'Using the "destruct" keyword', is_correct: false },
+ ],
+ },
+ {
+ title: 'Write an example of object destructuring in JavaScript.',
+ name: 'q6',
+ points: 1,
+ order: 5,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Explain the concept of nested destructuring in JavaScript.',
+ name: 'q7',
+ points: 1,
+ order: 6,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What is the purpose of the rest operator (...) in destructuring?',
+ name: 'q8',
+ points: 1,
+ order: 7,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What are the advantages of using destructuring in JavaScript?',
+ name: 'q9',
+ points: 1,
+ order: 8,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'List some common use cases for destructuring in JavaScript.',
+ name: 'q10',
+ points: 1,
+ order: 9,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ ],
+ },
+};
+
+export default template;
diff --git a/src/lib/mocks/react/006_react_es6SpreadOperator.ts b/src/lib/mocks/react/006_react_es6SpreadOperator.ts
new file mode 100644
index 00000000..e24c1316
--- /dev/null
+++ b/src/lib/mocks/react/006_react_es6SpreadOperator.ts
@@ -0,0 +1,115 @@
+import { QuestionTypes } from '../utils';
+
+import type { ExerciseTemplate } from '$lib/utils/types';
+
+const template: ExerciseTemplate = {
+ title: 'React ES6 Spread Operator Quiz',
+ description: 'Test your knowledge of the React ES6 spread operator.',
+ questionnaire: {
+ questions: [
+ {
+ title: 'What is the purpose of the spread operator (...) in JavaScript?',
+ name: 'q1',
+ points: 1,
+ order: 0,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'To concatenate arrays', is_correct: false },
+ { label: 'To clone an object or array', is_correct: true },
+ { label: 'To create a new function', is_correct: false },
+ ],
+ },
+ {
+ title: 'How do you use the spread operator to copy an array in JavaScript?',
+ name: 'q2',
+ points: 1,
+ order: 1,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'array.copy()', is_correct: false },
+ { label: 'array.clone()', is_correct: false },
+ { label: '[...array]', is_correct: true },
+ ],
+ },
+ {
+ title: 'Which of the following is a valid use case for the spread operator in JavaScript?',
+ name: 'q3',
+ points: 1,
+ order: 2,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Merging two arrays', is_correct: true },
+ { label: 'Creating a new object', is_correct: false },
+ { label: 'Defining a function', is_correct: false },
+ ],
+ },
+ {
+ title: 'What is the output of the following code: `const arr = [1, 2, ...[3, 4], 5];`?',
+ name: 'q4',
+ points: 1,
+ order: 3,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: '[1, 2, [3, 4], 5]', is_correct: false },
+ { label: '[1, 2, 3, 4, 5]', is_correct: true },
+ { label: '[1, 2, ...[3, 4], ...5]', is_correct: false },
+ ],
+ },
+ {
+ title: 'Select all valid use cases for the spread operator in JavaScript.',
+ name: 'q5',
+ points: 1,
+ order: 4,
+ question_type: QuestionTypes[1], // CHECKBOX
+ options: [
+ { label: 'Cloning an array', is_correct: true },
+ { label: 'Concatenating arrays', is_correct: true },
+ { label: 'Merging objects', is_correct: true },
+ { label: 'Defining a new function', is_correct: false },
+ ],
+ },
+ {
+ title: 'Write an example of using the spread operator to merge two objects in JavaScript.',
+ name: 'q6',
+ points: 1,
+ order: 5,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Explain the concept of shallow copying using the spread operator in JavaScript.',
+ name: 'q7',
+ points: 1,
+ order: 6,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What are the advantages of using the spread operator in JavaScript?',
+ name: 'q8',
+ points: 1,
+ order: 7,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'List some common use cases for the spread operator in JavaScript.',
+ name: 'q9',
+ points: 1,
+ order: 8,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What happens if you use the spread operator on a non-iterable value in JavaScript?',
+ name: 'q10',
+ points: 1,
+ order: 9,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ ],
+ },
+};
+
+export default template;
diff --git a/src/lib/mocks/react/007_react_es6Modules.ts b/src/lib/mocks/react/007_react_es6Modules.ts
new file mode 100644
index 00000000..308f7cf6
--- /dev/null
+++ b/src/lib/mocks/react/007_react_es6Modules.ts
@@ -0,0 +1,115 @@
+import { QuestionTypes } from '../utils';
+
+import type { ExerciseTemplate } from '$lib/utils/types';
+
+const template: ExerciseTemplate = {
+ title: 'React ES6 Modules Quiz',
+ description: 'Test your knowledge of React ES6 modules.',
+ questionnaire: {
+ questions: [
+ {
+ title: 'What is the purpose of ES6 modules in JavaScript?',
+ name: 'q1',
+ points: 1,
+ order: 0,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'To declare variables', is_correct: false },
+ { label: 'To define reusable pieces of code that can be imported and used in other modules', is_correct: true },
+ { label: 'To create new functions', is_correct: false },
+ ],
+ },
+ {
+ title: 'How do you export a function or variable from a module in ES6?',
+ name: 'q2',
+ points: 1,
+ order: 1,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Using the `import` keyword', is_correct: false },
+ { label: 'Using the `export` keyword', is_correct: true },
+ { label: 'Using the `require` keyword', is_correct: false },
+ ],
+ },
+ {
+ title: 'Which of the following statements is true about ES6 modules?',
+ name: 'q3',
+ points: 1,
+ order: 2,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Modules can only be used in the browser', is_correct: false },
+ { label: 'Modules can be used in both the browser and Node.js', is_correct: true },
+ { label: 'Modules are not supported in JavaScript', is_correct: false },
+ ],
+ },
+ {
+ title: 'What is the purpose of the default export in ES6 modules?',
+ name: 'q4',
+ points: 1,
+ order: 3,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'To export multiple values from a module', is_correct: false },
+ { label: 'To specify the main entry point of a module', is_correct: true },
+ { label: 'To import all values from a module', is_correct: false },
+ ],
+ },
+ {
+ title: 'Select all valid ways to import a named export from a module in ES6.',
+ name: 'q5',
+ points: 1,
+ order: 4,
+ question_type: QuestionTypes[1], // CHECKBOX
+ options: [
+ { label: 'Using the `import` keyword followed by the module path', is_correct: true },
+ { label: 'Using the `import * as moduleName` syntax', is_correct: true },
+ { label: 'Using the `import defaultExport` syntax', is_correct: false },
+ { label: 'Using the `require` keyword', is_correct: false },
+ ],
+ },
+ {
+ title: 'Write an example of exporting a named function from a module in ES6.',
+ name: 'q6',
+ points: 1,
+ order: 5,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Explain the concept of a default export in ES6 modules.',
+ name: 'q7',
+ points: 1,
+ order: 6,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What is the purpose of using ES6 modules in a large JavaScript project?',
+ name: 'q8',
+ points: 1,
+ order: 7,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'List some benefits of using ES6 modules over traditional script tags for including JavaScript in HTML files.',
+ name: 'q9',
+ points: 1,
+ order: 8,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'How do ES6 modules handle variable scope?',
+ name: 'q10',
+ points: 1,
+ order: 9,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ ],
+ },
+};
+
+export default template;
diff --git a/src/lib/mocks/react/008_react_es6TenaryOperator.ts b/src/lib/mocks/react/008_react_es6TenaryOperator.ts
new file mode 100644
index 00000000..f37eed8c
--- /dev/null
+++ b/src/lib/mocks/react/008_react_es6TenaryOperator.ts
@@ -0,0 +1,115 @@
+import { QuestionTypes } from '../utils';
+
+import type { ExerciseTemplate } from '$lib/utils/types';
+
+const template: ExerciseTemplate = {
+ title: 'React ES6 Ternary Operator Quiz',
+ description: 'Test your knowledge of the React ES6 ternary operator.',
+ questionnaire: {
+ questions: [
+ {
+ title: 'What is the purpose of the ternary operator in JavaScript?',
+ name: 'q1',
+ points: 1,
+ order: 0,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'To declare variables', is_correct: false },
+ { label: 'To conditionally assign a value based on a condition', is_correct: true },
+ { label: 'To define reusable functions', is_correct: false },
+ ],
+ },
+ {
+ title: 'How does the ternary operator differ from an "if...else" statement?',
+ name: 'q2',
+ points: 1,
+ order: 1,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'The ternary operator cannot be used for conditional assignments', is_correct: false },
+ { label: 'The ternary operator is shorter and results in a value', is_correct: true },
+ { label: 'The ternary operator can only be used for boolean conditions', is_correct: false },
+ ],
+ },
+ {
+ title: 'What is the syntax of the ternary operator in JavaScript?',
+ name: 'q3',
+ points: 1,
+ order: 2,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'if (condition) { value1 } else { value2 }', is_correct: false },
+ { label: 'condition ? value1 : value2', is_correct: true },
+ { label: 'condition ? { value1 } : { value2 }', is_correct: false },
+ ],
+ },
+ {
+ title: 'How do you use the ternary operator to assign a value based on a condition?',
+ name: 'q4',
+ points: 1,
+ order: 3,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Using "if" statements', is_correct: false },
+ { label: 'Using "switch" statements', is_correct: false },
+ { label: 'Using the "?" and ":" symbols', is_correct: true },
+ ],
+ },
+ {
+ title: 'Select all valid use cases for the ternary operator in JavaScript.',
+ name: 'q5',
+ points: 1,
+ order: 4,
+ question_type: QuestionTypes[1], // CHECKBOX
+ options: [
+ { label: 'Assigning a value based on a condition', is_correct: true },
+ { label: 'Replacing "if...else" statements', is_correct: true },
+ { label: 'Defining functions', is_correct: false },
+ { label: 'Creating arrays', is_correct: false },
+ ],
+ },
+ {
+ title: 'Write an example of using the ternary operator to conditionally assign a value in JavaScript.',
+ name: 'q6',
+ points: 1,
+ order: 5,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Explain the concept of a "truthy" and "falsy" value in the context of the ternary operator.',
+ name: 'q7',
+ points: 1,
+ order: 6,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What is the advantage of using the ternary operator over an "if...else" statement in certain situations?',
+ name: 'q8',
+ points: 1,
+ order: 7,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'List some common pitfalls to avoid when using the ternary operator in JavaScript.',
+ name: 'q9',
+ points: 1,
+ order: 8,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'How can you nest ternary operators in JavaScript?',
+ name: 'q10',
+ points: 1,
+ order: 9,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ ],
+ },
+};
+
+export default template;
diff --git a/src/lib/mocks/react/009_react_jsx.ts b/src/lib/mocks/react/009_react_jsx.ts
new file mode 100644
index 00000000..46e0b4f6
--- /dev/null
+++ b/src/lib/mocks/react/009_react_jsx.ts
@@ -0,0 +1,115 @@
+import { QuestionTypes } from '../utils';
+
+import type { ExerciseTemplate } from '$lib/utils/types';
+
+const template: ExerciseTemplate = {
+ title: 'React JSX Quiz',
+ description: 'Test your knowledge of React JSX.',
+ questionnaire: {
+ questions: [
+ {
+ title: 'What is JSX in React?',
+ name: 'q1',
+ points: 1,
+ order: 0,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'A data type in React', is_correct: false },
+ { label: 'A JavaScript extension for React', is_correct: true },
+ { label: 'A React component', is_correct: false },
+ ],
+ },
+ {
+ title: 'What is the primary advantage of using JSX in React?',
+ name: 'q2',
+ points: 1,
+ order: 1,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'It simplifies the syntax of JavaScript', is_correct: false },
+ { label: 'It allows you to define component structure with a more declarative syntax', is_correct: true },
+ { label: 'It improves performance in React applications', is_correct: false },
+ ],
+ },
+ {
+ title: 'Is JSX a requirement for building React applications?',
+ name: 'q3',
+ points: 1,
+ order: 2,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Yes, JSX is mandatory in React', is_correct: false },
+ { label: 'No, you can use plain JavaScript without JSX', is_correct: true },
+ { label: 'JSX is only required for server-side rendering', is_correct: false },
+ ],
+ },
+ {
+ title: 'What is the role of Babel in JSX usage?',
+ name: 'q4',
+ points: 1,
+ order: 3,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Babel transpiles JSX code to JavaScript code that browsers can understand', is_correct: true },
+ { label: 'Babel optimizes React components', is_correct: false },
+ { label: 'Babel is not related to JSX', is_correct: false },
+ ],
+ },
+ {
+ title: 'Select all valid JSX syntax rules in React.',
+ name: 'q5',
+ points: 1,
+ order: 4,
+ question_type: QuestionTypes[1], // CHECKBOX
+ options: [
+ { label: 'JSX elements must always be closed', is_correct: false },
+ { label: 'JSX attributes must be written in double quotes', is_correct: false },
+ { label: 'JSX elements can be nested', is_correct: true },
+ { label: 'JSX elements can be self-closing', is_correct: true },
+ ],
+ },
+ {
+ title: 'Write an example of a JSX element in React.',
+ name: 'q6',
+ points: 1,
+ order: 5,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Explain the concept of JSX transformations and how it relates to browser compatibility.',
+ name: 'q7',
+ points: 1,
+ order: 6,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What is the significance of the curly braces `{}` in JSX?',
+ name: 'q8',
+ points: 1,
+ order: 7,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'List some benefits of using JSX in React development.',
+ name: 'q9',
+ points: 1,
+ order: 8,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Can you embed JavaScript expressions within JSX? If yes, provide an example.',
+ name: 'q10',
+ points: 1,
+ order: 9,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ ],
+ },
+};
+
+export default template;
diff --git a/src/lib/mocks/react/010_react_components.ts b/src/lib/mocks/react/010_react_components.ts
new file mode 100644
index 00000000..4102a3b5
--- /dev/null
+++ b/src/lib/mocks/react/010_react_components.ts
@@ -0,0 +1,115 @@
+import { QuestionTypes } from '../utils';
+
+import type { ExerciseTemplate } from '$lib/utils/types';
+
+const template: ExerciseTemplate = {
+ title: 'React Components Quiz',
+ description: 'Test your knowledge of React components.',
+ questionnaire: {
+ questions: [
+ {
+ title: 'What is a React component?',
+ name: 'q1',
+ points: 1,
+ order: 0,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'A JavaScript library for building user interfaces', is_correct: false },
+ { label: 'A reusable and self-contained piece of UI', is_correct: true },
+ { label: 'A CSS framework for styling React applications', is_correct: false },
+ ],
+ },
+ {
+ title: 'What are the two main types of React components?',
+ name: 'q2',
+ points: 1,
+ order: 1,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Functional components and class components', is_correct: true },
+ { label: 'Stateful components and stateless components', is_correct: false },
+ { label: 'React components and React elements', is_correct: false },
+ ],
+ },
+ {
+ title: 'How do you define a functional component in React?',
+ name: 'q3',
+ points: 1,
+ order: 2,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Using the `class` keyword', is_correct: false },
+ { label: 'Using a JavaScript function', is_correct: true },
+ { label: 'Using the `extends` keyword', is_correct: false },
+ ],
+ },
+ {
+ title: 'What is the purpose of the `render` method in a class component?',
+ name: 'q4',
+ points: 1,
+ order: 3,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'To define the component\'s state', is_correct: false },
+ { label: 'To return the JSX that represents the component\'s UI', is_correct: true },
+ { label: 'To define the component\'s lifecycle methods', is_correct: false },
+ ],
+ },
+ {
+ title: 'Select all valid ways to pass data from a parent component to a child component in React.',
+ name: 'q5',
+ points: 1,
+ order: 4,
+ question_type: QuestionTypes[1], // CHECKBOX
+ options: [
+ { label: 'Using props', is_correct: true },
+ { label: 'Using state', is_correct: false },
+ { label: 'Using context', is_correct: true },
+ { label: 'Using refs', is_correct: false },
+ ],
+ },
+ {
+ title: 'Write an example of defining a functional component in React.',
+ name: 'q6',
+ points: 1,
+ order: 5,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Explain the concept of "props" in React and how they are used in components.',
+ name: 'q7',
+ points: 1,
+ order: 6,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What is the significance of the "key" prop in React when rendering lists of elements?',
+ name: 'q8',
+ points: 1,
+ order: 7,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'List some advantages of using functional components in React over class components.',
+ name: 'q9',
+ points: 1,
+ order: 8,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'How can you conditionally render content in a React component?',
+ name: 'q10',
+ points: 1,
+ order: 9,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ ],
+ },
+};
+
+export default template;
diff --git a/src/lib/mocks/react/011_react_classComponents.ts b/src/lib/mocks/react/011_react_classComponents.ts
new file mode 100644
index 00000000..88b71e76
--- /dev/null
+++ b/src/lib/mocks/react/011_react_classComponents.ts
@@ -0,0 +1,115 @@
+import { QuestionTypes } from '../utils';
+
+import type { ExerciseTemplate } from '$lib/utils/types';
+
+const template: ExerciseTemplate = {
+ title: 'React Class Components Quiz',
+ description: 'Test your knowledge of React class components.',
+ questionnaire: {
+ questions: [
+ {
+ title: 'What is a class component in React?',
+ name: 'q1',
+ points: 1,
+ order: 0,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'A JavaScript class used to define a React element', is_correct: true },
+ { label: 'A React component that uses only functional components', is_correct: false },
+ { label: 'A class used to style React components', is_correct: false },
+ ],
+ },
+ {
+ title: 'What is the main difference between a functional component and a class component in React?',
+ name: 'q2',
+ points: 1,
+ order: 1,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Functional components use the `render` method, while class components use functions', is_correct: false },
+ { label: 'Functional components use functions, while class components use the `render` method', is_correct: true },
+ { label: 'Functional components cannot have state, while class components can', is_correct: false },
+ ],
+ },
+ {
+ title: 'What is the purpose of the constructor method in a React class component?',
+ name: 'q3',
+ points: 1,
+ order: 2,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'To initialize the component\'s state and bind event handlers', is_correct: true },
+ { label: 'To define the component\'s rendering logic', is_correct: false },
+ { label: 'To declare props for the component', is_correct: false },
+ ],
+ },
+ {
+ title: 'How do you update the state of a class component in React?',
+ name: 'q4',
+ points: 1,
+ order: 3,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'By directly modifying the `state` property', is_correct: false },
+ { label: 'By calling the `setState` method', is_correct: true },
+ { label: 'By assigning a new value to `this.state`', is_correct: false },
+ ],
+ },
+ {
+ title: 'Select all valid lifecycle methods in a React class component.',
+ name: 'q5',
+ points: 1,
+ order: 4,
+ question_type: QuestionTypes[1], // CHECKBOX
+ options: [
+ { label: 'render', is_correct: true },
+ { label: 'componentDidMount', is_correct: true },
+ { label: 'componentWillUnmount', is_correct: true },
+ { label: 'componentUpdate', is_correct: false },
+ ],
+ },
+ {
+ title: 'Write an example of defining a class component in React.',
+ name: 'q6',
+ points: 1,
+ order: 5,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Explain the concept of the component lifecycle in React class components.',
+ name: 'q7',
+ points: 1,
+ order: 6,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What is the significance of the `super()` method in a React class component constructor?',
+ name: 'q8',
+ points: 1,
+ order: 7,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'List some advantages of using class components in React development.',
+ name: 'q9',
+ points: 1,
+ order: 8,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'How can you handle events in a React class component?',
+ name: 'q10',
+ points: 1,
+ order: 9,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ ],
+ },
+};
+
+export default template;
diff --git a/src/lib/mocks/react/012_react_props.ts b/src/lib/mocks/react/012_react_props.ts
new file mode 100644
index 00000000..72fe464b
--- /dev/null
+++ b/src/lib/mocks/react/012_react_props.ts
@@ -0,0 +1,115 @@
+import { QuestionTypes } from '../utils';
+
+import type { ExerciseTemplate } from '$lib/utils/types';
+
+const template: ExerciseTemplate = {
+ title: 'React Props Quiz',
+ description: 'Test your knowledge of React props.',
+ questionnaire: {
+ questions: [
+ {
+ title: 'What are props in React?',
+ name: 'q1',
+ points: 1,
+ order: 0,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'A method to define component styles', is_correct: false },
+ { label: 'Data that is passed from a parent component to a child component', is_correct: true },
+ { label: 'A way to define component state', is_correct: false },
+ ],
+ },
+ {
+ title: 'How do you pass props to a child component in React?',
+ name: 'q2',
+ points: 1,
+ order: 1,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Using the `state` property', is_correct: false },
+ { label: 'Using the `props` attribute in the child component\'s JSX', is_correct: true },
+ { label: 'By directly modifying the child component\'s state', is_correct: false },
+ ],
+ },
+ {
+ title: 'Can props be modified within a child component in React?',
+ name: 'q3',
+ points: 1,
+ order: 2,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Yes, props can be modified within a child component', is_correct: false },
+ { label: 'No, props are immutable within a child component', is_correct: true },
+ { label: 'Props can only be modified within a parent component', is_correct: false },
+ ],
+ },
+ {
+ title: 'Select all valid ways to define and use props in a React component.',
+ name: 'q4',
+ points: 1,
+ order: 3,
+ question_type: QuestionTypes[1], // CHECKBOX
+ options: [
+ { label: 'Define props using the `props` attribute', is_correct: false },
+ { label: 'Define props using a JavaScript object', is_correct: true },
+ { label: 'Access props within a component using `this.props`', is_correct: true },
+ { label: 'Access props directly as function parameters', is_correct: false },
+ ],
+ },
+ {
+ title: 'Write an example of passing and using props in a React component.',
+ name: 'q5',
+ points: 1,
+ order: 4,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Explain the concept of "prop drilling" in React.',
+ name: 'q6',
+ points: 1,
+ order: 5,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What is the significance of default props in React?',
+ name: 'q7',
+ points: 1,
+ order: 6,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'List some benefits of using props for component communication in React.',
+ name: 'q8',
+ points: 1,
+ order: 7,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'How can you handle missing props in a React component?',
+ name: 'q9',
+ points: 1,
+ order: 8,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Can you pass non-primitive data types (e.g., objects, arrays) as props in React?',
+ name: 'q10',
+ points: 1,
+ order: 9,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Yes, you can pass non-primitive data types as props', is_correct: true },
+ { label: 'No, only primitive data types can be passed as props', is_correct: false },
+ { label: 'Non-primitive data types can only be passed as state', is_correct: false },
+ ],
+ },
+ ],
+ },
+};
+
+export default template;
diff --git a/src/lib/mocks/react/013_react_events.ts b/src/lib/mocks/react/013_react_events.ts
new file mode 100644
index 00000000..d648c4d4
--- /dev/null
+++ b/src/lib/mocks/react/013_react_events.ts
@@ -0,0 +1,111 @@
+import { QuestionTypes } from '../utils';
+
+import type { ExerciseTemplate } from '$lib/utils/types';
+
+const template: ExerciseTemplate = {
+ title: 'React Events Quiz',
+ description: 'Test your knowledge of React events.',
+ questionnaire: {
+ questions: [
+ {
+ title: 'What are React events?',
+ name: 'q1',
+ points: 1,
+ order: 0,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'Functions that handle user interactions in React', is_correct: true },
+ { label: 'CSS styles applied to React components', is_correct: false },
+ { label: 'React components used to trigger animations', is_correct: false },
+ ],
+ },
+ {
+ title: 'How do you define an event handler in React?',
+ name: 'q2',
+ points: 1,
+ order: 1,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'By creating a new React component', is_correct: false },
+ { label: 'By adding an `onEvent` attribute to an HTML element', is_correct: false },
+ { label: 'By defining a function and assigning it to an event attribute', is_correct: true },
+ ],
+ },
+ {
+ title: 'Which of the following is an example of a React event?',
+ name: 'q3',
+ points: 1,
+ order: 2,
+ question_type: QuestionTypes[0], // RADIO
+ options: [
+ { label: 'onClick', is_correct: true },
+ { label: 'style', is_correct: false },
+ { label: 'render', is_correct: false },
+ ],
+ },
+ {
+ title: 'Select all valid event types in React.',
+ name: 'q4',
+ points: 1,
+ order: 3,
+ question_type: QuestionTypes[1], // CHECKBOX
+ options: [
+ { label: 'onClick', is_correct: true },
+ { label: 'onMouseOver', is_correct: true },
+ { label: 'onChange', is_correct: true },
+ { label: 'onSubmit', is_correct: true },
+ ],
+ },
+ {
+ title: 'Write an example of defining an event handler function in React.',
+ name: 'q5',
+ points: 1,
+ order: 4,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What is event propagation in React?',
+ name: 'q6',
+ points: 1,
+ order: 5,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'How can you prevent the default behavior of an event in React?',
+ name: 'q7',
+ points: 1,
+ order: 6,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'Explain the concept of "binding" in React event handlers.',
+ name: 'q8',
+ points: 1,
+ order: 7,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'What is the purpose of synthetic events in React?',
+ name: 'q9',
+ points: 1,
+ order: 8,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ {
+ title: 'How can you pass additional data to an event handler function in React?',
+ name: 'q10',
+ points: 1,
+ order: 9,
+ question_type: QuestionTypes[2], // TEXTAREA
+ options: [],
+ },
+ ],
+ },
+};
+
+export default template;
diff --git a/src/lib/mocks/react/014_react_conditionals.ts b/src/lib/mocks/react/014_react_conditionals.ts
new file mode 100644
index 00000000..6cf1a7a9
--- /dev/null
+++ b/src/lib/mocks/react/014_react_conditionals.ts
@@ -0,0 +1,172 @@
+import { QuestionTypes } from '../utils';
+
+import type { ExerciseTemplate } from '$lib/utils/types';
+
+const template: ExerciseTemplate = {
+ title: 'React Conditional Rendering Practical Quiz',
+ description: 'Test your practical knowledge of conditional rendering in React.',
+ questionnaire: {
+ questions: [
+ {
+ title: 'How can you conditionally render content in React?',
+ name: 'conditionalRendering',
+ points: 1,
+ order: 0,
+ question_type: QuestionTypes[0],
+ options: [
+ {
+ label: 'Using conditional statements (if-else).',
+ is_correct: true,
+ },
+ {
+ label: 'Always rendering all content.',
+ is_correct: false,
+ },
+ {
+ label: 'Using randomization.',
+ is_correct: false,
+ },
+ ],
+ },
+ {
+ title: 'What is the purpose of the "ternary operator" in conditional rendering?',
+ name: 'ternaryOperatorPurpose',
+ points: 1,
+ order: 1,
+ question_type: QuestionTypes[2],
+ options: [],
+ },
+ {
+ title: 'How would you conditionally render "ComponentA" if a condition is true and "ComponentB" if the condition is false?',
+ name: 'conditionalRenderingComponents',
+ points: 1,
+ order: 2,
+ question_type: QuestionTypes[0],
+ options: [
+ {
+ label: '{condition ?