CLASSROOMIO-T-199: Exercise Template for React

Merge branch 'main' into CLASSROOMIO-T-199

CLASSROOMIO-T-199: Questions Update

CLASSROOMIO-T-199: Added Exercises

CLASSROOMIO-T-199: Exercise Template for React


Co-authored-by: Rotimi Best <rotimiibitoyeemma@gmail.com>
Co-authored-by: Tunji Adeyemi <tunji@digdippa.com>


Merge-request: CLASSROOMIO-MR-93
Merged-by: Best Admin <best@digdippa.com>
This commit is contained in:
tunny17
2023-10-09 16:23:16 +00:00
committed by Space Cloud
co-authored by Rotimi Best
parent aa3c613363
commit 1896da7ffe
35 changed files with 4515 additions and 1 deletions
@@ -0,0 +1,172 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'React State Sharing Practical Quiz',
description: 'Test your practical knowledge of sharing state between components in React.',
questionnaire: {
questions: [
{
title: 'What is the primary purpose of using props to share data between React components?',
name: 'propsPurpose',
points: 1,
order: 0,
question_type: QuestionTypes[0],
options: [
{
label: 'To pass data from a parent component to its child components.',
is_correct: true,
},
{
label: 'To pass data from a child component to its parent components.',
is_correct: false,
},
{
label: 'To create local component data.',
is_correct: false,
},
],
},
{
title: 'What is the recommended way to pass a function as a prop in React?',
name: 'passingFunctionAsProp',
points: 1,
order: 1,
question_type: QuestionTypes[0],
options: [
{
label: 'Create a function in the child component and call it in the parent component.',
is_correct: false,
},
{
label: 'Pass the function as a prop from the parent component to the child component.',
is_correct: true,
},
{
label: 'Use a global variable to share the function.',
is_correct: false,
},
],
},
{
title: 'What is a common use case for using context to share state in React?',
name: 'contextUseCase',
points: 1,
order: 2,
question_type: QuestionTypes[2],
options: [],
},
{
title: 'How can you share state between components using React Context?',
name: 'sharingStateWithContext',
points: 1,
order: 3,
question_type: QuestionTypes[0],
options: [
{
label: 'Wrap the components with a Context Provider and use the useContext hook.',
is_correct: true,
},
{
label: 'Pass the state as a prop to each component.',
is_correct: false,
},
{
label: 'Use Redux for state management.',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the "useReducer" hook in React?',
name: 'useReducerPurpose',
points: 1,
order: 4,
question_type: QuestionTypes[2],
options: [],
},
{
title: 'How does the "useReducer" hook differ from the "useState" hook in React?',
name: 'useReducerVsUseState',
points: 1,
order: 5,
question_type: QuestionTypes[1],
options: [
{
label: 'useReducer is used for managing complex state logic, while useState is for simple state.',
is_correct: true,
},
{
label: 'useState is used for managing complex state logic, while useReducer is for simple state.',
is_correct: false,
},
{
label: 'There is no difference between them.',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the "prop drilling" problem in React?',
name: 'propDrillingPurpose',
points: 1,
order: 6,
question_type: QuestionTypes[2],
options: [],
},
{
title: 'How can you avoid prop drilling in React?',
name: 'avoidingPropDrilling',
points: 1,
order: 7,
question_type: QuestionTypes[0],
options: [
{
label: 'Use context to share state.',
is_correct: true,
},
{
label: 'Always pass props directly to the child components.',
is_correct: false,
},
{
label: 'Use global variables to store state.',
is_correct: false,
},
],
},
{
title: 'What is the purpose of using Redux for state management in React applications?',
name: 'reduxPurpose',
points: 1,
order: 8,
question_type: QuestionTypes[2],
options: [],
},
{
title: 'What is the role of a Redux reducer function?',
name: 'reduxReducerRole',
points: 1,
order: 9,
question_type: QuestionTypes[0],
options: [
{
label: 'To specify how the state should change in response to actions.',
is_correct: true,
},
{
label: 'To define the initial state of the application.',
is_correct: false,
},
{
label: 'To connect React components to the Redux store.',
is_correct: false,
},
],
},
],
},
};
export default template;