Thanks very much.';
$string['collespname'] = 'COLLES (Preferred)';
+$string['customintro'] = 'Custom intro';
$string['done'] = 'Done';
$string['download'] = 'Download';
$string['downloadexcel'] = 'Download data as Excel spreadsheet';
+++ /dev/null
-<?php // $Id$
-
- require_once("../../config.php");
- include_once $CFG->libdir.'/formslib.php';
- class mod_survey_details_form extends moodleform {
-
- function definition() {
- $mform =& $this->_form;
- $lastform = $this->_customdata['lastform'];
- $mform->addElement('static','namestatic',get_string('name','survey'),$lastform->name);
-
- if (!$lastform->intro) {
- $tempo = get_field("survey", "intro", "id", $lastform->template);
- $lastform->intro = get_string($tempo, "survey");
- }
- //TODO fix helpbuttons
- //emoticonhelpbutton("form", "intro");
- //helpbutton("writing", get_string("helpwriting"), "moodle", true, true, '', true)
- // helpbutton("text", get_string("helptext"), "moodle", true, true, '', true)
-
- $mform->setDefault('intro',$lastform->intro);
- $mform->addElement('textarea','intro',get_string("introtext", "survey"), 'wrap="virtual" rows="20" cols="50"');
- $mform->addElement('hidden', 'name', $lastform->name);
- $mform->addElement('hidden', 'template', $lastform->template);
- $mform->addElement('hidden', 'course', $lastform->course);
- $mform->addElement('hidden', 'coursemodule', $lastform->coursemodule);
- $mform->addElement('hidden', 'section', $lastform->section);
- $mform->addElement('hidden', 'module', $lastform->module);
- $mform->addElement('hidden', 'modulename', $lastform->modulename);
- $mform->addElement('hidden', 'instance', $lastform->instance);
- $mform->addElement('hidden', 'mode', $lastform->mode);
- $mform->addElement('hidden', 'visible', $lastform->visible);
- $mform->addElement('hidden', 'groupmode', $lastform->groupmode);
-//-------------------------------------------------------------------------------
- // buttons
- $this->add_action_buttons(false);
-
- }
- }
- if ($lastform = data_submitted($CFG->wwwroot.'/course/mod.php')) {
-
- if (! $course = get_record("course", "id", $lastform->course)) {
- error("This course doesn't exist");
- }
-
- require_login($course->id, false);
- require_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id));
-
- $streditingasurvey = get_string("editingasurvey", "survey");
- $strsurveys = get_string("modulenameplural", "survey");
-
- print_header_simple("$streditingasurvey", "",
- "<a href=\"index.php?id=$course->id\">$strsurveys</a>".
- " -> ".stripslashes_safe($lastform->name)." ($streditingasurvey)");
-
- if (!$lastform->name or !$lastform->template) {
- // $_SERVER["HTTP_REFERER"] breaks xhtml, urlencode breaks continue button,
- // removing $_SERVER["HTTP_REFERER"]
- error(get_string("filloutallfields"));
- }
- $mform = new mod_survey_details_form($CFG->wwwroot.'/course/mod.php', array('lastform'=>stripslashes_safe($lastform)));
- $mform->display();
- print_footer($course);
-
- } else {
- error("You can't use this page like that!");
- }
-?>
+++ /dev/null
-<?php
- if (!isset($form->name)) {
- $form->name = "";
- }
- if (!isset($form->template)) {
- $form->template = "";
- }
- if (!isset($form->intro)) {
- $form->intro = "";
- }
- $nohtmleditorneeded = true;
-?>
-
-<form id="form" method="post" action="../mod/survey/details.php">
-<fieldset class="invisiblefieldset">
-<table cellpadding="5">
-<tr valign="top">
- <td align="right"><b><?php print_string("surveyname", "survey") ?>:</b></td>
- <td>
- <input type="text" name="name" size="30" value="<?php p($form->name) ?>" alt="<?php print_string("surveyname", "survey") ?>" />
- </td>
-</tr>
-<tr>
- <td align="right"><b><?php print_string("surveytype", "survey") ?>:</b></td>
- <td>
- <?php
- if ($options = get_records_menu("survey", "template", 0, "name", "id, name")) {
- foreach ($options as $id => $name) {
- $options[$id] = get_string($name, "survey");
- }
- choose_from_menu($options, "template", $form->template);
- helpbutton("surveys", get_string("helpsurveys", "survey"));
- } else {
- echo "No surveys to choose from!";
- }
- ?>
- </td>
-</tr>
-<?php print_standard_coursemodule_settings($form); ?>
-</table>
-<div class="centerpara">
-<input type="hidden" name="intro" value="<?php p($form->intro) ?>" />
-<input type="hidden" name="course" value="<?php p($form->course) ?>" />
-<input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" />
-<input type="hidden" name="coursemodule" value="<?php p($form->coursemodule) ?>" />
-<input type="hidden" name="section" value="<?php p($form->section) ?>" />
-<input type="hidden" name="module" value="<?php p($form->module) ?>" />
-<input type="hidden" name="modulename" value="<?php p($form->modulename) ?>" />
-<input type="hidden" name="instance" value="<?php p($form->instance) ?>" />
-<input type="hidden" name="mode" value="<?php p($form->mode) ?>" />
-<input type="submit" value="<?php print_string("savechanges") ?>" />
-<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
-</div>
-</fieldset>
-</form>
--- /dev/null
+<?php
+require_once ('moodleform_mod.php');
+
+class mod_survey_mod_form extends moodleform_mod {
+
+ function definition() {
+
+ global $CFG;
+ $mform =& $this->_form;
+
+ $strrequired = get_string('required');
+
+//-------------------------------------------------------------------------------
+ $mform->addElement('header', 'general', get_string('general', 'form'));
+
+ $mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
+ $mform->setType('name', PARAM_TEXT);
+ $mform->addRule('name', null, 'required', null, 'client');
+
+ if (!$options = get_records_menu("survey", "template", 0, "name", "id, name")) {
+ error('No survey templates found!');
+ }
+
+ foreach ($options as $id => $name) {
+ $options[$id] = get_string($name, "survey");
+ }
+ $options = array(''=>get_string('choose').'...') + $options;
+ $mform->addElement('select', 'template', get_string("surveytype", "survey"), $options);
+ $mform->addRule('template', $strrequired, 'required', null, 'client');
+ $mform->setHelpButton('template', array('surveys', get_string('helpsurveys', 'survey')));
+
+
+ $mform->addElement('textarea', 'intro', get_string('customintro', 'survey'), 'wrap="virtual" rows="20" cols="75"');
+ $mform->setType('intro', PARAM_RAW);
+
+ $this->standard_coursemodule_elements();
+
+//-------------------------------------------------------------------------------
+ // buttons
+ $this->add_action_buttons();
+ }
+
+
+}
+?>
\ No newline at end of file
if (! $survey = get_record("survey", "id", $cm->instance)) {
error("Survey ID was incorrect");
}
+ $rimmedintro = trim($survey->intro);
+ if (empty($rimmedintro)) {
+ $tempo = get_field("survey", "intro", "id", $survey->template);
+ $survey->intro = get_string($tempo, "survey");
+ }
if (! $template = get_record("survey", "id", $survey->template)) {
error("Template ID was incorrect");