-
Notifications
You must be signed in to change notification settings - Fork 0
/
PythonPage.dart
165 lines (151 loc) · 6.02 KB
/
PythonPage.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import 'package:quizzapp/FailPage.dart';
import 'package:quizzapp/QuestionsC.dart';
import 'package:quizzapp/PassPage.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:quizzapp/Quizbrain.dart';
class Pyhton extends StatefulWidget {
const Pyhton({super.key});
@override
State<Pyhton> createState() => _PyhtonState();
}
class _PyhtonState extends State<Pyhton> {
List<IconData> scoreKeeper =[];
List<Questions> questionsBank=[
Questions(q: ' In Python, indentation is not important and does not affect the code\'s execution', a: false),
Questions(q: ' Python supports both single-line (//) and multi-line (/* */) comments. ', a: true),
Questions(q: ' The \'break\' statement is used to terminate the loop and skip the remaining iterations', a: true),
Questions(q: ' Python is a compiled programming language.', a: false),
Questions(q: ' Lists in Python can contain elements of different data types', a: true),
Questions(q: ' The \'append()\' method is used to remove an item from a list in Python. ', a: false),
Questions(q: ' A variable name in Python can start with a number.', a: false),
Questions(q: ' Python is not suitable for web development', a: false),
Questions(q: ' The \'and\' operator in Python is used to perform a bitwise AND operation. ', a: false),
Questions(q: ' Python\'s \'range()\' function returns a list of numbers starting from 1 to the specified value', a: false),
];
int questionnumber=0;
int totalnumber=0;
int t=0;
@override
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
flex:5,
child: Padding(
padding:EdgeInsets.all(10) ,
child: Center(
child: Text(
questionsBank[questionnumber].questiontext,
textAlign: TextAlign.center,
style:GoogleFonts.rajdhani(fontSize: 30,color: Colors.white,
),
),
),
),
),
Card(
color:Colors.green,
child: FloatingActionButton(
backgroundColor:Colors.green,
elevation: 0,
child:Text(
'True',
textAlign: TextAlign.center,
style:GoogleFonts.rajdhani(fontSize: 25,color: Colors.white,fontWeight: FontWeight.bold
),
),
onPressed: (){
bool correctans =questionsBank[questionnumber].questionanswer;
if (correctans==true){
t=t+1;
scoreKeeper.add(Icons.check);
}
else {
t=t;
scoreKeeper.add(Icons.close);
}
setState(() {
questionnumber++;
print('questionnumber: $questionnumber');
print('t: $t');
if (questionnumber == questionsBank.length-1 )
{
if( t >7 && t<10) {
Navigator.push(context,
MaterialPageRoute(
builder: (context) => PassPage()));
} else if( t<7 ) {
Navigator.push(context,
MaterialPageRoute(
builder: (context) => FailPage()));
}else{}
}});
},
),
),
Card(
color:Colors.red,
child: FloatingActionButton(
backgroundColor:Colors.red,
child:Text(
'False',
textAlign: TextAlign.center,
style:GoogleFonts.rajdhani(fontSize: 25,color: Colors.white,fontWeight: FontWeight.bold
),
),
elevation: 0,
onPressed: (){
bool correctans =questionsBank[questionnumber].questionanswer;
if (correctans==false){
t=t+1;
scoreKeeper.add(Icons.check);}
else {
t=t;
scoreKeeper.add(Icons.close);
}
setState(() {
questionnumber++;
print('questionnumber: $questionnumber');
print('t: $t');
if (questionnumber == questionsBank.length-1 ){
if( t<7 ) {
Navigator.push(context,
MaterialPageRoute(
builder: (context) => FailPage()));
} if (questionnumber == questionsBank.length-1 )
{
if( t >7 && t<10) {
Navigator.push(context,
MaterialPageRoute(
builder: (context) => PassPage()));
} }}
});},
),
),
Row(
children: scoreKeeper.map((iconData) {
if (iconData == Icons.check) {
return Icon(
iconData,
color: Colors.green, // Change this to the desired color for correct answers
);
} else if (iconData == Icons.close) {
return Icon(
iconData,
color: Colors.red, // Change this to the desired color for incorrect answers
);
}
return Container(); // Return an empty container if the iconData is invalid
}).toList(),
)
],
),
);
}
}