From: Vincent Vanwaelscappel Date: Wed, 10 Mar 2021 15:53:01 +0000 (+0100) Subject: wip #4333 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=06ce218d1b63c76c9e819398510f5aae98aa555e;p=scorm-scroll.git wip #4333 @1 --- diff --git a/imsmanifest.xml b/imsmanifest.xml index 8b478d8..57360e2 100644 --- a/imsmanifest.xml +++ b/imsmanifest.xml @@ -15,7 +15,7 @@ $scorm_title - $scorm_title + SCORM_TITLE diff --git a/index.html b/index.html index 9ff079a..1071589 100644 --- a/index.html +++ b/index.html @@ -1,339 +1,371 @@ - + - - + + + +
-
-
-
-
+
+
+
+
-
-


-

Introduction

-

+
+


+ Mark as complete
+ Mark as complete and close
+

Introduction

+

-

At Virgin Media, the safety of our people, partners and customers is paramount and everyone deserves a place to work that is safe and comfortable and to get home safe, every day. -In our business, there are plenty of potential risks. Hence our commitment to creating a Zero Harm culture. You are responsible for living the five Zero Harm behaviours every day.


+

At Virgin Media, the safety of our people, partners and customers is paramount and everyone deserves a place to + work that is safe and comfortable and to get home safe, every day. + In our business, there are plenty of potential risks. Hence our commitment to creating a Zero Harm culture. You + are responsible for living the five Zero Harm behaviours every day.


-
+
-

Why is it important we Be Safe?

+

Why is it important we Be Safe?

-

+

-

To avoid injuring ourselves, our work colleagues, our customers, or anyone who might be affected by our work

-

+

To avoid injuring ourselves, our work colleagues, our customers, or anyone who might be affected by our + work

+

-

The impact of an injury at work doesn't stop with the pain and discomfort of the physical injury. It can be emotionally and mentally damaging to the injured party, witnesses to the injury and those close to the injured party at home, and at work.

-

This may result in stress for the injured party, their family and those close to them. Serious injuries could result in long term sickness, financial difficulties, and long-term health complications.


+

The impact of an injury at work doesn't stop with the pain and discomfort of the physical injury. It can be + emotionally and mentally damaging to the injured party, witnesses to the injury and those close to the injured + party at home, and at work.

+

This may result in stress for the injured party, their family and those close to them. Serious injuries could + result in long term sickness, financial difficulties, and long-term health complications.


-

+

-

+

-

Poor safety can harm our business, as well as our people

+

Poor safety can harm our business, as well as our people

-

Poor safety practices also cost time and money and that is bad for any business. Possible costs to the business in the event of a serious accident:


-

+

Poor safety practices also cost time and money and that is bad for any business. Possible costs to the business + in the event of a serious accident:


+

-

downtime at the time of the accident (injured party and witnesses)

-

+

downtime at the time of the accident (injured party and witnesses)

+

-

downtime for those undertaking and participating in the accident investigation

-

+

downtime for those undertaking and participating in the accident investigation

+

-

additional labour costs, if injured party is off sick and work needs to be completed on paid overtime, or by employing contractors

-

+

additional labour costs, if injured party is off sick and work needs to be completed on paid overtime, or by + employing contractors

+

-

cost of possible enforcement activity (downtime and potentially fines)

-

+

cost of possible enforcement activity (downtime and potentially fines)

+

-

cost of defending a personal injury claim

-

+

cost of defending a personal injury claim

+

-

cost of paying out on a successful claim plus court costs

-

+

cost of paying out on a successful claim plus court costs

+

-

increased insurance premiums

-

+

increased insurance premiums

+

-

brand damage and consequent loss of business


+

brand damage and consequent loss of business


-

Even a minor incident can impact the business.

-

We have a brand we are immensely proud of and want to protect, as well as maintain your and our customers’ confidence in us.


+

Even a minor incident can impact the business.

+

We have a brand we are immensely proud of and want to protect, as well as maintain your and our customers’ + confidence in us.


-

+

-

It's the law!

-

+

It's the law!

+

-

The Health and Safety at Work etc Act 1974 is the primary legislation covering occupational health and safety in Great Britain. It sets out the general principles for managing health and safety at work.

-

This includes the Duty of Care Responsibilities...

-

employers have towards employees and members of the public

-

+

The Health and Safety at Work etc Act 1974 is the primary legislation covering occupational health and safety in + Great Britain. It sets out the general principles for managing health and safety at work.

