Exemple #1
0
/*
 * 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
------------------------------------------------------------------------------*/
$errors = array();
$warnings = array();
$messages = array();
if (!isset($_REQUEST["qtiid"])) {
    badrequest("no QTI ID was specified");
}
$item = getitem($_REQUEST["qtiid"]);
if (!$item) {
    badrequest("no item with the given QTI ID exists in the database");
}
// if not cloning...
if (!isset($_REQUEST["clone"])) {
    // only the owner can edit it
    if (!loggedin()) {
        badrequest("you're not logged in so can't edit this item");
    }
    if ($item["user"] != username()) {
        badrequest("you're not the owner of this item and so can't edit it");
    }
    // if the item's already in session memory redirect straight to Eqiat
    if (isset($_SESSION["items"]) && array_key_exists($_REQUEST["qtiid"], $_SESSION["items"])) {
        redirect(SITEROOT_WEB . "eqiat/#item_" . $_REQUEST["qtiid"]);
Exemple #2
0
function itemrating($qtiid)
{
    if (!loggedin() || !itemexists($qtiid)) {
        return false;
    }
    $item = getitem($qtiid);
    $result = db()->query("\n\t\tSELECT rating\n\t\tFROM ratings\n\t\tWHERE item='" . db()->escapeString($qtiid) . "'\n\t\tAND posted > " . max($item["uploaded"], is_null($item["modified"]) ? 0 : $item["modified"]) . "\n\t\tAND user='******'\n\t;");
    if ($row = $result->fetchArray(SQLITE3_NUM)) {
        return $row[0];
    }
    return null;
}
Exemple #3
0
            redirect(SITEROOT_WEB . "?page=playItem");
        case "startover":
            // reset the item pointer
            $_SESSION["itemqueuepos"] = 0;
            redirect(SITEROOT_WEB . "?page=playItem");
        default:
            badrequest("unrecognized action");
    }
}
if (!isset($_SESSION["itemqueue"]) || empty($_SESSION["itemqueue"])) {
    badrequest("item queue is empty");
}
// URL to embed in QTIEngine XML
$actionurl = SITEROOT_WEB . "?page=playItem";
// get the current item
$item = getitem($_SESSION["itemqueue"][$_SESSION["itemqueuepos"]]);
// set response to false (to give a message later) if the item doesn't exist
// (it's been deleted)
if (!$item) {
    $response = false;
} else {
    // if QTIEngine form submitted post onwards to QTIEngine and display its output
    if (isset($_POST["submit"])) {
        // build request string
        $multipart = new HttpRequestBodyMultipart();
        $multipart->addpart("actionUrl", $actionurl);
        $multipart->addfromarray($_POST);
        $request = $multipart->requeststring();
        $curl = curl_init();
        curl_setopt_array($curl, array(CURLOPT_URL => "http://" . QTIENGINE_HOST . ":" . QTIENGINE_PORT . QTIENGINE_PATH . "rest/playItem/0;jsessionid=" . $_SESSION["qtiengine_session"], CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => array("Content-Type: multipart/form-data; boundary=" . $multipart->boundary(), "Expect: "), CURLOPT_POSTFIELDS => $multipart->requeststring()));
        $response = curl_exec($curl);
Exemple #4
0
}
//////////////////////////////////////////////////////////////
if ($_GET["action"] == "getvip") {
    getvip();
} else {
    if ($_GET["action"] == "movepoints") {
        movepoints();
    } else {
        if ($_GET["action"] == "gen_char") {
            gen_char();
        } else {
            if ($_GET["action"] == "movechar") {
                movechar();
            } else {
                if ($_GET["action"] == "getitem") {
                    getitem();
                } else {
                    if ($_GET["action"] == "tplayer") {
                        tplayer();
                    } else {
                        if ($_GET["action"] == "extvip") {
                            extvip();
                        } else {
                            if ($_GET["action"] == "rename") {
                                renchar($ren_char);
                            } else {
                                require_once "header.php";
                                valid_login($action_permission['read']);
                                //################################################################################
                                ##############################
                                // EDIT USER
Exemple #5
0
        }
        if (isset($_SESSION["search"]["where"])) {
            $where = $_SESSION["search"]["where"];
        }
        if (isset($_SESSION["search"]["user"])) {
            $user = $_SESSION["search"]["user"];
        }
        if (isset($_SESSION["search"]["keyword"])) {
            $keyword = $_SESSION["search"]["keyword"];
        }
    }
}
// get items
$items = array();
foreach ($_SESSION["items"] as $itemid) {
    $items[] = getitem($itemid);
}
// get page number from request
$page = 1;
if (isset($_REQUEST["p"])) {
    $page = intval($_REQUEST["p"]);
}
if ($page < 1) {
    $page = 1;
}
$perpage = 20;
if (isset($_REQUEST["perpage"])) {
    $perpage = intval($_REQUEST["perpage"]);
}
if ($perpage < 1) {
    $perpage = 1;