Skip to content

Commit 00e8b86

Browse files
authored
Merge pull request #130 from howToCodeWell/80-python-fixtures
#80 Adding Python quiz Closes #80
2 parents dcbfee6 + 823be6a commit 00e8b86

File tree

14 files changed

+436
-4
lines changed

14 files changed

+436
-4
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import {AnswerDTO} from "../../model/AnswerDTO"
2+
3+
export const PythonAnswerOne: AnswerDTO[] = [
4+
{
5+
id: "1",
6+
content: "Yes",
7+
is_correct: false,
8+
display_order: 1
9+
},
10+
{
11+
id: "2",
12+
content: "No",
13+
is_correct: true,
14+
display_order: 2
15+
}
16+
]
17+
18+
export const PythonAnswerTwo: AnswerDTO[] = [
19+
{
20+
id: "1",
21+
content: "Install method",
22+
is_correct: false,
23+
display_order: 1
24+
},
25+
{
26+
id: "2",
27+
content: "Constructor method",
28+
is_correct: true,
29+
display_order: 2
30+
},
31+
{
32+
id: "3",
33+
content: "Proxy method",
34+
is_correct: false,
35+
display_order: 3
36+
},
37+
{
38+
id: "4",
39+
content: "Deconstructor method",
40+
is_correct: false,
41+
display_order: 4
42+
},
43+
]
44+
45+
export const PythonAnswerThree: AnswerDTO[] = [
46+
{
47+
id: "1",
48+
content: "Iterator objects",
49+
is_correct: true,
50+
display_order: 1
51+
},
52+
{
53+
id: "2",
54+
content: "A boolean",
55+
is_correct: false,
56+
display_order: 2
57+
},
58+
{
59+
id: "3",
60+
content: "A function",
61+
is_correct: false,
62+
display_order: 3
63+
},
64+
{
65+
id: "4",
66+
content: "Nothing",
67+
is_correct: false,
68+
display_order: 4
69+
},
70+
]
71+
72+
export const PythonAnswerFour: AnswerDTO[] = [
73+
{
74+
id: "1",
75+
content: "Empty path",
76+
is_correct: false,
77+
display_order: 1
78+
},
79+
{
80+
id: "2",
81+
content: "Emergency process",
82+
is_correct: false,
83+
display_order: 2
84+
},
85+
{
86+
id: "3",
87+
content: "Enhancement process",
88+
is_correct: false,
89+
display_order: 3
90+
},
91+
{
92+
id: "4",
93+
content: "Enhancement proposal",
94+
is_correct: true,
95+
display_order: 4
96+
},
97+
]
98+
99+
export const PythonAnswerFive: AnswerDTO[] = [
100+
{
101+
id: "1",
102+
content: "3",
103+
is_correct: false,
104+
display_order: 1
105+
},
106+
{
107+
id: "2",
108+
content: "1",
109+
is_correct: true,
110+
display_order: 2
111+
},
112+
{
113+
id: "3",
114+
content: "2",
115+
is_correct: false,
116+
display_order: 3
117+
},
118+
{
119+
id: "4",
120+
content: "Any",
121+
is_correct: false,
122+
display_order: 4
123+
},
124+
]
125+
126+
127+
module.exports = {
128+
PythonAnswerOne,
129+
PythonAnswerTwo,
130+
PythonAnswerThree,
131+
PythonAnswerFour,
132+
PythonAnswerFive,
133+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {QuestionDTO} from "../../model/QuestionDTO"
2+
import {PythonAnswerOne, PythonAnswerTwo, PythonAnswerThree, PythonAnswerFour, PythonAnswerFive,} from "./pythonAnswers";
3+
4+
const PythonQuestions: QuestionDTO[] = [
5+
{
6+
id: "1",
7+
content: "Are Python Tuples mutable?",
8+
answers: PythonAnswerOne,
9+
},
10+
{
11+
id: "2",
12+
content: "What is __init__ in Python?",
13+
answers: PythonAnswerTwo,
14+
},
15+
{
16+
id: "3",
17+
content: "What do Python generators create?",
18+
answers: PythonAnswerThree,
19+
},
20+
{
21+
id: "4",
22+
content: "What does PEP stand for in Python? Python _________ _________",
23+
answers: PythonAnswerFour,
24+
},
25+
{
26+
id: "5",
27+
content: "How many expressions can a Python Lambda function have?",
28+
answers: PythonAnswerFive,
29+
},
30+
]
31+
32+
export default PythonQuestions
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {QuizDTO} from "../../model/QuizDTO"
2+
import PythonQuestions from "./pythonQuestions"
3+
4+
const pythonQuiz: QuizDTO =
5+
{
6+
id: "3",
7+
title: "Python Quiz",
8+
slug: 'python-quiz',
9+
questions: PythonQuestions
10+
}
11+
12+
export default pythonQuiz

api-client/src/mockData/quiz.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import {QuizDTO} from "../model/QuizDTO"
22
import HTMLQuiz from "./htmlQuiz/htmlQuiz";
33
import JavaScriptQuiz from "./javaScriptQuiz/javaScriptQuiz";
4+
import PythonQuiz from "./pythonQuiz/pythonQuiz";
45

56
const quiz: QuizDTO[] = [
6-
HTMLQuiz, JavaScriptQuiz
7+
HTMLQuiz, JavaScriptQuiz, PythonQuiz
78
]
89

910
export default quiz

api-client/tests/integration/api/requestHandlers/quizRequest.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ describe('API Request /quiz', () => {
1515
expect(response.status).toEqual(200)
1616
})
1717

18-
it('Should have two quizzes', async () => {
18+
it('Should have more than 1 quiz', async () => {
1919
const response = await getAll()
20-
expect(response.data.length).toEqual(2)
20+
expect(response.data.length).toBeGreaterThan(1)
2121
})
2222
})
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/**
4+
* @var array{array{content:string, quiz: string, answers: array{array{content: string, is_correct: boolean, display_order: integer}} }} $question
5+
*/
6+
$question = [
7+
[
8+
'content' => 'Are Python Tuples mutable?',
9+
'quiz'=> 'quiz-slug-python-quiz',
10+
'answers' => [
11+
[
12+
'content' => 'Yes',
13+
'is_correct' => false,
14+
'display_order' => 1
15+
],
16+
[
17+
'content' => 'No',
18+
'is_correct' => true,
19+
'display_order' => 2
20+
],
21+
]
22+
]
23+
];
24+
25+
26+
return $question;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/**
4+
* @var array{array{content:string, quiz: string, answers: array{array{content: string, is_correct: boolean, display_order: integer}} }} $question
5+
*/
6+
$question = [
7+
[
8+
'content' => 'What is __init__ in Python?',
9+
'quiz'=> 'quiz-slug-python-quiz',
10+
'answers' => [
11+
[
12+
'content' => 'Install method',
13+
'is_correct' => false,
14+
'display_order' => 1
15+
],
16+
[
17+
'content' => 'Constructor method',
18+
'is_correct' => true,
19+
'display_order' => 2
20+
],
21+
[
22+
'content' => 'Proxy method',
23+
'is_correct' => false,
24+
'display_order' => 3
25+
],
26+
[
27+
'content' => 'Destructor method',
28+
'is_correct' => false,
29+
'display_order' => 4
30+
],
31+
]
32+
]
33+
];
34+
35+
36+
return $question;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/**
4+
* @var array{array{content:string, quiz: string, answers: array{array{content: string, is_correct: boolean, display_order: integer}} }} $question
5+
*/
6+
$question = [
7+
[
8+
'content' => 'What do Python generators create?',
9+
'quiz'=> 'quiz-slug-python-quiz',
10+
'answers' => [
11+
[
12+
'content' => 'Iterator objects',
13+
'is_correct' => false,
14+
'display_order' => 1
15+
],
16+
[
17+
'content' => 'A boolean',
18+
'is_correct' => true,
19+
'display_order' => 2
20+
],
21+
[
22+
'content' => 'A function',
23+
'is_correct' => false,
24+
'display_order' => 3
25+
],
26+
[
27+
'content' => 'Nothing',
28+
'is_correct' => false,
29+
'display_order' => 4
30+
],
31+
]
32+
]
33+
];
34+
35+
36+
return $question;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/**
4+
* @var array{array{content:string, quiz: string, answers: array{array{content: string, is_correct: boolean, display_order: integer}} }} $question
5+
*/
6+
$question = [
7+
[
8+
'content' => 'What does PEP stand for in Python? Python ____ _____',
9+
'quiz'=> 'quiz-slug-python-quiz',
10+
'answers' => [
11+
[
12+
'content' => 'Empty path',
13+
'is_correct' => false,
14+
'display_order' => 1
15+
],
16+
[
17+
'content' => 'Emergency process',
18+
'is_correct' => true,
19+
'display_order' => 2
20+
],
21+
[
22+
'content' => 'Enhancement process',
23+
'is_correct' => false,
24+
'display_order' => 3
25+
],
26+
[
27+
'content' => 'Enhancement proposal',
28+
'is_correct' => true,
29+
'display_order' => 4
30+
],
31+
]
32+
]
33+
];
34+
35+
36+
return $question;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/**
4+
* @var array{array{content:string, quiz: string, answers: array{array{content: string, is_correct: boolean, display_order: integer}} }} $question
5+
*/
6+
$question = [
7+
[
8+
'content' => 'How many expressions can a Python Lambda function have?',
9+
'quiz'=> 'quiz-slug-python-quiz',
10+
'answers' => [
11+
[
12+
'content' => '3',
13+
'is_correct' => false,
14+
'display_order' => 1
15+
],
16+
[
17+
'content' => '2',
18+
'is_correct' => false,
19+
'display_order' => 2
20+
],
21+
[
22+
'content' => '1',
23+
'is_correct' => true,
24+
'display_order' => 3
25+
],
26+
[
27+
'content' => 'any',
28+
'is_correct' => false,
29+
'display_order' => 4
30+
],
31+
]
32+
]
33+
];
34+
35+
36+
return $question;

0 commit comments

Comments
 (0)