changeset 20:3cbb9e7a359c

Added bottom box for training
author Giulio Moro <giuliomoro@yahoo.it>
date Thu, 12 May 2016 18:39:26 +0100
parents d74d570f4832
children 1ed0c5908575
files new/.git/COMMIT_EDITMSG new/.git/index new/.git/logs/HEAD new/.git/logs/refs/heads/giulio new/.git/logs/refs/remotes/origin/giulio new/.git/objects/08/70b148061e07a3df217a66f0700c18ee3d100f new/.git/objects/1c/35414d254d751f0722ffe165984cf0e92cf765 new/.git/objects/67/65523fc4fa556442234bed5c479065afeae550 new/.git/objects/7c/4af3c7655542124c5f43cfd84398314275c73f new/.git/objects/c8/a97eade0e33063e8d6f1e95a2d3824f60e2757 new/.git/objects/ce/c9051f37218d11c1bebe8c9620fbeb84a8622a new/.git/refs/heads/giulio new/.git/refs/remotes/origin/giulio new/css/core.css new/js/core.js new/test_base.php
diffstat 16 files changed, 46 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/new/.git/COMMIT_EDITMSG	Thu May 12 17:44:52 2016 +0100
+++ b/new/.git/COMMIT_EDITMSG	Thu May 12 18:39:26 2016 +0100
@@ -1,1 +1,1 @@
-Added allowEarlyExit feature which allows to exit early from a test
+Added box at the bottom to open training in another window
Binary file new/.git/index has changed
--- a/new/.git/logs/HEAD	Thu May 12 17:44:52 2016 +0100
+++ b/new/.git/logs/HEAD	Thu May 12 18:39:26 2016 +0100
@@ -89,3 +89,4 @@
 64acda7d1a99f2b3f599de8e5f52ab82c26cd044 24d72ac61c59496d824466116608aa96b3257c10 Giulio Moro <giuliomoro@yahoo.it> 1462927815 +0100	commit: Removed hook for 'enter' during survey. replaced with shift+enter
 24d72ac61c59496d824466116608aa96b3257c10 b22f843de0968e327fd9fbf2463dc928a0b8a7a7 Giulio Moro <giuliomoro@yahoo.it> 1462927936 +0100	commit: avoids scrollbar with radio or checkbox #63
 b22f843de0968e327fd9fbf2463dc928a0b8a7a7 703aa9a46fa3bf6fbe7ea0e0bd1f0dd9bb6d5525 Giulio Moro <giuliomoro@yahoo.it> 1462963932 +0100	commit: Added allowEarlyExit feature which allows to exit early from a test
+703aa9a46fa3bf6fbe7ea0e0bd1f0dd9bb6d5525 7c4af3c7655542124c5f43cfd84398314275c73f Giulio Moro <giuliomoro@yahoo.it> 1463074644 +0100	commit: Added box at the bottom to open training in another window
--- a/new/.git/logs/refs/heads/giulio	Thu May 12 17:44:52 2016 +0100
+++ b/new/.git/logs/refs/heads/giulio	Thu May 12 18:39:26 2016 +0100
@@ -27,3 +27,4 @@
 64acda7d1a99f2b3f599de8e5f52ab82c26cd044 24d72ac61c59496d824466116608aa96b3257c10 Giulio Moro <giuliomoro@yahoo.it> 1462927815 +0100	commit: Removed hook for 'enter' during survey. replaced with shift+enter
 24d72ac61c59496d824466116608aa96b3257c10 b22f843de0968e327fd9fbf2463dc928a0b8a7a7 Giulio Moro <giuliomoro@yahoo.it> 1462927936 +0100	commit: avoids scrollbar with radio or checkbox #63
 b22f843de0968e327fd9fbf2463dc928a0b8a7a7 703aa9a46fa3bf6fbe7ea0e0bd1f0dd9bb6d5525 Giulio Moro <giuliomoro@yahoo.it> 1462963932 +0100	commit: Added allowEarlyExit feature which allows to exit early from a test
