示例#1
0
    header("Location:index.php");
}
//Creates object for global class file
$hldGlobal = new clsGlobal($hdlDb);
//Creates the object for sigma template.
$hdlTpl =& new HTML_Template_Sigma(DIR_ADMIN_TEMPLATE, DIR_ADMIN_TEMPLATE . "/prepared");
//Loads the template from template folder
$hdlTpl->loadTemplateFile("editquizes.htm", TRUE, TRUE);
$strErrormessage = "";
$intError = 1;
if ($_POST["submit"] == "Save") {
    if ($_POST["quiztitle"] == "") {
        $strErrormessage = "Quiz title should not be empty<br>";
        $intError = 0;
    }
    $hldGlobal->fnCheckQuiztitle($_POST["cid"], trim($_POST["quiztitle"]));
    if ($intError) {
        foreach ($_POST as $key => $value) {
            $_POST[$key] = mysql_escape_string(trim($value));
        }
        $update = "UPDATE tblQuizTitle SET quiz_title='" . $_POST["quiztitle"] . "' WHERE id=" . $_GET["id"];
        mysql_query($update);
        $sqlQuestion = "INSERT INTO tblQuizQuestion(id,quiz_title_id,module_id,question,option_id,isactive,dtcreated) SELECT * FROM temp_quiz_question ON DUPLICATE KEY UPDATE quiz_title_id=" . $_GET["id"];
        mysql_query($sqlQuestion) or die(mysql_error());
        $sql = "SELECT id FROM tblQuizQuestion WHERE quiz_title_id=" . $_GET["id"];
        $rs = mysql_query($sql);
        $intCnt = mysql_num_rows($rs);
        if ($intCnt) {
            $rw = mysql_fetch_array($rs);
            $intQid = $rw["id"];
            $sqlOption = "INSERT INTO tblQuizOption(id,qid,options,isactive,dtcreated) SELECT * FROM temp_quiz_options ON DUPLICATE KEY UPDATE qid=" . $intQid;
示例#2
0
//Assigns footer
$hdlTpl->setVariable("leftmenu", $strLeftMenu);
//Assigns left menu
$intError = 1;
if ($_POST["submit"] == "Add quiz") {
    $strErrormessage = "";
    if (trim($_POST["course_id"]) == "--") {
        $strErrormessage .= "Please select course name.<br>";
        $intError = 0;
    }
    if (trim($_POST["quiztitle"]) == "") {
        $strErrormessage .= "Please enter quiz title.<br>";
        $intError = 0;
    }
    if ($_SESSION["InTlAsTiD"] == "") {
        if ($hldGlobal->fnCheckQuiztitle($_POST["course_id"], trim($_POST["quiztitle"]))) {
            $strErrormessage .= "Quiz title already added.<br>";
            $intError = 0;
        }
    }
    if ($intError) {
        foreach ($_POST as $key => $value) {
            $_POST[$key] = mysql_escape_string(trim($value));
        }
        if ($_SESSION["InTlAsTiD"]) {
            $sql = "UPDATE tblQuizTitle SET to_show='1' WHERE id=" . $_SESSION["InTlAsTiD"];
        } else {
            $sql = "INSERT INTO tblQuizTitle(id,course_id,quiz_title,to_show,isactive,dtcreated) VALUES('','" . $_POST["course_id"] . "','" . $_POST["quiztitle"] . "','1','1','" . date("Y-m-d H:i:s") . "')";
        }
        mysql_query($sql);
        unset($_SESSION["InTlAsTiD"]);