Example #1
0
 /**
  * Generate Users
  *
  * @param
  * @return
  */
 function generateUsers($a_login_base = "learner", $a_start = 1, $a_end = 1000, $a_firstname = "John", $a_lastname_base = "Learner", $a_pw = "learnerpw", $a_email = "*****@*****.**", $a_gender = "m", $a_lang = "en")
 {
     global $rbacadmin;
     // new users
     $this->log("Creating Users");
     for ($i = $a_start; $i <= $a_end; $i++) {
         $this->log($a_login_base . $i);
         $user = new ilObjUser();
         $user->setLogin($a_login_base . $i);
         $user->setFirstname($a_firstname);
         $user->setLastname($a_lastname_base . " " . $i);
         $user->setGender($a_gender);
         $user->setEmail($a_email);
         $user->setAgreeDate(ilUtil::now());
         $user->setPasswd($a_pw, IL_PASSWD_PLAIN);
         $user->setTitle($user->getFullname());
         $user->setDescription($user->getEmail());
         $user->setLastPasswordChangeTS(time());
         $user->setActive(true);
         $user->setTimeLimitUnlimited(true);
         $user->create();
         $user->setLanguage($a_lang);
         $user->saveAsNew(false);
         $user->writePrefs();
         $rbacadmin->assignUser(4, $user->getId(), true);
     }
 }
 /**
  * Add new type to object data
  * 
  * @param string $a_type_id
  * @param string $a_type_title 
  * @return int insert id
  */
 public static function addNewType($a_type_id, $a_type_title)
 {
     global $ilDB;
     // check if it already exists
     $type_id = self::getObjectTypeId($a_type_id);
     if ($type_id) {
         return $type_id;
     }
     $type_id = $ilDB->nextId('object_data');
     $fields = array('obj_id' => array('integer', $type_id), 'type' => array('text', 'typ'), 'title' => array('text', $a_type_id), 'description' => array('text', $a_type_title), 'owner' => array('integer', -1), 'create_date' => array('timestamp', ilUtil::now()), 'last_update' => array('timestamp', ilUtil::now()));
     $ilDB->insert('object_data', $fields);
     return $type_id;
 }
    function scorm12PlayerUnload()
    {
        global $ilUser, $ilDB;
        $user_id = $ilUser->getID();
        $ref_id = $_GET["ref_id"];
        $obj_id = ilObject::_lookupObjId($ref_id);
        if ($obj_id <= 1) {
            $GLOBALS['ilLog']->write(__METHOD__ . ' no valid obj_id');
        } else {
            $data = $_POST['last_visited'];
            //			$GLOBALS['ilLog']->write(__METHOD__.' last_visited: '.$data);
            if ($data) {
                $set = $ilDB->queryF('
				SELECT rvalue FROM scorm_tracking 
				WHERE user_id = %s
				AND sco_id =  %s
				AND lvalue =  %s
				AND obj_id = %s', array('integer', 'integer', 'text', 'integer'), array($user_id, 0, 'last_visited', $obj_id));
                if ($rec = $ilDB->fetchAssoc($set)) {
                    $ilDB->update('scorm_tracking', array('rvalue' => array('clob', $data), 'c_timestamp' => array('timestamp', ilUtil::now())), array('user_id' => array('integer', $user_id), 'sco_id' => array('integer', 0), 'lvalue' => array('text', 'last_visited'), 'obj_id' => array('integer', $obj_id)));
                } else {
                    $ilDB->insert('scorm_tracking', array('obj_id' => array('integer', $obj_id), 'user_id' => array('integer', $user_id), 'sco_id' => array('integer', 0), 'lvalue' => array('text', 'last_visited'), 'rvalue' => array('clob', $data), 'c_timestamp' => array('timestamp', ilUtil::now())));
                }
            }
            // update time and numbers of attempts in change event
            //NOTE: here it is correct (not count of commit with changed values); be careful to performance issues
            ilObjSCORMTracking::_syncReadEvent($obj_id, $user_id, "sahs", $ref_id);
        }
        header('Content-Type: text/plain; charset=UTF-8');
        print "";
    }
 /**
  * Creates the preview of the specified preview object.
  * 
  * @param ilPreview $preview The preview object.
  * @param ilObject $obj The object to create a preview for.
  * @param bool $async true, if the rendering should be done asynchronously; otherwise, false.
  * @return bool true, if the preview was successfully rendered; otherwise, false.
  */
 public final function render($preview, $obj, $async)
 {
     $preview->setRenderDate(ilUtil::now());
     $preview->setRenderStatus(ilPreview::RENDER_STATUS_PENDING);
     $preview->save();
     // TODO: this should be done in background if $async is true
     // the deriving renderer should deliver images
     require_once "./Services/Preview/classes/class.ilRenderedImage.php";
     $images = $this->renderImages($obj);
     // process each image
     if (is_array($images) && count($images) > 0) {
         $success = false;
         foreach ($images as $idx => $image) {
             // create the ending preview image
             $success |= $this->createPreviewImage($image->getImagePath(), sprintf($preview->getFilePathFormat(), $idx + 1));
             // if the image is temporary we can delete it
             if ($image->isTemporary()) {
                 $image->delete();
             }
         }
         $preview->setRenderDate(ilUtil::now());
         $preview->setRenderStatus($success ? ilPreview::RENDER_STATUS_CREATED : ilPreview::RENDER_STATUS_FAILED);
         return $success;
     } else {
         $preview->setRenderDate(ilUtil::now());
         $preview->setRenderStatus(ilPreview::RENDER_STATUS_FAILED);
         return false;
     }
 }
 /**
  * presentation title doesn't have to be page title, it may be
  * chapter title + page title or chapter title only, depending on settings
  *
  * @param	string	$a_mode		IL_CHAPTER_TITLE | IL_PAGE_TITLE | IL_NO_HEADER
  */
 function _getPresentationTitle($a_pg_id, $a_mode = IL_CHAPTER_TITLE, $a_include_numbers = false, $a_time_scheduled_activation = false, $a_force_content = false)
 {
     global $ilDB;
     // select
     $query = "SELECT * FROM lm_data WHERE obj_id = " . $ilDB->quote($a_pg_id, "integer");
     $pg_set = $ilDB->query($query);
     $pg_rec = $ilDB->fetchAssoc($pg_set);
     if ($a_mode == IL_NO_HEADER && !$a_force_content) {
         return "";
     }
     $tree = new ilTree($pg_rec["lm_id"]);
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     if ($a_mode == IL_PAGE_TITLE) {
         $nr = "";
         return $nr . $pg_rec["title"];
     }
     if ($tree->isInTree($pg_rec["obj_id"])) {
         $pred_node = $tree->fetchPredecessorNode($pg_rec["obj_id"], "st");
         $childs = $tree->getChildsByType($pred_node["obj_id"], "pg");
         $cnt_str = "";
         if (count($childs) > 1) {
             $cnt = 0;
             foreach ($childs as $child) {
                 include_once "./Services/COPage/classes/class.ilPageObject.php";
                 $active = ilPageObject::_lookupActive($child["obj_id"], ilObject::_lookupType($pg_rec["lm_id"]), $a_time_scheduled_activation);
                 if (!$active) {
                     $act_data = ilPageObject::_lookupActivationData((int) $child["obj_id"], ilObject::_lookupType($pg_rec["lm_id"]));
                     if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
                         $active = true;
                     }
                 }
                 if ($child["type"] != "pg" || $active) {
                     $cnt++;
                 }
                 if ($child["obj_id"] == $pg_rec["obj_id"]) {
                     $cur_cnt = $cnt;
                 }
             }
             if ($cnt > 1) {
                 $cnt_str = " (" . $cur_cnt . "/" . $cnt . ")";
             }
         }
         require_once "./Modules/LearningModule/classes/class.ilStructureObject.php";
         //$struct_obj =& new ilStructureObject($pred_node["obj_id"]);
         //return $struct_obj->getTitle();
         return ilStructureObject::_getPresentationTitle($pred_node["obj_id"], $a_include_numbers) . $cnt_str;
         //return $pred_node["title"].$cnt_str;
     } else {
         return $pg_rec["title"];
     }
 }
    function importSuccess($a_file)
    {
        global $ilDB, $ilUser;
        include_once "./Services/Tracking/classes/class.ilLPStatus.php";
        $scos = array();
        //get all SCO's of this object ONLY RELEVANT!
        include_once './Services/Object/classes/class.ilObjectLP.php';
        $olp = ilObjectLP::getInstance($this->getId());
        $collection = $olp->getCollectionInstance();
        if ($collection) {
            $scos = $collection->getItems();
        }
        $fhandle = fopen($a_file, "r");
        $obj_id = $this->getID();
        $users = array();
        $fields = fgetcsv($fhandle, 4096, ';');
        while (($csv_rows = fgetcsv($fhandle, 4096, ";")) !== FALSE) {
            $data = array_combine($fields, $csv_rows);
            //no check the format - sufficient to import users
            if ($data["Login"]) {
                $user_id = $this->get_user_id($data["Login"]);
            }
            if ($data["login"]) {
                $user_id = $this->get_user_id($data["login"]);
            }
            //add mail in future
            if ($data["user"] && is_int($data["user"])) {
                $user_id = $data["user"];
            }
            if ($user_id > 0) {
                $last_access = ilUtil::now();
                if ($data['Date']) {
                    $date_ex = explode('.', $data['Date']);
                    $last_access = implode('-', array($date_ex[2], $date_ex[1], $date_ex[0]));
                }
                if ($data['LastAccess']) {
                    $last_access = $data['LastAccess'];
                }
                $status = ilLPStatus::LP_STATUS_COMPLETED_NUM;
                // $users[] = $user_id;
                if ($data["Status"]) {
                    if (is_int($data["Status"])) {
                        $status = $data["Status"];
                    } else {
                        if ($data["Status"] == ilLPStatus::LP_STATUS_NOT_ATTEMPTED) {
                            $status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM;
                        } else {
                            if ($data["Status"] == ilLPStatus::LP_STATUS_IN_PROGRESS) {
                                $status = ilLPStatus::LP_STATUS_IN_PROGRESS_NUM;
                            } else {
                                if ($data["Status"] == ilLPStatus::LP_STATUS_FAILED) {
                                    $status = ilLPStatus::LP_STATUS_FAILED_NUM;
                                }
                            }
                        }
                    }
                }
                $attempts = null;
                if ($data["Attempts"]) {
                    $attempts = $data["Attempts"];
                }
                $percentage_completed = 0;
                if ($status == ilLPStatus::LP_STATUS_COMPLETED_NUM) {
                    $percentage_completed = 100;
                }
                if ($data['percentageCompletedSCOs']) {
                    $percentage_completed = $data['percentageCompletedSCOs'];
                }
                $sco_total_time_sec = null;
                if ($data['SumTotal_timeSeconds']) {
                    $sco_total_time_sec = $data['SumTotal_timeSeconds'];
                }
                $this->importSuccessForSahsUser($user_id, $last_access, $status, $attempts, $percentage_completed, $sco_total_time_sec);
                if ($status == ilLPStatus::LP_STATUS_COMPLETED_NUM) {
                    foreach ($scos as $sco_id) {
                        $res = $ilDB->queryF('
						SELECT * FROM cmi_node WHERE cp_node_id = %s AND user_id  = %s AND (completion_status = %s OR success_status = %s)', array('integer', 'integer', 'text', 'text'), array($sco_id, $user_id, 'completed', 'passed'));
                        if (!$ilDB->numRows($res)) {
                            $nextId = $ilDB->nextId('cmi_node');
                            $val_set = $ilDB->manipulateF('INSERT INTO cmi_node 
							(cp_node_id,user_id,completion_status,c_timestamp,cmi_node_id) 
							VALUES(%s,%s,%s,%s,%s)', array('integer', 'integer', 'text', 'timestamp', 'integer'), array($sco_id, $user_id, 'completed', $last_access, $nextId));
                        } else {
                            $ilDB->update('cmi_node', array('completion_status' => array('text', 'completed'), 'success_status' => array('text', ''), 'c_timestamp' => array('timestamp', $last_access)), array('user_id' => array('integer', $user_id), 'cp_node_id' => array('integer', $sco_id)));
                        }
                    }
                }
            } else {
                //echo "Warning! User $csv_rows[0] does not exist in ILIAS. Data for this user was skipped.\n";
            }
        }
        // update learning progress
        include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
        ilLPStatusWrapper::_refreshStatus($this->getId());
        return 0;
    }
 function isVisible($a_id, $a_type)
 {
     include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
     $active = ilLMPage::_lookupActive($a_id, $this->lm_obj->getType(), $this->lm_set->get("time_scheduled_page_activation"));
     if (!$active && $a_type == "pg") {
         $act_data = ilLMPage::_lookupActivationData((int) $a_id, $this->lm_obj->getType());
         if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
             return true;
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
 /**
  * Get last news id of news set related to a certain context
  */
 static function getLastNewsIdForContext($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id = "", $a_context_sub_obj_type = "", $a_only_today = false)
 {
     global $ilDB;
     // Determine how many rows should be deleted
     $query = "SELECT id, update_date " . "FROM il_news_item " . "WHERE " . "context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") . " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") . " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") . " AND " . $ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true) . " ORDER BY update_date DESC";
     $ilDB->setLimit(1);
     $set = $ilDB->query($query);
     $rec = $ilDB->fetchAssoc($set);
     $id = (int) $rec["id"];
     if ($a_only_today) {
         $now = ilUtil::now();
         if (substr($now, 0, 10) != substr($rec["update_date"], 0, 10)) {
             $id = 0;
         }
     }
     return $id;
 }
 public function updatePeerReviewComment($a_peer_id, $a_comment)
 {
     global $ilDB, $ilUser;
     $ilDB->manipulate("UPDATE exc_assignment_peer" . " SET tstamp = " . $ilDB->quote(ilUtil::now(), "timestamp") . ", pcomment  = " . $ilDB->quote($a_comment, "text") . " WHERE giver_id = " . $ilDB->quote($ilUser->getId(), "integer") . " AND peer_id = " . $ilDB->quote($a_peer_id, "integer") . " AND ass_id = " . $ilDB->quote($this->getId(), "integer"));
 }
 /**
  * Write success status
  *
  * @param	int		$a_obj_id		exercise id
  * @param	int		$a_user_id		member id
  * @param	int		$status			status: STATUS_NOT_GRADED|STATUS_PASSED|STATUS_FAILED
  *
  * @return	int		number of affected rows
  */
 function _writeStatus($a_obj_id, $a_user_id, $a_status)
 {
     global $ilDB;
     $ilDB->manipulate("DELETE FROM il_wiki_contributor WHERE " . " wiki_id = " . $ilDB->quote($a_obj_id, "integer") . " AND user_id = " . $ilDB->quote($a_user_id, "integer"));
     $ilDB->manipulateF("INSERT INTO il_wiki_contributor (status, wiki_id, user_id, status_time) " . "VALUES (%s,%s,%s,%s)", array("integer", "integer", "integer", "timestamp"), array($a_status, $a_obj_id, $a_user_id, ilUtil::now()));
 }