+

This includes the Duty of Care Responsibilities...

+

employers have towards employees and members of the public

+

-

employees have to themselves and to each other

-

+

employees have to themselves and to each other

+

-

Our Partners and self-employed workers have towards themselves and others


+

Our Partners and self-employed workers have towards themselves and others


-

Looking after your, and others’, health and safety isn’t just down to Virgin Media – legally, it’s down to you too!


+

Looking after your, and others’, health and safety isn’t just down to Virgin Media – legally, it’s down to you + too!


-
- -

The five Zero Harm behaviours to help you

-

+
-

-

Safety First - in everything you do

-

Always think safety first in everything you do both in and out of work.


+

The five Zero Harm behaviours to help you

+

-

-

Take care - of yourself and everyone else

-

Always take care of yourself and others


+

+

Safety First - in everything you do

+

Always think safety first in everything you do both in and out of work.


-

-

Do the right thing

-

Be vigilant about safety. Follow safe systems of work and always carry out simple risk assessments or Be Safe checks before every job, and if it doesn't feel safe then don’t do it!

-

If ever you are in any doubt speak to your manager or the safety team.


+

+

Take care - of yourself and everyone else

+

Always take care of yourself and others


-

-

Report that stuff

-

Report all unsafe practices or procedures you identify. Knowing about issues helps us put things right, and continually improve health and safety performance.


+

+

Do the right thing

+

Be vigilant about safety. Follow safe systems of work and always carry out simple risk assessments or Be Safe + checks before every job, and if it doesn't feel safe then don’t do it!

+

If ever you are in any doubt speak to your manager or the safety team.


-

-

Speak up and own it

-

If you see something or someone you know that is unsafe, you are expected to be confident and challenge the person and do something to make the situation safe.


+

+

Report that stuff

+

Report all unsafe practices or procedures you identify. Knowing about issues helps us put things right, and + continually improve health and safety performance.


+ +

+

Speak up and own it

+

If you see something or someone you know that is unsafe, you are expected to be confident and challenge the + person and do something to make the situation safe.


