Skip to content

Commit

Permalink
moodle files updated
Browse files Browse the repository at this point in the history
  • Loading branch information
jesussmariscal committed Dec 28, 2024
1 parent e371cc2 commit 903ca29
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public ResponseEntity<List<Attendance>> getAllAttendances(HttpServletRequest req
@ApiResponse(responseCode = "500", description = "Error interno del servidor", content = @Content)
})
@PutMapping("/attendances/{id}/add-time")
public ResponseEntity<Void> addTimeToAttendance(@PathVariable Long id, HttpServletRequest request) {
public ResponseEntity<Boolean> addTimeToAttendance(@PathVariable Long id, HttpServletRequest request) {
Principal principal = request.getUserPrincipal();
if (principal == null) {
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
Expand All @@ -143,12 +143,15 @@ public ResponseEntity<Void> addTimeToAttendance(@PathVariable Long id, HttpServl
}

if (attendanceService.addTime(id)) {
return ResponseEntity.ok().build();
return ResponseEntity.ok().body(true);
} else {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}



}
}
6 changes: 2 additions & 4 deletions Backend/src/main/java/com/example/model/Attendance.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ public void setDateTime(LocalDateTime dateTime) {
this.dateTime = dateTime;
}

public void moreTime() {
dateTime = LocalDateTime.now();
}

public User getCreator() {
return creator;
}
Expand All @@ -80,4 +76,6 @@ public long getId() {
return id;
}



}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.example.services;

import java.security.SecureRandom;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Random;

Expand Down Expand Up @@ -54,7 +55,10 @@ public boolean isCodeUsed(String code) {
}

public boolean addTime(Long id) {
this.attendanceRepository.findById(id).get().moreTime();
Attendance attendance = this.attendanceRepository.findById(id).get();
attendance.setDateTime(LocalDateTime.now().plusHours(1));
attendanceRepository.save(attendance);

return true;

}
Expand Down
Binary file not shown.
Binary file modified Backend/target/classes/com/example/model/Attendance.class
Binary file not shown.
Binary file modified Backend/target/classes/com/example/services/AttendanceService.class
Binary file not shown.
14 changes: 9 additions & 5 deletions Docker/Moodle/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ RUN apt-get update && apt-get install -y \
# Copy Moodle files from the Moodle directory
COPY ./../Moodle /var/www/html/

# Create moodledata directory and set permissions
RUN mkdir -p /var/www/moodledata && \
chown -R www-data:www-data /var/www/moodledata && \
chmod -R 0770 /var/www/moodledata
# ELIMINA la creación de moodledata aquí

# Adjust permissions for Moodle
# Adjust permissions for Moodle (Esto se puede mantener o mover al entrypoint)
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html

Expand All @@ -53,8 +50,15 @@ RUN a2enmod rewrite
COPY ./../Moodle/moodle.conf /etc/apache2/sites-available/moodle.conf
RUN a2ensite moodle.conf

# Create entrypoint script
COPY ./entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Expose port 80 for web traffic
EXPOSE 80

# Use entrypoint script
ENTRYPOINT ["/entrypoint.sh"]

# Default command to start Apache
CMD ["apache2-foreground"]
8 changes: 8 additions & 0 deletions Docker/Moodle/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# Ajusta los permisos de moodledata DESPUÉS de que el volumen se monte
chown -R www-data:www-data /var/www/html/moodledata
chmod -R 0770 /var/www/html/moodledata

# Ejecuta el comando principal (en este caso, Apache)
exec "$@"
9 changes: 8 additions & 1 deletion Docker/commands.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

ionic build
npx cap sync
npx cap copy android
ionic capacitor run android -l --external
Expand All @@ -20,5 +20,12 @@ Construirla:
cd Docker/App
docker-compose -p myurjc up -d

Si moodle deja de responder:

docker exec -it moodle bash
chown -R www-data:www-data /var/www/html/moodledata
chmod -R 0770 /var/www/html/moodledata




