From 27e68a530377d5c8022de06a5001299045c476eb Mon Sep 17 00:00:00 2001
From: Marcos Viera <mviera@fing.edu.uy>
Date: Wed, 31 Mar 2021 15:05:01 -0300
Subject: [PATCH] calificaciones con reentrega

---
 .../layout/archivos/archivos.component.html   |  2 +-
 .../grupos/calificarEntrega.component.ts      | 15 ++++++++-
 Frontend Angular 4/src/app/shared/config.ts   | 33 +------------------
 .../app/shared/services/haskell.service.ts    |  4 +--
 Frontend Angular 4/src/assets/i18n/en.json    |  7 ++--
 Frontend Angular 4/src/assets/i18n/es.json    |  6 ++--
 Servidor JEE/WebContent/index.html            |  2 +-
 .../java/edu/proygrado/ejb/ArchivosEJB.java   |  5 +--
 .../servicios/archivos/ArchivosRS.java        |  6 ++--
 addToGrupo.sh                                 |  3 +-
 addUsers.sh                                   |  5 ++-
 generate-war.sh                               |  1 +
 12 files changed, 41 insertions(+), 48 deletions(-)

diff --git a/Frontend Angular 4/src/app/layout/archivos/archivos.component.html b/Frontend Angular 4/src/app/layout/archivos/archivos.component.html
index 0b99729c..95961a2a 100755
--- a/Frontend Angular 4/src/app/layout/archivos/archivos.component.html	
+++ b/Frontend Angular 4/src/app/layout/archivos/archivos.component.html	
@@ -171,7 +171,7 @@
                         {{archivoSeleccionado.estado}} - </div>
 
                     <button 
-                        *ngIf="esAlumno && archivoSeleccionado?.estado == 'Corregido'"
+                        *ngIf="esAlumno && (archivoSeleccionado?.estado == 'Corregido' || archivoSeleccionado?.estado == 'Devuelto')"
                         class="btn btn-sm btn-secondary pull-left mr-2"
                         (click)="verCalificacion()">
                         {{ "i18n.msg.file.viewCalification" | translate }}
