Merge branch 'MDL-30290' of git://github.com/scriby/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Fri, 18 Nov 2011 12:40:16 +0000 (13:40 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Fri, 18 Nov 2011 12:40:16 +0000 (13:40 +0100)
mod/lti/backup/moodle2/backup_lti_stepslib.php
mod/lti/db/install.xml
mod/lti/db/upgrade.php
mod/lti/lib.php
mod/lti/mod_form.php
mod/lti/version.php
mod/lti/view.php

index 3be2514..c9c2a24 100644 (file)
@@ -77,8 +77,8 @@ class backup_lti_activity_structure_step extends backup_activity_structure_step
             'instructorchoiceallowsetting',
             'grade',
             'instructorcustomparameters',
-            'showtitle',
-            'showdescription'
+            'showtitlelaunch',
+            'showdescriptionlaunch'
             )
         );
 
index 4d62cb0..2df3df5 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/lti/db" VERSION="20111018" COMMENT="XMLDB file for Moodle mod/lti"
+<XMLDB PATH="mod/lti/db" VERSION="20111116" COMMENT="XMLDB file for Moodle mod/lti"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
 >
         <FIELD NAME="launchcontainer" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" COMMENT="Launch external tool in a pop-up" PREVIOUS="grade" NEXT="resourcekey"/>
         <FIELD NAME="resourcekey" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="launchcontainer" NEXT="password"/>
         <FIELD NAME="password" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="resourcekey" NEXT="debuglaunch"/>
-        <FIELD NAME="debuglaunch" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Enable the debug-style launch which pauses before auto-submit" PREVIOUS="password" NEXT="showtitle"/>
-        <FIELD NAME="showtitle" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="debuglaunch" NEXT="showdescription"/>
-        <FIELD NAME="showdescription" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="showtitle" NEXT="servicesalt"/>
-        <FIELD NAME="servicesalt" TYPE="char" LENGTH="40" NOTNULL="false" SEQUENCE="false" PREVIOUS="showdescription" NEXT="icon"/>
+        <FIELD NAME="debuglaunch" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Enable the debug-style launch which pauses before auto-submit" PREVIOUS="password" NEXT="showtitlelaunch"/>
+        <FIELD NAME="showtitlelaunch" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="debuglaunch" NEXT="showdescriptionlaunch"/>
+        <FIELD NAME="showdescriptionlaunch" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="showtitlelaunch" NEXT="servicesalt"/>
+        <FIELD NAME="servicesalt" TYPE="char" LENGTH="40" NOTNULL="false" SEQUENCE="false" PREVIOUS="showdescriptionlaunch" NEXT="icon"/>
         <FIELD NAME="icon" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="servicesalt" NEXT="secureicon"/>
         <FIELD NAME="secureicon" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="icon"/>
       </FIELDS>
@@ -95,4 +95,4 @@
       </INDEXES>
     </TABLE>
   </TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
index 99f9deb..c00f872 100644 (file)
@@ -64,6 +64,20 @@ function xmldb_lti_upgrade($oldversion) {
 
     $dbman = $DB->get_manager();
 
+    if($oldversion < 2011111600){
+        //Rename showdescription to showdescriptionlaunch to not conflict with setting from core Moodle
+        //Rename showtitle as well to be consistent
+        $table = new xmldb_table('lti');
+        $field = new xmldb_field('showtitle', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'debuglaunch');
+        
+        $dbman->rename_field($table, $field, 'showtitlelaunch');
+        
+        $field = new xmldb_field('showdescription', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'showtitlelaunch');
+        $dbman->rename_field($table, $field, 'showdescriptionlaunch');
+        
+        upgrade_mod_savepoint(true, 2011111600, 'lti');
+    }
+    
     return true;
 }
 
index 5853162..5ddda0c 100644 (file)
@@ -63,6 +63,7 @@ function lti_supports($feature) {
         case FEATURE_GRADE_HAS_GRADE:         return true;
         case FEATURE_GRADE_OUTCOMES:          return true;
         case FEATURE_BACKUP_MOODLE2:          return true;
+        case FEATURE_SHOW_DESCRIPTION:        return true;
 
         default: return null;
     }