2 changes: 1 addition & 1 deletion Frontend/capacitor.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const config: CapacitorConfig = {
appName: 'MyURJC',
webDir: 'www',
server: {
url: 'https://192.168.1.14:443',
url: 'http://192.168.1.14:8080',
cleartext: true
},
plugins: {
Expand Down
15 changes: 12 additions & 3 deletions Frontend/src/app/homePage/bluetooth-page/asistencia.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,25 @@ export class AsistenciaComponent implements OnInit {

addTimeToAttendance(attendanceId: number) {
this.teacherService.addTimeToAttendance(attendanceId).subscribe({
next: () => {
this.presentToast('Tiempo añadido correctamente', 'success');
this.getAsisttances(); // Actualizar la lista de asistencias
next: (success: boolean) => {
if (success) {
this.presentToast('Tiempo añadido correctamente', 'success');
const attendanceIndex = this.attendances.findIndex(a => a.id === attendanceId);
if (attendanceIndex > -1) {
// No necesitas usar 'response.newDateTime', ya que ahora solo estás trabajando con un booleano
this.getAsisttances(); // Actualiza las asistencias para refrescar la vista
}
} else {
this.presentToast('Error al añadir tiempo', 'danger');
}
},
error: (error) => {
console.error('Error al añadir tiempo:', error);
this.presentToast('Error al añadir tiempo', 'danger');
}
});
}


getTimeRemaining(dateTime: Date): number {
const FIVE_MINUTES_IN_MS = 5 * 60 * 1000; // 5 minutos en milisegundos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
<p>Inicia sesión para ver tu carnet.</p>
</div>

<ion-button *ngIf="presentAlert" id="present-alert">Click Me</ion-button>
<ion-alert
trigger="present-alert"
<ion-alert *ngIf="isNfcSupported && !showMenu"
trigger="open-modal"
header="Activar NFC para acceder a esta función."
[buttons]="alertButtons"
></ion-alert>
24 changes: 15 additions & 9 deletions Frontend/src/app/homePage/components/carnet/carnet.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ export class CarnetComponent implements OnInit {
isNfcSupported: boolean = false;
isNfcEnabled: boolean = false;
showMenu = false;
presentAlert = false;
countdown: number = 10;

private countdownInterval: any; // Variable para almacenar el ID del intervalo

public alertButtons = [
{
text: 'Cabcelar',
text: 'Cancelar',
role: 'cancel',
handler: () => {
this.presentAlert = false;

},
},
Expand All @@ -31,7 +32,6 @@ export class CarnetComponent implements OnInit {
role: 'confirm',
handler: async () => {
await Nfc.openSettings();
this.presentAlert = false;

},
},
Expand Down Expand Up @@ -67,15 +67,20 @@ export class CarnetComponent implements OnInit {
}

startCountdown() {
const interval = setInterval(() => {
clearInterval(this.countdownInterval);
this.countdown = 10;

this.countdownInterval = setInterval(() => {
if (this.countdown > 0) {
this.countdown--;
} else {
clearInterval(interval);
clearInterval(this.countdownInterval);
this.closeModal();
this.countdown = 10;
}
}, 1000);
}

closeModal() {
this.showMenu = false; // Cierra el modal al terminar el contador
}
Expand All @@ -92,6 +97,9 @@ export class CarnetComponent implements OnInit {
async checkNfcEnabled() {
const { isEnabled } = await Nfc.isEnabled();
this.isNfcEnabled = isEnabled;
if (!isEnabled) {
} else {
}
}

createNdefTextRecord() {
Expand All @@ -106,11 +114,9 @@ export class CarnetComponent implements OnInit {
return record;
}


async writeNfcTag() {
await this.checkNfcEnabled();
if (this.isNfcSupported && !this.isNfcEnabled) {
this.presentAlert = true;
return;
}
// Crear el registro NFC
Expand Down Expand Up @@ -142,4 +148,4 @@ export class CarnetComponent implements OnInit {
}
}, 10000); // 10000 milisegundos = 10 segundos
}
}
}
4 changes: 2 additions & 2 deletions Frontend/src/app/services/TeacherService/teacher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class TeacherService {
return this.http.get<Attendance[]>(`${this.API_BASE_URL}/attendances`, { withCredentials: true });
}

addTimeToAttendance(attendanceId: number): Observable<void> {
return this.http.put<void>(`${this.API_BASE_URL}/attendances/${attendanceId}/add-time`, null, { withCredentials: true });
addTimeToAttendance(attendanceId: number): Observable<boolean> {
return this.http.put<boolean>(`${this.API_BASE_URL}/attendances/${attendanceId}/add-time`, null, { withCredentials: true });
}
}
Binary file modified Moodle/.DS_Store
Binary file not shown.
Binary file removed Moodle/lib/.DS_Store
Binary file not shown.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ Si deseas ejecutar la app en Android:

1. Asegurarse de tener instalado Android Studio.
2. Situarse en el directorio Frontend de este repositorio: `cd Frontend/`
3. Ejecutar: `npx cap sync`
4. Ejecutar: `npx cap copy android`
5. Ejecutar: `npx cap run android`
3. Ejecutar: `ionic build`
4. Ejecutar: `npx cap sync`
5. Ejecutar: `npx cap copy android`
6. Ejecutar: `npx cap run android`

Si deseas acceder al aula virtual:

Expand Down

0 comments on commit 903ca29

Please sign in to comment.