Example #11
0
 public static function _setUserInactive($a_usr_id)
 {
     global $ilDB;
     $query = "UPDATE usr_data SET usr_data.active = 0, usr_data.inactivation_date = %s WHERE usr_data.usr_id = %s";
     $affected = $ilDB->manipulateF($query, array('timestamp', 'integer'), array(ilUtil::now(), $a_usr_id));
     if ($affected) {
         return true;
     } else {
         return false;
     }
 }
Example #12
0
require_once "./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php";
$orgu_type_id = ilDBUpdateNewObjectType::getObjectTypeId('orgu');
if ($orgu_type_id) {
    $view_lp = ilDBUpdateNewObjectType::addCustomRBACOperation('view_learning_progress', 'View learning progress from users in this orgu.', 'object', 270);
    $view_lp_rec = ilDBUpdateNewObjectType::addCustomRBACOperation('view_learning_progress_rec', 'View learning progress from users in this orgu and subsequent orgus.', 'object', 280);
    if ($view_lp && $view_lp_rec) {
        ilDBUpdateNewObjectType::addRBACOperation($orgu_type_id, $view_lp);
        ilDBUpdateNewObjectType::addRBACOperation($orgu_type_id, $view_lp_rec);
    }
}
?>
<#4035>
	<?php 
//ORGU TEMPLATES
$orgu_employee_contributor_tpl_id = $ilDB->nextId('object_data');
$ilDB->manipulateF("INSERT INTO object_data (obj_id, type, title, description," . " owner, create_date, last_update) VALUES (%s, %s, %s, %s, %s, %s, %s)", array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"), array($orgu_employee_contributor_tpl_id, "rolt", "il_orgu_superior", "OrgUnit Superior Role Template", -1, ilUtil::now(), ilUtil::now()));
$query = 'SELECT ops_id FROM rbac_operations WHERE operation = ' . $ilDB->quote('view_learning_progress', 'text');
$rset = $ilDB->query($query);
$row = $ilDB->fetchAssoc($rset);
$view_lp = $row['ops_id'];
if ($view_lp) {
    // See LP
    $ilDB->manipulateF("INSERT INTO rbac_templates (rol_id, type, ops_id, parent)" . " VALUES (%s, %s, %s, %s)", array("integer", "text", "integer", "integer"), array($orgu_employee_contributor_tpl_id, "orgu", $view_lp, 8));
    //Show
    $ilDB->manipulateF("INSERT INTO rbac_templates (rol_id, type, ops_id, parent)" . " VALUES (%s, %s, %s, %s)", array("integer", "text", "integer", "integer"), array($orgu_employee_contributor_tpl_id, "orgu", 2, 8));
    //Read
    $ilDB->manipulateF("INSERT INTO rbac_templates (rol_id, type, ops_id, parent)" . " VALUES (%s, %s, %s, %s)", array("integer", "text", "integer", "integer"), array($orgu_employee_contributor_tpl_id, "orgu", 3, 8));
    //No idea
    $ilDB->manipulateF("INSERT INTO rbac_fa (rol_id, parent, assign, protected)" . " VALUES (%s, %s, %s, %s)", array("integer", "integer", "text", "text"), array($orgu_employee_contributor_tpl_id, 8, "n", "n"));
}
?>
Example #13
0
 public function saveData($a_roles = array())
 {
     /**
      * @var $ilDB   ilDB
      * @var $ilUser ilObjUser
      */
     global $ilUser, $ilDB;
     $nextId = $ilDB->nextId('frm_data');
     $top_data = array('top_frm_fk' => $this->getId(), 'top_name' => $this->getTitle(), 'top_description' => $this->getDescription(), 'top_num_posts' => 0, 'top_num_threads' => 0, 'top_last_post' => NULL, 'top_mods' => !is_numeric($a_roles[0]) ? 0 : $a_roles[0], 'top_usr_id' => $ilUser->getId(), 'top_date' => ilUtil::now());
     $statement = $ilDB->manipulateF('
     	INSERT INTO frm_data 
     	( 
     	 	top_pk,
     		top_frm_fk, 
     		top_name,
     		top_description,
     		top_num_posts,
     		top_num_threads,
     		top_last_post,
     		top_mods,
     		top_date,
     		top_usr_id
     	)
     	VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)', array('integer', 'integer', 'text', 'text', 'integer', 'integer', 'text', 'integer', 'timestamp', 'integer'), array($nextId, $top_data['top_frm_fk'], $top_data['top_name'], $top_data['top_description'], $top_data['top_num_posts'], $top_data['top_num_threads'], $top_data['top_last_post'], $top_data['top_mods'], $top_data['top_date'], $top_data['top_usr_id']));
 }
Example #14
0
 /**
  * Is node visible for the learner
  *
  * @param mixed $a_node node object/array
  * @return boolean node visible true/false
  */
 static function _isNodeVisible($a_node)
 {
     include_once "./Services/COPage/classes/class.ilPageObject.php";
     if ($a_node["type"] != "pg") {
         return true;
     }
     $lm_set = new ilSetting("lm");
     $active = ilPageObject::_lookupActive($a_node["child"], "lm", $lm_set->get("time_scheduled_page_activation"));
     if (!$active) {
         $act_data = ilPageObject::_lookupActivationData((int) $a_node["child"], "lm");
         if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
             return true;
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
 /**
  * Handle text assignment submissions
  *
  * @param int $a_exc_id
  * @param int $a_ass_id
  * @param int $a_user_id
  * @param string $a_text
  * @return int
  */
 function updateTextSubmission($a_exc_id, $a_ass_id, $a_user_id, $a_text)
 {
     global $ilDB;
     $files = ilExAssignment::getDeliveredFiles($a_exc_id, $a_ass_id, $a_user_id);
     // no text = remove submission
     if (!trim($a_text)) {
         if ($files) {
             $files = array_shift($files);
             $id = $files["returned_id"];
             if ($id) {
                 $this->deleteDeliveredFiles($a_exc_id, $a_ass_id, array($id), $a_user_id);
                 return;
             }
         }
     }
     if (!$files) {
         return $this->addResourceObject("TEXT", $a_ass_id, $a_user_id, $a_text);
     } else {
         $files = array_shift($files);
         $id = $files["returned_id"];
         if ($id) {
             $ilDB->manipulate("UPDATE exc_returned" . " SET atext = " . $ilDB->quote($a_text, "text") . ", ts = " . $ilDB->quote(ilUtil::now(), "timestamp") . " WHERE returned_id = " . $ilDB->quote($id, "integer"));
             return $id;
         }
     }
 }
 /**
  * Write skill level status
  *
  * @param	int		skill level id
  * @param	int		user id
  * @param	int		status
  */
 static function writeUserSkillLevelStatus($a_level_id, $a_user_id, $a_status = ilBasicSkill::ACHIEVED, $a_force = false)
 {
     global $ilDB;
     $skill_id = ilBasicSkill::lookupLevelSkillId($a_level_id);
     $trigger = ilBasicSkill::lookupLevelTrigger($a_level_id);
     $trigger_ref_id = $trigger["ref_id"];
     $trigger_obj_id = $trigger["obj_id"];
     $trigger_title = ilObject::_lookupTitle($trigger["obj_id"]);
     $save = false;
     if ($a_force) {
         $save = true;
     } else {
         // check whether current skill user level is identical
         // to the one that should be set (-> no change required)
         $ilDB->setLimit(1);
         $set = $ilDB->query("SELECT status, valid FROM skl_user_skill_level WHERE " . "level_id = " . $ilDB->quote($a_level_id, "integer") . " AND " . "user_id = " . $ilDB->quote($a_user_id, "integer") . " ORDER BY status_date DESC");
         $rec = $ilDB->fetchAssoc($set);
         if (!$rec["valid"] || $rec["status"] != $a_status) {
             $save = true;
         }
     }
     if ($save) {
         $now = ilUtil::now();
         $ilDB->manipulate("INSERT INTO skl_user_skill_level " . "(level_id, user_id, status_date, skill_id, status, valid, trigger_ref_id," . "trigger_obj_id, trigger_title) VALUES (" . $ilDB->quote($a_level_id, "integer") . "," . $ilDB->quote($a_user_id, "integer") . "," . $ilDB->quote($now, "timestamp") . "," . $ilDB->quote($skill_id, "integer") . "," . $ilDB->quote($a_status, "integer") . "," . $ilDB->quote(1, "integer") . "," . $ilDB->quote($trigger_ref_id, "integer") . "," . $ilDB->quote($trigger_obj_id, "integer") . "," . $ilDB->quote($trigger_title, "text") . ")");
         $ilDB->manipulate("DELETE FROM skl_user_has_level WHERE " . " user_id = " . $ilDB->quote($a_user_id, "integer") . " AND level_id = " . $ilDB->quote($a_level_id, "integer"));
         if ($a_status == ilBasicSkill::ACHIEVED) {
             $ilDB->manipulate("INSERT INTO skl_user_has_level " . "(level_id, user_id, status_date, skill_id, trigger_ref_id, trigger_obj_id, trigger_title) VALUES (" . $ilDB->quote($a_level_id, "integer") . "," . $ilDB->quote($a_user_id, "integer") . "," . $ilDB->quote($now, "timestamp") . "," . $ilDB->quote($skill_id, "integer") . "," . $ilDB->quote($trigger_ref_id, "integer") . "," . $ilDB->quote($trigger_obj_id, "integer") . "," . $ilDB->quote($trigger_title, "text") . ")");
         }
     }
 }
 /**
  * Save self evaluation
  *
  * @param int $a_user_id user id
  * @param int $a_top_skill the "selectable" top skill
  * @param int $a_tref_id template reference id
  * @param int $a_basic_skill the basic skill the level belongs to
  * @param int $a_level level id
  */
 static function saveSelfEvaluation($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill, $a_level)
 {
     global $ilDB;
     $set = $ilDB->query("SELECT * FROM skl_self_eval_level " . " WHERE user_id = " . $ilDB->quote($a_user_id, "integer") . " AND top_skill_id = " . $ilDB->quote($a_top_skill, "integer") . " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") . " AND skill_id = " . $ilDB->quote($a_basic_skill, "integer"));
     if (!$ilDB->fetchAssoc($set)) {
         $ilDB->manipulate("INSERT INTO skl_self_eval_level " . "(user_id, top_skill_id, tref_id, skill_id, level_id, last_update) VALUES (" . $ilDB->quote($a_user_id, "integer") . "," . $ilDB->quote($a_top_skill, "integer") . "," . $ilDB->quote((int) $a_tref_id, "integer") . "," . $ilDB->quote($a_basic_skill, "integer") . "," . $ilDB->quote($a_level, "integer") . "," . $ilDB->quote(ilUtil::now(), "timestamp") . ")");
     } else {
         $ilDB->manipulate("UPDATE skl_self_eval_level SET " . " level_id = " . $ilDB->quote($a_level, "integer") . ", " . " last_update = " . $ilDB->quote(ilUtil::now(), "timestamp") . " WHERE user_id = " . $ilDB->quote($a_user_id, "integer") . " AND top_skill_id = " . $ilDB->quote($a_top_skill, "integer") . " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") . " AND skill_id = " . $ilDB->quote($a_basic_skill, "integer"));
     }
 }
    function importSuccess($a_file)
    {
        global $ilDB, $ilUser;
        include_once "./Services/Tracking/classes/class.ilLPStatus.php";
        $scos = array();
        //get all SCO's of this object ONLY RELEVANT!
        include_once './Services/Object/classes/class.ilObjectLP.php';
        $olp = ilObjectLP::getInstance($this->getId());
        $collection = $olp->getCollectionInstance();
        if ($collection) {
            $scos = $collection->getItems();
        }
        $fhandle = fopen($a_file, "r");
        $obj_id = $this->getID();
        $fields = fgetcsv($fhandle, pow(2, 16), ';');
        // $users = array();
        while (($csv_rows = fgetcsv($fhandle, pow(2, 16), ";")) !== FALSE) {
            $data = array_combine($fields, $csv_rows);
            //no check the format - sufficient to import users
            if ($data["Login"]) {
                $user_id = $this->get_user_id($data["Login"]);
            }
            if ($data["login"]) {
                $user_id = $this->get_user_id($data["login"]);
            }
            //add mail in future
            if ($data["user"] && is_int($data["user"])) {
                $user_id = $data["user"];
            }
            if ($user_id > 0) {
                $last_access = ilUtil::now();
                if ($data['Date']) {
                    $date_ex = explode('.', $data['Date']);
                    $last_access = implode('-', array($date_ex[2], $date_ex[1], $date_ex[0]));
                }
                if ($data['LastAccess']) {
                    $last_access = $data['LastAccess'];
                }
                $status = ilLPStatus::LP_STATUS_COMPLETED_NUM;
                // $users[] = $user_id;
                if ($data["Status"]) {
                    if (is_int($data["Status"])) {
                        $status = $data["Status"];
                    } else {
                        if ($data["Status"] == ilLPStatus::LP_STATUS_NOT_ATTEMPTED) {
                            $status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM;
                        } else {
                            if ($data["Status"] == ilLPStatus::LP_STATUS_IN_PROGRESS) {
                                $status = ilLPStatus::LP_STATUS_IN_PROGRESS_NUM;
                            } else {
                                if ($data["Status"] == ilLPStatus::LP_STATUS_FAILED) {
                                    $status = ilLPStatus::LP_STATUS_FAILED_NUM;
                                }
                            }
                        }
                    }
                }
                $attempts = null;
                if ($data["Attempts"]) {
                    $attempts = $data["Attempts"];
                }
                $percentage_completed = 0;
                if ($status == ilLPStatus::LP_STATUS_COMPLETED_NUM) {
                    $percentage_completed = 100;
                }
                if ($data['percentageCompletedSCOs']) {
                    $percentage_completed = $data['percentageCompletedSCOs'];
                }
                $sco_total_time_sec = null;
                if ($data['SumTotal_timeSeconds']) {
                    $sco_total_time_sec = $data['SumTotal_timeSeconds'];
                }
                $this->importSuccessForSahsUser($user_id, $last_access, $status, $attempts, $percentage_completed, $sco_total_time_sec);
                if ($status == ilLPStatus::LP_STATUS_COMPLETED_NUM) {
                    foreach ($scos as $sco_id) {
                        $statement = $ilDB->queryF('
							SELECT * FROM scorm_tracking 
							WHERE user_id = %s
							AND sco_id = %s 
							AND lvalue = %s
							AND obj_id = %s', array('integer', 'integer', 'text', 'integer'), array($user_id, $sco_id, 'cmi.core.lesson_status', $obj_id));
                        if ($ilDB->numRows($statement) > 0) {
                            $ilDB->update('scorm_tracking', array('rvalue' => array('clob', 'completed'), 'c_timestamp' => array('timestamp', $last_access)), array('user_id' => array('integer', $user_id), 'sco_id' => array('integer', $sco_id), 'lvalue' => array('text', 'cmi.core.lesson_status'), 'obj_id' => array('integer', $obj_id)));
                        } else {
                            $ilDB->insert('scorm_tracking', array('obj_id' => array('integer', $obj_id), 'user_id' => array('integer', $user_id), 'sco_id' => array('integer', $sco_id), 'lvalue' => array('text', 'cmi.core.lesson_status'), 'rvalue' => array('clob', 'completed'), 'c_timestamp' => array('timestamp', $last_access)));
                        }
                    }
                }
            } else {
                //echo "Warning! User $csv_rows[0] does not exist in ILIAS. Data for this user was skipped.\n";
            }
        }
        include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
        ilLPStatusWrapper::_refreshStatus($this->getId());
        //		<4.2.6: foreach ($users as $user_id) {ilLPStatusWrapper::_updateStatus($obj_id, $user_id);}
        return 0;
    }
Example #19
0
 /**
  * presentation title doesn't have to be page title, it may be
  * chapter title + page title or chapter title only, depending on settings
  *
  * @param	string	$a_mode		IL_CHAPTER_TITLE | IL_PAGE_TITLE | IL_NO_HEADER
  */
 static function _getPresentationTitle($a_pg_id, $a_mode = IL_CHAPTER_TITLE, $a_include_numbers = false, $a_time_scheduled_activation = false, $a_force_content = false, $a_lm_id = 0, $a_lang = "-")
 {
     if ($a_mode == IL_NO_HEADER && !$a_force_content) {
         return "";
     }
     if ($a_lm_id == 0) {
         $a_lm_id = ilLMObject::_lookupContObjID($a_pg_id);
     }
     if ($a_lm_id == 0) {
         return "";
     }
     // this is optimized when ilLMObject::preloadDataByLM is invoked (e.g. done in ilLMExplorerGUI)
     $title = ilLMObject::_lookupTitle($a_pg_id);
     // this is also optimized since ilObjectTranslation re-uses instances for one lm
     include_once "./Services/Object/classes/class.ilObjectTranslation.php";
     $ot = ilObjectTranslation::getInstance($a_lm_id);
     $languages = $ot->getLanguages();
     if ($a_lang != "-" && $ot->getContentActivated() && isset($languages[$a_lang])) {
         include_once "./Modules/LearningModule/classes/class.ilLMObjTranslation.php";
         $lmobjtrans = new ilLMObjTranslation($a_pg_id, $a_lang);
         if ($lmobjtrans->getTitle() != "") {
             $title = $lmobjtrans->getTitle();
         }
     }
     if ($a_mode == IL_PAGE_TITLE) {
         return $title;
     }
     include_once "./Modules/LearningModule/classes/class.ilLMTree.php";
     $tree = ilLMTree::getInstance($a_lm_id);
     if ($tree->isInTree($a_pg_id)) {
         $pred_node = $tree->fetchPredecessorNode($a_pg_id, "st");
         $childs = $tree->getChildsByType($pred_node["obj_id"], "pg");
         $cnt_str = "";
         if (count($childs) > 1) {
             $cnt = 0;
             foreach ($childs as $child) {
                 include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
                 $active = ilLMPage::_lookupActive($child["obj_id"], ilObject::_lookupType($a_lm_id), $a_time_scheduled_activation);
                 if (!$active) {
                     $act_data = ilLMPage::_lookupActivationData((int) $child["obj_id"], ilObject::_lookupType($a_lm_id));
                     if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
                         $active = true;
                     }
                 }
                 if ($child["type"] != "pg" || $active) {
                     $cnt++;
                 }
                 if ($child["obj_id"] == $a_pg_id) {
                     $cur_cnt = $cnt;
                 }
             }
             if ($cnt > 1) {
                 $cnt_str = " (" . $cur_cnt . "/" . $cnt . ")";
             }
         }
         require_once "./Modules/LearningModule/classes/class.ilStructureObject.php";
         //$struct_obj =& new ilStructureObject($pred_node["obj_id"]);
         //return $struct_obj->getTitle();
         return ilStructureObject::_getPresentationTitle($pred_node["obj_id"], $a_include_numbers, false, 0, $a_lang) . $cnt_str;
         //return $pred_node["title"].$cnt_str;
     } else {
         return $title;
     }
 }
Example #20
0
 /**
  * Create new blog posting
  */
 function create($a_import = false)
 {
     global $ilDB;
     $id = $ilDB->nextId("il_blog_posting");
     $this->setId($id);
     if (!$a_import) {
         $created = ilUtil::now();
     } else {
         $created = $this->getCreated()->get(IL_CAL_DATETIME);
     }
     // we are using a separate creation date to enable sorting without JOINs
     $query = "INSERT INTO il_blog_posting (id, title, blog_id, created, author, approved)" . " VALUES (" . $ilDB->quote($this->getId(), "integer") . "," . $ilDB->quote($this->getTitle(), "text") . "," . $ilDB->quote($this->getBlogId(), "integer") . "," . $ilDB->quote($created, "timestamp") . "," . $ilDB->quote($this->getAuthor(), "integer") . "," . $ilDB->quote(false, "integer") . ")";
     $ilDB->manipulate($query);
     if (!$a_import) {
         parent::create();
         // $this->saveInternalLinks($this->getXMLContent());
     }
 }
Example #21
0
 /**
  * Write skill level status
  *
  * @param	int		skill level id
  * @param	int		user id
  * @param	int		status
  */
 static function writeUserSkillLevelStatus($a_level_id, $a_user_id, $a_trigger_ref_id, $a_tref_id = 0, $a_status = ilBasicSkill::ACHIEVED, $a_force = false, $a_self_eval = 0)
 {
     global $ilDB;
     $skill_id = ilBasicSkill::lookupLevelSkillId($a_level_id);
     $trigger_ref_id = $a_trigger_ref_id;
     $trigger_obj_id = ilObject::_lookupObjId($trigger_ref_id);
     $trigger_title = ilObject::_lookupTitle($trigger_obj_id);
     $trigger_type = ilObject::_lookupType($trigger_obj_id);
     $update = false;
     // check whether current skill user level is identical
     // to the one that should be set (-> no change required)
     /*			$ilDB->setLimit(1);
     			$set = $ilDB->query("SELECT status, valid FROM skl_user_skill_level WHERE ".
     				"level_id = ".$ilDB->quote($a_level_id, "integer")." AND ".
     				"user_id = ".$ilDB->quote($a_user_id, "integer")." AND ".
     				"tref_id = ".$ilDB->quote((int) $a_tref_id, "integer")." AND ".
     				"trigger_obj_id = ".$ilDB->quote($trigger_obj_id, "integer")." AND ".
     				"self_eval = ".$ilDB->quote($a_self_eval, "integer").
     				" ORDER BY status_date DESC"
     			);
     			$rec = $ilDB->fetchAssoc($set);
     			if (!$rec["valid"] || $rec["status"] != $a_status)
     			{
     				$save = true;
     			}*/
     if ($a_self_eval) {
         $ilDB->setLimit(1);
         $set = $ilDB->query("SELECT * FROM skl_user_skill_level WHERE " . "skill_id = " . $ilDB->quote($skill_id, "integer") . " AND " . "user_id = " . $ilDB->quote($a_user_id, "integer") . " AND " . "tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") . " AND " . "trigger_obj_id = " . $ilDB->quote($trigger_obj_id, "integer") . " AND " . "self_eval = " . $ilDB->quote($a_self_eval, "integer") . " ORDER BY status_date DESC");
         $rec = $ilDB->fetchAssoc($set);
         $status_day = substr($rec["status_date"], 0, 10);
         $today = substr(ilUtil::now(), 0, 10);
         if ($rec["valid"] && $rec["status"] == $a_status && $status_day == $today) {
             $update = true;
         }
     }
     if ($update) {
         $now = ilUtil::now();
         $ilDB->manipulate("UPDATE skl_user_skill_level SET " . " level_id = " . $ilDB->quote($a_level_id, "integer") . "," . " status_date = " . $ilDB->quote($now, "timestamp") . " WHERE user_id = " . $ilDB->quote($a_user_id, "integer") . " AND status_date = " . $ilDB->quote($rec["status_date"], "timestamp") . " AND skill_id = " . $ilDB->quote($rec["skill_id"], "integer") . " AND status = " . $ilDB->quote($a_status, "integer") . " AND trigger_obj_id = " . $ilDB->quote($trigger_obj_id, "integer") . " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") . " AND self_eval = " . $ilDB->quote($a_self_eval, "integer"));
     } else {
         $now = ilUtil::now();
         $ilDB->manipulate("INSERT INTO skl_user_skill_level " . "(level_id, user_id, tref_id, status_date, skill_id, status, valid, trigger_ref_id," . "trigger_obj_id, trigger_obj_type, trigger_title, self_eval) VALUES (" . $ilDB->quote($a_level_id, "integer") . "," . $ilDB->quote($a_user_id, "integer") . "," . $ilDB->quote((int) $a_tref_id, "integer") . "," . $ilDB->quote($now, "timestamp") . "," . $ilDB->quote($skill_id, "integer") . "," . $ilDB->quote($a_status, "integer") . "," . $ilDB->quote(1, "integer") . "," . $ilDB->quote($trigger_ref_id, "integer") . "," . $ilDB->quote($trigger_obj_id, "integer") . "," . $ilDB->quote($trigger_type, "text") . "," . $ilDB->quote($trigger_title, "text") . "," . $ilDB->quote($a_self_eval, "integer") . ")");
     }
     // fix (removed level_id and added skill id, since table should hold only
     // one entry per skill)
     $ilDB->manipulate("DELETE FROM skl_user_has_level WHERE " . " user_id = " . $ilDB->quote($a_user_id, "integer") . " AND skill_id = " . $ilDB->quote($skill_id, "integer") . " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") . " AND trigger_obj_id = " . $ilDB->quote($trigger_obj_id, "integer") . " AND self_eval = " . $ilDB->quote($a_self_eval, "integer"));
     if ($a_status == ilBasicSkill::ACHIEVED) {
         $ilDB->manipulate("INSERT INTO skl_user_has_level " . "(level_id, user_id, tref_id, status_date, skill_id, trigger_ref_id, trigger_obj_id, trigger_obj_type, trigger_title, self_eval) VALUES (" . $ilDB->quote($a_level_id, "integer") . "," . $ilDB->quote($a_user_id, "integer") . "," . $ilDB->quote($a_tref_id, "integer") . "," . $ilDB->quote($now, "timestamp") . "," . $ilDB->quote($skill_id, "integer") . "," . $ilDB->quote($trigger_ref_id, "integer") . "," . $ilDB->quote($trigger_obj_id, "integer") . "," . $ilDB->quote($trigger_type, "text") . "," . $ilDB->quote($trigger_title, "text") . "," . $ilDB->quote($a_self_eval, "integer") . ")");
     }
 }
 /**
  * copy all history entries for an object
  *
  * @param	integer $a_src_id		source object id
  * @param	integer $a_dst_id		destination object id
  * @return	boolean
  */
 function _copyEntriesForObject($a_src_id, $a_dst_id)
 {
     global $ilDB;
     $q = "SELECT * FROM history WHERE obj_id = " . $ilDB->quote($a_src_id, "integer");
     $r = $ilDB->query($q);
     while ($row = $ilDB->fetchObject($r)) {
         $id = $ilDB->nextId("history");
         $ilDB->insert("history", array("id" => array("integer", $id), "obj_id" => array("integer", $a_dst_id), "obj_type" => array("text", $row->obj_type), "action" => array("text", $row->action), "hdate" => array("timestamp", ilUtil::now()), "usr_id" => array("integer", $row->usr_id), "info_params" => array("text", $row->info_params), "user_comment" => array("clob", $row->user_comment)));
         /*
         			$q = "INSERT INTO history (obj_id, obj_type, action, hdate, usr_id, info_params, user_comment) VALUES ".
         				 "(".
         					$ilDB->quote($a_dst_id).", ".
         					$ilDB->quote($row->obj_type).", ".
         					$ilDB->quote($row->action).", ".
         					$ilDB->quote($row->hdate).", ".
         					$ilDB->quote($row->usr_id).", ".
         					$ilDB->quote($row->info_params).", ".
         					$ilDB->quote($row->user_comment).
         				 ")";
         
         			$ilDB->query($q);*/
     }
     return true;
 }
    /**
     * save the active module version to scorm_tracking
     */
    function save_module_version()
    {
        global $ilDB, $ilUser;
        $val_set = $ilDB->queryF('
			SELECT * FROM scorm_tracking 
			WHERE user_id =  %s
			AND sco_id = %s
			AND lvalue= %s
			AND obj_id = %s', array('integer', 'integer', 'text', 'integer'), array($ilUser->getId(), 0, 'module_version', $this->slm->getId()));
        if ($ilDB->numRows($val_set) > 0) {
            $ilDB->update('scorm_tracking', array('rvalue' => array('clob', $this->slm->getModuleVersion()), 'c_timestamp' => array('timestamp', ilUtil::now())), array('user_id' => array('integer', $ilUser->getId()), 'sco_id' => array('integer', 0), 'lvalue' => array('text', 'module_version'), 'obj_id' => array('integer', $this->slm->getId())));
        } else {
            $ilDB->insert('scorm_tracking', array('obj_id' => array('integer', $this->slm->getId()), 'user_id' => array('integer', $ilUser->getId()), 'sco_id' => array('integer', 0), 'lvalue' => array('text', 'module_version'), 'rvalue' => array('clob', $this->slm->getModuleVersion()), 'c_timestamp' => array('timestamp', ilUtil::now())));
        }
        include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
        ilLPStatusWrapper::_updateStatus($this->slm->getId(), $ilUser->getId());
    }
 /**
  * Write rendered content
  */
 function writeRenderedContent($a_content, $a_md5)
 {
     global $ilDB;
     $ilDB->update("page_object", array("rendered_content" => array("clob", $a_content), "render_md5" => array("text", $a_md5), "rendered_time" => array("timestamp", ilUtil::now())), array("page_id" => array("integer", $this->getId()), "parent_type" => array("text", $this->getParentType())));
     /*$st = $ilDB->prepareManip("UPDATE page_object ".
     			" SET rendered_content = ?, render_md5 = ?, rendered_time = now()".
     			" WHERE page_id = ?  AND parent_type = ?",
     			array("text", "text", "integer", "text"));
     		$r = $ilDB->execute($st,
     			array($a_content, $a_md5, $this->getId(), $this->getParentType()));*/
 }
 function updateNoticeForUser($a_ass_id, $a_user_id, $a_notice)
 {
     global $ilDB;
     $ilDB->manipulateF("UPDATE  rep_robj_xeph_ass_stat " . "SET notice = %s, status_time= %s " . " WHERE ass_id = %s AND user_id = %s AND " . $ilDB->equalsNot("notice", $a_notice, "text", true), array("text", "timestamp", "integer", "integer"), array($a_notice, ilUtil::now(), $a_ass_id, $a_user_id));
 }
 /**
  * inserts sequential learning module navigation
  * at template variable LMNAVIGATION_CONTENT
  */
 function ilLMNavigation()
 {
     global $ilUser;
     include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
     include_once "./Services/Accessibility/classes/class.ilAccessKeyGUI.php";
     $page_id = $this->getCurrentPageId();
     if (empty($page_id)) {
         return;
     }
     // process navigation for free page
     if (!$this->lm_tree->isInTree($page_id)) {
         if ($this->offlineMode() || $_GET["back_pg"] == "") {
             return;
         }
         $limpos = strpos($_GET["back_pg"], ":");
         if ($limpos > 0) {
             $back_pg = substr($_GET["back_pg"], 0, $limpos);
         } else {
             $back_pg = $_GET["back_pg"];
         }
         if (!$this->lm->cleanFrames()) {
             $back_href = $this->getLink($this->lm->getRefId(), "layout", $back_pg, $_GET["frame"], "", "reduce");
             $back_target = "";
         } else {
             $back_href = $this->getLink($this->lm->getRefId(), "layout", $back_pg, "", "", "reduce");
             $back_target = 'target="' . ilFrameTargetInfo::_getFrame("MainContent") . '" ';
         }
         $back_img = ilUtil::getImagePath("nav_arr2_L.png", false, "output", $this->offlineMode());
         $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
         $this->tpl->setVariable("IMG_PREV", $back_img);
         $this->tpl->setVariable("HREF_PREV", $back_href);
         $this->tpl->setVariable("FRAME_PREV", $back_target);
         $this->tpl->setVariable("TXT_PREV", $this->lng->txt("back"));
         $this->tpl->setVariable("ALT_PREV", $this->lng->txt("back"));
         $this->tpl->setVariable("PREV_ACC_KEY", ilAccessKeyGUI::getAttribute(ilAccessKey::PREVIOUS));
         $this->tpl->setVariable("SPACER_PREV", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
         $this->tpl->setVariable("IMG_PREV2", $back_img);
         $this->tpl->setVariable("HREF_PREV2", $back_href);
         $this->tpl->setVariable("FRAME_PREV2", $back_target);
         $this->tpl->setVariable("TXT_PREV2", $this->lng->txt("back"));
         $this->tpl->setVariable("ALT_PREV2", $this->lng->txt("back"));
         $this->tpl->setVariable("SPACER_PREV2", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->parseCurrentBlock();
         return;
     }
     // determine successor page_id
     $found = false;
     // empty chapter
     if ($this->chapter_has_no_active_page && ilLMObject::_lookupType($_GET["obj_id"]) == "st") {
         $c_id = $_GET["obj_id"];
     } else {
         if ($this->deactivated_page) {
             $c_id = $_GET["obj_id"];
         } else {
             $c_id = $page_id;
         }
     }
     while (!$found) {
         $succ_node = $this->lm_tree->fetchSuccessorNode($c_id, "pg");
         $c_id = $succ_node["obj_id"];
         $active = ilLMPage::_lookupActive($c_id, $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
         if ($succ_node["obj_id"] > 0 && ($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && ($this->lm->getPublicAccessMode() == "selected" && !ilLMObject::_isPagePublic($succ_node["obj_id"]))) {
             $found = false;
         } else {
             if ($succ_node["obj_id"] > 0 && !$active) {
                 // look, whether activation data should be shown
                 $act_data = ilLMPage::_lookupActivationData((int) $succ_node["obj_id"], $this->lm->getType());
                 if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
                     $found = true;
                 } else {
                     $found = false;
                 }
             } else {
                 $found = true;
             }
         }
     }
     $succ_str = $succ_node !== false ? " -> " . $succ_node["obj_id"] . "_" . $succ_node["type"] : "";
     // determine predecessor page id
     $found = false;
     if ($this->deactivated_page) {
         $c_id = $_GET["obj_id"];
     } else {
         $c_id = $page_id;
     }
     while (!$found) {
         $pre_node = $this->lm_tree->fetchPredecessorNode($c_id, "pg");
         $c_id = $pre_node["obj_id"];
         $active = ilLMPage::_lookupActive($c_id, $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
         if ($pre_node["obj_id"] > 0 && ($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && ($this->lm->getPublicAccessMode() == "selected" && !ilLMObject::_isPagePublic($pre_node["obj_id"]))) {
             $found = false;
         } else {
             if ($pre_node["obj_id"] > 0 && !$active) {
                 // look, whether activation data should be shown
                 $act_data = ilLMPage::_lookupActivationData((int) $pre_node["obj_id"], $this->lm->getType());
                 if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
                     $found = true;
                 } else {
                     $found = false;
                 }
             } else {
                 $found = true;
             }
         }
     }
     $pre_str = $pre_node !== false ? $pre_node["obj_id"] . "_" . $pre_node["type"] . " -> " : "";
     // determine target frame
     $framestr = !empty($_GET["frame"]) ? "frame=" . $_GET["frame"] . "&" : "";
     // Determine whether the view of a learning resource should
     // be shown in the frameset of ilias, or in a separate window.
     $showViewInFrameset = true;
     if ($pre_node != "") {
         // get presentation title
         $prev_title = ilLMPageObject::_getPresentationTitle($pre_node["obj_id"], $this->lm->getPageHeader(), $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), false, 0, $this->lang);
         $prev_title = ilUtil::shortenText($prev_title, 50, true);
         $prev_img = ilUtil::getImagePath("nav_arr_L.png", false, "output", $this->offlineMode());
         if (!$this->lm->cleanFrames()) {
             $prev_href = $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"], $_GET["frame"]);
             $prev_target = "";
         } else {
             if ($showViewInFrameset && !$this->offlineMode()) {
                 $prev_href = $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]);
                 $prev_target = 'target="' . ilFrameTargetInfo::_getFrame("MainContent") . '" ';
             } else {
                 $prev_href = $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]);
                 $prev_target = 'target="_top" ';
             }
         }
         if (($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && ($this->lm->getPublicAccessMode() == 'selected' && !ilLMObject::_isPagePublic($pre_node["obj_id"]))) {
             $output = $this->lng->txt("msg_page_not_public");
         }
         $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
         $this->tpl->setVariable("IMG_PREV", $prev_img);
         $this->tpl->setVariable("HREF_PREV", $prev_href);
         $this->tpl->setVariable("FRAME_PREV", $prev_target);
         $this->tpl->setVariable("TXT_PREV", $prev_title);
         $this->tpl->setVariable("ALT_PREV", $this->lng->txt("previous"));
         $this->tpl->setVariable("SPACER_PREV", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->setVariable("PREV_ACC_KEY", ilAccessKeyGUI::getAttribute(ilAccessKey::PREVIOUS));
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
         $this->tpl->setVariable("IMG_PREV2", $prev_img);
         $this->tpl->setVariable("HREF_PREV2", $prev_href);
         $this->tpl->setVariable("FRAME_PREV2", $prev_target);
         $this->tpl->setVariable("TXT_PREV2", $prev_title);
         $this->tpl->setVariable("ALT_PREV2", $this->lng->txt("previous"));
         $this->tpl->setVariable("SPACER_PREV2", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->parseCurrentBlock();
     }
     if ($succ_node != "") {
         // get presentation title
         $succ_title = ilLMPageObject::_getPresentationTitle($succ_node["obj_id"], $this->lm->getPageHeader(), $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), false, 0, $this->lang);
         $succ_title = ilUtil::shortenText($succ_title, 50, true);
         $succ_img = ilUtil::getImagePath("nav_arr_R.png", false, "output", $this->offlineMode());
         if (!$this->lm->cleanFrames()) {
             $succ_href = $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"], $_GET["frame"]);
             $succ_target = "";
         } else {
             if ($showViewInFrameset && !$this->offlineMode()) {
                 $succ_href = $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]);
                 $succ_target = ' target="' . ilFrameTargetInfo::_getFrame("MainContent") . '" ';
             } else {
                 $succ_href = $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]);
                 $succ_target = ' target="_top" ';
             }
         }
         if (($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && ($this->lm->getPublicAccessMode() == 'selected' && !ilLMObject::_isPagePublic($pre_node["obj_id"]))) {
             $output = $this->lng->txt("msg_page_not_public");
         }
         $this->tpl->setCurrentBlock("ilLMNavigation_Next");
         $this->tpl->setVariable("IMG_SUCC", $succ_img);
         $this->tpl->setVariable("HREF_SUCC", $succ_href);
         $this->tpl->setVariable("FRAME_SUCC", $succ_target);
         $this->tpl->setVariable("TXT_SUCC", $succ_title);
         $this->tpl->setVariable("ALT_SUCC", $this->lng->txt("next"));
         $this->tpl->setVariable("SPACER_SUCC", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->setVariable("NEXT_ACC_KEY", ilAccessKeyGUI::getAttribute(ilAccessKey::NEXT));
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock("ilLMNavigation_Next2");
         $this->tpl->setVariable("IMG_SUCC2", $succ_img);
         $this->tpl->setVariable("HREF_SUCC2", $succ_href);
         $this->tpl->setVariable("FRAME_SUCC2", $succ_target);
         $this->tpl->setVariable("TXT_SUCC2", $succ_title);
         $this->tpl->setVariable("ALT_SUCC2", $this->lng->txt("next"));
         $this->tpl->setVariable("SPACER_SUCC2", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->parseCurrentBlock();
         // check if successor page is not restricted
         if (!$this->offlineMode()) {
             if ($this->lm->getRestrictForwardNavigation()) {
                 if ($this->getTracker()->hasPredIncorrectAnswers($succ_node["obj_id"])) {
                     $this->tpl->addOnLoadCode("\$('.ilc_page_rnav_RightNavigation').addClass('ilNoDisplay');");
                 }
             }
         }
     }
 }
Example #27
0
 /**
  * Write rendered content
  */
 function writeRenderedContent($a_content, $a_md5)
 {
     global $ilDB;
     $ilDB->update("page_object", array("rendered_content" => array("clob", $a_content), "render_md5" => array("text", $a_md5), "rendered_time" => array("timestamp", ilUtil::now())), array("page_id" => array("integer", $this->getId()), "lang" => array("text", $this->getLanguage()), "parent_type" => array("text", $this->getParentType())));
 }
 /**
  * Save submitted file of user
  */
 function deliverFile($a_http_post_files, $a_ass_id, $user_id, $unzip = false)
 {
     global $ilDB;
     include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php";
     $storage = new ilFSStorageExercise($this->getId(), $a_ass_id);
     $deliver_result = $storage->deliverFile($a_http_post_files, $user_id, $unzip);
     //var_dump($deliver_result);
     if ($deliver_result) {
         $next_id = $ilDB->nextId("exc_returned");
         $query = sprintf("INSERT INTO exc_returned " . "(returned_id, obj_id, user_id, filename, filetitle, mimetype, ts, ass_id) " . "VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", $ilDB->quote($next_id, "integer"), $ilDB->quote($this->getId(), "integer"), $ilDB->quote($user_id, "integer"), $ilDB->quote($deliver_result["fullname"], "text"), $ilDB->quote($a_http_post_files["name"], "text"), $ilDB->quote($deliver_result["mimetype"], "text"), $ilDB->quote(ilUtil::now(), "timestamp"), $ilDB->quote($a_ass_id, "integer"));
         $ilDB->manipulate($query);
         // team upload?
         $user_ids = ilExAssignment::getTeamMembersByAssignmentId($a_ass_id, $user_id);
         if (!$user_ids) {
             $user_ids = array($user_id);
         } else {
             $team_id = ilExAssignment::getTeamIdByAssignment($a_ass_id, $user_id);
             ilExAssignment::writeTeamLog($team_id, ilExAssignment::TEAM_LOG_ADD_FILE, $a_http_post_files["name"]);
         }
         foreach ($user_ids as $user_id) {
             if (!$this->members_obj->isAssigned($user_id)) {
                 $this->members_obj->assignMember($user_id);
             }
             ilExAssignment::updateStatusReturnedForUser($a_ass_id, $user_id, 1);
             ilExerciseMembers::_writeReturned($this->getId(), $user_id, 1);
         }
     }
     return true;
 }
Example #29
0
$ilDB->renameTable('usr_new_account_mail', 'mail_template');
$ilDB->manipulate('ALTER TABLE mail_template DROP PRIMARY KEY');
$ilDB->addTableColumn("mail_template", "type", array("type" => "text", "length" => 4, "notnull" => true, 'default' => ''));
$ilDB->addPrimaryKey("mail_template", array("type", "lang"));
$ilDB->manipulate("UPDATE mail_template SET type = 'nacc'");
?>
<#2745>
<?php 
// media object and media pool settings
// register new object type 'mobs' for media pool and media object settings
$id = $ilDB->nextId("object_data");
$ilDB->manipulateF("INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " . "VALUES (%s, %s, %s, %s, %s, %s, %s)", array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"), array($id, "typ", "mobs", "Media Object/Pool settings", -1, ilUtil::now(), ilUtil::now()));
$typ_id = $id;
// create object data entry
$id = $ilDB->nextId("object_data");
$ilDB->manipulateF("INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " . "VALUES (%s, %s, %s, %s, %s, %s, %s)", array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"), array($id, "mobs", "__MediaObjectSettings", "Media Object/Pool Settings", -1, ilUtil::now(), ilUtil::now()));
// create object reference entry
$ref_id = $ilDB->nextId('object_reference');
$res = $ilDB->manipulateF("INSERT INTO object_reference (ref_id, obj_id) VALUES (%s, %s)", array("integer", "integer"), array($ref_id, $id));
// put in tree
$tree = new ilTree(ROOT_FOLDER_ID);
$tree->insertNode($ref_id, SYSTEM_FOLDER_ID);
// add rbac operations
// 1: edit_permissions, 2: visible, 3: read, 4:write
$ilDB->manipulateF("INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)", array("integer", "integer"), array($typ_id, 1));
$ilDB->manipulateF("INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)", array("integer", "integer"), array($typ_id, 2));
$ilDB->manipulateF("INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)", array("integer", "integer"), array($typ_id, 3));
$ilDB->manipulateF("INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)", array("integer", "integer"), array($typ_id, 4));
?>
<#2746>
<?php 
Example #30
0
 /**
  * Catches up with all write events which occured before the specified
  * timestamp.
  *
  * @param $obj_id int The object.
  * @param $usr_id int The user.
  * @param $timestamp SQL timestamp.
  */
 function _catchupWriteEvents($obj_id, $usr_id, $timestamp = null)
 {
     global $ilDB;
     $query = "SELECT obj_id FROM catch_write_events " . "WHERE obj_id = " . $ilDB->quote($obj_id, 'integer') . " " . "AND usr_id  = " . $ilDB->quote($usr_id, 'integer');
     $res = $ilDB->query($query);
     if ($res->numRows()) {
         $ts = $timestamp == null ? ilUtil::now() : $timestamp;
         /*			$query = "UPDATE catch_write_events ".
         				"SET ts = ".($timestamp == null ? $ilDB->now() : $ilDB->quote($timestamp, 'timestamp'))." ".
         				"WHERE usr_id = ".$ilDB->quote($usr_id ,'integer')." ".
         				"AND obj_id = ".$ilDB->quote($obj_id ,'integer');
         			$res = $ilDB->manipulate($query);*/
     } else {
         $ts = ilUtil::now();
         /*			$query = "INSERT INTO catch_write_events (ts,obj_id,usr_id) ".
         				"VALUES( ".
         				$ilDB->now().", ".
         				$ilDB->quote($obj_id,'integer').", ".
         				$ilDB->quote($usr_id,'integer')." ".
         				")";
         			$res = $ilDB->manipulate($query);*/
     }
     // alex, use replace due to bug #10406
     $ilDB->replace("catch_write_events", array("obj_id" => array("integer", $obj_id), "usr_id" => array("integer", $usr_id)), array("ts" => array("timestamp", $ts)));
 }