fixes

parent 431b9387
......@@ -1358,8 +1358,8 @@ var GHCI_URL = window.location.protocol == 'http:' ? 'ws://' + window.location.h
/* unused harmony export GrupoDTO */
/* unused harmony export MoodleCourseDTO */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Usuario; });
var studentRoles = ["student"];
var teacherRoles = ["teacher", "editingteacher", "manager"];
var studentRoles = ["student", "estudiantematefun", "matefunstudent"];
var teacherRoles = ["teacher", "editingteacher", "manager", "docentematefun", "matefunteacher"];
var Configuracion = (function () {
function Configuracion() {
}
......@@ -1462,6 +1462,8 @@ var Usuario = (function () {
return this.tipo == "adminliceo";
};
Usuario.prototype.getCursosConRolDocente = function () {
if (!this.todosLosCursos)
return [];
return this.todosLosCursos.filter(function (c) { return c.roles.some(function (r) { return teacherRoles.some(function (opt) { return r.shortname === opt || r.name === opt; }); }); });
};
Usuario.prototype.checkForRolesMatch = function (userRoles) {
......@@ -1470,8 +1472,7 @@ var Usuario = (function () {
Usuario.prototype.cursosQueSoyAlumno = function () {
if (!this.todosLosCursos)
return [];
var options = ["student"];
return this.todosLosCursos.filter(function (c) { return c.roles.some(function (r) { return options.some(function (opt) { return r.shortname === opt || r.name === opt; }); }); });
return this.todosLosCursos.filter(function (c) { return c.roles.some(function (r) { return studentRoles.some(function (opt) { return r.shortname === opt || r.name === opt; }); }); });
};
return Usuario;
}());
This diff is collapsed.
import { Grupo } from './grupo';
const studentRoles = ["student"];
const teacherRoles = ["teacher","editingteacher","manager"];
const studentRoles = ["student", "estudiantematefun", "matefunstudent"];
const teacherRoles = ["teacher","editingteacher","manager", "docentematefun", "matefunteacher"];
export class Configuracion{
themeEditor: string;
......@@ -146,10 +146,9 @@ export class Usuario{
}
getCursosConRolDocente() : MoodleCourseDTO[]{
return this.todosLosCursos.filter (
(c: MoodleCourseDTO) => c.roles.some(
r => teacherRoles.some( opt => r.shortname===opt || r.name===opt)
));
if (!this.todosLosCursos)
return [];
return this.todosLosCursos.filter ((c: MoodleCourseDTO) => c.roles.some(r => teacherRoles.some( opt => r.shortname===opt || r.name===opt)));
}
checkForRolesMatch(userRoles){
......@@ -162,8 +161,7 @@ export class Usuario{
cursosQueSoyAlumno() : MoodleCourseDTO[] {
if (!this.todosLosCursos)
return [];
const options = ["student"];
return this.todosLosCursos.filter (c => c.roles.some (r => options.some (opt => r.shortname===opt || r.name===opt )));
return this.todosLosCursos.filter ((c: MoodleCourseDTO) => c.roles.some (r => studentRoles.some (opt => r.shortname===opt || r.name===opt )));
}
}
\ No newline at end of file
......@@ -8,9 +8,8 @@ import java.util.stream.Stream;
public class MoodleConstants {
public static final String course_enroll_default_roleid = "1";
public static final String privateFilesRootDir = "/";
public static final List<String> rolesValidosDocente = Arrays.asList("teacher","editingteacher","manager");
public static final List<String> rolesValidosAlumno = Arrays.asList("student");
public static final List<String> rolesValidosDocente = Arrays.asList("teacher","editingteacher","manager", "docentematefun", "matefunteacher");
public static final List<String> rolesValidosAlumno = Arrays.asList("student", "estudiantematefun", "matefunstudent");
public static final List<String> rolesValidos = Stream.concat(rolesValidosDocente.stream(), rolesValidosAlumno.stream()).collect(Collectors.toList());
public static final String matefunUserCustomServiceToken = "MatefunUser-CustomService-Token";
}
......@@ -19,11 +19,11 @@ public class MoodleFunctions {
//Capabilities requeridas para mod_assign_save_grade
// no tiene capabilities requeridas
public static final String mod_assign_get_submission_status = "mod_assign_get_submission_status"; //alumno
public static final String mod_assign_get_submission_status = "mod_assign_get_submission_status"; //alumno, docente
//Capabilities requeridas para mod_assign_get_submission_status
// mod/assign:view
public static final String core_user_get_course_user_profiles = "core_user_get_course_user_profiles"; //estudiante
public static final String core_user_get_course_user_profiles = "core_user_get_course_user_profiles"; //estudiante, docente
//Capabilities requeridas para core_user_get_course_user_profiles
// moodle/user:viewdetails,
// moodle/user:viewhiddendetails,
......@@ -31,15 +31,15 @@ public class MoodleFunctions {
// moodle/user:update,
// moodle/site:accessallgroups
public static final String core_files_get_files = "core_files_get_files"; //alumno, ShareFileMatefun
public static final String core_files_get_files = "core_files_get_files"; //alumno, docente, ShareFileMatefun
//Capabilities requeridas para core_files_get_files
// no tiene capabilities requeridas
public static final String core_group_get_course_user_groups = "core_group_get_course_user_groups"; //alumno
public static final String core_group_get_course_user_groups = "core_group_get_course_user_groups"; //alumno, docente
//Capabilities requeridas para core_group_get_course_user_groups
// moodle/course:managegroups
public static final String core_enrol_get_enrolled_users = "core_enrol_get_enrolled_users"; //ShareFileMatefun
public static final String core_enrol_get_enrolled_users = "core_enrol_get_enrolled_users"; //ShareFileMatefun, docente
//Capabilities requeridas para core_enrol_get_enrolled_users
// moodle/user:viewdetails,
// moodle/user:viewhiddendetails,
......@@ -50,19 +50,19 @@ public class MoodleFunctions {
// -- moodle/course:viewparticipants
// -- moodle/course:view
public static final String core_group_get_course_groups = "core_group_get_course_groups"; //estudiante, ShareFileMatefun
public static final String core_group_get_course_groups = "core_group_get_course_groups"; //estudiante, docente, ShareFileMatefun
//Capabilities requeridas para core_group_get_course_groups
// moodle/course:managegroups
public static final String mod_assign_get_assignments = "mod_assign_get_assignments"; //estudiante
public static final String mod_assign_get_assignments = "mod_assign_get_assignments"; //estudiante, docente
//Capabilities requeridas para mod_assign_get_assignments
// no tiene capabilities requeridas
public static final String core_user_agree_site_policy = "core_user_agree_site_policy";// todos
//Capabilities requeridas para core_webservice_get_site_info
//Capabilities requeridas para core_user_agree_site_policy
// no tiene capabilities requeridas
public static final String core_course_get_contents = "core_course_get_contents"; //estudiante
public static final String core_course_get_contents = "core_course_get_contents"; //estudiante, docente
//Capabilities requeridas para core_course_get_contents
// moodle/course:update,
// moodle/course:viewhiddencourses
......
......@@ -65,7 +65,8 @@ public class MoodleHelper {
if (tokens!=null && tokens.getToken() != null) {
List<StringPair> ret = new ArrayList<StringPair>();
ret.add(new StringPair (liceoBD.getMoodlewsservice() ,tokens.getToken()));
ret.add( new StringPair(MoodleConstants.matefunUserCustomServiceToken, liceoBD.getMoodleapiusertoken()));
ret.add(new StringPair(MoodleConstants.matefunUserCustomServiceToken, liceoBD.getMoodleapiusertoken()));
System.out.println("Tokens obtenidos:\n\t" + ret.get(0).getKey() + "\n\t" + ret.get(1).getKey());
return ret;
}else {
throw new MatefunException("No se puede obtener token para el servicio '" + liceoBD.getMoodlewsservice() + "' y el usuario '" + username + "'.");
......
......@@ -132,35 +132,39 @@ public class MoodleWS {
return target;
}
private static String getWho(StringPair moodleTokenPair) {
return moodleTokenPair.getKey().equals("serviciomatefun") ? " USUARIO" : " SUPERUSUARIO";
}
private static String getWho(List<StringPair> moodleTokenPairs) {
return moodleTokenPairs.get(0).getKey().equals("serviciomatefun") ? " USUARIO" : " SUPERUSUARIO";
}
public static JsonObject POST(StringPair moodleTokenPair, String moodleApiEndpoint, String functionName, Map<String, Object> params) throws Exception {
System.out.println(" ****(1.1) POST " + functionName + " token: " + moodleTokenPair.getKey());
System.out.println(" ****(1) POST " + functionName + getWho(moodleTokenPair));
return MAKE_REQUEST(POST, moodleApiEndpoint, functionName, params, Arrays.asList(moodleTokenPair), null, null, null);
}
public static JsonObject POST(InvitadoEJB invitadoEJB, String matefunToken, String functionName, Map<String, Object> params, boolean... forceSuperuser) throws Exception {
List<StringPair> moodleTokenPairs = invitadoEJB.getAllMoodleTokens(matefunToken);
if (forceSuperuser!=null && forceSuperuser.length>0 && forceSuperuser[0]) {
System.out.println(" ****(2.1) POST " + functionName + " SUPERUSER");
moodleTokenPairs = moodleTokenPairs.subList(moodleTokenPairs.size()-1, moodleTokenPairs.size());
}else {
System.out.println(" ****(2.2) POST " + functionName);
}
System.out.println(" ****(2) POST " + functionName + getWho(moodleTokenPairs));
return MAKE_REQUEST(POST, invitadoEJB.getMoodleApiEndpoint(matefunToken), functionName, params, moodleTokenPairs, invitadoEJB.getTiempoAccesoEJB(), invitadoEJB.getLiceoId(matefunToken), invitadoEJB.getMoodleUserId(matefunToken));
}
public static JsonObject GET(StringPair moodleTokenPair, String moodleApiEndpoint, String functionName, Map<String, Object> params) throws Exception {
System.out.println(" ****(1.1) GET " + functionName + " token: " + moodleTokenPair.getKey());
System.out.println(" ****(1) GET " + functionName + getWho(moodleTokenPair));
return MAKE_REQUEST(GET, moodleApiEndpoint, functionName, params, Arrays.asList(moodleTokenPair), null, null, null);
}
public static JsonObject GET(InvitadoEJB invitadoEJB, String matefunToken, String functionName, Map<String, Object> params, boolean... forceSuperuser) throws Exception {
List<StringPair> moodleTokenPairs = invitadoEJB.getAllMoodleTokens(matefunToken);
if (forceSuperuser!=null && forceSuperuser.length>0 && forceSuperuser[0]) {
System.out.println(" ****(2.1) GET " + functionName + " SUPERUSER");
moodleTokenPairs = moodleTokenPairs.subList(moodleTokenPairs.size()-1, moodleTokenPairs.size());
}else {
System.out.println(" ****(2.2) GET " + functionName);
}
System.out.println(" ****(2) GET " + functionName + getWho(moodleTokenPairs));
return MAKE_REQUEST(GET, invitadoEJB.getMoodleApiEndpoint(matefunToken), functionName, params, moodleTokenPairs, invitadoEJB.getTiempoAccesoEJB(), invitadoEJB.getLiceoId(matefunToken), invitadoEJB.getMoodleUserId(matefunToken));
}
......
#Generated by Maven Integration for Eclipse
#Sat Jun 27 22:58:57 BRT 2020
#Mon Jun 29 22:08:54 BRT 2020
version=0.0.1-SNAPSHOT
groupId=proygrado
m2e.projectName=Servidor JEE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment