Files
classroomio/apps/dashboard/src/lib/mocks/php/015_php_arrays.ts
T

265 lines
6.8 KiB
TypeScript
Raw Normal View History

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',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'A data structure that can hold multiple values',
2023-11-25 21:56:02 +00:00
is_correct: true
},
{
label: 'A string manipulation technique',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'A type of loop in PHP',
2023-11-25 21:56:02 +00:00
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',
2023-11-25 21:56:02 +00:00
is_correct: true
},
{
label: 'Using the `new Array()` constructor',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'By defining each element separately',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'Indexed arrays are not supported in PHP',
2023-11-25 21:56:02 +00:00
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',
2023-11-25 21:56:02 +00:00
is_correct: true
},
{
label: '1',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: '-1',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'No index for the first element',
2023-11-25 21:56:02 +00:00
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',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'By using the element value',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'By using the element index',
2023-11-25 21:56:02 +00:00
is_correct: true
},
{
label: 'By using the element key',
2023-11-25 21:56:02 +00:00
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',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'To store only strings',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'To store key-value pairs',
2023-11-25 21:56:02 +00:00
is_correct: true
},
{
label: 'To store only boolean values',
2023-11-25 21:56:02 +00:00
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',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'By using the `append` method',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'By using square brackets and the key name',
2023-11-25 21:56:02 +00:00
is_correct: true
},
{
label: 'Associative arrays do not support adding key-value pairs',
2023-11-25 21:56:02 +00:00
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',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'By using the `contains` keyword',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'By using the `in_array` function',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'By using the `array_key_exists` function',
2023-11-25 21:56:02 +00:00
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',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'To store only strings',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'To store key-value pairs',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'To store arrays within an array',
2023-11-25 21:56:02 +00:00
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',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'By using the element value',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'By using the element index',
2023-11-25 21:56:02 +00:00
is_correct: true
},
{
label: 'By using the element key',
2023-11-25 21:56:02 +00:00
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',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'Indexed arrays are unordered, while associative arrays are ordered',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'Indexed arrays use strings as keys, while associative arrays use integers',
2023-11-25 21:56:02 +00:00
is_correct: false
},
{
label: 'Indexed arrays use integers as keys, while associative arrays use named keys',
2023-11-25 21:56:02 +00:00
is_correct: true
}
]
}
]
}
};
export default template;