public function getLogic()
 {
     $ai = QTIAssessmentItem::fromQTIID($_REQUEST["qtiid"]);
     // download the content package
     header("Content-Type: application/zip");
     header("Content-Disposition: attachment; filename=\"{$ai->getTitleFS()}.zip\"");
     echo $ai->getContentPackage();
 }
 public function getLogic()
 {
     $ai = QTIAssessmentItem::fromQTIID($_REQUEST["qtiid"]);
     // download the QTI
     //header("Content-Type: application/qti+xml"); //proposed Mime type -- http://www.imsglobal.org/question/ims-qti-archives/2003-January/000502.html
     header("Content-Type: application/xml");
     header("Content-Disposition: attachment; filename=\"{$ai->getTitleFS()}.xml\"");
     echo $ai->getQTIIndentedString();
 }
 public function postLogic()
 {
     $ai = QTIAssessmentItem::fromQTIID($_REQUEST["qtiid"]);
     // clone the item
     $ai = clone $ai;
     // update the modified time and set new identifiers
     $ai->setQTIID(null);
     $ai->setMID();
     $ai->sessionStore();
     // take the user to the main menu with the cloned item highlighted
     redirect(SITEROOT_WEB . "#item_" . $ai->getQTIID());
 }
 public function beforeLogic()
 {
     $this->ai = QTIAssessmentItem::fromQTIID($_REQUEST["qtiid"]);
 }
 public function beforeLogic()
 {
     $this->ai = QTIAssessmentItem::fromQTIID($_REQUEST["qtiid"]);
     $this->aititle = $this->ai->data("title");
 }
<?php

/*
 * Question Bank
 */
