Initial commit

This commit is contained in:
Lyanis SOUIDI 2023-02-13 15:28:20 +01:00
commit 159d371ec6
26 changed files with 446 additions and 0 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# WIMS Tester
This extension modifies the [WIMS](https://en.wikipedia.org/wiki/WWW_Interactive_Multipurpose_Server) interface in order to be able to easily launch exercises on another server, this allows them to be tested without being graded.

21
_locales/ca/messages.json Normal file
View File

@ -0,0 +1,21 @@
{
"extensionDescription": {
"message": "Aquesta extensió modifica la interfície WIMS per tal de poder llançar fàcilment exercicis en un altre servidor, això permet provar-los sense ser qualificats."
},
"openOnServer": {
"message": "Obrir en el servidor "
},
"serverSelection": {
"message": "Servidor WIMS:"
},
"openCurrentPageOnServer": {
"message": "Obrir la pàgina actual en el servidor "
},
"save": {
"message": "Desar"
}
}

21
_locales/cn/messages.json Normal file
View File

@ -0,0 +1,21 @@
{
"extensionDescription": {
"message": "此扩展修改了 WIMS 界面,以便能够轻松地在另一台服务器上启动练习,这使得它们可以在不评分的情况下进行测试。"
},
"openOnServer": {
"message": "在服务器上打开 "
},
"serverSelection": {
"message": "WIMS服务器"
},
"openCurrentPageOnServer": {
"message": "在服务器上打开当前页面 "
},
"save": {
"message": "保存"
}
}

21
_locales/de/messages.json Normal file
View File

@ -0,0 +1,21 @@
{
"extensionDescription": {
"message": "Diese Erweiterung modifiziert die WIMS-Schnittstelle, um Aufgaben einfach auf einem anderen Server starten zu können, sodass sie ohne Benotung getestet werden können."
},
"openOnServer": {
"message": "Öffnen auf Server "
},
"serverSelection": {
"message": "WIMS-Server:"
},
"openCurrentPageOnServer": {
"message": "Öffne aktuelle Seite auf Server "
},
"save": {
"message": "Speichern"
}
}

21
_locales/en/messages.json Normal file
View File

@ -0,0 +1,21 @@
{
"extensionDescription": {
"message": "This extension modifies the WIMS interface in order to be able to easily launch exercises on another server, this allows them to be tested without being graded."
},
"openOnServer": {
"message": "Open on server "
},
"serverSelection": {
"message": "WIMS server:"
},
"openCurrentPageOnServer": {
"message": "Open current page on server "
},
"save": {
"message": "Save"
}
}

21
_locales/es/messages.json Normal file
View File

@ -0,0 +1,21 @@
{
"extensionDescription": {
"message": "Esta extensión modifica la interfaz de WIMS para poder lanzar ejercicios fácilmente en otro servidor, esto permite que sean evaluados sin ser calificados."
},
"openOnServer": {
"message": "Abrir en el servidor "
},
"serverSelection": {
"message": "servidor WIMS:"
},
"openCurrentPageOnServer": {
"message": "Abrir la página actual en el servidor "
},
"save": {
"message": "Guardar"
}
}

21
_locales/fr/messages.json Normal file
View File

@ -0,0 +1,21 @@
{
"extensionDescription": {
"message": "Cette extension modifie l'interface WIMS afin de pouvoir lancer facilement des exercices sur un autre serveur, cela permet de les tester sans être notés."
},
"openOnServer": {
"message": "Ouvrir sur le serveur "
},
"serverSelection": {
"message": "Serveur WIMS :"
},
"openCurrentPageOnServer": {
"message": "Ouvrir la page actuelle sur le serveur "
},
"save": {
"message": "Enregistrer"
}
}

21
_locales/it/messages.json Normal file
View File

@ -0,0 +1,21 @@
{
"extensionDescription": {
"message": "Questa estensione modifica l'interfaccia WIMS per poter lanciare facilmente gli esercizi su un altro server, questo permette loro di essere testati senza essere valutati."
},
"openOnServer": {
"message": "Apri sul server "
},
"serverSelection": {
"message": "Server WIMS:"
},
"openCurrentPageOnServer": {
"message": "Apri la pagina attuale sul server "
},
"save": {
"message": "Salva"
}
}

21
_locales/jp/messages.json Normal file
View File

@ -0,0 +1,21 @@
{
"extensionDescription": {
"message": "この拡張機能は、WIMS インターフェイスを変更して、別のサーバーで演習を簡単に開始できるようにします。これにより、採点せずにテストすることができます。"
},
"openOnServer": {
"message": "サーバー上で開く "
},
"serverSelection": {
"message": "WIMS サーバー:"
},
"openCurrentPageOnServer": {
"message": "サーバー上で現在のページを開く "
},
"save": {
"message": "保存する"
}
}

21
_locales/nl/messages.json Normal file
View File

@ -0,0 +1,21 @@
{
"extensionDescription": {
"message": "Deze extensie past de WIMS-interface aan om oefeningen gemakkelijk op een andere server te kunnen starten, waardoor ze kunnen worden getest zonder dat ze worden beoordeeld."
},
"openOnServer": {
"message": "Openen op server "
},
"serverSelection": {
"message": "WIMS-server:"
},
"openCurrentPageOnServer": {
"message": "Open huidige pagina op server "
},
"save": {
"message": "Opslaan"
}
}

21
_locales/si/messages.json Normal file
View File

@ -0,0 +1,21 @@
{
"extensionDescription": {
"message": "Toto rozšírenie upravuje rozhranie WIMS, aby bolo možné ľahko spúšťať cvičenia na inom serveri, čo umožňuje ich testovanie bez hodnotenia."
},
"openOnServer": {
"message": "Otvoriť na serveri "
},
"serverSelection": {
"message": "WIMS server:"
},
"openCurrentPageOnServer": {
"message": "Otvoriť aktuálnu stránku na serveri "
},
"save": {
"message": "Uložiť"
}
}

BIN
icons/128-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

BIN
icons/128-light.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
icons/16-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

BIN
icons/16-light.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

BIN
icons/32-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
icons/32-light.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
icons/48-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
icons/48-light.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
icons/96-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
icons/96-light.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

24
index.html Normal file
View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>WIMS Tester</title>
<style>
body {
font-family: system-ui;
text-align: center;
margin: 10px 25px 25px 25px;
}
</style>
</head>
<body>
<h1>WIMS Tester</h1>
<form action="">
<fieldset id="servers">
<legend></legend>
</fieldset>
</form>
<a href=""></a>
<script src="script.js"></script>
</body>
</html>

47
inject.js Normal file
View File

@ -0,0 +1,47 @@
function createLink(name, oldURL, newURL) {
let e = document.createElement("a");
e.className = "_wims_tester_link";
e.innerText = "[" + browser.i18n.getMessage("openOnServer") + `'${name}']`;
let link = new URL(newURL);
link.search = new URL(oldURL).search;
e.href = link.toString();
e.target = "_blank";
return e;
}
function updateLink(e, name, url) {
e.innerText = "[" + browser.i18n.getMessage("openOnServer") + `'${name}']`;
let link = new URL(url);
link.search = new URL(e.href).search;
e.href = link.toString();
}
async function load() {
let serversList = await fetch(browser.runtime.getURL("servers.json")).then((response) => response.json()).then((data) => data["servers"]);
let preferredServer = await browser.storage.sync.get('preferredServer').then(item => item.preferredServer);
if (typeof preferredServer === "undefined" || !preferredServer.hasOwnProperty("url")) preferredServer = serversList[0];
let list = document.getElementsByClassName("wims_exo_item");
for (let item of list) item.firstElementChild.after(createLink(preferredServer.name, item.firstElementChild.href, preferredServer.url));
list = document.querySelectorAll('a[target="wims_exo"]');
for (let item of list) item.after(createLink(preferredServer.name, item.href, preferredServer.url));
list = document.querySelectorAll('ul[class="wims_home_result_list"] > li');
for (let item of list) item.firstElementChild.after(createLink(preferredServer.name, item.firstElementChild.href, preferredServer.url));
}
let style = document.createElement('style');
style.textContent = "._wims_tester_link::before { content: ' '; } ._wims_tester_link { font-size: small; color: black; }";
document.head.append(style);
load();
browser.storage.sync.onChanged.addListener((changes) => {
const changedItems = Object.keys(changes);
for (const item of changedItems) {
if (item == "preferredServer") {
document.querySelectorAll('a[class="_wims_tester_link"]').forEach(e => updateLink(e, changes[item].newValue.name, changes[item].newValue.url));
}
}
});

61
manifest.json Normal file
View File

@ -0,0 +1,61 @@
{
"manifest_version": 2,
"name": "WIMS Tester",
"author": "Lyanis Souidi",
"version": "1.0",
"browser_specific_settings": {
"gecko": {
"id": "wims-tester@lyanis.sh"
}
},
"description": "__MSG_extensionDescription__",
"homepage_url": "https://github.com/lyanissouidi/wims-tester",
"default_locale": "en",
"browser_action": {
"default_title": "WIMS Tester",
"default_popup": "index.html",
"browser_style": true,
"default_icon": {
"16": "icons/16-light.png",
"32": "icons/32-light.png",
"48": "icons/48-light.png",
"96": "icons/96-light.png",
"128": "icons/128-light.png"
},
"theme_icons": [{
"light": "icons/16-light.png",
"dark": "icons/16-dark.png",
"size": 16
}, {
"light": "icons/32-light.png",
"dark": "icons/32-dark.png",
"size": 32
}, {
"light": "icons/48-light.png",
"dark": "icons/48-dark.png",
"size": 48
}, {
"light": "icons/96-light.png",
"dark": "icons/96-dark.png",
"size": 96
}, {
"light": "icons/128-light.png",
"dark": "icons/128-dark.png",
"size": 128
}]
},
"content_scripts": [
{
"matches": ["*://*/*wims.cgi*"],
"js": ["inject.js"]
}
],
"permissions": ["tabs", "storage"],
"icons": {
"16": "icons/16-light.png",
"32": "icons/32-light.png",
"48": "icons/48-light.png",
"96": "icons/96-light.png",
"128": "icons/128-light.png"
}
}

37
script.js Normal file
View File

@ -0,0 +1,37 @@
document.getElementsByTagName("legend")[0].innerText = browser.i18n.getMessage("serverSelection");
async function updateLink(name, url) {
let link = new URL(url);
let tabURL = await browser.tabs.query({currentWindow: true, active: true}).then(tabs => tabs[0].url);
link.search = new URL(tabURL).search;
let a = document.getElementsByTagName("a")[0];
a.href = link.toString();
a.innerText = browser.i18n.getMessage("openCurrentPageOnServer") + `'${name}'`;
}
async function load(qualifiedName, value) {
let serversList = await fetch(browser.runtime.getURL("servers.json")).then((response) => response.json()).then((data) => data["servers"]);
let preferredServer = await browser.storage.sync.get('preferredServer').then(item => item.preferredServer);
if (typeof preferredServer === "undefined" || !preferredServer.hasOwnProperty("url")) preferredServer = serversList[0];
for (let i = 0; i < serversList.length; i++) {
let div = document.createElement("div");
let input = document.createElement("input");
input.type = "radio";
input.id = serversList[i].url;
input.name = "server";
input.value = serversList[i].name;
if (preferredServer.url === serversList[i].url) input.checked = true;
input.addEventListener("click", saveServer);
div.appendChild(input);
let label = document.createElement("label");
label.for = serversList[i].name;
label.innerText = serversList[i].name;
div.appendChild(label);
document.getElementById("servers").appendChild(div);
}
updateLink(preferredServer.name, preferredServer.url);
}
load();
function saveServer(e) {
browser.storage.sync.set({ preferredServer: { name: e.target.value, url: e.target.id } });
updateLink(e.target.value, e.target.id);
}

64
servers.json Normal file
View File

@ -0,0 +1,64 @@
{
"servers": [
{
"name": "Université Côte d'Azur",
"url": "https://wims.univ-cotedazur.fr/wims/wims.cgi"
},
{
"name": "CNRS",
"url": "https://wims.math.cnrs.fr/wims/wims.cgi"
},
{
"name": "Université Caen Normandie",
"url": "https://wims.unicaen.fr/wims/wims.cgi"
},
{
"name": "Université Sorbonne Paris Nord",
"url": "https://sercalwims.ig-edu.univ-paris13.fr/wims/wims.cgi"
},
{
"name": "Université Paris-Saclay",
"url": "https://wimsauto.universite-paris-saclay.fr/wims/wims.cgi"
},
{
"name": "Aix-Marseille Université",
"url": "https://wims.univ-mrs.fr/wims/wims.cgi"
},
{
"name": "Université de Picardie",
"url": "https://www.u-picardie.fr/wims/wims.cgi"
},
{
"name": "Académie de Versailles",
"url": "https://euler-ressources.ac-versailles.fr/wims/wims.cgi"
},
{
"name": "Université de Nice",
"url": "http://wims.espe-nice-toulon.fr/wims/wims.cgi"
},
{
"name": "Université Littoral Côte d'Opale",
"url": "http://wims.univ-littoral.fr/wims/wims.cgi"
},
{
"name": "Lycée polyvalent Diderot Paris",
"url": "http://www.f-lasne.com/wims/wims.cgi"
},
{
"name": "Università degli Studi di Milano-Bicocca",
"url": "https://wims.matapp.unimib.it/wims/wims.cgi"
},
{
"name": "Universitat Rovira i Virgili",
"url": "http://wims-deq.urv.cat/wims/wims.cgi"
},
{
"name": "Xarxa Telemàtica Educativa de Catalunya",
"url": "http://insbaixpenedes.xtec.cat/wims/wims.cgi"
},
{
"name": "Uniwersytet Mikołaja Kopernika",
"url": "https://cosmo.astro.uni.torun.pl/wims/wims.cgi"
}
]
}