Commit 4667babb authored by Sylvain Coulange's avatar Sylvain Coulange
Browse files

ajout addStat

parent 77502f3e
......@@ -72,6 +72,7 @@ urlpatterns = [
path('users/', user_views.usersPage, name='users'),
path('users/<str:username>/', user_views.userInfo, name='userInfo'),
path('downloadTraces/', csrf_exempt(user_views.downloadTraces), name='downloadTraces'),
path('addStat/', csrf_exempt(user_views.addStat))
# path('getActivity/', csrf_exempt(clavier_views.getActivity)),
# path('switchstress/', clavier_views.openSwitchStress),
......
async function addStat(modul, lang=thisPageLang) {
// ON EMBALLE TOUT ÇA
var colis = {
app: "phonographe",
module: modul,
lang: lang
}
// Paramètres d'envoi
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(colis)
};
// ENVOI
await fetch('/addStat/', options);
}
\ No newline at end of file
......@@ -149,6 +149,7 @@ function recupPhon(identifiant){
//////////////////////////////
//// IF NOT modeGraphies
//// → écrire directement le phonème
document.getElementById('checkWordValid').style.display = "none";
var rectId = identifiant
var boucheId = rectId.replace("rect","bouche")
......@@ -1206,6 +1207,8 @@ function checkWord() {
}
console.log(ww);
var wordPhonoSpansList = []
if (thisPageLang != "dz") {
let cptw = 0;
for (w of ww) {
......@@ -1229,59 +1232,124 @@ function checkWord() {
if (cptw == ww.length) fin = true;
document.getElementById('checkWordValid').style.display = "none";
document.getElementById('checkWordLoading').style.display = "block";
reqWiki(word,phono.trim(),thisPageLang,listSpans,fin);
wordPhonoSpansList.push( {'w':word, 't':phono.trim(), 'spans':listSpans} );
}
reqWiki(wordPhonoSpansList,thisPageLang);
} else {
window.alert("Cette fonctionnalité n'est pas encore disponible pour cette langue");
}
}
async function reqWiki(word,phono,lang,listSpans,fin) {
console.log("reqWiki",word,phono,lang,listSpans,fin);
async function reqWiki(wordPhonoSpansList,lang) {
// wordPhonoSpansList = {
// {
// 'w':"orthographe",
// 't':"transcriptionAPI",
// 'spans':['id1','id2','id3']
// },
// {w2},
// {w3}
// }
console.log("reqWiki",wordPhonoSpansList);
// Paramètres d'envoi
const options = {
method: 'GET',
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
},
body: JSON.stringify({'wordPhonoSpansList':wordPhonoSpansList, 'lang':lang})
}
const response = await fetch(`https://wikicolor.alem-app.fr/checkWord?w=${word}&t=${phono}&lang=${lang}`, options);
const response = await fetch(`https://wikicolor.alem-app.fr/checkWordList/`, options); // `http://127.0.0.1:8000/checkWordList/`
const data = await response.json();
console.log(data);
for (span of listSpans){
var el = document.getElementById(span);
var title = []
for (let x=0; x<data.rep.length; x++){
var word = data.rep[x];
for (span of wordPhonoSpansList[x].spans){
var el = document.getElementById(span);
var title = []
el.classList.remove("FBortho");
el.classList.remove("FBphonoCarte");
el.classList.remove("FBphonoGraphCarte");
el.classList.remove("FBphono");
el.classList.remove("FBphonoGraph");
if (!word.t) {
if (el.classList[0]=="carte" || el.classList[0]=="carteZh") el.classList.add("FBphonoCarte"); // que bouches et mandarin
else el.classList.add("FBphono");
title.push("problème de phonologie")
}
if (!word.w) {
if (!el.classList.contains("carte")) el.classList.add("FBortho"); // tous sauf bouches
title.push("problème d'orthographe")
} else if (word.t && !word.wt) {
if (el.classList[0]=="carte" || el.classList[0]=="carteZh") el.classList.add("FBphonoGraphCarte"); // que bouches et mandarin
else el.classList.add("FBphonoGraph");
title.push("orthographe et phonologie existantes mais pas pour le même mot")
}
el.title = title.join("\n");
}
}
el.classList.remove("FBortho");
el.classList.remove("FBphonoCarte");
el.classList.remove("FBphonoGraphCarte");
el.classList.remove("FBphono");
el.classList.remove("FBphonoGraph");
document.getElementById('checkWordLoading').style.display = "none";
document.getElementById('checkWordValid').style.display = "block";
}
///// VIEUX --- 1 REQUETE PAR MOT (trop lent)
// async function reqWiki(word,phono,lang,listSpans,fin) {
// console.log("reqWiki",word,phono,lang,listSpans,fin);
// // Paramètres d'envoi
// const options = {
// method: 'GET',
// headers: {
// 'Content-Type': 'application/json'
// }
// }
// const response = await fetch(`https://wikicolor.alem-app.fr/checkWord?w=${word}&t=${phono}&lang=${lang}`, options);
// const data = await response.json();
// console.log(data);
// for (span of listSpans){
// var el = document.getElementById(span);
// var title = []
// el.classList.remove("FBortho");
// el.classList.remove("FBphonoCarte");
// el.classList.remove("FBphonoGraphCarte");
// el.classList.remove("FBphono");
// el.classList.remove("FBphonoGraph");
if (!data.rep.t) {
if (el.classList[0]=="carte" || el.classList[0]=="carteZh") el.classList.add("FBphonoCarte"); // que bouches et mandarin
else el.classList.add("FBphono");
title.push("problème de phonologie")
}
// if (!data.rep.t) {
// if (el.classList[0]=="carte" || el.classList[0]=="carteZh") el.classList.add("FBphonoCarte"); // que bouches et mandarin
// else el.classList.add("FBphono");
// title.push("problème de phonologie")
// }
if (!data.rep.w) {
if (!el.classList.contains("carte")) el.classList.add("FBortho"); // tous sauf bouches
title.push("problème d'orthographe")
} else if (data.rep.t && !data.rep.wt) {
if (el.classList[0]=="carte" || el.classList[0]=="carteZh") el.classList.add("FBphonoGraphCarte"); // que bouches et mandarin
else el.classList.add("FBphonoGraph");
title.push("orthographe et phonologie existantes mais pas pour le même mot")
}
// if (!data.rep.w) {
// if (!el.classList.contains("carte")) el.classList.add("FBortho"); // tous sauf bouches
// title.push("problème d'orthographe")
// } else if (data.rep.t && !data.rep.wt) {
// if (el.classList[0]=="carte" || el.classList[0]=="carteZh") el.classList.add("FBphonoGraphCarte"); // que bouches et mandarin
// else el.classList.add("FBphonoGraph");
// title.push("orthographe et phonologie existantes mais pas pour le même mot")
// }
el.title = title.join("\n");
}
if (fin) {
document.getElementById('checkWordLoading').style.display = "none";
document.getElementById('checkWordValid').style.display = "block";
}
}
\ No newline at end of file
// el.title = title.join("\n");
// }
// if (fin) {
// document.getElementById('checkWordLoading').style.display = "none";
// document.getElementById('checkWordValid').style.display = "block";
// }
// }
\ No newline at end of file
......@@ -26,6 +26,7 @@ if (serie.nom.length == 0) {
console.log("Création d'une nouvelle série");
} else {
console.log('Édition de la série',serie.nom);
addStat("phonoplayer-editserie",thisPageLang);
for (i=0; i<listeMots.length; i++) {
listeMotsGen.push(listeMots[i].motGenerique)
......
......@@ -118,7 +118,7 @@ function selectLang(lang, p="default", f="default"){
}
selectPanneau(p);
selectFidel(f);
addStat("phonographe",lang);
}
function selectPanneau(p){
......
......@@ -31,7 +31,6 @@ if (videoDeb==1) {
audioMode = true
}
selectLang("fr");
function selectLang(lang, p="default", f="default"){
console.log('SelectLang()',lang)
......@@ -115,7 +114,6 @@ function selectPanneau(p){
}
}
/// ACTIONS LORS DU CLIC SUR PHONEME
var cartes = [] // initialisation de la liste des cartes disponible (0 au début)
var ligneCible = "rep"
......@@ -205,6 +203,7 @@ function demarrer() {
document.getElementById('bravo_audio').style.display = "block"
}
saveTrace(`start serie ${serieName}`)
addStat("phonoplayer",thisPageLang);
loadNext()
}
......
......@@ -276,6 +276,7 @@
{% endblock %}
{% block javascript %}
<script type="text/javascript" src="{% static 'js/addStat.js' %}"></script>
<script type="text/javascript" src="{% static 'json/fidel_arabe.js' %}"></script>
<script type="text/javascript" src="{% static 'js/id2class.js' %}"></script>
<script type="text/javascript" src="{% static 'js/phon2api.js' %}"></script>
......
......@@ -202,6 +202,7 @@
{% endblock content %}
{% block javascript %}
<script type="text/javascript" src="{% static 'js/addStat.js' %}"></script>
<script type="text/javascript" src="{% static 'js/id2class.js' %}"></script>
<script type="text/javascript" src="{% static 'js/phon2api.js' %}"></script>
<script type="text/javascript" src="{% static 'js/interface.js' %}"></script>
......
......@@ -339,6 +339,7 @@ phon_d, phon_r_maj, phon_o_maj, phon_m"></textarea>
{% block javascript %}
<script type="text/javascript" src="{% static 'js/addStat.js' %}"></script>
<script type="text/javascript" src="{% static 'js/interface_basic.js' %}"></script>
<!-- JQUERY FILE UPLOAD SCRIPTS -->
......
......@@ -52,3 +52,10 @@ class SynthVocRecord(models.Model):
def __str__(self):
return f'VocRecord n°{self.id} \n\t[{self.ipa}] {self.lang} {self.voix}\n\tCompteur d\'écoutes: {self.cptEcoute}'
class appstats(models.Model):
date = models.DateTimeField(auto_now_add=True, auto_now=False)
app = models.CharField(max_length=30)
module = models.CharField(max_length=30)
ip = models.CharField(max_length=30)
lang = models.CharField(max_length=10)
......@@ -11,7 +11,7 @@ from django.contrib.auth.models import Group, User
from .forms import UserLoginForm, UserRegisterForm, CreateSerieForm, UserUpdateForm, ProfileUpdateForm, UploadAudioForm, UploadImageForm, UploadVideoForm
from clavier.models import Serie, Audio, Image, Video
from .models import Trace, SynthVocTrace, SynthVocRecord
from .models import Trace, SynthVocTrace, SynthVocRecord, appstats
from .decorators import unauthenticated_user, allowed_users
from user_agents import parse
......@@ -597,4 +597,22 @@ def removeFile(request):
os.remove(fileName)
return JsonResponse({})
\ No newline at end of file
def addStat(request):
colis = json.loads(request.body)
app = colis["app"]
module = colis["module"]
lang = colis["lang"]
newStat = appstats()
newStat.app = app
newStat.module = module
newStat.ip = get_client_ip(request)
newStat.lang = lang
# if newStat.ip!="127.0.0.1": newStat.save()
newStat.save()
return JsonResponse({})
\ No newline at end of file
Supports Markdown
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