+703aa9a46fa3bf6fbe7ea0e0bd1f0dd9bb6d5525 7c4af3c7655542124c5f43cfd84398314275c73f Giulio Moro <giuliomoro@yahoo.it> 1463074644 +0100	commit: Added box at the bottom to open training in another window
--- a/new/.git/logs/refs/remotes/origin/giulio	Thu May 12 17:44:52 2016 +0100
+++ b/new/.git/logs/refs/remotes/origin/giulio	Thu May 12 18:39:26 2016 +0100
@@ -19,3 +19,4 @@
 64acda7d1a99f2b3f599de8e5f52ab82c26cd044 24d72ac61c59496d824466116608aa96b3257c10 Giulio Moro <giuliomoro@yahoo.it> 1462927824 +0100	update by push
 24d72ac61c59496d824466116608aa96b3257c10 b22f843de0968e327fd9fbf2463dc928a0b8a7a7 Giulio Moro <giuliomoro@yahoo.it> 1462927947 +0100	update by push
 b22f843de0968e327fd9fbf2463dc928a0b8a7a7 703aa9a46fa3bf6fbe7ea0e0bd1f0dd9bb6d5525 Giulio Moro <giuliomoro@yahoo.it> 1462963939 +0100	update by push
+703aa9a46fa3bf6fbe7ea0e0bd1f0dd9bb6d5525 7c4af3c7655542124c5f43cfd84398314275c73f Giulio Moro <giuliomoro@yahoo.it> 1463074654 +0100	update by push
Binary file new/.git/objects/08/70b148061e07a3df217a66f0700c18ee3d100f has changed
Binary file new/.git/objects/1c/35414d254d751f0722ffe165984cf0e92cf765 has changed
Binary file new/.git/objects/67/65523fc4fa556442234bed5c479065afeae550 has changed
Binary file new/.git/objects/7c/4af3c7655542124c5f43cfd84398314275c73f has changed
Binary file new/.git/objects/c8/a97eade0e33063e8d6f1e95a2d3824f60e2757 has changed
Binary file new/.git/objects/ce/c9051f37218d11c1bebe8c9620fbeb84a8622a has changed
--- a/new/.git/refs/heads/giulio	Thu May 12 17:44:52 2016 +0100
+++ b/new/.git/refs/heads/giulio	Thu May 12 18:39:26 2016 +0100
@@ -1,1 +1,1 @@
-703aa9a46fa3bf6fbe7ea0e0bd1f0dd9bb6d5525
+7c4af3c7655542124c5f43cfd84398314275c73f
--- a/new/.git/refs/remotes/origin/giulio	Thu May 12 17:44:52 2016 +0100
+++ b/new/.git/refs/remotes/origin/giulio	Thu May 12 18:39:26 2016 +0100
@@ -1,1 +1,1 @@
-703aa9a46fa3bf6fbe7ea0e0bd1f0dd9bb6d5525
+7c4af3c7655542124c5f43cfd84398314275c73f
--- a/new/css/core.css	Thu May 12 17:44:52 2016 +0100
+++ b/new/css/core.css	Thu May 12 18:39:26 2016 +0100
@@ -72,16 +72,24 @@
     position: relative;
 }
 
-div#earlyExitBox{
+div.bottomBox{
 	z-index: 100;
-	float: left;
 	padding: 20px;
 	border: 1px solid black;
+	max-width: 45%;
 	position: absolute;
 	background: wheat;
 	bottom: 20px;
 }
 
