fix: update base URLs in constants and clean up unused code in various files

This commit is contained in:
Resh 2025-04-16 11:00:33 +07:00
parent 7ba660a4eb
commit db1a76cd80
5 changed files with 11 additions and 110 deletions

View File

@ -1,3 +1,3 @@
const String baseUrl = 'https://api.seals.id/';
const String baseUrl = 'http://labai.polinema.ac.id:3001/';
const String mediaUrl = 'https://api.seals.id/api/uploads/';
const String mediaUrl = 'http://labai.polinema.ac.id:3001/api/uploads/';

View File

@ -21,11 +21,9 @@ class ProgressCard extends StatelessWidget {
Future<void> _navigateToTopics(
BuildContext context, CompletedTopic topic) async {
// Get the SectionProvider
final sectionProvider =
Provider.of<SectionProvider>(context, listen: false);
// Show loading indicator while checking/loading data
showDialog(
context: context,
barrierDismissible: false,
@ -35,7 +33,6 @@ class ProgressCard extends StatelessWidget {
);
try {
// If sections aren't loaded yet, load them
if (sectionProvider.sections.isEmpty) {
final userProvider = Provider.of<UserProvider>(context, listen: false);
final token = await userProvider.getValidToken();
@ -47,10 +44,8 @@ class ProgressCard extends StatelessWidget {
}
}
// Remove loading indicator
Navigator.pop(context);
// Navigate to topics screen
Navigator.push(
context,
MaterialPageRoute(
@ -60,10 +55,8 @@ class ProgressCard extends StatelessWidget {
),
);
} catch (e) {
// Remove loading indicator
Navigator.pop(context);
// Show error dialog
showDialog(
context: context,
builder: (context) => AlertDialog(

View File

@ -34,81 +34,6 @@ class _MatchingPairsQuestionState extends State<MatchingPairsQuestion> {
initializePairs();
}
// void initializePairs() {
// pairs = [];
// studentAnswers = {};
// originalPairMapping = {};
// originalPairIndices = {};
// if (widget.exercise is ExerciseModel) {
// // Mode Exercise
// pairs = (widget.exercise.choices as MatchingPair).pairs;
// final provider = Provider.of<ExerciseProvider>(context, listen: false);
// final currentIndex = provider.currentExerciseIndex;
// // Simpan indeks asli untuk setiap pasangan kiri
// for (int i = 0; i < pairs.length; i++) {
// originalPairIndices[pairs[i].left] = i;
// }
// originalRightPairs = pairs.map((pair) => pair.right as String).toList();
// shuffledRightPairs =
// List<String>.from(provider.shuffledRightPairsList[currentIndex]);
// } else if (widget.exercise is ReviewExerciseDetail) {
// // Mode Review
// if (widget.exercise.matchingPairs != null) {
// if (widget.exercise.answerStudent.isNotEmpty) {
// final answerPairs = widget.exercise.answerStudent.split(', ');
// // Buat pairs berdasarkan urutan jawaban siswa
// pairs = answerPairs.map((pair) {
// final parts = pair.split('-');
// return Pair(left: parts[0], right: parts[1]);
// }).toList();
// // Simpan indeks asli dan mapping untuk setiap pasangan
// for (int i = 0; i < pairs.length; i++) {
// final left = pairs[i].left;
// final right = pairs[i].right;
// originalPairIndices[left] = i;
// studentAnswers[left] = right;
// originalPairMapping[left] = right;
// }
// // Set originalRightPairs dan shuffledRightPairs sama dengan urutan jawaban siswa
// originalRightPairs =
// pairs.map((pair) => pair.right as String).toList();
// shuffledRightPairs =
// originalRightPairs.toList(); // Tidak diacak untuk review
// } else {
// // Jika tidak ada jawaban, gunakan data asli
// pairs = widget.exercise.matchingPairs!.map((reviewPair) {
// return Pair(
// left: reviewPair.leftPair,
// right: reviewPair.rightPair,
// );
// }).toList();
// // Simpan indeks asli untuk setiap pasangan
// for (int i = 0; i < pairs.length; i++) {
// originalPairIndices[pairs[i].left] = i;
// }
// originalRightPairs =
// pairs.map((pair) => pair.right as String).toList();
// shuffledRightPairs = originalRightPairs.toList();
// }
// }
// }
// // Bangun pemetaan konsisten
// for (int i = 0; i < pairs.length; i++) {
// final left = pairs[i].left;
// final right = pairs[i].right;
// originalPairMapping[left] = right;
// }
// }
void initializePairs() {
pairs = [];
studentAnswers = {};
@ -116,12 +41,10 @@ class _MatchingPairsQuestionState extends State<MatchingPairsQuestion> {
originalPairIndices = {};
if (widget.exercise is ExerciseModel) {
// Mode Exercise
pairs = (widget.exercise.choices as MatchingPair).pairs;
final provider = Provider.of<ExerciseProvider>(context, listen: false);
final currentIndex = provider.currentExerciseIndex;
// Simpan indeks asli untuk setiap pasangan kiri
for (int i = 0; i < pairs.length; i++) {
originalPairIndices[pairs[i].left] = i;
}
@ -130,9 +53,7 @@ class _MatchingPairsQuestionState extends State<MatchingPairsQuestion> {
shuffledRightPairs =
List<String>.from(provider.shuffledRightPairsList[currentIndex]);
} else if (widget.exercise is ReviewExerciseDetail) {
// Mode Review
if (widget.exercise.matchingPairs != null) {
// Gunakan data asli dari exercise untuk mempertahankan urutan
pairs = widget.exercise.matchingPairs!.map((reviewPair) {
return Pair(
left: reviewPair.leftPair,
@ -140,17 +61,13 @@ class _MatchingPairsQuestionState extends State<MatchingPairsQuestion> {
);
}).toList();
// Simpan indeks asli untuk setiap pasangan
for (int i = 0; i < pairs.length; i++) {
originalPairIndices[pairs[i].left] = i;
}
// Use the original right pairs without shuffling
originalRightPairs = pairs.map((pair) => pair.right as String).toList();
shuffledRightPairs =
originalRightPairs.toList(); // No shuffling for review
shuffledRightPairs = originalRightPairs.toList();
// Rekonstruksi jawaban siswa
if (widget.exercise.answerStudent.isNotEmpty) {
final answerPairs = widget.exercise.answerStudent.split('|');
for (var pair in answerPairs) {
@ -163,7 +80,6 @@ class _MatchingPairsQuestionState extends State<MatchingPairsQuestion> {
}
}
// Bangun pemetaan konsisten
for (int i = 0; i < pairs.length; i++) {
final left = pairs[i].left;
final right = pairs[i].right;
@ -194,7 +110,6 @@ class _MatchingPairsQuestionState extends State<MatchingPairsQuestion> {
bool isActive = false;
Color? color;
// Mencari indeks asli pasangan untuk warna yang konsisten
int originalPairIndex = -1;
if (isLeft) {
@ -202,9 +117,7 @@ class _MatchingPairsQuestionState extends State<MatchingPairsQuestion> {
pair is Pair ? pair.left == option : pair.leftPair == option);
isActive = provider.activeLeftOption == option;
} else {
// Untuk right pair, cari berdasarkan pasangan yang sudah terbentuk
if (widget.isReview) {
// Untuk mode review, periksa apakah opsi ini ada di jawaban siswa
final matchedLeft = studentAnswers.keys.firstWhere(
(key) => studentAnswers[key] == option,
orElse: () => '',
@ -229,20 +142,17 @@ class _MatchingPairsQuestionState extends State<MatchingPairsQuestion> {
}
}
// Menentukan warna berdasarkan status
if (widget.isReview) {
if (isLeft) {
// Untuk left pair di mode review
final matchedRight = studentAnswers[option];
if (matchedRight != null) {
isSelected = true;
// Cari indeks pasangan untuk warna yang konsisten
originalPairIndex = pairs.indexWhere(
(pair) => (pair is Pair ? pair.left : pair.leftPair) == option);
color = _getPairColor(originalPairIndex);
}
} else {
// Untuk right pair di mode review
final matchedLeft = studentAnswers.keys.firstWhere(
(key) => studentAnswers[key] == option,
orElse: () => '',
@ -250,7 +160,7 @@ class _MatchingPairsQuestionState extends State<MatchingPairsQuestion> {
if (matchedLeft.isNotEmpty) {
isSelected = true;
// Cari indeks pasangan untuk warna yang konsisten
originalPairIndex = pairs.indexWhere((pair) =>
(pair is Pair ? pair.left : pair.leftPair) == matchedLeft);
color = _getPairColor(originalPairIndex);
@ -331,7 +241,7 @@ class _MatchingPairsQuestionState extends State<MatchingPairsQuestion> {
final int pairIndex = entry.key;
final dynamic pair = entry.value;
final String left = pair is Pair ? pair.left : pair.leftPair;
// Menggunakan shuffledRightPairs untuk right pair
final String right = shuffledRightPairs[pairIndex];
return Padding(

View File

@ -45,9 +45,9 @@ class SeeProgressModal extends StatelessWidget {
),
const SizedBox(height: 20),
GridView.builder(
shrinkWrap: true, // Important to wrap GridView inside a modal
shrinkWrap: true,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 5, // Number of columns
crossAxisCount: 5,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
childAspectRatio: 1,
@ -57,9 +57,8 @@ class SeeProgressModal extends StatelessWidget {
final isCompleted = exerciseProvider.isExerciseCompleted(index);
return ElevatedButton(
onPressed: () {
Navigator.pop(context); // Close modal
exerciseProvider
.goToExercise(index); // Navigate to the selected exercise
Navigator.pop(context);
exerciseProvider.goToExercise(index);
},
style: ElevatedButton.styleFrom(
backgroundColor:
@ -71,7 +70,7 @@ class SeeProgressModal extends StatelessWidget {
width: 1,
),
),
elevation: 0, // Remove shadow
elevation: 0,
padding: const EdgeInsets.all(0),
minimumSize: const Size(50, 50),
),

View File

@ -48,7 +48,6 @@ class ResultScreen extends StatelessWidget {
);
}
// Menggunakan compareTo untuk membandingkan level
final currentLevelNum = _extractLevelNumber(currentLevel);
final nextLevelNum = _extractLevelNumber(nextLevel);