- -
+
+ - - \ No newline at end of file + + \ No newline at end of file diff --git a/scorm-scroll.min.js b/scorm-scroll.min.js index 8ac1102..6f945cd 100644 --- a/scorm-scroll.min.js +++ b/scorm-scroll.min.js @@ -1 +1 @@ -var pipwerks={UTILS:{},debug:{isActive:!0},SCORM:{version:null,handleCompletionStatus:!0,handleExitMode:!0,API:{handle:null,isFound:!1},connection:{isActive:!1},data:{completionStatus:null,exitStatus:null},debug:{}}};pipwerks.SCORM.isAvailable=function(){return!0},pipwerks.SCORM.API.find=function(e){for(var t=null,i=0,n="SCORM.API.find",s=pipwerks.UTILS.trace,o=pipwerks.SCORM;!e.API&&!e.API_1484_11&&e.parent&&e.parent!=e&&i<=12;)i++,e=e.parent;if(o.version)switch(o.version){case"2004":e.API_1484_11?t=e.API_1484_11:s(n+": SCORM version 2004 was specified by user, but API_1484_11 cannot be found.");break;case"1.2":e.API?t=e.API:s(n+": SCORM version 1.2 was specified by user, but API cannot be found.")}else e.API_1484_11?(o.version="2004",t=e.API_1484_11):e.API&&(o.version="1.2",t=e.API);return t?(s(n+": API found. Version: "+o.version),s("API: "+t)):s(n+": Error finding API. \nFind attempts: "+i+". \nFind attempt limit: 12"),t},pipwerks.SCORM.API.get=function(){var e=null,t=window,i=pipwerks.SCORM,n=i.API.find,s=pipwerks.UTILS.trace;return(e=!(e=!(e=!(e=n(t))&&t.parent&&t.parent!=t?n(t.parent):e)&&t.top&&t.top.opener?n(t.top.opener):e)&&t.top&&t.top.opener&&t.top.opener.document?n(t.top.opener.document):e)?i.API.isFound=!0:s("API.get failed: Can't find the API!"),e},pipwerks.SCORM.API.getHandle=function(){var e=pipwerks.SCORM.API;return e.handle||e.isFound||(e.handle=e.get()),e.handle},pipwerks.SCORM.connection.initialize=function(){var e=!1,t=pipwerks.SCORM,i=t.data.completionStatus,n=pipwerks.UTILS.trace,s=pipwerks.UTILS.StringToBoolean,o=t.debug,r="SCORM.connection.initialize ";if(n("connection.initialize called."),t.connection.isActive)n(r+"aborted: Connection already active.");else{var a=t.API.getHandle(),c=0;if(a){switch(t.version){case"1.2":e=s(a.LMSInitialize(""));break;case"2004":e=s(a.Initialize(""))}if(e)if(null!==(c=o.getCode())&&0===c){if(t.connection.isActive=!0,t.handleCompletionStatus&&(i=t.status("get"))){switch(i){case"not attempted":case"unknown":t.status("set","incomplete"),t.set("cmi.success_status","unknown");break;default:t.status("set",i),t.set("cmi.success_status",t.get("cmi.success_status"))}t.save()}}else e=!1,n(r+"failed. \nError code: "+c+" \nError info: "+o.getInfo(c));else n(null!==(c=o.getCode())&&0!==c?r+"failed. \nError code: "+c+" \nError info: "+o.getInfo(c):r+"failed: No response from server.")}else n(r+"failed: API is null.")}return e},pipwerks.SCORM.connection.terminate=function(){var e=!1,t=pipwerks.SCORM,i=t.data.exitStatus,n=t.data.completionStatus,s=pipwerks.UTILS.trace,o=pipwerks.UTILS.StringToBoolean,r=t.debug,a="SCORM.connection.terminate ";if(t.connection.isActive){var c,l=t.API.getHandle();if(l){if(t.handleExitMode&&!i)if("completed"!==n&&"passed"!==n)switch(t.version){case"1.2":e=t.set("cmi.core.exit","suspend");break;case"2004":e=t.set("cmi.exit","suspend")}else switch(t.version){case"1.2":e=t.set("cmi.core.exit","suspend");break;case"2004":e=t.set("cmi.exit","suspend")}if(e=t.save()){switch(t.version){case"1.2":e=o(l.LMSFinish(""));break;case"2004":e=o(l.Terminate(""))}e?t.connection.isActive=!1:s(a+"failed. \nError code: "+(c=r.getCode())+" \nError info: "+r.getInfo(c))}}else s(a+"failed: API is null.")}else s(a+"aborted: Connection already terminated.");return e},pipwerks.SCORM.data.get=function(e){var t=null,i=pipwerks.SCORM,n=pipwerks.UTILS.trace,s=i.debug,o="SCORM.data.get('"+e+"') ";if(i.connection.isActive){var r,a=i.API.getHandle();if(a){switch(i.version){case"1.2":t=a.LMSGetValue(e);break;case"2004":t=a.GetValue(e)}if(r=s.getCode(),""!==t||0===r)switch(e){case"cmi.core.lesson_status":case"cmi.completion_status":i.data.completionStatus=t;break;case"cmi.core.exit":case"cmi.exit":i.data.exitStatus=t}else n(o+"failed. \nError code: "+r+"\nError info: "+s.getInfo(r))}else n(o+"failed: API is null.")}else n(o+"failed: API connection is inactive.");return n(o+" value: "+t),String(t)},pipwerks.SCORM.data.set=function(e,t){var i=!1,n=pipwerks.SCORM,s=pipwerks.UTILS.trace,o=pipwerks.UTILS.StringToBoolean,r=n.debug,a="SCORM.data.set('"+e+"') ";if(n.connection.isActive){var c,l=n.API.getHandle();if(l){switch(n.version){case"1.2":i=o(l.LMSSetValue(e,t));break;case"2004":i=o(l.SetValue(e,t))}i?"cmi.core.lesson_status"===e||"cmi.completion_status"===e?n.data.completionStatus=t:"cmi.core.exit"!=e&&"cmi.exit"!=e||(n.data.exitStatus=t):s(a+"failed. \nError code: "+(c=r.getCode())+". \nError info: "+r.getInfo(c))}else s(a+"failed: API is null.")}else s(a+"failed: API connection is inactive.");return s(a+" value: "+t),i},pipwerks.SCORM.data.save=function(){var e=!1,t=pipwerks.SCORM,i=pipwerks.UTILS.trace,n=pipwerks.UTILS.StringToBoolean,s="SCORM.data.save failed";if(t.connection.isActive){var o=t.API.getHandle();if(o)switch(t.version){case"1.2":e=n(o.LMSCommit(""));break;case"2004":e=n(o.Commit(""))}else i(s+": API is null.")}else i(s+": API connection is inactive.");return e},pipwerks.SCORM.status=function(e,t){var i=!1,n=pipwerks.SCORM,s=pipwerks.UTILS.trace,o="SCORM.getStatus failed",r="";if(null!==e){switch(n.version){case"1.2":r="cmi.core.lesson_status";break;case"2004":r="cmi.completion_status"}switch(e){case"get":i=n.data.get(r);break;case"set":null!==t?i=n.data.set(r,t):(i=!1,s(o+": status was not specified."));break;default:i=!1,s(o+": no valid action was specified.")}}else s(o+": action was not specified.");return i},pipwerks.SCORM.debug.getCode=function(){var e=pipwerks.SCORM,t=e.API.getHandle(),i=pipwerks.UTILS.trace,n=0;if(t)switch(e.version){case"1.2":n=parseInt(t.LMSGetLastError(),10);break;case"2004":n=parseInt(t.GetLastError(),10)}else i("SCORM.debug.getCode failed: API is null.");return n},pipwerks.SCORM.debug.getInfo=function(e){var t=pipwerks.SCORM,i=t.API.getHandle(),n=pipwerks.UTILS.trace,s="";if(i)switch(t.version){case"1.2":s=i.LMSGetErrorString(e.toString());break;case"2004":s=i.GetErrorString(e.toString())}else n("SCORM.debug.getInfo failed: API is null.");return String(s)},pipwerks.SCORM.debug.getDiagnosticInfo=function(e){var t=pipwerks.SCORM,i=t.API.getHandle(),n=pipwerks.UTILS.trace,s="";if(i)switch(t.version){case"1.2":s=i.LMSGetDiagnostic(e);break;case"2004":s=i.GetDiagnostic(e)}else n("SCORM.debug.getDiagnosticInfo failed: API is null.");return String(s)},pipwerks.SCORM.init=pipwerks.SCORM.connection.initialize,pipwerks.SCORM.get=pipwerks.SCORM.data.get,pipwerks.SCORM.set=pipwerks.SCORM.data.set,pipwerks.SCORM.save=pipwerks.SCORM.data.save,pipwerks.SCORM.quit=pipwerks.SCORM.connection.terminate,pipwerks.UTILS.StringToBoolean=function(e){switch(typeof e){case"object":case"string":return/(true|1)/i.test(e);case"number":return!!e;case"boolean":return e;case"undefined":return null;default:return!1}},pipwerks.UTILS.trace=function(e){pipwerks.debug.isActive&&window.console&&window.console.log&&window.console.log(e)},SCORM=!0,SCORM_INITED=!1,SCORM_START_TIME=null,SCORM_INTERACTION_TIMESTAMPS=[],SCORM_CORRECT_ANSWERS=[],SCORM_ID_TO_N={},SCORM_QUESTIONS=[],SCORM_SUCCESS_STATUS="unknown",SCORM_SUCCESS_SCORE=SCORM_WEIGHTING=0,SCORM_INTERACTIONS_INITED=SCORM_EVENTS_INITED=!1,SCORM_LOCATION_INITED=!1,SCORM_OK=!1;var _CMI12={location:"cmi.core.lesson_location",status:"cmi.core.lesson_status",session_time:"cmi.core.session_time",success_status:"",exit:"cmi.core.exit"},_CMI2004={location:"cmi.location",status:"cmi.completion_status",session_time:"cmi.session_time",success_status:"cmi.success_status",exit:"cmi.exit"};function initScorm(){if(!SCORM_INITED){console.log("init scorm"),SCORM_INITED=!0;try{pipwerks.SCORM.init()&&(SCORM_OK=!0)}catch(e){}try{FORCE_SCORM&&(SCORM_OK=!0)}catch(e){}return SCORM_OK?$(document).on("fluidbook.ready",function(){scormExit(),startScormTimer(),initScormEvents(),initScormInteractions()}):console.log("SCORM nok"),SCORM_OK}}function _cmi(e){var t=null;switch(pipwerks.SCORM.version){case"1.2":t=_CMI12[e];break;case"2004":t=_CMI2004[e]}return t=null==t||null==t?e:t}function initScormEvents(){SCORM_OK&&!SCORM_EVENTS_INITED&&(SCORM_EVENTS_INITED=!0,$(window).on("unload",function(){scormMarkAsComplete(),finishScorm()}),SCORM_LOCATION_INITED||(SCORM_LOCATION_INITED=!0,setInterval(function(){pipwerks.SCORM.save()},5e3)))}function finishScorm(){SCORM_OK&&(setSessionTime(),pipwerks.SCORM.save(),pipwerks.SCORM.quit())}function scormMarkAsComplete(){SCORM_OK&&(scormExit(),setScormValue("status","completed"),setScormValue("success_status","passed"))}function scormExit(){var e;SCORM_OK&&(e="suspend",setScormValue("exit",e=fluidbook.settings.scorm_force_attempts?"1.2"===pipwerks.SCORM.version?"logout":"normal":e))}function startScormTimer(){SCORM_START_TIME=new Date}function scormComplete(){SCORM_OK&&(scormMarkAsComplete(),finishScorm())}function scormCompleteAndClose(){scormComplete(),scormClose()}function scormClose(){parent.close(),top.close(),window.close()}function getScormValue(e){if(!SCORM_OK)return null;e=_cmi(e);return""==e?null:pipwerks.SCORM.get(e)}function setScormValue(e,t){if(SCORM_OK){e=_cmi(e);return""==e?!1:pipwerks.SCORM.set(e,t)}}function setSessionTime(){var e,t,i;SCORM_OK&&(e=(new Date).getTime()-SCORM_START_TIME,"1.2"==pipwerks.SCORM.version?(e-=1e3*(t=Math.floor(e/1e3/60/60))*60*60,t<1e3&&99=COMPLETE_SCROLL_RATIO&&(COMPLETED=!0,scormComplete()),!0}),window.addEventListener("unload",function(){COMPLETE_ON_CLOSE&&scormMarkAsComplete(),finishScorm()}); \ No newline at end of file diff --git a/scorm-scroll.zip b/scorm-scroll.zip new file mode 100644 index 0000000..8feb596 Binary files /dev/null and b/scorm-scroll.zip differ diff --git a/scripts/project.js b/scripts/project.js index 2559528..404a588 100644 --- a/scripts/project.js +++ b/scripts/project.js @@ -4,10 +4,24 @@ if (COMPLETE_ON_CLOSE === undefined) { if (COMPLETE_ON_CLOSE === undefined) { var COMPLETE_ON_CLOSE = true; } +var COMPLETED = false; + +document.addEventListener("DOMContentLoaded", function () { + initScorm(); +}); window.addEventListener('scroll', function () { - if (getWindowScroll() >= COMPLETE_SCROLL_RATIO) { + var scroll = getWindowScroll(); + if (!COMPLETED && scroll >= COMPLETE_SCROLL_RATIO) { + COMPLETED = true; scormComplete(); } return true; +}); + +window.addEventListener('unload', function () { + if (COMPLETE_ON_CLOSE) { + scormMarkAsComplete(); + } + finishScorm(); }); \ No newline at end of file diff --git a/scripts/scorm.js b/scripts/scorm.js index bb53ae2..06a9ace 100644 --- a/scripts/scorm.js +++ b/scripts/scorm.js @@ -52,12 +52,9 @@ function initScorm() { } if (SCORM_OK) { - $(document).on('fluidbook.ready', function () { - scormExit(); - startScormTimer(); - initScormEvents(); - initScormInteractions(); - }); + scormExit(); + startScormTimer(); + initScormEvents(); } else { console.log('SCORM nok'); } @@ -86,13 +83,6 @@ function initScormEvents() { } SCORM_EVENTS_INITED = true; - $(window).on('unload', function () { - if (COMPLETE_ON_CLOSE) { - scormMarkAsComplete(); - } - finishScorm(); - }); - if (SCORM_LOCATION_INITED) { return; } @@ -183,14 +173,6 @@ function scormExit() { return; } var v = 'suspend'; - if (fluidbook.settings.scorm_force_attempts) { - if (pipwerks.SCORM.version === '1.2') { - v = 'logout'; - } else { - v = 'normal'; - } - } - setScormValue('exit', v); } @@ -199,15 +181,12 @@ function startScormTimer() { } function scormComplete() { - if (SCORM_OK) { - scormMarkAsComplete(); - finishScorm(); - return; - } + scormMarkAsComplete(); } function scormCompleteAndClose() { scormComplete(); + finishScorm(); scormClose(); }