<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/lesson/db" VERSION="20091208" COMMENT="XMLDB file for Moodle mod/lesson"
+<XMLDB PATH="mod/lesson/db" VERSION="20100629" COMMENT="XMLDB file for Moodle mod/lesson"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="display" NEXT="timemodified"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated" NEXT="title"/>
<FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="timemodified" NEXT="contents"/>
- <FIELD NAME="contents" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" PREVIOUS="title"/>
+ <FIELD NAME="contents" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" PREVIOUS="title" NEXT="contentsformat"/>
+ <FIELD NAME="contentsformat" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="contents"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="lessonid"/>
$dbman->drop_table($table);
upgrade_mod_savepoint($result, 2009120800, 'lesson');
}
+ if ($result && $oldversion < 2009120801) {
+
+ /// Define field contentsformat to be added to lesson_pages
+ $table = new xmldb_table('lesson_pages');
+ $field = new xmldb_field('contentsformat', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'contents');
+
+ /// Conditionally launch add field contentsformat
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ /// lesson savepoint reached
+ upgrade_mod_savepoint($result, 2009120801, 'lesson');
+ }
+
return $result;
}
}
}
-echo $lessonoutput->footer();
\ No newline at end of file
+echo $lessonoutput->footer();
$lessonoutput = $PAGE->get_renderer('mod_lesson');
echo $lessonoutput->header($lesson, $cm);
$mform->display();
-echo $lessonoutput->footer();
\ No newline at end of file
+echo $lessonoutput->footer();
$this->answers = array();
$answers = $DB->get_records('lesson_answers', array('pageid'=>$this->properties->id, 'lessonid'=>$this->lesson->id), 'id');
if (!$answers) {
- print_error('cannotfindanswer', 'lesson');
+ debugging(get_string('cannotfindanswer', 'lesson'));
+ return array();
}
foreach ($answers as $answer) {
$this->answers[count($this->answers)] = new lesson_page_answer($answer);
* @param object $properties
* @return bool
*/
- public function update($properties,$context, $maxbytes) {
- global $DB;
+ public function update($properties, $context = null, $maxbytes = null) {
+ global $DB, $PAGE;
$answers = $this->get_answers();
$properties->id = $this->properties->id;
$properties->lessonid = $this->lesson->id;
if (empty($properties->qoption)) {
$properties->qoption = '0';
}
+ if (empty($context)) {
+ $context = $PAGE->context;
+ }
+ if ($maxbytes === null) {
+ $maxbytes =get_max_upload_file_size();
+ }
$properties = file_postupdate_standard_editor($properties, 'contents', array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$maxbytes), $context, 'lesson_page_contents', $properties->id);
$DB->update_record("lesson_pages", $properties);
$mform->addElement('text', 'title', get_string("pagetitle", "lesson"), array('size'=>70));
$mform->setType('title', PARAM_TEXT);
+ $mform->addRule('title', null, 'required', null, 'server');
$this->editoroptions = array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$PAGE->course->maxbytes);
$mform->addElement('editor', 'contents_editor', get_string("pagecontents", "lesson"), null, $this->editoroptions);
$mform->addElement('header', 'headeranswer'.$i, get_string('branch', 'lesson').' '.($i+1));
$mform->addElement('textarea', 'answer['.$i.']', get_string("description", "lesson"), array('rows'=>10, 'cols'=>70, 'width'=>630, 'height'=>300));
$mform->setType('answer['.$i.']', PARAM_CLEANHTML);
+ if ($i == 0) {
+ // we should have one required branch
+ $mform->addRule('answer['.$i.']', null, 'required', null, 'server');
+ }
$mform->addElement('select', 'jumpto['.$i.']', get_string("jump", "lesson"), $jumptooptions);
if ($i === 0) {
}
}
}
-}
\ No newline at end of file
+}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or late
**/
-$module->version = 2009120800; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2009120801; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2008072401; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)
}
$lessoncontent = $lessonoutput->display_page($lesson, $page, $attempt);
} else {
-
- $nextpage = $lesson->get_next_page($page->nextpageid);
-
$data = new stdClass;
$data->id = $PAGE->cm->id;
- $data->newpageid = $nextpage->id;
+ if ($nextpage = $lesson->get_next_page($page->nextpageid)) {
+ $data->newpageid = $nextpage->id;
+ }
- $mform = lesson_page_without_answers();
+ $mform = new lesson_page_without_answers();
$mform->set_data($data);
ob_start();
$mform->display();