diff -u --recursive --new-file c:\xampp\htdocs\moodle\mod\quiz/attempt.php c:\xampp\htdocs\moodle192\mod\quiz\/attempt.php --- moodle\mod\quiz/attempt.php 2008-07-03 08:17:50.000000000 +0200 +++ moodle192\mod\quiz\/attempt.php 2008-07-14 16:40:29.712619500 +0200 @@ -1,4 +1,4 @@ -timestart = $timestamp - 1; } + + //Check if the current page number is bigger than the highest ever visited in this attempt + //if so, set the current page number as the highest ever visited + if($page > $attempt->lastpage) { + if($page - $attempt->lastpage >= 2 and $quiz->noback == 0) { + $page = $attempt->lastpage+1; + } + $attempt->lastpage = $page; + } + + //Check if the user manually requests a lower page number + //if so, redirect to highest number ever visited - no cheating allowed =) + //$quiz->noback == 0 ==> zur�ck nicht erlauben + if($page < $attempt->lastpage and $quiz->noback == 0) { + $page = $attempt->lastpage; + } /// Load all the questions and states needed by this script @@ -484,7 +500,11 @@ /// Print the navigation panel if required $numpages = quiz_number_of_pages($attempt->layout); if ($numpages > 1) { - quiz_print_navigation_panel($page, $numpages); + if($quiz->noback == 0) { + quiz_print_navigation_panel_noback($page, $numpages); + } else { + quiz_print_navigation_panel($page, $numpages); + } } /// Print all the questions @@ -507,12 +527,23 @@ echo "\n"; } echo "\n"; + + //Add "NEXT"-Button + + if($page < $numpages-1 and $quiz->noback == 0) { + echo "\n"; + } + echo ""; // Print the navigation panel if required if ($numpages > 1) { - quiz_print_navigation_panel($page, $numpages); + if($quiz->noback == 0) { + #quiz_print_navigation_panel_noback($page, $numpages); + } else { + quiz_print_navigation_panel($page, $numpages); + } } // Finish the form @@ -539,8 +570,9 @@ } if ($showtimer && (!$ispreviewing || $timerstartvalue > 0)) { $timerstartvalue = max($timerstartvalue, 1); // Make sure it starts just above zero. - require('jstimer.php'); + $showtimer = true; } + require('jstimer.php'); // Finish the page if (empty($popup)) { diff -u --recursive --new-file moodle\mod\quiz/jstimer.php moodle192\mod\quiz\/jstimer.php --- moodle\mod\quiz/jstimer.php 2007-11-03 09:52:36.000000000 +0100 +++ moodle192\mod\quiz\/jstimer.php 2008-08-07 11:51:56.078019100 +0200 @@ -29,6 +29,8 @@ +
+ + + + + + noback == 1) { + ?> + + +
+ + + prefix."question_states m1 + JOIN ".$CFG->prefix."question q + ON q.id=m1.question + INNER JOIN (SELECT question, MAX(timestamp) AS Maxtime FROM ".$CFG->prefix."question_states + WHERE attempt = '{$attempt->uniqueid}' AND question IN($attempt->layout) GROUP BY question) m2 + ON m1.question = m2.question AND m1.timestamp = m2.Maxtime"; + // SELECT * FROM mdl_question_states m1 INNER JOIN (SELECT question, MAX(timestamp) AS Maxtime FROM mdl_question_states WHERE attempt = '12' GROUP BY question) m2 ON m1.question = m2.question AND m1.timestamp = m2.Maxtime + $allgradedstates = get_records_sql($sql); + #echo $sql; + #echo $attempt->uniqueid; + #var_dump($allgradedstates); + $i_page=0; + $i_question=1; + $i=0; + $qids=explode(",",$attempt->layout); + + foreach($qids as $id) { + if($i%7 == 0) { + echo ""; + } + if($id != 0) { // 0 is a pagebreak + + $answered=false; + if($allgradedstates[$id]->qtype == "multichoice") { + // 1,2,3-ANSWER + $tmp=explode(":",$allgradedstates[$id]->answer); + if($tmp[1] != "") $answered=true; + + } elseif($allgradedstates[$id]->qtype == "calculated") { + // dataset?-ANSWER + $tmp=explode("-",$allgradedstates[$id]->answer); + if($tmp[1] != "") $answered=true; + + } elseif($allgradedstates[$id]->qtype == "essay" OR $allgradedstates[$id]->qtype == "numerical" OR $allgradedstates[$id]->qtype == "shortanswer" OR $allgradedstates[$id]->qtype == "truefalse") { + if($allgradedstates[$id]->answer != "") $answered=true; + + } elseif($allgradedstates[$id]->qtype == "match" OR $allgradedstates[$id]->qtype == "randomsamatch") { + // 1-ANSWER,2-ANSWER,... + $mq=0; + $tmp=explode(",",$allgradedstates[$id]->answer); + foreach($tmp as $choose) { + $answer=explode("-",$choose); + if($answer[1] != 0) $mq++; + } + if($mq == count($tmp)) $answered=true; + + } elseif($allgradedstates[$id]->qtype == "multianswer") { + // 1-ANSWER,2-ANSWER,... + $mq=0; + $tmp=explode(",",$allgradedstates[$id]->answer); + foreach($tmp as $choose) { + $answer=explode("-",$choose); + if($answer[1] != "") $mq++; + } + if($mq == count($tmp)) $answered=true; + + } + + + if($i_page == $page) { + $style="background-color:silver;"; + } + if($quiz->noback == 1) { + $onclick="onclick=\"navigate(".$i_page.",'#q".$allgradedstates[$id]->question."');\""; + } + if($allgradedstates[$id]->qtype != "description") + { + if($answered == true) { + echo ""; + } else { + echo ""; + } + unset($style); + $i_question++; + $i++; + } + } else { + $i_page++; + } + + } + ?> + +
".$i_question."".$i_question."
+ + + diff -u --recursive --new-file moodle\mod\quiz/locallib.php moodle192\mod\quiz\/locallib.php --- moodle\mod\quiz/locallib.php 2008-04-24 08:18:04.000000000 +0200 +++ moodle192\mod\quiz\/locallib.php 2008-07-03 17:27:26.000000000 +0200 @@ -228,21 +228,65 @@ * @param integer $page The number of the current page (counting from 0). * @param integer $pages The total number of pages. */ +function quiz_print_navigation_panel_noback($page, $pages) { + //$page++; + echo '
'; + echo '' . get_string('page') . ':'; + + //Zur�ck-Link nicht mehr enzeigen + +// if ($page > 0) { +// // Print previous link +// $strprev = get_string('previous'); +// echo '(' . $strprev . ')'; +// } + + //Nur mehr die Seitenzahlen anzeigen, aber keine Links mehr darauf + + for ($i = 0; $i < $pages; $i++) { + if ($i == $page) { + echo ''.($i+1).''; + } else { + //echo ''.($i+1).''; + echo '' . ($i+1) . ''; + } + } + + //N�chste-Link bleibt wie er ist... + + if ($page < $pages - 1) { + // Print next link + $strnext = get_string('next'); + echo '(' . $strnext . ')'; + } + echo '
'; +} + +/** + * Print navigation panel for quiz attempt and review pages + * + * @param integer $page The number of the current page (counting from 0). + * @param integer $pages The total number of pages. + */ function quiz_print_navigation_panel($page, $pages) { //$page++; echo '
'; echo '' . get_string('page') . ':'; + if ($page > 0) { // Print previous link $strprev = get_string('previous'); echo '(' . $strprev . ')'; } + for ($i = 0; $i < $pages; $i++) { if ($i == $page) { echo ''.($i+1).''; } else { - echo ''.($i+1).''; + echo ''.($i+1).''; } } diff -u --recursive --new-file moodle\mod\quiz/mod_form.php moodle192\mod\quiz\/mod_form.php --- moodle\mod\quiz/mod_form.php 2007-11-24 09:26:08.000000000 +0100 +++ moodle192\mod\quiz\/mod_form.php 2008-07-03 17:07:12.000000000 +0200 @@ -113,6 +113,11 @@ $mform->setHelpButton('adaptive', array("adaptive", get_string("adaptive","quiz"), "quiz")); $mform->setAdvanced('adaptive', $CFG->quiz_fix_adaptive); $mform->setDefault('adaptive', $CFG->quiz_optionflags & QUESTION_ADAPTIVE); + + $mform->addElement('selectyesno', 'noback', get_string("noback", "quiz")); + $mform->setHelpButton('noback', array("noback", get_string("noback","quiz"), "quiz")); + $mform->setAdvanced('noback', $CFG->quiz_fix_noback); + $mform->setDefault('noback', 1); //------------------------------------------------------------------------------- diff -u --recursive --new-file moodle\mod\quiz/quiz.js moodle192\mod\quiz\/quiz.js --- moodle\mod\quiz/quiz.js 2008-04-18 08:15:54.000000000 +0200 +++ moodle192\mod\quiz\/quiz.js 2008-08-07 11:40:23.626219100 +0200 @@ -7,9 +7,9 @@ */ /* Used by quiz navigation links to force a form submit, and hence save the user's data. */ -function navigate(page) { +function navigate(page,anker) { var ourForm = document.getElementById('responseform'); - ourForm.action = ourForm.action.replace(/page=.*/, 'page=' + page); + ourForm.action = ourForm.action.replace(/page=.*/, 'page=' + page+anker); if (ourForm.onsubmit) { ourForm.onsubmit(); } @@ -87,7 +87,20 @@ } if (pos == old) { timerbox.style.top = pos + 'px'; + if (typeof window.innerWidth == "undefined") { + timerbox.style.margin = '0 0 0 ' + (document.body.clientWidth - timerbox.offsetWidth) + 'px'; + } + else { + timerbox.style.margin = '0 0 0 ' + (window.innerWidth - timerbox.offsetWidth - 30) + 'px'; + } } old = pos; temp = setTimeout('movecounter(timerbox)',100); } + +function highlight(id) { + document.getElementById("qid_"+id).style.textDecoration="underline overline"; +} +function dehighlight(id) { + document.getElementById("qid_"+id).style.textDecoration="none"; +}