/*------------------------------------------------------------------------------
(c) 2010 JISC-funded EASiHE project, University of Southampton
Licensed under the Creative Commons 'Attribution non-commercial share alike' 
licence -- see the LICENCE file for more details
------------------------------------------------------------------------------*/
requirelogin();
if (!isset($_REQUEST["qtiid"])) {
    redirect("eqiat/");
}
$ai = QTIAssessmentItem::fromQTIID($_REQUEST["qtiid"]);
if (!$ai) {
    badrequest("No QTI found in session data for specified QTI ID");
}
if (!$ai->getQTI() || count($ai->getErrors())) {
    badrequest("Specified QTI item is unfinished or has errors");
}
if (($exists = itemexists($ai->getQTIID())) && itemowner($ai->getQTIID()) != username()) {
    badrequest("The item you are trying to deposit was already uploaded by a different user. You should clone it so it gets a new identifier and then try again.");
}
deposititem($ai);
// remove from session memory to remove from Eqiat view
$ai->sessionRemove();
$title = "Item " . ($exists ? "updated" : "deposited");
include "htmlheader.php";
?>
<h2><?php 
 public function getLogic()
 {
     $ai = QTIAssessmentItem::fromQTIID($_REQUEST["qtiid"]);
     // upload the QTI to QTIEngine
     // Doing this manually rather than using curl because until PHP 5.2.7
     // (SVN r269951 to be specific) there is a bug
     // (http://bugs.php.net/bug.php?id=46696) which breaks the feature
     // needed to submit the uploaded file's mimetype. PHP 5.2.4 is still
     // common at the time of writing (it's in Ubuntu 8.04 LTS) so we can't
     // use curl here.
     // Could build the multipart/form-data ourselves but that still leaves
     // the issue that we don't want to follow the last redirect.
     // boundary -- see
     // http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html
     while (true) {
         $boundary = "----------------------------" . uniqid();
         if (strpos($ai->getQTIIndentedString(), $boundary) === false) {
             break;
         }
     }
     // request
     $request = "--{$boundary}\r\n";
     $request .= "Content-Disposition: form-data; name=\"uploadedContent\"; filename=\"{$ai->getTitleFS()}.xml\"\r\n";
     $request .= "Content-Type: application/xml\r\n";
     $request .= "\r\n";
     $request .= $ai->getQTIIndentedString();
     $request .= "\r\n--{$boundary}--\r\n\r\n";
     // headers
     $reqheader = array("Host" => QTIENGINE_HOST, "Accept" => "*/*", "Content-Length" => strlen($request), "Content-Type" => "multipart/form-data; boundary={$boundary}");
     $url = "/application/upload";
     $reqaction = "POST {$url} HTTP/1.1";
     // make requests until we're redirected to the preview page
     $error = null;
     while (true) {
         // open socket
         $sock = fsockopen(QTIENGINE_HOST, 80, $errno, $errstr, 30);
         if (!$sock) {
             servererror("Couldn't connect to QTIEngine (" . QTIENGINE_HOST . ")");
         }
         // send data
         $reqheaderstrings = array();
         foreach ($reqheader as $key => $value) {
             $reqheaderstrings[] = "{$key}: {$value}";
         }
         fputs($sock, $reqaction . "\r\n" . implode("\r\n", $reqheaderstrings) . "\r\n\r\n" . $request);
         fflush($sock);
         // receive headers
         $header = array();
         $httpcode = null;
         while (!feof($sock) && ($line = fgets($sock)) != "\r\n") {
             if (is_null($httpcode) && preg_match('%^HTTP/[^\\s]*\\s+\\d+%', $line)) {
                 $httpcode = preg_replace('%^HTTP/[^\\s]*\\s+(\\d+).*$%', '\\1', $line);
             } else {
                 $parts = explode(":", $line, 2);
                 $header[trim($parts[0])] = trim($parts[1]);
             }
         }
         // close the socket
         fclose($sock);
         // check HTTP response code is a redirection
         if ($httpcode != 301 && $httpcode != 302 || !array_key_exists("Location", $header)) {
             $error = "Didn't get a redirection to the QTIEngine preview page. Last page was {$url}";
             break;
         }
         // check its URL is valid
         $urlparts = parse_url($header["Location"]);
         if (!isset($urlparts)) {
             $error = "Hit a malformed Location header pointing to '" . $header["Location"] . "'";
             break;
         }
         // stop if we've got to the preview page
         if (preg_match('%^/item/play/0;%', $urlparts["path"])) {
             break;
         }
         // redirect
         $url = $urlparts["path"];
         $reqaction = "GET {$url} HTTP/1.1";
         // delete POST related headers
         if (isset($reqheader["Content-Length"])) {
             unset($reqheader["Content-Length"]);
             unset($reqheader["Content-Type"]);
         }
         // clear the request data
         $request = "";
         // loop...
     }
     if (!is_null($error)) {
         servererror($error);
     }
     redirect($header["Location"]);
 }
Beispiel #8
0
 */
/*------------------------------------------------------------------------------
(c) 2010 JISC-funded EASiHE project, University of Southampton
Licensed under the Creative Commons 'Attribution non-commercial share alike' 
licence -- see the LICENCE file for more details
------------------------------------------------------------------------------*/
if (!isset($_REQUEST["action"]) || empty($_REQUEST["action"])) {
    badrequest("no action specified");
}
$classname = ucfirst($_REQUEST["action"]) . "Action";
if (!@class_exists($classname) || !is_subclass_of($classname, "ItemAction")) {
    badrequest("Item action doesn't exist or not implemented");
}
$action = new $classname();
if (!isset($_REQUEST["qtiid"])) {
    badrequest("No QTI ID specified");
}
if (!QTIAssessmentItem::fromQTIID($_REQUEST["qtiid"])) {
    badrequest("No QTI found in session data for specified QTI ID");
}
if (!$action->available(QTIAssessmentItem::fromQTIID($_REQUEST["qtiid"]))) {
    badrequest(ucfirst($action->name()) . " action is not currently available for the specified QTI item");
}
$GLOBALS["title"] = $action->description();
$action->beforeLogic();
if (isset($_POST) && !empty($_POST)) {
    $action->postLogic();
} else {
    $action->getLogic();
}
$action->afterLogic();