Thank you for downloading default.php
Your download should start in 3 seconds... If not please use the download link below
| 1 | <?php
|
|---|---|
| 2 | defined( '_JEXEC' ) or die( 'Restricted access' ); |
| 3 | JHTML::_('behavior.mootools');
|
| 4 | ?> |
| 5 | |
| 6 | <?php if ($this->quiz) : ?> |
| 7 | |
| 8 | <script language="javascript" type="text/javascript"> |
| 9 | |
| 10 | var hours ; |
| 11 | var minutes ; |
| 12 | var seconds ; |
| 13 | var t ; |
| 14 | var availableTime ; |
| 15 | var remainingTime ; |
| 16 | |
| 17 | window.onload = function () {
|
| 18 | |
| 19 | availableTime = <?php echo ($this->quiz->time_limit) ? $this->quiz->time_limit : 0 ; ?> ; |
| 20 | if (availableTime) |
| 21 | {
|
| 22 | hours = Math.floor(availableTime / 60) ; |
| 23 | minutes = availableTime % 60 ; |
| 24 | |
| 25 | if (hours < 10) { |
| 26 | hours = '0' + hours ; |
| 27 | } |
| 28 | |
| 29 | if (minutes < 10) { |
| 30 | minutes = '0' + minutes ; |
| 31 | } |
| 32 | |
| 33 | seconds = '00' ; |
| 34 | |
| 35 | var timer = document.getElementById('timer') ;
|
| 36 | timer.innerHTML = '<?php echo JText::_('TIME_REMAINING') ; ?> ' + hours + ":" + minutes + ":" + seconds ; |
| 37 | |
| 38 | remainingTime = availableTime *= 60 ; |
| 39 | |
| 40 | updateTimer(); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | function pad(number, length) |
| 45 | {
|
| 46 | var str = '' + number; |
| 47 | if (str.length < length) { |
| 48 | str = '0' + str; |
| 49 | } |
| 50 | |
| 51 | return str; |
| 52 | } |
| 53 | |
| 54 | function updateTimer() |
| 55 | {
|
| 56 | seconds -= 1 ; |
| 57 | seconds = pad(seconds, 2) ; |
| 58 | |
| 59 | if (seconds < 0) |
| 60 | {
|
| 61 | seconds = '59' ; |
| 62 | minutes -= 1 ; |
| 63 | minutes = pad(minutes, 2) ; |
| 64 | |
| 65 | if (minutes < 0) |
| 66 | {
|
| 67 | minutes = '59' ; |
| 68 | hours -= 1 ; |
| 69 | hours = pad(hours, 2) ; |
| 70 | |
| 71 | if (hours < 0) |
| 72 | {
|
| 73 | hours = minutes = seconds = '00' ; |
| 74 | document.getElementById('timeUp').value = 1 ;
|
| 75 | document.jquarks_quiz.submit(); |
| 76 | return true ; |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | var timer = document.getElementById('timer') ;
|
| 82 | timer.innerHTML = '<?php echo JText::_('TIME_REMAINING') ; ?> ' + hours + ':' + minutes + ':' + seconds ; |
| 83 | |
| 84 | remainingTime -= 1 ; |
| 85 | if (Math.floor(availableTime / 10) == remainingTime ) |
| 86 | {
|
| 87 | timer.style.color="white" ; |
| 88 | timer.style.backgroundColor = "#DD0000" ; |
| 89 | } |
| 90 | |
| 91 | t = setTimeout("updateTimer()", 1000);
|
| 92 | } |
| 93 | |
| 94 | function validation() |
| 95 | {
|
| 96 | var message = "<?php echo JText::_('PLEASE_CHECK_THAT_YOU_ANSWERED_ALL_QUESTIONS_BEFORE_PROCEEDING')?>" ; |
| 97 | |
| 98 | if (<?php echo $this->quiz->unique_session ; ?>) { |
| 99 | message += "\n<?php echo JText::_('YOU_CAN_ONLY_PASS_THIS_QUIZ_ONCE') ; ?>" ; |
| 100 | } |
| 101 | |
| 102 | if (confirm(message)) {
|
| 103 | return true ; |
| 104 | } else {
|
| 105 | return false ; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | </script> |
| 110 | <style> |
| 111 | #timer_wrap |
| 112 | {
|
| 113 | text-align:left; |
| 114 | margin-bottom: 10px; |
| 115 | |
| 116 | } |
| 117 | |
| 118 | .timer |
| 119 | {
|
| 120 | border: 1px solid gray; |
| 121 | display: table-cell; |
| 122 | font-size: larger; |
| 123 | padding: 5px; |
| 124 | margin: 5px; |
| 125 | margin-rigth: 0px; |
| 126 | position: relative; |
| 127 | } |
| 128 | </style> |
| 129 | |
| 130 | |
| 131 | <div class="componentheading"><?php echo $this->quiz->title ; ?></div> |
| 132 | |
| 133 | <?php if ($this->quiz->time_limit) : ?> |
| 134 | <div id="timer_wrap"> |
| 135 | <p id="timer" class="timer"></p> |
| 136 | </div> |
| 137 | <?php endif ; ?> |
| 138 | |
| 139 | <form name="jquarks_quiz" method="post" action="index.php" onsubmit="return validation()"> |
| 140 | |
| 141 | <?php
|
| 142 | |
| 143 | // get the total number of pages for the quiz
|
| 144 | |
| 145 | // no pagination
|
| 146 | $nbrQuestionPage = 0 ;
|
| 147 | |
| 148 | if ($this->quiz->paginate['use_pagination'] == 2 ) |
| 149 | {
|
| 150 | // case of use global
|
| 151 | if($this->params['paginate']) |
| 152 | {
|
| 153 | // pagination is activ
|
| 154 | // getting if the pagination is by slide or by page
|
| 155 | switch ($this->params['slide']) |
| 156 | {
|
| 157 | case 0 : |
| 158 | $showType = "show" ;
|
| 159 | $hideType = "hide" ;
|
| 160 | break ;
|
| 161 | |
| 162 | case 1 : |
| 163 | $showType = "slideIn" ;
|
| 164 | $hideType = "slideOut" ;
|
| 165 | break ;
|
| 166 | } |
| 167 | |
| 168 | $nbrQuestionPage = $this->params['question_page'] ; |
| 169 | } |
| 170 | } |
| 171 | elseif ($this->quiz->paginate['use_pagination'] == 1) |
| 172 | {
|
| 173 | |
| 174 | // case of local quiz parameter
|
| 175 | if($this->quiz->paginate['use_pagination']) |
| 176 | {
|
| 177 | switch ($this->quiz->paginate['use_slide']) : |
| 178 | |
| 179 | case 0 : |
| 180 | $showType = "show" ;
|
| 181 | $hideType = "hide" ;
|
| 182 | break ;
|
| 183 | |
| 184 | case 1 : |
| 185 | $showType = "slideIn" ;
|
| 186 | $hideType = "slideOut" ;
|
| 187 | break ;
|
| 188 | |
| 189 | endswitch ;
|
| 190 | |
| 191 | $nbrQuestionPage = $this->quiz->paginate['question_page'] ; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | |
| 196 | $totalNbrQuestions = count($this->questions) ;
|
| 197 | |
| 198 | if ($nbrQuestionPage)
|
| 199 | {
|
| 200 | $nbrPage = (int)($totalNbrQuestions / $nbrQuestionPage) ; |
| 201 | |
| 202 | if($totalNbrQuestions % $nbrQuestionPage) {
|
| 203 | $nbrPage++ ; |
| 204 | } |
| 205 | } else {
|
| 206 | $nbrPage = 1 ;
|
| 207 | } |
| 208 | |
| 209 | $document =& JFactory::getDocument(); |
| 210 | |
| 211 | // The quiz is multi-pages
|
| 212 | if ($nbrPage > 1) |
| 213 | {
|
| 214 | $script = 'window.addEvent(\'domready\', function() { ' ;
|
| 215 | |
| 216 | // declaring the pages
|
| 217 | for( $pageNumber = 1 ; $pageNumber <= $nbrPage ; $pageNumber++ ) |
| 218 | {
|
| 219 | $script .= '
|
| 220 | var jquarksPage_' . $pageNumber . ' = new Fx.Slide(\'jquarksPage_' . $pageNumber . '\', {mode: \'horizontal\'}) ; ' ; |
| 221 | } |
| 222 | |
| 223 | // hiding the next pages
|
| 224 | for( $pageNumber = 2 ; $pageNumber <= $nbrPage ; $pageNumber++ ) |
| 225 | {
|
| 226 | $script .= '
|
| 227 | jquarksPage_' . $pageNumber . '.hide() ; |
| 228 | page' . $pageNumber . ' = document.getElementById(\'jquarksPage_' . $pageNumber . '\') ; |
| 229 | page' . $pageNumber . '.className="hidden" ; |
| 230 | page' . $pageNumber . '.style.visibility="hidden" ;' ; |
| 231 | } |
| 232 | |
| 233 | // adding the events to the pages
|
| 234 | for ($pageNumber = 1, $prevPage = $pageNumber - 1, $nextPage = $pageNumber + 1 ; $pageNumber <= $nbrPage ; $prevPage++, $pageNumber++, $nextPage++) |
| 235 | {
|
| 236 | if ($prevPage)
|
| 237 | {
|
| 238 | $script .= '
|
| 239 | $(\'jquarksPage_' . $pageNumber . 'back\').addEvent(\'click\', function(e){ |
| 240 | |
| 241 | jquarksPage_' . $pageNumber . '.' . $hideType .'() ; |
| 242 | page' . $pageNumber . ' = document.getElementById(\'jquarksPage_' . $pageNumber . '\') ; |
| 243 | page' . $pageNumber . '.className="hidden" ; |
| 244 | page' . $pageNumber . '.style.visibility="hidden" ; |
| 245 | |
| 246 | jquarksPage_' . $prevPage . '.' . $showType . '() ; |
| 247 | page' . $prevPage . ' = document.getElementById(\'jquarksPage_' . $prevPage . '\') ; |
| 248 | page' . $prevPage . '.className="shown" ; |
| 249 | page' . $prevPage . '.style.visibility="" ; |
| 250 | }) ' ;
|
| 251 | } |
| 252 | |
| 253 | if ($nextPage <= $nbrPage)
|
| 254 | {
|
| 255 | $script .= '
|
| 256 | $(\'jquarksPage_' . $pageNumber . 'next\').addEvent(\'click\', function(e){ |
| 257 | |
| 258 | jquarksPage_' . $pageNumber . '.' . $hideType . '() ; |
| 259 | page' . $pageNumber . ' = document.getElementById(\'jquarksPage_' . $pageNumber . '\') ; |
| 260 | page' . $pageNumber . '.className="hidden" ; |
| 261 | page' . $pageNumber . '.style.visibility="hidden" ; |
| 262 | |
| 263 | jquarksPage_' . $nextPage . '.' . $showType . '() ; |
| 264 | page' . $nextPage . ' = document.getElementById(\'jquarksPage_' . $nextPage . '\') ; |
| 265 | page' . $nextPage . '.className="shown" ; |
| 266 | page' . $nextPage . '.style.visibility="" ; |
| 267 | |
| 268 | }) ' ;
|
| 269 | } |
| 270 | } |
| 271 | |
| 272 | $script .= '
|
| 273 | }); ' ;
|
| 274 | |
| 275 | $document->addScriptDeclaration($script) ; |
| 276 | } |
| 277 | |
| 278 | // adding the corresponding styling TODO make this a css file
|
| 279 | $style = '#jquarksNav {width: 100%; }
|
| 280 | #jquarksNav ul { list-style : none ; }
|
| 281 | #jquarksNav div.hidden {display: block; float: left; position:fixed; }
|
| 282 | #jquarksNav div.shown {display: block; float: left; position:static; }';
|
| 283 | |
| 284 | $document->addStyleDeclaration($style) ; |
| 285 | ?> |
| 286 | |
| 287 | <div id="jquarksNav"> |
| 288 | <?php
|
| 289 | // qNum number of the current question
|
| 290 | // pNum number of the current page
|
| 291 | $qNum = $pNum = 1 ;
|
| 292 | |
| 293 | foreach ($this->questions as $question) |
| 294 | {
|
| 295 | if ($nbrQuestionPage)
|
| 296 | {
|
| 297 | if( $qNum % $nbrQuestionPage == 1 || $qNum == 1 || $nbrQuestionPage == 1) { |
| 298 | echo '<div id="jquarksPage_' . $pNum . '">' ; |
| 299 | } |
| 300 | } |
| 301 | else
|
| 302 | {
|
| 303 | if ( $qNum == 1 ) { |
| 304 | echo '<div id="jquarksPage_1">' ; |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | echo '<div class="contentheading">' . $question->statement . '</div>' ; |
| 309 | |
| 310 | switch($question->type_id)
|
| 311 | {
|
| 312 | case '1' : // input question |
| 313 | $questionInputId = 'answers[' . $question->id . ']' ; |
| 314 | $html = '<textarea name="' . $questionInputId . '"rows="2" cols="50"></textarea><br /><br />' ; |
| 315 | echo $html ;
|
| 316 | break ;
|
| 317 | |
| 318 | case '2' : // radio question |
| 319 | $propositions = $this->propositions[$question->id] ;
|
| 320 | echo '<ul>' ; |
| 321 | foreach ($propositions as $proposition) : |
| 322 | |
| 323 | $questionRadioId = 'answers[' . $question->id . ']' ; |
| 324 | $questionRadioProp = $proposition->id ; |
| 325 | $html = '<li><input type="radio" name="' . $questionRadioId . '" id="' . $questionRadioProp . '" value="' . $questionRadioProp . '" /><label for="' . $questionRadioProp . '">' . nl2br($proposition->answer) . '</label></li>' ; |
| 326 | echo $html ;
|
| 327 | endforeach ;
|
| 328 | echo '</ul>' ; |
| 329 | break ;
|
| 330 | |
| 331 | case '3' : // checkbox question |
| 332 | case '4' : // radio shown as checkbox |
| 333 | $propositions = $this->propositions[$question->id] ;
|
| 334 | echo '<ul>' ; |
| 335 | foreach ($propositions as $proposition) : |
| 336 | |
| 337 | $questionCheckboxId = 'answers[' . $question->id . '][' . $proposition->id . ']' ; |
| 338 | $questionCheckbox = 'q'. $question->id .'p' . $proposition->id ; |
| 339 | $html = '<li><input type="checkbox" name="' . $questionCheckboxId . '" id="' . $questionCheckbox . '" /><label for="' . $questionCheckbox . '">' . nl2br($proposition->answer) . '</label></li>' ; |
| 340 | echo $html ;
|
| 341 | endforeach ;
|
| 342 | echo '</ul>' ; |
| 343 | break ;
|
| 344 | |
| 345 | default :
|
| 346 | $html = 'Invalid Type of question' ;
|
| 347 | echo $html ;
|
| 348 | } |
| 349 | |
| 350 | // adding the back next link if multi-pages
|
| 351 | if ($nbrPage > 1) |
| 352 | {
|
| 353 | if( $pNum == (int)($qNum / $nbrQuestionPage) || $qNum == $totalNbrQuestions )
|
| 354 | {
|
| 355 | |
| 356 | if ($pNum == 1) |
| 357 | {
|
| 358 | echo '<span class="jquarks_qprog"><a id="jquarksPage_' . $pNum . 'next" href="#">' . JText::_('NEXT') . '</a>' |
| 359 | . '<p>' . JText::_("PAGE") . ' ' . $pNum . ' / ' . $nbrPage .'</p>' .'</span></div>' ; |
| 360 | } |
| 361 | elseif ( $pNum == $nbrPage )
|
| 362 | {
|
| 363 | echo '<span class="jquarks_qprog"><a id="jquarksPage_' . $pNum . 'back" href="#">' . JText::_('BACK') . '</a>' |
| 364 | . '<p>' . JText::_("PAGE") . ' ' . $pNum . ' / ' . $nbrPage .'</p>' .'</span></div>' ; |
| 365 | } |
| 366 | else
|
| 367 | {
|
| 368 | echo '<span class="jquarks_qprog"><a id="jquarksPage_' . $pNum . 'back" href="#">' . JText::_('BACK') . '</a> |
| 369 | | |
| 370 | <a id="jquarksPage_' . $pNum . 'next" href="#">' . JText::_('NEXT') . '</a>' |
| 371 | . '<p>' . JText::_("PAGE") . ' ' . $pNum . ' / ' . $nbrPage .'</p>' |
| 372 | . '</span></div>' ;
|
| 373 | } |
| 374 | $pNum ++ ; |
| 375 | } |
| 376 | } |
| 377 | $qNum++ ; |
| 378 | } |
| 379 | if ($nbrPage == 1 ) : |
| 380 | echo "</div>" ; |
| 381 | endif ;
|
| 382 | ?> |
| 383 | |
| 384 | </div> |
| 385 | <div style="clear: both;"></div> |
| 386 | <div> |
| 387 | <p> |
| 388 | <?php if ($nbrPage > 1) : ?> |
| 389 | <input type="submit" value="<?php echo JText::_('SUBMIT_ANSWERS_CHECK_PAGES') ; ?>" id="send" name="send" /> |
| 390 | <?php else : ?> |
| 391 | <input type="submit" value="<?php echo JText::_('SUBMIT_ANSWERS') ; ?>" id="send" name="send" /> |
| 392 | <?php endif ; ?> |
| 393 | </p> |
| 394 | <p> |
| 395 | <a href="http://www.jquarks.org" target="_blank">Powered by JQuarks</a> |
| 396 | </p> |
| 397 | </div> |
| 398 | |
| 399 | <?php
|
| 400 | $attribs = array('type' => 'text/css'); |
| 401 | $document->addHeadLink(JRoute::_("components/com_jquarks/assets/stylesheets/SyntaxHighlighter.css"), "stylesheet", "rel", $attribs) ; |
| 402 | ?> |
| 403 | <script language="javascript" src="<?php echo JRoute::_("components/com_jquarks/assets/js/shCore.js") ; ?>"></script> |
| 404 | <script language="javascript" src="<?php echo JRoute::_("components/com_jquarks/assets/js/shBrushCpp.js") ; ?>"></script> |
| 405 | <script language="javascript" src="<?php echo JRoute::_("components/com_jquarks/assets/js/shBrushCSharp.js") ; ?>"></script> |
| 406 | <script language="javascript" src="<?php echo JRoute::_("components/com_jquarks/assets/js/shBrushCss.js") ; ?>"></script> |
| 407 | <script language="javascript" src="<?php echo JRoute::_("components/com_jquarks/assets/js/shBrushDelphi.js") ; ?>"></script> |
| 408 | <script language="javascript" src="<?php echo JRoute::_("components/com_jquarks/assets/js/shBrushJava.js") ; ?>"></script> |
| 409 | <script language="javascript" src="<?php echo JRoute::_("components/com_jquarks/assets/js/shBrushJScript.js") ; ?>"></script> |
| 410 | <script language="javascript" src="<?php echo JRoute::_("components/com_jquarks/assets/js/shBrushPhp.js") ; ?>"></script> |
| 411 | <script language="javascript" src="<?php echo JRoute::_("components/com_jquarks/assets/js/shBrushPython.js") ; ?>"></script> |
| 412 | <script language="javascript" src="<?php echo JRoute::_("components/com_jquarks/assets/js/shBrushRuby.js") ; ?>"></script> |
| 413 | <script language="javascript" src="<?php echo JRoute::_("components/com_jquarks/assets/js/shBrushSql.js") ; ?>"></script> |
| 414 | <script language="javascript" src="<?php echo JRoute::_("components/com_jquarks/assets/js/shBrushVb.js") ; ?>"></script> |
| 415 | <script language="javascript" src="<?php echo JRoute::_("components/com_jquarks/assets/js/shBrushXml.js") ; ?>"></script> |
| 416 | <script language="javascript"> |
| 417 | dp.SyntaxHighlighter.ClipboardSwf = 'administrator/components/com_jquarks/assets/js/clipboard.swf'; |
| 418 | dp.SyntaxHighlighter.BloggerMode(); |
| 419 | dp.SyntaxHighlighter.HighlightAll('code');
|
| 420 | </script> |
| 421 | |
| 422 | <input type="hidden" name="option" value="com_jquarks" /> |
| 423 | <input type="hidden" name="id" value="<?php echo $this->quiz->id ; ?>"/> |
| 424 | <input type="hidden" name="sessionId" value="<?php echo $this->sessionId ; ?>"/> |
| 425 | <input type="hidden" id="timeUp" name="timeUp" value="0" /> |
| 426 | <input type="hidden" name="task" value="submitAnswer" /> |
| 427 | <input type="hidden" name="view" value="quiz" /> |
| 428 | <input type="hidden" name="showResults" value="<?php echo $this->isShowResults ; ?>" /> |
| 429 | |
| 430 | <?php echo JHTML::_( 'form.token' ); ?> |
| 431 | </form> |
| 432 | |
| 433 | <?php endif ; ?> |