コード例 #1
0
ファイル: uploadItem.php プロジェクト: rprince/questionbank
if (isset($_POST["uploaditem"])) {
    $output = handleupload($errors, $warnings, $messages);
    if ($output !== false) {
        list($xml, $metadata) = $output;
        if (validateQTI($xml, $errors, $warnings, $messages)) {
            $xml = simplexml_load_string($xml);
            // get data from QTI
            $identifier = (string) $xml["identifier"];
            $title = (string) $xml["title"];
            // see if an item with this identifier already exists in the
            // database
            $exists = itemexists($identifier);
            if ($exists && itemowner($identifier) != username()) {
                $errors[] = "The item you are trying to upload was already uploaded by a different user. You should clone it so it gets a new identifier and then try again.";
            } else {
                deposititem($xml, $metadata);
                if (!authoredineqiat($xml)) {
                    $warnings[] = "This item was not authored in Eqiat. The item will still be playable but Eqiat may not be able to import it for editing.";
                }
                // collect any warnings and messages
                $thingstosay = array();
                if (!empty($warnings)) {
                    $thingstosay[] = "warnings";
                }
                if (!empty($messages)) {
                    $thingstosay[] = "messages";
                }
                $title = "Item " . ($exists ? "updated" : "deposited");
                include "htmlheader.php";
                ?>
				<h2><?php 
コード例 #2
0
------------------------------------------------------------------------------*/
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 
echo htmlspecialchars($title);
?>
</h2>
<p>The item "<?php 
echo htmlspecialchars($ai->data("title"));
?>
" has been <?php 
echo $exists ? "updated" : "deposited";
?>