-
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 #79 from Eugene600/ask_Me
Ask me Tool
- Loading branch information
Showing
38 changed files
with
2,305 additions
and
5 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 @@ | ||
export 'pages/pages.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'files_controller.dart'; | ||
export 'quizSettings_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import 'package:get/get.dart'; | ||
import '../models/models.dart'; | ||
|
||
class FilesController extends GetxController { | ||
RxList<AskMeFiles> files = <AskMeFiles>[].obs; | ||
RxList<AskMeScores> scores = <AskMeScores>[].obs; | ||
|
||
@override | ||
void onInit() { | ||
super.onInit(); | ||
loadFiles(); | ||
} | ||
|
||
Future<void> loadFiles() async { | ||
// Fetch files | ||
FilesModelHelper().queryAll().then((value) { | ||
files.value = value.map((e) => AskMeFiles.fromJson(e)).toList(); | ||
}); | ||
|
||
//Fetch all scores | ||
ScoresModelHelper().queryAll().then((value) { | ||
scores.value = value.map((e) => AskMeScores.fromJson(e)).toList(); | ||
}); | ||
} | ||
|
||
// Fetch scores by file ID | ||
Future<void> fetchScoresByFileId(int fileId) async { | ||
final scoreList = await ScoresModelHelper().queryScoresByFileId(fileId); | ||
scores.value = scoreList.map((score) => AskMeScores.fromJson(score)).toList(); | ||
} | ||
|
||
//Adds Scores | ||
Future<void> addScores(AskMeScores score) async { | ||
final id = await ScoresModelHelper().create(score.toJson()); | ||
score.id = id; | ||
scores.add(score); | ||
|
||
// Reload files and scores | ||
await loadFiles(); | ||
} | ||
|
||
Future<void> addFile(AskMeFiles file) async { | ||
final id = await FilesModelHelper().create(file.toJson()); | ||
file.id = id; | ||
files.add(file); | ||
await loadFiles(); | ||
} | ||
//Update an existing file | ||
Future<void> updateFile(AskMeFiles file) async { | ||
await FilesModelHelper().update(file.toJson()); | ||
files[files.indexWhere((f) => f.id == file.id)] = file; | ||
|
||
await loadFiles(); | ||
} | ||
|
||
// Delete a file and its associated scores | ||
Future<void> deleteFile(AskMeFiles file) async { | ||
await FilesModelHelper().delete(file.toJson()); | ||
files.remove(file); | ||
|
||
await loadFiles(); | ||
} | ||
} | ||
|
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,31 @@ | ||
import 'package:get/get.dart'; | ||
class QuizSettingsController extends GetxController { | ||
var fileTitle = ''.obs; | ||
var filePath = ''.obs; | ||
var questionType = 'Multiple choice'.obs; | ||
var multipleChoice = true.obs; | ||
var selectedTimer = 2.obs; | ||
var minute = 2.obs; | ||
var seconds = 30.obs; | ||
|
||
void setQuestionType(String type, bool choice) { | ||
questionType.value = type; | ||
multipleChoice.value = choice; | ||
} | ||
|
||
void setFileTitle(String title) { | ||
fileTitle.value = title; | ||
} | ||
void setFilePath(String path) { | ||
filePath.value = path; | ||
} | ||
|
||
void setSelectedTimer(int timer) { | ||
selectedTimer.value = timer; | ||
} | ||
|
||
void setTimer(int min, sec) { | ||
minute.value = min; | ||
seconds.value = sec; | ||
} | ||
} |
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,31 @@ | ||
class AskMeFiles { | ||
int? id; | ||
final String title; | ||
final String filePath; | ||
int avgScore; | ||
|
||
AskMeFiles({ | ||
this.id, | ||
required this.title, | ||
required this.filePath, | ||
required this.avgScore, | ||
}); | ||
|
||
factory AskMeFiles.fromJson(Map<String, dynamic> json) { | ||
return AskMeFiles( | ||
id: json["id"], | ||
title: json["title"], | ||
filePath: json['filePath'], | ||
avgScore: json['avgScore'], | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return { | ||
'id': id, | ||
'title': title, | ||
'filePath': filePath, | ||
'avgScore': avgScore, | ||
}; | ||
} | ||
} |
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,28 @@ | ||
class AskMeScores { | ||
int? id; | ||
final int score; | ||
final int filesId; | ||
|
||
AskMeScores({ | ||
this.id, | ||
required this.score, | ||
required this.filesId, | ||
}); | ||
|
||
|
||
factory AskMeScores.fromJson(Map<String, dynamic> json) { | ||
return AskMeScores( | ||
id: json['id'], | ||
score: json['score'], | ||
filesId: json['filesId'], | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return { | ||
'id': id, | ||
'score': score, | ||
'filesId': filesId, | ||
}; | ||
} | ||
} |
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,54 @@ | ||
import 'package:academia/storage/storage.dart'; | ||
import 'package:sqflite/sqflite.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class FilesModelHelper implements DatabaseOperations { | ||
static final FilesModelHelper _instance = | ||
FilesModelHelper._internal(); | ||
|
||
factory FilesModelHelper() { | ||
return _instance; | ||
} | ||
|
||
FilesModelHelper._internal(); | ||
|
||
@override | ||
Future<int> create(Map<String, dynamic> data) async { | ||
final db = await DatabaseHelper().database; | ||
final id = await db.insert( | ||
'askme_files', | ||
data, | ||
conflictAlgorithm: ConflictAlgorithm.replace, | ||
); | ||
|
||
debugPrint("[+] Files written successfully"); | ||
return id; | ||
} | ||
|
||
@override | ||
Future<List<Map<String, dynamic>>> queryAll() async { | ||
final db = await DatabaseHelper().database; | ||
final files = await db.query('askme_files'); | ||
return files; | ||
} | ||
|
||
@override | ||
Future<int> delete(Map<String, dynamic> data) async { | ||
final db = await DatabaseHelper().database; | ||
return await db | ||
.delete('askme_files', where: 'id =?', whereArgs: [data["id"]]); | ||
} | ||
|
||
@override | ||
Future<int> update(Map<String, dynamic> data) async { | ||
final db = await DatabaseHelper().database; | ||
return await db | ||
.update('askme_files', data, where: 'id =?', whereArgs: [data['id']]); | ||
} | ||
|
||
@override | ||
Future<void> truncate() async { | ||
final db = await DatabaseHelper().database; | ||
await db.execute('DELETE FROM askme_files'); | ||
} | ||
} |
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,48 @@ | ||
class MultipleChoiceQuestion{ | ||
String question; | ||
List<String> choices; | ||
String correctAnswer; | ||
|
||
MultipleChoiceQuestion({ | ||
required this.question, | ||
required this.choices, | ||
required this.correctAnswer, | ||
}); | ||
|
||
factory MultipleChoiceQuestion.fromJson(Map<String, dynamic> json) { | ||
return MultipleChoiceQuestion( | ||
question: json['question'], | ||
choices: List<String>.from(json['multiple_choice']), | ||
correctAnswer: json['correct_answer'], | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return { | ||
'question': question, | ||
'multiple_choice': choices, | ||
'correct_answer': correctAnswer, | ||
}; | ||
} | ||
} | ||
|
||
//Multiple choice Quiz model | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class Question { | ||
final String question; | ||
final String answer; | ||
|
||
const Question({required this.question, required this.answer}); | ||
|
||
factory Question.fromJson(Map<String, dynamic> json) { | ||
return Question( | ||
question: json['question'], | ||
answer: json['answer'], | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return { | ||
'question': question, | ||
'answer': answer | ||
}; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.