From 1505674033beac7ab77dc5a54cdda87def08d9ea Mon Sep 17 00:00:00 2001 From: Arindam Upadhyay <20bec018@iiitdmj.ac.in> Date: Mon, 27 Mar 2023 13:11:13 +0530 Subject: [PATCH 1/5] script structured --- clone.sh | 13 ------------- scripts/clone.sh | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 clone.sh create mode 100644 scripts/clone.sh diff --git a/clone.sh b/clone.sh deleted file mode 100644 index 3a3780c4..00000000 --- a/clone.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -#branches=("ac-1" "ac-2" "ac-3" "ac-4" "ac-5" "ps-1" "ps-2" "gad-1" "gad-2" "gad-3" "gad-4" "gad-5" "hr" "sa-1" "sa-2" "sa-3" "sa-4" "os-1" "os-2" "os-3" "os-4" "rspc") -branches=("ac") -for branch in "${branches[@]}" -do - echo "Creating $branch" - - git checkout -b "$branch" - git push origin "$branch" - - echo "Pushed new branch $branch to remote" -done \ No newline at end of file diff --git a/scripts/clone.sh b/scripts/clone.sh new file mode 100644 index 00000000..20bf0276 --- /dev/null +++ b/scripts/clone.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +branches=("ac" "ac-1" "ac-2" "ac-3" "ac-4" "ac-5" "ps-1" "ps-2" "gad-1" "gad-2" "gad-3" "gad-4" "gad-5" "hr" "sa-1" "sa-2" "sa-3" "sa-4" "os-1" "os-2" "os-3" "os-4" "rspc") + +for branch in "${branches[@]}" +do + echo "Creating $branch..." + + git checkout -b "$branch" + git push origin "$branch" + + echo "Pushed new branch $branch to remote" +done \ No newline at end of file From aa2e5791c9de58bf6f19f7220e74d8c2306c14d5 Mon Sep 17 00:00:00 2001 From: AgPriyanshu18 Date: Fri, 17 Nov 2023 17:02:40 +0530 Subject: [PATCH 2/5] Server Url updated --- android/build.gradle | 4 ++-- android/gradle/wrapper/gradle-wrapper.properties | 2 +- lib/api.dart | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index b3a325d5..a78be8cb 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.8.21' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.2.2' + classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index cc5527d7..6b665338 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/lib/api.dart b/lib/api.dart index 802bee2d..73d1c6bc 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -1,10 +1,11 @@ //Server and local links String klocalLink = "127.0.0.1:8000"; -String kserverLink = "172.27.16.215:80"; +String kserverLink = "172.27.16.214:8000"; //Login Service -String kAuthUrl = "172.27.16.215:80"; +String kAuthUrl = "172.27.16.214:8000"; String kAuthLogin = "/api/auth/login/"; +// String kAuthLogin = "/accounts/login"; //Profile Service String kProfile = "/api/profile/"; From 13a2f779f2bb49000d3e52fc13068c7fde55211d Mon Sep 17 00:00:00 2001 From: Adi-Gupta018 Date: Tue, 20 Feb 2024 11:55:51 +0530 Subject: [PATCH 3/5] added module ac-3 --- lib/Components/side_drawer.dart | 11 + lib/main.dart | 27 +- .../Registration/final_registration.dart | 4 +- .../ComplaintHistory/update_complaint.dart | 4 +- lib/screens/Complaint/complaint.dart | 3 - .../announcements/announcement.dart | 221 +++++++++ .../Instructor/content/course_contentIns.dart | 221 +++++++++ .../Instructor/evaluation/assignments.dart | 187 +++++++ .../Instructor/evaluation/grading_scheme.dart | 0 .../Instructor/evaluation/submissions.dart | 0 .../evaluation/upload_assignment.dart | 187 +++++++ .../Courses/Registered_Courses_Home.dart | 201 ++++++++ .../Students/announcements/announcements.dart | 186 +++++++ .../Students/assignments/assignments.dart | 187 +++++++ .../assignments/upload_assignment.dart | 456 ++++++++++++++++++ .../course_content/course_content.dart | 187 +++++++ .../Courses/Students/progress/progress.dart | 170 +++++++ lib/screens/Courses/course_home.dart | 182 +++++++ lib/screens/Gymkhana/Record.dart | 8 +- lib/screens/LoginandDashboard/dashboard.dart | 4 +- pubspec.yaml | 1 + 21 files changed, 2431 insertions(+), 16 deletions(-) create mode 100644 lib/screens/Courses/Instructor/announcements/announcement.dart create mode 100644 lib/screens/Courses/Instructor/content/course_contentIns.dart create mode 100644 lib/screens/Courses/Instructor/evaluation/assignments.dart create mode 100644 lib/screens/Courses/Instructor/evaluation/grading_scheme.dart create mode 100644 lib/screens/Courses/Instructor/evaluation/submissions.dart create mode 100644 lib/screens/Courses/Instructor/evaluation/upload_assignment.dart create mode 100644 lib/screens/Courses/Registered_Courses_Home.dart create mode 100644 lib/screens/Courses/Students/announcements/announcements.dart create mode 100644 lib/screens/Courses/Students/assignments/assignments.dart create mode 100644 lib/screens/Courses/Students/assignments/upload_assignment.dart create mode 100644 lib/screens/Courses/Students/course_content/course_content.dart create mode 100644 lib/screens/Courses/Students/progress/progress.dart create mode 100644 lib/screens/Courses/course_home.dart diff --git a/lib/Components/side_drawer.dart b/lib/Components/side_drawer.dart index be08db0e..bae18c05 100644 --- a/lib/Components/side_drawer.dart +++ b/lib/Components/side_drawer.dart @@ -13,6 +13,7 @@ class _SideDrawerState extends State { int count = 0; String? name; String? depttype; + String? userType; @override void initState() { super.initState(); @@ -23,6 +24,10 @@ class _SideDrawerState extends State { depttype = service.profileData.profile!['department']!['name'] + " " + service.profileData.profile!['user_type']; + userType = service.profileData.profile!['user_type']; + print(name); + print(depttype); + print(userType); } @override @@ -121,6 +126,12 @@ class _SideDrawerState extends State { pageMover: '/programme_curriculum_home', isActive: true, ), + // if (userType == '') + ModulesPadding( + line: "Courses Module", + pageMover: '/registered_courses', + isActive: true, + ), ModulesPadding( line: 'Gymkhana Module', pageMover: '/gymkhana_homepage'), diff --git a/lib/main.dart b/lib/main.dart index 9ca81ff8..ab083dd1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -42,6 +42,14 @@ import 'package:fusion/screens/Healthcenter/viewschedule.dart'; import 'package:fusion/screens/Healthcenter/history.dart'; import 'package:fusion/screens/Healthcenter/HealthCenter.dart'; import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/screens/Courses/Registered_Courses_Home.dart'; +import 'package:fusion/screens/Courses/course_home.dart'; +import 'package:fusion/screens/Courses/Students/progress/progress.dart'; +import 'package:fusion/screens/Courses/Students/course_content/course_content.dart'; +import 'package:fusion/screens/Courses/Students/announcements/announcements.dart'; +import 'package:fusion/screens/Courses/Students/assignments/assignments.dart'; +import 'package:fusion/screens/Courses/Instructor/content/course_contentIns.dart'; +import 'package:fusion/screens/Courses/Students/assignments/upload_assignment.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); @@ -60,7 +68,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { MediaQueryData windowData = - MediaQueryData.fromWindow(WidgetsBinding.instance.window); + MediaQueryData.fromWindow(WidgetsBinding.instance.window); windowData = windowData.copyWith( textScaleFactor: 1, ); @@ -71,10 +79,10 @@ class MyApp extends StatelessWidget { title: 'Fusion', debugShowCheckedModeBanner: false, theme: ThemeData( - // primarySwatch: Colors.blueGrey, + // primarySwatch: Colors.blueGrey, // colorSchemeSeed: Color(0xFF2085D0), colorSchemeSeed: Color(0xFFF36C35), - fontFamily: 'Nunito', + fontFamily: 'Nunito', useMaterial3: true, ), initialRoute: '/landing', @@ -127,6 +135,19 @@ class MyApp extends StatelessWidget { '/health_center/feedback': (context) => FeedBack(), '/health_center/viewschedule': (context) => ViewSchedule(), '/health_center/history': (context) => History(), + '/registered_courses': (context) => RegisteredCoursesHome(), + '/registered_courses/course_home': (context) => CourseHome(), + '/registered_courses/course_home/progress': (context) => Progress(), + '/registered_courses/course_home/course_content': (context) => + CourseContent(), + '/registered_courses/course_home/announcement': (context) => + Announcement(), + '/registered_courses/course_home/assignment': (context) => + Assignment(), + '/registered_courses/instructor/course_home/course_content': + (context) => CourseContentIns(), + '/registered_courses/course_home/assignment/upload_assignment': + (context) => uploadAssignment(), }, ), ); diff --git a/lib/screens/Academic/Registration/final_registration.dart b/lib/screens/Academic/Registration/final_registration.dart index 4ca4b245..12e958cd 100644 --- a/lib/screens/Academic/Registration/final_registration.dart +++ b/lib/screens/Academic/Registration/final_registration.dart @@ -32,7 +32,7 @@ class _FinalRegistrationState extends State { children: [ SizedBox(height: 10), Text("Final Choices Of Courses"), - if (finalData != null && finalData[0].length > 0) + if (finalData?[0].length > 0) SingleChildScrollView( scrollDirection: Axis.vertical, child: SingleChildScrollView( @@ -61,7 +61,7 @@ class _FinalRegistrationState extends State { ], rows: getRows(finalData)), ), ), - if (finalData == null || finalData[0].length == 0) + if (finalData?[0].length == 0) Expanded( child: Center( child: Text( diff --git a/lib/screens/Complaint/ComplaintHistory/update_complaint.dart b/lib/screens/Complaint/ComplaintHistory/update_complaint.dart index 8ea7af87..917de43c 100644 --- a/lib/screens/Complaint/ComplaintHistory/update_complaint.dart +++ b/lib/screens/Complaint/ComplaintHistory/update_complaint.dart @@ -172,8 +172,8 @@ class _UpdateComplaintState extends State { widget.id!, complaint_date, finishedDate, - complaint_type!, - location!, + complaint_type, + location, specific_location!, details!, status, diff --git a/lib/screens/Complaint/complaint.dart b/lib/screens/Complaint/complaint.dart index f1b5ed77..a7fc09ed 100644 --- a/lib/screens/Complaint/complaint.dart +++ b/lib/screens/Complaint/complaint.dart @@ -4,12 +4,9 @@ import 'package:fusion/Components/appBar.dart'; import 'package:fusion/models/profile.dart'; import 'package:fusion/services/profile_service.dart'; import 'package:http/http.dart'; -import 'ComplaintHistory/complain_history.dart'; import 'package:flutter/material.dart'; import 'package:fusion/Components/side_drawer.dart'; import 'dart:ui'; -import 'LodgeComplaint/lodge_complaint.dart'; -import 'Feedback/feedback.dart'; import 'package:provider/provider.dart'; class Complaint extends StatefulWidget { diff --git a/lib/screens/Courses/Instructor/announcements/announcement.dart b/lib/screens/Courses/Instructor/announcements/announcement.dart new file mode 100644 index 00000000..5e5530d1 --- /dev/null +++ b/lib/screens/Courses/Instructor/announcements/announcement.dart @@ -0,0 +1,221 @@ +import 'dart:async'; +import 'dart:convert'; +import 'package:fusion/models/profile.dart'; +import 'package:fusion/services/profile_service.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/models/dashboard.dart'; +import 'package:fusion/screens/LoginandDashboard/DashboardComponents/cardItems.dart'; +import 'package:fusion/services/dashboard_service.dart'; +import 'package:http/http.dart'; + +class Announcement extends StatefulWidget { + @override + _AnnouncementState createState() => _AnnouncementState(); +} + +class _AnnouncementState extends State { + bool _loading = true; + late String name; + late String studentType; + // Stream Controller for API + late StreamController _dashboardController; + late DashboardService dashboardService; + late DashboardData data; + late StreamController _profileController; + late ProfileService profileService; + late ProfileData data2; + @override + void initState() { + super.initState(); + _dashboardController = StreamController(); + dashboardService = DashboardService(); + _profileController = StreamController(); + profileService = ProfileService(); + getData(); + } + + getData() async { + try { + Response response = await dashboardService.getDashboard(); + Response response2 = await profileService.getProfile(); + setState(() { + data = DashboardData.fromJson(jsonDecode(response.body)); + data2 = ProfileData.fromJson(jsonDecode(response2.body)); + _loading = false; + }); + name = data2.user!['first_name'] + ' ' + data2.user!['last_name']; + studentType = data2.profile!['department']!['name'] + + ' ' + + data2.profile!['user_type']; + } catch (e) { + print(e); + } + } + + loadData() async { + getData().then((res) { + _dashboardController.add(res); + _profileController.add(res); + }); + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + studentType, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Announments", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Announcement 1"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Announcement 2"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Announcement 3"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Assignments"), + // onTap: () { + // Navigator.pushNamed( + // context, '/registered_courses/course_home/assignment', + // arguments: data); + // }, + // ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Instructor/content/course_contentIns.dart b/lib/screens/Courses/Instructor/content/course_contentIns.dart new file mode 100644 index 00000000..16e0fc11 --- /dev/null +++ b/lib/screens/Courses/Instructor/content/course_contentIns.dart @@ -0,0 +1,221 @@ +import 'dart:async'; +import 'dart:convert'; +import 'package:fusion/models/profile.dart'; +import 'package:fusion/services/profile_service.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/models/dashboard.dart'; +import 'package:fusion/screens/LoginandDashboard/DashboardComponents/cardItems.dart'; +import 'package:fusion/services/dashboard_service.dart'; +import 'package:http/http.dart'; + +class CourseContentIns extends StatefulWidget { + @override + _CourseContentInsState createState() => _CourseContentInsState(); +} + +class _CourseContentInsState extends State { + bool _loading = true; + late String name; + late String studentType; + // Stream Controller for API + late StreamController _dashboardController; + late DashboardService dashboardService; + late DashboardData data; + late StreamController _profileController; + late ProfileService profileService; + late ProfileData data2; + @override + void initState() { + super.initState(); + _dashboardController = StreamController(); + dashboardService = DashboardService(); + _profileController = StreamController(); + profileService = ProfileService(); + getData(); + } + + getData() async { + try { + Response response = await dashboardService.getDashboard(); + Response response2 = await profileService.getProfile(); + setState(() { + data = DashboardData.fromJson(jsonDecode(response.body)); + data2 = ProfileData.fromJson(jsonDecode(response2.body)); + _loading = false; + }); + name = data2.user!['first_name'] + ' ' + data2.user!['last_name']; + studentType = data2.profile!['department']!['name'] + + ' ' + + data2.profile!['user_type']; + } catch (e) { + print(e); + } + } + + loadData() async { + getData().then((res) { + _dashboardController.add(res); + _profileController.add(res); + }); + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + studentType, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Course-Code", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Module 1"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/instructor/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Module 2"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Upload"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Assignments"), + // onTap: () { + // Navigator.pushNamed( + // context, '/registered_courses/course_home/assignment', + // arguments: data); + // }, + // ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Instructor/evaluation/assignments.dart b/lib/screens/Courses/Instructor/evaluation/assignments.dart new file mode 100644 index 00000000..ef4bc14c --- /dev/null +++ b/lib/screens/Courses/Instructor/evaluation/assignments.dart @@ -0,0 +1,187 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Assignment extends StatefulWidget { + @override + _AssignmentState createState() => _AssignmentState(); +} + +class _AssignmentState extends State { + bool _loading = true; + // Stream Controller for API + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Assignments", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Assignment 1"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/upload_assignment', + arguments: data); + }, + ), + InkWell( + child: myContainer("Assignment 2"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Assignment 3"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Assignments"), + // onTap: () { + // Navigator.pushNamed( + // context, '/registered_courses/course_home/assignment', + // arguments: data); + // }, + // ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Instructor/evaluation/grading_scheme.dart b/lib/screens/Courses/Instructor/evaluation/grading_scheme.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/screens/Courses/Instructor/evaluation/submissions.dart b/lib/screens/Courses/Instructor/evaluation/submissions.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/screens/Courses/Instructor/evaluation/upload_assignment.dart b/lib/screens/Courses/Instructor/evaluation/upload_assignment.dart new file mode 100644 index 00000000..919ee8f3 --- /dev/null +++ b/lib/screens/Courses/Instructor/evaluation/upload_assignment.dart @@ -0,0 +1,187 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Assignment extends StatefulWidget { + @override + _AssignmentState createState() => _AssignmentState(); +} + +class _AssignmentState extends State { + bool _loading = true; + // Stream Controller for API + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Assignments", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Assignment 1"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Assignment 2"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Assignment 3"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Assignments"), + // onTap: () { + // Navigator.pushNamed( + // context, '/registered_courses/course_home/assignment', + // arguments: data); + // }, + // ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Registered_Courses_Home.dart b/lib/screens/Courses/Registered_Courses_Home.dart new file mode 100644 index 00000000..866c6d40 --- /dev/null +++ b/lib/screens/Courses/Registered_Courses_Home.dart @@ -0,0 +1,201 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class RegisteredCoursesHome extends StatefulWidget { + @override + _RegisteredCoursesHomeState createState() => _RegisteredCoursesHomeState(); +} + +class _RegisteredCoursesHomeState extends State { + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Courses", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Course1"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home', + arguments: data); + }, + ), + InkWell( + child: myContainer("Course2"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home', + arguments: data); + }, + ), + InkWell( + child: myContainer("Course3"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Course4"), + // onTap: () { + // Navigator.pushNamed(context, '/_home/course_content', + // arguments: data); + // // Navigator.pushNamed( + // // context, '/academic_home_page/bonafide', + // // arguments: { + // // 'firstName': data.details!['current_user'] + // // ['first_name'] + // // .toString(), + // // 'lastName': data.details!['current_user'] + // // ['last_name'], + // // 'branch': data.details!['user_branch'] + // // }); + // }, + // ), + // InkWell( + // child: myContainer("Batches"), + // onTap: () { + // Navigator.pushNamed(context, '/registered_courses/batches', + // arguments: data); + // }, + // ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Students/announcements/announcements.dart b/lib/screens/Courses/Students/announcements/announcements.dart new file mode 100644 index 00000000..b6dd60b2 --- /dev/null +++ b/lib/screens/Courses/Students/announcements/announcements.dart @@ -0,0 +1,186 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Announcement extends StatefulWidget { + @override + _AnnouncementState createState() => _AnnouncementState(); +} + +class _AnnouncementState extends State { + bool _loading = true; + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Announments", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Upload Assignment by 12pm today"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("No class on 12/3/2024"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("marks chahiyeu to kaam karo"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Assignments"), + // onTap: () { + // Navigator.pushNamed( + // context, '/registered_courses/course_home/assignment', + // arguments: data); + // }, + // ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Students/assignments/assignments.dart b/lib/screens/Courses/Students/assignments/assignments.dart new file mode 100644 index 00000000..f2cd9d39 --- /dev/null +++ b/lib/screens/Courses/Students/assignments/assignments.dart @@ -0,0 +1,187 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Assignment extends StatefulWidget { + @override + _AssignmentState createState() => _AssignmentState(); +} + +class _AssignmentState extends State { + bool _loading = true; + // Stream Controller for API + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Assignments", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Assignment 1"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/assignment/upload_assignment', + arguments: data); + }, + ), + InkWell( + child: myContainer("Assignment 2"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Assignment 3"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Assignments"), + // onTap: () { + // Navigator.pushNamed( + // context, '/registered_courses/course_home/assignment', + // arguments: data); + // }, + // ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Students/assignments/upload_assignment.dart b/lib/screens/Courses/Students/assignments/upload_assignment.dart new file mode 100644 index 00000000..12ba5418 --- /dev/null +++ b/lib/screens/Courses/Students/assignments/upload_assignment.dart @@ -0,0 +1,456 @@ +// import 'dart:convert'; + +// import 'package:flutter/material.dart'; +// import 'package:fusion/services/login_service.dart'; +// import 'package:fusion/services/service_locator.dart'; +// import 'package:fusion/services/storage_service.dart'; +// import 'package:flutter/material.dart'; +// import 'package:fusion/Components/appBar.dart'; +// import 'package:fusion/Components/side_drawer.dart'; + +// class uploadAssignment extends StatefulWidget { +// @override +// _uploadAssignmentState createState() => _uploadAssignmentState(); +// } + +// class _uploadAssignmentState extends State { +// bool _loading = true; +// late String name; +// late String depttype; + +// final _formKey = GlobalKey(); +// late TextEditingController _assignmentNameController; + +// @override +// void initState() { +// super.initState(); +// var service = locator(); +// name = service.profileData.user!["first_name"] + +// " " + +// service.profileData.user!["last_name"]; +// depttype = service.profileData.profile!['department']!['name'] + +// " " + +// service.profileData.profile!['user_type']; +// _assignmentNameController = TextEditingController(); +// } + +// @override +// void dispose() { +// _assignmentNameController.dispose(); +// super.dispose(); +// } + +// BoxDecoration myBoxDecoration() { +// return BoxDecoration( +// border: Border.all( +// color: Colors.deepOrangeAccent, +// width: 2.0, +// style: BorderStyle.solid, +// ), +// borderRadius: BorderRadius.all( +// Radius.circular(15.0), +// ), +// ); +// } + +// Text myText(String text) { +// return Text( +// text, +// style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), +// ); +// } + +// Padding myContainer(String text) { +// return Padding( +// padding: const EdgeInsets.all(8.0), +// child: Container( +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: myText(text), +// ), +// decoration: myBoxDecoration(), +// ), +// ); +// } + +// void _submitForm() { +// if (_formKey.currentState!.validate()) { +// // Form is validated, proceed to convert form data to JSON +// Map formData = { +// 'assignmentName': _assignmentNameController.text, +// // Add more fields if needed +// }; +// String jsonData = jsonEncode(formData); +// print(jsonData); // Print or use the JSON data as needed +// } +// } + +// @override +// Widget build(BuildContext context) { +// final data = ''; +// return Scaffold( +// appBar: DefaultAppBar().buildAppBar(), +// drawer: SideDrawer(), +// body: ListView( +// shrinkWrap: true, +// physics: ClampingScrollPhysics(), +// children: [ +// Card( +// elevation: 2.0, +// margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), +// shadowColor: Colors.black, +// child: Column( +// children: [ +// Container( +// margin: EdgeInsets.only(top: 20.0), +// width: 170.0, +// height: 170.0, +// decoration: BoxDecoration( +// image: DecorationImage( +// image: AssetImage('assets/unknown.jpg'), +// fit: BoxFit.cover, +// ), +// ), +// ), +// SizedBox( +// height: 10.0, +// ), +// Text( +// name, +// style: TextStyle(fontSize: 20.0, color: Colors.black), +// ), +// SizedBox( +// height: 10.0, +// ), +// Text( +// depttype, +// ), +// SizedBox( +// height: 10.0, +// ), +// ], +// ), +// ), +// Padding( +// padding: const EdgeInsets.all(8.0), +// child: Container( +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: Center( +// child: Text( +// "Assignments", +// style: TextStyle( +// fontSize: 20.0, +// color: Colors.white, +// ), +// ), +// ), +// ), +// decoration: BoxDecoration( +// color: Colors.deepOrangeAccent, +// boxShadow: [ +// BoxShadow( +// color: Colors.black, +// offset: Offset(0.0, 1.0), +// blurRadius: 2.0, +// ) +// ], +// borderRadius: BorderRadius.all( +// Radius.circular(5.0), +// ), +// ), +// ), +// ), +// Card( +// elevation: 2.0, +// margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), +// shadowColor: Colors.black, +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.stretch, +// children: [ +// // InkWell( +// // child: myContainer("Assignment 1"), +// // onTap: () { +// // Navigator.pushNamed( +// // context, +// // '/registered_courses/course_home/module', +// // arguments: data, +// // ); +// // }, +// // ), +// // InkWell( +// // child: myContainer("Assignment 2"), +// // onTap: () { +// // Navigator.pushNamed( +// // context, +// // '/registered_courses/course_home/module', +// // arguments: data, +// // ); +// // }, +// // ), +// // InkWell( +// // child: myContainer("Assignment 3"), +// // onTap: () { +// // Navigator.pushNamed( +// // context, +// // '/registered_courses/course_home/module', +// // arguments: data, +// // ); +// // }, +// // ), +// Form( +// key: _formKey, +// child: Column( +// children: [ +// TextFormField( +// controller: _assignmentNameController, +// decoration: InputDecoration( +// labelText: 'Assignment Name', +// border: OutlineInputBorder(), +// ), +// validator: (value) { +// if (value == null || value.isEmpty) { +// return 'Please enter assignment name'; +// } +// return null; +// }, +// ), +// SizedBox(height: 10), +// ElevatedButton( +// onPressed: _submitForm, +// child: Text('Submit'), +// ), +// ], +// ), +// ), +// ], +// ), +// ), +// ], +// ), +// ); +// } +// } +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:file_picker/file_picker.dart'; + +class uploadAssignment extends StatefulWidget { + @override + _uploadAssignmentState createState() => _uploadAssignmentState(); +} + +class _uploadAssignmentState extends State { + bool _loading = true; + late String name; + late String depttype; + + final _formKey = GlobalKey(); + late TextEditingController _assignmentNameController; + String? _filePath; + + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + _assignmentNameController = TextEditingController(); + } + + @override + void dispose() { + _assignmentNameController.dispose(); + super.dispose(); + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: BorderRadius.all( + Radius.circular(15.0), + ), + ); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + void _submitForm() { + if (_formKey.currentState!.validate()) { + // Form is validated, proceed to convert form data to JSON + Map formData = { + 'assignmentName': _assignmentNameController.text, + 'filePath': _filePath, + }; + String jsonData = jsonEncode(formData); + print(jsonData); // Print or use the JSON data as needed + } + } + + Future _pickFile() async { + FilePickerResult? result = await FilePicker.platform.pickFiles( + type: FileType.custom, + allowedExtensions: ['pdf'], + ); + + if (result != null) { + setState(() { + _filePath = result.files.single.path; + }); + } + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + name, + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Assignments", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + ), + ), + ), + decoration: BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: BorderRadius.all( + Radius.circular(5.0), + ), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Form( + key: _formKey, + child: Column( + children: [ + TextFormField( + controller: _assignmentNameController, + decoration: InputDecoration( + labelText: 'Assignment Name', + border: OutlineInputBorder(), + ), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter assignment name'; + } + return null; + }, + ), + SizedBox(height: 10), + ElevatedButton( + onPressed: _pickFile, + child: Text('Select PDF File'), + ), + SizedBox(height: 10), + ElevatedButton( + onPressed: _submitForm, + child: Text('Submit'), + ), + ], + ), + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Students/course_content/course_content.dart b/lib/screens/Courses/Students/course_content/course_content.dart new file mode 100644 index 00000000..724ee535 --- /dev/null +++ b/lib/screens/Courses/Students/course_content/course_content.dart @@ -0,0 +1,187 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class CourseContent extends StatefulWidget { + @override + _CourseContentState createState() => _CourseContentState(); +} + +class _CourseContentState extends State { + bool _loading = true; + // Stream Controller for API + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Course-Code", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Module 1"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Module 2"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Module 3"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Assignments"), + // onTap: () { + // Navigator.pushNamed( + // context, '/registered_courses/course_home/assignment', + // arguments: data); + // }, + // ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Students/progress/progress.dart b/lib/screens/Courses/Students/progress/progress.dart new file mode 100644 index 00000000..44554033 --- /dev/null +++ b/lib/screens/Courses/Students/progress/progress.dart @@ -0,0 +1,170 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Progress extends StatefulWidget { + @override + _ProgressState createState() => _ProgressState(); +} + +class _ProgressState extends State { + bool _loading = true; + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Course-Code", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Attendance -> 9/10"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/progress', + arguments: data); + }, + ), + InkWell( + child: myContainer("marks"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/progess', + arguments: data); + }, + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/course_home.dart b/lib/screens/Courses/course_home.dart new file mode 100644 index 00000000..54b54b41 --- /dev/null +++ b/lib/screens/Courses/course_home.dart @@ -0,0 +1,182 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class CourseHome extends StatefulWidget { + @override + _CourseHomeState createState() => _CourseHomeState(); +} + +class _CourseHomeState extends State { + bool _loading = true; + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Course-Code", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Course_content"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/course_content', + arguments: data); + }, + ), + InkWell( + child: myContainer("progress"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/progress', + arguments: data); + }, + ), + InkWell( + child: myContainer("Announcements"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/announcement', + arguments: data); + }, + ), + InkWell( + child: myContainer("Assignments"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/assignment', + arguments: data); + }, + ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Gymkhana/Record.dart b/lib/screens/Gymkhana/Record.dart index adcfacf2..0a5f8f05 100644 --- a/lib/screens/Gymkhana/Record.dart +++ b/lib/screens/Gymkhana/Record.dart @@ -123,10 +123,10 @@ class Srecord { late String Category; Srecord( - {this.Name: "default-name", - this.Rollno: "000000", - this.Club: "default-club", - this.Category: "default-category"}); + {this.Name = "default-name", + this.Rollno = "000000", + this.Club = "default-club", + this.Category = "default-category"}); } var Srecords = [ diff --git a/lib/screens/LoginandDashboard/dashboard.dart b/lib/screens/LoginandDashboard/dashboard.dart index 80c2719f..d19ce47f 100644 --- a/lib/screens/LoginandDashboard/dashboard.dart +++ b/lib/screens/LoginandDashboard/dashboard.dart @@ -16,10 +16,10 @@ class Dashboard extends StatefulWidget { static String tag = 'home-page'; Dashboard(); @override - _DashboardState createState() => _DashboardState(); + DashboardState createState() => DashboardState(); } -class _DashboardState extends State { +class DashboardState extends State { bool _notificationsBool = true; bool _newsBool = false; bool _announcementsBool = false; diff --git a/pubspec.yaml b/pubspec.yaml index 49030f0b..8645fe85 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,6 +39,7 @@ dependencies: path_provider: ^2.0.8 open_file: ^3.2.1 flutter_html: ^2.2.1 + file_picker: ^5.2.10 From ac3c46a104958a014275a0fe994c0b5c2f748606 Mon Sep 17 00:00:00 2001 From: Adi-Gupta018 Date: Tue, 16 Apr 2024 13:26:27 +0530 Subject: [PATCH 4/5] Added views and api --- android/build.gradle | 2 +- lib/Components/side_drawer.dart | 15 + lib/main.dart | 46 +- .../ComplaintHistory/update_complaint.dart | 4 +- lib/screens/Complaint/complaint.dart | 3 - .../Acad_admin/academic_admin_homepage.dart | 191 ++++++++ lib/screens/Courses/Acad_admin/calender.dart | 155 ++++++ .../Courses/Acad_admin/timetablepage.dart | 156 ++++++ .../Announcements/Announcement.dart | 221 +++++++++ .../Instructor/content/course_contentIns.dart | 221 +++++++++ .../Instructor/evaluation/assignments.dart | 187 +++++++ .../Instructor/evaluation/evaluation.dart | 178 +++++++ .../Instructor/evaluation/grading_scheme.dart | 161 +++++++ .../Instructor/evaluation/submissions.dart | 161 +++++++ .../evaluation/upload_assignment.dart | 187 +++++++ .../Courses/Registered_Courses_Home.dart | 454 +++++++++++++++++ .../Students/announcements/announcements.dart | 186 +++++++ .../Students/assignments/assignments.dart | 187 +++++++ .../assignments/upload_assignment.dart | 456 ++++++++++++++++++ .../course_content/course_content.dart | 187 +++++++ .../Courses/Students/progress/progress.dart | 170 +++++++ lib/screens/Courses/course_home.dart | 220 +++++++++ lib/screens/Gymkhana/Record.dart | 8 +- lib/screens/LoginandDashboard/login_page.dart | 39 +- lib/services/dashboard_service.dart | 1 + lib/services/login_service.dart | 3 +- pubspec.yaml | 1 + 27 files changed, 3771 insertions(+), 29 deletions(-) create mode 100644 lib/screens/Courses/Acad_admin/academic_admin_homepage.dart create mode 100644 lib/screens/Courses/Acad_admin/calender.dart create mode 100644 lib/screens/Courses/Acad_admin/timetablepage.dart create mode 100644 lib/screens/Courses/Instructor/Announcements/Announcement.dart create mode 100644 lib/screens/Courses/Instructor/content/course_contentIns.dart create mode 100644 lib/screens/Courses/Instructor/evaluation/assignments.dart create mode 100644 lib/screens/Courses/Instructor/evaluation/evaluation.dart create mode 100644 lib/screens/Courses/Instructor/evaluation/grading_scheme.dart create mode 100644 lib/screens/Courses/Instructor/evaluation/submissions.dart create mode 100644 lib/screens/Courses/Instructor/evaluation/upload_assignment.dart create mode 100644 lib/screens/Courses/Registered_Courses_Home.dart create mode 100644 lib/screens/Courses/Students/announcements/announcements.dart create mode 100644 lib/screens/Courses/Students/assignments/assignments.dart create mode 100644 lib/screens/Courses/Students/assignments/upload_assignment.dart create mode 100644 lib/screens/Courses/Students/course_content/course_content.dart create mode 100644 lib/screens/Courses/Students/progress/progress.dart create mode 100644 lib/screens/Courses/course_home.dart diff --git a/android/build.gradle b/android/build.gradle index a78be8cb..881e7e55 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/lib/Components/side_drawer.dart b/lib/Components/side_drawer.dart index be08db0e..dd0436be 100644 --- a/lib/Components/side_drawer.dart +++ b/lib/Components/side_drawer.dart @@ -13,6 +13,7 @@ class _SideDrawerState extends State { int count = 0; String? name; String? depttype; + late String userType; @override void initState() { super.initState(); @@ -23,6 +24,10 @@ class _SideDrawerState extends State { depttype = service.profileData.profile!['department']!['name'] + " " + service.profileData.profile!['user_type']; + userType = service.profileData.profile!['user_type']; + print(name); + print(depttype); + print("usertype$userType"); } @override @@ -121,6 +126,16 @@ class _SideDrawerState extends State { pageMover: '/programme_curriculum_home', isActive: true, ), + userType.toLowerCase().contains('staff')? + ModulesPadding( + line: "Timetable & Calender", + pageMover: '/acad_admin/academic_admin_homepage', + isActive: true, + ):ModulesPadding( + line: "Courses Module", + pageMover: '/registered_courses', + isActive: true, + ), ModulesPadding( line: 'Gymkhana Module', pageMover: '/gymkhana_homepage'), diff --git a/lib/main.dart b/lib/main.dart index 9ca81ff8..abedb28c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -42,6 +42,21 @@ import 'package:fusion/screens/Healthcenter/viewschedule.dart'; import 'package:fusion/screens/Healthcenter/history.dart'; import 'package:fusion/screens/Healthcenter/HealthCenter.dart'; import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/screens/Courses/Registered_Courses_Home.dart'; +import 'package:fusion/screens/Courses/course_home.dart'; +import 'package:fusion/screens/Courses/Students/progress/progress.dart'; +import 'package:fusion/screens/Courses/Students/course_content/course_content.dart'; +import 'package:fusion/screens/Courses/Students/announcements/announcements.dart'; +import 'package:fusion/screens/Courses/Students/assignments/assignments.dart'; +import 'package:fusion/screens/Courses/Instructor/content/course_contentIns.dart'; +import 'package:fusion/screens/Courses/Students/assignments/upload_assignment.dart'; +import 'package:fusion/screens/Courses/Instructor/Announcements/Announcement.dart'; +import 'package:fusion/screens/Courses/Acad_admin/academic_admin_homepage.dart'; +import 'package:fusion/screens/Courses/Acad_admin/calender.dart'; +import 'package:fusion/screens/Courses/Acad_admin/timetablepage.dart'; +import 'package:fusion/screens/Courses/Instructor/evaluation/evaluation.dart'; +import 'package:fusion/screens/Courses/Instructor/evaluation/grading_scheme.dart'; +import 'package:fusion/screens/Courses/Instructor/evaluation/submissions.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); @@ -60,7 +75,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { MediaQueryData windowData = - MediaQueryData.fromWindow(WidgetsBinding.instance.window); + MediaQueryData.fromWindow(WidgetsBinding.instance.window); windowData = windowData.copyWith( textScaleFactor: 1, ); @@ -71,10 +86,10 @@ class MyApp extends StatelessWidget { title: 'Fusion', debugShowCheckedModeBanner: false, theme: ThemeData( - // primarySwatch: Colors.blueGrey, + // primarySwatch: Colors.blueGrey, // colorSchemeSeed: Color(0xFF2085D0), colorSchemeSeed: Color(0xFFF36C35), - fontFamily: 'Nunito', + fontFamily: 'Nunito', useMaterial3: true, ), initialRoute: '/landing', @@ -127,6 +142,31 @@ class MyApp extends StatelessWidget { '/health_center/feedback': (context) => FeedBack(), '/health_center/viewschedule': (context) => ViewSchedule(), '/health_center/history': (context) => History(), + '/registered_courses': (context) => RegisteredCoursesHome(), + '/registered_courses/course_home': (context) => CourseHome(), + '/registered_courses/course_home/progress': (context) => Progress(), + '/registered_courses/course_home/course_content': (context) => + CourseContent(), + '/registered_courses/course_home/announcement': (context) => + Announcement(), + '/registered_courses/course_home/assignment': (context) => + Assignment(), + '/registered_courses/course_home/instructor/course_content': + (context) => CourseContentIns(), + '/registered_courses/course_home/assignment/upload_assignment': + (context) => uploadAssignment(), + '/registered_courses/course_home/assignment/announcements': + (context) => AnnouncementIns(), + '/acad_admin/academic_admin_homepage': (context) => + AcademicAdminHomePage(), + '/acad_admin/calender': (context) => CalendarPage(), + '/acad_admin/timetablepage': (context) => TimeTablePage(), + '/registered_courses/course_home/instructor/evaluation/evaluation': + (context) => Evaluation(), + '/registered_courses/course_home/instructor/evaluation/grading_scheme': + (context) => GradingScheme(), + '/registered_courses/course_home/instructor/evaluation/submissions': + (context) => Submissions(), }, ), ); diff --git a/lib/screens/Complaint/ComplaintHistory/update_complaint.dart b/lib/screens/Complaint/ComplaintHistory/update_complaint.dart index 8ea7af87..917de43c 100644 --- a/lib/screens/Complaint/ComplaintHistory/update_complaint.dart +++ b/lib/screens/Complaint/ComplaintHistory/update_complaint.dart @@ -172,8 +172,8 @@ class _UpdateComplaintState extends State { widget.id!, complaint_date, finishedDate, - complaint_type!, - location!, + complaint_type, + location, specific_location!, details!, status, diff --git a/lib/screens/Complaint/complaint.dart b/lib/screens/Complaint/complaint.dart index f1b5ed77..a7fc09ed 100644 --- a/lib/screens/Complaint/complaint.dart +++ b/lib/screens/Complaint/complaint.dart @@ -4,12 +4,9 @@ import 'package:fusion/Components/appBar.dart'; import 'package:fusion/models/profile.dart'; import 'package:fusion/services/profile_service.dart'; import 'package:http/http.dart'; -import 'ComplaintHistory/complain_history.dart'; import 'package:flutter/material.dart'; import 'package:fusion/Components/side_drawer.dart'; import 'dart:ui'; -import 'LodgeComplaint/lodge_complaint.dart'; -import 'Feedback/feedback.dart'; import 'package:provider/provider.dart'; class Complaint extends StatefulWidget { diff --git a/lib/screens/Courses/Acad_admin/academic_admin_homepage.dart b/lib/screens/Courses/Acad_admin/academic_admin_homepage.dart new file mode 100644 index 00000000..7cbbef83 --- /dev/null +++ b/lib/screens/Courses/Acad_admin/academic_admin_homepage.dart @@ -0,0 +1,191 @@ +import 'dart:async'; +import 'dart:convert'; +import 'package:fusion/models/profile.dart'; +import 'package:fusion/services/profile_service.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/models/dashboard.dart'; +import 'package:fusion/screens/LoginandDashboard/DashboardComponents/cardItems.dart'; +import 'package:fusion/services/dashboard_service.dart'; +import 'package:http/http.dart'; + +class AcademicAdminHomePage extends StatefulWidget { + @override + _AcademicAdminHomePageState createState() => _AcademicAdminHomePageState(); +} + +class _AcademicAdminHomePageState extends State { + bool _loading = true; + late String name; + // Stream Controller for API + late StreamController _dashboardController; + late DashboardService dashboardService; + late DashboardData data; + late StreamController _profileController; + late ProfileService profileService; + late ProfileData data2; + @override + void initState() { + super.initState(); + _dashboardController = StreamController(); + dashboardService = DashboardService(); + _profileController = StreamController(); + profileService = ProfileService(); + getData(); + } + + getData() async { + try { + Response response = await dashboardService.getDashboard(); + Response response2 = await profileService.getProfile(); + setState(() { + data = DashboardData.fromJson(jsonDecode(response.body)); + data2 = ProfileData.fromJson(jsonDecode(response2.body)); + _loading = false; + }); + name = data2.user!['first_name'] + ' ' + data2.user!['last_name']; + } catch (e) { + print(e); + } + } + + loadData() async { + getData().then((res) { + _dashboardController.add(res); + _profileController.add(res); + }); + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Academic Admin", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Add Timetable"), + onTap: () { + Navigator.pushNamed(context, '/acad_admin/timetablepage', + arguments: data); + }, + ), + InkWell( + child: myContainer("Add Academic Calendar"), + onTap: () { + Navigator.pushNamed(context, '/acad_admin/calender', + arguments: data); + }, + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Acad_admin/calender.dart b/lib/screens/Courses/Acad_admin/calender.dart new file mode 100644 index 00000000..6ea12714 --- /dev/null +++ b/lib/screens/Courses/Acad_admin/calender.dart @@ -0,0 +1,155 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/models/profile.dart'; +import 'package:fusion/services/profile_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:http/http.dart' as http; +import 'dart:async'; +import 'dart:convert'; + +class CalendarPage extends StatefulWidget { + @override + _CalendarPageState createState() => _CalendarPageState(); +} + +class _CalendarPageState extends State { + late ProfileData profileData; + bool _loading = true; + late String name; + late String depttype; + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + _loading = false; + print(name); + print(depttype); + } + + // Future fetchProfileData() async { + // try { + // final response = await http.get(Uri.parse('your_api_url_here')); + // if (response.statusCode == 200) { + // setState(() { + // profileData = ProfileData.fromJson(jsonDecode(response.body)); + // _loading = false; + // }); + // } else { + // throw Exception('Failed to load profile data'); + // } + // } catch (e) { + // print('Error: $e'); + // } + // } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: Border.all(color: Colors.deepOrangeAccent, width: 2.0), + borderRadius: BorderRadius.circular(15.0), + ); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: _loading + ? Center(child: CircularProgressIndicator()) + : ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + // Profile Data + Card( + elevation: 2.0, + margin: + EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox(height: 10.0), + Text( + '$name', + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox(height: 10.0), + Text( + '$depttype', + style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox(height: 10.0), + ], + ), + ), + // Calendar Section + Padding( + padding: const EdgeInsets.all(8.0), + child: GestureDetector( + onTap: () { + // Handle navigation to the Calendar upload page + }, + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Upload Calendar", + style: TextStyle( + fontSize: 20.0, + color: Colors.black, + ), + ), + ), + ), + decoration: BoxDecoration( + color: Colors.lightBlueAccent, + borderRadius: BorderRadius.circular(5.0), + ), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Acad_admin/timetablepage.dart b/lib/screens/Courses/Acad_admin/timetablepage.dart new file mode 100644 index 00000000..a2fa85c2 --- /dev/null +++ b/lib/screens/Courses/Acad_admin/timetablepage.dart @@ -0,0 +1,156 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/models/profile.dart'; +import 'package:fusion/services/profile_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:http/http.dart' as http; +import 'dart:async'; +import 'dart:convert'; + +class TimeTablePage extends StatefulWidget { + @override + _TimeTablePageState createState() => _TimeTablePageState(); +} + +class _TimeTablePageState extends State { + late ProfileData profileData; + bool _loading = true; + late String name; + late String depttype; + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + _loading = false; + + print(name); + print(depttype); + } + + // Future fetchProfileData() async { + // try { + // final response = await http.get(Uri.parse('your_api_url_here')); + // if (response.statusCode == 200) { + // setState(() { + // profileData = ProfileData.fromJson(jsonDecode(response.body)); + // _loading = false; + // }); + // } else { + // throw Exception('Failed to load profile data'); + // } + // } catch (e) { + // print('Error: $e'); + // } + // } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: Border.all(color: Colors.deepOrangeAccent, width: 2.0), + borderRadius: BorderRadius.circular(15.0), + ); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: _loading + ? Center(child: CircularProgressIndicator()) + : ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + // Profile Data + Card( + elevation: 2.0, + margin: + EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox(height: 10.0), + Text( + '$name', + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox(height: 10.0), + Text( + '$depttype', + style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox(height: 10.0), + ], + ), + ), + // Time Table Section + Padding( + padding: const EdgeInsets.all(8.0), + child: GestureDetector( + onTap: () { + // Handle navigation to the Time Table upload page + }, + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Upload Time Table", + style: TextStyle( + fontSize: 20.0, + color: Colors.black, + ), + ), + ), + ), + decoration: BoxDecoration( + color: Colors.lightBlueAccent, + borderRadius: BorderRadius.circular(5.0), + ), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Instructor/Announcements/Announcement.dart b/lib/screens/Courses/Instructor/Announcements/Announcement.dart new file mode 100644 index 00000000..2b0bd9d8 --- /dev/null +++ b/lib/screens/Courses/Instructor/Announcements/Announcement.dart @@ -0,0 +1,221 @@ +import 'dart:async'; +import 'dart:convert'; +import 'package:fusion/models/profile.dart'; +import 'package:fusion/services/profile_service.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/models/dashboard.dart'; +import 'package:fusion/screens/LoginandDashboard/DashboardComponents/cardItems.dart'; +import 'package:fusion/services/dashboard_service.dart'; +import 'package:http/http.dart'; + +class AnnouncementIns extends StatefulWidget { + @override + _AnnouncementState createState() => _AnnouncementState(); +} + +class _AnnouncementState extends State { + bool _loading = true; + late String name; + late String studentType; + // Stream Controller for API + late StreamController _dashboardController; + late DashboardService dashboardService; + late DashboardData data; + late StreamController _profileController; + late ProfileService profileService; + late ProfileData data2; + @override + void initState() { + super.initState(); + _dashboardController = StreamController(); + dashboardService = DashboardService(); + _profileController = StreamController(); + profileService = ProfileService(); + getData(); + } + + getData() async { + try { + Response response = await dashboardService.getDashboard(); + Response response2 = await profileService.getProfile(); + setState(() { + data = DashboardData.fromJson(jsonDecode(response.body)); + data2 = ProfileData.fromJson(jsonDecode(response2.body)); + _loading = false; + }); + name = data2.user!['first_name'] + ' ' + data2.user!['last_name']; + studentType = data2.profile!['department']!['name'] + + ' ' + + data2.profile!['user_type']; + } catch (e) { + print(e); + } + } + + loadData() async { + getData().then((res) { + _dashboardController.add(res); + _profileController.add(res); + }); + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + studentType, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Announments", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Announcement 1"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Announcement 2"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Announcement 3"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Assignments"), + // onTap: () { + // Navigator.pushNamed( + // context, '/registered_courses/course_home/assignment', + // arguments: data); + // }, + // ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Instructor/content/course_contentIns.dart b/lib/screens/Courses/Instructor/content/course_contentIns.dart new file mode 100644 index 00000000..16e0fc11 --- /dev/null +++ b/lib/screens/Courses/Instructor/content/course_contentIns.dart @@ -0,0 +1,221 @@ +import 'dart:async'; +import 'dart:convert'; +import 'package:fusion/models/profile.dart'; +import 'package:fusion/services/profile_service.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/models/dashboard.dart'; +import 'package:fusion/screens/LoginandDashboard/DashboardComponents/cardItems.dart'; +import 'package:fusion/services/dashboard_service.dart'; +import 'package:http/http.dart'; + +class CourseContentIns extends StatefulWidget { + @override + _CourseContentInsState createState() => _CourseContentInsState(); +} + +class _CourseContentInsState extends State { + bool _loading = true; + late String name; + late String studentType; + // Stream Controller for API + late StreamController _dashboardController; + late DashboardService dashboardService; + late DashboardData data; + late StreamController _profileController; + late ProfileService profileService; + late ProfileData data2; + @override + void initState() { + super.initState(); + _dashboardController = StreamController(); + dashboardService = DashboardService(); + _profileController = StreamController(); + profileService = ProfileService(); + getData(); + } + + getData() async { + try { + Response response = await dashboardService.getDashboard(); + Response response2 = await profileService.getProfile(); + setState(() { + data = DashboardData.fromJson(jsonDecode(response.body)); + data2 = ProfileData.fromJson(jsonDecode(response2.body)); + _loading = false; + }); + name = data2.user!['first_name'] + ' ' + data2.user!['last_name']; + studentType = data2.profile!['department']!['name'] + + ' ' + + data2.profile!['user_type']; + } catch (e) { + print(e); + } + } + + loadData() async { + getData().then((res) { + _dashboardController.add(res); + _profileController.add(res); + }); + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + studentType, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Course-Code", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Module 1"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/instructor/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Module 2"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Upload"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Assignments"), + // onTap: () { + // Navigator.pushNamed( + // context, '/registered_courses/course_home/assignment', + // arguments: data); + // }, + // ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Instructor/evaluation/assignments.dart b/lib/screens/Courses/Instructor/evaluation/assignments.dart new file mode 100644 index 00000000..ef4bc14c --- /dev/null +++ b/lib/screens/Courses/Instructor/evaluation/assignments.dart @@ -0,0 +1,187 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Assignment extends StatefulWidget { + @override + _AssignmentState createState() => _AssignmentState(); +} + +class _AssignmentState extends State { + bool _loading = true; + // Stream Controller for API + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Assignments", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Assignment 1"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/upload_assignment', + arguments: data); + }, + ), + InkWell( + child: myContainer("Assignment 2"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Assignment 3"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Assignments"), + // onTap: () { + // Navigator.pushNamed( + // context, '/registered_courses/course_home/assignment', + // arguments: data); + // }, + // ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Instructor/evaluation/evaluation.dart b/lib/screens/Courses/Instructor/evaluation/evaluation.dart new file mode 100644 index 00000000..2b6a95f5 --- /dev/null +++ b/lib/screens/Courses/Instructor/evaluation/evaluation.dart @@ -0,0 +1,178 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Evaluation extends StatefulWidget { + @override + _ProgressState createState() => _ProgressState(); +} + +class _ProgressState extends State { + bool _loading = true; + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Course-Code", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Upload Assignment"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/assignment/upload_assignment', + arguments: data); + }, + ), + InkWell( + child: myContainer("Grading Scheme"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/instructor/evaluation/grading_scheme', + arguments: data); + }, + ), + InkWell( + child: myContainer("Submission"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/instructor/evaluation/submissions', + arguments: data); + }, + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Instructor/evaluation/grading_scheme.dart b/lib/screens/Courses/Instructor/evaluation/grading_scheme.dart new file mode 100644 index 00000000..f19c6f94 --- /dev/null +++ b/lib/screens/Courses/Instructor/evaluation/grading_scheme.dart @@ -0,0 +1,161 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class GradingScheme extends StatefulWidget { + @override + _GradingSchemeState createState() => _GradingSchemeState(); +} + +class _GradingSchemeState extends State { + late String name; + late String depttype; + + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: BorderRadius.circular(15.0), + ); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox(height: 10.0), + Text( + //NAME OF USER + name, + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox(height: 10.0), + Text( + depttype, + ), + SizedBox(height: 10.0), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Assignments", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + ), + ), + ), + decoration: BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: BorderRadius.circular(5.0), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("100 - 90 => Grade A+"), + onTap: () { + // Handle onTap event + }, + ), + InkWell( + child: myContainer("89-80 => Grade A"), + onTap: () { + // Handle onTap event + }, + ), + InkWell( + child: myContainer("79 - 70 => Grade B+"), + onTap: () { + // Handle onTap event + }, + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Instructor/evaluation/submissions.dart b/lib/screens/Courses/Instructor/evaluation/submissions.dart new file mode 100644 index 00000000..a9541a24 --- /dev/null +++ b/lib/screens/Courses/Instructor/evaluation/submissions.dart @@ -0,0 +1,161 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Submissions extends StatefulWidget { + @override + _SubmissionState createState() => _SubmissionState(); +} + +class _SubmissionState extends State { + late String name; + late String depttype; + + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: BorderRadius.circular(15.0), + ); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox(height: 10.0), + Text( + //NAME OF USER + name, + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox(height: 10.0), + Text( + depttype, + ), + SizedBox(height: 10.0), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Assignments", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + ), + ), + ), + decoration: BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: BorderRadius.circular(5.0), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Submission 1"), + onTap: () { + // Handle onTap event + }, + ), + InkWell( + child: myContainer("Submission 2"), + onTap: () { + // Handle onTap event + }, + ), + InkWell( + child: myContainer("Submission 3"), + onTap: () { + // Handle onTap event + }, + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Instructor/evaluation/upload_assignment.dart b/lib/screens/Courses/Instructor/evaluation/upload_assignment.dart new file mode 100644 index 00000000..919ee8f3 --- /dev/null +++ b/lib/screens/Courses/Instructor/evaluation/upload_assignment.dart @@ -0,0 +1,187 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Assignment extends StatefulWidget { + @override + _AssignmentState createState() => _AssignmentState(); +} + +class _AssignmentState extends State { + bool _loading = true; + // Stream Controller for API + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Assignments", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Assignment 1"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Assignment 2"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Assignment 3"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Assignments"), + // onTap: () { + // Navigator.pushNamed( + // context, '/registered_courses/course_home/assignment', + // arguments: data); + // }, + // ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Registered_Courses_Home.dart b/lib/screens/Courses/Registered_Courses_Home.dart new file mode 100644 index 00000000..3fe4e41c --- /dev/null +++ b/lib/screens/Courses/Registered_Courses_Home.dart @@ -0,0 +1,454 @@ +// import 'package:flutter/material.dart'; +// import 'package:fusion/services/login_service.dart'; +// import 'package:fusion/services/service_locator.dart'; +// import 'package:fusion/services/storage_service.dart'; +// import 'package:flutter/material.dart'; +// import 'package:fusion/Components/appBar.dart'; +// import 'package:fusion/Components/side_drawer.dart'; +// import 'package:http/http.dart' as http; +// import 'dart:convert' as convert; + +// class RegisteredCoursesHome extends StatefulWidget { +// @override +// _RegisteredCoursesHomeState createState() => _RegisteredCoursesHomeState(); +// } + +// class Course { +// final String courseCode; +// final String courseName; + +// Course.fromJson(Map json) +// : courseCode = json['course_code'], +// courseName = json['course_name']; +// } + +// class _RegisteredCoursesHomeState extends State { +// late String name; +// late String depttype; +// late List registeredCourses = []; + +// // Function to fetch registered courses from student or instructor data +// Future fetchRegisteredCourses(String userType) async { +// final url = Uri.parse('http://localhost:3000/$userType'); +// final response = await http.get(url); + +// if (response.statusCode == 200) { +// final data = convert.jsonDecode(response.body); +// setState(() { +// registeredCourses = List.from( +// data['registered_courses'].map((item) => Course.fromJson(item))); +// }); +// } else { +// // Handle error scenario (e.g., display error message) +// print('Failed to load courses: ${response.statusCode}'); +// } +// } + +// // Course class to represent registered course data + +// @override +// void initState() { +// super.initState(); +// var service = locator(); +// name = service.profileData.user!["first_name"] + +// " " + +// service.profileData.user!["last_name"]; +// depttype = service.profileData.profile!['department']!['name'] + +// " " + +// service.profileData.profile!['user_type']; + +// // Determine user type (student or instructor) and fetch courses +// final userType = service.profileData.profile!['user_type']; +// fetchRegisteredCourses(userType); +// } + +// BoxDecoration myBoxDecoration() { +// return BoxDecoration( +// border: new Border.all( +// color: Colors.deepOrangeAccent, +// width: 2.0, +// style: BorderStyle.solid, +// ), +// borderRadius: new BorderRadius.all(new Radius.circular(15.0))); +// } + +// Text myText(String text) { +// return Text( +// text, +// style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), +// ); +// } + +// Padding myContainer(String text) { +// return Padding( +// padding: const EdgeInsets.all(8.0), +// child: Container( +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: myText(text), +// ), +// decoration: myBoxDecoration(), +// ), +// ); +// } + +// @override +// Widget build(BuildContext context) { +// return Scaffold( +// appBar: DefaultAppBar().buildAppBar(), +// drawer: SideDrawer(), +// body: ListView( +// shrinkWrap: true, +// physics: ClampingScrollPhysics(), +// children: [ +// Card( +// elevation: 2.0, +// margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), +// shadowColor: Colors.black, +// child: Column( +// children: [ +// Container( +// margin: EdgeInsets.only(top: 20.0), +// width: 170.0, +// height: 170.0, +// decoration: BoxDecoration( +// image: DecorationImage( +// image: AssetImage('assets/unknown.jpg'), +// fit: BoxFit.cover, +// ), +// ), +// ), +// SizedBox( +// height: 10.0, +// ), +// Text( +// name, +// style: TextStyle(fontSize: 20.0, color: Colors.black), +// ), +// SizedBox( +// height: 10.0, +// ), +// Text( +// depttype, +// style: TextStyle(fontSize: 15.0, color: Colors.black), +// ), +// SizedBox( +// height: 10.0, +// ), +// ], +// ), +// ), +// Padding( +// padding: const EdgeInsets.all(8.0), +// child: Container( +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: Center( +// child: Text( +// "Courses", +// style: TextStyle( +// fontSize: 20.0, +// color: Colors.white, +// ), +// )), +// ), +// decoration: new BoxDecoration( +// color: Colors.deepOrangeAccent, +// boxShadow: [ +// BoxShadow( +// color: Colors.black, +// offset: Offset(0.0, 1.0), +// blurRadius: 2.0, +// ) +// ], +// borderRadius: new BorderRadius.all(new Radius.circular(5.0)), +// ), +// ), +// ), +// Card( +// elevation: 2.0, +// margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), +// shadowColor: Colors.black, +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.stretch, +// children: [ +// // Loop through registeredCourses and display course details +// for (final course in registeredCourses) +// InkWell( +// child: myContainer( +// course.courseCode + " - " + course.courseName), +// onTap: () { +// // Handle course selection (e.g., navigate to course details page) +// print('Selected course: ${course.courseCode}'); +// // You can navigate to a course details page here +// }, +// ), +// ], +// ), +// ), +// ], +// ), +// ); +// } +// } + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:http/http.dart' as http; +import 'dart:convert' as convert; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:fusion/screens/Courses/course_home.dart'; + +class RegisteredCoursesHome extends StatefulWidget { + @override + _RegisteredCoursesHomeState createState() => _RegisteredCoursesHomeState(); +} + +class Course { + final String courseCode; + final String courseName; + + Course.fromJson(Map json) + : courseCode = json['course_code'], + courseName = json['course_name']; +} + +class _RegisteredCoursesHomeState extends State { + late String name; + late String depttype; + late List registeredCourses = []; + + // Function to fetch users based on type and optionally ID + // Future fetchUsers(String name, String? type) async { + // SharedPreferences prefs = await SharedPreferences.getInstance(); + // String? storedUsername = prefs.getString('username'); + // print(name); + // final url = Uri.parse('http://localhost:3000/users?id=$storedUsername'); + + // final response = await http.get(url); + // print("response:$response"); + + // if (response.statusCode == 200) { + // final data = convert.jsonDecode(response.body); + // print("data: $data\n"); + // final users = List>.from(data['users']); + // print(users); + + // // Extract courses based on user type (logic can be improved if needed) + // registeredCourses = users.fold>([], (courses, user) { + // if (user['type'] == type && user['id'] == name) { + // courses.addAll(List.from( + // user['registered_courses'].map((item) => Course.fromJson(item)))); + // } + // return courses; + // }); + + // setState(() {}); + // } else { + // // Handle error scenario (e.g., display error message) + // print('Failed to load users: ${response.statusCode}'); + // } + // } + Future fetchUsers(String name, String? type) async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + String? storedUsername = prefs.getString('username'); + print(name); + + final url = Uri.parse('http://localhost:3000/users?id=$storedUsername'); + + final response = await http.get(url); + print("response:$response"); + + if (response.statusCode == 200) { + final data = convert.jsonDecode(response.body); + print("data: $data\n"); + + // Check if 'users' is a list before accessing it + if (data is List) { + final users = List>.from(data); + print(users); + + // Extract courses based on user type (logic can be improved if needed) + registeredCourses = users.fold>([], (courses, user) { + if (user['type'] == type) { + courses.addAll(List.from(user['registered_courses'] + .map((item) => Course.fromJson(item)))); + } + return courses; + }); + } else { + // Handle the case where 'users' is not a list (e.g., display error message) + print('Unexpected data format: users key is not a list'); + } + + print(registeredCourses); + + setState(() {}); + } else { + // Handle error scenario (e.g., display error message) + print('Failed to load users: ${response.statusCode}'); + } + } + + // Course class to represent registered course data + + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + + // Determine user type and potentially user ID (logic can be improved) + final userType = service.profileData.profile!['user_type']; + final userID = + service.profileData.user!["first_name"]; // Assuming ID retrieval + + print("userid:$userID"); + fetchUsers(service.profileData.user!["first_name"], userType); + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + name, + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Courses", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + // Loop through registeredCourses and display course details + for (final course in registeredCourses) + InkWell( + child: myContainer( + course.courseCode + " - " + course.courseName), + onTap: () { + // Handle course selection (e.g., navigate to course details page) + print('Selected course: ${course.courseCode}'); + Navigator.pushNamed( + context, + '/registered_courses/course_home', + ); + // You can navigate to a course details page here + }, + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Students/announcements/announcements.dart b/lib/screens/Courses/Students/announcements/announcements.dart new file mode 100644 index 00000000..b6dd60b2 --- /dev/null +++ b/lib/screens/Courses/Students/announcements/announcements.dart @@ -0,0 +1,186 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Announcement extends StatefulWidget { + @override + _AnnouncementState createState() => _AnnouncementState(); +} + +class _AnnouncementState extends State { + bool _loading = true; + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Announments", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Upload Assignment by 12pm today"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("No class on 12/3/2024"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("marks chahiyeu to kaam karo"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Assignments"), + // onTap: () { + // Navigator.pushNamed( + // context, '/registered_courses/course_home/assignment', + // arguments: data); + // }, + // ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Students/assignments/assignments.dart b/lib/screens/Courses/Students/assignments/assignments.dart new file mode 100644 index 00000000..f2cd9d39 --- /dev/null +++ b/lib/screens/Courses/Students/assignments/assignments.dart @@ -0,0 +1,187 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Assignment extends StatefulWidget { + @override + _AssignmentState createState() => _AssignmentState(); +} + +class _AssignmentState extends State { + bool _loading = true; + // Stream Controller for API + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Assignments", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Assignment 1"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/assignment/upload_assignment', + arguments: data); + }, + ), + InkWell( + child: myContainer("Assignment 2"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Assignment 3"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Assignments"), + // onTap: () { + // Navigator.pushNamed( + // context, '/registered_courses/course_home/assignment', + // arguments: data); + // }, + // ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Students/assignments/upload_assignment.dart b/lib/screens/Courses/Students/assignments/upload_assignment.dart new file mode 100644 index 00000000..12ba5418 --- /dev/null +++ b/lib/screens/Courses/Students/assignments/upload_assignment.dart @@ -0,0 +1,456 @@ +// import 'dart:convert'; + +// import 'package:flutter/material.dart'; +// import 'package:fusion/services/login_service.dart'; +// import 'package:fusion/services/service_locator.dart'; +// import 'package:fusion/services/storage_service.dart'; +// import 'package:flutter/material.dart'; +// import 'package:fusion/Components/appBar.dart'; +// import 'package:fusion/Components/side_drawer.dart'; + +// class uploadAssignment extends StatefulWidget { +// @override +// _uploadAssignmentState createState() => _uploadAssignmentState(); +// } + +// class _uploadAssignmentState extends State { +// bool _loading = true; +// late String name; +// late String depttype; + +// final _formKey = GlobalKey(); +// late TextEditingController _assignmentNameController; + +// @override +// void initState() { +// super.initState(); +// var service = locator(); +// name = service.profileData.user!["first_name"] + +// " " + +// service.profileData.user!["last_name"]; +// depttype = service.profileData.profile!['department']!['name'] + +// " " + +// service.profileData.profile!['user_type']; +// _assignmentNameController = TextEditingController(); +// } + +// @override +// void dispose() { +// _assignmentNameController.dispose(); +// super.dispose(); +// } + +// BoxDecoration myBoxDecoration() { +// return BoxDecoration( +// border: Border.all( +// color: Colors.deepOrangeAccent, +// width: 2.0, +// style: BorderStyle.solid, +// ), +// borderRadius: BorderRadius.all( +// Radius.circular(15.0), +// ), +// ); +// } + +// Text myText(String text) { +// return Text( +// text, +// style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), +// ); +// } + +// Padding myContainer(String text) { +// return Padding( +// padding: const EdgeInsets.all(8.0), +// child: Container( +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: myText(text), +// ), +// decoration: myBoxDecoration(), +// ), +// ); +// } + +// void _submitForm() { +// if (_formKey.currentState!.validate()) { +// // Form is validated, proceed to convert form data to JSON +// Map formData = { +// 'assignmentName': _assignmentNameController.text, +// // Add more fields if needed +// }; +// String jsonData = jsonEncode(formData); +// print(jsonData); // Print or use the JSON data as needed +// } +// } + +// @override +// Widget build(BuildContext context) { +// final data = ''; +// return Scaffold( +// appBar: DefaultAppBar().buildAppBar(), +// drawer: SideDrawer(), +// body: ListView( +// shrinkWrap: true, +// physics: ClampingScrollPhysics(), +// children: [ +// Card( +// elevation: 2.0, +// margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), +// shadowColor: Colors.black, +// child: Column( +// children: [ +// Container( +// margin: EdgeInsets.only(top: 20.0), +// width: 170.0, +// height: 170.0, +// decoration: BoxDecoration( +// image: DecorationImage( +// image: AssetImage('assets/unknown.jpg'), +// fit: BoxFit.cover, +// ), +// ), +// ), +// SizedBox( +// height: 10.0, +// ), +// Text( +// name, +// style: TextStyle(fontSize: 20.0, color: Colors.black), +// ), +// SizedBox( +// height: 10.0, +// ), +// Text( +// depttype, +// ), +// SizedBox( +// height: 10.0, +// ), +// ], +// ), +// ), +// Padding( +// padding: const EdgeInsets.all(8.0), +// child: Container( +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: Center( +// child: Text( +// "Assignments", +// style: TextStyle( +// fontSize: 20.0, +// color: Colors.white, +// ), +// ), +// ), +// ), +// decoration: BoxDecoration( +// color: Colors.deepOrangeAccent, +// boxShadow: [ +// BoxShadow( +// color: Colors.black, +// offset: Offset(0.0, 1.0), +// blurRadius: 2.0, +// ) +// ], +// borderRadius: BorderRadius.all( +// Radius.circular(5.0), +// ), +// ), +// ), +// ), +// Card( +// elevation: 2.0, +// margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), +// shadowColor: Colors.black, +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.stretch, +// children: [ +// // InkWell( +// // child: myContainer("Assignment 1"), +// // onTap: () { +// // Navigator.pushNamed( +// // context, +// // '/registered_courses/course_home/module', +// // arguments: data, +// // ); +// // }, +// // ), +// // InkWell( +// // child: myContainer("Assignment 2"), +// // onTap: () { +// // Navigator.pushNamed( +// // context, +// // '/registered_courses/course_home/module', +// // arguments: data, +// // ); +// // }, +// // ), +// // InkWell( +// // child: myContainer("Assignment 3"), +// // onTap: () { +// // Navigator.pushNamed( +// // context, +// // '/registered_courses/course_home/module', +// // arguments: data, +// // ); +// // }, +// // ), +// Form( +// key: _formKey, +// child: Column( +// children: [ +// TextFormField( +// controller: _assignmentNameController, +// decoration: InputDecoration( +// labelText: 'Assignment Name', +// border: OutlineInputBorder(), +// ), +// validator: (value) { +// if (value == null || value.isEmpty) { +// return 'Please enter assignment name'; +// } +// return null; +// }, +// ), +// SizedBox(height: 10), +// ElevatedButton( +// onPressed: _submitForm, +// child: Text('Submit'), +// ), +// ], +// ), +// ), +// ], +// ), +// ), +// ], +// ), +// ); +// } +// } +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:file_picker/file_picker.dart'; + +class uploadAssignment extends StatefulWidget { + @override + _uploadAssignmentState createState() => _uploadAssignmentState(); +} + +class _uploadAssignmentState extends State { + bool _loading = true; + late String name; + late String depttype; + + final _formKey = GlobalKey(); + late TextEditingController _assignmentNameController; + String? _filePath; + + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + _assignmentNameController = TextEditingController(); + } + + @override + void dispose() { + _assignmentNameController.dispose(); + super.dispose(); + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: BorderRadius.all( + Radius.circular(15.0), + ), + ); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + void _submitForm() { + if (_formKey.currentState!.validate()) { + // Form is validated, proceed to convert form data to JSON + Map formData = { + 'assignmentName': _assignmentNameController.text, + 'filePath': _filePath, + }; + String jsonData = jsonEncode(formData); + print(jsonData); // Print or use the JSON data as needed + } + } + + Future _pickFile() async { + FilePickerResult? result = await FilePicker.platform.pickFiles( + type: FileType.custom, + allowedExtensions: ['pdf'], + ); + + if (result != null) { + setState(() { + _filePath = result.files.single.path; + }); + } + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + name, + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Assignments", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + ), + ), + ), + decoration: BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: BorderRadius.all( + Radius.circular(5.0), + ), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Form( + key: _formKey, + child: Column( + children: [ + TextFormField( + controller: _assignmentNameController, + decoration: InputDecoration( + labelText: 'Assignment Name', + border: OutlineInputBorder(), + ), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter assignment name'; + } + return null; + }, + ), + SizedBox(height: 10), + ElevatedButton( + onPressed: _pickFile, + child: Text('Select PDF File'), + ), + SizedBox(height: 10), + ElevatedButton( + onPressed: _submitForm, + child: Text('Submit'), + ), + ], + ), + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Students/course_content/course_content.dart b/lib/screens/Courses/Students/course_content/course_content.dart new file mode 100644 index 00000000..724ee535 --- /dev/null +++ b/lib/screens/Courses/Students/course_content/course_content.dart @@ -0,0 +1,187 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class CourseContent extends StatefulWidget { + @override + _CourseContentState createState() => _CourseContentState(); +} + +class _CourseContentState extends State { + bool _loading = true; + // Stream Controller for API + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Course-Code", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Module 1"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Module 2"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + InkWell( + child: myContainer("Module 3"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/module', + arguments: data); + }, + ), + // InkWell( + // child: myContainer("Assignments"), + // onTap: () { + // Navigator.pushNamed( + // context, '/registered_courses/course_home/assignment', + // arguments: data); + // }, + // ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/Students/progress/progress.dart b/lib/screens/Courses/Students/progress/progress.dart new file mode 100644 index 00000000..44554033 --- /dev/null +++ b/lib/screens/Courses/Students/progress/progress.dart @@ -0,0 +1,170 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class Progress extends StatefulWidget { + @override + _ProgressState createState() => _ProgressState(); +} + +class _ProgressState extends State { + bool _loading = true; + late String name; + late String depttype; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + // data.details!['current_user']['first_name'] + + // ' ' + + // data.details!['current_user']['last_name'], + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + // data.details!['user_branch'] + ' | ' + "STUDENT", + // style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Course-Code", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + InkWell( + child: myContainer("Attendance -> 9/10"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/progress', + arguments: data); + }, + ), + InkWell( + child: myContainer("marks"), + onTap: () { + Navigator.pushNamed( + context, '/registered_courses/course_home/progess', + arguments: data); + }, + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Courses/course_home.dart b/lib/screens/Courses/course_home.dart new file mode 100644 index 00000000..8ff2aaac --- /dev/null +++ b/lib/screens/Courses/course_home.dart @@ -0,0 +1,220 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; + +class CourseHome extends StatefulWidget { + @override + _CourseHomeState createState() => _CourseHomeState(); +} + +class _CourseHomeState extends State { + bool _loading = true; + late String name; + late String depttype; + late String user; + // Stream Controller for API + @override + void initState() { + super.initState(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + user = service.profileData.profile!['user_type']; + } + + BoxDecoration myBoxDecoration() { + return BoxDecoration( + border: new Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + } + + Text myText(String text) { + return Text( + text, + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), + ); + } + + Padding myContainer(String text) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: myText(text), + ), + decoration: myBoxDecoration(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final data = ''; + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + //NAME OF USER + name, + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + style: TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Course-Code", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: new BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: new BorderRadius.all(new Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + user.toLowerCase().contains('student') + ? InkWell( + child: myContainer("Course_content"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/course_content', + arguments: data); + }, + ) + : InkWell( + child: myContainer("Course_content"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/instructor/course_content', + arguments: data); + }, + ), + user.toLowerCase().contains('student') + ? InkWell( + child: myContainer("Progress"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/progress', + arguments: data); + }, + ) + : InkWell( + child: myContainer("Evaluation"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/instructor/evaluation/evaluation', + arguments: data); + }, + ), + user.toLowerCase().contains('student') + ? InkWell( + child: myContainer("Announcements"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/announcement', + arguments: data); + }, + ) + : InkWell( + child: myContainer("Announcements"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/assignment/announcements', + arguments: data); + }, + ), + user.toLowerCase().contains('student') + ? InkWell( + child: myContainer("Assignments"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/assignment', + arguments: data); + }, + ) + : InkWell( + child: myContainer("Assignments"), + onTap: () { + Navigator.pushNamed(context, + '/registered_courses/course_home/assignment/upload_assignment', + arguments: data); + }, + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/Gymkhana/Record.dart b/lib/screens/Gymkhana/Record.dart index adcfacf2..0a5f8f05 100644 --- a/lib/screens/Gymkhana/Record.dart +++ b/lib/screens/Gymkhana/Record.dart @@ -123,10 +123,10 @@ class Srecord { late String Category; Srecord( - {this.Name: "default-name", - this.Rollno: "000000", - this.Club: "default-club", - this.Category: "default-category"}); + {this.Name = "default-name", + this.Rollno = "000000", + this.Club = "default-club", + this.Category = "default-category"}); } var Srecords = [ diff --git a/lib/screens/LoginandDashboard/login_page.dart b/lib/screens/LoginandDashboard/login_page.dart index ca09fee2..da1e7066 100644 --- a/lib/screens/LoginandDashboard/login_page.dart +++ b/lib/screens/LoginandDashboard/login_page.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:fusion/constants.dart'; import 'package:fusion/services/login_service.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class LoginPage extends StatefulWidget { static String tag = 'login-page'; @@ -20,7 +21,6 @@ class _LoginPageState extends State { @override Widget build(BuildContext context) { - final Widget logoWidget = CircleAvatar( backgroundColor: Colors.transparent, radius: 54.0, @@ -30,13 +30,16 @@ class _LoginPageState extends State { keyboardType: TextInputType.emailAddress, autofocus: false, decoration: InputDecoration( - label: Text('Username', style: TextStyle( - fontSize: 12.0, - ),), + label: Text( + 'Username', + style: TextStyle( + fontSize: 12.0, + ), + ), contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), border: OutlineInputBorder( - // borderRadius: BorderRadius.circular(32.0), - ), + // borderRadius: BorderRadius.circular(32.0), + ), ), onChanged: (input) { username = input; @@ -44,11 +47,9 @@ class _LoginPageState extends State { validator: (String? value) { if (value?.length == 0) { return 'Please enter username'; - } - else if (value?.contains('@') == true) { + } else if (value?.contains('@') == true) { return 'Please enter username only'; } - }, autofillHints: [AutofillHints.username], ); @@ -57,13 +58,16 @@ class _LoginPageState extends State { autofocus: false, obscureText: true, decoration: InputDecoration( - label: Text('Password', style: TextStyle( - fontSize: 12.0, - ),), + label: Text( + 'Password', + style: TextStyle( + fontSize: 12.0, + ), + ), contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), border: OutlineInputBorder( - // borderRadius: BorderRadius.circular(32.0), - ), + // borderRadius: BorderRadius.circular(32.0), + ), ), onChanged: (input) { pass = input; @@ -91,6 +95,11 @@ class _LoginPageState extends State { bool complete = await auth.login(username ?? "", pass ?? ""); TextInput.finishAutofillContext(); if (complete == true) { + String parameterValue = username ?? ""; + + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.setString('username', parameterValue); + Navigator.pushReplacementNamed(context, "/landing"); } Navigator.pushReplacementNamed(context, "/landing"); @@ -141,7 +150,7 @@ class _LoginPageState extends State { ), Padding( padding: EdgeInsets.only(bottom: 15), - child: emailFormField, + child: emailFormField, ), Padding( padding: EdgeInsets.only(bottom: 15), diff --git a/lib/services/dashboard_service.dart b/lib/services/dashboard_service.dart index 8e4520a9..275c6fee 100644 --- a/lib/services/dashboard_service.dart +++ b/lib/services/dashboard_service.dart @@ -24,6 +24,7 @@ class DashboardService { ); if (response.statusCode == 200) { print("success"); + print(response); return response; } throw Exception('Can\'t load'); diff --git a/lib/services/login_service.dart b/lib/services/login_service.dart index 17d79b42..962d3f60 100644 --- a/lib/services/login_service.dart +++ b/lib/services/login_service.dart @@ -27,6 +27,7 @@ class LoginService { var storage_service = await StorageService.getInstance(); storage_service!.saveUserInDB(User((jsonDecode(response.body))["token"])); + print(storage_service); return true; } catch (e) { rethrow; @@ -41,4 +42,4 @@ class LoginService { rethrow; } } -} \ No newline at end of file +} diff --git a/pubspec.yaml b/pubspec.yaml index 49030f0b..8645fe85 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,6 +39,7 @@ dependencies: path_provider: ^2.0.8 open_file: ^3.2.1 flutter_html: ^2.2.1 + file_picker: ^5.2.10 From de79d5b146595ff1d46eab8a8ef1d952769a6039 Mon Sep 17 00:00:00 2001 From: Adi-Gupta018 Date: Wed, 31 Jul 2024 15:28:59 +0530 Subject: [PATCH 5/5] added backend apis --- .../Instructor/content/course_contentIns.dart | 556 ++++++++++++------ .../Instructor/evaluation/grading_scheme.dart | 442 +++++++++++--- .../Courses/Registered_Courses_Home.dart | 532 +++++++++++++---- .../course_content/course_content.dart | 523 ++++++++++++---- 4 files changed, 1576 insertions(+), 477 deletions(-) diff --git a/lib/screens/Courses/Instructor/content/course_contentIns.dart b/lib/screens/Courses/Instructor/content/course_contentIns.dart index 16e0fc11..95d0a367 100644 --- a/lib/screens/Courses/Instructor/content/course_contentIns.dart +++ b/lib/screens/Courses/Instructor/content/course_contentIns.dart @@ -1,16 +1,233 @@ -import 'dart:async'; -import 'dart:convert'; -import 'package:fusion/models/profile.dart'; -import 'package:fusion/services/profile_service.dart'; -import 'package:flutter/cupertino.dart'; +// import 'dart:async'; +// import 'dart:convert'; +// import 'package:fusion/models/profile.dart'; +// import 'package:fusion/services/profile_service.dart'; +// import 'package:flutter/cupertino.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter/rendering.dart'; +// import 'package:fusion/Components/appBar.dart'; +// import 'package:fusion/Components/side_drawer.dart'; +// import 'package:fusion/models/dashboard.dart'; +// import 'package:fusion/screens/LoginandDashboard/DashboardComponents/cardItems.dart'; +// import 'package:fusion/services/dashboard_service.dart'; +// import 'package:http/http.dart'; + +// class CourseContentIns extends StatefulWidget { +// @override +// _CourseContentInsState createState() => _CourseContentInsState(); +// } + +// class _CourseContentInsState extends State { +// bool _loading = true; +// late String name; +// late String studentType; +// // Stream Controller for API +// late StreamController _dashboardController; +// late DashboardService dashboardService; +// late DashboardData data; +// late StreamController _profileController; +// late ProfileService profileService; +// late ProfileData data2; +// @override +// void initState() { +// super.initState(); +// _dashboardController = StreamController(); +// dashboardService = DashboardService(); +// _profileController = StreamController(); +// profileService = ProfileService(); +// getData(); +// } + +// getData() async { +// try { +// Response response = await dashboardService.getDashboard(); +// Response response2 = await profileService.getProfile(); +// setState(() { +// data = DashboardData.fromJson(jsonDecode(response.body)); +// data2 = ProfileData.fromJson(jsonDecode(response2.body)); +// _loading = false; +// }); +// name = data2.user!['first_name'] + ' ' + data2.user!['last_name']; +// studentType = data2.profile!['department']!['name'] + +// ' ' + +// data2.profile!['user_type']; +// } catch (e) { +// print(e); +// } +// } + +// loadData() async { +// getData().then((res) { +// _dashboardController.add(res); +// _profileController.add(res); +// }); +// } + +// BoxDecoration myBoxDecoration() { +// return BoxDecoration( +// border: new Border.all( +// color: Colors.deepOrangeAccent, +// width: 2.0, +// style: BorderStyle.solid, +// ), +// borderRadius: new BorderRadius.all(new Radius.circular(15.0))); +// } + +// Text myText(String text) { +// return Text( +// text, +// style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), +// ); +// } + +// Padding myContainer(String text) { +// return Padding( +// padding: const EdgeInsets.all(8.0), +// child: Container( +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: myText(text), +// ), +// decoration: myBoxDecoration(), +// ), +// ); +// } + +// @override +// Widget build(BuildContext context) { +// final data = ''; +// return Scaffold( +// appBar: DefaultAppBar().buildAppBar(), +// drawer: SideDrawer(), +// body: ListView( +// shrinkWrap: true, +// physics: ClampingScrollPhysics(), +// children: [ +// Card( +// elevation: 2.0, +// margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), +// shadowColor: Colors.black, +// child: Column( +// children: [ +// Container( +// margin: EdgeInsets.only(top: 20.0), +// width: 170.0, +// height: 170.0, +// decoration: BoxDecoration( +// image: DecorationImage( +// image: AssetImage('assets/unknown.jpg'), +// fit: BoxFit.cover, +// ), +// ), +// ), +// SizedBox( +// height: 10.0, +// ), +// Text( +// //NAME OF USER +// name, +// // data.details!['current_user']['first_name'] + +// // ' ' + +// // data.details!['current_user']['last_name'], +// style: TextStyle(fontSize: 20.0, color: Colors.black), +// ), +// SizedBox( +// height: 10.0, +// ), +// Text( +// studentType, +// // data.details!['user_branch'] + ' | ' + "STUDENT", +// // style: TextStyle(fontSize: 15.0, color: Colors.black), +// ), +// SizedBox( +// height: 10.0, +// ), +// ], +// ), +// ), +// Padding( +// padding: const EdgeInsets.all(8.0), +// child: Container( +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: Center( +// child: Text( +// "Course-Code", +// style: TextStyle( +// fontSize: 20.0, +// color: Colors.white, +// ), +// )), +// ), +// decoration: new BoxDecoration( +// color: Colors.deepOrangeAccent, +// boxShadow: [ +// BoxShadow( +// color: Colors.black, +// offset: Offset(0.0, 1.0), +// blurRadius: 2.0, +// ) +// ], +// borderRadius: new BorderRadius.all(new Radius.circular(5.0)), +// ), +// ), +// ), +// Card( +// elevation: 2.0, +// margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), +// shadowColor: Colors.black, +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.stretch, +// children: [ +// InkWell( +// child: myContainer("Module 1"), +// onTap: () { +// Navigator.pushNamed(context, +// '/registered_courses/instructor/course_home/module', +// arguments: data); +// }, +// ), +// InkWell( +// child: myContainer("Module 2"), +// onTap: () { +// Navigator.pushNamed( +// context, '/registered_courses/course_home/module', +// arguments: data); +// }, +// ), +// InkWell( +// child: myContainer("Upload"), +// onTap: () { +// Navigator.pushNamed( +// context, '/registered_courses/course_home/module', +// arguments: data); +// }, +// ), +// // InkWell( +// // child: myContainer("Assignments"), +// // onTap: () { +// // Navigator.pushNamed( +// // context, '/registered_courses/course_home/assignment', +// // arguments: data); +// // }, +// // ) +// ], +// ), +// ), +// ], +// ), +// ); +// } +// } import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; +import 'package:http/http.dart' as http; +import 'dart:convert'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:fusion/services/login_service.dart'; +import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/services/storage_service.dart'; import 'package:fusion/Components/appBar.dart'; import 'package:fusion/Components/side_drawer.dart'; -import 'package:fusion/models/dashboard.dart'; -import 'package:fusion/screens/LoginandDashboard/DashboardComponents/cardItems.dart'; -import 'package:fusion/services/dashboard_service.dart'; -import 'package:http/http.dart'; class CourseContentIns extends StatefulWidget { @override @@ -20,57 +237,78 @@ class CourseContentIns extends StatefulWidget { class _CourseContentInsState extends State { bool _loading = true; late String name; - late String studentType; - // Stream Controller for API - late StreamController _dashboardController; - late DashboardService dashboardService; - late DashboardData data; - late StreamController _profileController; - late ProfileService profileService; - late ProfileData data2; + late String depttype; + Map? courseDetails; + @override void initState() { super.initState(); - _dashboardController = StreamController(); - dashboardService = DashboardService(); - _profileController = StreamController(); - profileService = ProfileService(); - getData(); + var service = locator(); + name = service.profileData.user!["first_name"] + + " " + + service.profileData.user!["last_name"]; + depttype = service.profileData.profile!['department']!['name'] + + " " + + service.profileData.profile!['user_type']; + fetchCourseDetails(); } - getData() async { - try { - Response response = await dashboardService.getDashboard(); - Response response2 = await profileService.getProfile(); + Future fetchCourseDetails() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + int? selectedCourseId = prefs.getInt('selectedCourseId'); + String? storedToken = 'Token 7f272a843c2589f1304d0167d8aae96dd649930f'; + + if (selectedCourseId == null) { + print('No course selected'); + return; + } + + final url = Uri.parse('http://localhost:8000/ocms/api/courses/'); + + final response = await http.get( + url, + headers: { + 'Authorization': storedToken, + 'Content-Type': 'application/json', + }, + ); + + if (response.statusCode == 200) { + final data = jsonDecode(response.body); + if (data['courses'] is List) { + final courses = List>.from(data['courses']); + final course = courses.firstWhere( + (course) => course['id'] == selectedCourseId, + orElse: () => {}, + ); + setState(() { + courseDetails = course; + _loading = false; + }); + print(courseDetails); + } else { + print('Unexpected data format: courses key is not a list'); + setState(() { + _loading = false; + }); + } + } else { + print('Failed to load courses: ${response.statusCode}'); setState(() { - data = DashboardData.fromJson(jsonDecode(response.body)); - data2 = ProfileData.fromJson(jsonDecode(response2.body)); _loading = false; }); - name = data2.user!['first_name'] + ' ' + data2.user!['last_name']; - studentType = data2.profile!['department']!['name'] + - ' ' + - data2.profile!['user_type']; - } catch (e) { - print(e); } } - loadData() async { - getData().then((res) { - _dashboardController.add(res); - _profileController.add(res); - }); - } - BoxDecoration myBoxDecoration() { return BoxDecoration( - border: new Border.all( - color: Colors.deepOrangeAccent, - width: 2.0, - style: BorderStyle.solid, - ), - borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + border: Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: BorderRadius.all(Radius.circular(15.0)), + ); } Text myText(String text) { @@ -95,127 +333,117 @@ class _CourseContentInsState extends State { @override Widget build(BuildContext context) { - final data = ''; return Scaffold( appBar: DefaultAppBar().buildAppBar(), drawer: SideDrawer(), - body: ListView( - shrinkWrap: true, - physics: ClampingScrollPhysics(), - children: [ - Card( - elevation: 2.0, - margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), - shadowColor: Colors.black, - child: Column( - children: [ - Container( - margin: EdgeInsets.only(top: 20.0), - width: 170.0, - height: 170.0, - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage('assets/unknown.jpg'), - fit: BoxFit.cover, + body: _loading + ? Center(child: CircularProgressIndicator()) + : courseDetails == null + ? Center(child: Text('No course details available')) + : ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric( + horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + name, + style: + TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + style: + TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), ), - ), - ), - SizedBox( - height: 10.0, - ), - Text( - //NAME OF USER - name, - // data.details!['current_user']['first_name'] + - // ' ' + - // data.details!['current_user']['last_name'], - style: TextStyle(fontSize: 20.0, color: Colors.black), - ), - SizedBox( - height: 10.0, - ), - Text( - studentType, - // data.details!['user_branch'] + ' | ' + "STUDENT", - // style: TextStyle(fontSize: 15.0, color: Colors.black), - ), - SizedBox( - height: 10.0, - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Text( - "Course-Code", - style: TextStyle( - fontSize: 20.0, - color: Colors.white, - ), - )), - ), - decoration: new BoxDecoration( - color: Colors.deepOrangeAccent, - boxShadow: [ - BoxShadow( - color: Colors.black, - offset: Offset(0.0, 1.0), - blurRadius: 2.0, - ) - ], - borderRadius: new BorderRadius.all(new Radius.circular(5.0)), - ), - ), - ), - Card( - elevation: 2.0, - margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), - shadowColor: Colors.black, - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - InkWell( - child: myContainer("Module 1"), - onTap: () { - Navigator.pushNamed(context, - '/registered_courses/instructor/course_home/module', - arguments: data); - }, - ), - InkWell( - child: myContainer("Module 2"), - onTap: () { - Navigator.pushNamed( - context, '/registered_courses/course_home/module', - arguments: data); - }, - ), - InkWell( - child: myContainer("Upload"), - onTap: () { - Navigator.pushNamed( - context, '/registered_courses/course_home/module', - arguments: data); - }, + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Course Code: ${courseDetails!['code']}", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: BorderRadius.all(Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric( + horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + "Course Name: ${courseDetails!['name']}", + style: TextStyle( + fontSize: 20.0, fontWeight: FontWeight.bold), + ), + ), + ...courseDetails!['syllabus'] + .split('\n') + .map((line) => InkWell( + child: myContainer(line), + onTap: () { + Navigator.pushNamed( + context, + '/registered_courses/course_home/module', + arguments: line); + }, + )) + .toList(), + ], + ), + ), + ], ), - // InkWell( - // child: myContainer("Assignments"), - // onTap: () { - // Navigator.pushNamed( - // context, '/registered_courses/course_home/assignment', - // arguments: data); - // }, - // ) - ], - ), - ), - ], - ), ); } } diff --git a/lib/screens/Courses/Instructor/evaluation/grading_scheme.dart b/lib/screens/Courses/Instructor/evaluation/grading_scheme.dart index f19c6f94..ed912944 100644 --- a/lib/screens/Courses/Instructor/evaluation/grading_scheme.dart +++ b/lib/screens/Courses/Instructor/evaluation/grading_scheme.dart @@ -1,3 +1,214 @@ +// import 'package:flutter/material.dart'; +// import 'package:fusion/services/login_service.dart'; +// import 'package:fusion/services/service_locator.dart'; +// import 'package:fusion/services/storage_service.dart'; +// import 'package:flutter/material.dart'; +// import 'package:fusion/Components/appBar.dart'; +// import 'package:fusion/Components/side_drawer.dart'; +// import 'package:shared_preferences/shared_preferences.dart'; +// import 'package:http/http.dart' as http; +// import 'dart:convert'; +// class GradingScheme extends StatefulWidget { +// @override +// _GradingSchemeState createState() => _GradingSchemeState(); +// } + +// class _GradingSchemeState extends State { +// bool _loading = true; +// late String name; +// late String depttype; +// Map? courseDetails; + +// @override +// void initState() { +// super.initState(); +// var service = locator(); +// name = service.profileData.user!["first_name"] + +// " " + +// service.profileData.user!["last_name"]; +// depttype = service.profileData.profile!['department']!['name'] + +// " " + +// service.profileData.profile!['user_type']; +// } +// Future fetchCourseDetails() async { +// SharedPreferences prefs = await SharedPreferences.getInstance(); +// int? selectedCourseId = prefs.getInt('selectedCourseId'); +// String? storedToken = 'Token 7f272a843c2589f1304d0167d8aae96dd649930f'; + +// if (selectedCourseId == null) { +// print('No course selected'); +// return; +// } + +// final url = Uri.parse('http://localhost:8000/ocms/api/courses/'); + +// final response = await http.get( +// url, +// headers: { +// 'Authorization': storedToken, +// 'Content-Type': 'application/json', +// }, +// ); + +// if (response.statusCode == 200) { +// final data = jsonDecode(response.body); +// if (data['courses'] is List) { +// final courses = List>.from(data['courses']); +// final course = courses.firstWhere( +// (course) => course['id'] == selectedCourseId, +// orElse: () => {}, +// ); +// setState(() { +// courseDetails = course; +// _loading = false; +// }); +// print(courseDetails); +// } else { +// print('Unexpected data format: courses key is not a list'); +// setState(() { +// _loading = false; +// }); +// } +// } else { +// print('Failed to load courses: ${response.statusCode}'); +// setState(() { +// _loading = false; +// }); +// } +// } + +// BoxDecoration myBoxDecoration() { +// return BoxDecoration( +// border: Border.all( +// color: Colors.deepOrangeAccent, +// width: 2.0, +// style: BorderStyle.solid, +// ), +// borderRadius: BorderRadius.circular(15.0), +// ); +// } + +// Text myText(String text) { +// return Text( +// text, +// style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), +// ); +// } + +// Padding myContainer(String text) { +// return Padding( +// padding: const EdgeInsets.all(8.0), +// child: Container( +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: myText(text), +// ), +// decoration: myBoxDecoration(), +// ), +// ); +// } + +// @override +// Widget build(BuildContext context) { +// return Scaffold( +// appBar: DefaultAppBar().buildAppBar(), +// drawer: SideDrawer(), +// body: ListView( +// shrinkWrap: true, +// physics: ClampingScrollPhysics(), +// children: [ +// Card( +// elevation: 2.0, +// margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), +// shadowColor: Colors.black, +// child: Column( +// children: [ +// Container( +// margin: EdgeInsets.only(top: 20.0), +// width: 170.0, +// height: 170.0, +// decoration: BoxDecoration( +// image: DecorationImage( +// image: AssetImage('assets/unknown.jpg'), +// fit: BoxFit.cover, +// ), +// ), +// ), +// SizedBox(height: 10.0), +// Text( +// //NAME OF USER +// name, +// style: TextStyle(fontSize: 20.0, color: Colors.black), +// ), +// SizedBox(height: 10.0), +// Text( +// depttype, +// ), +// SizedBox(height: 10.0), +// ], +// ), +// ), +// Padding( +// padding: const EdgeInsets.all(8.0), +// child: Container( +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: Center( +// child: Text( +// "Assignments", +// style: TextStyle( +// fontSize: 20.0, +// color: Colors.white, +// ), +// ), +// ), +// ), +// decoration: BoxDecoration( +// color: Colors.deepOrangeAccent, +// boxShadow: [ +// BoxShadow( +// color: Colors.black, +// offset: Offset(0.0, 1.0), +// blurRadius: 2.0, +// ) +// ], +// borderRadius: BorderRadius.circular(5.0), +// ), +// ), +// ), +// Card( +// elevation: 2.0, +// margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), +// shadowColor: Colors.black, +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.stretch, +// children: [ +// InkWell( +// child: myContainer("100 - 90 => Grade A+"), +// onTap: () { +// // Handle onTap event +// }, +// ), +// InkWell( +// child: myContainer("89-80 => Grade A"), +// onTap: () { +// // Handle onTap event +// }, +// ), +// InkWell( +// child: myContainer("79 - 70 => Grade B+"), +// onTap: () { +// // Handle onTap event +// }, +// ), +// ], +// ), +// ), +// ], +// ), +// ); +// } +// } import 'package:flutter/material.dart'; import 'package:fusion/services/login_service.dart'; import 'package:fusion/services/service_locator.dart'; @@ -5,6 +216,9 @@ import 'package:fusion/services/storage_service.dart'; import 'package:flutter/material.dart'; import 'package:fusion/Components/appBar.dart'; import 'package:fusion/Components/side_drawer.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:http/http.dart' as http; +import 'dart:convert'; class GradingScheme extends StatefulWidget { @override @@ -12,8 +226,10 @@ class GradingScheme extends StatefulWidget { } class _GradingSchemeState extends State { + bool _loading = true; late String name; late String depttype; + Map? courseDetails; @override void initState() { @@ -25,6 +241,82 @@ class _GradingSchemeState extends State { depttype = service.profileData.profile!['department']!['name'] + " " + service.profileData.profile!['user_type']; + fetchCourseDetails(); + } + + Future fetchCourseDetails() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + int? selectedCourseId = prefs.getInt('selectedCourseId'); + String? storedToken = 'Token 7f272a843c2589f1304d0167d8aae96dd649930f'; + + if (selectedCourseId == null) { + print('No course selected'); + return; + } + + final url = Uri.parse('http://localhost:8000/ocms/api/courses/'); + + final response = await http.get( + url, + headers: { + 'Authorization': storedToken, + 'Content-Type': 'application/json', + }, + ); + + if (response.statusCode == 200) { + final data = jsonDecode(response.body); + if (data['courses'] is List) { + final courses = List>.from(data['courses']); + final course = courses.firstWhere( + (course) => course['id'] == selectedCourseId, + orElse: () => {}, + ); + setState(() { + courseDetails = course; + _loading = false; + }); + print(courseDetails); + } else { + print('Unexpected data format: courses key is not a list'); + setState(() { + _loading = false; + }); + } + } else { + print('Failed to load courses: ${response.statusCode}'); + setState(() { + _loading = false; + }); + } + } + + List buildGradingSchemeWidgets(Map course) { + List gradingWidgets = []; + + if (course.containsKey('percent_quiz_1')) { + gradingWidgets.add(myContainer("Quiz 1: ${course['percent_quiz_1']}%")); + } + if (course.containsKey('percent_midsem')) { + gradingWidgets.add(myContainer("Midsem: ${course['percent_midsem']}%")); + } + if (course.containsKey('percent_quiz_2')) { + gradingWidgets.add(myContainer("Quiz 2: ${course['percent_quiz_2']}%")); + } + if (course.containsKey('percent_endsem')) { + gradingWidgets.add(myContainer("Endsem: ${course['percent_endsem']}%")); + } + if (course.containsKey('percent_project')) { + gradingWidgets.add(myContainer("Project: ${course['percent_project']}%")); + } + if (course.containsKey('percent_lab_evaluation')) { + gradingWidgets.add(myContainer("Lab Evaluation: ${course['percent_lab_evaluation']}%")); + } + if (course.containsKey('percent_course_attendance')) { + gradingWidgets.add(myContainer("Course Attendance: ${course['percent_course_attendance']}%")); + } + + return gradingWidgets; } BoxDecoration myBoxDecoration() { @@ -63,99 +355,81 @@ class _GradingSchemeState extends State { return Scaffold( appBar: DefaultAppBar().buildAppBar(), drawer: SideDrawer(), - body: ListView( - shrinkWrap: true, - physics: ClampingScrollPhysics(), - children: [ - Card( - elevation: 2.0, - margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), - shadowColor: Colors.black, - child: Column( + body: _loading + ? Center(child: CircularProgressIndicator()) + : ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), children: [ - Container( - margin: EdgeInsets.only(top: 20.0), - width: 170.0, - height: 170.0, - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage('assets/unknown.jpg'), - fit: BoxFit.cover, - ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox(height: 10.0), + Text( + name, + style: TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox(height: 10.0), + Text(depttype), + SizedBox(height: 10.0), + ], ), ), - SizedBox(height: 10.0), - Text( - //NAME OF USER - name, - style: TextStyle(fontSize: 20.0, color: Colors.black), - ), - SizedBox(height: 10.0), - Text( - depttype, - ), - SizedBox(height: 10.0), - ], - ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Text( - "Assignments", - style: TextStyle( - fontSize: 20.0, - color: Colors.white, + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Grading Scheme", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + ), + ), + ), + decoration: BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: BorderRadius.circular(5.0), ), ), ), - ), - decoration: BoxDecoration( - color: Colors.deepOrangeAccent, - boxShadow: [ - BoxShadow( - color: Colors.black, - offset: Offset(0.0, 1.0), - blurRadius: 2.0, - ) - ], - borderRadius: BorderRadius.circular(5.0), - ), - ), - ), - Card( - elevation: 2.0, - margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), - shadowColor: Colors.black, - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - InkWell( - child: myContainer("100 - 90 => Grade A+"), - onTap: () { - // Handle onTap event - }, - ), - InkWell( - child: myContainer("89-80 => Grade A"), - onTap: () { - // Handle onTap event - }, - ), - InkWell( - child: myContainer("79 - 70 => Grade B+"), - onTap: () { - // Handle onTap event - }, + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: courseDetails != null + ? buildGradingSchemeWidgets(courseDetails!) + : [Text('No grading scheme available')], + ), ), ], ), - ), - ], - ), ); } } diff --git a/lib/screens/Courses/Registered_Courses_Home.dart b/lib/screens/Courses/Registered_Courses_Home.dart index 3fe4e41c..e485b590 100644 --- a/lib/screens/Courses/Registered_Courses_Home.dart +++ b/lib/screens/Courses/Registered_Courses_Home.dart @@ -1,3 +1,199 @@ +// // import 'package:flutter/material.dart'; +// // import 'package:fusion/services/login_service.dart'; +// // import 'package:fusion/services/service_locator.dart'; +// // import 'package:fusion/services/storage_service.dart'; +// // import 'package:flutter/material.dart'; +// // import 'package:fusion/Components/appBar.dart'; +// // import 'package:fusion/Components/side_drawer.dart'; +// // import 'package:http/http.dart' as http; +// // import 'dart:convert' as convert; + +// // class RegisteredCoursesHome extends StatefulWidget { +// // @override +// // _RegisteredCoursesHomeState createState() => _RegisteredCoursesHomeState(); +// // } + +// // class Course { +// // final String courseCode; +// // final String courseName; + +// // Course.fromJson(Map json) +// // : courseCode = json['course_code'], +// // courseName = json['course_name']; +// // } + +// // class _RegisteredCoursesHomeState extends State { +// // late String name; +// // late String depttype; +// // late List registeredCourses = []; + +// // // Function to fetch registered courses from student or instructor data +// // Future fetchRegisteredCourses(String userType) async { +// // final url = Uri.parse('http://localhost:3000/$userType'); +// // final response = await http.get(url); + +// // if (response.statusCode == 200) { +// // final data = convert.jsonDecode(response.body); +// // setState(() { +// // registeredCourses = List.from( +// // data['registered_courses'].map((item) => Course.fromJson(item))); +// // }); +// // } else { +// // // Handle error scenario (e.g., display error message) +// // print('Failed to load courses: ${response.statusCode}'); +// // } +// // } + +// // // Course class to represent registered course data + +// // @override +// // void initState() { +// // super.initState(); +// // var service = locator(); +// // name = service.profileData.user!["first_name"] + +// // " " + +// // service.profileData.user!["last_name"]; +// // depttype = service.profileData.profile!['department']!['name'] + +// // " " + +// // service.profileData.profile!['user_type']; + +// // // Determine user type (student or instructor) and fetch courses +// // final userType = service.profileData.profile!['user_type']; +// // fetchRegisteredCourses(userType); +// // } + +// // BoxDecoration myBoxDecoration() { +// // return BoxDecoration( +// // border: new Border.all( +// // color: Colors.deepOrangeAccent, +// // width: 2.0, +// // style: BorderStyle.solid, +// // ), +// // borderRadius: new BorderRadius.all(new Radius.circular(15.0))); +// // } + +// // Text myText(String text) { +// // return Text( +// // text, +// // style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), +// // ); +// // } + +// // Padding myContainer(String text) { +// // return Padding( +// // padding: const EdgeInsets.all(8.0), +// // child: Container( +// // child: Padding( +// // padding: const EdgeInsets.all(8.0), +// // child: myText(text), +// // ), +// // decoration: myBoxDecoration(), +// // ), +// // ); +// // } + +// // @override +// // Widget build(BuildContext context) { +// // return Scaffold( +// // appBar: DefaultAppBar().buildAppBar(), +// // drawer: SideDrawer(), +// // body: ListView( +// // shrinkWrap: true, +// // physics: ClampingScrollPhysics(), +// // children: [ +// // Card( +// // elevation: 2.0, +// // margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), +// // shadowColor: Colors.black, +// // child: Column( +// // children: [ +// // Container( +// // margin: EdgeInsets.only(top: 20.0), +// // width: 170.0, +// // height: 170.0, +// // decoration: BoxDecoration( +// // image: DecorationImage( +// // image: AssetImage('assets/unknown.jpg'), +// // fit: BoxFit.cover, +// // ), +// // ), +// // ), +// // SizedBox( +// // height: 10.0, +// // ), +// // Text( +// // name, +// // style: TextStyle(fontSize: 20.0, color: Colors.black), +// // ), +// // SizedBox( +// // height: 10.0, +// // ), +// // Text( +// // depttype, +// // style: TextStyle(fontSize: 15.0, color: Colors.black), +// // ), +// // SizedBox( +// // height: 10.0, +// // ), +// // ], +// // ), +// // ), +// // Padding( +// // padding: const EdgeInsets.all(8.0), +// // child: Container( +// // child: Padding( +// // padding: const EdgeInsets.all(8.0), +// // child: Center( +// // child: Text( +// // "Courses", +// // style: TextStyle( +// // fontSize: 20.0, +// // color: Colors.white, +// // ), +// // )), +// // ), +// // decoration: new BoxDecoration( +// // color: Colors.deepOrangeAccent, +// // boxShadow: [ +// // BoxShadow( +// // color: Colors.black, +// // offset: Offset(0.0, 1.0), +// // blurRadius: 2.0, +// // ) +// // ], +// // borderRadius: new BorderRadius.all(new Radius.circular(5.0)), +// // ), +// // ), +// // ), +// // Card( +// // elevation: 2.0, +// // margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), +// // shadowColor: Colors.black, +// // child: Column( +// // crossAxisAlignment: CrossAxisAlignment.stretch, +// // children: [ +// // // Loop through registeredCourses and display course details +// // for (final course in registeredCourses) +// // InkWell( +// // child: myContainer( +// // course.courseCode + " - " + course.courseName), +// // onTap: () { +// // // Handle course selection (e.g., navigate to course details page) +// // print('Selected course: ${course.courseCode}'); +// // // You can navigate to a course details page here +// // }, +// // ), +// // ], +// // ), +// // ), +// // ], +// // ), +// // ); +// // } +// // } + +// import 'dart:async'; + // import 'package:flutter/material.dart'; // import 'package:fusion/services/login_service.dart'; // import 'package:fusion/services/service_locator.dart'; @@ -7,42 +203,169 @@ // import 'package:fusion/Components/side_drawer.dart'; // import 'package:http/http.dart' as http; // import 'dart:convert' as convert; +// import 'package:shared_preferences/shared_preferences.dart'; +// import 'package:fusion/screens/Courses/course_home.dart'; // class RegisteredCoursesHome extends StatefulWidget { // @override // _RegisteredCoursesHomeState createState() => _RegisteredCoursesHomeState(); // } -// class Course { -// final String courseCode; -// final String courseName; +// // class Course { +// // final String courseCode; +// // final String courseName; -// Course.fromJson(Map json) -// : courseCode = json['course_code'], -// courseName = json['course_name']; +// // Course.fromJson(Map json) +// // : courseCode = json['course_code'], +// // courseName = json['course_name']; +// // } +// class Course { +// final int id; +// final String code; +// final String name; +// // Add other fields as needed + +// Course({required this.id, required this.code, required this.name}); + +// factory Course.fromJson(Map json) { +// return Course( +// id: json['id'], +// code: json['code'], +// name: json['name'], +// // Initialize other fields as needed +// ); +// } // } - // class _RegisteredCoursesHomeState extends State { // late String name; // late String depttype; // late List registeredCourses = []; -// // Function to fetch registered courses from student or instructor data -// Future fetchRegisteredCourses(String userType) async { -// final url = Uri.parse('http://localhost:3000/$userType'); -// final response = await http.get(url); - -// if (response.statusCode == 200) { -// final data = convert.jsonDecode(response.body); -// setState(() { -// registeredCourses = List.from( -// data['registered_courses'].map((item) => Course.fromJson(item))); -// }); +// // Function to fetch users based on type and optionally ID +// // Future fetchUsers(String name, String? type) async { +// // SharedPreferences prefs = await SharedPreferences.getInstance(); +// // String? storedUsername = prefs.getString('username'); +// // print(name); +// // final url = Uri.parse('http://localhost:3000/users?id=$storedUsername'); + +// // final response = await http.get(url); +// // print("response:$response"); + +// // if (response.statusCode == 200) { +// // final data = convert.jsonDecode(response.body); +// // print("data: $data\n"); +// // final users = List>.from(data['users']); +// // print(users); + +// // // Extract courses based on user type (logic can be improved if needed) +// // registeredCourses = users.fold>([], (courses, user) { +// // if (user['type'] == type && user['id'] == name) { +// // courses.addAll(List.from( +// // user['registered_courses'].map((item) => Course.fromJson(item)))); +// // } +// // return courses; +// // }); + +// // setState(() {}); +// // } else { +// // // Handle error scenario (e.g., display error message) +// // print('Failed to load users: ${response.statusCode}'); +// // } +// // } +// // Future fetchUsers(String name, String? type) async { +// // SharedPreferences prefs = await SharedPreferences.getInstance(); +// // String? storedUsername = prefs.getString('username'); +// // print(name); + +// // final url = Uri.parse('http://localhost:3000/users?id=$storedUsername'); + +// // final response = await http.get(url); +// // print("response:$response"); + +// // if (response.statusCode == 200) { +// // final data = convert.jsonDecode(response.body); +// // print("data: $data\n"); + +// // // Check if 'users' is a list before accessing it +// // if (data is List) { +// // final users = List>.from(data); +// // print(users); + +// // // Extract courses based on user type (logic can be improved if needed) +// // registeredCourses = users.fold>([], (courses, user) { +// // if (user['type'] == type) { +// // courses.addAll(List.from(user['registered_courses'] +// // .map((item) => Course.fromJson(item)))); +// // } +// // return courses; +// // }); +// // } else { +// // // Handle the case where 'users' is not a list (e.g., display error message) +// // print('Unexpected data format: users key is not a list'); +// // } + +// // print(registeredCourses); + +// // setState(() {}); +// // } else { +// // // Handle error scenario (e.g., display error message) +// // print('Failed to load users: ${response.statusCode}'); +// // } +// // } +// Future fetchUsers(String name, String? type) async { +// SharedPreferences prefs = await SharedPreferences.getInstance(); +// String? storedUsername = prefs.getString('username'); +// String? storedPassword = prefs.getString('password'); // Assuming password is also stored +// String? storedToken = 'Token ef03c341eda820cd8e2dc95a1b8e4b75228b1077'; // Assuming token is also stored + +// print(name); + +// final url = Uri.parse('http://localhost:8000/ocms/api/courses/'); + +// final response = await http.get( +// url, +// headers: { +// 'Authorization': storedToken, +// 'Content-Type': 'application/json', +// }, +// ); +// // print("response: ${response.body}"); + +// if (response.statusCode == 200) { +// final data = convert.jsonDecode(response.body); +// print("data: $data\n"); + +// // Check if 'courses' is a list before accessing it +// if (data['courses'] is List) { +// final coursesData = List>.from(data['courses']); +// print(coursesData); + +// List registeredCourses = coursesData.map((courseData) { +// return Course.fromJson(courseData); +// }).toList(); + +// // If needed, filter courses by type or any other criteria +// // if (type != null) { +// // registeredCourses = registeredCourses.where((course) { +// // // Apply the type filtering logic here if needed +// // // Assuming 'type' is a property in the course object +// // return course.type == type; // Adjust this condition based on your data structure +// // }).toList(); +// // } + +// print(registeredCourses); + +// // Call setState() to update the UI if you're in a stateful widget +// // setState(() {}); // } else { -// // Handle error scenario (e.g., display error message) -// print('Failed to load courses: ${response.statusCode}'); +// // Handle the case where 'courses' is not a list (e.g., display error message) +// print('Unexpected data format: courses key is not a list'); // } +// } else { +// // Handle error scenario (e.g., display error message) +// print('Failed to load courses: ${response.statusCode}'); // } +// } // // Course class to represent registered course data @@ -57,9 +380,13 @@ // " " + // service.profileData.profile!['user_type']; -// // Determine user type (student or instructor) and fetch courses +// // Determine user type and potentially user ID (logic can be improved) // final userType = service.profileData.profile!['user_type']; -// fetchRegisteredCourses(userType); +// final userID = +// service.profileData.user!["first_name"]; // Assuming ID retrieval + +// print("userid:$userID"); +// fetchUsers(service.profileData.user!["first_name"], userType); // } // BoxDecoration myBoxDecoration() { @@ -173,14 +500,30 @@ // crossAxisAlignment: CrossAxisAlignment.stretch, // children: [ // // Loop through registeredCourses and display course details +// // for (final course in registeredCourses) +// // InkWell( +// // child: myContainer( +// // course.courseCode + " - " + course.courseName), +// // onTap: () { +// // // Handle course selection (e.g., navigate to course details page) +// // print('Selected course: ${course.courseCode}'); +// // Navigator.pushNamed( +// // context, +// // '/registered_courses/course_home', +// // ); +// // // You can navigate to a course details page here +// // }, +// // ), // for (final course in registeredCourses) // InkWell( -// child: myContainer( -// course.courseCode + " - " + course.courseName), +// child: myContainer(course.code + " - " + course.name), // onTap: () { // // Handle course selection (e.g., navigate to course details page) -// print('Selected course: ${course.courseCode}'); -// // You can navigate to a course details page here +// print('Selected course: ${course.code}'); +// Navigator.pushNamed( +// context, +// '/registered_courses/course_home', +// ); // }, // ), // ], @@ -191,20 +534,16 @@ // ); // } // } - import 'dart:async'; - import 'package:flutter/material.dart'; import 'package:fusion/services/login_service.dart'; import 'package:fusion/services/service_locator.dart'; import 'package:fusion/services/storage_service.dart'; -import 'package:flutter/material.dart'; -import 'package:fusion/Components/appBar.dart'; -import 'package:fusion/Components/side_drawer.dart'; import 'package:http/http.dart' as http; import 'dart:convert' as convert; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:fusion/screens/Courses/course_home.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:fusion/Components/side_drawer.dart'; class RegisteredCoursesHome extends StatefulWidget { @override @@ -212,93 +551,78 @@ class RegisteredCoursesHome extends StatefulWidget { } class Course { - final String courseCode; - final String courseName; - - Course.fromJson(Map json) - : courseCode = json['course_code'], - courseName = json['course_name']; + final int id; + final String code; + final String name; + // Add other fields as needed + + Course({required this.id, required this.code, required this.name}); + + factory Course.fromJson(Map json) { + return Course( + id: json['id'], + code: json['code'], + name: json['name'], + // Initialize other fields as needed + ); + } } class _RegisteredCoursesHomeState extends State { late String name; late String depttype; - late List registeredCourses = []; - - // Function to fetch users based on type and optionally ID - // Future fetchUsers(String name, String? type) async { - // SharedPreferences prefs = await SharedPreferences.getInstance(); - // String? storedUsername = prefs.getString('username'); - // print(name); - // final url = Uri.parse('http://localhost:3000/users?id=$storedUsername'); - - // final response = await http.get(url); - // print("response:$response"); - - // if (response.statusCode == 200) { - // final data = convert.jsonDecode(response.body); - // print("data: $data\n"); - // final users = List>.from(data['users']); - // print(users); - - // // Extract courses based on user type (logic can be improved if needed) - // registeredCourses = users.fold>([], (courses, user) { - // if (user['type'] == type && user['id'] == name) { - // courses.addAll(List.from( - // user['registered_courses'].map((item) => Course.fromJson(item)))); - // } - // return courses; - // }); - - // setState(() {}); - // } else { - // // Handle error scenario (e.g., display error message) - // print('Failed to load users: ${response.statusCode}'); - // } - // } + List registeredCourses = []; + Future fetchUsers(String name, String? type) async { SharedPreferences prefs = await SharedPreferences.getInstance(); String? storedUsername = prefs.getString('username'); + String? storedPassword = + prefs.getString('password'); // Assuming password is also stored + String? storedToken = + 'Token ef03c341eda820cd8e2dc95a1b8e4b75228b1077'; // Assuming token is also stored + String? token2 = 'Token 7f272a843c2589f1304d0167d8aae96dd649930f'; + print(name); - final url = Uri.parse('http://localhost:3000/users?id=$storedUsername'); + final url = Uri.parse('http://localhost:8000/ocms/api/courses/'); - final response = await http.get(url); - print("response:$response"); + final response = await http.get( + url, + headers: { + 'Authorization': type == 'student' ? storedToken : token2, + 'Content-Type': 'application/json', + }, +); + print("response: ${response.body}"); if (response.statusCode == 200) { final data = convert.jsonDecode(response.body); print("data: $data\n"); - // Check if 'users' is a list before accessing it - if (data is List) { - final users = List>.from(data); - print(users); - - // Extract courses based on user type (logic can be improved if needed) - registeredCourses = users.fold>([], (courses, user) { - if (user['type'] == type) { - courses.addAll(List.from(user['registered_courses'] - .map((item) => Course.fromJson(item)))); - } - return courses; + // Check if 'courses' is a list before accessing it + if (data['courses'] is List) { + final coursesData = List>.from(data['courses']); + print(coursesData); + + List courses = coursesData.map((courseData) { + return Course.fromJson(courseData); + }).toList(); + + setState(() { + registeredCourses = courses; }); + + print(registeredCourses); } else { - // Handle the case where 'users' is not a list (e.g., display error message) - print('Unexpected data format: users key is not a list'); + // Handle the case where 'courses' is not a list (e.g., display error message) + print('Unexpected data format: courses key is not a list'); } - - print(registeredCourses); - - setState(() {}); } else { // Handle error scenario (e.g., display error message) - print('Failed to load users: ${response.statusCode}'); + print('Failed to load courses: ${response.statusCode}'); } } - // Course class to represent registered course data - @override void initState() { super.initState(); @@ -429,19 +753,19 @@ class _RegisteredCoursesHomeState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - // Loop through registeredCourses and display course details for (final course in registeredCourses) InkWell( - child: myContainer( - course.courseCode + " - " + course.courseName), + child: myContainer(course.code + " - " + course.name), onTap: () { + SharedPreferences.getInstance().then((prefs) { + prefs.setInt('selectedCourseId', course.id); + print('Selected course: ${course.code}'); + Navigator.pushNamed( + context, + '/registered_courses/course_home', + ); + }); // Handle course selection (e.g., navigate to course details page) - print('Selected course: ${course.courseCode}'); - Navigator.pushNamed( - context, - '/registered_courses/course_home', - ); - // You can navigate to a course details page here }, ), ], diff --git a/lib/screens/Courses/Students/course_content/course_content.dart b/lib/screens/Courses/Students/course_content/course_content.dart index 724ee535..1e819a5b 100644 --- a/lib/screens/Courses/Students/course_content/course_content.dart +++ b/lib/screens/Courses/Students/course_content/course_content.dart @@ -1,8 +1,242 @@ + +// import 'package:flutter/material.dart'; +// import 'package:http/http.dart' as http; +// import 'dart:convert'; +// import 'package:shared_preferences/shared_preferences.dart'; +// import 'package:fusion/services/login_service.dart'; +// import 'package:fusion/services/service_locator.dart'; +// import 'package:fusion/services/storage_service.dart'; +// import 'package:fusion/Components/appBar.dart'; +// import 'package:fusion/Components/side_drawer.dart'; + +// class CourseContent extends StatefulWidget { +// @override +// _CourseContentState createState() => _CourseContentState(); +// } + +// class _CourseContentState extends State { +// bool _loading = true; +// late String name; +// late String depttype; +// Map? courseDetails; + +// @override +// void initState() { +// super.initState(); +// var service = locator(); +// name = service.profileData.user!["first_name"] + +// " " + +// service.profileData.user!["last_name"]; +// depttype = service.profileData.profile!['department']!['name'] + +// " " + +// service.profileData.profile!['user_type']; +// fetchCourseDetails(); +// } + +// Future fetchCourseDetails() async { +// SharedPreferences prefs = await SharedPreferences.getInstance(); +// int? selectedCourseId = prefs.getInt('selectedCourseId'); +// String? storedToken = 'Token ef03c341eda820cd8e2dc95a1b8e4b75228b1077'; + +// if (selectedCourseId == null) { +// print('No course selected'); +// return; +// } + +// final url = Uri.parse('http://localhost:8000/ocms/api/courses/'); + +// final response = await http.get( +// url, +// headers: { +// 'Authorization': storedToken, +// 'Content-Type': 'application/json', +// }, +// ); + +// if (response.statusCode == 200) { +// final data = jsonDecode(response.body); +// if (data['courses'] is List) { +// final courses = List>.from(data['courses']); +// final course = courses.firstWhere( +// (course) => course['id'] == selectedCourseId, +// orElse: () => {}, +// ); +// setState(() { +// courseDetails = course; +// _loading = false; +// }); +// print(courseDetails); +// } else { +// print('Unexpected data format: courses key is not a list'); +// setState(() { +// _loading = false; +// }); +// } +// } else { +// print('Failed to load courses: ${response.statusCode}'); +// setState(() { +// _loading = false; +// }); +// } +// } + +// BoxDecoration myBoxDecoration() { +// return BoxDecoration( +// border: Border.all( +// color: Colors.deepOrangeAccent, +// width: 2.0, +// style: BorderStyle.solid, +// ), +// borderRadius: BorderRadius.all(Radius.circular(15.0)), +// ); +// } + +// Text myText(String text) { +// return Text( +// text, +// style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500), +// ); +// } + +// Padding myContainer(String text) { +// return Padding( +// padding: const EdgeInsets.all(8.0), +// child: Container( +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: myText(text), +// ), +// decoration: myBoxDecoration(), +// ), +// ); +// } + +// @override +// Widget build(BuildContext context) { +// return Scaffold( +// appBar: DefaultAppBar().buildAppBar(), +// drawer: SideDrawer(), +// body: _loading +// ? Center(child: CircularProgressIndicator()) +// : courseDetails == null +// ? Center(child: Text('No course details available')) +// : ListView( +// shrinkWrap: true, +// physics: ClampingScrollPhysics(), +// children: [ +// Card( +// elevation: 2.0, +// margin: EdgeInsets.symmetric( +// horizontal: 50.0, vertical: 20.0), +// shadowColor: Colors.black, +// child: Column( +// children: [ +// Container( +// margin: EdgeInsets.only(top: 20.0), +// width: 170.0, +// height: 170.0, +// decoration: BoxDecoration( +// image: DecorationImage( +// image: AssetImage('assets/unknown.jpg'), +// fit: BoxFit.cover, +// ), +// ), +// ), +// SizedBox( +// height: 10.0, +// ), +// Text( +// name, +// style: +// TextStyle(fontSize: 20.0, color: Colors.black), +// ), +// SizedBox( +// height: 10.0, +// ), +// Text( +// depttype, +// style: +// TextStyle(fontSize: 15.0, color: Colors.black), +// ), +// SizedBox( +// height: 10.0, +// ), +// ], +// ), +// ), +// Padding( +// padding: const EdgeInsets.all(8.0), +// child: Container( +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: Center( +// child: Text( +// "Course Code: ${courseDetails!['code']}", +// style: TextStyle( +// fontSize: 20.0, +// color: Colors.white, +// ), +// )), +// ), +// decoration: BoxDecoration( +// color: Colors.deepOrangeAccent, +// boxShadow: [ +// BoxShadow( +// color: Colors.black, +// offset: Offset(0.0, 1.0), +// blurRadius: 2.0, +// ) +// ], +// borderRadius: BorderRadius.all(Radius.circular(5.0)), +// ), +// ), +// ), +// Card( +// elevation: 2.0, +// margin: EdgeInsets.symmetric( +// horizontal: 10.0, vertical: 10.0), +// shadowColor: Colors.black, +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.stretch, +// children: [ +// Padding( +// padding: const EdgeInsets.all(8.0), +// child: Text( +// "Course Name: ${courseDetails!['name']}", +// style: TextStyle( +// fontSize: 20.0, fontWeight: FontWeight.bold), +// ), +// ), +// Padding( +// padding: const EdgeInsets.all(8.0), +// child: Text( +// "Credits: ${courseDetails!['credit']}", +// style: TextStyle(fontSize: 18.0), +// ), +// ), +// Padding( +// padding: const EdgeInsets.all(8.0), +// child: Text( +// "Syllabus: ${courseDetails!['syllabus']}", +// style: TextStyle(fontSize: 18.0), +// ), +// ), +// // Add other course details as needed +// ], +// ), +// ), +// ], +// ), +// ); +// } +// } import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; +import 'dart:convert'; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:fusion/services/login_service.dart'; import 'package:fusion/services/service_locator.dart'; import 'package:fusion/services/storage_service.dart'; -import 'package:flutter/material.dart'; import 'package:fusion/Components/appBar.dart'; import 'package:fusion/Components/side_drawer.dart'; @@ -13,10 +247,10 @@ class CourseContent extends StatefulWidget { class _CourseContentState extends State { bool _loading = true; - // Stream Controller for API late String name; late String depttype; - // Stream Controller for API + Map? courseDetails; + @override void initState() { super.initState(); @@ -27,16 +261,65 @@ class _CourseContentState extends State { depttype = service.profileData.profile!['department']!['name'] + " " + service.profileData.profile!['user_type']; + fetchCourseDetails(); + } + + Future fetchCourseDetails() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + int? selectedCourseId = prefs.getInt('selectedCourseId'); + String? storedToken = 'Token ef03c341eda820cd8e2dc95a1b8e4b75228b1077'; + + if (selectedCourseId == null) { + print('No course selected'); + return; + } + + final url = Uri.parse('http://localhost:8000/ocms/api/courses/'); + + final response = await http.get( + url, + headers: { + 'Authorization': storedToken, + 'Content-Type': 'application/json', + }, + ); + + if (response.statusCode == 200) { + final data = jsonDecode(response.body); + if (data['courses'] is List) { + final courses = List>.from(data['courses']); + final course = courses.firstWhere( + (course) => course['id'] == selectedCourseId, + orElse: () => {}, + ); + setState(() { + courseDetails = course; + _loading = false; + }); + print(courseDetails); + } else { + print('Unexpected data format: courses key is not a list'); + setState(() { + _loading = false; + }); + } + } else { + print('Failed to load courses: ${response.statusCode}'); + setState(() { + _loading = false; + }); + } } BoxDecoration myBoxDecoration() { return BoxDecoration( - border: new Border.all( - color: Colors.deepOrangeAccent, - width: 2.0, - style: BorderStyle.solid, - ), - borderRadius: new BorderRadius.all(new Radius.circular(15.0))); + border: Border.all( + color: Colors.deepOrangeAccent, + width: 2.0, + style: BorderStyle.solid, + ), + borderRadius: BorderRadius.all(Radius.circular(15.0)), + ); } Text myText(String text) { @@ -61,127 +344,117 @@ class _CourseContentState extends State { @override Widget build(BuildContext context) { - final data = ''; return Scaffold( appBar: DefaultAppBar().buildAppBar(), drawer: SideDrawer(), - body: ListView( - shrinkWrap: true, - physics: ClampingScrollPhysics(), - children: [ - Card( - elevation: 2.0, - margin: EdgeInsets.symmetric(horizontal: 50.0, vertical: 20.0), - shadowColor: Colors.black, - child: Column( - children: [ - Container( - margin: EdgeInsets.only(top: 20.0), - width: 170.0, - height: 170.0, - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage('assets/unknown.jpg'), - fit: BoxFit.cover, + body: _loading + ? Center(child: CircularProgressIndicator()) + : courseDetails == null + ? Center(child: Text('No course details available')) + : ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric( + horizontal: 50.0, vertical: 20.0), + shadowColor: Colors.black, + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 20.0), + width: 170.0, + height: 170.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/unknown.jpg'), + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 10.0, + ), + Text( + name, + style: + TextStyle(fontSize: 20.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + Text( + depttype, + style: + TextStyle(fontSize: 15.0, color: Colors.black), + ), + SizedBox( + height: 10.0, + ), + ], + ), ), - ), - ), - SizedBox( - height: 10.0, - ), - Text( - //NAME OF USER - name, - // data.details!['current_user']['first_name'] + - // ' ' + - // data.details!['current_user']['last_name'], - style: TextStyle(fontSize: 20.0, color: Colors.black), - ), - SizedBox( - height: 10.0, - ), - Text( - depttype, - // data.details!['user_branch'] + ' | ' + "STUDENT", - // style: TextStyle(fontSize: 15.0, color: Colors.black), - ), - SizedBox( - height: 10.0, - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Text( - "Course-Code", - style: TextStyle( - fontSize: 20.0, - color: Colors.white, - ), - )), - ), - decoration: new BoxDecoration( - color: Colors.deepOrangeAccent, - boxShadow: [ - BoxShadow( - color: Colors.black, - offset: Offset(0.0, 1.0), - blurRadius: 2.0, - ) - ], - borderRadius: new BorderRadius.all(new Radius.circular(5.0)), - ), - ), - ), - Card( - elevation: 2.0, - margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), - shadowColor: Colors.black, - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - InkWell( - child: myContainer("Module 1"), - onTap: () { - Navigator.pushNamed( - context, '/registered_courses/course_home/module', - arguments: data); - }, - ), - InkWell( - child: myContainer("Module 2"), - onTap: () { - Navigator.pushNamed( - context, '/registered_courses/course_home/module', - arguments: data); - }, - ), - InkWell( - child: myContainer("Module 3"), - onTap: () { - Navigator.pushNamed( - context, '/registered_courses/course_home/module', - arguments: data); - }, + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + "Course Code: ${courseDetails!['code']}", + style: TextStyle( + fontSize: 20.0, + color: Colors.white, + ), + )), + ), + decoration: BoxDecoration( + color: Colors.deepOrangeAccent, + boxShadow: [ + BoxShadow( + color: Colors.black, + offset: Offset(0.0, 1.0), + blurRadius: 2.0, + ) + ], + borderRadius: BorderRadius.all(Radius.circular(5.0)), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.symmetric( + horizontal: 10.0, vertical: 10.0), + shadowColor: Colors.black, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + "Course Name: ${courseDetails!['name']}", + style: TextStyle( + fontSize: 20.0, fontWeight: FontWeight.bold), + ), + ), + ...courseDetails!['syllabus'] + .split('\n') + .map((line) => InkWell( + child: myContainer(line), + onTap: () { + Navigator.pushNamed( + context, + '/registered_courses/course_home/module', + arguments: line); + }, + )) + .toList(), + ], + ), + ), + ], ), - // InkWell( - // child: myContainer("Assignments"), - // onTap: () { - // Navigator.pushNamed( - // context, '/registered_courses/course_home/assignment', - // arguments: data); - // }, - // ) - ], - ), - ), - ], - ), ); } }