Skip to content

Commit

Permalink
Quiz confirmation popup is now for limited attempts and/or timelimit,…
Browse files Browse the repository at this point in the history
… or a combination of the above
  • Loading branch information
mjollnir_ committed Jan 11, 2006
1 parent 46d0a76 commit 2422dc9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lang/en/quiz.php
Expand Up @@ -73,6 +73,8 @@
$string['confirmclose'] = 'You are about to close this attempt. Once you close the attempt you will no longer be able to change your answers.';
$string['confirmserverdelete'] = 'Are you sure you want to remove the server <b>$a</b> from the list?';
$string['confirmstartattempt'] = 'The Quiz has a time limit. Are you sure that you wish to start?';
$string['confirmstartattemptnotimelimit'] = 'This quiz is limited to $a attempts. Accessing the quiz will be counted as an attempt. Do you wish to proceed?';
$string['confirmstartattempttimelimit'] = 'This quiz has a time limit and is limited to $a attempts. Accessing the quiz will be counted as an attempt. Do you wish to proceed?';
$string['containercategorycreated'] = 'This category has been created to store all the original categories moved to site level due to the causes specified below.';
$string['continueattemptquiz'] = 'Continue the last attempt';
$string['copyingfrom'] = 'Creating a copy of the question \'$a\'';
Expand Down
20 changes: 17 additions & 3 deletions mod/quiz/view.php
Expand Up @@ -211,8 +211,15 @@
'resizeable=no, directories=no, toolbar=no, titlebar=no, location=no, status=no, '+
'menubar=no';\n";
$jslink = 'javascript:';
if ($quiz->timelimit) {
$jslink .= "if (confirm('$strconfirmstartattempt')) ";
if ($quiz->timelimit && !$quiz->attempts) {
$strconfirmstartattempt = addslashes(get_string("confirmstartattempt","quiz"));
$jslink .= "if (confirm(\'$strconfirmstartattempt\')) ";
} else if ($quiz->timelimit && $quiz->attempts) {
$strconfirmstartattempt = addslashes(get_string("confirmstartattempttimelimit","quiz",$quiz->attempts));
$jslink .= "if (confirm(\'$strconfirmstartattempt\')) ";
} else if ($quiz->attempts && !$quiz->timelimit) {
$strconfirmstartattempt = addslashes(get_string("confirmstartattemptnotimelimit","quiz",$quiz->attempts));
$jslink .= "if (confirm(\'$strconfirmstartattempt\')) ";
}
$jslink .= "var popup = window.open(\\'$attempturl\\', \\'quizpopup\\', windowoptions);";
} else {
Expand Down Expand Up @@ -292,7 +299,14 @@
if ($numattempts and $quiz->grade) {
print_heading("$strbestgrade: $mygrade / $quiz->grade.");
}
$strconfirmstartattempt = addslashes(get_string("confirmstartattempt","quiz"));
if ($quiz->timelimit && !$quiz->attempts) {
$strconfirmstartattempt = addslashes(get_string("confirmstartattempt","quiz"));
} else if ($quiz->timelimit && $quiz->attempts) {
$strconfirmstartattempt = addslashes(get_string("confirmstartattempttimelimit","quiz",$quiz->attempts));
} else if ($quiz->attempts && !$quiz->timelimit) {
$strconfirmstartattempt = addslashes(get_string("confirmstartattemptnotimelimit","quiz",$quiz->attempts));
}

echo "<br />";
echo "</p>";
echo "<div align=\"center\">";
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/view_js.php
Expand Up @@ -15,7 +15,7 @@
<script language="javascript" type="text/javascript">
<!--
document.write('<input type="button" value="<?php echo $buttontext ?>" '+
'onclick="javascript: <?php if ($quiz->timelimit and !$unfinished) echo "if (confirm(\\'$strconfirmstartattempt\\'))"; ?> '+
'onclick="javascript: <?php if ($quiz->timelimit || $quiz->attempts) echo "if (confirm(\\'$strconfirmstartattempt\\'))"; ?> '+
'window.open(\'<?php echo $attempturl ?>\', \'<?php echo $window ?>\', \'<?php echo $windowoptions ?>\'); " />');
// -->
</script>
Expand Down

0 comments on commit 2422dc9

Please sign in to comment.