Index: moodle/mod/lamslesson/lib.php
===================================================================
RCS file: /usr/local/cvsroot/moodle/mod/lamslesson/lib.php,v
diff -u -r1.2 -r1.3
--- moodle/mod/lamslesson/lib.php 21 Jan 2011 13:25:46 -0000 1.2
+++ moodle/mod/lamslesson/lib.php 24 Jan 2011 02:37:39 -0000 1.3
@@ -53,11 +53,13 @@
define('LAMSLESSON_PARAM_AUTHOR_METHOD', 'author');
define('LAMSLESSON_PARAM_MONITOR_METHOD', 'monitor');
define('LAMSLESSON_PARAM_LEARNER_METHOD', 'learner');
+define('LAMSLESSON_PARAM_PREVIEW_METHOD', 'preview');
define('LAMSLESSON_PARAM_SINGLE_PROGRESS_METHOD', 'singleStudentProgress');
define('LAMSLESSON_PARAM_PROGRESS_METHOD', 'studentProgress');
define('LAMSLESSON_PARAM_CUSTOM_CSV', 'customCSV');
define('LAMSLESSON_LD_SERVICE', '/services/xml/LearningDesignRepository');
define('LAMSLESSON_LESSON_MANAGER', '/services/xml/LessonManager');
+define('LAMSLESSON_POPUP_OPTIONS', 'location=0,toolbar=0,menubar=0,statusbar=0,width=996,height=700,resizable');
/**
* If you for some reason need to use global variables instead of constants, do not forget to make them
@@ -374,7 +376,7 @@
// start the lesson
$form->lesson_id = lamslesson_get_lesson(
$USER->username, $form->sequence_id, $form->course,
- $form->name, $form->intro,
+ $form->name, $form->intro, 'start',
$locale['country'], $locale['lang'], $form->customCSV
);
@@ -479,8 +481,8 @@
* @param string $lang The Language's ISO code
* @return int lesson id
*/
-function lamslesson_get_lesson($username,$ldid,$courseid,$title,$desc,$country,$lang,$customcsv='') {
- //echo "enter lamslesson_get_lesson
";
+function lamslesson_get_lesson($username,$ldid,$courseid,$title,$desc,$method,$country,$lang,$customcsv='') {
+
global $CFG, $USER;
if (!isset($CFG->lamslesson_serverid, $CFG->lamslesson_serverkey) || $CFG->lamslesson_serverid == "") {
print_error(get_string('notsetup', 'lamslesson'));
@@ -498,7 +500,7 @@
$title = urlencode($title);
$desc = urlencode($desc);
- $request = "$CFG->lamslesson_serverurl" . LAMSLESSON_LESSON_MANAGER . "?method=start&serverId=" . $CFG->lamslesson_serverid . "&datetime=" . $datetime_encoded . "&hashValue=" . $hashvalue . "&username=" . $username . "&ldId=" . $ldid . "&courseId=" . $courseid . "&title=" . $title . "&desc=" . $desc . "&country=" . $country . "&lang=" . $lang;
+ $request = "$CFG->lamslesson_serverurl" . LAMSLESSON_LESSON_MANAGER . "?method=" . $method . "&serverId=" . $CFG->lamslesson_serverid . "&datetime=" . $datetime_encoded . "&hashValue=" . $hashvalue . "&username=" . $username . "&ldId=" . $ldid . "&courseId=" . $courseid . "&title=" . $title . "&desc=" . $desc . "&country=" . $country . "&lang=" . $lang;
// GET call to LAMS
$xml = file_get_contents($request);
@@ -543,7 +545,7 @@
* URL redirects LAMS to learner or monitor interface depending on method.
*/
function lamslesson_get_url($username, $lang, $country, $lessonid, $courseid, $coursename, $coursecreatedate, $method, $customcsv='') {
- global $CFG, $LAMS2CONSTANTS;
+ global $CFG;
// append month/year to course name
$coursename = $coursename.' '.date('n/Y', $coursecreatedate);
Index: moodle/mod/lamslesson/mod_form.php
===================================================================
RCS file: /usr/local/cvsroot/moodle/mod/lamslesson/mod_form.php,v
diff -u -r1.4 -r1.5
--- moodle/mod/lamslesson/mod_form.php 23 Jan 2011 17:39:06 -0000 1.4
+++ moodle/mod/lamslesson/mod_form.php 24 Jan 2011 02:37:39 -0000 1.5
@@ -31,7 +31,8 @@
$PAGE->requires->yui2_lib('yahoo-dom-event');
$PAGE->requires->yui2_lib('treeview');
-
+$PAGE->requires->yui2_lib('event');
+$PAGE->requires->yui2_lib('connection');
require_once($CFG->dirroot.'/course/moodleform_mod.php');
class mod_lamslesson_mod_form extends moodleform_mod {
@@ -67,43 +68,67 @@
$locale = lamslesson_get_locale($COURSE->id);
$canmanage = has_capability('mod/lamslesson:manage', $context);
- //-- Open URL button
+ //-- Open Author & Preview URL buttons
// Check whether this person has the right permissions to see the open button.
if ($canmanage) {
$customcsv = "$USER->username,$COURSE->id,$CFG->lamslesson_serverid";
$authorurl = lamslesson_get_url($USER->username, $locale['lang'], $locale['country'], 0, $COURSE->id, $COURSE->fullname, $COURSE->timecreated, LAMSLESSON_PARAM_AUTHOR_METHOD, $customcsv);
+
+ $previewurl = $CFG->wwwroot.'/mod/lamslesson/preview.php?';
+ $popupoptions = LAMSLESSON_POPUP_OPTIONS;
$openauthorlabel = get_string('openauthor', 'lamslesson');
+ $openpreviewlabel = get_string('previewthislesson', 'lamslesson');
// html "chunk" for open Author button
- $authorbutton = <<
-
+ var authorWin = null;
+ var previewWin = null;
+ var options = '$popupoptions';
+
+ function openAuthor(url,name,fullscreen) {
+ url = url + "&requestSrc=" + escape("$CFG->lamslesson_requestsource");
+ url = url + "¬ifyCloseURL=" + escape(window.location.href);
+ if(authorWin && !authorWin.closed){
+ authorWin.focus();
+ }else{
+ authorWin = window.open(url,name,options);
+ if (fullscreen) {
+ authorWin.moveTo(0,0);
+ authorWin.resizeTo(screen.availWidth,screen.availHeight);
+ }
+ authorWin.focus();
+ }
+ return false;
+ }
+ function openPreview(url,name,fullscreen) {
+
+ url = url + "&ldId=" + document.getElementsByName("sequence_id")[0].value;
+ url = url + "&course=" + $COURSE->id;
+ previewWin = window.open(url,name,options);
+ if (fullscreen) {
+ previewWin.moveTo(0,0);
+ previewWin.resizeTo(screen.availWidth,screen.availHeight);
+ }
+ previewWin.focus();
+ return false;
+ }
+
+ //-->
+
+
XXX;
}
@@ -130,6 +155,9 @@
if (document.getElementsByName("name")[0].value == '') {
document.getElementsByName("name")[0].value = name;
}
+ document.getElementById('previewbutton').style.visibility='visible';
+ } else {
+ document.getElementById('previewbutton').style.visibility='hidden';
}
}
@@ -157,7 +185,7 @@
XXX;
// Now we put the two html chunks together
-$html = $authorbutton . $html;
+$html = $authorpreviewbutton . $html;
$mform->addElement('header', 'selectsequence', get_string('selectsequence', 'lamslesson'));
Index: moodle/mod/lamslesson/preview.php
===================================================================
RCS file: /usr/local/cvsroot/moodle/mod/lamslesson/preview.php,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ moodle/mod/lamslesson/preview.php 24 Jan 2011 02:37:39 -0000 1.1
@@ -0,0 +1,61 @@
+.
+
+
+/**
+ * Prepares and launches a preview lesson
+ *
+ * @copyright 2011 LAMS Foundation - Ernie Ghiglione (ernieg@lamsfoundation.org)
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU GPL v2
+ */
+
+require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
+require_once(dirname(__FILE__).'/lib.php');
+
+$course = optional_param('course', 0, PARAM_INT); // course
+$ldId = optional_param('ldId', 0, PARAM_INT); // learning design ID we want to create a preview instance for.
+
+
+if ($course != 0) {
+ $course = $DB->get_record('course', array('id' => $course), '*', MUST_EXIST);
+} else {
+ print_error('You must specify a course');
+}
+
+require_login($course);
+
+// Check permissions and capabilities:
+
+$context = get_context_instance(CONTEXT_COURSE, $course->id);
+$locale = lamslesson_get_locale($course->id);
+
+$canmanage = has_capability('mod/lamslesson:manage', $context);
+
+if ($canmanage) {
+
+ // Get a lessonID from LAMS first
+ $lessonID = lamslesson_get_lesson($USER->username, $ldId, $course->id, 'preview', 'preview', LAMSLESSON_PARAM_PREVIEW_METHOD, $locale['country'], $locale['lang'],'');
+
+ // With the lesson now we put together the URL
+ $learnerurl = lamslesson_get_url($USER->username, $locale['lang'], $locale['country'], $lessonID, $course->id, $course->fullname, $course->timecreated, LAMSLESSON_PARAM_LEARNER_METHOD);
+ header('Location:'.$learnerurl."'");
+ die();
+
+} else {
+ // Don't have permission so finish here
+ print_error('Sorry, you don\'t have permissions to perform this task');
+}
Index: moodle/mod/lamslesson/styles.css
===================================================================
RCS file: /usr/local/cvsroot/moodle/mod/lamslesson/styles.css,v
diff -u -r1.4 -r1.5
--- moodle/mod/lamslesson/styles.css 23 Jan 2011 17:39:06 -0000 1.4
+++ moodle/mod/lamslesson/styles.css 24 Jan 2011 02:37:39 -0000 1.5
@@ -5,9 +5,10 @@
.path-mod-lamslesson .super {position:relative;bottom:0.5em;color:red;font-size:0.8em;}
/* Button styles */
-#authorbutton a {padding-left: 2.25em;background: url([[pix:i/admin]]) 5% 50% no-repeat;}
-#learnerbutton a {padding-left: 2.25em;background: url([[pix:t/go]]) 8% 50% no-repeat;}
-#monitorbutton a {padding-left: 2.25em;background: url([[pix:a/search]]) 5% 50% no-repeat;}
+#authorbutton a {text-decoration:none;padding-left: 2.25em;background: url([[pix:i/admin]]) 5% 50% no-repeat;}
+#learnerbutton a {text-decoration:none;padding-left: 2.25em;background: url([[pix:t/go]]) 8% 50% no-repeat;}
+#monitorbutton a {text-decoration:none;padding-left: 2.25em;background: url([[pix:a/search]]) 5% 50% no-repeat;}
+#previewbutton a {text-decoration:none;padding-left: 2.25em;background: url([[pix:a/search]]) 5% 50% no-repeat;}
/* Copyright (c) 2006 Yahoo! Inc. All rights reserved.
This file is from:
Index: moodle/mod/lamslesson/lang/en/lamslesson.php
===================================================================
RCS file: /usr/local/cvsroot/moodle/mod/lamslesson/lang/en/lamslesson.php,v
diff -u -r1.2 -r1.3
--- moodle/mod/lamslesson/lang/en/lamslesson.php 21 Jan 2011 13:25:46 -0000 1.2
+++ moodle/mod/lamslesson/lang/en/lamslesson.php 24 Jan 2011 02:37:39 -0000 1.3
@@ -77,7 +77,8 @@
$string['restcallfail'] = 'Call to LAMS failed: received no response or connection was refused. Please check that you have the correct LAMS server URL and that it is online.';
$string['sequencenotselected'] = 'You must select a sequence to proceed.';
-
+$string['previewthislesson'] = 'Preview this lesson';
+$string['disablepopupblocker'] = 'It seems that you have a pop-up blocker that is preventing the preview window to be displayed. Please disable the pop-up blocker to preview'
// view.php
$string['nolessons'] = 'There are no LAMS lessons yet in this instance.';