Skip to content

Commit

Permalink
feat: student performance features
Browse files Browse the repository at this point in the history
  • Loading branch information
IamMuuo committed Oct 3, 2024
1 parent f099e84 commit 915583f
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 69 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
110 changes: 46 additions & 64 deletions lib/constants/tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@ import 'package:get/get.dart';
import 'package:academia/exports/barrel.dart';

final List<Map<String, dynamic>> allTools = [
{
"id": 8,
"name": "Exam Timetable",
"action": "Show exam timetable",
"image": "assets/images/sketchbook-man-analyzing-business-data.png",
"ontap": () {
Get.to(const ExamTimeTablePage());
},
"description":
"Exams around the corner? Don't panic we've got you covered with the timetable",
},
{
"id": 1,
"name": "GPA Calculator",
Expand All @@ -34,9 +23,8 @@ final List<Map<String, dynamic>> allTools = [
},
"description": "Having trouble tracking your finaces? We're here for you"
},

{
"id": 2,
"id": 3,
"name": "Elearning",
"image": "assets/images/sketchbook-coworkers-discussing-something-1.png",
"action": "Visit Elearning",
Expand All @@ -55,56 +43,19 @@ final List<Map<String, dynamic>> allTools = [
"description":
"Psst! Elearning is here for you. Keep track of your assignments and notes!",
},
// {
// "id": 5,
// "name": "Student Audit",
// "action": "Get my audit",
// "image": "assets/images/view.png",
// "ontap": () async {
// var controller = Get.find<SettingsController>();
// if ((controller.settings.value!.enableAudit ?? false)) {
// showCustomSnackbar(
// "Tool locked",
// "Student Audit functionality is locked in the settings page, please unlock it to view your student audit",
// icon: Icons.lock,
// );
// } else {
// final UserController userController = Get.find<UserController>();
// Get.to(PdfViewer(
// title: "Your audit",
// url:
// "https://student.daystar.ac.ke/Downloads/STDAUDIT-${userController.user.value!.regno}.pdf",
// ));
// }
// },
// "description": "Having trouble finding your audit? Here it is"
// },
// {
// "id": 6,
// "name": "Transcript",
// "action": "Get my transcript",
// "image": "assets/images/graduating.png",
// "ontap": () async {
// var controller = Get.find<SettingsController>();
// if (controller.settings.value!.enableTranscript ?? false) {
// showCustomSnackbar(
// "Tool locked",
// "Transcript functionality is locked in the settings page, please unlock it to view your transcript",
// icon: Icons.lock,
// );
// } else {
// final UserController userController = Get.find<UserController>();
// Get.to(PdfViewer(
// title: "Your Transcript",
// url:
// "https://student.daystar.ac.ke/Downloads/PROVISIONAL%20RESULTS-${userController.user.value!.regno}.pdf",
// ));
// }
// },
// "description": "Need your transcript ASAP? Find it here"
// },
{
"id": 9,
"id": 4,
"name": "Exam Timetable",
"action": "Show exam timetable",
"image": "assets/images/sketchbook-man-analyzing-business-data.png",
"ontap": () {
Get.to(const ExamTimeTablePage());
},
"description":
"Exams around the corner? Don't panic we've got you covered with the timetable",
},
{
"id": 5,
"name": "Task Manager",
"action": "Manage your tasks",
"image": "assets/images/organize.png",
Expand All @@ -115,7 +66,7 @@ final List<Map<String, dynamic>> allTools = [
"Having trouble keeping track of your todos? We've got you covered",
},
{
"id": 10,
"id": 6,
"name": "Anki Flash Cards",
"action": "Lets Up That Grade",
"image":
Expand All @@ -127,7 +78,7 @@ final List<Map<String, dynamic>> allTools = [
"Ready to revolutionize your study habits?\nLet's help you master courses effortlessly",
},
{
"id": 11,
"id": 7,
"name": "Ask Me",
"action": "Study with Ai",
"image":
Expand All @@ -137,5 +88,36 @@ final List<Map<String, dynamic>> allTools = [
},
"description":
"Generate quiz questions from your notes and study materials with our AI tool."
},
{
"id": 8,
"name": "Student Audit",
"action": "Get student Audit",
"image":
"assets/images/sketchbook-school-backpack-with-school-supplies-1.png",
"ontap": () {
Get.to(
const StudentPerformancePage(
parameter: StudentPerfomanceParameter.audit,
),
);
},
"description": "Need your student audit? Get it here"
},
{
"id": 9,
"name": "Transcript",
"action": "Show my transcript",
"image":
"assets/images/sketchbook-young-businesswoman-giving-a-presentation-1.png",
"ontap": () {
Get.to(
const StudentPerformancePage(
parameter: StudentPerfomanceParameter.transcript,
),
);
},
"description":
"Worried of your entire student progression? Fetch your transcript here"
}
];
10 changes: 6 additions & 4 deletions lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ class _SettingsPageState extends State<SettingsPage> {
trailing: Switch(
value: settingsController.settings.value.showAudit,
onChanged: (value) {
settingsController.settings
.update((val) => val?.copyWith(showAudit: value));
settingsController.settings.value = settingsController
.settings.value
.copyWith(showAudit: value);
},
),
),
Expand All @@ -177,8 +178,9 @@ class _SettingsPageState extends State<SettingsPage> {
value:
settingsController.settings.value.showExamTimetable,
onChanged: (value) {
settingsController.settings.update(
(val) => val?.copyWith(showExamTimetable: value));
settingsController.settings.value = settingsController
.settings.value
.copyWith(showExamTimetable: value);
},
),
),
Expand Down
136 changes: 136 additions & 0 deletions lib/tools/student_performance/pages/student_performance_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import 'package:academia/exports/barrel.dart';
import 'package:get/get.dart';
import 'package:http/http.dart' as http;

enum StudentPerfomanceParameter { audit, transcript }

class StudentPerformancePage extends StatefulWidget {
const StudentPerformancePage({
super.key,
required this.parameter,
});
final StudentPerfomanceParameter parameter;

@override
State<StudentPerformancePage> createState() => _StudentPerformancePageState();
}

class _StudentPerformancePageState extends State<StudentPerformancePage> {
final SettingsController _settingsController = Get.find<SettingsController>();
final UserController _userController = Get.find<UserController>();
bool documentLocked = true;
int currentPage = 0, totalPages = 0;
bool isReady = false;
String errorMessage = '';

Future<Uint8List> _loadPdf() async {
try {
setState(() {
isReady = false;
});
final response = await http.get(Uri.parse(widget.parameter ==
StudentPerfomanceParameter.transcript
? "https://student.daystar.ac.ke/Downloads/STDAUDIT-${_userController.user.value!.admissionNumber}.pdf"
: "https://student.daystar.ac.ke/Downloads/PROVISIONAL%20RESULTS-${_userController.user.value!.admissionNumber}.pdf"));
if (response.statusCode != 200) {
throw "Error while fetching content";
}

setState(() {
isReady = true;
});
return response.bodyBytes;
} catch (e) {
setState(() {
errorMessage = e.toString();
});
}
return Uint8List(0);
}

@override
void initState() {
super.initState();

if (_settingsController.settings.value.showAudit &&
widget.parameter == StudentPerfomanceParameter.audit) {
documentLocked = false;
return;
}

if (_settingsController.settings.value.showTranscript &&
widget.parameter == StudentPerfomanceParameter.transcript) {
documentLocked = false;
return;
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
widget.parameter == StudentPerfomanceParameter.audit
? "Student Audit"
: "Student Transcript",
),
),
body: documentLocked
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"The requested document cannot be loaded because the document is locked from the settings page",
style: Theme.of(context).textTheme.headlineSmall,
textAlign: TextAlign.center,
),
],
)
: FutureBuilder(
future: _loadPdf(),
builder: (context, snapshot) {
return snapshot.hasData
? snapshot.hasError
? Center(
child: Column(
children: [
Image.asset("assets/images/bot_sad.png"),
Text(
snapshot.error.toString(),
),
],
),
)
: Stack(
children: [
PDFView(
fitPolicy: FitPolicy.BOTH,
pdfData: snapshot.data,
pageFling: true,
defaultPage: currentPage,
onPageChanged: (page, total) {
setState(() {
currentPage = page!;
});
},
onRender: (pages) {
setState(() {});
},
onError: (error) {
debugPrint("Error");
},
),
],
)
: const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Loading .."),
],
),
);
}),
);
}
}
1 change: 1 addition & 0 deletions lib/tools/student_performance/student_performance.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'pages/student_performance_page.dart';
2 changes: 1 addition & 1 deletion lib/tools/tools.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export 'leaderboard/leaderboard.dart';
export 'anki/anki.dart';
// export 'stories/stories.dart';
export 'student_performance/student_performance.dart';
export 'events/events.dart';
export 'fees/fees.dart';
export 'gpa_calculator/gpacalculator.dart';
Expand Down

0 comments on commit 915583f

Please sign in to comment.