Ejemplo n.º 1
0
}
// Needed here for forced language courses.
require_course_login($course, true, $cm);
$context = context_module::instance($cm->id);
$url = new moodle_url($CFG->wwwroot . '/mod/questionnaire/qsettings.php', array('id' => $id));
$PAGE->set_url($url);
$PAGE->set_context($context);
if (!isset($SESSION->questionnaire)) {
    $SESSION->questionnaire = new stdClass();
}
$questionnaire = new questionnaire(0, $questionnaire, $course, $cm);
$SESSION->questionnaire->current_tab = 'settings';
if (!$questionnaire->capabilities->manage) {
    print_error('nopermissions', 'error', 'mod:questionnaire:manage');
}
$settingsform = new questionnaire_settings_form('qsettings.php');
$sdata = clone $questionnaire->survey;
$sdata->sid = $questionnaire->survey->id;
$sdata->id = $cm->id;
$draftideditor = file_get_submitted_draft_itemid('info');
$currentinfo = file_prepare_draft_area($draftideditor, $context->id, 'mod_questionnaire', 'info', $sdata->sid, array('subdirs' => true), $questionnaire->survey->info);
$sdata->info = array('text' => $currentinfo, 'format' => FORMAT_HTML, 'itemid' => $draftideditor);
$draftideditor = file_get_submitted_draft_itemid('thankbody');
$currentinfo = file_prepare_draft_area($draftideditor, $context->id, 'mod_questionnaire', 'thankbody', $sdata->sid, array('subdirs' => true), $questionnaire->survey->thank_body);
$sdata->thank_body = array('text' => $currentinfo, 'format' => FORMAT_HTML, 'itemid' => $draftideditor);
$draftideditor = file_get_submitted_draft_itemid('feedbacknotes');
$currentinfo = file_prepare_draft_area($draftideditor, $context->id, 'mod_questionnaire', 'feedbacknotes', $sdata->sid, array('subdirs' => true), $questionnaire->survey->feedbacknotes);
$sdata->feedbacknotes = array('text' => $currentinfo, 'format' => FORMAT_HTML, 'itemid' => $draftideditor);
$settingsform->set_data($sdata);
if ($settingsform->is_cancelled()) {
    redirect($CFG->wwwroot . '/mod/questionnaire/view.php?id=' . $questionnaire->cm->id, '');
}
if (!($course = get_record("course", "id", $cm->course))) {
    error("Course is misconfigured");
}
if (!($questionnaire = get_record("questionnaire", "id", $cm->instance))) {
    error("Course module is incorrect");
}
// needed here for forced language courses
require_course_login($course->id);
require_once $CFG->dirroot . '/mod/questionnaire/lib.php';
$questionnaire = new questionnaire(0, $questionnaire, $course, $cm);
$SESSION->questionnaire->current_tab = 'settings';
if (!$questionnaire->capabilities->manage) {
    error(get_string('nopermissions', 'error', 'mod:questionnaire:manage'));
}
$settings_form = new questionnaire_settings_form('qsettings.php');
$sdata = clone $questionnaire->survey;
$sdata->sid = $questionnaire->survey->id;
$sdata->id = $cm->id;
$settings_form->set_data($sdata);
if ($settings = $settings_form->get_data()) {
    $sdata = new Object();
    $sdata->id = $settings->sid;
    $sdata->name = $settings->name;
    $sdata->realm = $settings->realm;
    $sdata->title = $settings->title;
    $sdata->subtitle = $settings->subtitle;
    $sdata->info = $settings->info;
    $sdata->theme = $settings->theme;
    $sdata->thanks_page = $settings->thanks_page;
    $sdata->thank_head = $settings->thank_head;