Index: temp_moodle_dev/moodle/mod/quiz/view.php
===================================================================
RCS file: /usr/local/cvsroot/temp_moodle_dev/moodle/mod/quiz/view.php,v
diff -u -r1.1 -r1.2
--- temp_moodle_dev/moodle/mod/quiz/view.php 14 Nov 2008 05:57:17 -0000 1.1
+++ temp_moodle_dev/moodle/mod/quiz/view.php 14 Nov 2008 06:16:59 -0000 1.2
@@ -1,17 +1,21 @@
libdir.'/blocklib.php');
+ //add new library so Lams can use their functions
+ require_once($CFG->libdir.'/weblib.php');
+ //
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->dirroot.'/mod/quiz/locallib.php');
require_once($CFG->dirroot.'/mod/quiz/pagelib.php');
-
$id = optional_param('id', 0, PARAM_INT); // Course Module ID, or
$q = optional_param('q', 0, PARAM_INT); // quiz ID
$edit = optional_param('edit', -1, PARAM_BOOL);
-
+ $is_learner = optional_param('is_learner',0, PARAM_INT);
+ $editing = optional_param('editing', 0, PARAM_INT);
+ $returnurl = optional_param('returnUrl', '', PARAM_TEXT); // lams url to proceed to next in sequence
if ($id) {
if (! $cm = get_coursemodule_from_id('quiz', $id)) {
error("There is no coursemodule with id $id");
@@ -33,14 +37,21 @@
error("The course module for the quiz with id $q is missing");
}
}
-
+ //if is inside a Lams sequence we pass the Lams Update URL to be able to come back to Lams later
+ if($quiz->is_lams==1){
+ $lamsupdateurl = urlencode(optional_param('lamsUpdateURL', PARAM_TEXT));
+ }
// Check login and get context.
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
// if no questions have been set up yet redirect to edit.php
if (!$quiz->questions and has_capability('mod/quiz:manage', $context)) {
- redirect($CFG->wwwroot . '/mod/quiz/edit.php?cmid=' . $cm->id);
+ if($quiz->is_lams==1){ //if is inside a Lams sequence we pass the Lams Update URL to be able to come back to Lams later
+ redirect($CFG->wwwroot . '/mod/quiz/edit.php?cmid=' . $cm->id.'&lamsUpdateURL='.$lamsupdateurl);
+ }else{
+ redirect($CFG->wwwroot . '/mod/quiz/edit.php?cmid=' . $cm->id.'');
+ }
}
add_to_log($course->id, "quiz", "view", "view.php?id=$cm->id", $quiz->id, $cm->id);
@@ -54,11 +65,18 @@
if ($edit != -1 and $PAGE->user_allowed_editing()) {
$USER->editing = $edit;
}
+
//only check pop ups if the user is not a teacher, and popup is set
- $bodytags = (has_capability('mod/quiz:attempt', $context) && $quiz->popup)?'onload="popupchecker(\'' . get_string('popupblockerwarning', 'quiz') . '\');"':'';
- $PAGE->print_header($course->shortname.': %fullname%','',$bodytags);
+ $bodytags =(has_capability('mod/quiz:attempt', $context) && $quiz->popup)?'onload="popupchecker(\'' . get_string('popupblockerwarning', 'quiz') . '\');"':'';
+ //if is a Lams sequence activity don't print the top header
+ if($quiz->is_lams==1){
+ print_header();
+ }else{
+ $PAGE->print_header($course->shortname.': %fullname%','',$bodytags);
+ }
+
echo '
';
@@ -77,8 +95,9 @@
// Print heading and tabs (if there is more than one).
$currenttab = 'info';
+
include('tabs.php');
-
+
// Print quiz name
print_heading(format_string($quiz->name));
@@ -100,6 +119,19 @@
if ($quiz->attempts != 1) {
echo "".get_string("grademethod", "quiz").": ".quiz_get_grading_option_name($quiz->grademethod)."
";
}
+ //if you are in lams and you've done more than one attempt display lams navigation buttons
+ if($quiz->is_lams==1){
+ if ($quiz->attempts >= 1) {
+ if($editing == 1) {
+ //if you are editing, finish editing an go back to lams
+ include('showlamsfinish.php');
+ }else{
+ //if you a learner or a teacher that does the activity as a learner, go to the next activity
+ include('showlamsnext.php');
+ }
+
+ }
+ }
// Print information about timings.
$timenow = time();
@@ -127,7 +159,7 @@
// Show number of attempts summary to those who can view reports.
if (has_capability('mod/quiz:viewreports', $context)) {
if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm)) {
- echo '';
}
}
@@ -141,14 +173,15 @@
notice_yesno('' . get_string('guestsno', 'quiz') . "
\n\n" .
get_string('liketologin') . '', $loginurl, get_referer(false));
- finish_page($course);
+ finish_page($course,$quiz);//we pass $quiz
}
if (!(has_capability('mod/quiz:attempt', $context) || has_capability('mod/quiz:preview', $context))) {
- print_box('' . get_string('youneedtoenrol', 'quiz') . '
' .
+ print_box('
' . get_string('youneedtoenrol', 'quiz') . '
' .
print_continue($CFG->wwwroot . '/course/view.php?id=' . $course->id, true) .
'
', 'generalbox', 'notice');
- finish_page($course);
+ finish_page($course,$quiz);// we pass $quiz so later we can check the is_lams variable
+ // old finish_page($course);
}
// Get this user's attempts.
@@ -183,9 +216,25 @@
// Print table with existing attempts
if ($attempts) {
-
+ if($quiz->is_lams==1){
+ if($editing==1){
+ include('showlamsfinish.php');
+ }else{
+ //if($is_learner==1){
+ include('showlamsnext.php');
+ //}
+ }
+ }
print_heading(get_string('summaryofattempts', 'quiz'));
+ // Get some strings.
+ $strattempt = get_string("attempt", "quiz");
+ $strtimetaken = get_string("timetaken", "quiz");
+ $strtimecompleted = get_string("timecompleted", "quiz");
+ $strgrade = get_string("grade");
+ $strmarks = get_string('marks', 'quiz');
+ $strfeedback = get_string('feedback', 'quiz');
+
// Work out which columns we need, taking account what data is available in each attempt.
list($someoptions, $alloptions) = quiz_get_combined_reviewoptions($quiz, $attempts, $context);
@@ -196,28 +245,28 @@
$feedbackcolumn = quiz_has_feedback($quiz->id);
$overallfeedback = $feedbackcolumn && $alloptions->overallfeedback;
- // Prepare table header
+ // prepare table header
$table->class = 'generaltable quizattemptsummary';
- $table->head = array(get_string('attempt', 'quiz'), get_string('timecompleted', 'quiz'));
- $table->align = array('center', 'left');
- $table->size = array('', '');
+ $table->head = array($strattempt, $strtimecompleted);
+ $table->align = array("center", "left");
+ $table->size = array("", "");
if ($markcolumn) {
- $table->head[] = get_string('marks', 'quiz') . " / $quiz->sumgrades";
+ $table->head[] = "$strmarks / $quiz->sumgrades";
$table->align[] = 'center';
$table->size[] = '';
}
if ($gradecolumn) {
- $table->head[] = get_string('grade') . " / $quiz->grade";
+ $table->head[] = "$strgrade / $quiz->grade";
$table->align[] = 'center';
$table->size[] = '';
}
if ($feedbackcolumn) {
- $table->head[] = get_string('feedback', 'quiz');
+ $table->head[] = $strfeedback;
$table->align[] = 'left';
$table->size[] = '';
}
if (isset($quiz->showtimetaken)) {
- $table->head[] = get_string('timetaken', 'quiz');
+ $table->head[] = $strtimetaken;
$table->align[] = 'left';
$table->size[] = '';
}
@@ -229,6 +278,7 @@
// Add the attempt number, making it a link, if appropriate.
if ($attempt->preview) {
+
$row[] = make_review_link(get_string('preview', 'quiz'), $quiz, $attempt);
} else {
$row[] = make_review_link($attempt->attempt, $quiz, $attempt);
@@ -339,6 +389,11 @@
// Print a button to start/continue an attempt, if appropriate.
if (!$quiz->questions) {
print_heading(get_string("noquestions", "quiz"));
+
+ //print button "next activity" to continue
+ if($quiz->is_lams==1){
+ include('showlamsnext.php');
+ }
} else if ($available && $moreattempts) {
echo "
";
@@ -351,9 +406,30 @@
$buttontext = get_string('continueattemptquiz', 'quiz');
}
} else {
+
+ // print next button to continue next activity in lams
+
+ if($quiz->is_lams==1){
+ //m acabar
+ //if($is_learner==1){
+ //finish is_learner
+ //include('showlamsnext.php');
+ //}else{
+ if($editing==1){
+ include('showlamsfinish.php');
+ }
+ //}
+
+ }
// Work out the appropriate button caption.
if (has_capability('mod/quiz:preview', $context)) {
+ //lams: if you are a teacher and are doing a preview of the activity show next activity button
+ if($editing==1){
+ include('showlamsfinish.php');
+ }else{
+ include('showlamsnext.php');
+ }
$buttontext = get_string('previewquiznow', 'quiz');
} else if ($numattempts == 0) {
$buttontext = get_string('attemptquiznow', 'quiz');
@@ -400,8 +476,8 @@
$strconfirmstartattempt = '';
}
// Determine the URL to use.
- $attempturl = "attempt.php?id=$cm->id";
-
+ $attempturl = "attempt.php?id=$cm->id";
+
// Prepare options depending on whether the quiz should be a popup.
if (!empty($quiz->popup)) {
$window = 'quizpopup';
@@ -420,7 +496,7 @@
}
echo "window.open('$attempturl','$window','$windowoptions');", '" />';
} else {
- print_single_button("attempt.php", array('id'=>$cm->id), $buttontext, 'get', '', false, '', false, $strconfirmstartattempt);
+ print_single_button("attempt.php", array('id'=>$cm->id), $buttontext, 'get', '', false, '', false, $strconfirmstartattempt);
}
@@ -440,15 +516,18 @@
// Should we not be seeing if we need to print right-hand-side blocks?
- finish_page($course);
+ finish_page($course,$quiz);// we pass $quiz so later we can check the is_lams variable
+ // old finish_page($course);
// Utility functions =================================================================
-function finish_page($course) {
+function finish_page($course,$quiz=null) { // we pass $quiz so we can check the is_lams variable
+ //old function finish_page($course) {
global $THEME;
print_container_end();
echo '
';
- print_footer($course);
+ //we pass a new parameter to the function so it won't we printed if is_lams=1
+ print_footer($course,null, false,$quiz->is_lams);
exit;
}
@@ -460,13 +539,13 @@
}
// If the quiz is still open, are reviews allowed?
- if ((!$quiz->timeclose or time() < $quiz->timeclose) and !($quiz->review & QUIZ_REVIEW_OPEN & QUIZ_REVIEW_RESPONSES)) {
+ if ((!$quiz->timeclose or time() < $quiz->timeclose) and !($quiz->review & QUIZ_REVIEW_OPEN)) {
// If not, don't link.
return $linktext;
}
// If the quiz is closed, are reviews allowed?
- if (($quiz->timeclose and time() > $quiz->timeclose) and !($quiz->review & QUIZ_REVIEW_CLOSED & QUIZ_REVIEW_RESPONSES)) {
+ if (($quiz->timeclose and time() > $quiz->timeclose) and !($quiz->review & QUIZ_REVIEW_CLOSED)) {
// If not, don't link.
return $linktext;
}