Display a message when the quiz attemp finishes

Display a message when the quiz attemp finishes

by Angie Mariño -
Number of replies: 0

I am using the quiz_attempt_submitted event from the locallib.php file but I can not display any messages in moodle.

My code is this:


function quiz_attempt_submitted_handler($event) {

    global $DB;

    $course  = $DB->get_record('course', array('id' => $event->courseid));

    $attempt = $event->get_record_snapshot('quiz_attempts', $event->objectid);

    $quiz    = $event->get_record_snapshot('quiz', $attempt->quiz);

    $cm      = get_coursemodule_from_id('quiz', $event->get_context()->instanceid, $event->courseid);


    if (!($course && $quiz && $cm && $attempt)) {

        // Something has been deleted since the event was raised. Therefore, the

        // event is no longer relevant.

        return true;

    }

    return quiz_send_notification_messages($course, $quiz, $attempt, context_module::instance($cm->id), $cm, $t);

    echo "Hello world";

}

I hope you can help me, thanks!

Average of ratings: -