-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from Eugene600/ask_Me
Applied Separation of concerns in Ask Me
- Loading branch information
Showing
15 changed files
with
552 additions
and
452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:academia/exports/barrel.dart'; | ||
import 'package:academia/tools/ask_me/models/services/askme_service.dart.dart'; | ||
import 'package:dartz/dartz.dart'; | ||
import 'package:get/get.dart'; | ||
import 'controllers.dart'; | ||
|
||
class AskMeController extends GetxController{ | ||
final AskMeService _service = AskMeService(); | ||
UserController userController = Get.find<UserController>(); | ||
QuizSettingsController quizSettingsController = Get.find<QuizSettingsController>(); | ||
// final userId = 'MQ4'; | ||
/* | ||
For testing purposes as of now, I would recommend you to uncomment the above | ||
while comment the userId gotten from the userController since there is an issue | ||
at the moment on the backend since the backend does not expect the current number | ||
of characters for the user id which is 32 which is a really large number. | ||
This the error I am getting: | ||
Error: {"user_id":["Ensure this field has no more than 12 characters."]} | ||
The above issue is currently being fixed though. | ||
*/ | ||
|
||
Future<Either<String, dynamic>> fetchQuestions() async{ | ||
final result = await _service.fetchQuestions( | ||
userController.user.value?.id, | ||
// userId, | ||
quizSettingsController.fileTitle.value, | ||
quizSettingsController.filePath.value, | ||
quizSettingsController.multipleChoice.value); | ||
|
||
return result.fold((l) { | ||
return left(l); | ||
}, (r) { | ||
return right(r); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export 'files_controller.dart'; | ||
export 'quiz_settings_controller.dart'; | ||
export 'files_and_scores_controller.dart'; | ||
export 'quiz_settings_controller.dart'; | ||
export 'ask_me_controller.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import '../models.dart'; | ||
|
||
class MultipleChoiceQuiz { | ||
List<MultipleChoiceQuestion> questions; | ||
|
||
MultipleChoiceQuiz({required this.questions}); | ||
|
||
factory MultipleChoiceQuiz.fromJson(Map<String, dynamic> json) { | ||
return MultipleChoiceQuiz( | ||
questions: List<MultipleChoiceQuestion>.from( | ||
json['questions'].map((questionJson) => MultipleChoiceQuestion.fromJson(questionJson)), | ||
), | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return { | ||
'questions': questions.map((question) => question.toJson()).toList(), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import '../models.dart'; | ||
// import '../models.dart'; | ||
|
||
class Quiz { | ||
final List<Question> questions; | ||
// class Quiz { | ||
// final List<Question> questions; | ||
|
||
Quiz({required this.questions}); | ||
// Quiz({required this.questions}); | ||
|
||
// Factory method to create a Quiz from JSON | ||
factory Quiz.fromJson(Map<String, dynamic> json) { | ||
var questionsJson = json['questions'] as List; | ||
List<Question> questionList = questionsJson.map((q) => Question.fromJson(q)).toList(); | ||
// // Factory method to create a Quiz from JSON | ||
// factory Quiz.fromJson(Map<String, dynamic> json) { | ||
// var questionsJson = json['questions'] as List; | ||
// List<Question> questionList = questionsJson.map((q) => Question.fromJson(q)).toList(); | ||
|
||
return Quiz(questions: questionList); | ||
} | ||
// return Quiz(questions: questionList); | ||
// } | ||
|
||
// Convert the Quiz object to JSON | ||
Map<String, dynamic> toJson() { | ||
return { | ||
'questions': questions.map((q) => q.toJson()).toList(), | ||
}; | ||
} | ||
} | ||
// // Convert the Quiz object to JSON | ||
// Map<String, dynamic> toJson() { | ||
// return { | ||
// 'questions': questions.map((q) => q.toJson()).toList(), | ||
// }; | ||
// } | ||
// } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import '../models.dart'; | ||
|
||
class TrueFalseQuiz { | ||
List<TrueFalseQuestion> questions; | ||
|
||
TrueFalseQuiz({required this.questions}); | ||
|
||
factory TrueFalseQuiz.fromJson(Map<String, dynamic> json) { | ||
return TrueFalseQuiz( | ||
questions: List<TrueFalseQuestion>.from( | ||
json['questions'].map((questionJson) => TrueFalseQuestion.fromJson(questionJson)), | ||
), | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return { | ||
'questions': questions.map((question) => question.toJson()).toList(), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.