Skip to content

Commit

Permalink
Merge pull request #73 from B3-3iL-DLW/feat/marks-absences
Browse files Browse the repository at this point in the history
Feat/marks absences
  • Loading branch information
PHPLukaas authored May 28, 2024
2 parents a1a7075 + 281b169 commit e3524bb
Show file tree
Hide file tree
Showing 29 changed files with 606 additions and 562 deletions.
43 changes: 26 additions & 17 deletions backend/src/Service/TimetableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getXmlFile(string $classParam): ?string
if ($class->getName() === $classParam) {
$encodedClassFile = str_replace(' ', '%20', $class->getFile());

return $this->schedule_url.$encodedClassFile;
return $this->schedule_url . $encodedClassFile;
}
}

Expand Down Expand Up @@ -73,6 +73,13 @@ public function parseData(array $parsedData): array

$changes = false;

$weeksTest = $parsedData['GROUPE']['PLAGES']['SEMAINE'];
// Si 'weeksTest' contient une seule semaine, convertissez-la en tableau multidimensionnel

if (!isset($weeksTest[0])) {
$parsedData['GROUPE']['PLAGES']['SEMAINE'] = [$weeksTest];
}

foreach ($parsedData['GROUPE']['PLAGES']['SEMAINE'] as $week) {
$weekSchedule = new WeekSchedule();
$weekSchedule->setId($week['SemId']);
Expand Down Expand Up @@ -125,26 +132,28 @@ public function parseData(array $parsedData): array

if ($existingEvent) {
// Si l'événement existe déjà, fusionnez les modifications
if ($existingEvent->getActivite() !== $event->getActivite()
if (
$existingEvent->getActivite() !== $event->getActivite()
|| $existingEvent->getCouleur() !== $event->getCouleur()
|| $existingEvent->getSalle() !== $event->getSalle()
|| $existingEvent->isRepas() !== $event->isRepas()
|| $existingEvent->isVisio() !== $event->isVisio()
|| $existingEvent->getEval() !== $event->getEval()) {


(new Logger())->info('Existing event: '.$existingEvent->getActivite());
(new Logger())->info('New event: '.$event->getActivite());
(new Logger())->info('Existing event: '.$existingEvent->getCouleur());
(new Logger())->info('New event: '.$event->getCouleur());
(new Logger())->info('Existing event: '.$existingEvent->getSalle());
(new Logger())->info('New event: '.$event->getSalle());
(new Logger())->info('Existing event: '.$existingEvent->isRepas());
(new Logger())->info('New event: '.$event->isRepas());
(new Logger())->info('Existing event: '.$existingEvent->isVisio());
(new Logger())->info('New event: '.$event->isVisio());
(new Logger())->info('Existing event: '.$existingEvent->getEval());
(new Logger())->info('New event: '.$event->getEval());
|| $existingEvent->getEval() !== $event->getEval()
) {


(new Logger())->info('Existing event: ' . $existingEvent->getActivite());
(new Logger())->info('New event: ' . $event->getActivite());
(new Logger())->info('Existing event: ' . $existingEvent->getCouleur());
(new Logger())->info('New event: ' . $event->getCouleur());
(new Logger())->info('Existing event: ' . $existingEvent->getSalle());
(new Logger())->info('New event: ' . $event->getSalle());
(new Logger())->info('Existing event: ' . $existingEvent->isRepas());
(new Logger())->info('New event: ' . $event->isRepas());
(new Logger())->info('Existing event: ' . $existingEvent->isVisio());
(new Logger())->info('New event: ' . $event->isVisio());
(new Logger())->info('Existing event: ' . $existingEvent->getEval());
(new Logger())->info('New event: ' . $event->getEval());

$existingEvent->setActivite($event->getActivite());
$existingEvent->setCouleur($event->getCouleur());
Expand Down
1 change: 1 addition & 0 deletions frontend/app_student/.fvm/flutter_sdk
1 change: 1 addition & 0 deletions frontend/app_student/.fvm/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.19.2
1 change: 1 addition & 0 deletions frontend/app_student/.fvm/versions/3.19.2
2 changes: 1 addition & 1 deletion frontend/app_student/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ flutter {
}

dependencies {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<application
android:label="my3iL"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:enableOnBackInvokedCallback="true">

<activity
android:name=".MainActivity"
android:exported="true"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'dart:io';

class DocumentEntity {
final String title;
final File? file;

DocumentEntity({required this.title, required this.file});

Map<String, dynamic> toJson() => {
'title': title,
'file': file!.path,
};

factory DocumentEntity.fromJson(Map<String, dynamic> json) {
return DocumentEntity(
title: json['title'],
file: File(json['file']),
);
}
}
30 changes: 30 additions & 0 deletions frontend/app_student/lib/api/documents/models/document_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'dart:io';
import 'package:app_student/api/documents/entities/document_entity.dart';

class DocumentModel {
final DocumentEntity entity;

DocumentModel({required this.entity});

String get title => entity.title;

File? get file => entity.file;

factory DocumentModel.fromEntity(DocumentEntity entity) {
return DocumentModel(
entity: entity,
);
}

DocumentEntity toEntity() {
return DocumentEntity(
title: title,
file: file,
);
}

@override
String toString() {
return 'DocumentModel: {title: $title, file: ${file?.path}}';
}
}
46 changes: 33 additions & 13 deletions frontend/app_student/lib/api/users/entities/user_entity.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
import 'dart:io';
import '../../documents/entities/document_entity.dart';

class UserEntity {
final String? ine;
final String firstName;
final DateTime? birthDate;
final String? className;
final int? studentId;
final File? marksFile;
final File? absencesFile;
String? ine;
String? firstName;
DateTime? birthDate;
String? className;
int? studentId;
List<DocumentEntity>? documents;

UserEntity(
{required this.ine,
required this.firstName,
required this.birthDate,
{this.ine,
this.firstName,
this.birthDate,
this.className,
this.studentId,
this.marksFile,
this.absencesFile});
this.documents});

Map<String, dynamic> toJson() => {
'firstName': firstName,
'className': className,
'ine': ine,
'birthDate': birthDate?.toIso8601String(),
'studentId': studentId,
'documents': documents?.map((doc) => doc.toJson()).toList(),
};

factory UserEntity.fromJson(Map<String, dynamic> json) => UserEntity(
firstName: json['firstName'],
className: json['className'],
ine: json['ine'],
birthDate: json['birthDate'] != null
? DateTime.parse(json['birthDate'])
: null,
studentId: json['studentId'],
documents: (json['documents'] as List<dynamic>?)
?.map((doc) => DocumentEntity.fromJson(doc))
.toList(),
);
}
82 changes: 75 additions & 7 deletions frontend/app_student/lib/api/users/models/user_model.dart
Original file line number Diff line number Diff line change
@@ -1,25 +1,93 @@
import 'dart:io';

import 'package:app_student/api/documents/models/document_model.dart';
import 'package:app_student/api/users/entities/user_entity.dart';

class UserModel {
final UserEntity entity;
UserEntity entity;

UserModel({required this.entity});

String get firstName => entity.firstName;
String? get firstName => entity.firstName;

String get name => entity.firstName;
set firstName(String? value) => entity.firstName = value;

DateTime? get birthDate => entity.birthDate;

set birthDate(DateTime? value) => entity.birthDate = value;

String? get className => entity.className;

set className(String? value) => entity.className = value;

String? get ine => entity.ine;

set ine(String? value) => entity.ine = value;

int? get studentId => entity.studentId;

File? get marksFile => entity.marksFile;
set studentId(int? value) => entity.studentId = value;

List<DocumentModel>? get documents => entity.documents
?.map((documentEntity) => DocumentModel.fromEntity(documentEntity))
.toList();

set documents(List<DocumentModel>? value) {
entity.documents = value?.map((model) => model.toEntity()).toList();
}

Map<String, dynamic> toJson() => {
'entity': entity.toJson(),
};

factory UserModel.fromJson(Map<String, dynamic> json) => UserModel(
entity: json['entity'] != null
? UserEntity.fromJson(json['entity'])
: UserEntity(),
);

@override
String toString() {
return 'User : {firstName: $firstName, birthDate: $birthDate, className: $className, ine: $ine, studentId: $studentId, documents: ${documents?.map((doc) => doc.toString()).join(', ')}}';
}

bool get isEmpty {
return firstName == null || firstName!.isEmpty;
}

bool get hasFirstName {
return firstName != null && firstName!.isNotEmpty;
}

bool get hasBirthDate {
return birthDate != null;
}

bool get hasClassName {
return className != null && className!.isNotEmpty;
}

bool get hasIne {
return ine != null && ine!.isNotEmpty;
}

bool get hasStudentId {
return studentId != null;
}

bool get hasDocuments {
return documents != null && documents!.isNotEmpty;
}

File? get absencesFile => entity.absencesFile;
static UserModel create(String firstName, String? className, String? ine,
DateTime? birthDate, int? studentId, List<DocumentModel>? documents) {
return UserModel(
entity: UserEntity(
firstName: firstName,
className: className,
ine: ine,
birthDate: birthDate,
studentId: studentId,
documents: documents?.map((doc) => doc.toEntity()).toList(),
),
);
}
}
Loading

0 comments on commit e3524bb

Please sign in to comment.