Esempio n. 1
0
 public function createCourse()
 {
     $response = $this->generateResponse();
     if (!checkACL(user_type(), $this->input->post("module_ID")) && API_Controller::STUDENT_MANAGEMENT) {
         //if not admin
         $response["error"][] = array("status" => 1, "message" => "Not Authorized");
     } else {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('code', 'Code', 'required');
         $this->form_validation->set_rules('description', 'Course Description', 'required|is_unique[course.description]');
         if ($this->form_validation->run()) {
             $result = $this->m_course->createCourse($this->input->post("code"), $this->input->post("description"));
             if ($result) {
                 $this->m_change_log->createChangeLog(4, user_id(), json_encode(array("message" => "Create Course", "associated_ID" => $result)));
                 $response["data"] = $result;
             } else {
                 $response["error"][] = array("status" => 3, "message" => "Failed to create Course");
             }
         } else {
             $response["error"][] = array("status" => 2, "message" => validation_errors());
         }
     }
     echo json_encode($response);
 }
Esempio n. 2
0
	/**
* Launch a Content-Item
* @param integer CID to launch
* @param integer ID of the level to launch to.
* @param integer ID of the variation to launch.
* @returns integer Translated ID after launch
*/
	function launchContent($in, $level, $variation) {
		global $db, $auth;
		if (!checkACL($in)) {						
			$out = translateState($in, $level);
			$sql = "SELECT * FROM content WHERE CID = $in";
			$query = new query($db, $sql);
			$query->getrow();
			$module = $query->field("MODULE_ID");
			$category = $query->field("CATEGORY_ID");
			$mtid = $query->field("MT_ID");
			$name = addslashes($query->field("NAME"));
			$keywords = addslashes($query->field("KEYWORDS"));
			$description = addslashes($query->field("DESCRIPTION"));
			$delme = $query->field("DELETED");
			$accesskey = $query->field("ACCESSKEY");

			// do some launches
			$mtTrans = launchMetaTemplate($mtid, $level);

			$sql = "DELETE FROM content WHERE CID = $out";
			$query = new query($db, $sql);
			$sql = "INSERT INTO content (CID, MODULE_ID, CATEGORY_ID, MT_ID, NAME, DESCRIPTION, KEYWORDS, CREATED, LAST_MODIFIER, VERSION, DELETED, ACCESSKEY) VALUES ";
			$sql .= "($out, $module, $category, $mtTrans, '$name', '$description', '$keywords', NOW(), '$auth->user', $level, $delme, '$accesskey')";
			
			$query = new query($db, $sql);
			// launch the content.
			$dbc = createDBCArray("content_variations", "VARIATION_ID", "DELETED=0 AND CID=".$in);
			for ($i=0; $i<count($dbc);$i++) {
			  launchContentVariation($in, $module, $level, $dbc[$i]);
      }		
			// launch metas
			$sql = "SELECT MID FROM meta WHERE CID = $in AND DELETED=0";
			$query = new query($db, $sql);

			while ($query->getrow()) {
				launchMeta($query->field("MID"), $level);
			}

			$query->free();			
			return $out;
		} else
			return translateState($in, $level);
	}
Esempio n. 3
0
/** 
 * Launch a Meta-Template-Item
 * @param integer ID to launch
 * @param integer ID of the corresponding Meta-TEmplate.
 * @param integer ID of the level to launch to
 * @returns integer Translated ID after launch
 */
function launchMetaTemplateItem($in, $mt, $level)
{
    global $db;
    if (!checkACL($in)) {
        $out = translateState($in, $level);
        $sql = "SELECT NAME, POSITION, MTYPE_ID FROM meta_template_items WHERE MTI_ID = {$in}";
        $query = new query($db, $sql);
        $query->getrow();
        $name = addslashes($query->field("NAME"));
        $position = $query->field("POSITION");
        $type = $query->field("MTYPE_ID");
        $sql = "DELETE FROM meta_template_items WHERE MTI_ID = {$out}";
        $query = new query($db, $sql);
        $sql = "INSERT INTO meta_template_items (MTI_ID, MT_ID, NAME, POSITION, MTYPE_ID, VERSION) VALUES ({$out}, {$mt}, '{$name}', {$position}, {$type}, {$level})";
        $query = new query($db, $sql);
        $query->free();
        return $out;
    } else {
        return translateState($in, $level);
    }
}
/** 
 * Launch a Cluster-Template-Item
 * @param integer ID to launch
 * @param integer ID of the corresponding Cluster-Template
 * @param integer ID of the level to launch to
 * @param integer ID of the variation to launch.
 * @returns integer Translated ID after launch
 */
