diff new/test_base.php @ 20:3cbb9e7a359c

Added bottom box for training
author Giulio Moro <giuliomoro@yahoo.it>
date Thu, 12 May 2016 18:39:26 +0100
parents b2ae87f9f1c7
children 1f375b7d75fd
line wrap: on
line diff
--- 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'];
 }