pedago-angular-quiz
Version:
A pedago quiz component for Angular projects
213 lines (172 loc) • 5.47 kB
Markdown
<h1 style="text-align: center">Pedago Angular Quiz</h1>
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.2.0.
```bash
npm install pedago-angular-quiz --save
```
Import NgxQuizModule
```typescript
import { PedagoAngularQuizModule } from 'pedago-angular-quiz';
@NgModule({
imports: [
// Other module imports
PedagoAngularQuizModule
],
// Other module properties
})
export class YourModule { }
```
Use it in your template and then pass a data object to the component as follows as an example
```html
<pedago-angular-quiz [data]="data" (onSubmit)="onSubmit($event)"></pedago-angular-quiz>
```
| Property | Type | Description |
|---------------|-----------|----------------------------------|
| **data!** | IData | The quiz data |
| **metadata?** | IMetadata | The quiz configuration |
| **client?** | string | The client name |
| **userId?** | string | The connected user id |
| Name | Parameters | Description |
|-------------------|----------------|---------------------------------------|
| **onSubmit** | event: IResult | Callback to invoke on quiz submission |
Interface representing the data structure of the quiz:
```typescript
interface IData {
questions: IQuestion[];
}
```
Interface representing a quiz question:
```typescript
interface IQuestion {
question: string;
options: IOption[];
explanation: string;
skill: string;
}
```
Interface representing a question option:
```typescript
interface IOption {
option: string;
is_correct: boolean;
}
```
Interface representing the result of the quiz:
```typescript
interface IResult {
client?: string;
userId?: string;
response: IResponse[];
}
```
Interface representing the response to a quiz question:
```typescript
interface IResponse {
questionID: string;
answer: string | string[];
correctedAnswer: string | string[];
is_correct: boolean;
is_partially_correct?: boolean;
}
```
Interface representing the theme of the quiz:
```typescript
interface ITheme {
primaryColor?: string;
secondaryColor?: string;
hasheader?: boolean;
headerBackColor?: string;
headerImage?: string;
}
```
```typescript
const data = {
"questions":
[
{
"question": "Quelle est la règle de probabilité qui dit que la probabilité d'un événement complémentaire est égale à 1 moins la probabilité de cet événement ?",
"options": [
{
"option": "La règle de l'addition",
"is_correct": false
},
{
"option": "La règle de la multiplication",
"is_correct": false
},
{
"option": "La règle du complément",
"is_correct": true
},
{
"option": "La règle de Bayes",
"is_correct": false
}
],
"explanation": "La réponse correcte est la règle du complément. Cette règle indique que la probabilité de l'événement complémentaire est égale à 1 moins la probabilité de l'événement lui-même.",
"skill": "Applying Probability Rules"
},
{
"question": "Quelles sont les distributions de probabilité discrètes les plus couramment utilisées pour modéliser des phénomènes aléatoires dans le domaine des sciences et de l'ingénierie?",
"options": [
{
"option": "Loi normale",
"is_correct": false
},
{
"option": "Loi uniforme",
"is_correct": false
},
{
"option": "Loi binomiale",
"is_correct": true
},
{
"option": "Loi exponentielle",
"is_correct": true
}
],
"explanation": "Les lois binomiale et exponentielle sont des distributions de probabilité discrètes couramment utilisées pour modéliser des phénomènes aléatoires. La loi binomiale est utilisée pour des expériences aléatoires avec un nombre fixe d'essais indépendants, tandis que la loi exponentielle est utilisée pour modéliser le temps entre occurrences d'événements selon un processus de Poisson.",
"skill": "Random Variables and Their Distributions"
},
{
"question": "Quelle est la règle utilisée pour calculer la probabilité de l'intersection de deux événements indépendants?",
"options": [
{
"option": "La règle de l'addition",
"is_correct": false
},
{
"option": "La règle de Bayes",
"is_correct": false
},
{
"option": "La règle de la multiplication",
"is_correct": true
},
{
"option": "La règle du complément",
"is_correct": false
}
],
"explanation": "La réponse correcte est la règle de la multiplication. Cette règle stipule que la probabilité de l'intersection de deux événements indépendants est égale au produit de leurs probabilités individuelles.",
"skill": "Applying Probability Rules"
}
]
}
```
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.