Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function init()
- {
- if(type == 'test' || type == 'test-finale'){
- openNr(2);
- }else{
- window.oncontextmenu = function(){return false;}
- openNr(1);
- }
- }
- function openNr(nr,mode)
- {
- if(type == 'test' || type == 'test-finale'){
- document.getElementById('n-slide').innerHTML = 'Test';
- }else{
- if(nr == '1'){
- document.getElementById('n-slide').innerHTML = 'Video';
- }else{
- document.getElementById('n-slide').innerHTML = 'Test';
- }
- }
- document.getElementById('ico-freccia-ind').style.opacity = '0';
- document.getElementById('ico-freccia-av').style.opacity = '0';
- document.getElementById('ico-freccia-ind').setAttribute('onclick','');
- document.getElementById('ico-freccia-av').setAttribute('onclick','');
- document.getElementById('ico-unit-load').style.display = 'block';
- document.getElementById('ico-unit-attesa').style.display = 'none';
- document.getElementById('ico-unit-incorso').style.display = 'none';
- document.getElementById('ico-unit-completato').style.display = 'none';
- if(type == 'test' || type == 'test-finale'){
- //
- }else{
- if(nr > 1){
- document.getElementById('ico-freccia-ind').style.opacity = '1';
- document.getElementById('ico-freccia-ind').setAttribute('onclick','openNr('+(nr-1)+',\'no-block\')');
- }
- }
- if(nr <= lesson_location)
- {
- document.getElementById('ico-unit-load').style.display = 'none';
- document.getElementById('ico-unit-attesa').style.display = 'none';
- document.getElementById('ico-unit-incorso').style.display = 'none';
- document.getElementById('ico-unit-completato').style.display = 'block';
- document.getElementById('ico-freccia-av').style.opacity = '1';
- if(nr == nSlide){
- //document.getElementById('ico-freccia-av').setAttribute("onclick","doQuit()");
- document.getElementById('ico-freccia-av').setAttribute("onclick","window.open('"+pag_principale+"','_top')");
- }else{
- document.getElementById('ico-freccia-av').setAttribute('onclick','openNr('+(nr+1)+'),\'no-block\')');
- }
- }
- else
- {
- document.getElementById('ico-unit-load').style.display = 'none';
- document.getElementById('ico-unit-attesa').style.display = 'none';
- document.getElementById('ico-unit-incorso').style.display = 'block';
- document.getElementById('ico-unit-completato').style.display = 'none';
- }
- nRisp = 0;
- var audio_tic = document.getElementById('tic');
- var audio_frusta = document.getElementById('frusta');
- var audio_beep = document.getElementById('beep3');
- var audio_no = document.getElementById('no');
- var audio_waw = document.getElementById('waw');
- var audio_ding = document.getElementById('ding');
- for(var i=1; i<=nSlide; i++)
- {
- if(document.getElementById('unit-'+i))
- {
- document.getElementById('u-'+i).style.display = 'none';
- if(nr == i)
- {
- if(i==1)
- {
- //1. Video
- var video3 = document.getElementById('unit-'+nr+'-video');
- if(mode == 'no-block'){
- video3.currentTime = 0;
- }
- video3.play();
- startVideoCrono(nr,mode);
- video3.onended = function() {
- if(timeTot >= video3.currentTime){
- save(nr);
- }else{
- video3.currentTime = timeTot;
- video3.play();
- }
- };
- /*video3.onseeking = function() {
- if(video3.currentTime > timeTot){
- video3.currentTime = timeTot;
- }
- };*/
- /*$('#unit-'+nr+'-video').bind("ended", function() {
- save(nr);
- });*/
- }
- else if(i==2)
- {
- //2. Verifica finale
- for(j=1; j<=nTest; j++){
- if(j==1){
- document.getElementById('unit-'+i+'-test-'+j).style.display = 'block';
- }else{
- document.getElementById('unit-'+i+'-test-'+j).style.display = 'none';
- }
- document.getElementById('unit-'+i+'-test-'+j+'-A').setAttribute("class","risposta");
- document.getElementById('unit-'+i+'-test-'+j+'-B').setAttribute("class","risposta");
- document.getElementById('unit-'+i+'-test-'+j+'-C').setAttribute("class","risposta");
- document.getElementById('unit-'+i+'-test-'+j+'-A').setAttribute("onclick","setTest("+i+","+j+",'A');");
- document.getElementById('unit-'+i+'-test-'+j+'-B').setAttribute("onclick","setTest("+i+","+j+",'B');");
- document.getElementById('unit-'+i+'-test-'+j+'-C').setAttribute("onclick","setTest("+i+","+j+",'C');");
- document.getElementById('unit-'+i+'-test-'+j+'-OK').style.display = 'none';
- }
- document.getElementById('unit-'+i+'-test-avanti').style.display = 'none';
- document.getElementById('unit-'+i+'-test-'+(nTest+1)).style.display = 'none';
- }
- else if(i==3)
- {
- //1. Attestato digitale
- //save(nr);
- //document.getElementById('ifr-attestato').src = 'attestato.html';
- }
- document.getElementById('u-'+i).style.display = 'block';
- document.getElementById('unit-'+i).style.display = 'block';
- }
- else
- {
- if(i==1)
- {
- //1. Approfondimento contenutistico (video da 3 minuti)
- var video3 = document.getElementById('unit-'+i+'-video');
- //video3.currentTime = 0;
- video3.pause();
- }
- else if(i==2)
- {
- //2. Verifica finale
- }
- else if(i==3)
- {
- //3. Attestato digitale
- }
- document.getElementById('unit-'+i).style.display = 'none';
- }
- }
- }
- }
- function setTest(id, nr, risposta)
- {
- var audio_tic = document.getElementById('tic');
- var audio_frusta = document.getElementById('frusta');
- var audio_beep = document.getElementById('beep3');
- var audio_no = document.getElementById('no');
- var audio_waw = document.getElementById('waw');
- var audio_ding = document.getElementById('ding');
- rispEsatta = document.getElementById('unit-'+id+'-test-'+nr+'-OK').innerHTML;
- document.getElementById('unit-'+id+'-test-'+nr+'-A').setAttribute("onClick","return false;");
- document.getElementById('unit-'+id+'-test-'+nr+'-B').setAttribute("onClick","return false;");
- document.getElementById('unit-'+id+'-test-'+nr+'-C').setAttribute("onClick","return false;");
- document.getElementById('unit-'+id+'-test-'+nr+'-A').setAttribute("class","risposta risposta-disabled");
- document.getElementById('unit-'+id+'-test-'+nr+'-B').setAttribute("class","risposta risposta-disabled");
- document.getElementById('unit-'+id+'-test-'+nr+'-C').setAttribute("class","risposta risposta-disabled");
- if(risposta == rispEsatta)
- {
- //audio_waw.play();
- audio_tic.play();
- //document.getElementById('unit-'+id+'-test-'+nr+'-'+risposta).setAttribute("class","risposta risposta-esatta");
- document.getElementById('unit-'+id+'-test-'+nr+'-'+risposta).setAttribute("class","risposta risposta-disabled-clicked");
- nRisp++;
- risp = nRisp;
- }
- else
- {
- //audio_no.play();
- audio_tic.play();
- /*if(rispEsatta == 'A'){
- document.getElementById('unit-'+id+'-test-'+nr+'-A').setAttribute("class","risposta risposta-esatta");
- }else if(rispEsatta == 'B'){
- document.getElementById('unit-'+id+'-test-'+nr+'-B').setAttribute("class","risposta risposta-esatta");
- }else if(rispEsatta == 'C'){
- document.getElementById('unit-'+id+'-test-'+nr+'-C').setAttribute("class","risposta risposta-esatta");
- }
- document.getElementById('unit-'+id+'-test-'+nr+'-'+risposta).setAttribute("class","risposta risposta-no");*/
- document.getElementById('unit-'+id+'-test-'+nr+'-'+risposta).setAttribute("class","risposta risposta-disabled-clicked");
- risp = nRisp;
- }
- document.getElementById('unit-'+id+'-test-avanti').style.display = 'block';
- document.getElementById('unit-'+id+'-test-avanti').setAttribute('onClick','nextDomanda('+id+','+nr+','+risp+','+nTest+');');
- }
- function nextDomanda(id, nr, risp, nTest)
- {
- var audio_tic = document.getElementById('tic');
- var audio_frusta = document.getElementById('frusta');
- var audio_beep = document.getElementById('beep3');
- var audio_no = document.getElementById('no');
- var audio_waw = document.getElementById('waw');
- var audio_ding = document.getElementById('ding');
- audio_tic.play();
- //alert(id+'-'+nr+'-'+risp+'-'+nTest);
- document.getElementById('unit-'+id+'-test-'+nr).style.display = 'none';
- document.getElementById('unit-'+id+'-test-'+(nr+1)).style.display = 'block';
- document.getElementById('unit-'+id+'-test-'+(nr+1)).style.opacity = 0;
- document.getElementById('unit-'+id+'-test-avanti').style.display = 'none';
- document.getElementById('unit-'+id+'-test-avanti').setAttribute('onClick','return false;');
- $('#unit-'+id+'-test-'+(nr+1)).animate(
- {
- opacity: 1
- },
- {
- duration: 500
- }
- );
- if(nr == nTest){
- if(risp == 1){
- txt='domanda';
- }else{
- txt='domande';
- }
- document.getElementById('unit-'+id+'-risultato').innerHTML = '<strong>'+risp+' '+txt+' su '+nTest+'</strong>';
- save(id);
- }
- }
- function openMenu(nr)
- {
- var audio_tic = document.getElementById('tic');
- var audio_frusta = document.getElementById('frusta');
- var audio_beep = document.getElementById('beep3');
- var audio_no = document.getElementById('no');
- var audio_waw = document.getElementById('waw');
- var audio_ding = document.getElementById('ding');
- nRisp = 0;
- for(var i=1; i<=nSlide; i++)
- {
- if(document.getElementById('unit-'+i))
- {
- if(i==1){
- //1. Video
- var video3 = document.getElementById('unit-'+i+'-video');
- //video3.currentTime = 0;
- video3.pause();
- }
- else if(i==2){
- //2. Verifica finale
- }
- else if(i==3){
- //3. Attestato digitale
- }
- document.getElementById('u-'+i).style.display = 'block';
- document.getElementById('unit-'+i).style.display = 'none';
- }
- }
- }
- function save(nr)
- {
- var audio_tic = document.getElementById('tic');
- var audio_frusta = document.getElementById('frusta');
- var audio_beep = document.getElementById('beep3');
- var audio_no = document.getElementById('no');
- var audio_waw = document.getElementById('waw');
- var audio_ding = document.getElementById('ding');
- var id_user = id_user_log; // risorsa esterna
- var id_unit = id_unit_log; // risorsa esterna
- var content = 1;
- if(nr == 1){
- //1. Video
- audio_ding.play();
- document.getElementById('unit-popup').style.display = 'block';
- if(nSlide == 1){
- document.getElementById('unit-popup-txt').innerHTML = 'LEZIONE TERMINATA <div class="ico-freccia" style="margin-top:-10px;width:120px;float:right;" onclick="document.getElementById(\'unit-popup\').style.display=\'none\'; document.getElementById(\'unit-'+nr+'-video\').currentTime=0; document.getElementById(\'unit-'+nr+'-video\').play();"> < REPLAY </div>';
- document.getElementById('unit-popup-btn').innerHTML = 'VAI ALLA PROSSIMA LEZIONE >';
- //document.getElementById('unit-popup-btn').setAttribute("onclick","doQuit()");
- document.getElementById('unit-popup-btn').setAttribute("onclick","window.open('"+pag_principale+"','_top')");
- }else if(nSlide == 2){
- document.getElementById('unit-popup-txt').innerHTML = 'VIDEO TERMINATO <div class="ico-freccia" style="margin-top:-10px;width:120px;float:right;" onclick="document.getElementById(\'unit-popup\').style.display=\'none\'; document.getElementById(\'unit-'+nr+'-video\').currentTime=0; document.getElementById(\'unit-'+nr+'-video\').play();"> < REPLAY </div>';
- document.getElementById('unit-popup-btn').innerHTML = 'VAI AL TEST >';
- document.getElementById('unit-popup-btn').setAttribute("onclick","document.getElementById('unit-popup').style.display='none'; openNr("+(nr+1)+");");
- }
- }
- else if(nr == 2)
- {
- //2. Verifica finale
- audio_ding.play();
- document.getElementById('unit-popup').style.display = 'block';
- if(nRisp == 1){
- txt='a';
- }else{
- txt='e';
- }
- if(nRisp < nTest){
- document.getElementById('unit-popup-txt').innerHTML = '<br>Spiacente. Hai risposto correttamente solo a<br><span style="font-size:24px;font-weight:bold;">'+nRisp+' domand'+txt+' su '+nTest+'</span>.';
- if(type == 'test-finale'){
- document.getElementById('unit-popup-txt').innerHTML += '<br>Per ottenere l\'<span style="font-size:20px;font-weight:bold;">ATTESTATO DIGITALE<span style="font-size:20px;font-weight:bold;"><br><span style="font-size:20px;font-weight:bold;">DEVI RISPONDERE ESATTAMENTE A TUTTE LE DOMANDE</span>';
- }else{
- document.getElementById('unit-popup-txt').innerHTML += '<br>Per Passare alla lezione successiva<br><span style="font-size:20px;font-weight:bold;">DEVI RISPONDERE ESATTAMENTE A TUTTE LE DOMANDE</span>';
- }
- if(type == 'test' || type == 'test-finale'){
- document.getElementById('unit-popup-btn').innerHTML = 'RICOMINCIA IL TEST >';
- document.getElementById('unit-popup-btn').setAttribute("onclick","document.getElementById('unit-popup').style.display='none'; openNr("+(nr)+");");
- }else{
- document.getElementById('unit-popup-btn').innerHTML = '< TORNA AL VIDEO';
- document.getElementById('unit-popup-btn').setAttribute("onclick","document.getElementById('unit-popup').style.display='none'; openNr("+(nr-1)+",'no-block');");
- }
- }else{
- document.getElementById('unit-popup-txt').innerHTML = '<br>BRAVO!<BR/>Hai risposto correttamente a<br><span style="font-size:24px;font-weight:bold;">'+nRisp+' domand'+txt+' su '+nTest+'</span>';
- if(type == 'test-finale'){
- document.getElementById('unit-popup-txt').innerHTML += '<br>CORSO TERMINATO.';
- document.getElementById('unit-popup-btn').innerHTML = 'SCARICA il tuo ATTESTATO DI PARTECIPAZIONE >';
- //document.getElementById('unit-popup-btn').setAttribute("onclick","doQuit()");
- document.getElementById('unit-popup-btn').setAttribute("onclick","window.open('"+pag_principale+"?action=attestato','_top')");
- }else{
- if(type == 'test'){
- document.getElementById('unit-popup-txt').innerHTML += '<br>TEST TERMINATO.';
- }else{
- document.getElementById('unit-popup-txt').innerHTML += '<br>LEZIONE TERMINATA.';
- }
- document.getElementById('unit-popup-btn').innerHTML = 'VAI ALLA PROSSIMA LEZIONE >';
- //document.getElementById('unit-popup-btn').setAttribute("onclick","doQuit()");
- document.getElementById('unit-popup-btn').setAttribute("onclick","window.open('"+pag_principale+"','_top')");
- }
- }
- content = nRisp/*+'/'+nTest*/;
- }
- else if(nr == 3)
- {
- //3. Attestato digitale
- }
- //------------------------------------------------------
- if(nSlide == 1)//lezione video
- {
- lesson_location = nr;
- doLMSSetValue( "cmi.core.lesson_location", nr );
- doLMSSetValue( "cmi.core.lesson_status", "completed" );
- }
- else if(nSlide == 2) //lezione video + test
- {
- if(nr == 2)
- {
- if(nRisp == nTest)
- {
- lesson_location = nr;
- doLMSSetValue( "cmi.core.lesson_location", nr );
- doLMSSetValue( "cmi.core.lesson_status", "completed" );
- doLMSSetValue( "cmi.core.score", content );
- }
- else
- {
- doLMSSetValue( "cmi.core.score", content );
- }
- }
- else
- {
- lesson_location = nr;
- doLMSSetValue( "cmi.core.lesson_location", nr );
- }
- }
- if(nr<nSlide){
- activateUnit(parseInt(nr)+1);
- }
- //------------------------------------------------------
- }
- //--------------------------
- function startVideoCrono(nr,mode)
- {
- var video = document.getElementById('unit-'+nr+'-video');
- // video.readyState
- //0 = HAVE_NOTHING - no information whether or not the audio/video is ready
- //1 = HAVE_METADATA - metadata for the audio/video is ready
- //2 = HAVE_CURRENT_DATA - data for the current playback position is available, but not enough data to play next frame/millisecond
- //3 = HAVE_FUTURE_DATA - data for the current and at least the next frame is available
- //4 = HAVE_ENOUGH_DATA - enough data available to start playing
- if(mode == 'no-block')
- {
- if(video.readyState == 0){ // Internet Explorer
- video.onloadedmetadata = function() {
- video.currentTime = 0;
- };
- }else{ // Tutti gli altri browser
- video.currentTime = 0;
- }
- }
- else
- {
- if(doLMSGetValue( "cmi.core.total_time")){
- time_init = doLMSGetValue( "cmi.core.total_time");
- }
- var timeSplit = time_init.split(':');
- var timeH = parseInt(timeSplit[0]);
- var timeM = parseInt(timeSplit[1]);
- var timeS = parseInt(timeSplit[2]);
- timeTot = (timeH*3600)+(timeM*60)+timeS;
- if(video.readyState == 0){ // Internet Explorer
- video.onloadedmetadata = function() {
- video.currentTime = timeTot;
- };
- }else{ // Tutti gli altri browser
- video.currentTime = timeTot;
- }
- }
- setInterval("videoCrono('"+nr+"')", 1000);
- }
- function videoCrono(nr)
- {
- var video = document.getElementById('unit-'+nr+'-video');
- if(video.currentTime >= timeTot){
- timeTot++;
- }
- var hh = parseInt((timeTot - 1) / 3600);
- var hh_t = hh; if(hh < 9){hh_t = '0'+hh;}
- var hh_res = (timeTot - 1) % 3600;
- var mm = parseInt(hh_res / 60);
- var mm_t = mm; if(mm < 9){mm_t = '0'+mm;}
- var ss = (timeTot - 1) % 60;
- var ss_t = ss; if(ss < 9){ss_t = '0'+ss;}
- var timeTxt = hh_t+':'+mm_t+':'+ss_t;
- //document.getElementById('timer').innerHTML = (timeTot - 1)+' -> '+timeTxt;
- //------------------------------------------------
- if(timeTot == 1 || timeTot % 15 == 0 || timeTot == (Math.ceil(video.duration)-1)){
- doLMSSetValue( "cmi.core.total_time", timeTxt);
- }
- //------------------------------------------------
- if(video.currentTime > (timeTot+1)){
- video.currentTime = timeTot;
- }
- }
- //---------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement