Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Academic page tabs and exams timeline #1379

Open
wants to merge 8 commits into
base: ui/redesign
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/uni_app/lib/controller/fetchers/exam_fetcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ExamFetcher implements SessionDependantFetcher {
) &&
courseExam.examType != 'EE' &&
courseExam.examType != 'EAE' &&
courseExam.subject == uc.abbreviation &&
courseExam.subjectAcronym == uc.abbreviation &&
uc.enrollmentIsValid() &&
!courseExam.hasEnded()) {
exams.add(courseExam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import 'package:uni/model/entities/exam.dart';
/// See the [Exam] class to see what data is stored in this database.
class AppExamsDatabase extends AppDatabase<List<Exam>> {
AppExamsDatabase()
: super('exams.db', [_createScript], onUpgrade: migrate, version: 7);
: super('exams.db', [_createScript], onUpgrade: migrate, version: 8);

static const _createScript = '''
CREATE TABLE exams(id TEXT, subject TEXT, start TEXT, finish TEXT,
CREATE TABLE exams(id TEXT, subjectAcronym TEXT, subject TEXT, start TEXT, finish TEXT,
rooms TEXT, examType TEXT, faculty TEXT, PRIMARY KEY (id,faculty)) ''';

/// Returns a list containing all of the exams stored in this database.
Expand All @@ -24,6 +24,7 @@ CREATE TABLE exams(id TEXT, subject TEXT, start TEXT, finish TEXT,
return List.generate(maps.length, (i) {
return Exam.secConstructor(
maps[i]['id'] as String,
maps[i]['subjectAcronym'] as String,
maps[i]['subject'] as String,
DateTime.parse(maps[i]['start'] as String),
DateTime.parse(maps[i]['finish'] as String),
Expand Down
6 changes: 5 additions & 1 deletion packages/uni_app/lib/controller/parsers/parser_exams.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ParserExams {
final dates = <String>[];
final examTypes = <String>[];
var rooms = <String>[];
String? subjectAcronym;
String? subject;
var id = '0';
var days = 0;
Expand All @@ -46,7 +47,8 @@ class ParserExams {
if (exams.querySelector('td.exame') != null) {
exams.querySelectorAll('td.exame').forEach((examsDay) {
if (examsDay.querySelector('a') != null) {
subject = examsDay.querySelector('a')!.text;
subjectAcronym = examsDay.querySelector('a')!.text;
subject = examsDay.querySelector('a')!.attributes['title'];
id = Uri.parse(examsDay.querySelector('a')!.attributes['href']!)
.queryParameters['p_exa_id']!;
}
Expand All @@ -56,6 +58,7 @@ class ParserExams {
.text
.split(',')
.map((e) => e.trim())
.where((e) => e.isNotEmpty)
.toList();
}
final DateTime begin;
Expand All @@ -73,6 +76,7 @@ class ParserExams {
id,
begin,
end,
subjectAcronym ?? '',
subject ?? '',
rooms,
examTypes[tableNum],
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/uni_app/lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Floor -1 of building B | AEFEUP building"),
"course_class": MessageLookupByLibrary.simpleMessage("Classes"),
"course_info": MessageLookupByLibrary.simpleMessage("Info"),
"courses": MessageLookupByLibrary.simpleMessage("Courses"),
"current_state":
MessageLookupByLibrary.simpleMessage("Current state: "),
"current_year":
Expand All @@ -122,6 +123,7 @@ class MessageLookup extends MessageLookupByLibrary {
"empty_text":
MessageLookupByLibrary.simpleMessage("Please fill in this field"),
"evaluation": MessageLookupByLibrary.simpleMessage("Evaluation"),
"exams": MessageLookupByLibrary.simpleMessage("Exams"),
"exams_filter":
MessageLookupByLibrary.simpleMessage("Exams Filter Settings"),
"exit_confirm":
Expand Down Expand Up @@ -157,6 +159,7 @@ class MessageLookup extends MessageLookupByLibrary {
"language": MessageLookupByLibrary.simpleMessage("Language"),
"last_refresh_time": m0,
"last_timestamp": m1,
"lectures": MessageLookupByLibrary.simpleMessage("Lectures"),
"library_occupation":
MessageLookupByLibrary.simpleMessage("Library Occupation"),
"load_error": MessageLookupByLibrary.simpleMessage(
Expand Down
3 changes: 3 additions & 0 deletions packages/uni_app/lib/generated/intl/messages_pt_PT.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Piso -1 do edifício B | Edifício da AEFEUP"),
"course_class": MessageLookupByLibrary.simpleMessage("Turmas"),
"course_info": MessageLookupByLibrary.simpleMessage("Ficha"),
"courses": MessageLookupByLibrary.simpleMessage("Cursos"),
"current_state": MessageLookupByLibrary.simpleMessage("Estado atual: "),
"current_year":
MessageLookupByLibrary.simpleMessage("Ano curricular atual: "),
Expand All @@ -121,6 +122,7 @@ class MessageLookup extends MessageLookupByLibrary {
"empty_text": MessageLookupByLibrary.simpleMessage(
"Por favor preenche este campo"),
"evaluation": MessageLookupByLibrary.simpleMessage("Avaliação"),
"exams": MessageLookupByLibrary.simpleMessage("Exames"),
"exams_filter":
MessageLookupByLibrary.simpleMessage("Definições Filtro de Exames"),
"exit_confirm": MessageLookupByLibrary.simpleMessage(
Expand Down Expand Up @@ -156,6 +158,7 @@ class MessageLookup extends MessageLookupByLibrary {
"language": MessageLookupByLibrary.simpleMessage("Idioma"),
"last_refresh_time": m0,
"last_timestamp": m1,
"lectures": MessageLookupByLibrary.simpleMessage("Aulas"),
"library_occupation":
MessageLookupByLibrary.simpleMessage("Ocupação da Biblioteca"),
"load_error": MessageLookupByLibrary.simpleMessage(
Expand Down
30 changes: 30 additions & 0 deletions packages/uni_app/lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/uni_app/lib/generated/model/entities/exam.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/uni_app/lib/generated/model/entities/trip.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion packages/uni_app/lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -333,5 +333,11 @@
"wrong_credentials_exception": "Invalid credentials",
"@wrong_credentials_exception": {},
"internet_status_exception": "Check your internet connection",
"@internet_status_exception": {}
"@internet_status_exception": {},
"lectures": "Lectures",
"@lectures": {},
"exams": "Exams",
"@exams": {},
"courses": "Courses",
"@courses": {}
}
8 changes: 7 additions & 1 deletion packages/uni_app/lib/l10n/intl_pt_PT.arb
Original file line number Diff line number Diff line change
Expand Up @@ -333,5 +333,11 @@
"wrong_credentials_exception": "Credenciais inválidas",
"@wrong_credentials_exception": {},
"internet_status_exception": "Verifique sua conexão com a internet",
"@internet_status_exception": {}
"@internet_status_exception": {},
"lectures": "Aulas",
"@lectures": {},
"exams": "Exames",
"@exams": {},
"courses": "Cursos",
"@courses": {}
}
8 changes: 6 additions & 2 deletions packages/uni_app/lib/model/entities/exam.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Exam {
this.id,
this.start,
this.finish,
this.subjectAcronym,
this.subject,
this.rooms,
this.examType,
Expand All @@ -31,6 +32,7 @@ class Exam {

Exam.secConstructor(
this.id,
this.subjectAcronym,
this.subject,
this.start,
this.finish,
Expand All @@ -42,6 +44,7 @@ class Exam {
final DateTime start;
final DateTime finish;
final String id;
final String subjectAcronym;
final String subject;
final List<String> rooms;
final String examType;
Expand All @@ -67,6 +70,7 @@ class Exam {
.WEEKDAYS[start.weekday % 7];
}

// TODO(thePeras): Remove this method and use {start.month} in the toString. Tests will fail and need to be updated.
String month(AppLocale locale) {
return DateFormat.EEEE(locale.localeCode.languageCode)
.dateSymbols
Expand All @@ -81,7 +85,7 @@ class Exam {

@override
String toString() {
return '''$id - $subject - ${start.year} - $month - ${start.day} - $startTime-$finishTime - $examType - $rooms - $weekDay''';
return '''$id - $subjectAcronym - ${start.year} - $month - ${start.day} - $startTime-$finishTime - $examType - $rooms - $weekDay''';
}

/// Prints the data in this exam to the [Logger] with an INFO level.
Expand All @@ -92,7 +96,7 @@ class Exam {
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Exam && id == other.id && subject == other.subject;
other is Exam && id == other.id && subjectAcronym == other.subjectAcronym;

@override
int get hashCode => id.hashCode;
Expand Down
11 changes: 9 additions & 2 deletions packages/uni_app/lib/utils/date_time_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ extension DateTimeExtensions on DateTime {
.WEEKDAYS[weekday % 7];
}

String month(AppLocale locale) {
String fullMonth(AppLocale locale) {
return DateFormat.EEEE(locale.localeCode.languageCode)
.dateSymbols
.MONTHS[this.month - 1];
.MONTHS[month - 1];
}

String shortMonth(AppLocale locale) {
return DateFormat.EEEE(locale.localeCode.languageCode)
.dateSymbols
.SHORTMONTHS[month - 1]
.replaceAll('.', '');
}

String formattedDate(AppLocale locale) {
Expand Down
5 changes: 5 additions & 0 deletions packages/uni_app/lib/utils/string_formatter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extension StringExtension on String {
String capitalize() {
return '${this[0].toUpperCase()}${substring(1).toLowerCase()}';
}
}
Loading