Last active
October 23, 2017 15:34
-
-
Save mTorres/5100a15770e1990b1c92604aaddde096 to your computer and use it in GitHub Desktop.
Moodle - select all participants without profile image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelectorAll("img.img-circle") | |
.forEach(function(el) { | |
var td = el.parentElement.parentElement; | |
// Cal mirar si existeix td.nextSibling perquè a més de la taula de participants també hi ha la foto | |
// del perfil a dalt a la dreta. Segurament es podria millor amb table#participants img.imc-circle, no | |
// ho he provat, però... | |
if (td.nextSibling && td.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.innerHTML == "Mai") { | |
console.log(td.nextSibling.firstChild.firstChild.text); | |
//console.log(td.nextSibling.firstChild.firstChild.href); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelectorAll("img.defaultuserpic") // seleccionem totes les imatges que són de perfils sense imatge | |
.forEach( | |
function(el) { // per cada imatge apliquem la següent funció | |
var td = el.parentElement.parentElement; // seleccionem l'element HTML cel·la (td). Serà la segona de la fila | |
// mirem si la persona ha entrat mai o no (a l'última cel·la hi surt el text "Mai" | |
if (td.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.innerHTML != "Mai") { | |
// no ha entrat mai, per tant seleccionem la casella de verificació de la primera cel·la | |
td.previousElementSibling.firstChild.checked=true; | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment