/**
  * Search a list of modules.
  *
  * @param $modulecode
  * @return array [string]
  * @throws \invalid_parameter_exception
  */
 public static function get_submission_status($submissionid)
 {
     global $DB, $USER;
     $params = self::validate_parameters(self::get_submission_status_parameters(), array('submissionid' => $submissionid));
     $submissionid = $params['submissionid'];
     $submission = $DB->get_record('turnitintooltwo_submissions', array('id' => $submissionid));
     if (!$submission) {
         return array('status' => 'error');
     }
     // Grab more data.
     $turnitintooltwo = $DB->get_record('turnitintooltwo', array('id' => $submission->turnitintooltwoid));
     list($course, $cm) = get_course_and_cm_from_instance($turnitintooltwo, 'turnitintooltwo');
     // Check this is our submission.
     if ($USER->id !== $submission->userid && !has_capability('mod/turnitintooltwo:grade', \context_module::instance($cm->id))) {
         return array('status' => 'nopermission');
     }
     // What is the status?
     $status = $DB->get_record('turnitintooltwo_sub_status', array('submissionid' => $submissionid));
     if (!$status) {
         return array('status' => 'queued');
     }
     // Decode the receipt.
     $digitalreceipt = (array) json_decode($status->receipt);
     // Woo!
     if ($status->status == \mod_turnitintooltwo\task\submit_assignment::STATUS_SUCCESS) {
         $turnitintooltwoview = new \turnitintooltwo_view();
         $digitalreceipt = $turnitintooltwoview->show_digital_receipt($digitalreceipt);
         $digitalreceipt = \html_writer::tag("div", $digitalreceipt, array("id" => "box_receipt"));
         return array('status' => 'success', 'message' => $digitalreceipt);
     }
     return array('status' => 'failed', 'message' => \html_writer::tag("div", $digitalreceipt["message"], array("class" => "alert alert-danger")));
 }
    echo html_writer::tag('noscript', $noscriptcss);
}
if (!is_null($notice)) {
    echo $turnitintooltwoview->show_notice($notice);
}
// Show a warning (and hide the rest of the output) if javascript is not enabled while a tutor is logged in.
if ($istutor) {
    echo html_writer::tag('noscript', get_string('noscript', 'turnitintooltwo'), array("class" => "warning"));
}
// Determine if javascript is required and apply class which will hide/show appropriate content.
$class = $istutor ? "js_required" : "";
echo html_writer::start_tag("div", array("class" => $class));
echo html_writer::tag("div", $viewcontext, array("id" => "view_context"));
switch ($do) {
    case "submission_success":
        $digitalreceipt = $turnitintooltwoview->show_digital_receipt($_SESSION["digital_receipt"]);
        if ($viewcontext == "box_solid") {
            $digitalreceipt = html_writer::tag("div", $digitalreceipt, array("id" => "box_receipt"));
        }
        echo $digitalreceipt;
        unset($_SESSION["digital_receipt"]);
        break;
    case "submission_failure":
        $output = $OUTPUT->box($OUTPUT->pix_icon('icon', get_string('turnitin', 'turnitintooltwo'), 'mod_turnitintooltwo'), 'centered_div');
        $output .= html_writer::tag("div", $_SESSION["digital_receipt"]["message"], array("class" => "general_warning"));
        if ($viewcontext == "box_solid") {
            $output = html_writer::tag("div", $output, array("class" => "submission_failure_msg"));
        }
        echo $output;
        unset($_SESSION["digital_receipt"]);
        break;