diff --git a/Frontend Angular 4/src/app/layout/grupos/calificarEntrega.component.ts b/Frontend Angular 4/src/app/layout/grupos/calificarEntrega.component.ts
index e5dc97ed..0d627e95 100755
--- a/Frontend Angular 4/src/app/layout/grupos/calificarEntrega.component.ts	
+++ b/Frontend Angular 4/src/app/layout/grupos/calificarEntrega.component.ts	
@@ -7,6 +7,7 @@ export interface ConfirmModel {
   cedula:string;
   archivo: Archivo;
   parentContext: any;
+
 }
 @Component({  
     selector: 'confirm',
@@ -28,6 +29,14 @@ export interface ConfirmModel {
                         <label for="message-text" class="form-control-label">{{ "i18n.object.detail" | translate | titleCase }}:</label>
                         <textarea class="form-control" id="message-text" [(ngModel)]="descripcion" [ngModelOptions]="{standalone: true}" ></textarea>
                       </div>
+                      <div class="form-group">
+                        <label for="message-text" class="form-control-label">{{ "i18n.object.state" | translate | titleCase }}:</label>
+ 			<select name="estado" id="estado" class="form-control"
+        		[(ngModel)]="estado">
+        		<option *ngFor="let st of estados" [value]="st.value">{{ st.label }}</option>
+    			</select>
+                      </div>
+
                     </form>
                   </div>
 
@@ -44,12 +53,16 @@ export class CalificarEntrega extends DialogComponent<ConfirmModel, boolean> imp
   cedula: string;
   archivo: Archivo;
   nota: number = 0;
+  estado : string = "Corregido";
+  estados : any ;
   translateService: any;
   parentContext: any;
 
   constructor(dialogService: DialogService, public translate: TranslateService) {
     super(dialogService);
     this.translateService = translate;
+    this.estados = [ {value : "Corregido", label : this.translateService.get('i18n.msg.file.evaluated').value }
+                   , {value : "Devuelto", label : this.translateService.get('i18n.msg.file.returned').value }];
   }
 
   ngOnInit() {
@@ -65,7 +78,7 @@ export class CalificarEntrega extends DialogComponent<ConfirmModel, boolean> imp
     evaluacion.descripcion = this.descripcion;
     evaluacion.nota = this.nota;
     if(this.nota>=0 && this.nota<=100){
-      this.parentContext.haskellService.calificarArchivo(this.archivo.id,evaluacion )
+      this.parentContext.haskellService.calificarArchivo(this.archivo.id,this.estado,evaluacion )
        .subscribe(
         evaluacion => {
           this.parentContext.notifService.success(this.translateService.get('i18n.msg.file.evaluated').value);
diff --git a/Frontend Angular 4/src/app/shared/config.ts b/Frontend Angular 4/src/app/shared/config.ts
index 655cce7e..04b68e29 100755
--- a/Frontend Angular 4/src/app/shared/config.ts	
+++ b/Frontend Angular 4/src/app/shared/config.ts	
@@ -1,28 +1,3 @@
-//export const SERVER = 'https://matefun.mybluemix.net';
-//export const GHCI_URL = 'wss://matefun.mybluemix.net/endpoint';
-
-//export const SERVER = 'http://localhost:9090';
-//export const GHCI_URL = 'ws://localhost:9090/endpoint';
-
-// export const SERVER = 'http://localhost:9090';
-// export const GHCI_URL = 'ws://localhost:9090/endpoint';
-
-//Configuracion dinamica pensando en servidor con ip dinamica
-
-// export const SERVER = window.location.protocol + '//' + window.location.host;//'http://localhost:9090';
-// export const GHCI_URL = window.location.protocol == 'http:'?  'ws://'+window.location.host+'/endpoint': 'wss://'+window.location.host+'/endpoint';
-
-// Linux Nacho
-// export const SERVER = 'http://192.168.129.3:9090';
-// export const GHCI_URL = 'ws://192.168.129.3:9090/endpoint';
-
-// Google cloud platform
-// export const SERVER = 'http://35.199.110.129:9090';
-// export const GHCI_URL = 'ws://35.199.110.129:9090/endpoint';
-
-// Google cloud platform v2
-// export const SERVER = 'http://35.199.87.61:9090';
-// export const GHCI_URL = 'ws://35.199.87.61:9090/endpoint';
 
 // psico
 // export const SERVER = 'https://matefun.math.psico.edu.uy';
@@ -32,16 +7,10 @@
 export const SERVER = 'https://www.fing.edu.uy/proyectos/matefun';
 export const GHCI_URL = 'wss://www.fing.edu.uy/proyectos/matefun/endpoint';
 
-// fing-pru
-//export const SERVER = 'https://localhost:9443/proyectos/matefun';
-//export const GHCI_URL = 'wss://localhost:9443/proyectos/matefun/endpoint';
 
-//diego docker
+// local
 // export const SERVER = 'http://localhost:8080';
 // export const GHCI_URL = 'ws://localhost:8080/endpoint';
 
-//local proyectos/matefun
-//export const SERVER = 'http://localhost:9990';
-//export const GHCI_URL = 'ws://localhost:9990/endpoint';
 
 
diff --git a/Frontend Angular 4/src/app/shared/services/haskell.service.ts b/Frontend Angular 4/src/app/shared/services/haskell.service.ts
index 0d4a3cf3..baa28211 100755
--- a/Frontend Angular 4/src/app/shared/services/haskell.service.ts	
+++ b/Frontend Angular 4/src/app/shared/services/haskell.service.ts	
@@ -93,10 +93,10 @@ export class HaskellService {
      .catch(this.handleError);
    }
 
-   calificarArchivo(archivoId, evaluacion): Observable<Evaluacion> {
+   calificarArchivo(archivoId, estado, evaluacion): Observable<Evaluacion> {
      let headers = new Headers({ 'Content-Type': 'application/json', 'Authorization':'Bearer '+this.authService.getToken()  });
      let options = new RequestOptions({ headers: headers });
-     return this.http.post(SERVER+'/servicios/archivo/'+archivoId+'/evaluacion', evaluacion, options)
+     return this.http.post(SERVER+'/servicios/archivo/'+archivoId+'/'+estado+'/evaluacion', evaluacion, options)
      .map((res: Response) => res.json())
      .catch(this.handleError);
    }
diff --git a/Frontend Angular 4/src/assets/i18n/en.json b/Frontend Angular 4/src/assets/i18n/en.json
index fcc7ce57..40bef673 100644
--- a/Frontend Angular 4/src/assets/i18n/en.json	
+++ b/Frontend Angular 4/src/assets/i18n/en.json	
@@ -57,7 +57,8 @@
             "qualification" : "qualification",
             "date" : "date",
             "detail" : "detail",
-            "score" : "score"
+            "score" : "score",
+	    "state" : "state"
         },
         "codemirror" : {
             "command" : {
@@ -105,7 +106,9 @@
                 "move" : "Where do you want to move the file?",
                 "create" : "Where do you want to create the file?",
                 "qualify" : "Qualify the delivered file",
-                "evaluated" : "Evaluated file"
+                "evaluated" : "Evaluated file",
+		"returned" : "Evaluated file (re-send)"
+
             },
             "folder" : {
                 "delete" : "Are you want to delete the {{fileName}} folder?"
diff --git a/Frontend Angular 4/src/assets/i18n/es.json b/Frontend Angular 4/src/assets/i18n/es.json
index 95434059..e3e39769 100644
--- a/Frontend Angular 4/src/assets/i18n/es.json	
+++ b/Frontend Angular 4/src/assets/i18n/es.json	
@@ -57,7 +57,8 @@
             "qualification" : "calificación",
             "date" : "fecha",
             "detail" : "detalle",
-            "score" : "puntaje"
+            "score" : "puntaje",
+	    "state" : "estado"
         },
         "codemirror" : {
             "command" : {
@@ -105,7 +106,8 @@
                 "move" : "¿Dónde quieres mover el archivo?",
                 "create" : "¿Dónde quieres crear el archivo?",
                 "qualify" : "Calificar entrega",
-                "evaluated" : "Archivo evaluado"
+                "evaluated" : "Archivo evaluado",
+		"returned" : "Archivo evaluado (re-entrega)"
             },
             "folder" : {
                 "delete" : "¿Está seguro que desea eliminar la carpeta {{fileName}}?"
diff --git a/Servidor JEE/WebContent/index.html b/Servidor JEE/WebContent/index.html
index 18d0dfc4..bcffd501 100644
--- a/Servidor JEE/WebContent/index.html	
+++ b/Servidor JEE/WebContent/index.html	
@@ -1,4 +1,4 @@
 <!doctype html><html><head><meta charset="utf-8"><title>Proyecto MateFun</title><base href="/proyectos/matefun/"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" type="image/x-icon" href="favicon.ico"><!-- despues lo saco de aca --><!-- <link rel="stylesheet" type="text/css" href="node_modules/codemirror/addon/hint/show-hint.css">  --><script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" crossorigin="anonymous"></script><!--
     <script src="https://wzrd.in/standalone/function-plot@1.18.1" crossorigin="anonymous"></script>
 
-    --><link href="styles.1dc6715c59e708068692.bundle.css" rel="stylesheet"/></head><body><app-root><div class="loading"><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div></div></app-root><script type="text/javascript" src="inline.b6f342c3bceccf578c39.bundle.js"></script><script type="text/javascript" src="polyfills.d50ac7c762e2eb4097d9.bundle.js"></script><script type="text/javascript" src="scripts.d01654a9119059a68b2b.bundle.js"></script><script type="text/javascript" src="vendor.d3c1758890cc7548bc7b.bundle.js"></script><script type="text/javascript" src="main.98a532e0b59061522b75.bundle.js"></script></body></html>
\ No newline at end of file
+    --><link href="styles.1dc6715c59e708068692.bundle.css" rel="stylesheet"/></head><body><app-root><div class="loading"><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div></div></app-root><script type="text/javascript" src="inline.8cfebe1df0508124ae25.bundle.js"></script><script type="text/javascript" src="polyfills.d50ac7c762e2eb4097d9.bundle.js"></script><script type="text/javascript" src="scripts.d01654a9119059a68b2b.bundle.js"></script><script type="text/javascript" src="vendor.d3c1758890cc7548bc7b.bundle.js"></script><script type="text/javascript" src="main.98a532e0b59061522b75.bundle.js"></script></body></html>
\ No newline at end of file
diff --git a/Servidor JEE/src/main/java/edu/proygrado/ejb/ArchivosEJB.java b/Servidor JEE/src/main/java/edu/proygrado/ejb/ArchivosEJB.java
index f3cfb9fe..306986f7 100644
--- a/Servidor JEE/src/main/java/edu/proygrado/ejb/ArchivosEJB.java	
+++ b/Servidor JEE/src/main/java/edu/proygrado/ejb/ArchivosEJB.java	
@@ -182,7 +182,7 @@ public class ArchivosEJB {
 		}
 	}
 
-	public EvaluacionDTO evaluarArchivo(Long archivoId, EvaluacionDTO evaluacion) throws Exception {
+        public EvaluacionDTO evaluarArchivo(Long archivoId, String estado, EvaluacionDTO evaluacion) throws Exception {
 		Archivo archivo = em.find(Archivo.class, archivoId);
 		if (archivo == null) {
 			throw new Exception("No se encuentra el archivo con id: " + archivoId);
@@ -203,7 +203,8 @@ public class ArchivosEJB {
 		eval.setFecha(new Date());
 		eval.setNota(evaluacion.getNota());
 		archivo.setEvaluacion(eval);
-		archivo.setEstado(EstadoArchivo.Corregido);
+		if (estado.equals("Devuelto")) { archivo.setEstado(EstadoArchivo.Devuelto); }
+		else {archivo.setEstado(EstadoArchivo.Corregido);}
 		return evaluacion;
 	}
 
diff --git a/Servidor JEE/src/main/java/edu/proygrado/servicios/archivos/ArchivosRS.java b/Servidor JEE/src/main/java/edu/proygrado/servicios/archivos/ArchivosRS.java
index bbc7030b..409145c2 100644
--- a/Servidor JEE/src/main/java/edu/proygrado/servicios/archivos/ArchivosRS.java	
+++ b/Servidor JEE/src/main/java/edu/proygrado/servicios/archivos/ArchivosRS.java	
@@ -101,11 +101,11 @@ public class ArchivosRS{
     }
     
     @POST
-    @Path("/{archivoId}/evaluacion")
+    @Path("/{archivoId}/{estado}/evaluacion")
     @Produces(MediaType.APPLICATION_JSON)
     @Consumes(MediaType.APPLICATION_JSON)
-    public EvaluacionDTO evaluarArchivo(@PathParam("archivoId") long archivoId, EvaluacionDTO evaluacion) throws Exception {
-    	return archivosEJB.evaluarArchivo(archivoId, evaluacion);
+    public EvaluacionDTO evaluarArchivo(@PathParam("archivoId") long archivoId, @PathParam("estado") String estado, EvaluacionDTO evaluacion) throws Exception {
+    	return archivosEJB.evaluarArchivo(archivoId, estado, evaluacion);
     }
     
     private boolean esInvitado(){
diff --git a/addToGrupo.sh b/addToGrupo.sh
index 58333222..080ba613 100644
--- a/addToGrupo.sh
+++ b/addToGrupo.sh
@@ -4,7 +4,8 @@
 # todas las filas tienen que terminar con enter
 INPUT=usersGroup.csv
 
-SERVER=http:/localhost:8080/servicios #https://www.fing.edu.uy/proyectos/matefun/servicios
+SERVER=https://www.fing.edu.uy/proyectos/matefun/servicios
+#http:/localhost:8080/servicios 
 
 # parametros del script: usuario y pass
 read USER # =  $1
diff --git a/addUsers.sh b/addUsers.sh
index 1a91d7d3..af0d8fea 100644
--- a/addUsers.sh
+++ b/addUsers.sh
@@ -5,7 +5,8 @@
 # todas las filas tienen que terminar con enter
 INPUT=users.csv
 
-SERVER=http:/localhost:8080/servicios #https://www.fing.edu.uy/proyectos/matefun/servicios
+SERVER=https://www.fing.edu.uy/proyectos/matefun/servicios
+# http:/localhost:8080/servicios 
 
 # parametros del script: usuario y pass
 read USER # =  $1
@@ -13,6 +14,8 @@ stty -echo
 read PASS # =  $2
 stty echo
 
+echo "//$USER//$PASS//"
+
 token=$(curl --header "Content-Type: application/json" \
   --request POST \
   --data '{"cedula":"'$USER'","password":"'$PASS'"}' \
diff --git a/generate-war.sh b/generate-war.sh
index bc5cb836..9ff7b728 100644
--- a/generate-war.sh
+++ b/generate-war.sh
@@ -1,3 +1,4 @@
+# editar tambien: Frontend\ Angular\ 4/src/app/shared/config.ts
 cd Frontend\ Angular\ 4/
 ng build --prod --base-href /proyectos/matefun/
 cd ..
-- 
GitLab