コード例 #1
0
$SESSION->instance = $instance;
$usergraph = get_config('questionnaire', 'usergraph');
if (!($questionnaire = $DB->get_record("questionnaire", array("id" => $instance)))) {
    print_error('incorrectquestionnaire', 'questionnaire');
}
if (!($course = $DB->get_record("course", array("id" => $questionnaire->course)))) {
    print_error('coursemisconf');
}
if (!($cm = get_coursemodule_from_instance("questionnaire", $questionnaire->id, $course->id))) {
    print_error('invalidcoursemodule');
}
require_course_login($course, true, $cm);
$questionnaire = new questionnaire(0, $questionnaire, $course, $cm);
// Add renderer and page objects to the questionnaire object for display use.
$questionnaire->add_renderer($PAGE->get_renderer('mod_questionnaire'));
$questionnaire->add_page(new \mod_questionnaire\output\reportpage());
// If you can't view the questionnaire, or can't view a specified response, error out.
$context = context_module::instance($cm->id);
if (!has_capability('mod/questionnaire:readallresponseanytime', $context) && !($questionnaire->capabilities->view && $questionnaire->can_view_response($rid))) {
    // Should never happen, unless called directly by a snoop...
    print_error('nopermissions', 'moodle', $CFG->wwwroot . '/mod/questionnaire/view.php?id=' . $cm->id);
}
$questionnaire->canviewallgroups = has_capability('moodle/site:accessallgroups', $context);
$sid = $questionnaire->survey->id;
$url = new moodle_url($CFG->wwwroot . '/mod/questionnaire/report.php');
if ($instance) {
    $url->param('instance', $instance);
}
$url->param('action', $action);
if ($type) {
    $url->param('type', $type);
コード例 #2
0
            $context = context_module::instance($questionnaire->cm->id);
            $questiontype = \mod_questionnaire\question\base::qtypename($qformdata->type_id);
            $params = array('context' => $context, 'courseid' => $questionnaire->course->id, 'other' => array('questiontype' => $questiontype));
            $event = \mod_questionnaire\event\question_created::create($params);
            $event->trigger();
        }
        $questionsform->set_data($question);
    }
}
// Reload the form data if called for...
if ($reload) {
    unset($questionsform);
    $questionnaire = new questionnaire($questionnaire->id, null, $course, $cm);
    // Add renderer and page objects to the questionnaire object for display use.
    $questionnaire->add_renderer($PAGE->get_renderer('mod_questionnaire'));
    $questionnaire->add_page(new \mod_questionnaire\output\questionspage());
    if ($action == 'main') {
        $questionsform = new mod_questionnaire_questions_form('questions.php', $moveq);
        $sdata = clone $questionnaire->survey;
        $sdata->sid = $questionnaire->survey->id;
        $sdata->id = $cm->id;
        if (!empty($questionnaire->questions)) {
            $pos = 1;
            foreach ($questionnaire->questions as $qidx => $question) {
                $sdata->{'pos_' . $qidx} = $pos;
                $pos++;
            }
        }
        $questionsform->set_data($sdata);
    } else {
        if ($action == 'question') {
コード例 #3
0
if (!($questionnaire = $DB->get_record("questionnaire", array("id" => $cm->instance)))) {
    print_error('invalidcoursemodule');
}
// 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);
// Add renderer and page objects to the questionnaire object for display use.
$questionnaire->add_renderer($PAGE->get_renderer('mod_questionnaire'));
$questionnaire->add_page(new \mod_questionnaire\output\qsettingspage());
$SESSION->questionnaire->current_tab = 'settings';
if (!$questionnaire->capabilities->manage) {
    print_error('nopermissions', 'error', 'mod:questionnaire:manage');
}
$settingsform = new mod_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');
コード例 #4
0
$referer = $CFG->wwwroot . '/mod/questionnaire/report.php';
if (!($questionnaire = $DB->get_record("questionnaire", array("id" => $qid)))) {
    print_error('invalidcoursemodule');
}
if (!($course = $DB->get_record("course", array("id" => $questionnaire->course)))) {
    print_error('coursemisconf');
}
if (!($cm = get_coursemodule_from_instance("questionnaire", $questionnaire->id, $course->id))) {
    print_error('invalidcoursemodule');
}
// Check login and get context.
require_login($courseid);
$questionnaire = new questionnaire(0, $questionnaire, $course, $cm);
// Add renderer and page objects to the questionnaire object for display use.
$questionnaire->add_renderer($PAGE->get_renderer('mod_questionnaire'));
$questionnaire->add_page(new \mod_questionnaire\output\previewpage());
// If you can't view the questionnaire, or can't view a specified response, error out.
if (!($questionnaire->capabilities->view && ($rid == 0 || $questionnaire->can_view_response($rid)))) {
    // Should never happen, unless called directly by a snoop...
    print_error('nopermissions', 'moodle', $CFG->wwwroot . '/mod/questionnaire/view.php?id=' . $cm->id);
}
$blankquestionnaire = true;
if ($rid != 0) {
    $blankquestionnaire = false;
}
$url = new moodle_url($CFG->wwwroot . '/mod/questionnaire/print.php');
$url->param('qid', $qid);
$url->param('rid', $rid);
$url->param('courseid', $courseid);
$url->param('sec', $sec);
$PAGE->set_url($url);
コード例 #5
0
    }
}
if (!($context = context_module::instance($cm->id))) {
    print_error('badcontext');
}
// We need the coursecontext to allow sending of mass mails.
if (!($coursecontext = context_course::instance($course->id))) {
    print_error('badcontext');
}
require_course_login($course, true, $cm);
$url = new moodle_url('/mod/questionnaire/show_nonrespondents.php', array('id' => $cm->id));
$PAGE->set_url($url);
$questionnaire = new questionnaire($sid, $questionnaire, $course, $cm);
// Add renderer and page objects to the questionnaire object for display use.
$questionnaire->add_renderer($PAGE->get_renderer('mod_questionnaire'));
$questionnaire->add_page(new \mod_questionnaire\output\nonrespondentspage());
$resume = $questionnaire->resume;
$fullname = $questionnaire->respondenttype == 'fullname';
$sid = $questionnaire->sid;
if (($formdata = data_submitted()) && !confirm_sesskey()) {
    print_error('invalidsesskey');
}
require_capability('mod/questionnaire:viewsingleresponse', $context);
// Anonymous questionnaire.
if (!$fullname) {
    $nonrespondents = questionnaire_get_incomplete_users($cm, $sid);
    $countnonrespondents = count($nonrespondents);
    if ($resume) {
        $countstarted = 0;
        $countnotstarted = 0;
        $params = array('survey_id' => $sid, 'complete' => 'n');
コード例 #6
0
$resume = optional_param('resume', null, PARAM_INT);
// Is this attempt a resume of a saved attempt?
list($cm, $course, $questionnaire) = questionnaire_get_standard_page_items($id, $a);
// Check login and get context.
require_course_login($course, true, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/questionnaire:view', $context);
$url = new moodle_url($CFG->wwwroot . '/mod/questionnaire/complete.php');
if (isset($id)) {
    $url->param('id', $id);
} else {
    $url->param('a', $a);
}
$PAGE->set_url($url);
$PAGE->set_context($context);
$questionnaire = new questionnaire(0, $questionnaire, $course, $cm);
// Add renderer and page objects to the questionnaire object for display use.
$questionnaire->add_renderer($PAGE->get_renderer('mod_questionnaire'));
$questionnaire->add_page(new \mod_questionnaire\output\completepage());
$questionnaire->strquestionnaires = get_string("modulenameplural", "questionnaire");
$questionnaire->strquestionnaire = get_string("modulename", "questionnaire");
// Mark as viewed.
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
if ($resume) {
    $context = context_module::instance($questionnaire->cm->id);
    $anonymous = $questionnaire->respondenttype == 'anonymous';
    $event = \mod_questionnaire\event\attempt_resumed::create(array('objectid' => $questionnaire->id, 'anonymous' => $anonymous, 'context' => $context));
    $event->trigger();
}
$questionnaire->view();