Index: details.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/survey/details.php,v retrieving revision 1.23 diff -u -r1.23 details.php --- details.php 30 Aug 2006 08:43:19 -0000 1.23 +++ details.php 19 Oct 2006 00:02:58 -0000 @@ -1,83 +1,63 @@ wwwroot.'/course/mod.php')) { - - if (! $course = get_record("course", "id", $form->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", "", - "id\">$strsurveys". - " -> ".stripslashes_safe($form->name)." ($streditingasurvey)"); - - if (!$form->name or !$form->template) { - error(get_string("filloutallfields"), $_SERVER["HTTP_REFERER"]); +require_once("../../config.php"); +include_once $CFG->libdir.'/formslib.php'; +class survey_details_form extends moodleform { + + function definition() { + $mform =& $this->_form; + $fromlastform = $this->_customdata['fromlastform']; + $fromlastform = $this->_customdata['fromlastform']; + $mform->addElement('static','label',get_string('name','survey'),$fromlastform->name); + + if (!$fromlastform->intro) { + $tempo = get_field("survey", "intro", "id", $fromlastform->template); + $fromlastform->intro = get_string($tempo, "survey"); } - - print_simple_box_start('center'); - ?> -
- setDefault('intro',$fromlastform->intro); + //TODO fix helpbuttons + emoticonhelpbutton("form", "intro"); + $mform->addElement('textarea','intro',get_string("introtext", "survey").helpbutton("writing", get_string("helpwriting"), "moodle", true, true, '', true). helpbutton("text", get_string("helptext"), "moodle", true, true, '', true), 'wrap="virtual" rows="20" cols="50"'); + $fromlastform = stripslashes_safe($fromlastform); + $mform->addElement('hidden', 'name',$fromlastform->name); + $mform->addElement('hidden', 'template',$fromlastform->template); + $mform->addElement('hidden', 'course',$fromlastform->course); + $mform->addElement('hidden', 'coursemodule',$fromlastform->coursemodule); + $mform->addElement('hidden', 'section',$fromlastform->section); + $mform->addElement('hidden', 'module',$fromlastform->module); + $mform->addElement('hidden', 'modulename',$fromlastform->modulename); + $mform->addElement('hidden', 'instance',$fromlastform->instance); + $mform->addElement('hidden', 'mode',$fromlastform->mode); + $mform->addElement('hidden', 'visible',$fromlastform->visible); + $mform->addElement('hidden', 'groupmode',$fromlastform->groupmode); + $mform->addElement('submit', 'submit', get_string("savechanges")); + + } +} +if ($fromlastform = data_submitted($CFG->wwwroot.'/course/mod.php')) { + + if (! $course = get_record("course", "id", $fromlastform->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", "", + "id\">$strsurveys". + " -> ".stripslashes_safe($fromlastform->name)." ($streditingasurvey)"); + + if (!$fromlastform->name or !$fromlastform->template) { + error(get_string("filloutallfields"), $_SERVER["HTTP_REFERER"]); + } + $mform = new survey_details_form($CFG->wwwroot.'/course/mod.php',compact('fromlastform')); + $mform->display(); + print_footer($course); + +} else { + error("You can't use this page like that!"); +} ?>