Updated and modified true/false question widget to change answer values and formatting
This commit is contained in:
parent
09d264ed59
commit
b5e33fc8dd
|
|
@ -1 +1,2 @@
|
||||||
const String baseUrl = 'https://1252-114-6-25-184.ngrok-free.app/';
|
const String baseUrl =
|
||||||
|
'https://ba47-2001-448a-50a0-14bf-701c-6eb0-9412-6ff4.ngrok-free.app/';
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ class TrueFalseQuestion extends StatelessWidget {
|
||||||
String? studentAnswer = _getStudentAnswer();
|
String? studentAnswer = _getStudentAnswer();
|
||||||
|
|
||||||
final options = [
|
final options = [
|
||||||
{'label': 'A', 'value': '1', 'text': 'True'},
|
{'label': 'A', 'value': 'true', 'text': 'True'},
|
||||||
{'label': 'B', 'value': '0', 'text': 'False'}
|
{'label': 'B', 'value': 'false', 'text': 'False'},
|
||||||
];
|
];
|
||||||
|
|
||||||
return _buildOptionsList(context, options, provider, studentAnswer);
|
return _buildOptionsList(context, options, provider, studentAnswer);
|
||||||
|
|
@ -29,7 +29,8 @@ class TrueFalseQuestion extends StatelessWidget {
|
||||||
|
|
||||||
String? _getStudentAnswer() {
|
String? _getStudentAnswer() {
|
||||||
if (isReview && exercise is ReviewExerciseDetail) {
|
if (isReview && exercise is ReviewExerciseDetail) {
|
||||||
return exercise.answerStudent;
|
// Konversi jawaban siswa ke format yang konsisten
|
||||||
|
return exercise.answerStudent == '1' ? 'true' : 'false';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -47,11 +48,9 @@ class TrueFalseQuestion extends StatelessWidget {
|
||||||
final text = option['text']!;
|
final text = option['text']!;
|
||||||
|
|
||||||
bool isSelected = false;
|
bool isSelected = false;
|
||||||
bool isCorrect = false;
|
|
||||||
|
|
||||||
if (isReview && exercise is ReviewExerciseDetail) {
|
if (isReview && exercise is ReviewExerciseDetail) {
|
||||||
|
// Menentukan apakah pilihan saat ini dipilih berdasarkan jawaban siswa
|
||||||
isSelected = studentAnswer == value;
|
isSelected = studentAnswer == value;
|
||||||
isCorrect = exercise.isCorrect == 1;
|
|
||||||
} else {
|
} else {
|
||||||
isSelected = provider.answers[provider.currentExerciseIndex] == value;
|
isSelected = provider.answers[provider.currentExerciseIndex] == value;
|
||||||
}
|
}
|
||||||
|
|
@ -66,8 +65,6 @@ class TrueFalseQuestion extends StatelessWidget {
|
||||||
label,
|
label,
|
||||||
text,
|
text,
|
||||||
isSelected,
|
isSelected,
|
||||||
isReview && isSelected,
|
|
||||||
isCorrect,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
|
|
@ -78,8 +75,6 @@ class TrueFalseQuestion extends StatelessWidget {
|
||||||
String label,
|
String label,
|
||||||
String text,
|
String text,
|
||||||
bool isSelected,
|
bool isSelected,
|
||||||
bool isReviewSelected,
|
|
||||||
bool isCorrect,
|
|
||||||
) {
|
) {
|
||||||
final backgroundColor =
|
final backgroundColor =
|
||||||
isSelected ? AppColors.blueColor : AppColors.whiteColor;
|
isSelected ? AppColors.blueColor : AppColors.whiteColor;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user