Commit 7acb517e authored by Ronald Perez's avatar Ronald Perez

Archivos fuentes de Plugins English

parent 7ec0a2db
El **Plugin NoteMyProgress** es una extensión para el navegador ``Google Chrome``. Esta versión ha sido desarrollada para dar soporte únicamente a la plataforma MOOC ``Coursera``.
Objetivo del desarrolo del proyecto
=======================
El desarrollo de esta herramienta es parte del proyecto del tesis de doctorado, del estudiante ``Ronald Pérez Álvarez``, para el programa de ``Ciencias de la Ingeniería,
área de la Computación de la Pontificia Universidad Católica de Chile``.
El objetivo de este proyecto es diseñar e implementar una herramienta educacional que apoye las estrategias de autorregulación
de los estudiantes en los Cursos Masivos Abiertos en Línea (MOOCs- Massive Open Online Courses).
Configuración para integración con el dashboard NoteMyProgress.
=======================
Para cambiar la configuración y rediccionarlo a un nuevo dominio correspondiente a su propio servidor. Se deben realizar los siguientes pasos:
1. Descomprimir la carpeta descargada ``chrome_extension_v10.zip``
2. Abrir el archivo ``"global_configurations.js"`` ubicado en la carpeta ``/share/assets/js/``y cambiar la información referente a las variables, en el caso correspondiente a production.
* **root_web** = "http://xxx.xx.xxx.xxx/";
* **root** = 'http://xxx.xx.xxx.xxx/api';
3. Abrir el archivo ``"manifest"`` ubicado en la raíz de la carpeta y cambiar la variable ``name`` por ``NoteMyProgress`` + acrónimo de su universidad.
Implementación del Plugin NoteMyProgress.
=======================
El siguiente paso para la implementación del plugin es subirlo al web store de google. Para realizar este proceso realizar los pasos mostrados en el [tutorial oficial](https://chrome.google.com/webstore/developer/dashboard) de Chrome Web Store.
Para revisar el tutorial debes ingresar con tu cuenta de google.
Las carpetas ``screenshots`` y ``mosaicos`` contiene las imágenes requeridas durante el proceso.
Este software es compartido bajo licencia Creative Commons, que permite permite a otros distribuir, ‘remezclar’, retocar y crear a partir de la obra de modo no comercial, siempre y cuando den los créditos al Proyecto LALA (586120-EPP-1-2017-1-ES-EPPKA2-CBHE-JP) y al proyecto Fondecyt (11150231); y licencien sus nuevas creaciones bajo nuestras mismas condiciones.
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.
{
"manifest_version": 2,
"name":"NoteMyProgress",
"description": "Esta extensión te permite monitorear tu proceso de aprendizaje durante tus sesiones de estudio en la plataforma MOOC.",
"version":"1.3",
"icons": { "128": "share/assets/img/icon128.png", "48": "share/assets/img/icon48.png", "16": "share/assets/img/icon16.png"},
"browser_action":{
"default_icon":"share/assets/img/icon19.png",
"default_tittle":"NoteMyProgress",
"default_popup":"share/views/login.html"
},
"web_accessible_resources": [
"share/assets/img/*"
],
"background":{
"scripts": [
"share/assets/js/manage/context.js",
"share/assets/js/eventPage.js",
"share/assets/lib/js/jquery-3.2.1.js",
"share/assets/js/manage/apiTools.js",
"share/assets/js/manage/chromeTools.js",
"share/assets/js/manage/tabsManager.js",
"share/assets/js/manage/visitedUrl.js",
"share/assets/js/manage/sessionManager.js"
],
"persistent":true
},
"permissions":[
"<all_urls>",
"tabs",
"storage"
],
"content_security_policy": "script-src 'self' 'unsafe-eval' https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.4/Chart.min.js; object-src 'self'"
}
// Shared var and functions
function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function validate_token () {
var token = getToken(function(saved_token){
if(saved_token){
var req = new XMLHttpRequest();
req.open('GET', root + '/validate_token', true);
req.setRequestHeader("Content-type", "application/json");
req.setRequestHeader("Authorization", "Bearer " + saved_token);
req.onreadystatechange = function (aEvt) {
console.log(req.response);
if (req.readyState == 4) {
if(req.status == 200) {
console.log('El token guardado es valido');
//Chronometer starts
window.location.href = "home.html";
}
else {
$('body').children().show();
}
}
};
req.send();
}
else {
$('body').children().show();
}
});
}
function login(email, password) {
var req = new XMLHttpRequest();
req.open('POST', root + '/auth_user', true);
req.setRequestHeader("Content-type", "application/json");
req.onreadystatechange = function (aEvt) {
if (req.readyState == 4) {
// Login succesful
if(req.status == 200) {
$('#error-message').html('');
var token = JSON.parse(req.response).auth_token;
saveToken(token, function () {
//chrome.extension.sendMessage({action: "loadExistingTabs"});
window.location.href = "home.html";
});
}
// Login error
else {
$('#error-message').html('<p>Invalid email or password, please try again.</p>')
}
}
};
var data = JSON.stringify({"email": email, "password": password});
req.send(data);
}
// Extracted from https://stackoverflow.com/questions/8847109/formatting-the-date-time-with-javascript
function strftime(sFormat, date) {
if (!(date instanceof Date)) date = new Date();
var nDay = date.getDay(),
nDate = date.getDate(),
nMonth = date.getMonth(),
nYear = date.getFullYear(),
nHour = date.getHours(),
aDays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
aMonths = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
aDayCount = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334],
isLeapYear = function() {
return (nYear%4===0 && nYear%100!==0) || nYear%400===0;
},
getThursday = function() {
var target = new Date(date);
target.setDate(nDate - ((nDay+6)%7) + 3);
return target;
},
zeroPad = function(nNum, nPad) {
return ('' + (Math.pow(10, nPad) + nNum)).slice(1);
};
return sFormat.replace(/%[a-z]/gi, function(sMatch) {
return {
'%a': aDays[nDay].slice(0,3),
'%A': aDays[nDay],
'%b': aMonths[nMonth].slice(0,3),
'%B': aMonths[nMonth],
'%c': date.toUTCString(),
'%C': Math.floor(nYear/100),
'%d': zeroPad(nDate, 2),
'%e': nDate,
'%F': date.toISOString().slice(0,10),
'%G': getThursday().getFullYear(),
'%g': ('' + getThursday().getFullYear()).slice(2),
'%H': zeroPad(nHour, 2),
'%I': zeroPad((nHour+11)%12 + 1, 2),
'%j': zeroPad(aDayCount[nMonth] + nDate + ((nMonth>1 && isLeapYear()) ? 1 : 0), 3),
'%k': '' + nHour,
'%l': (nHour+11)%12 + 1,
'%m': zeroPad(nMonth + 1, 2),
'%M': zeroPad(date.getMinutes(), 2),
'%p': (nHour<12) ? 'AM' : 'PM',
'%P': (nHour<12) ? 'am' : 'pm',
'%s': Math.round(date.getTime()/1000),
'%S': zeroPad(date.getSeconds(), 2),
'%u': nDay || 7,
'%V': (function() {
var target = getThursday(),
n1stThu = target.valueOf();
target.setMonth(0, 1);
var nJan1 = target.getDay();
if (nJan1!==4) target.setMonth(0, 1 + ((4-nJan1)+7)%7);
return zeroPad(1 + Math.ceil((n1stThu-target)/604800000), 2);
})(),
'%w': '' + nDay,
'%x': date.toLocaleDateString(),
'%X': date.toLocaleTimeString(),
'%y': ('' + nYear).slice(2),
'%Y': nYear,
'%z': date.toTimeString().replace(/.+GMT([+-]\d+).+/, '$1'),
'%Z': date.toTimeString().replace(/.+\((.+?)\)$/, '$1')
}[sMatch] || sMatch;
});
}
// Close button
$('a.close-nav').click(function () {
window.close();
});
// Log out button
$('#log-out').click(function () {
chrome.extension.sendMessage({action: "logout"});
});
// Log out listener
chrome.extension.onMessage.addListener(
function(response, sender, sendResponse) {
if(response.action == 'logoutDone') {
window.location.href = "login.html";
}
}
);
chrome.extension.onMessage.addListener(
function(request, sender, sendResponse) {
//console.log('MESSAGE: ' + request.action);
switch (request.action) {
case "changePassword":
chrome.tabs.create({ url: root_web + forgotPasswordUrl });
break;
case "openAgreement":
chrome.tabs.create({ url: root_web + agreementUrl });
break;
case "loadExistingTabs":
getCurrentSession(function() {
console.log(urlHistory);
loadExistingTabs();
});
break;
case "getEffectiveTime":
getCurrentSession(function() {
getEffectiveTime(function(response) {
chrome.extension.sendMessage({action: "chartDataResponse", chartData: response});
//sendResponse(response);
});
});
break;
case "logout":
getCurrentSession(function() {
logout(function() {
chrome.extension.sendMessage({action: "logoutDone"});
//sendResponse();
});
});
break;
case "on1sec":
setTimeout(function() {chrome.extension.sendMessage({action: "1secElapsed"})}, 1000);
break;
case "getIsTrackingEnabled":
chrome.extension.sendMessage({action: "isTrackingEnabled", isTrackingEnabled: isTrackingEnabled});
break;
case "setIsTrackingEnabled":
if(request.isTrackingEnabled) {
if(currentSessionId) {
loadExistingTabs();
isTracking = true;
} else {
isTracking = false;
}
} else {
urlHistory = new Array();
isTracking = false;
}
isTrackingEnabled = request.isTrackingEnabled;
break;
}
}
);
chrome.tabs.onUpdated.addListener(function(tabID, changeInfo, tab) {
if(tab.status == "complete" && changeInfo.status == "complete" && tab.url.length > 0){
// First we check if it is an LMS site
if(matchAnyLMS(tab.url)) {
if((!currentSessionId || !isTracking) && isTrackingEnabled) {
startSession();
}
resetSessionTimer();
}
if(isTracking) {
changeCurrentURL(tabID);
updateTabState(tabID, tab.windowId, tab.url);
}
}
});
chrome.tabs.onRemoved.addListener(function(tabid) {
if(isTracking) {
console.log("Se cerro el tab: " + tabid);
removeTab(tabid);
}
});
chrome.windows.onRemoved.addListener(function(windowid) {
if(isTracking) {
changeCurrentURL(null);
removeTabsFromWindow(windowid);
}
});
chrome.tabs.onActiveChanged.addListener(function(tabID) {
if(isTracking) {
console.log("Nuevo tab activo: " + tabID);
changeCurrentURL(tabID);
}
});
root = "";
root_web = ""
environment = "production";
switch (environment) {
case "development":
root = 'http://localhost:3000/api';
root_web = 'http://localhost:3000/';
break
case "production":
root_web = 'http://159.89.151.243/';
root = 'http://159.89.151.243/api';
break
case "testing":
root_web = 'http://159.89.151.243:3000/';
root = 'http://159.89.151.243:3000/api';
break
default:
root = 'http://localhost:3000/api';
break
}
function round(number, precision) {
var pair = (number + 'e').split('e')
var value = Math.round(pair[0] + 'e' + (+pair[1] + precision))
pair = (value + 'e').split('e')
return +(pair[0] + 'e' + (+pair[1] - precision))
}
var sessionStartTime = null;
$(document).ready(function() {
// Init tracking toggle
var trackingToggle = $('#tracking-toggle');
//$('send')
// Log out listener
chrome.extension.onMessage.addListener(
function(response, sender, sendResponse) {
if (response.action == '1secElapsed') {
updateSessionTime();
chrome.extension.sendMessage({action: "on1sec"});
}
else if (response.action == 'isTrackingEnabled') {
if(response.isTrackingEnabled) {
trackingToggle.bootstrapToggle('on');
} else {
trackingToggle.bootstrapToggle('off');
}
// Set the change event here to avoid triggering on loading
trackingToggle.change(function() {
if(trackingToggle.prop('checked')) {
//, '#no-data', '#effectiveness-chart'
$('#display-session-start-time, #no-data, #effectiveness-chart').css({ 'opacity' : 1.0 });
} else {
$('#display-session-start-time, #no-data, #effectiveness-chart').css({ 'opacity' : 0.5 });
}
chrome.extension.sendMessage({action: "setIsTrackingEnabled", isTrackingEnabled: trackingToggle.prop('checked')});
});
}
}
);
chrome.extension.sendMessage({action: "getIsTrackingEnabled"});
$('#dashboard-web').click(function(){
chrome.storage.sync.get(['access_token'], function(items){
var token = items.access_token;
if(token){
var dashboard_url = root_web + "sing_in_by_token?token=" + token;
chrome.tabs.create({ url: dashboard_url });
}
});
});
$('#no-data').hide();
// Pass dateTimeStart and dateTimeFinish in miliseconds since 1 Jan 1970 (UNIX format)
function updateSessionTime() {
var totalTime = (Date.now() - sessionStartTime)/1000; //time in seconds
var htmlOutput = "_";
if(totalTime < 60) {
htmlOutput = Number(totalTime).toFixed(0) + " " + jsI18n.t('seconds');
} else {
totalTime = totalTime/60;
htmlOutput = Number(totalTime).toFixed(1) + " " + jsI18n.t('minutes');
if(totalTime > 60) {
totalTime = totalTime/60;
htmlOutput = Number(totalTime).toFixed(1) + " " + jsI18n.t('hours');
}
//$('span#session-min').html(Number(parseFloat(3)/60.0).toFixed(1) + ' minutes');
}
$('span#session-min').html(htmlOutput);
}
// Listener to receive chart data from background
chrome.extension.onMessage.addListener(
function(response, sender, sendResponse) {
if(response.action == 'chartDataResponse') {
if(response.chartData.session_exists) {
if(response.chartData.effective_time + response.chartData.procrastination_time > 0) {
$('#no-data').hide();
$('#display-session-start-time').show();
sessionStartTime = response.chartData.session_start;
chrome.extension.sendMessage({action: "on1sec"});
drawChart(response.chartData.effective_time, response.chartData.procrastination_time);
$('#effectiveness-chart').show();
} else {
sessionStartTime = response.chartData.session_start;
chrome.extension.sendMessage({action: "on1sec"});
$('#no-data').show();
}
} else {
$('#no-data').html("<p>" + jsI18n.t('no-session-started-msg') + "</p>");
$('#no-data').show();
$('#display-session-start-time').hide();
}
}
}
);
// Build chart if there is data
getToken(function(saved_token){
chrome.extension.sendMessage({action: "getEffectiveTime"});
});
function drawChart(effective_time, procrastination_time) {
var ctx = document.getElementById("effectiveness-chart").getContext('2d');
var myChart = new Chart(ctx, {
type: 'pie',
data: {
labels: [jsI18n.t('effective-time'), jsI18n.t('procrastination')],
datasets: [{
backgroundColor: [
"#304FFE",
"#FE4A49"
],
data: [effective_time, procrastination_time]
}]
},
options: {
tooltips: {
callbacks: {
label: function(tooltipItem) {
var dataVal = 0;
var label = "";
if(tooltipItem.index == 0){
dataVal = effective_time;
label = jsI18n.t('effective-time');
} else {
dataVal = procrastination_time;
label = jsI18n.t('procrastination');
}
var precentage = Number((parseFloat(dataVal)/(effective_time+procrastination_time)) * 100.0).toFixed(2);
var minutes = dataVal/60.0
if(minutes < 1) {
return label + ": " + dataVal + " " + jsI18n.t('seconds-short') + " (" + precentage + "%)";
} else {
return label + ": " + (dataVal/60.0).toPrecision(2) + " " + jsI18n.t('minutes-short') + " (" + precentage + "%)";
}
}
}
}
}
});
}
});
(function ($) {
$.extend($.summernote.lang, {
'ar-AR': {
font: {
bold: 'عريض',
italic: 'مائل',
underline: 'تحته خط',
clear: 'مسح التنسيق',
height: 'إرتفاع السطر',
name: 'الخط',
strikethrough: 'فى وسطه خط',
size: 'الحجم'
},
image: {
image: 'صورة',
insert: 'إضافة صورة',
resizeFull: 'الحجم بالكامل',
resizeHalf: 'تصغير للنصف',
resizeQuarter: 'تصغير للربع',
floatLeft: 'تطيير لليسار',
floatRight: 'تطيير لليمين',
floatNone: 'ثابته',
dragImageHere: 'إدرج الصورة هنا',
selectFromFiles: 'حدد ملف',
url: 'رابط الصورة',
remove: 'حذف الصورة'
},
video: {
video: 'فيديو',
videoLink: 'رابط الفيديو',
insert: 'إدراج الفيديو',
url: 'رابط الفيديو',
providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion ou Youku)'
},
link: {
link: 'رابط رابط',
insert: 'إدراج',
unlink: 'حذف الرابط',
edit: 'تعديل',
textToDisplay: 'النص',
url: 'مسار الرابط',
openInNewWindow: 'فتح في نافذة جديدة'
},
table: {
table: 'جدول'
},
hr: {
insert: 'إدراج خط أفقي'
},
style: {
style: 'تنسيق',
p: 'عادي',
blockquote: 'إقتباس',
pre: 'شفيرة',
h1: 'عنوان رئيسي 1',
h2: 'عنوان رئيسي 2',
h3: '