/** * Return the output for a form to launch the relevant LTi function * It is then submitted on load via Javascript * * @param string $userrole either Instructor or Learner * @param int $userid * @return output form */ public static function output_lti_form_launch($type, $userrole, $partid = 0, $classid = 0) { global $USER, $CFG; // Initialise Comms Object. $turnitincomms = new turnitintooltwo_comms(); $turnitincall = $turnitincomms->initialise_api(); $user = new turnitintooltwo_user($USER->id, $userrole); $lti = new TiiLTI(); $lti->setUserId($user->tii_user_id); $lti->setRole($userrole); $lti->setFormTarget(''); switch ($type) { case "messages_inbox": $ltifunction = "outputMessagesForm"; break; case "rubric_manager": if ($classid != 0) { $lti->setClassId($classid); } $ltifunction = "outputRubricManagerForm"; break; case "rubric_view": $lti->setAssignmentId($partid); $ltifunction = "outputRubricViewForm"; break; case "quickmark_manager": $ltifunction = "outputQuickmarkManagerForm"; break; case "peermark_manager": $lti->setAssignmentId($partid); $ltifunction = "outputPeerMarkSetupForm"; break; case "peermark_reviews": $lti->setAssignmentId($partid); $ltifunction = "outputPeerMarkReviewForm"; break; } ob_start(); $turnitincall->{$ltifunction}($lti); $rubricform = ob_get_contents(); ob_end_clean(); return $rubricform; }
/** * @param TiiLTI $object * @param array $params * @param string $endpoint * @param string $target * @param string $buttonimg * @param string $buttontext * @param boolean $uploadfile * @param boolean $uploadtext * @return string */ public function getFormHtml($object, $params, $uploadfile, $uploadtext) { if ($uploadfile or $uploadtext) { $enctype = 'multipart/form-data'; } else { $enctype = 'application/x-www-form-urlencoded'; } $output = '<form action="' . $this->getEndPoint() . '" method="POST" target="' . $object->getFormTarget() . '" enctype="' . $enctype . '">' . PHP_EOL; foreach ($params as $name => $value) { $output .= '<input name="' . htmlentities($name, ENT_QUOTES) . '" value="' . htmlentities($value, ENT_QUOTES) . '" type="hidden" />' . PHP_EOL; } if ($uploadtext) { $output .= '<textarea name="custom_submission_data"></textarea>' . PHP_EOL; } else { if ($uploadfile) { $output .= '<input name="custom_submission_data" type="file" />' . PHP_EOL; } } if (!is_null($object->getHasButton())) { $output .= '<input type="submit" value="' . $object->getButtonText() . '" style="' . $object->getButtonStyle() . '" />' . PHP_EOL; } $output .= '</form>' . PHP_EOL; return $output; }