@@ -117,12 +118,12 @@ function lti_update_instance($lti, $mform) {
     $lti->timemodified = time();
     $lti->id = $lti->instance;
 
-    if (!isset($lti->showtitle)) {
-        $lti->showtitle = 0;
+    if (!isset($lti->showtitlelaunch)) {
+        $lti->showtitlelaunch = 0;
     }
 
-    if (!isset($lti->showdescription)) {
-        $lti->showdescription = 0;
+    if (!isset($lti->showdescriptionlaunch)) {
+        $lti->showdescriptionlaunch = 0;
     }
 
     if (!isset($lti->grade)) {
@@ -175,7 +176,7 @@ function lti_get_coursemodule_info($coursemodule) {
     require_once($CFG->dirroot.'/mod/lti/locallib.php');
 
     if (!$lti = $DB->get_record('lti', array('id' => $coursemodule->instance),
-            'icon, secureicon')) {
+            'icon, secureicon, intro, introformat, name')) {
         return null;
     }
 
@@ -188,7 +189,14 @@ function lti_get_coursemodule_info($coursemodule) {
     } else if (!empty($lti->icon)) {
         $info->iconurl = new moodle_url($lti->icon);
     }
+    
+    if ($coursemodule->showdescription) {
+        // Convert intro to html. Do not filter cached version, filters run at display time.
+        $info->content = format_module_intro('lti', $lti, $coursemodule->id, false);
+    }
 
+    $info->name = $lti->name;
+    
     return $info;
 }
 
index c588e39..fb1b9af 100644 (file)
@@ -69,14 +69,23 @@ class mod_lti_mod_form extends moodleform_mod {
         // Adding the optional "intro" and "introformat" pair of fields
         $this->add_intro_editor(false, get_string('basicltiintro', 'lti'));
         $mform->setAdvanced('introeditor');
+        
+        //Display the label to the right of the checkbox so it looks better & matches rest of the form
+        $coursedesc = $mform->getElement('showdescription');
+        if(!empty($coursedesc)){
+            $coursedesc->setText(' ' . $coursedesc->getLabel());
+            $coursedesc->setLabel('&nbsp');
+        }
+        
+        $mform->setAdvanced('showdescription');
 
-        $mform->addElement('checkbox', 'showtitle', '&nbsp;', ' ' . get_string('display_name', 'lti'));
-        $mform->setAdvanced('showtitle');
-        $mform->addHelpButton('showtitle', 'display_name', 'lti');
+        $mform->addElement('checkbox', 'showtitlelaunch', '&nbsp;', ' ' . get_string('display_name', 'lti'));
+        $mform->setAdvanced('showtitlelaunch');
+        $mform->addHelpButton('showtitlelaunch', 'display_name', 'lti');
 
-        $mform->addElement('checkbox', 'showdescription', '&nbsp;', ' ' . get_string('display_description', 'lti'));
-        $mform->setAdvanced('showdescription');
-        $mform->addHelpButton('showdescription', 'display_description', 'lti');
+        $mform->addElement('checkbox', 'showdescriptionlaunch', '&nbsp;', ' ' . get_string('display_description', 'lti'));
+        $mform->setAdvanced('showdescriptionlaunch');
+        $mform->addHelpButton('showdescriptionlaunch', 'display_description', 'lti');
 
         // Tool settings
         $tooltypes = $mform->addElement('select', 'typeid', get_string('external_tool_type', 'lti'), array());
index 9eb1e6d..499854d 100644 (file)
@@ -48,7 +48,7 @@
 
 defined('MOODLE_INTERNAL') || die;
 
-$module->version   = 2011111400;;
+$module->version   = 2011111600;;
 $module->requires  = 2011110200;  // Requires this Moodle version
 $module->cron      = 0;
 $module->component = 'mod_lti';
index 0697df6..350c68e 100644 (file)
@@ -100,12 +100,12 @@ $PAGE->set_heading($course->fullname);
 // Print the page header
 echo $OUTPUT->header();
 
-if ($lti->showtitle) {
+if ($lti->showtitlelaunch) {
     // Print the main part of the page
     echo $OUTPUT->heading(format_string($lti->name));
 }
 
-if ($lti->showdescription && $lti->intro) {
+if ($lti->showdescriptionlaunch && $lti->intro) {
     echo $OUTPUT->box($lti->intro, 'generalbox description', 'intro');
 }