CLASSROOMIO-T-201: Exercise Template for PHP

CLASSROOMIO-T-201: Quick bug fix

Merge branch 'main' into CLASSROOMIO-T-201

CLASSROOMIO-T-201: Exercise Template for PHP


Co-authored-by: Tunji Adeyemi <tunji@digdippa.com>


Merge-request: CLASSROOMIO-MR-96
Merged-by: Best Admin <best@digdippa.com>
This commit is contained in:
tunny17
2023-10-10 06:39:23 +00:00
committed by Space Cloud
parent 6ccef8f62b
commit 27b0284538
22 changed files with 4892 additions and 2 deletions
+5 -2
View File
@@ -6,6 +6,7 @@ import { JS_IDS, JS_TEMPLATES } from './js';
import { NODE_IDS, NODE_TEMPLATES } from './node';
import { REACT_IDS, REACT_TEMPLATES } from './react';
import { TS_IDS, TS_TEMPLATES } from './typescript';
import { PHP_IDS, PHP_TEMPLATES } from './php';
export const TAGS = {
HTML: 'HTML',
@@ -14,7 +15,8 @@ export const TAGS = {
Typescript: 'Typescript',
ReactJS: 'ReactJS',
VueJS: 'VueJS',
NodeJS: 'NodeJS'
NodeJS: 'NodeJS',
PHP: 'PHP'
};
function generateTemplateForTag(
@@ -50,5 +52,6 @@ export const TEMPLATES = {
[TAGS.Typescript]: generateTemplateForTag(TS_IDS, TS_TEMPLATES),
[TAGS.ReactJS]: generateTemplateForTag(REACT_IDS, REACT_TEMPLATES),
[TAGS.VueJS]: [],
[TAGS.NodeJS]: generateTemplateForTag(NODE_IDS, NODE_TEMPLATES)
[TAGS.NodeJS]: generateTemplateForTag(NODE_IDS, NODE_TEMPLATES),
[TAGS.PHP]: generateTemplateForTag(PHP_IDS, PHP_TEMPLATES)
};
+218
View File
@@ -0,0 +1,218 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Syntax Quiz',
description: 'Test your knowledge of PHP syntax.',
questionnaire: {
questions: [
{
title: 'What does PHP stand for?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Personal Hypertext Processor',
is_correct: false,
},
{
label: 'PHP: Hypertext Preprocessor',
is_correct: true,
},
{
label: 'Pretext Hyper Processor',
is_correct: false,
},
],
},
{
title: 'Which of the following is the correct way to start a PHP script?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '<?php',
is_correct: true,
},
{
label: '<?',
is_correct: false,
},
{
label: '<script>',
is_correct: false,
},
{
label: '<php>',
is_correct: false,
},
],
},
{
title: 'What is the correct way to output "Hello, World!" in PHP?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[2], // TEXTAREA
options: [],
},
{
title: 'How do you end a PHP statement?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: ';',
is_correct: true,
},
{
label: '.',
is_correct: false,
},
{
label: ':',
is_correct: false,
},
{
label: ',',
is_correct: false,
},
],
},
{
title: 'What is the correct way to create a variable in PHP?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[1], // CHECKBOX
options: [
{
label: '$variable_name',
is_correct: true,
},
{
label: '@variable_name',
is_correct: false,
},
{
label: '%variable_name%',
is_correct: false,
},
],
},
{
title: 'How do you concatenate two strings in PHP?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '+',
is_correct: false,
},
{
label: '.',
is_correct: true,
},
{
label: ',',
is_correct: false,
},
{
label: '&',
is_correct: false,
},
],
},
{
title: 'What does the "echo" function do in PHP?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'It performs mathematical calculations.',
is_correct: false,
},
{
label: 'It outputs text or variables.',
is_correct: true,
},
{
label: 'It generates random numbers.',
is_correct: false,
},
],
},
{
title: 'Which operator is used to check if two values are equal in PHP?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '==',
is_correct: true,
},
{
label: '===',
is_correct: false,
},
{
label: '=',
is_correct: false,
},
{
label: '!=',
is_correct: false,
},
],
},
{
title: 'How do you comment out a single line of code in PHP?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '// This is a comment',
is_correct: false,
},
{
label: '# This is a comment',
is_correct: false,
},
{
label: '/* This is a comment */',
is_correct: false,
},
{
label: '/* This is a comment',
is_correct: true,
},
],
},
{
title: 'Which PHP function is used to include the contents of one PHP file into another?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[2], // TEXTAREA
options: [],
},
],
},
};
export default template;
+215
View File
@@ -0,0 +1,215 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Comments Quiz',
description: 'Test your knowledge of PHP comments.',
questionnaire: {
questions: [
{
title: 'What is the purpose of comments in PHP?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To execute code.',
is_correct: false,
},
{
label: 'To document code and provide explanations.',
is_correct: true,
},
{
label: 'To hide code from others.',
is_correct: false,
},
],
},
{
title: 'Which symbol is used to start a single-line comment in PHP?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '#',
is_correct: true,
},
{
label: '//',
is_correct: false,
},
{
label: '/*',
is_correct: false,
},
{
label: '--',
is_correct: false,
},
],
},
{
title: 'How do you start a multi-line comment in PHP?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '/*',
is_correct: true,
},
{
label: '#',
is_correct: false,
},
{
label: '//',
is_correct: false,
},
{
label: '--',
is_correct: false,
},
],
},
{
title: 'How do you end a multi-line comment in PHP?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '*/',
is_correct: true,
},
{
label: '#',
is_correct: false,
},
{
label: '//',
is_correct: false,
},
{
label: '--',
is_correct: false,
},
],
},
{
title: 'What is the purpose of using comments in code?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[1], // CHECKBOX
options: [
{
label: 'To provide explanations for code.',
is_correct: true,
},
{
label: 'To disable code temporarily.',
is_correct: false,
},
{
label: 'To make code execute faster.',
is_correct: false,
},
{
label: 'To document the author of the code.',
is_correct: true,
},
],
},
{
title: 'What is the correct way to add a comment in PHP?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[2], // TEXTAREA
options: [],
},
{
title: 'Can comments be nested in PHP?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Yes',
is_correct: true,
},
{
label: 'No',
is_correct: false,
},
],
},
{
title: 'Which of the following is not a valid way to comment out a block of code in PHP?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[1], // CHECKBOX
options: [
{
label: '/* ... */',
is_correct: false,
},
{
label: '// ...',
is_correct: false,
},
{
label: '# ... #',
is_correct: true,
},
{
label: '-- ... --',
is_correct: false,
},
],
},
{
title: 'What is the purpose of a doc comment in PHP?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To disable code temporarily.',
is_correct: false,
},
{
label: 'To document functions, classes, and methods.',
is_correct: true,
},
{
label: 'To hide code from others.',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to add a single-line comment?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[2], // TEXTAREA
options: [],
},
],
},
};
export default template;
+210
View File
@@ -0,0 +1,210 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Variables Quiz',
description: 'Test your knowledge of PHP variables.',
questionnaire: {
questions: [
{
title: 'What is a variable in PHP?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'A fixed value.',
is_correct: false,
},
{
label: 'A container for storing data.',
is_correct: true,
},
{
label: 'A PHP function.',
is_correct: false,
},
],
},
{
title: 'How do you declare a variable in PHP?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Using the keyword "let".',
is_correct: false,
},
{
label: 'Using the keyword "var".',
is_correct: false,
},
{
label: 'Using the dollar sign "$" followed by the variable name.',
is_correct: true,
},
],
},
{
title: 'Which of the following is a valid variable name in PHP?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[1], // CHECKBOX
options: [
{
label: '$my-variable',
is_correct: false,
},
{
label: '$my_variable',
is_correct: true,
},
{
label: '$1variable',
is_correct: false,
},
{
label: '$variable123',
is_correct: true,
},
],
},
{
title: 'What is the purpose of concatenation in PHP?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To perform mathematical operations.',
is_correct: false,
},
{
label: 'To combine two or more strings or values.',
is_correct: true,
},
{
label: 'To create a new variable.',
is_correct: false,
},
],
},
{
title: 'Which operator is used for concatenation in PHP?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '.',
is_correct: true,
},
{
label: '+',
is_correct: false,
},
{
label: '++',
is_correct: false,
},
{
label: '-',
is_correct: false,
},
],
},
{
title: 'What is the scope of a global variable in PHP?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'It is accessible only within a function.',
is_correct: false,
},
{
label: 'It is accessible throughout the entire script.',
is_correct: true,
},
{
label: 'It is accessible only within a loop.',
is_correct: false,
},
],
},
{
title: 'Which of the following is a superglobal variable in PHP?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[1], // CHECKBOX
options: [
{
label: '$my_variable',
is_correct: false,
},
{
label: '$_SESSION',
is_correct: true,
},
{
label: '$_POST',
is_correct: true,
},
{
label: '$_local',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the "unset" function in PHP?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To define a new variable.',
is_correct: false,
},
{
label: 'To destroy a session variable.',
is_correct: false,
},
{
label: 'To unset a variable or free its memory.',
is_correct: true,
},
],
},
{
title: 'Which function is used to check if a variable is empty in PHP?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[2], // TEXTAREA
options: [],
},
{
title: 'How do you display the value of a variable in PHP?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[2], // TEXTAREA
options: [],
},
],
},
};
export default template;
+184
View File
@@ -0,0 +1,184 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Echo and Print Quiz',
description: 'Test your knowledge of PHP echo and print functions.',
questionnaire: {
questions: [
{
title: 'What is the purpose of the "echo" statement in PHP?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To display text or HTML content to the browser.',
is_correct: true,
},
{
label: 'To declare a new variable.',
is_correct: false,
},
{
label: 'To perform mathematical calculations.',
is_correct: false,
},
],
},
{
title: 'Which of the following is the correct syntax for the "echo" statement in PHP?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[1], // CHECKBOX
options: [
{
label: 'echo "Hello, World!";',
is_correct: true,
},
{
label: 'echo("Hello, World!");',
is_correct: true,
},
{
label: 'echo = "Hello, World!";',
is_correct: false,
},
{
label: 'echo("Hello, World!");',
is_correct: false,
},
],
},
{
title: 'What is the difference between "echo" and "print" in PHP?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'There is no difference; "echo" and "print" are interchangeable.',
is_correct: false,
},
{
label: '"echo" can output multiple values at once, while "print" can output only one value at a time.',
is_correct: true,
},
{
label: '"echo" can only output text, while "print" can output both text and variables.',
is_correct: false,
},
],
},
{
title: 'Which of the following is an example of using the "print" statement in PHP?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[2], // TEXTAREA
options: [],
},
{
title: 'What is the output of the following PHP code?\n\n```php\n$variable = "Hello, World!";\necho $variable;\n```',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[2], // TEXTAREA
options: [],
},
{
title: 'Which of the following is a valid use of the "print_r" function in PHP?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[1], // CHECKBOX
options: [
{
label: 'Displaying the structure of an array.',
is_correct: true,
},
{
label: 'Performing mathematical calculations.',
is_correct: false,
},
{
label: 'Printing a text string.',
is_correct: false,
},
{
label: 'Checking the existence of a file.',
is_correct: false,
},
],
},
{
title: 'Which of the following PHP statements can be used to output HTML content?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'echo',
is_correct: true,
},
{
label: 'if',
is_correct: false,
},
{
label: 'for',
is_correct: false,
},
{
label: 'while',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the "nl2br" function in PHP?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To perform mathematical calculations.',
is_correct: false,
},
{
label: 'To convert newlines to HTML line breaks.',
is_correct: true,
},
{
label: 'To check the length of a string.',
is_correct: false,
},
],
},
{
title: 'What is the output of the following PHP code?\n\n```php\n$text = "Hello\nWorld!";\necho nl2br($text);\n```',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[2], // TEXTAREA
options: [],
},
{
title: 'In PHP, which function can be used to output the length of a string?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[2], // TEXTAREA
options: [],
},
],
},
};
export default template;
+226
View File
@@ -0,0 +1,226 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Data Types Quiz',
description: 'Test your knowledge of PHP data types.',
questionnaire: {
questions: [
{
title: 'What is the data type of the value 42 in PHP?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'String',
is_correct: false,
},
{
label: 'Integer',
is_correct: true,
},
{
label: 'Boolean',
is_correct: false,
},
],
},
{
title: 'Which of the following is NOT a valid PHP data type?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[1], // CHECKBOX
options: [
{
label: 'Array',
is_correct: false,
},
{
label: 'Object',
is_correct: false,
},
{
label: 'Float',
is_correct: false,
},
{
label: 'Character',
is_correct: true,
},
],
},
{
title: 'How do you declare a floating-point number in PHP?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '$x = 5;',
is_correct: false,
},
{
label: '$x = "5";',
is_correct: false,
},
{
label: '$x = 5.0;',
is_correct: true,
},
{
label: '$x = true;',
is_correct: false,
},
],
},
{
title: 'Which data type is used to store a sequence of characters in PHP?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Boolean',
is_correct: false,
},
{
label: 'Integer',
is_correct: false,
},
{
label: 'String',
is_correct: true,
},
{
label: 'Array',
is_correct: false,
},
],
},
{
title: 'What is the data type of the value "true" in PHP?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'String',
is_correct: false,
},
{
label: 'Integer',
is_correct: false,
},
{
label: 'Boolean',
is_correct: true,
},
{
label: 'Float',
is_correct: false,
},
],
},
{
title: 'Which data type is used to store a list of values in PHP?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Array',
is_correct: true,
},
{
label: 'String',
is_correct: false,
},
{
label: 'Object',
is_correct: false,
},
{
label: 'Float',
is_correct: false,
},
],
},
{
title: 'How do you declare a constant in PHP?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[2], // TEXTAREA
options: [],
},
{
title: 'Which data type is used to represent a date and time in PHP?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'String',
is_correct: false,
},
{
label: 'Integer',
is_correct: false,
},
{
label: 'Date',
is_correct: false,
},
{
label: 'DateTime',
is_correct: true,
},
],
},
{
title: 'How do you check the data type of a variable in PHP?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[2], // TEXTAREA
options: [],
},
{
title: 'Which data type is used to store a single character in PHP?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'String',
is_correct: true,
},
{
label: 'Character',
is_correct: false,
},
{
label: 'Integer',
is_correct: false,
},
{
label: 'Boolean',
is_correct: false,
},
],
},
],
},
};
export default template;
+264
View File
@@ -0,0 +1,264 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Strings Quiz',
description: 'Test your knowledge of PHP string manipulation.',
questionnaire: {
questions: [
{
title: 'What function is used to find the length of a string in PHP?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'strlen()',
is_correct: true,
},
{
label: 'strlength()',
is_correct: false,
},
{
label: 'length()',
is_correct: false,
},
{
label: 'count()',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to replace a specified text within a string?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'str_replace()',
is_correct: true,
},
{
label: 'replace()',
is_correct: false,
},
{
label: 'replaceText()',
is_correct: false,
},
{
label: 'substr_replace()',
is_correct: false,
},
],
},
{
title: 'What is the output of the following PHP code: `echo strpos("Hello World", "World");`?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Hello World',
is_correct: false,
},
{
label: 'World',
is_correct: false,
},
{
label: '0',
is_correct: true,
},
{
label: '-1',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to concatenate two strings?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'concat()',
is_correct: false,
},
{
label: 'join()',
is_correct: false,
},
{
label: 'implode()',
is_correct: false,
},
{
label: ' . (dot)',
is_correct: true,
},
],
},
{
title: 'How do you get the substring "World" from the string "Hello World" using PHP?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'substr("Hello World", 6, 5)',
is_correct: true,
},
{
label: 'substring("Hello World", 6, 5)',
is_correct: false,
},
{
label: 'substring("Hello World", 0, 5)',
is_correct: false,
},
{
label: 'slice("Hello World", 6, 5)',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to convert a string to all lowercase letters?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'tolowercase()',
is_correct: false,
},
{
label: 'strtolower()',
is_correct: true,
},
{
label: 'caseToLower()',
is_correct: false,
},
{
label: 'stringToLowerCase()',
is_correct: false,
},
],
},
{
title: 'How do you remove white spaces from the beginning and end of a string in PHP?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'trim()',
is_correct: true,
},
{
label: 'removeWhitespace()',
is_correct: false,
},
{
label: 'clean()',
is_correct: false,
},
{
label: 'strip()',
is_correct: false,
},
],
},
{
title: 'What is the output of the following PHP code: `echo strtoupper("hello");`?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Hello',
is_correct: false,
},
{
label: 'hello',
is_correct: false,
},
{
label: 'HELLO',
is_correct: true,
},
{
label: 'hELLO',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to split a string into an array of substrings?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'split()',
is_correct: false,
},
{
label: 'explode()',
is_correct: true,
},
{
label: 'splitString()',
is_correct: false,
},
{
label: 'substring()',
is_correct: false,
},
],
},
{
title: 'What is the correct way to escape a single quote (apostrophe) within a string in PHP?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '"Hello \'World\'"',
is_correct: false,
},
{
label: '"Hello "World""',
is_correct: false,
},
{
label: '"Hello \\\'World\\\'"',
is_correct: true,
},
{
label: '"Hello "World""',
is_correct: false,
},
],
},
],
},
};
export default template;
+252
View File
@@ -0,0 +1,252 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Numbers Quiz',
description: 'Test your knowledge of PHP numeric operations.',
questionnaire: {
questions: [
{
title: 'Which of the following is not a valid numeric data type in PHP?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'int',
is_correct: false,
},
{
label: 'float',
is_correct: false,
},
{
label: 'string',
is_correct: true,
},
{
label: 'double',
is_correct: false,
},
],
},
{
title: 'What is the result of the expression: `5 + 3 * 2` in PHP?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '16',
is_correct: false,
},
{
label: '11',
is_correct: true,
},
{
label: '13',
is_correct: false,
},
{
label: '10',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to check if a variable is an integer?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'is_int()',
is_correct: true,
},
{
label: 'intval()',
is_correct: false,
},
{
label: 'is_integer()',
is_correct: false,
},
{
label: 'int_check()',
is_correct: false,
},
],
},
{
title: 'What is the correct way to increment a variable `$x` by 1 in PHP?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '$x = $x++',
is_correct: false,
},
{
label: '$x++',
is_correct: true,
},
{
label: '$x += 1',
is_correct: false,
},
{
label: '$x = ++$x',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to round a float to the nearest integer?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'round()',
is_correct: true,
},
{
label: 'ceil()',
is_correct: false,
},
{
label: 'floor()',
is_correct: false,
},
{
label: 'intval()',
is_correct: false,
},
],
},
{
title: 'What is the result of the expression: `10 / 0` in PHP?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '0',
is_correct: false,
},
{
label: '10',
is_correct: false,
},
{
label: 'Infinity',
is_correct: true,
},
{
label: 'Error',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to find the minimum value among a list of numbers?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'min()',
is_correct: true,
},
{
label: 'maximum()',
is_correct: false,
},
{
label: 'minimum()',
is_correct: false,
},
{
label: 'smallest()',
is_correct: false,
},
],
},
{
title: 'What is the result of the expression: `5 == "5"` in PHP?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'true',
is_correct: true,
},
{
label: 'false',
is_correct: false,
},
{
label: 'Error',
is_correct: false,
},
{
label: '0',
is_correct: false,
},
],
},
{
title: 'How can you check if a PHP variable is NaN (Not-a-Number)?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[1], // CHECKBOX
options: [
{
label: 'Use `is_nan()` function',
is_correct: true,
},
{
label: 'Compare the variable to itself using `!==`',
is_correct: true,
},
{
label: 'Use `isNaN()` function',
is_correct: false,
},
{
label: 'Check if the variable is equal to `NaN`',
is_correct: true,
},
],
},
{
title: 'What is the correct way to convert the string "123" to an integer in PHP?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[2], // TEXTAREA
options: [
{
label: 'Enter your answer here',
is_correct: false,
},
],
},
],
},
};
export default template;
+252
View File
@@ -0,0 +1,252 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Math Quiz',
description: 'Test your knowledge of PHP mathematical operations.',
questionnaire: {
questions: [
{
title: 'Which of the following operators is used for exponentiation in PHP?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '**',
is_correct: true,
},
{
label: '^',
is_correct: false,
},
{
label: '^^',
is_correct: false,
},
{
label: 'exp()',
is_correct: false,
},
],
},
{
title: 'What is the result of the expression: `5 + 3` in PHP?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '15',
is_correct: false,
},
{
label: '8',
is_correct: true,
},
{
label: '53',
is_correct: false,
},
{
label: 'Error',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to find the square root of a number?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'sqrt()',
is_correct: true,
},
{
label: 'pow()',
is_correct: false,
},
{
label: 'log()',
is_correct: false,
},
{
label: 'exp()',
is_correct: false,
},
],
},
{
title: 'What is the correct way to generate a random number between 1 and 100 in PHP?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'rand(1, 100)',
is_correct: true,
},
{
label: 'random(1, 100)',
is_correct: false,
},
{
label: 'mt_rand(1, 100)',
is_correct: false,
},
{
label: 'random_int(1, 100)',
is_correct: false,
},
],
},
{
title: 'What is the result of the expression: `floor(6.75)` in PHP?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '7',
is_correct: false,
},
{
label: '6.75',
is_correct: false,
},
{
label: '6',
is_correct: true,
},
{
label: 'Error',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to calculate the absolute (positive) value of a number?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'abs()',
is_correct: true,
},
{
label: 'absolute()',
is_correct: false,
},
{
label: 'pos()',
is_correct: false,
},
{
label: 'positive()',
is_correct: false,
},
],
},
{
title: 'What is the result of the expression: `pi()` in PHP?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '3.14159265359',
is_correct: true,
},
{
label: '3.14',
is_correct: false,
},
{
label: '22/7',
is_correct: false,
},
{
label: 'Error',
is_correct: false,
},
],
},
{
title: 'How can you calculate the factorial of a number in PHP?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[1], // CHECKBOX
options: [
{
label: 'Use a loop to calculate the factorial',
is_correct: true,
},
{
label: 'Use the `factorial()` function',
is_correct: false,
},
{
label: 'Multiply the number by itself repeatedly',
is_correct: true,
},
{
label: 'Use recursion to calculate the factorial',
is_correct: true,
},
],
},
{
title: 'What is the result of the expression: `log10(100)` in PHP?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '2',
is_correct: true,
},
{
label: '10',
is_correct: false,
},
{
label: '0.01',
is_correct: false,
},
{
label: 'Error',
is_correct: false,
},
],
},
{
title: 'How can you round a floating-point number to the nearest integer in PHP?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[2], // TEXTAREA
options: [
{
label: 'Enter your answer here',
is_correct: false,
},
],
},
],
},
};
export default template;
+252
View File
@@ -0,0 +1,252 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Constants Quiz',
description: 'Test your knowledge of PHP constants.',
questionnaire: {
questions: [
{
title: 'Which keyword is used to define a constant in PHP?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'const',
is_correct: false,
},
{
label: 'var',
is_correct: false,
},
{
label: 'define',
is_correct: true,
},
{
label: 'let',
is_correct: false,
},
],
},
{
title: 'What is the value of a constant once it is defined in PHP?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'It cannot be changed',
is_correct: true,
},
{
label: 'It can be modified at any time',
is_correct: false,
},
{
label: 'It is automatically initialized to 0',
is_correct: false,
},
{
label: 'It is set to null',
is_correct: false,
},
],
},
{
title: 'What is the correct way to access a constant in PHP?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '$constant_name',
is_correct: false,
},
{
label: 'constant_name()',
is_correct: false,
},
{
label: 'constant("constant_name")',
is_correct: true,
},
{
label: 'Constant::constant_name',
is_correct: false,
},
],
},
{
title: 'Which of the following is a valid constant name in PHP?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'my constant',
is_correct: false,
},
{
label: 'CONSTANT_NAME',
is_correct: true,
},
{
label: '123constant',
is_correct: false,
},
{
label: 'constant-name',
is_correct: false,
},
],
},
{
title: 'How do you define a case-insensitive constant in PHP?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[1], // CHECKBOX
options: [
{
label: 'Use the `const` keyword',
is_correct: false,
},
{
label: 'Use the `define` function',
is_correct: true,
},
{
label: 'Use the `CASE_INSENSITIVE` flag when defining',
is_correct: false,
},
{
label: 'Use uppercase letters for the constant name',
is_correct: false,
},
],
},
{
title: 'Which of the following is a predefined constant in PHP that represents the current file name?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '__FILE__',
is_correct: true,
},
{
label: '__NAME__',
is_correct: false,
},
{
label: '__SCRIPT__',
is_correct: false,
},
{
label: '__FILENAME__',
is_correct: false,
},
],
},
{
title: 'What is the value of the predefined constant `PHP_VERSION`?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'The name of the current PHP script',
is_correct: false,
},
{
label: 'The version number of the PHP interpreter',
is_correct: true,
},
{
label: 'The date and time of the PHP installation',
is_correct: false,
},
{
label: 'The server name',
is_correct: false,
},
],
},
{
title: 'What is the value of the predefined constant `PHP_OS`?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'The operating system of the server',
is_correct: true,
},
{
label: 'The name of the PHP interpreter',
is_correct: false,
},
{
label: 'The version of PHP',
is_correct: false,
},
{
label: 'The server hostname',
is_correct: false,
},
],
},
{
title: 'How do you define a constant with a case-insensitive name in PHP?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[2], // TEXTAREA
options: [
{
label: 'Enter your answer here',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to check if a constant exists?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'isset()',
is_correct: false,
},
{
label: 'define()',
is_correct: false,
},
{
label: 'constant()',
is_correct: true,
},
{
label: 'check_constant()',
is_correct: false,
},
],
},
],
},
};
export default template;
+264
View File
@@ -0,0 +1,264 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Operators Quiz',
description: 'Test your knowledge of PHP operators.',
questionnaire: {
questions: [
{
title: 'Which operator is used for addition in PHP?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '+',
is_correct: true,
},
{
label: '-',
is_correct: false,
},
{
label: '*',
is_correct: false,
},
{
label: '/',
is_correct: false,
},
],
},
{
title: 'What is the result of the expression `5 % 2` in PHP?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '2',
is_correct: false,
},
{
label: '3',
is_correct: true,
},
{
label: '0',
is_correct: false,
},
{
label: '1',
is_correct: false,
},
],
},
{
title: 'Which operator is used for concatenating strings in PHP?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '+',
is_correct: true,
},
{
label: '-',
is_correct: false,
},
{
label: '*',
is_correct: false,
},
{
label: '/',
is_correct: false,
},
],
},
{
title: 'What is the result of the expression `$x .= $y` in PHP?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '$x is assigned the value of $y',
is_correct: true,
},
{
label: '$x is incremented by the value of $y',
is_correct: false,
},
{
label: '$x is compared to $y',
is_correct: false,
},
{
label: 'An error occurs',
is_correct: false,
},
],
},
{
title: 'Which operator is used for logical AND in PHP?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '&&',
is_correct: true,
},
{
label: '||',
is_correct: false,
},
{
label: '&',
is_correct: false,
},
{
label: '|||',
is_correct: false,
},
],
},
{
title: 'What is the result of the expression `true || false` in PHP?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'true',
is_correct: true,
},
{
label: 'false',
is_correct: false,
},
{
label: 'null',
is_correct: false,
},
{
label: '1',
is_correct: false,
},
],
},
{
title: 'Which operator is used for the not equal comparison in PHP?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '!=',
is_correct: true,
},
{
label: '!==',
is_correct: false,
},
{
label: '==',
is_correct: false,
},
{
label: '===',
is_correct: false,
},
],
},
{
title: 'What is the result of the expression `5 == "5"` in PHP?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'true',
is_correct: true,
},
{
label: 'false',
is_correct: false,
},
{
label: 'null',
is_correct: false,
},
{
label: '1',
is_correct: false,
},
],
},
{
title: 'Which operator is used for incrementing a variable in PHP?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '++',
is_correct: true,
},
{
label: '--',
is_correct: false,
},
{
label: '**',
is_correct: false,
},
{
label: '//',
is_correct: false,
},
],
},
{
title: 'What is the result of the expression `10 / 0` in PHP?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'An error occurs',
is_correct: true,
},
{
label: '0',
is_correct: false,
},
{
label: 'Infinity',
is_correct: false,
},
{
label: '1',
is_correct: false,
},
],
},
],
},
};
export default template;
+264
View File
@@ -0,0 +1,264 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP If-Else Statements Quiz',
description: 'Test your knowledge of PHP if-else statements.',
questionnaire: {
questions: [
{
title: 'What is the purpose of the PHP if statement?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To execute code if a condition is true',
is_correct: true,
},
{
label: 'To execute code if a condition is false',
is_correct: false,
},
{
label: 'To execute code in all cases',
is_correct: false,
},
{
label: 'To execute code only in a loop',
is_correct: false,
},
],
},
{
title: 'Which keyword is used to start an if-else statement in PHP?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'if-else',
is_correct: false,
},
{
label: 'if',
is_correct: true,
},
{
label: 'else',
is_correct: false,
},
{
label: 'elseif',
is_correct: false,
},
],
},
{
title: 'How do you write "if $x is equal to 5" in PHP?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'if $x = 5',
is_correct: true,
},
{
label: 'if $x == 5',
is_correct: false,
},
{
label: 'if $x := 5',
is_correct: false,
},
{
label: 'if $x -> 5',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the PHP else statement?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To execute code only if the condition is true',
is_correct: false,
},
{
label: 'To execute code only if the condition is false',
is_correct: true,
},
{
label: 'To execute code in all cases',
is_correct: false,
},
{
label: 'To execute code only in a loop',
is_correct: false,
},
],
},
{
title: 'Which of the following is the correct way to write an if-else statement in PHP?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'if (condition) { // code } else { // code }',
is_correct: true,
},
{
label: 'if (condition) { // code } else (condition) { // code }',
is_correct: false,
},
{
label: 'if { // code } else { // code } (condition)',
is_correct: false,
},
{
label: 'if (condition) { // code } { // code } else { // code }',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the PHP elseif statement?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To execute code only if the condition is true',
is_correct: true,
},
{
label: 'To execute code only if the condition is false',
is_correct: false,
},
{
label: 'To execute code in all cases',
is_correct: false,
},
{
label: 'To execute code only in a loop',
is_correct: false,
},
],
},
{
title: 'What is the output of the code snippet: `if (true) { echo "Hello"; } else { echo "Goodbye"; }`?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Hello',
is_correct: true,
},
{
label: 'Goodbye',
is_correct: false,
},
{
label: 'HelloGoodbye',
is_correct: false,
},
{
label: 'No output',
is_correct: false,
},
],
},
{
title: 'How can you write a switch statement in PHP?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'switch (x) { case 1: // code break; case 2: // code break; default: // code }',
is_correct: true,
},
{
label: 'if (x) { // code } else { // code }',
is_correct: false,
},
{
label: 'if (x == 1) { // code } else if (x == 2) { // code } else { // code }',
is_correct: false,
},
{
label: 'select (x) { case 1: // code break; case 2: // code break; default: // code }',
is_correct: false,
},
],
},
{
title: 'In a switch statement, what does the `break` keyword do?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'It exits the switch statement',
is_correct: true,
},
{
label: 'It continues to the next case without checking conditions',
is_correct: false,
},
{
label: 'It restarts the switch statement',
is_correct: false,
},
{
label: 'It is used to define a default case',
is_correct: false,
},
],
},
{
title: 'What is the output of the code: `if (false) { echo "Hello"; } elseif (true) { echo "Goodbye"; } else { echo "No output"; }`?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Goodbye',
is_correct: true,
},
{
label: 'Hello',
is_correct: false,
},
{
label: 'No output',
is_correct: false,
},
{
label: 'HelloGoodbye',
is_correct: false,
},
],
},
],
},
};
export default template;
+264
View File
@@ -0,0 +1,264 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Switch Statements Quiz',
description: 'Test your knowledge of PHP switch statements.',
questionnaire: {
questions: [
{
title: 'What is the purpose of the PHP switch statement?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To execute code only if the condition is true',
is_correct: false,
},
{
label: 'To execute code only if the condition is false',
is_correct: false,
},
{
label: 'To execute code in all cases',
is_correct: true,
},
{
label: 'To execute code only in a loop',
is_correct: false,
},
],
},
{
title: 'Which keyword is used to start a switch statement in PHP?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'if-else',
is_correct: false,
},
{
label: 'switch',
is_correct: true,
},
{
label: 'else',
is_correct: false,
},
{
label: 'elseif',
is_correct: false,
},
],
},
{
title: 'How do you write a case in a switch statement in PHP?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'case x:',
is_correct: true,
},
{
label: 'if x:',
is_correct: false,
},
{
label: 'when x:',
is_correct: false,
},
{
label: 'condition x:',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the PHP default case in a switch statement?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To execute code only if the condition is true',
is_correct: false,
},
{
label: 'To execute code only if the condition is false',
is_correct: false,
},
{
label: 'To execute code in all cases',
is_correct: false,
},
{
label: 'To execute code if no other case matches',
is_correct: true,
},
],
},
{
title: 'Which of the following is the correct way to write a switch statement in PHP?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'switch (x) { case 1: // code break; case 2: // code break; default: // code }',
is_correct: true,
},
{
label: 'if (x) { // code } else { // code }',
is_correct: false,
},
{
label: 'if (x == 1) { // code } else if (x == 2) { // code } else { // code }',
is_correct: false,
},
{
label: 'select (x) { case 1: // code break; case 2: // code break; default: // code }',
is_correct: false,
},
],
},
{
title: 'In a switch statement, what does the `break` keyword do?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'It exits the switch statement',
is_correct: true,
},
{
label: 'It continues to the next case without checking conditions',
is_correct: false,
},
{
label: 'It restarts the switch statement',
is_correct: false,
},
{
label: 'It is used to define a default case',
is_correct: false,
},
],
},
{
title: 'What is the output of the code snippet: `switch (2) { case 1: echo "One"; break; case 2: echo "Two"; break; default: echo "Default"; }`?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Two',
is_correct: true,
},
{
label: 'One',
is_correct: false,
},
{
label: 'Default',
is_correct: false,
},
{
label: 'TwoDefault',
is_correct: false,
},
],
},
{
title: 'What happens if there is no `break` statement in a case in a switch statement?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'The code in that case is executed, and then the switch statement continues to the next case',
is_correct: true,
},
{
label: 'An error is thrown',
is_correct: false,
},
{
label: 'The switch statement terminates',
is_correct: false,
},
{
label: 'The code in that case is skipped',
is_correct: false,
},
],
},
{
title: 'Which of the following is used to define the default case in a switch statement?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'case default:',
is_correct: false,
},
{
label: 'default:',
is_correct: true,
},
{
label: 'case else:',
is_correct: false,
},
{
label: 'else:',
is_correct: false,
},
],
},
{
title: 'What is the output of the code: `switch (true) { case 1: echo "One"; break; case 2: echo "Two"; break; default: echo "Default"; }`?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'One',
is_correct: false,
},
{
label: 'Two',
is_correct: false,
},
{
label: 'Default',
is_correct: true,
},
{
label: 'OneDefault',
is_correct: false,
},
],
},
],
},
};
export default template;
+264
View File
@@ -0,0 +1,264 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Looping Quiz',
description: 'Test your knowledge of PHP looping constructs.',
questionnaire: {
questions: [
{
title: 'Which PHP construct is used for iterating over the elements of an array?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'if statement',
is_correct: false,
},
{
label: 'while loop',
is_correct: false,
},
{
label: 'foreach loop',
is_correct: true,
},
{
label: 'switch statement',
is_correct: false,
},
],
},
{
title: 'What is the output of the code: `for ($i = 0; $i < 5; $i++) { echo $i; }`?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '01234',
is_correct: true,
},
{
label: '54321',
is_correct: false,
},
{
label: '012345',
is_correct: false,
},
{
label: '543210',
is_correct: false,
},
],
},
{
title: 'Which looping construct is best suited for executing code as long as a condition is true?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'for loop',
is_correct: false,
},
{
label: 'while loop',
is_correct: true,
},
{
label: 'foreach loop',
is_correct: false,
},
{
label: 'do...while loop',
is_correct: false,
},
],
},
{
title: 'How can you stop an ongoing loop in PHP?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Use the `halt` keyword',
is_correct: false,
},
{
label: 'Use the `exit` function',
is_correct: true,
},
{
label: 'Use the `stop` function',
is_correct: false,
},
{
label: 'Use the `break` statement',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the `continue` statement in a loop?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To exit the loop',
is_correct: false,
},
{
label: 'To restart the loop from the beginning',
is_correct: false,
},
{
label: 'To skip the current iteration and continue to the next',
is_correct: true,
},
{
label: 'To print the loop variable',
is_correct: false,
},
],
},
{
title: 'In a `for` loop, what does the initialization part specify?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'The loop condition',
is_correct: false,
},
{
label: 'The loop body',
is_correct: false,
},
{
label: 'The loop variable and its initial value',
is_correct: true,
},
{
label: 'The loop increment',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the `do...while` loop?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To execute the loop body once and then check the condition',
is_correct: true,
},
{
label: 'To execute the loop body a fixed number of times',
is_correct: false,
},
{
label: 'To iterate over the elements of an array',
is_correct: false,
},
{
label: 'To execute the loop body until a condition is false',
is_correct: false,
},
],
},
{
title: 'Which loop construct is best suited for iterating over the elements of an associative array in PHP?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'for loop',
is_correct: false,
},
{
label: 'while loop',
is_correct: false,
},
{
label: 'foreach loop',
is_correct: true,
},
{
label: 'do...while loop',
is_correct: false,
},
],
},
{
title: 'What is the output of the code: `foreach ($colors as $color) { echo $color; }` where `$colors` is an array containing ["red", "green", "blue"]?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'redgreenblue',
is_correct: false,
},
{
label: 'RGB',
is_correct: false,
},
{
label: 'red green blue',
is_correct: true,
},
{
label: 'red,green,blue',
is_correct: false,
},
],
},
{
title: 'What does the `break` statement do in a loop?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'It continues to the next iteration of the loop',
is_correct: false,
},
{
label: 'It exits the loop prematurely',
is_correct: true,
},
{
label: 'It skips the current iteration and continues to the next',
is_correct: false,
},
{
label: 'It restarts the loop from the beginning',
is_correct: false,
},
],
},
],
},
};
export default template;
+264
View File
@@ -0,0 +1,264 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Functions Quiz',
description: 'Test your knowledge of PHP functions and their usage.',
questionnaire: {
questions: [
{
title: 'What is the purpose of a PHP function?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To define a variable',
is_correct: false,
},
{
label: 'To execute a block of code when called',
is_correct: true,
},
{
label: 'To perform mathematical operations',
is_correct: false,
},
{
label: 'To display a message',
is_correct: false,
},
],
},
{
title: 'What is the correct syntax for defining a PHP function?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'function myFunction() { }',
is_correct: true,
},
{
label: 'def myFunction():',
is_correct: false,
},
{
label: 'func myFunction { }',
is_correct: false,
},
{
label: 'void myFunction() { }',
is_correct: false,
},
],
},
{
title: 'What is a parameter in a PHP function?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'A value that is returned by the function',
is_correct: false,
},
{
label: 'A variable used to store the function name',
is_correct: false,
},
{
label: 'A value passed into the function when it is called',
is_correct: true,
},
{
label: 'A variable that is declared inside the function',
is_correct: false,
},
],
},
{
title: 'How do you call a PHP function named "myFunction"?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'call myFunction()',
is_correct: false,
},
{
label: 'myFunction;',
is_correct: false,
},
{
label: 'myFunction();',
is_correct: true,
},
{
label: 'execute myFunction;',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the `return` statement in a PHP function?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To define a variable',
is_correct: false,
},
{
label: 'To exit the function and return a value',
is_correct: true,
},
{
label: 'To print a message to the console',
is_correct: false,
},
{
label: 'To declare a function',
is_correct: false,
},
],
},
{
title: 'What is the purpose of function parameters?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To store global variables',
is_correct: false,
},
{
label: 'To define the function name',
is_correct: false,
},
{
label: 'To provide input values to the function',
is_correct: true,
},
{
label: 'To print output values',
is_correct: false,
},
],
},
{
title: 'What does the `global` keyword do in PHP?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Declares a function as global',
is_correct: false,
},
{
label: 'Defines a global variable',
is_correct: true,
},
{
label: 'Specifies the function scope',
is_correct: false,
},
{
label: 'Prints a message to the screen',
is_correct: false,
},
],
},
{
title: 'What is the purpose of a PHP built-in function?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To define a user-defined function',
is_correct: false,
},
{
label: 'To create a new variable',
is_correct: false,
},
{
label: 'To perform common tasks without writing custom code',
is_correct: true,
},
{
label: 'To declare a class',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the `strlen()` function in PHP?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To calculate the square root of a number',
is_correct: false,
},
{
label: 'To check if a variable is empty',
is_correct: false,
},
{
label: 'To count the number of characters in a string',
is_correct: true,
},
{
label: 'To convert a string to lowercase',
is_correct: false,
},
],
},
{
title: 'How do you define a default value for a function parameter in PHP?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'By using the `default` keyword',
is_correct: false,
},
{
label: 'By specifying the default value in the function declaration',
is_correct: true,
},
{
label: 'By using the `value` keyword',
is_correct: false,
},
{
label: 'Default values are not supported in PHP',
is_correct: false,
},
],
},
],
},
};
export default template;
+264
View File
@@ -0,0 +1,264 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Arrays Quiz',
description: 'Test your knowledge of PHP arrays and their usage.',
questionnaire: {
questions: [
{
title: 'What is an array in PHP?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'A mathematical function',
is_correct: false,
},
{
label: 'A data structure that can hold multiple values',
is_correct: true,
},
{
label: 'A string manipulation technique',
is_correct: false,
},
{
label: 'A type of loop in PHP',
is_correct: false,
},
],
},
{
title: 'How do you create an indexed array in PHP?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Using the `array()` constructor',
is_correct: true,
},
{
label: 'Using the `new Array()` constructor',
is_correct: false,
},
{
label: 'By defining each element separately',
is_correct: false,
},
{
label: 'Indexed arrays are not supported in PHP',
is_correct: false,
},
],
},
{
title: 'What is the index of the first element in a PHP indexed array?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '0',
is_correct: true,
},
{
label: '1',
is_correct: false,
},
{
label: '-1',
is_correct: false,
},
{
label: 'No index for the first element',
is_correct: false,
},
],
},
{
title: 'How do you access an element in a PHP indexed array?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'By using the element name',
is_correct: false,
},
{
label: 'By using the element value',
is_correct: false,
},
{
label: 'By using the element index',
is_correct: true,
},
{
label: 'By using the element key',
is_correct: false,
},
],
},
{
title: 'What is the purpose of an associative array in PHP?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To store only numbers',
is_correct: false,
},
{
label: 'To store only strings',
is_correct: false,
},
{
label: 'To store key-value pairs',
is_correct: true,
},
{
label: 'To store only boolean values',
is_correct: false,
},
],
},
{
title: 'How do you add a key-value pair to an associative array in PHP?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'By using the `add` keyword',
is_correct: false,
},
{
label: 'By using the `append` method',
is_correct: false,
},
{
label: 'By using square brackets and the key name',
is_correct: true,
},
{
label: 'Associative arrays do not support adding key-value pairs',
is_correct: false,
},
],
},
{
title: 'How do you check if a key exists in an associative array in PHP?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'By using the `exists` method',
is_correct: false,
},
{
label: 'By using the `contains` keyword',
is_correct: false,
},
{
label: 'By using the `in_array` function',
is_correct: false,
},
{
label: 'By using the `array_key_exists` function',
is_correct: true,
},
],
},
{
title: 'What is the purpose of a multidimensional array in PHP?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To store only numbers',
is_correct: false,
},
{
label: 'To store only strings',
is_correct: false,
},
{
label: 'To store key-value pairs',
is_correct: false,
},
{
label: 'To store arrays within an array',
is_correct: true,
},
],
},
{
title: 'How do you access an element in a multidimensional array in PHP?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'By using the element name',
is_correct: false,
},
{
label: 'By using the element value',
is_correct: false,
},
{
label: 'By using the element index',
is_correct: true,
},
{
label: 'By using the element key',
is_correct: false,
},
],
},
{
title: 'What is the difference between indexed and associative arrays in PHP?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Indexed arrays have keys and values, while associative arrays only have values',
is_correct: false,
},
{
label: 'Indexed arrays are unordered, while associative arrays are ordered',
is_correct: false,
},
{
label: 'Indexed arrays use strings as keys, while associative arrays use integers',
is_correct: false,
},
{
label: 'Indexed arrays use integers as keys, while associative arrays use named keys',
is_correct: true,
},
],
},
],
},
};
export default template;
+264
View File
@@ -0,0 +1,264 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Superglobals Quiz',
description: 'Test your knowledge of PHP superglobals and their usage.',
questionnaire: {
questions: [
{
title: 'Which superglobal in PHP is used to collect form data after submitting an HTML form?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '$_POST',
is_correct: true,
},
{
label: '$_GET',
is_correct: false,
},
{
label: '$_REQUEST',
is_correct: false,
},
{
label: '$_SESSION',
is_correct: false,
},
],
},
{
title: 'Which superglobal in PHP is used to read variables from the global scope?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '$_POST',
is_correct: false,
},
{
label: '$_GET',
is_correct: false,
},
{
label: '$_REQUEST',
is_correct: false,
},
{
label: '$GLOBALS',
is_correct: true,
},
],
},
{
title: 'What does the superglobal $_SESSION in PHP store?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'User session data',
is_correct: true,
},
{
label: 'Server configuration settings',
is_correct: false,
},
{
label: 'Database connection details',
is_correct: false,
},
{
label: 'Form input data',
is_correct: false,
},
],
},
{
title: 'Which superglobal in PHP is used to retrieve data sent to the server via a URL?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '$_POST',
is_correct: false,
},
{
label: '$_GET',
is_correct: true,
},
{
label: '$_REQUEST',
is_correct: false,
},
{
label: '$_SERVER',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the $_COOKIE superglobal in PHP?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To store database records',
is_correct: false,
},
{
label: 'To store session data',
is_correct: false,
},
{
label: 'To store user-specific data on the client side',
is_correct: true,
},
{
label: 'To store form input data',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the $_REQUEST superglobal in PHP?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To retrieve server configuration settings',
is_correct: false,
},
{
label: 'To retrieve data from the client side',
is_correct: true,
},
{
label: 'To store user session data',
is_correct: false,
},
{
label: 'To store form input data',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the $_SERVER superglobal in PHP?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To store user session data',
is_correct: false,
},
{
label: 'To retrieve information about the server environment and request',
is_correct: true,
},
{
label: 'To store form input data',
is_correct: false,
},
{
label: 'To retrieve data from the client side',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the $_ENV superglobal in PHP?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To store user session data',
is_correct: false,
},
{
label: 'To retrieve server configuration settings',
is_correct: true,
},
{
label: 'To store form input data',
is_correct: false,
},
{
label: 'To retrieve data from the client side',
is_correct: false,
},
],
},
{
title: 'Which superglobal in PHP is used to access environment variables?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '$_SERVER',
is_correct: false,
},
{
label: '$_GET',
is_correct: false,
},
{
label: '$_ENV',
is_correct: true,
},
{
label: '$_POST',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the $_FILES superglobal in PHP?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To store user session data',
is_correct: false,
},
{
label: 'To retrieve server configuration settings',
is_correct: false,
},
{
label: 'To store form input data',
is_correct: false,
},
{
label: 'To handle file uploads from HTML forms',
is_correct: true,
},
],
},
],
},
};
export default template;
+264
View File
@@ -0,0 +1,264 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Regular Expressions Quiz',
description: 'Test your knowledge of regular expressions in PHP.',
questionnaire: {
questions: [
{
title: 'What is the purpose of regular expressions in PHP?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To manipulate arrays',
is_correct: false,
},
{
label: 'To perform pattern matching on strings',
is_correct: true,
},
{
label: 'To create databases',
is_correct: false,
},
{
label: 'To define classes and objects',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to perform a regular expression match?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'strpos()',
is_correct: false,
},
{
label: 'preg_match()',
is_correct: true,
},
{
label: 'substr()',
is_correct: false,
},
{
label: 'str_replace()',
is_correct: false,
},
],
},
{
title: 'In a regular expression, what does the caret (^) symbol represent?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'The start of a line or string',
is_correct: true,
},
{
label: 'The end of a line or string',
is_correct: false,
},
{
label: 'A wildcard character',
is_correct: false,
},
{
label: 'An optional character',
is_correct: false,
},
],
},
{
title: 'Which regular expression modifier is used in PHP to perform a case-insensitive match?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'i',
is_correct: true,
},
{
label: 'm',
is_correct: false,
},
{
label: 's',
is_correct: false,
},
{
label: 'x',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the quantifier "+" in a regular expression?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To match zero or one occurrence of the preceding character',
is_correct: false,
},
{
label: 'To match zero or more occurrences of the preceding character',
is_correct: false,
},
{
label: 'To match one or more occurrences of the preceding character',
is_correct: true,
},
{
label: 'To match a specific number of occurrences of the preceding character',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the backslash (\) in a regular expression?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To escape a special character',
is_correct: true,
},
{
label: 'To represent a wildcard character',
is_correct: false,
},
{
label: 'To indicate the end of a line',
is_correct: false,
},
{
label: 'To define a character class',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to replace text based on a regular expression?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'preg_match()',
is_correct: false,
},
{
label: 'preg_replace()',
is_correct: true,
},
{
label: 'strpos()',
is_correct: false,
},
{
label: 'str_replace()',
is_correct: false,
},
],
},
{
title: 'What does the metacharacter "." (dot) represent in a regular expression?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'Any character except a newline',
is_correct: true,
},
{
label: 'A numeric digit',
is_correct: false,
},
{
label: 'A whitespace character',
is_correct: false,
},
{
label: 'The start of a line or string',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to perform a global regular expression match?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'preg_match()',
is_correct: false,
},
{
label: 'preg_replace()',
is_correct: false,
},
{
label: 'preg_grep()',
is_correct: false,
},
{
label: 'preg_match_all()',
is_correct: true,
},
],
},
{
title: 'What is a capture group in a regular expression?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'A way to exclude characters from matching',
is_correct: false,
},
{
label: 'A way to capture and remember a matched portion of the input',
is_correct: true,
},
{
label: 'A way to specify a required character in the input',
is_correct: false,
},
{
label: 'A way to match any character',
is_correct: false,
},
],
},
],
},
};
export default template;
+264
View File
@@ -0,0 +1,264 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Forms Quiz',
description: 'Test your knowledge of working with forms in PHP.',
questionnaire: {
questions: [
{
title: 'What is the purpose of an HTML form in PHP?',
name: 'question1',
points: 2,
order: 0,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To display text on a webpage',
is_correct: false,
},
{
label: 'To store data in a database',
is_correct: false,
},
{
label: 'To collect user input and send it to a server',
is_correct: true,
},
{
label: 'To create links between web pages',
is_correct: false,
},
],
},
{
title: 'Which HTML tag is used to create a form in PHP?',
name: 'question2',
points: 2,
order: 1,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '<form>',
is_correct: true,
},
{
label: '<input>',
is_correct: false,
},
{
label: '<button>',
is_correct: false,
},
{
label: '<div>',
is_correct: false,
},
],
},
{
title: 'What attribute is used to specify the HTTP method for submitting a form in PHP?',
name: 'question3',
points: 2,
order: 2,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'action',
is_correct: false,
},
{
label: 'method',
is_correct: true,
},
{
label: 'target',
is_correct: false,
},
{
label: 'enctype',
is_correct: false,
},
],
},
{
title: 'Which HTTP method is used to send form data to the server in PHP?',
name: 'question4',
points: 2,
order: 3,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'GET',
is_correct: true,
},
{
label: 'POST',
is_correct: false,
},
{
label: 'PUT',
is_correct: false,
},
{
label: 'DELETE',
is_correct: false,
},
],
},
{
title: 'In PHP, which superglobal array is used to collect form data?',
name: 'question5',
points: 2,
order: 4,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '$_GET',
is_correct: false,
},
{
label: '$_POST',
is_correct: true,
},
{
label: '$_REQUEST',
is_correct: false,
},
{
label: '$_SESSION',
is_correct: false,
},
],
},
{
title: 'Which HTML input element is used to create a text field in a form?',
name: 'question6',
points: 2,
order: 5,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '<input type="text">',
is_correct: true,
},
{
label: '<input type="checkbox">',
is_correct: false,
},
{
label: '<input type="radio">',
is_correct: false,
},
{
label: '<input type="password">',
is_correct: false,
},
],
},
{
title: 'Which PHP function is used to validate and sanitize user input from a form?',
name: 'question7',
points: 2,
order: 6,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'htmlspecialchars()',
is_correct: false,
},
{
label: 'mysqli_query()',
is_correct: false,
},
{
label: 'filter_var()',
is_correct: true,
},
{
label: 'json_encode()',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the enctype attribute in a form element?',
name: 'question8',
points: 2,
order: 7,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To specify the form action',
is_correct: false,
},
{
label: 'To define the form method',
is_correct: false,
},
{
label: 'To specify the character encoding of form data',
is_correct: true,
},
{
label: 'To define the form target',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the <button> element in a form?',
name: 'question9',
points: 2,
order: 8,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: 'To create a clickable link',
is_correct: false,
},
{
label: 'To submit the form data',
is_correct: false,
},
{
label: 'To define a form field',
is_correct: false,
},
{
label: 'To create a clickable button',
is_correct: true,
},
],
},
{
title: 'In PHP, how can you access the value of a submitted form field named "username"?',
name: 'question10',
points: 2,
order: 9,
question_type: QuestionTypes[0], // RADIO
options: [
{
label: '$_POST["username"]',
is_correct: true,
},
{
label: '$_GET["username"]',
is_correct: false,
},
{
label: '$_REQUEST["username"]',
is_correct: false,
},
{
label: '$_SESSION["username"]',
is_correct: false,
},
],
},
],
},
};
export default template;
+186
View File
@@ -0,0 +1,186 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Form Validation Quiz',
description: 'Test your knowledge of PHP form validation.',
questionnaire: {
questions: [
{
title: 'What is form validation?',
name: 'q1',
points: 2,
order: 1,
question_type: QuestionTypes[0],
options: [
{
label: 'Ensuring that data is submitted to the server',
is_correct: false,
},
{
label: 'Validating user input before processing',
is_correct: true,
},
{
label: 'Displaying form data on the page',
is_correct: false,
},
],
},
{
title: 'How is form data typically sent to the server?',
name: 'q2',
points: 2,
order: 2,
question_type: QuestionTypes[1],
options: [
{
label: 'Using GET method',
is_correct: false,
},
{
label: 'Using POST method',
is_correct: true,
},
{
label: 'Using PUT method',
is_correct: false,
},
],
},
{
title: 'Which function is used to perform form validation in PHP?',
name: 'q3',
points: 2,
order: 3,
question_type: QuestionTypes[2],
options: [
{
label: 'validate_form()',
is_correct: false,
},
{
label: 'check_form_data()',
is_correct: false,
},
{
label: 'filter_input()',
is_correct: true,
},
],
},
{
title: 'Your text area question goes here.',
name: 'q4',
points: 2,
order: 4,
question_type: QuestionTypes[3],
options: [], // No options for TEXTAREA type
},
{
title: 'Your checkbox question goes here.',
name: 'q5',
points: 2,
order: 5,
question_type: QuestionTypes[4],
options: [
{
label: 'Option 1',
is_correct: true,
},
{
label: 'Option 2',
is_correct: false,
},
{
label: 'Option 3',
is_correct: true,
},
],
},
{
title: 'Your text area question goes here.',
name: 'q6',
points: 2,
order: 6,
question_type: QuestionTypes[5],
options: [], // No options for TEXTAREA type
},
{
title: 'Your radio question goes here.',
name: 'q7',
points: 2,
order: 7,
question_type: QuestionTypes[6],
options: [
{
label: 'Option A',
is_correct: true,
},
{
label: 'Option B',
is_correct: false,
},
],
},
{
title: 'Your checkbox question goes here.',
name: 'q8',
points: 2,
order: 8,
question_type: QuestionTypes[7],
options: [
{
label: 'Option X',
is_correct: true,
},
{
label: 'Option Y',
is_correct: false,
},
{
label: 'Option Z',
is_correct: true,
},
],
},
{
title: 'Your text area question goes here.',
name: 'q9',
points: 2,
order: 9,
question_type: QuestionTypes[8],
options: [], // No options for TEXTAREA type
},
{
title: 'Your radio question goes here.',
name: 'q10',
points: 2,
order: 10,
question_type: QuestionTypes[9],
options: [
{
label: 'Option P',
is_correct: false,
},
{
label: 'Option Q',
is_correct: true,
},
],
},
],
},
};
export default template;
+185
View File
@@ -0,0 +1,185 @@
import { QuestionTypes } from '../utils';
import type { ExerciseTemplate } from '$lib/utils/types';
const template: ExerciseTemplate = {
title: 'PHP Form Required Quiz',
description: 'Test your knowledge of required fields in PHP forms.',
questionnaire: {
questions: [
{
title: 'What is a required field in a form?',
name: 'q1',
points: 2,
order: 1,
question_type: QuestionTypes[0],
options: [
{
label: 'A field that must be filled out by the user',
is_correct: true,
},
{
label: 'A field that is optional for the user to fill out',
is_correct: false,
},
{
label: 'A field that is automatically populated by the server',
is_correct: false,
},
],
},
{
title: 'How can you mark a field as required in HTML?',
name: 'q2',
points: 2,
order: 2,
question_type: QuestionTypes[1],
options: [
{
label: '<input type="required">',
is_correct: false,
},
{
label: '<input required>',
is_correct: true,
},
{
label: '<input type="text" required>',
is_correct: false,
},
],
},
{
title: 'What is the purpose of the "required" attribute in HTML forms?',
name: 'q3',
points: 2,
order: 3,
question_type: QuestionTypes[2],
options: [
{
label: 'It specifies the maximum length of input data',
is_correct: false,
},
{
label: 'It specifies that the field must be filled out before submitting the form',
is_correct: true,
},
{
label: 'It specifies the default value for the input field',
is_correct: false,
},
],
},
{
title: 'Your text area question goes here.',
name: 'q4',
points: 2,
order: 4,
question_type: QuestionTypes[3],
options: [], // No options for TEXTAREA type
},
{
title: 'Your checkbox question goes here.',
name: 'q5',
points: 2,
order: 5,
question_type: QuestionTypes[4],
options: [
{
label: 'Option 1',
is_correct: true,
},
{
label: 'Option 2',
is_correct: false,
},
{
label: 'Option 3',
is_correct: true,
},
],
},
{
title: 'Your text area question goes here.',
name: 'q6',
points: 2,
order: 6,
question_type: QuestionTypes[5],
options: [], // No options for TEXTAREA type
},
{
title: 'Your radio question goes here.',
name: 'q7',
points: 2,
order: 7,
question_type: QuestionTypes[6],
options: [
{
label: 'Option A',
is_correct: true,
},
{
label: 'Option B',
is_correct: false,
},
],
},
{
title: 'Your checkbox question goes here.',
name: 'q8',
points: 2,
order: 8,
question_type: QuestionTypes[7],
options: [
{
label: 'Option X',
is_correct: true,
},
{
label: 'Option Y',
is_correct: false,
},
{
label: 'Option Z',
is_correct: true,
},
],
},
{
title: 'Your text area question goes here.',
name: 'q9',
points: 2,
order: 9,
question_type: QuestionTypes[8],
options: [], // No options for TEXTAREA type
},
{
title: 'Your radio question goes here.',
name: 'q10',
points: 2,
order: 10,
question_type: QuestionTypes[9],
options: [
{
label: 'Option P',
is_correct: false,
},
{
label: 'Option Q',
is_correct: true,
},
],
},
],
},
};
export default template;
+67
View File
@@ -0,0 +1,67 @@
import phpSyntax from './001_php_syntax';
import phpComments from './002_php_comments';
import phpVariables from './003_php_variables';
import phpEcho from './004_php_echo';
import phpDataTypes from './005_php_dataTypes';
import phpString from './006_php_string';
import phpNumbers from './007_php_numbers';
import phpMath from './008_php_math';
import phpConstants from './009_php_constants';
import phpOperators from './010_php_operators';
import phpConditionals from './011_php_conditionals';
import phpSwitch from './012_php_switch';
import phpLoops from './013_php_loops';
import phpFunctions from './014_php_functions';
import phpArrays from './015_php_arrays';
import phpSuperglobal from './016_php_superGlobal';
import phpRegex from './017_php_regex';
import phpForms from './018_php_forms';
import phpFormValidation from './019_php_formValidation';
import phpFormRequired from './020_php_formRequired';
export const PHP_IDS: { [key: string]: string } = {
PHP_SYNTAX: 'PHP_SYNTAX',
PHP_COMMENTS: 'PHP_COMMENTS',
PHP_VARIABLES: 'PHP_VARIABLES',
PHP_ECHO: 'PHP_ECHO',
PHP_DATATYPES: 'PHP_DATATYPES',
PHP_STRING: 'PHP_STRING',
PHP_NUMBERS: 'PHP_NUMBERS',
PHP_MATH: 'PHP_MATH',
PHP_CONSTANTS: 'PHP_CONSTANTS',
PHP_OPERATORS: 'PHP_OPERATORS',
PHP_CONDITIONALS: 'PHP_CONDITIONALS',
PHP_SWITCH: 'PHP_SWITCH',
PHP_LOOPS: 'PHP_LOOPS',
PHP_FUNCTIONS: 'PHP_FUNCTIONS',
PHP_ARRAYS: 'PHP_ARRAYS',
PHP_SUPERGLOBAL: 'PHP_SUPERGLOBAL',
PHP_REGEX: 'PHP_REGEX',
PHP_FORMS: 'PHP_FORMS',
PHP_FORMVALIDATION: 'PHP_FORMVALIDATION',
PHP_FORMREQUIRED: 'PHP_FORMREQUIRED',
};
export const PHP_TEMPLATES = {
[PHP_IDS.PHP_SYNTAX]: phpSyntax,
[PHP_IDS.PHP_COMMENTS]: phpComments,
[PHP_IDS.PHP_VARIABLES]: phpVariables,
[PHP_IDS.PHP_ECHO]: phpEcho,
[PHP_IDS.PHP_DATATYPES]: phpDataTypes,
[PHP_IDS.PHP_STRING]: phpString,
[PHP_IDS.PHP_NUMBERS]: phpNumbers,
[PHP_IDS.PHP_MATH]: phpMath,
[PHP_IDS.PHP_CONSTANTS]: phpConstants,
[PHP_IDS.PHP_OPERATORS]: phpOperators,
[PHP_IDS.PHP_CONDITIONALS]: phpConditionals,
[PHP_IDS.PHP_SWITCH]: phpSwitch,
[PHP_IDS.PHP_LOOPS]: phpLoops,
[PHP_IDS.PHP_FUNCTIONS]: phpFunctions,
[PHP_IDS.PHP_ARRAYS]: phpArrays,
[PHP_IDS.PHP_SUPERGLOBAL]: phpSuperglobal,
[PHP_IDS.PHP_REGEX]: phpRegex,
[PHP_IDS.PHP_FORMS]: phpForms,
[PHP_IDS.PHP_FORMVALIDATION]: phpFormValidation,
[PHP_IDS.PHP_FORMREQUIRED]: phpFormRequired,
};