+div#earlyExitBox{
+	left: 2%;
+}
+
+div#trainingUrlBox{
+	right: 2%;
+}
+
 button.popupButton {
 	/* Button for popup window
 	 */
--- a/new/js/core.js	Thu May 12 17:44:52 2016 +0100
+++ b/new/js/core.js	Thu May 12 18:39:26 2016 +0100
@@ -146,9 +146,10 @@
     {
         var search = window.location.search.split('?')[1];
         // Now split the requests into pairs
+        var allowEarlyExit = false;
+        var trainingURL = '';
+
         var searchQueries = search.split('&');
-        var allowEarlyExit = false;
-
         for (var i in searchQueries)
         {
             // Split each key-value pair
@@ -166,7 +167,10 @@
             	gSaveFilenamePrefix = value;
             	break;
             case "allowEarlyExit":
-                allowEarlyExit = (value === 'true');
+                allowEarlyExit = value;
+                break;
+            case "trainingURL":
+                trainingURL = value;
                 break;
             }
         }
@@ -174,11 +178,23 @@
         window.onbeforeunload = function() {
             return "Please only leave this page once you have completed the tests. Are you sure you have completed all testing?";
         };
-        if(allowEarlyExit === true){
+        if(allowEarlyExit === "true" || allowEarlyExit === "show"){
 			window.onbeforeunload = undefined;
 			var msg = document.createElement('div');
-			msg.innerHTML = 'You can exit the training and go back to the test at any time by clicking <a href="'+gReturnURL+'">here</a>.';
+	        if(allowEarlyExit === "show"){
+	            msg.innerHTML = 'You can exit this training and go back to the test at any time by clicking <a href="'+gReturnURL+'">here</a>.';
+	        } else if (allowEarlyExit === "true"){
+	            msg.innerHTML = 'You can close this training window at any time.';
+	        }
 			msg.id = 'earlyExitBox';
+			msg.className = 'bottomBox';
+			document.getElementsByTagName('body')[0].appendChild(msg);
+        }
+        if(trainingURL.length > 0){
+			var msg = document.createElement('div');
+			msg.innerHTML = 'You can open the training page in a new tab by clicking <a target="_blank" href="'+trainingURL+'">here</a>.';
+			msg.id = 'trainingUrlBox';
+			msg.className = 'bottomBox';
 			document.getElementsByTagName('body')[0].appendChild(msg);
         }
     }
--- a/new/test_base.php	Thu May 12 17:44:52 2016 +0100
+++ b/new/test_base.php	Thu May 12 18:39:26 2016 +0100
@@ -59,7 +59,7 @@
     $queryString = http_build_query($queryStringParsed);
     $absoluteUrlNextPlusOne = $absoluteUrlSplit[0]."?".$queryString;
   }
-  $defaultTestEntry = Array('url' => null, 'string' => null, 'class' => 'disabled', 'a' => false, 'editable' => false, 'alwaysAccessible' => false, 'returnUrl' => '', 'saveFilenamePrefix' => '', 'allowEarlyExit' => 'false');
+  $defaultTestEntry = Array('url' => null, 'string' => null, 'class' => 'disabled', 'a' => false, 'editable' => false, 'alwaysAccessible' => false, 'returnUrl' => '', 'saveFilenamePrefix' => '', 'allowEarlyExit' => 'false', 'trainingURL' => '');
 
   require_once('test_list.php'); //this returns $tests
 
@@ -73,6 +73,7 @@
   }
   // until this point, the content of $tests will always be the same for a given $id,
   // regardless of how many times we visited this page.
+  $trainingUrl = urlencode($tests[1]['url'].'&allowEarlyExit=true');
   for($n = 0; $n < sizeof($tests); $n++ ){
     //TODO: check if the corresponding file 
     // meantime, let us just rely on the GET variable 'next'
@@ -92,11 +93,15 @@
     }
     if($n < $next){
       if($tests[$n]['alwaysAccessible'] === true){
-        $tests[$n]['allowEarlyExit'] = 'true';
+        $tests[$n]['allowEarlyExit'] = 'show';
       }
-    }if($tests[$n]['alwaysAccessible'] === true){
+    }
+    if($tests[$n]['alwaysAccessible'] === true){
       $tests[$n]['class'] .= ' alwaysAccessible';
     }
+    if($n >= 2 && $n < sizeof($tests) - 1){
+      $tests[$n]['trainingURL'] = $trainingUrl;
+    }
   }
 ?>
 <html>
@@ -174,7 +179,7 @@
   // id= keeps track of the user and of the sorting of the tests in this page
   // next= keeps track of the first test not yet undertaken
   
-  echo '<a href="'.$test['url'].'&allowEarlyExit='.$test['allowEarlyExit'].'&saveFilenamePrefix='.$test['saveFilenamePrefix'].'&returnURL='.$test['returnUrl'].'">'.($n+1).' - '.$test['string'].'</a>';
+  echo '<a href="'.$test['url'].'&trainingURL='.$test['trainingURL'].'&allowEarlyExit='.$test['allowEarlyExit'].'&saveFilenamePrefix='.$test['saveFilenamePrefix'].'&returnURL='.$test['returnUrl'].'">'.($n+1).' - '.$test['string'].'</a>';
 } else {
   echo ($n+1).' - '.$test['string'];
 }