예제 #1
0
/**
 * Mark the activity completed (if required) and trigger the course_module_viewed event.
 *
 * @param  stdClass $survey     survey object
 * @param  stdClass $course     course object
 * @param  stdClass $cm         course module object
 * @param  stdClass $context    context object
 * @param  string $viewed       which page viewed
 * @since Moodle 3.0
 */
function survey_view($survey, $course, $cm, $context, $viewed) {

    // Trigger course_module_viewed event.
    $params = array(
        'context' => $context,
        'objectid' => $survey->id,
        'courseid' => $course->id,
        'other' => array('viewed' => $viewed)
    );

    $event = \mod_survey\event\course_module_viewed::create($params);
    $event->add_record_snapshot('course_modules', $cm);
    $event->add_record_snapshot('course', $course);
    $event->add_record_snapshot('survey', $survey);
    $event->trigger();

    // Completion.
    $completion = new completion_info($course);
    $completion->set_module_viewed($cm);
}
예제 #2
0
                    $table->head = array(get_string($question->text, "survey"));
                    $table->align = array("left");
                    $table->data[] = array(s($answer->answer1));
                    //no html here, just plain text
                    echo html_writer::table($table);
                    echo $OUTPUT->spacer(array('height' => 30, 'width' => 1), true);
                }
            }
        }
    }
    echo $OUTPUT->footer();
    exit;
}
//  Start the survey form
$params = array('objectid' => $survey->id, 'context' => $context, 'courseid' => $course->id, 'other' => array('viewed' => 'form'));
$event = \mod_survey\event\course_module_viewed::create($params);
$event->trigger();
echo "<form method=\"post\" action=\"save.php\" id=\"surveyform\">";
echo '<div>';
echo "<input type=\"hidden\" name=\"id\" value=\"{$id}\" />";
echo "<input type=\"hidden\" name=\"sesskey\" value=\"" . sesskey() . "\" />";
echo $OUTPUT->box(format_module_intro('survey', $survey, $cm->id), 'generalbox boxaligncenter bowidthnormal', 'intro');
echo '<div>' . get_string('allquestionrequireanswer', 'survey') . '</div>';
// Get all the major questions and their proper order
if (!($questions = $DB->get_records_list("survey_questions", "id", explode(',', $survey->questions)))) {
    print_error('cannotfindquestion', 'survey');
}
$questionorder = explode(",", $survey->questions);
// Cycle through all the questions in order and print them
global $qnum;
//TODO: ugly globals hack for survey_print_*()