function launchClusterTemplateItem($in, $clt, $level, $variation)
{
    global $db;
    if (!checkACL($in)) {
        $out = translateState($in, $level);
        $sql = "SELECT NAME, POSITION, MINCARD, MAXCARD, FKID, CLTITYPE_ID FROM cluster_template_items WHERE CLTI_ID = {$in}";
        $query = new query($db, $sql);
        $query->getrow();
        $name = addslashes($query->field("NAME"));
        $position = $query->field("POSITION");
        $type = $query->field("CLTITYPE_ID");
        $mincard = $query->field("MINCARD");
        $maxcard = $query->field("MAXCARD");
        $fkid = $query->field("FKID");
        $foreign = $fkid;
        // launch static content or cluster-instance.
        if ($type == 1) {
            $foreign = launchContent($fkid, $level, $variation);
        }
        if ($type == 2) {
            launchPgnConfigStore($in);
        }
        if ($type == 3) {
            $foreign = launchCluster($fkid, $level, $variation);
        }
        if ($type == 7) {
            $foreign = translateState($fkid, $level, false);
        }
        $sql = "DELETE FROM cluster_template_items WHERE CLTI_ID = {$out}";
        $query = new query($db, $sql);
        $sql = "INSERT INTO cluster_template_items (CLTI_ID, CLT_ID, NAME, POSITION, MINCARD, MAXCARD, FKID, CLTITYPE_ID, DELETED, VERSION) ";
        $sql .= "VALUES ({$out}, {$clt}, '{$name}', {$position}, {$mincard}, {$maxcard}, {$foreign}, {$type}, 0, {$level})";
        $query = new query($db, $sql);
        $query->free();
        return $out;
    } else {
        return translateState($in, $level);
    }
}
Esempio n. 5
0
/**
* Launch a Cluster-Content-Item
* @param integer CLCID to launch
* @param integer ID of the level to launch to.
* @param integer ID of the variation to launch.
* @return integer Translated ID after launch
*/
function launchClusterContent($in, $level, $variation)
{
    global $db;
    if (!checkACL($in)) {
        $out = translateState($in, $level);
        $sql = "SELECT * FROM cluster_content WHERE CLCID = {$in} AND DELETED=0";
        $query = new query($db, $sql);
        $query->getrow();
        $clid = $query->field("CLID");
        $clti = $query->field("CLTI_ID");
        $posi = $query->field("POSITION");
        $title = addslashes($query->field("TITLE"));
        $fkid = $query->field("FKID");
        $delme = $query->field("DELETED");
        // get type from clti...
        $sql = "SELECT CLTITYPE_ID, FKID FROM cluster_template_items WHERE CLTI_ID = {$clti}";
        $query = new query($db, $sql);
        $query->getrow();
        $type = $query->field("CLTITYPE_ID");
        $clfktype = $query->field("FKID");
        $fkTrans = 0;
        if ($fkid != 0 && ($type == 4 || $type == 6)) {
            $fkTrans = launchCluster($fkid, $level, $variation);
        }
        if ($type == 2) {
            launchPlugin($in, $clfktype, $level, $clti);
        }
        if ($fkid != 0 && $type == 5) {
            $fkTrans = launchContent($fkid, $level, $variation);
        }
        if ($type == 8) {
            $fkTrans = launchCenterstage($in, $level);
        }
        // translate ids
        $clid = translateState($clid, $level, false);
        $clti = translateState($clti, $level, false);
        $sql = "DELETE FROM cluster_content WHERE CLCID = {$out}";
        $query = new query($db, $sql);
        $sql = "INSERT INTO cluster_content (CLCID, CLID, CLTI_ID, POSITION, TITLE, FKID, DELETED) VALUES ";
        $sql .= "({$out}, {$clid}, {$clti}, {$posi}, '{$title}', {$fkTrans}, {$delme})";
        $query = new query($db, $sql);
        $query->free();
        return $out;
    } else {
        return translateState($in, $level);
    }
}