print_error('cannotviewassignment', 'assignment');
}
if ($assignment->assignmenttype != 'babelium') {
    print_error('invalidtype', 'assignment');
}
$assignmentinstance = new assignment_babelium($cm->id, $assignment, $cm, $course);
if ($submission = $assignmentinstance->get_submission($user->id)) {
    $PAGE->set_pagelayout('popup');
    $PAGE->set_title(fullname($user, true) . ': ' . $assignment->name);
    echo $OUTPUT->header();
    echo $OUTPUT->box_start('generalbox boxaligcenter', 'dates');
    echo '<table>';
    if ($assignment->timedue) {
        echo '<tr><td class="c0">' . get_string('duedate', 'assignment') . ':</td>';
        echo '    <td class="c1">' . userdate($assignment->timedue) . '</td></tr>';
    }
    echo '<tr><td class="c0">' . get_string('lastedited') . ':</td>';
    echo '    <td class="c1">' . userdate($submission->timemodified);
    echo '</td></tr></table>';
    echo $OUTPUT->box_end();
    $html_content = '';
    $response_data = babelium_get_response_data($submission->data1);
    if ($response_data) {
        $html_content = babelium_html_output(0, $response_data['info'], $response_data['subtitles']);
    }
    echo $OUTPUT->box($html_content, 'generalbox boxaligncenter boxwidthwide');
    echo $OUTPUT->close_window_button();
    echo $OUTPUT->footer();
} else {
    print_string('emptysubmission', 'assignment');
}
 /**
  * Displays full info about the submission of the given user ID for the current assignment
  * @param int $userid
  * @param boolean $return
  * 	Defaults to false. If true the list is returned rather than printed
  */
 function print_user_files($userid = 0, $return = false)
 {
     global $CFG, $USER, $OUTPUT;
     if (!$userid) {
         if (!isloggedin()) {
             return '';
         }
         $userid = $USER->id;
     }
     $output = '';
     $submission = $this->get_submission($userid);
     if (!$submission) {
         return $output;
     }
     $link = new moodle_url("/mod/assignment/type/babelium/file.php?id={$this->cm->id}&userid={$submission->userid}");
     $action = new popup_action('click', $link, 'file' . $userid, array('height' => 500, 'width' => 680));
     $image_tag = '<img src="http://' . $CFG->filter_babelium_serverdomain . '/resources/images/thumbs/' . $submission->data2 . '/default.jpg" alt="submission" border="0" height="45" width="60"/>';
     $popup = $OUTPUT->action_link($link, $image_tag . get_string('popupinnewwindow', 'assignment'), $action, array('title' => get_string('submission', 'assignment')));
     $wordcount = '<p id="wordcount" style="vertical-align=middle;">' . $popup . '&nbsp;</p>';
     $html_content = '';
     $response_data = babelium_get_response_data($submission->data1);
     if ($response_data) {
         $html_content = babelium_html_output(0, $response_data['info'], $response_data['subtitles']);
     }
     $output = $wordcount . $html_content;
     $output = '<div class="files">' . $output . '</div>';
     if ($return) {
         return $output;
     }
     echo $output;
 }