Skip to content

Commit

Permalink
1.0.1 several fixes
Browse files Browse the repository at this point in the history
some fixes
  • Loading branch information
fapret committed Oct 17, 2024
1 parent c645bf6 commit 4e8d45c
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 100 deletions.
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

proyecto/java_microservice/build/classes/Carreras.class
proyecto/java_microservice/build/classes/Estudiante.class
proyecto/java_microservice/build/classes/EstudianteAddEvaluation.class
proyecto/java_microservice/build/classes/EstudianteAddPlan.class
proyecto/java_microservice/build/classes/Estudiantes/impl/CourseInscriptionImpl.class
proyecto/java_microservice/build/classes/Estudiantes/impl/EstudiantesFactoryImpl.class
proyecto/java_microservice/build/classes/Estudiantes/impl/EstudiantesPackageImpl.class
proyecto/java_microservice/build/classes/Estudiantes/impl/PlanInscriptionImpl.class
proyecto/java_microservice/build/classes/Estudiantes/impl/RootImpl.class
proyecto/java_microservice/build/classes/Estudiantes/impl/StudentEvaluationImpl.class
proyecto/java_microservice/build/classes/Estudiantes/impl/StudentImpl.class
*.class
proyecto/java_microservice/build/classes/EvalPlan.class
proyecto/java_microservice/build/classes/Evaluations.class
proyecto/java_microservice/build/classes/EvalUC.class
proyecto/java_microservice/build/classes/Facultad.class
proyecto/java_microservice/build/classes/modelSingleton.class
proyecto/java_microservice/build/classes/Plan.class
proyecto/java_microservice/build/classes/PlanUcs.class
proyecto/java_microservice/build/classes/Subjects.class
proyecto/java_microservice/build/classes/UnidadCurricular.class
*.class
lab3/org.eclipse.acceleo.SoaML2JavaWS/bin/org/eclipse/acceleo/SoaML2JavaWS/GenerateJavaWSfromSoaML.class
1 change: 1 addition & 0 deletions lab3/org.eclipse.acceleo.SoaML2JavaWS/bin/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/org/
/modelo/
65 changes: 36 additions & 29 deletions proyecto/front/js/seePlan.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,38 @@ function consultarPlan() {
var nodos_final = [];
var aristas = [];

function processSomeOfGraph(reqFather, aristas, materias, nodos_0){
for (let j = 1; j < (reqFather).length; j++) {
let a = reqFather[j];
let b = Object.keys(a);
let req = b[0];
if (req === "Coursed") {
let source_index = findKeyByValue(nodos_0, a['Coursed']);
let dest_index = findKeyByValue(nodos_0, materias);
let aaa = {
from: source_index,
to: dest_index,
color: "#0000FF",
arrows: "to",
dashes: true
};
aristas.push(aaa);
} else if (req === "Exam") {
let source_index = findKeyByValue(nodos_0, a['Exam']);
let dest_index = findKeyByValue(nodos_0, materias);
let aaa = {
from: source_index,
to: dest_index,
color: "#0000FF",
arrows: "to"
};
aristas.push(aaa);
} else if (req === "SomeOf") {
processSomeOfGraph(a['SomeOf'], aristas, materias, nodos_0);
}
}
}

fetch(url)
.then(response => response.json())
.then(materias => {
Expand All @@ -26,11 +58,12 @@ function consultarPlan() {
for (let i = 0; i < materias.length; i++) {
let apiUrl = `https://tmde-api.fapret.com:8443/curricula_microservice/Faculty/ucs?faculty=${faculty}&curricularUnit=` + materias[i];
fetch(apiUrl)
.then(response => {
.then(async response => {
if (!response.ok) {
throw new Error('No se pudo obtener la respuesta de la API');
}
return response.json(); // Parsear la respuesta JSON
return response.json();
//return await response.json(); // Parsear la respuesta JSON
})
.then(async data => {
const result = await getMaxRequirementLevel(facultyName, materias[i]);
Expand All @@ -49,33 +82,7 @@ function consultarPlan() {
if (data.Requirement && (data.Requirement).length > 0) {
//todo: si es un someof, tengo que ver cuales de las N se cumple, y mostrar solo las aristas de ella. por ejemplo, tprog y sus 2 vias de cursado
if (Object.keys(data.Requirement[0])[0] === "SomeOf") {
for (let j = 1; j < (data.Requirement[0]['SomeOf']).length; j++) {
let a = data.Requirement[0]['SomeOf'][j];
let b = Object.keys(a);
let req = b[0];
if (req === "Coursed") {
let source_index = findKeyByValue(nodos_0, a['Coursed']);
let dest_index = findKeyByValue(nodos_0, materias[i]);
let aaa = {
from: source_index,
to: dest_index,
color: "#0000FF",
arrows: "to",
dashes: true
};
aristas.push(aaa);
} else if (req === "Exam") {
let source_index = findKeyByValue(nodos_0, a['Exam']);
let dest_index = findKeyByValue(nodos_0, materias[i]);
let aaa = {
from: source_index,
to: dest_index,
color: "#0000FF",
arrows: "to"
};
aristas.push(aaa);
}
}
processSomeOfGraph(data.Requirement[0]['SomeOf'], aristas, materias[i], nodos_0);
} else {
let a = data.Requirement[0];
let b = Object.keys(a);
Expand Down
33 changes: 18 additions & 15 deletions proyecto/front/js/selectLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,21 @@ function findKeyByValue(obj, value) {
return null; // Return null if the value is not found
}

async function processSomeOf(someOfArray, req_values, facultyName) {
for (let j = 0; j < someOfArray.length; j++) {
const subReq = someOfArray[j];

if (subReq.Exam) {
req_values.push(await getMaxRequirementLevel(facultyName, subReq.Exam));
} else if (subReq.Coursed) {
req_values.push(await getMaxRequirementLevel(facultyName, subReq.Coursed));
} else if (subReq.SomeOf) {
// Recursive call for nested SomeOf
await processSomeOf(subReq.SomeOf, req_values, facultyName);
}
}
}

async function getMaxRequirementLevel(facultyName, cu_id) {
let apiUrl = `https://tmde-api.fapret.com:8443/curricula_microservice/Faculty/ucs?faculty=${facultyName}&curricularUnit=${cu_id}`;

Expand All @@ -139,27 +154,15 @@ async function getMaxRequirementLevel(facultyName, cu_id) {

for (let i = 0; i < data['Requirement'].length; i++) {
const subRequirement = data['Requirement'][i];

if (subRequirement.Exam) {
req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.Exam));
} else if (subRequirement.Coursed) {
req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.Coursed));
}
else if (subRequirement.SomeOf) {
for (let j = 0; j < subRequirement.SomeOf.length; j++) {
if (subRequirement.SomeOf[j].Exam)
req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.SomeOf[j].Exam));
else if (subRequirement.SomeOf[j].Coursed)
req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.SomeOf[j].Coursed));

}
} else if (subRequirement.SomeOf) {
await processSomeOf(subRequirement.SomeOf, req_values, facultyName);
}
}
let base = 1;
//if (data['Id'] === "P4" || data['Id'] === "LOGICA" || data["Id"] === "METNUM" || data["Id"] === "FBD" || data["Id"] === "PROLOG" || data["Id"] === "PROGFUN" || data["Id"] === "IIO")
//base = 2;

return base + Math.max(...req_values);
return req_values.length > 0 ? 1 + Math.max(...req_values) : 0;
} catch (error) {
console.error(error);
return 0;
Expand Down
117 changes: 62 additions & 55 deletions proyecto/front/js/viewTrajectory.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,38 @@ function mostrar_trayectoria() {

};

function processSomeOfGraph(reqFather, aristas, materias, nodos_0){
for (let j = 1; j < reqFather.length; j++) {
let a = reqFather[j];
let b = Object.keys(a);
let req = b[0];
if (req === "Coursed") {
let source_index = findKeyByValue(nodos_0, a['Coursed']);
let dest_index = findKeyByValue(nodos_0, materias);
let aaa = {
from: source_index,
to: dest_index,
color: "#0000FF",
arrows: "to",
dashes: true
};
aristas.push(aaa);
} else if (req === "Exam") {
let source_index = findKeyByValue(nodos_0, a['Exam']);
let dest_index = findKeyByValue(nodos_0, materias);
let aaa = {
from: source_index,
to: dest_index,
color: "#0000FF",
arrows: "to"
};
aristas.push(aaa);
} else if (req === "SomeOf") {
processSomeOfGraph(a['SomeOf'], aristas, materias, nodos_0);
}
}
}

fetch(url, options)
.then(response => response.json())
.then(materias => {
Expand All @@ -55,33 +87,7 @@ function mostrar_trayectoria() {
//PENDIENTE: si es un someof, tengo que ver cuales de las N se cumple,
//y mostrar solo las aristas de ella. por ejemplo, tprog y sus 2 vias de cursado
if (Object.keys(data.Requirement[0])[0] === "SomeOf") {
for (let j = 1; j < (data.Requirement[0]['SomeOf']).length; j++) {
let a = data.Requirement[0]['SomeOf'][j];
let b = Object.keys(a);
let req = b[0];
if (req === "Coursed") {
let source_index = findKeyByValue(nodos_0, a['Coursed']);
let dest_index = findKeyByValue(nodos_0, materias[i]);
let aaa = {
from: source_index,
to: dest_index,
color: "#0000FF",
arrows: "to",
dashes: true
};
aristas.push(aaa);
} else if (req === "Exam") {
let source_index = findKeyByValue(nodos_0, a['Exam']);
let dest_index = findKeyByValue(nodos_0, materias[i]);
let aaa = {
from: source_index,
to: dest_index,
color: "#0000FF",
arrows: "to"
};
aristas.push(aaa);
}
}
processSomeOfGraph(data.Requirement[0]['SomeOf'], aristas, materias[i], nodos_0);
}
else {
let a = data.Requirement[0];
Expand Down Expand Up @@ -222,6 +228,21 @@ function mostrar_trayectoria() {
})
}

async function processSomeOf(someOfArray, req_values, facultyName) {
for (let j = 0; j < someOfArray.length; j++) {
const subReq = someOfArray[j];

if (subReq.Exam) {
req_values.push(await getMaxRequirementLevel(facultyName, subReq.Exam));
} else if (subReq.Coursed) {
req_values.push(await getMaxRequirementLevel(facultyName, subReq.Coursed));
} else if (subReq.SomeOf) {
// Recursive call for nested SomeOf
await processSomeOf(subReq.SomeOf, req_values, facultyName);
}
}
}

async function getMaxRequirementLevel(facultyName, cu_id) {
let apiUrl = `https://tmde-api.fapret.com:8443/curricula_microservice/Faculty/ucs?faculty=${facultyName}&curricularUnit=${cu_id}`;

Expand All @@ -234,38 +255,24 @@ async function getMaxRequirementLevel(facultyName, cu_id) {

const data = await response.json();

if (data['Requirement'].length === 0)
if (data['Id'] === "P1") // porque P1 se dicta en el segundo semestre
return 1;
else
return 0;
else {
const req_values = [];

for (let i = 0; i < data['Requirement'].length; i++) {
const subRequirement = data['Requirement'][i];
if (!data['Requirement'] || data['Requirement'].length === 0)
return 0;
const req_values = [];

if (subRequirement.Exam) {
req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.Exam));
} else if (subRequirement.Coursed) {
req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.Coursed));
}
else if (subRequirement.SomeOf) {
for (let j = 0; j < subRequirement.SomeOf.length; j++) {
if (subRequirement.SomeOf[j].Exam)
req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.SomeOf[j].Exam));
else if (subRequirement.SomeOf[j].Coursed)
req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.SomeOf[j].Coursed));
for (let i = 0; i < data['Requirement'].length; i++) {
const subRequirement = data['Requirement'][i];

}
}
if (subRequirement.Exam) {
req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.Exam));
} else if (subRequirement.Coursed) {
req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.Coursed));
}
else if (subRequirement.SomeOf) {
await processSomeOf(subRequirement.SomeOf, req_values, facultyName);
}
let base = 1;
if (data['Id'] === "P4" || data['Id'] === "LOGICA" || data["Id"] === "METNUM" || data["Id"] === "FBD" || data["Id"] === "PROLOG" || data["Id"] === "PROGFUN" || data["Id"] === "IIO")
base = 2;

return base + Math.max(...req_values);
}

return req_values.length > 0 ? 1 + Math.max(...req_values) : 0;
} catch (error) {
console.error(error);
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public UnidadCurricular() {
private String getRequeriment(Requirement requerimiento) {
if(requerimiento instanceof NOT) {
NOT req = (NOT) requerimiento;
return "{ \"NOT\": \"" + getRequeriment(req.getRequirement()) + "\"}";
return "{ \"NOT\": " + getRequeriment(req.getRequirement()) + "}";
}
if(requerimiento instanceof Coursed) {
Coursed req = (Coursed) requerimiento;
Expand Down

0 comments on commit 4e8d45c

Please sign in to comment.