Exemplo n.º 1
0
 function init()
 {
     YuiLib::load(array('json' => 'json-min.js', 'container' => 'container_core-min.js', 'menu' => 'menu-min.js', 'button' => 'button-min.js', 'treeview' => 'treeview-min.js'), array('assets/skins/sam' => 'skin.css'));
     cout(Util::get_css('base-folder-tree.css'), 'page_head');
     cout(Util::get_js('appLms/lib/category/lib.categorytree.js'), 'page_head');
     Util::get_js(Get::rel_path('base') . '/lib/lib.elem_selector.js', true, true);
 }
 public function showTask()
 {
     if (!Get::cfg('enable_plugins', false)) {
         cout("Plugin feature disabled");
         return;
     }
     $model = new PluginAdm();
     $plugins = $model->getInstalledPlugins();
     $plugins_info = $model->getPluginsInfo($plugins);
     $active_tab = $_GET['active_tab'];
     $this->render('show', array('model' => $model, 'plugins' => $plugins, 'active_tab' => $active_tab, 'plugins_info' => $plugins_info));
 }
Exemplo n.º 3
0
    function play($object_link, $id_param)
    {
        //-kb-play-// if(!checkPerm('view', true, 'organization') && !checkPerm('view', true, 'storage')) die("You can't access");
        $lang =& DoceboLanguage::createInstance('link');
        $idCategory = $object_link->getId();
        $mode = importVar('mode', false, 'link');
        $back_coded = htmlentities(urlencode($object_link->back_url));
        require_once $GLOBALS['where_lms'] . '/lib/lib.param.php';
        $idReference = getLOParam($id_param, 'idReference');
        // NOTE: Track only if $idReference is present
        if ($idReference !== FALSE) {
            require_once $GLOBALS['where_lms'] . '/class.module/track.link.php';
            list($exist, $idTrack) = Track_Link::getIdTrack($idReference, getLogUserId(), $idCategory, TRUE);
            if ($exist) {
                $ti = new Track_Link($idTrack);
                $ti->setDate(date('Y-m-d H:i:s'));
                $ti->status = 'completed';
                $ti->update();
            } else {
                $ti = new Track_Link(false);
                $ti->createTrack($idReference, $idTrack, getLogUserId(), date('Y-m-d H:i:s'), 'completed', 'link');
            }
        }
        list($title) = sql_fetch_row(sql_query("\r\n\tSELECT title \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_link_cat \r\n\tWHERE idCategory = '" . (int) $idCategory . "'"));
        $link = 'index.php?modname=link&op=play&idCategory=' . $idCategory . '&id_param=' . $id_param . '&back_url=' . $back_coded;
        /*$GLOBALS['page']->add('<div id="top" class="std_block">'
        		.'<div class="colum_container">' */
        cout('<div id="top" class="yui-navset yui-navset-top tab_block">
		<ul class="yui-nav">
			<li class="first' . ($mode != 'keyw' ? ' selected' : '') . '">
				<a href="' . $link . '&amp;mode=list">
					<em>' . Lang::t('_SWITCH_TO_LIST', 'link') . '</em>
				</a>
			</li>
			<li' . ($mode == 'keyw' ? ' class="selected"' : '') . '>
				<a href="' . $link . '&amp;mode=keyw">
					<em>' . Lang::t('_SWITCH_TO_KEYWORD', 'link') . '</em>
				</a>
			</li>
		</ul>
		<div class="yui-content">', 'content');
        cout(getBackUi(Util::str_replace_once('&', '&amp;', $object_link->back_url), $lang->def('_BACK')), 'content');
        $GLOBALS['page']->add('<b>' . $lang->def('_TITLE') . ' : ' . $title . '</b><br /><br />' . $lang->def('_LINKIUNNEWWINDOW') . '<br /><br />', 'content');
        if ($mode == 'keyw') {
            displayAsKey($idCategory, $link . '&amp;mode=keyw');
        } else {
            displayAsList($idCategory);
        }
        $GLOBALS['page']->add('<div class="align_center">' . '<a href="#top"><img src="' . getPathImage() . 'standard/up.png" title="' . $lang->def('_BACKTOTOP') . '" />' . $lang->def('_BACKTOTOP') . '</a>' . getBackUi(Util::str_replace_once('&', '&amp;', $object_link->back_url), $lang->def('_BACK')) . '</div>', 'content');
        cout('</div></div>', 'content');
    }
Exemplo n.º 4
0
function reportList()
{
    checkPerm('view');
    require_once _base_ . '/lib/lib.table.php';
    $lang =& DoceboLanguage::createInstance('report', 'framework');
    $_SESSION['report_tempdata'] = array();
    $can_mod = checkPerm('mod', true);
    $acl_man = Docebo::aclm();
    $public_admin_mod = true;
    $query = "SELECT t1.*, t2.userid \r\n\tFROM %lms_report_filter as t1 \r\n\t\tLEFT JOIN %adm_user as t2 ON t1.author=t2.idst\r\n\tWHERE t1.is_public = 1 OR t1.author = " . Docebo::user()->getId();
    $tb = new Table();
    $tb->initNavBar('ini', 'button');
    $col_type = array('', 'align_center', 'align_center', 'image');
    $col_content = array($lang->def('_NAME'), $lang->def('_TAB_REP_CREATOR', 'report', 'framework'), $lang->def('_CREATION_DATE'), '<img src="' . getPathImage() . 'standard/view.png" alt="' . $lang->def('REPORT_SHOW_RESULTS') . '" title="' . $lang->def('REPORT_SHOW_RESULTS') . '" />');
    if ($public_admin_mod && $can_mod) {
        $col_type[] = 'image';
        $col_content[] = '<img src="' . getPathImage() . 'standard/edit.png"  alt="' . $lang->def('_MOD') . '" title="' . $lang->def('_MOD') . '"/>';
        $col_type[] = 'image';
        $col_content[] = '<img src="' . getPathImage() . 'standard/delete.png"  alt="' . $lang->def('_DEL') . '" title="' . $lang->def('_DEL') . '"/>';
    }
    $tb->setColsStyle($col_type);
    $tb->addHead($col_content);
    $res = sql_query($query);
    if ($res) {
        while ($row = sql_fetch_assoc($res)) {
            $id = $row['id_filter'];
            $opn_link = '<a href="index.php?modname=public_report_admin&amp;op=view_report&amp;idrep=' . $id . '" ' . ' title="' . $lang->def('REPORT_SHOW_RESULTS', 'report', 'framework') . '">' . '<img src="' . getPathImage() . 'standard/view.png" alt="' . $lang->def('REPORT_SHOW_RESULTS', 'report', 'framework') . '" />' . '</a>';
            $tb_content = array($row['author'] == 0 ? $lang->def($row['filter_name']) : $row['filter_name'], $row['author'] == 0 ? '<div class="align_center">-</div>' : $acl_man->relativeId($row['userid']), Format::date($row['creation_date']), $opn_link);
            if ($public_admin_mod && $can_mod) {
                if ($row['author'] == Docebo::user()->getId()) {
                    $tb_content[] = '<a href="index.php?modname=public_report_admin&amp;op=modify_name&amp;modid=' . $id . '" ' . ' title="' . $lang->def('_MOD', 'report', 'framework') . '">' . '<img src="' . getPathImage() . 'standard/edit.png" alt="' . $lang->def('_MOD', 'report', 'framework') . '" />' . '</a>';
                } else {
                    $tb_content[] = '';
                }
                if ($row['author'] == Docebo::user()->getId()) {
                    $tb_content[] = '<a href="index.php?modname=public_report_admin&amp;op=del_public_report&amp;idrep=' . $id . '" ' . ' title="' . $lang->def('_DEL', 'report', 'framework') . '">' . '<img src="' . getPathImage() . 'standard/delete.png" alt="' . $lang->def('_DEL', 'report', 'framework') . '" />' . '</a>';
                } else {
                    $tb_content[] = '';
                }
            }
            $tb->addBody($tb_content);
        }
    }
    require_once _base_ . '/lib/lib.dialog.php';
    setupHrefDialogBox('a[href*=del_public_report]');
    if ($public_admin_mod && $can_mod) {
        $tb->addActionAdd('<a href="index.php?modname=public_report_admin&amp;op=create_name">' . '<img src="' . getPathImage() . 'standard/add.png" title="' . $lang->def('_NEW') . '" /> ' . $lang->def('_NEW') . '</a>');
    }
    cout(getTitleArea($lang->def('_REPORT')) . '<div class="std_block">' . $tb->getTable() . '</div>', 'content');
}
Exemplo n.º 5
0
function mycompetences(&$url)
{
    checkPerm('view');
    $html = "";
    $html .= getTitleArea(Lang::t('_COMPETENCES'), 'competences');
    $html .= '<div class="std_block">';
    $cmodel = new CompetencesAdm();
    $fmodel = new FunctionalrolesAdm();
    $id_user = getLogUserId();
    $ucomps = $cmodel->getUserCompetences($id_user);
    $rcomps = $fmodel->getUserRequiredCompetences($id_user);
    $ucomps_info = $cmodel->getCompetencesInfo(array_keys($ucomps));
    $language = getLanguage();
    $_typologies = $cmodel->getCompetenceTypologies();
    $_types = $cmodel->getCompetenceTypes();
    $icon_actv = '<span class="ico-sprite subs_actv"><span>' . Lang::t('_COMPETENCE_OBTAINED', 'competences') . '</span></span>';
    $icon_req = '<span class="ico-sprite subs_actv"><span>' . Lang::t('_MANDATORY', 'competences') . '</span></span>';
    //*******************
    require_once _base_ . '/lib/lib.table.php';
    $table = new Table(Get::sett('visuItem'), Lang::t('_COMPETENCES'), Lang::t('_COMPETENCES'));
    $style_h = array('', '', 'image', 'image', 'image', 'image', 'image');
    $label_h = array(Lang::t('_NAME', 'competences'), Lang::t('_TYPOLOGY', 'competences'), Lang::t('_TYPE', 'standard'), Lang::t('_SCORE', 'competences'), Lang::t('_DATE_LAST_COMPLETE', 'subscribe'), Lang::t('_COMPETENCES_REQUIRED', 'competences'));
    $table->addHead($label_h, $style_h);
    foreach ($ucomps_info as $id_competence => $cinfo) {
        $line = array();
        $line[] = $cinfo->langs[$language]['name'];
        $line[] = $_typologies[$cinfo->typology];
        $line[] = $_types[$cinfo->type];
        $line[] = $cinfo->type == 'score' ? '<b>' . $ucomps[$id_competence]->score_got . '</b>' : $icon_actv;
        $line[] = Format::date($ucomps[$id_competence]->last_assign_date, 'datetime');
        $line[] = array_key_exists($id_competence, $rcomps) ? $icon_req : '';
        $table->addBody($line);
    }
    $html .= $table->getTable();
    $html .= '</div>';
    $html .= Form::openForm('beck_url', 'index.php');
    $html .= Form::openButtonSpace();
    $html .= Form::getButton('close', 'close', Lang::t('_CLOSE', 'standard'));
    $html .= Form::closeButtonSpace();
    $html .= Form::closeform();
    cout($html, 'content');
}
Exemplo n.º 6
0
 /**
  * Display the user/group/orgchart/fncrole selector
  * @param string $url the url of the page, used for the form
  * @param string $title the main title for the page (will be passed to a getTitleArea function
  * @param string $text extra text to display
  * @param bool $selector_mode if true the main div and page title will be drawed by the selector
  * @param string $id the id for the form that will contain the selector
  */
 public function loadSelector($url, $title = false, $text = '', $selector_mode = TRUE, $id = FALSE)
 {
     $res = '';
     $id = empty($id) ? 'main_selector' : $id;
     $us_util = new UserSelectorUtil();
     if ($selector_mode && $title != false) {
         $res .= getTitleArea($title);
         $res .= '<div class="std_block">';
     }
     $res .= Form::openForm($id . '_form', $url);
     if (is_array($this->_extra_form) && !empty($this->_extra_form)) {
         $res .= implode("\n", $this->_extra_form);
     }
     $res .= Util::widget('userselector', array('id' => $id, 'show_user_selector' => $this->show_user_selector, 'show_group_selector' => $this->show_group_selector, 'show_orgchart_selector' => $this->show_orgchart_selector, 'show_fncrole_selector' => $this->show_fncrole_selector, 'initial_selection' => $this->selection, 'admin_filter' => true, 'learning_filter' => $this->learning_filter, 'use_suspended' => $this->use_suspended, 'nFields' => $this->nFields !== FALSE ? $this->nFields : 3), true);
     $res .= Form::openButtonSpace();
     $res .= Form::getButton('okselector', 'okselector', Lang::t('_SAVE', 'standard'));
     $res .= Form::getButton('cancelselector', 'cancelselector', Lang::t('_UNDO', 'standard'));
     $res .= Form::closeButtonSpace();
     $res .= Form::closeForm();
     if ($selector_mode) {
         $res .= '</div>';
     }
     cout($res, 'content');
 }
Exemplo n.º 7
0
function getHistoryTable($id_user, $id_org, $idscorm_item, $idReference)
{
    require_once _base_ . '/lib/lib.table.php';
    $tb = new Table(Get::sett('visu_course'));
    $lang = DoceboLanguage::CreateInstance('organization', 'lms');
    $h_type = array('', '', '', '', '');
    $h_content = array($lang->def('_ATTEMPT'), $lang->def('_STATUS'), $lang->def('_SCORE'), $lang->def('_DATE'), $lang->def('_TIME'));
    $tb->setColsStyle($h_type);
    $tb->addHead($h_content);
    $qry = "SELECT t1.* FROM " . $GLOBALS['prefix_lms'] . "_scorm_tracking_history as t1 JOIN " . $GLOBALS['prefix_lms'] . "_scorm_tracking as t2 ON (t1.idscorm_tracking=t2.idscorm_tracking) " . " WHERE t2.idscorm_item={$idscorm_item} AND t2.idUser={$id_user} " . " ORDER BY t1.date_action ASC ";
    $res = sql_query($qry);
    $i = 1;
    while ($row = mysql_fetch_assoc($res)) {
        $line = array();
        $line[] = $lang->def('_ATTEMPT') . ' ' . $i;
        $line[] = $row['lesson_status'];
        $line[] = $row['score_raw'];
        $line[] = Format::date($row['date_action']);
        $line[] = decodeSessionTime($row['session_time']);
        $tb->addBody($line);
        $i++;
    }
    //title
    cout($tb->getTable(), 'content');
}
Exemplo n.º 8
0
function handleCreateStore()
{
    $useremail = $_SESSION['email'];
    $storelocation = $_POST['storelocation'];
    $storename = $_POST['storename'];
    cout("<br> username :"******"storeloaction :" . $storelocation);
    cout("storename\t:" . $storename);
    dbConnect("endurance");
    $sql = "INSERT INTO storeslist (storeid, storelocation, storename, username) VALUES ('','" . $storelocation . "' , '" . $storename . "' , '" . $useremail . "' )";
    $result = mysql_query($sql);
    if (!$result) {
        echo "<b>Error </b>" . mysql_error();
        //cout("database error") ; //echo "<br> database error";
    } else {
        cout("Last generated row id" + mysql_insert_id());
        $storeID = mysql_insert_id();
        //Create a new table with this name
        //All the devices should point to this table
        dbConnect("endurance");
        $storeID = (string) $storeID;
        $storeIDinValidFormat = "Z" . $storeID . "Z";
        //$sql = "CREATE TABLE IF NOT EXISTS '".$storeID."' ()                  ";
        //$sql = "CREATE TABLE ". $storeIDinValidFormat. " ( first_name VARCHAR(25), last_name VARCHAR(25), phone_number VARCHAR(15)) ENGINE=InnoDB DEFAULT CHARSET=latin1";
        $sql = "CREATE TABLE IF NOT EXISTS " . $storeIDinValidFormat . " (\r\n\t\tslno int(11) NOT NULL,\r\n\t\tbarcode varchar(255) NOT NULL,\r\n\t\tproductcategory varchar(100) NOT NULL,\r\n\t\tproductname varchar(100) NOT NULL,\r\n\t\tbuyprice int(11) NOT NULL,\r\n\t\tsellprice int(11) NOT NULL,\r\n\t\ttaxcategory int(11) NOT NULL,\r\n\t\tquantityadded int(11) NOT NULL,\r\n\t\tquantityremaining int(11) NOT NULL,\r\n\t\treferencecode int(11) NOT NULL ,\r\n\t\tPRIMARY KEY (slno) \r\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1";
        $result = mysql_query($sql);
        if (!$result) {
            echo "<b>Error </b>" . mysql_error();
        } else {
            echo "<br>Success Creating new Store table";
        }
    }
}
Exemplo n.º 9
0
    public function get($noPrint = true)
    {
        $js_code = '';
        if ($this->jsClassName != '') {
            $jsOptions = $this->_getJsOptions();
            $treeName = 'tree_' . $this->id;
            if ($this->isGlobalVariable) {
                $js_code = 'var ' . $treeName . ';';
            } else {
                $js_code = '';
            }
            $js_code .= ($this->useDOMReady ? 'YAHOO.util.Event.onDOMReady(function(e){' : '') . '
				' . ($this->isGlobalVariable ? '' : 'var ') . $treeName . ' = new ' . $this->jsClassName . '("' . $this->id . '"' . ($jsOptions != '' ? ', ' . $jsOptions : '') . ');
				' . ($this->useDOMReady ? '});' : '');
        }
        $output = array('js' => '<script type="text/javascript">' . $js_code . '</script>', 'html' => '<div class="folder_tree" id="' . $this->id . '">' . $this->_getHtml() . '</div>', 'options' => $jsOptions);
        if ($noPrint) {
            return $output;
        } else {
            cout($output['js'], 'page_head');
            cout($output['html'], 'content');
        }
    }
Exemplo n.º 10
0
function showLog()
{
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.table.php';
    $lang =& DoceboLanguage::createInstance('conference', 'lms');
    $id = Get::req('id', DOTY_INT, 0);
    $conference = new Conference_Manager();
    $room_info = $conference->roomInfo($id);
    $acl_man =& Docebo::user()->getAclManager();
    cout(getTitleArea('') . '<div class="std_block">', 'content');
    $room_log = array();
    switch ($room_info['room_type']) {
        case 'teleskill':
            require_once $GLOBALS['where_scs'] . '/lib/lib.teleskill.php';
            $teleskill = new Teleskill_Management();
            $roomid = $teleskill->getRoomId($id);
            if (isset($_POST['update_log'])) {
                $teleskill->updateRoomLog($roomid);
            }
            $room_log = $teleskill->getRoomLog($roomid);
            break;
    }
    $tb = new Table(0, $lang->def('_ROOM_LOG'), $lang->def('_ROOM_LOG'));
    $cont_h = array($lang->def('_FULLNAME'), $lang->def('_ROLE'), $lang->def('_DATE'), $lang->def('_TOTAL_TIME'), $lang->def('_NUMBER_OF_ACCESS'));
    $type_h = array('', '', '', '', '');
    $tb->setColsStyle($type_h);
    $tb->addHead($cont_h);
    foreach ($room_log as $log_row) {
        $user_info = $acl_man->getUser($log_row['idUser'], false);
        $cont = array();
        if ($user_info[ACL_INFO_FIRSTNAME] !== '' && $user_info[ACL_INFO_LASTNAME]) {
            $cont[] = $user_info[ACL_INFO_FIRSTNAME] . ' ' . $user_info[ACL_INFO_LASTNAME] . ' (' . $acl_man->relativeId($user_info[ACL_INFO_USERID]) . ')';
        } elseif ($user_info[ACL_INFO_FIRSTNAME] !== '') {
            $cont[] = $user_info[ACL_INFO_FIRSTNAME] . ' (' . $acl_man->relativeId($user_info[ACL_INFO_USERID]) . ')';
        } elseif ($user_info[ACL_INFO_LASTNAME] !== '') {
            $cont[] = $user_info[ACL_INFO_LASTNAME] . ' (' . $acl_man->relativeId($user_info[ACL_INFO_USERID]) . ')';
        } else {
            $cont[] = $acl_man->relativeId($user_info[ACL_INFO_USERID]);
        }
        $cont[] = $log_row['role'] == 1 ? $lang->def('_USER_ROLE') : $lang->def('_TUTOR_ROLE');
        $cont[] = Format::date($log_row['date'], 'datetime');
        $duration_s = 0;
        $duration_m = 0;
        $duration_h = 0;
        $duration = $log_row['duration'];
        $duration_s = $duration % 60;
        $duration -= $duration_s;
        if ($duration) {
            $duration_m = $duration % 3600 / 60;
            $duration -= $duration_m * 60;
            if ($duration) {
                $duration_h = $duration / 3600;
            }
        }
        $cont[] = $duration_h . ' ' . $lang->def('_HOURS') . ' ' . $duration_m . ' ' . $lang->def('_MINUTS') . ' ' . $duration_s . ' ' . $lang->def('_SECONDS');
        $cont[] = $log_row['access'];
        $tb->addBody($cont);
    }
    $tb->addActionAdd(Form::getButton('update_log', 'update_log', $lang->def('_UPDATE_LOG')));
    cout(Form::openForm('log_table', 'index.php?modname=conference&amp;op=log&amp;id=' . $id) . $tb->getTable() . Form::closeForm() . '<br/>' . getBackUi('index.php?modname=conference&amp;op=history', $lang->def('_BACK')), 'content');
    cout('</div>', 'content');
}
Exemplo n.º 11
0
                // They're either tweeting to me for shits and giggles or playing.
                // In either scenario, just play the game.
                // Clean their post and submit their guess.
                $tweetman->guess(substr($message, 0, 1));
                // Check if they found the word or failed.
                $game = $tweetman->isGameOver();
                if (!$game['status']) {
                    // debug:
                    cout("{$user}: {$game['remaining']} left\r\n");
                    //$lettersRemaining = insertSpaces($tweetman->getRemainingLetters());
                    $strReplyText = "@{$user} {$game['remaining']} attempts left.  \r\n";
                    //  Remaining characters: {$lettersRemaining}";
                    $strReplyText .= $game['message'] != 'You lose.' ? insertSpaces($game['message']) : $game['message'];
                    $twitter->postStatus($strReplyText, $tweet->id_str);
                } else {
                    //debug:
                    cout("{$user} won!\r\n\t{$game['message']}\r\n--------------------\r\n");
                    $twitter->postStatus("@{$user} {$game['message']}", $tweet->id_str);
                }
                break;
        }
    }
    endMain:
    // debug:
    cout("sleeping...\r\n\r\n");
    // Twitter REST API has maximum of 150 requests/IP per hour.
    // This must run at 25 second intervals or longer.
    sleep(25);
    // Don't run this forever!
}
fclose($fp);
Exemplo n.º 12
0
function schedule_set($idrep)
{
    checkPerm('mod');
    $lang =& DoceboLanguage::createInstance('report', 'framework');
    //initialize session data for schedulation, if not updating
    if (!isset($_SESSION['schedule_tempdata'])) {
        $_SESSION['schedule_tempdata'] = array('name' => '', 'period' => 'day', 'period_info' => '', 'time' => '', 'recipients' => array());
    }
    $ref =& $_SESSION['schedule_tempdata'];
    require_once _base_ . '/lib/lib.form.php';
    $jump_url = 'index.php?modname=report&op=report_schedule&idrep=' . $idrep;
    $back_url = 'index.php?modname=report&op=schedulelist&idrep=' . $idrep;
    $body = Form::openForm('report_schedule_time', $jump_url);
    $body .= Form::getTextfield($lang->def('_SAVE_SCHED_NAME'), 'sched_name', 'sched_name', '200', $ref['name']) . Form::getHidden('next_step', 'next_step', 'sched_setrecipients');
    //create selections for crontab specification
    $month_days = array();
    for ($i = 1; $i <= 31; $i++) {
        $month_days[$i] = $i;
        //TO DO : format with 2 digits filling with 0
    }
    $year_months = array();
    for ($i = 1; $i <= 12; $i++) {
        $year_months[$i] = $i;
        //TO DO : format with 2 digits filling with 0
    }
    $lang_days =& DoceboLanguage::createInstance('calendar', 'lms');
    $week_days = array('0' => $lang_days->def('_MONDAY'), '1' => $lang_days->def('_TUESDAY'), '2' => $lang_days->def('_WEDNESDAY'), '3' => $lang_days->def('_THURSDAY'), '4' => $lang_days->def('_FRIDAY'), '5' => $lang_days->def('_SATURDAY'), '6' => $lang_days->def('_SUNDAY'));
    $body .= Form::getRadio($lang->def('_REPORT_DAILY'), 'cron_radio_1', 'cron_radio', 'day', $ref['period'] == 'day' ? true : false) . '<div class="form_line_l">' . Form::getInputRadio('cron_radio_2', 'cron_radio', 'week', $ref['period'] == 'week' ? true : false, '') . ' <label class="label_normal" for="cron_radio_2">' . $lang->def('_REPORT_WEEKLY') . '</label> ' . Form::getInputDropdown('', 'cron_weekly', 'cron_weekly', $week_days, $ref['period'] == 'week' ? $ref['period_info'] : '', '') . '</div>' . '<div class="form_line_l">' . Form::getInputRadio('cron_radio_3', 'cron_radio', 'month', $ref['period'] == 'month' ? true : false, '') . ' <label class="label_normal" for="cron_radio_3">' . $lang->def('_REPORT_MONTHLY') . '</label> ' . Form::getInputDropdown('', 'cron_monthly', 'cron_monthly', $month_days, $ref['period'] == 'month' ? $ref['period_info'] : '', '') . '</div>' . Form::getHidden('idrep', 'idrep', $idrep);
    $body .= Form::openButtonSpace() . Form::getButton('', 'schedule_confirm', $lang->def('_NEXT')) . Form::getButton('', 'schedule_undo', $lang->def('_UNDO')) . form::closeButtonSpace();
    $body .= Form::closeForm();
    //output content
    cout(getTitleArea($lang->def('_SCHEDULE')));
    cout('<div class="std_block">');
    cout($body);
    cout('</div>');
    //close std_block div
}
Exemplo n.º 13
0
function modTransaction()
{
    require_once _base_ . '/lib/lib.table.php';
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.dialog.php';
    require_once _lms_ . '/lib/lib.course.php';
    require_once _lms_ . '/lib/lib.date.php';
    $lang =& DoceboLanguage::createInstance('transaction');
    $acl_man = Docebo::user()->getAclManager();
    $man_transaction = new Man_Transaction();
    $course_man = new Man_Course();
    $date_man = new DateManager();
    $id_transaction = Get::req('id', DOTY_INT, 0);
    $transaction_info = $man_transaction->getTransactionInfo($id_transaction);
    if (isset($_POST['update'])) {
        $payment_status = Get::req('payment_status', DOTY_INT, 0);
        $course_status = Get::req('course_status', DOTY_INT, 0);
        $note = Get::req('note', DOTY_MIXED, '');
        if ($man_transaction->updateTransaction($id_transaction, $payment_status, $course_status, $note)) {
            if (isset($_POST['confirm'])) {
                $activations = array();
                foreach ($_POST['confirm'] as $id => $n) {
                    list($id_course, $id_date) = explode('_', $id);
                    if ($id_date != 0) {
                        $activations[$id_course]['dates'][$id_date] = $id_date;
                    } else {
                        $activations[$id_course] = $id_course;
                    }
                }
                if ($man_transaction->activateCourses($id_transaction, $transaction_info['id_user'], $activations)) {
                    Util::jump_to('index.php?modname=transaction&op=transaction&res=ok');
                }
            } else {
                Util::jump_to('index.php?modname=transaction&op=transaction&res=ok');
            }
        }
        Util::jump_to('index.php?modname=transaction&op=transaction&res=err_up');
    }
    $array_title = array('index.php?modname=transaction&amp;op=transaction' => $lang->def('_TRANSACTION'), $lang->def('_MOD_TRANSACTION'));
    //Status info & note
    $array_payment_status = array('-1' => $lang->def('_CANCELLED'), '0' => $lang->def('_WAITING_PAYMENT'), '1' => $lang->def('_PARTIAL_PAID'), '2' => $lang->def('_PAID'));
    $array_course_status = array('-1' => $lang->def('_CANCELLED'), '0' => $lang->def('_NO_COURSE_ACTIVATED'), '1' => $lang->def('_SOME_COURSE_ACTIVATED'), '2' => $lang->def('_ALL_COURSE_ACTIVATED'));
    cout(getTitleArea($array_title) . '<div class="std_block">' . Form::openForm('transaction_info', 'index.php?modname=transaction&amp;op=mod&amp;id=' . $id_transaction) . Form::openElementSpace() . Form::getDropdown($lang->def('_PAYMENT_STATUS_FILTER'), 'payment_status', 'payment_status', $array_payment_status, $transaction_info['payment_status']) . Form::getDropdown($lang->def('_COURSE_STATUS_FILTER'), 'course_status', 'course_status', $array_course_status, $transaction_info['course_status']) . Form::getSimpleTextarea($lang->def('_NOTES'), 'note', 'note', $transaction_info['note']) . Form::closeElementSpace());
    //User info
    $user_info = $acl_man->getUser($transaction_info['id_user'], false);
    $tb_user = new Table(0, $lang->def('_USER_INFO'), $lang->def('_USER_INFO'));
    $cont_h = array($lang->def('_USERNAME'), $lang->def('_FIRSTNAME'), $lang->def('_LASTNAME'), $lang->def('_EMAIL'));
    $type_h = array('', '', '', '');
    $tb_user->setColsStyle($type_h);
    $tb_user->addHead($cont_h);
    $tb_user->addBody(array($acl_man->relativeId($user_info[ACL_INFO_USERID]), $user_info[ACL_INFO_FIRSTNAME], $user_info[ACL_INFO_LASTNAME], $user_info[ACL_INFO_EMAIL]));
    cout('<br />' . $tb_user->getTable());
    //Payment info if we need it
    //Product info
    $tb_product = new Table(0, $lang->def('_PRODUCT_INFO'), $lang->def('_PRODUCT_INFO'));
    $cont_h = array($lang->def('_CODE'), $lang->def('_NAME'), $lang->def('_DATE_BEGIN'), $lang->def('_DATE_END'), $lang->def('_COURSE_PRIZE'), $lang->def('_CONFIRM_COURSE'));
    $type_h = array('', '', '', '', '', '');
    $tb_product->setColsStyle($type_h);
    $tb_product->addHead($cont_h);
    $transaction_course = $man_transaction->getTransactionCourses($id_transaction);
    foreach ($transaction_course as $id_course => $details) {
        if (is_array($details)) {
            foreach ($details['dates'] as $id_date) {
                $date_info = $date_man->getDateInfo($id_date);
                $checked = false;
                $other = '';
                if ($man_transaction->controlActivation($id_transaction, $id_course, $id_date)) {
                    $checked = true;
                    $other = 'disabled="disabled"';
                }
                $tb_product->addBody(array($date_info['code'], $date_info['name'], Format::date($date_info['date_begin']), Format::date($date_info['date_end']), $date_info['price'], Form::getInputCheckbox($id_course . '_' . $id_date, 'confirm[' . $id_course . '_' . $id_date . ']', 1, $checked, $other)));
            }
        } else {
            $course_info = $course_man->getCourseInfo($id_course);
            $checked = false;
            $other = '';
            if ($man_transaction->controlActivation($id_transaction, $id_course)) {
                $checked = true;
                $other = 'disabled="disabled"';
            }
            $tb_product->addBody(array($course_info['code'], $course_info['name'], $course_info['date_begin'] !== '0000-00-00' ? Format::date($course_info['date_begin'], 'date') . ($course_info['hour_begin'] !== '-1' ? $course_info['hour_begin'] : '') : '', $course_info['date_end'] !== '0000-00-00' ? Format::date($course_info['date_end'], 'date') . ($course_info['hour_end'] !== '-1' ? $course_info['hour_end'] : '') : '', $course_info['prize'] == '' ? '0' : $course_info['prize'], Form::getInputCheckbox($id_course . '_0', 'confirm[' . $id_course . '_0]', 1, $checked, $other)));
        }
    }
    cout('<br />' . $tb_product->getTable() . Form::openButtonSpace() . Form::getButton('update', 'update', $lang->def('_UPDATE')) . Form::getButton('back_mod', 'back_mod', $lang->def('_BACK')) . Form::closeButtonSpace() . Form::closeForm());
    cout('</div>');
}
Exemplo n.º 14
0
    /**
     * public static function getButton( $id, $name, $value, $css_class )
     *
     * @param string $id 			the id of the submit button
     * @param string $name 			the name of the submit button
     * @param string $value 		the value of the submit button
     * @param string $css_button 	optional css class for the button
     * @param string $other_param 	other element for the tag
     *
     * @return string contains the close tag for button element
     */
    public static function getButton($id, $name, $value, $css_button = FALSE, $other_param = '', $use_js = true, $is_submit = true)
    {
        if ($use_js && ($css_button == false || $css_button == 'yui-button')) {
            if (!defined("IS_AJAX")) {
                cout('<script type="text/javascript">
					(function() {
						YAHOO.util.Event.onDOMReady(function() {
							var o = YAHOO.namespace("buttonObjects.' . $id . '");
							YAHOO.buttonObjects.' . $id . ' = new YAHOO.widget.Button("' . $id . '", { value: "' . addslashes($value) . '" });
						});
					})();
					</script>', 'scripts');
            }
            return '<input type="' . ($is_submit ? 'submit' : 'button') . '" id="' . $id . '" ' . ($name ? 'name="' . $name . '" ' : '') . 'value="' . $value . '"' . ($other_param != '' ? ' ' . $other_param : '') . ' />';
        }
        if ($css_button == 'yui-button') {
            return '<span id="' . $id . '_span" class="yui-button yui-submit-button">' . '<span class="first-child">' . '<input type="' . ($is_submit ? 'submit' : 'button') . '" id="' . $id . '" ' . ($name ? 'name="' . $name . '" ' : '') . 'value="' . $value . '"' . ($other_param != '' ? ' ' . $other_param : '') . ' />' . '</span>' . '</span>';
        }
        $css_button = $css_button === FALSE ? 'button' : $css_button;
        return '<input type="' . ($is_submit ? 'submit' : 'button') . '" ' . "\n\t" . 'class="' . $css_button . '" ' . "\n\t" . 'id="' . $id . '" ' . "\n\t" . 'name="' . $name . '" ' . "\n\t" . 'value="' . $value . '"' . ($other_param != '' ? ' ' . $other_param : '') . ' />';
    }
Exemplo n.º 15
0
function showchart()
{
    require_once _lms_ . '/modules/test/charts.test.php';
    $idTest = Get::req('id_test', DOTY_INT, -1);
    $idUser = Get::req('id_user', DOTY_INT, -1);
    $chartType = Get::req('chart_type', DOTY_STRING, 'column');
    $lang =& DoceboLanguage::createInstance('coursereport', 'lms');
    $acl_man = Docebo::user()->getAclManager();
    $user_info = $acl_man->getUser($idUser, false);
    list($title) = sql_fetch_row(sql_query("SELECT title FROM " . $GLOBALS['prefix_lms'] . "_test WHERE idTest=" . (int) $idTest));
    $backUrl = 'index.php?modname=coursereport&op=testvote&id_test=' . (int) $idTest;
    $backUi = getBackUi($backUrl, $lang->def('_BACK'));
    $page_title = array('index.php?modname=coursereport&amp;op=coursereport' => $lang->def('_COURSEREPORT', 'menu_course'), $backUrl => strip_tags($title), $acl_man->relativeId($user_info[ACL_INFO_USERID]));
    cout(getTitleArea($page_title, 'coursereport', $lang->def('_TH_ALT')));
    cout('<div class="stdblock">');
    cout($backUi);
    cout('<div><h2>' . $lang->def('_USER_DETAILS') . '</h2>');
    cout('<div class="form_line_l"><p><label class="floating">' . $lang->def('_USERNAME') . ':&nbsp;</label></p>' . $acl_man->relativeId($user_info[ACL_INFO_USERID]) . '</div>');
    cout('<div class="form_line_l"><p><label class="floating">' . $lang->def('_LASTNAME') . ':&nbsp;</label></p>' . $user_info[ACL_INFO_LASTNAME] . '</div>');
    cout('<div class="form_line_l"><p><label class="floating">' . $lang->def('_FIRSTNAME') . ':&nbsp;</label></p>' . $user_info[ACL_INFO_FIRSTNAME] . '</div>');
    cout('<div class="no_float"></div>');
    $charts = new Test_Charts($idTest, $idUser);
    $charts->render($chartType, true);
    cout($backUi);
    cout('</div>');
}
Exemplo n.º 16
0
function editviewer()
{
    checkPerm('mod');
    require_once _base_ . '/lib/lib.userselector.php';
    require_once _base_ . '/lib/lib.form.php';
    $lang =& DoceboLanguage::createInstance('admin_news', 'lms');
    $form = new Form();
    $out =& $GLOBALS['page'];
    $out->setWorkingZone('content');
    $id_news = importVar('id_news', true, 0);
    $page_title = array('index.php?modname=internal_news&amp;op=news' => $lang->def('_NEWS'), $lang->def('_RECIPIENTS'));
    $acl_manager = new DoceboACLManager();
    $user_select = new UserSelector();
    $user_select->show_user_selector = TRUE;
    $user_select->show_group_selector = TRUE;
    $user_select->show_orgchart_selector = TRUE;
    $user_select->show_orgchart_simple_selector = false;
    //$user_select->multi_choice = TRUE;
    $query_news = "\r\n\tSELECT title, viewer\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_news_internal\r\n\tWHERE idNews = '" . $id_news . "'";
    list($title, $viewer) = sql_fetch_row(sql_query($query_news));
    // try to load previous saved
    if (isset($_GET['load'])) {
        $viewer = unserialize($viewer);
        if (is_array($viewer)) {
            $user_select->resetSelection($viewer);
        } else {
            $user_select->resetSelection(array());
        }
    }
    if (isset($_POST['cancelselector'])) {
        Util::jump_to('index.php?modname=internal_news&amp;op=news');
    }
    if (isset($_POST['okselector'])) {
        $selected = $user_select->getSelection($_POST);
        $query_news = "\r\n\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_news_internal\r\n\t\tSET viewer = '" . serialize($selected) . "'\r\n\t\tWHERE idNews = '" . $id_news . "'";
        $re = sql_query($query_news);
        Util::jump_to('index.php?modname=internal_news&amp;op=news&amp;result=' . ($re ? 'ok' : 'err'));
    }
    cout(getTitleArea($page_title, 'news') . '<div class="std_block">');
    $user_select->addFormInfo($form->getHidden('id_news', 'id_news', $id_news));
    $user_select->loadSelector('index.php?modname=internal_news&amp;op=editviewer', false, false, true);
    cout('</div>');
}
Exemplo n.º 17
0
function writePollReport($id_poll, $id_param, $back_url, $mvc = false)
{
    require_once _lms_ . '/lib/lib.param.php';
    require_once _lms_ . '/lib/lib.poll.php';
    $poll_man = new PollManagement($id_poll);
    $report_man = new ReportPollManagement();
    $poll_info = $poll_man->getPollAllInfo();
    $valid_track = $report_man->getAllTrackId($id_poll, 'valid');
    $tot_tracks = $report_man->getHowMuchStat($id_poll, 'valid');
    // save page track info
    $quest_sequence_number = $poll_man->getInitQuestSequenceNumberForPage(1);
    $query_question = $report_man->getQuestions($id_poll);
    $treeview_value = str_replace('treeview_selected_' . $_SESSION['idCourse'], '', array_search($poll_info['title'], $_POST));
    $editions_filter = Get::req('poll_editions_filter', DOTY_INT, -1);
    if (Get::req('del_filter', DOTY_STRING, '') != '') {
        $editions_filter = -1;
    }
    $output = "";
    $str = (!$mvc ? '<div class="std_block">' : '') . '<div class="test_answer_space">';
    if ($mvc) {
        $output .= $str;
    } else {
        cout($str, 'content');
    }
    //--- filter on edition ------------------------------------------------------
    //retrieve editions
    $query = "SELECT * FROM %lms_course_editions WHERE id_course = " . (int) $_SESSION['idCourse'];
    $res = sql_query($query);
    //is there any edition ?
    if (sql_num_rows($res) > 0) {
        $arr_editions = array(-1 => Lang::t('_FILTEREDITIONSELECTONEOPTION', 'stats', 'lms'));
        //list of editions for the dropdown, in the format: "[code] name (date_begin - date_end)"
        while ($einfo = sql_fetch_object($res)) {
            $_label = '';
            if ($einfo->code != '') {
                $_label .= '[' . $einfo->code . '] ';
            }
            if ($einfo->name != '') {
                $_label .= $einfo->neme;
            }
            if (($einfo->date_begin != '' || $einfo->date_begin != '0000-00-00') && ($einfo->date_end != '' || $einfo->date_end != '0000-00-00')) {
                $_label .= ' (' . Format::date($einfo->date_begin, 'date') . ' - ' . Format::date($einfo->date_end, 'date') . ')';
            }
            if ($_label == '') {
                //...
            }
            $arr_editions[$einfo->id_edition] = $_label;
        }
        //draw editions dropdown and filter
        $str = Form::openForm('tree_filter_form', 'index.php?modname=stats&amp;op=statcourse') . Form::getHidden('seq_0.' . $treeview_value, 'treeview_selected_' . $_SESSION['idCourse'] . $treeview_value, $poll_info['title']) . Form::getHidden('treeview_selected_' . $_SESSION['idCourse'], 'treeview_selected_' . $_SESSION['idCourse'], $treeview_value) . Form::getHidden('treeview_state_' . $_SESSION['idCourse'], 'treeview_state_' . $_SESSION['idCourse'], $_POST['treeview_state_' . $_SESSION['idCourse']]) . Form::openElementSpace() . Form::getDropdown(Lang::t('_FILTEREDITIONSELECTTITLE', 'stats', 'lms'), 'poll_editions_filter', 'poll_editions_filter', $arr_editions, $editions_filter) . Form::openButtonSpace() . Form::getButton('filter', 'filter', Lang::t('_SEARCH', 'stats', 'lms')) . Form::getButton('del_filter', 'del_filter', Lang::t('_DEL_FILTER', 'stats', 'lms')) . Form::closeButtonSpace() . Form::closeElementSpace() . Form::closeForm();
        if ($mvc) {
            $output .= $str;
        } else {
            cout($str, 'content');
        }
    }
    //------------------------------------------------------------------------------
    $user = array();
    $tracks = array();
    if ($editions_filter > 0) {
        $query = "SELECT idUser FROM %lms_courseuser " . " WHERE idCourse = '" . (int) $_SESSION['idCourse'] . "' AND edition_id = '" . $editions_filter . "'";
        $res = sql_query($query);
        while (list($idUser) = sql_fetch_row($res)) {
            $users[] = $idUser;
        }
        if (count($users) > 0) {
            $query_traks = "SELECT id_track " . " FROM %lms_polltrack " . " WHERE id_user IN (" . implode(', ', $users) . ") ";
            $result_traks = sql_query($query_traks);
            while (list($id_traks) = sql_fetch_row($result_traks)) {
                $tracks[$id_traks] = $id_traks;
            }
        }
    }
    if (!empty($tracks)) {
        $valid_track = array_intersect($valid_track, $tracks);
    } elseif ($editions_filter != -1) {
        $valid_track = array();
        $valid_track[] = 0;
    }
    if (empty($valid_track)) {
        $valid_track[] = 0;
    }
    $tot_tracks = count($valid_track);
    //----------------------------------------------------------------------------
    // Get question from database
    $re_question = sql_query($query_question);
    if (isset($_POST['export'])) {
        $export = true;
        $filename = 'stats_' . str_replace(' ', '_', $poll_info['title']) . '_' . date("Y\\_m\\_d") . '.csv';
        $filetext = '';
    } else {
        $export = false;
    }
    while (list($idQuest, $type_quest, $type_file, $type_class) = sql_fetch_row($re_question)) {
        require_once _lms_ . '/modules/question_poll/' . $type_file;
        $quest_obj = eval("return new {$type_class}( {$idQuest} );");
        if ($export) {
            $filetext .= $quest_obj->export_CSV($quest_sequence_number, $tot_tracks, $valid_track);
            $filetext .= "\r\n";
        } else {
            $GLOBALS['page']->add($quest_obj->playReport($quest_sequence_number, $tot_tracks, $valid_track), 'content');
        }
        if ($type_quest != 'break_page' && $type_quest != 'title') {
            ++$quest_sequence_number;
        }
    }
    if ($export) {
        require_once _base_ . '/lib/lib.download.php';
        sendStrAsFile($filetext, $filename);
    }
    $treeview_value = str_replace('treeview_selected_' . $_SESSION['idCourse'], '', array_search($poll_info['title'], $_POST));
    $str = Form::openForm('tree_export_form', 'index.php?modname=stats&amp;op=statcourse') . Form::getHidden('seq_0.' . $treeview_value, 'treeview_selected_' . $_SESSION['idCourse'] . $treeview_value, $poll_info['title']) . Form::getHidden('treeview_selected_' . $_SESSION['idCourse'], 'treeview_selected_' . $_SESSION['idCourse'], $treeview_value) . Form::getHidden('treeview_state_' . $_SESSION['idCourse'], 'treeview_state_' . $_SESSION['idCourse'], $_POST['treeview_state_' . $_SESSION['idCourse']]) . Form::openButtonSpace() . Form::getButton('export', 'export', Lang::t('_EXPORT_CSV', 'standard')) . Form::closeButtonSpace() . Form::closeForm();
    if ($mvc) {
        $output .= $str;
    } else {
        cout($str, 'content');
    }
    $str = '</div>' . (!$mvc ? '</div>' : '');
    if ($mvc) {
        $output .= $str;
    } else {
        cout($str, 'content');
    }
}
Exemplo n.º 18
0
function addCourse()
{
    checkPerm('mod');
    require_once _base_ . '/lib/lib.form.php';
    //require_once(_i18n_.'/lib.lang.php');
    require_once _base_ . '/lib/lib.table.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    require_once dirname(__FILE__) . '/../category/category.php';
    require_once dirname(__FILE__) . '/../category/tree.category.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.manmenu.php';
    require_once $GLOBALS['where_lms'] . '/lib/category/class.categorytree.php';
    $form = new Form();
    $lang =& DoceboLanguage::CreateInstance('course', 'lms');
    // tree for categories ------------------------------------------------
    $categoryDb = new CategoryTree();
    $id_category = isset($_SESSION['course_category']['filter_status']['c_category']) ? (int) $_SESSION['course_category']['filter_status']['c_category'] : 0;
    $name_category = $categoryDb->getFolderById($id_category);
    $name_category = end(explode("/", $name_category->path));
    // -------------------------------------------------------------------
    $course = array('autoregistration_code' => '', 'code' => '', 'name' => '', 'lang_code' => getLanguage(), 'difficult' => 'medium', 'course_type' => 'elearning', 'status' => CST_EFFECTIVE, 'course_edition' => 0, 'description' => '', 'can_subscribe' => 1, 'sub_start_date' => '', 'sub_end_date' => '', 'show_rules' => 0, 'show_progress' => 1, 'show_time' => 1, 'show_who_online' => 1, 'show_extra_info' => 0, 'level_show_user' => 0, 'subscribe_method' => 2, 'selling' => 0, 'prize' => '', 'advance' => '', 'permCloseLO' => 0, 'userStatusOp' => 1 << _CUS_SUSPEND, 'direct_play' => 0, 'date_begin' => '', 'date_end' => '', 'hour_begin' => '-1', 'hour_end' => '-1', 'valid_time' => '0', 'mediumTime' => '0', 'min_num_subscribe' => '0', 'max_num_subscribe' => '0', 'allow_overbooking' => '', 'course_quota' => '', 'show_result' => '0', 'linkSponsor' => 'http://', 'use_logo_in_courselist' => '1');
    // -------------------------------------------------------------------
    $title_area = array('index.php?modname=course&amp;op=course_list' => $lang->def('_COURSE'), $lang->def('_NEW_COURSE'));
    cout(getTitleArea($title_area, 'course') . '<div class="std_block">' . getBackUi('index.php?modname=course&amp;op=course_list', $lang->def('_BACK')) . $form->getFormHeader($lang->def('_NEW_COURSE')) . $form->openForm('course_creation', 'index.php?modname=course&amp;op=add_course', false, false, 'multipart/form-data') . $form->getHidden('idCategory', 'idCategory', $id_category), 'content');
    maskModCourse($course, true, $name_category);
    $GLOBALS['page']->add($form->openButtonSpace() . $form->getButton('course_create', 'course_create', $lang->def('_CREATE')) . $form->getButton('course_undo', 'course_undo', $lang->def('_UNDO')) . $form->closeButtonSpace() . $form->closeForm() . '</div>', 'content');
}
Exemplo n.º 19
0
function userdetails()
{
    checkPerm('view');
    require_once _base_ . '/lib/lib.table.php';
    $idst_user = importVar('id', true, 0);
    $ord = importVar('ord');
    $inv = importVar('inv', true, 0);
    $link = 'index.php?modname=statistic&amp;op=userdetails&amp;id=' . $idst_user . '';
    $nav_bar = new NavBar('ini', Get::sett('visuItem'), 0, 'link');
    $nav_bar->setLink($link . '&amp;ord=' . $ord . '&amp;inv=' . $inv);
    if (!isset($_GET['p_ini'])) {
        $ini = $nav_bar->getSelectedElement();
    } else {
        $ini = $_GET['p_ini'];
    }
    $lang =& DoceboLanguage::createInstance('statistic', 'lms');
    $acl_man = Docebo::user()->getAclManager();
    $user_info =& $acl_man->getUser($idst_user, false);
    $page_title = array('index.php?modname=statistic&amp;op=statistic' => $lang->def('_STATISTICS'), $user_info[ACL_INFO_LASTNAME] . $user_info[ACL_INFO_FIRSTNAME] ? $user_info[ACL_INFO_LASTNAME] . ' ' . $user_info[ACL_INFO_FIRSTNAME] : $acl_man->relativeId($user_info[ACL_INFO_USERID]));
    // Find modulename -> name int his course
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    $course_man = new Man_Course();
    $mods_names =& $course_man->getModulesName($_SESSION['idCourse']);
    // find total time in the course
    $query_time = "\r\n\tSELECT SUM((UNIX_TIMESTAMP(lastTime) - UNIX_TIMESTAMP(enterTime)))\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_tracksession \r\n\tWHERE idCourse = '" . (int) $_SESSION['idCourse'] . "' AND idUser = '******'";
    list($tot_time) = sql_fetch_row(sql_query($query_time));
    $query_track = "\r\n\tSELECT idEnter, enterTime, lastTime, (UNIX_TIMESTAMP(lastTime) - UNIX_TIMESTAMP(enterTime)) AS howm, \r\n\t\tnumOp, lastFunction, lastOp, session_id \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_tracksession \r\n\tWHERE idCourse = '" . (int) $_SESSION['idCourse'] . "' AND idUser = '******'\r\n\tORDER BY ";
    $img_down = '<img src="' . getPathImage() . 'standard/ord_asc.png" alt="' . $lang->def("_ORD_ASC_TITLE") . '" ' . 'title="' . $lang->def("_ORD_ASC_TITLE") . '" />';
    $img_up = '<img src="' . getPathImage() . 'standard/ord_desc.png" alt="' . $lang->def("_ORD_DESC_ALT") . '" ' . 'title="' . $lang->def("_ORD_DESC_TITLE") . '" />';
    $image_hm = $image_nop = $image_sst = '';
    switch ($ord) {
        case "hm":
            $query_track .= " howm " . ($inv ? '  ' : ' DESC ');
            $order_for = $lang->def('_HOW_MUCH_TIME');
            $image_hm = $inv ? $img_down : $img_up;
            break;
        case "nop":
            $query_track .= " numOp " . ($inv ? '  ' : 'DESC');
            $order_for = $lang->def('_NUMBER_OF_OP');
            $image_nop = $inv ? $img_down : $img_up;
            break;
        default:
            $query_track .= " enterTime " . ($inv ? ' DESC ' : '');
            $order_for = $lang->def('_SESSION_STARTED');
            $image_sst = $inv ? $img_down : $img_up;
            break;
    }
    $query_track .= " LIMIT " . $ini . ", " . Get::sett('visuItem');
    $re_tracks = sql_query($query_track);
    $query_tot_track = "\r\n\tSELECT COUNT(*) \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_tracksession \r\n\tWHERE idCourse = '" . (int) $_SESSION['idCourse'] . "' AND idUser = '******'";
    list($tot_elem) = sql_fetch_row(sql_query($query_tot_track));
    $nav_bar->setElementTotal($tot_elem);
    $GLOBALS['page']->add(getTitleArea($page_title, 'statistic') . '<div class="std_block">' . getBackUi('index.php?modname=statistic&amp;op=statistic', $lang->def('_BACK')), 'content');
    $tb = new Table(0, $lang->def('_USERS_LIST_DETAILS_CAPTION'), $lang->def('_USERS_LIST_DETAILS_SUMMARY'));
    $type_h = array('', '', 'align_center', 'align_center', '');
    $cont_h = array('<a href="' . $link . '&amp;ord=sst&amp;inv=' . ($ord == 'sst' && $inv ? '0' : '1') . '" title="' . $lang->def('_ORD_FOR_SST') . '">' . $image_sst . ' ' . $lang->def('_SESSION_STARTED') . '</a>', $lang->def('_LAST_ACTION_AT'), '<a href="' . $link . '&amp;ord=hm&amp;inv=' . ($ord == 'hm' && $inv ? '0' : '1') . '" title="' . $lang->def('_ORD_FOR_HM') . '">' . $image_hm . ' ' . $lang->def('_HOW_MUCH_TIME') . '</a>', '<a href="' . $link . '&amp;ord=nop&amp;inv=' . ($ord == 'nop' && $inv ? '0' : '1') . '" title="' . $lang->def('_ORD_FOR_NOP') . '">' . $image_nop . ' ' . $lang->def('_NUMBER_OF_OP') . '</a>', $lang->def('_LAST_OP'));
    if (Get::sett('tracking') == 'on') {
        $cont_h[] = '<img src="' . getPathImage() . 'standard/view.png" title="' . $lang->def('_VIEW_SESSION_DETAILS') . '" ' . 'alt="' . $lang->def('_VIEW_SESSION_DETAILS_ALT') . '" />';
        $type_h[] = 'image';
    }
    $tb->setColsStyle($type_h);
    $tb->addHead($cont_h);
    $type_h[2] = 'align_right';
    $tb->setColsStyle($type_h);
    $total_sec = 0;
    $chart_data = array();
    while (list($id_enter, $session_start_at, $last_action_at, $how, $num_op, $last_module, $last_op, $session_id) = sql_fetch_row($re_tracks)) {
        $hours = (int) ($how / 3600);
        $minutes = (int) ($how % 3600 / 60);
        $seconds = (int) ($how % 60);
        if ($minutes < 10) {
            $minutes = '0' . $minutes;
        }
        if ($seconds < 10) {
            $seconds = '0' . $seconds;
        }
        $readable = $hours . 'h ' . $minutes . 'm ' . $seconds . 's ';
        $start = Format::date($session_start_at);
        $cont = array($start, Format::date($last_action_at, false, true), $readable, $num_op, '<span class="text_bold">' . (isset($mods_names[$last_module]) ? $mods_names[$last_module] : $last_module) . '</span> [' . $last_op . ']');
        if (Get::sett('tracking') == 'on') {
            $cont[] = '<a href="index.php?modname=statistic&amp;op=sessiondetails&amp;id=' . $idst_user . '&amp;id_enter=' . $id_enter . '&amp;p_ini=' . $ini . '&amp;sid=' . $session_id . '" ' . 'title="' . $lang->def('_VIEW_SESSION_DETAILS') . ' : ' . $start . '">' . '<img src="' . getPathImage() . 'standard/view.png" alt="' . $lang->def('_VIEW_SESSION_DETAILS_ALT') . ' : ' . $start . '" /></a>';
        }
        $tb->addBody($cont);
        $chart_data[] = array('x_axis' => $start, 'y_axis' => $how);
    }
    $hours = (int) ($tot_time / 3600);
    $minutes = (int) ($tot_time % 3600 / 60);
    $seconds = (int) ($tot_time % 60);
    if ($minutes < 10) {
        $minutes = '0' . $minutes;
    }
    if ($seconds < 10) {
        $seconds = '0' . $seconds;
    }
    $json = new Services_JSON();
    cout('<div>' . '<span class="text_bold">' . $lang->def('_USER_TOTAL_TIME') . ' : </span>' . $hours . 'h ' . $minutes . 'm ' . $seconds . 's ' . '</div>' . '<div id="statistic_chart">Unable to load Flash content. Required Flash Player 9.0.45 or higher. You can download the latest version of Flash Player from the <a href="http://www.adobe.com/go/getflashplayer">Adobe Flash Player Download Center</a>.</div>
		<script type="text/javascript">
			var dataSource = new YAHOO.util.DataSource( ' . $json->encode(array_values($chart_data)) . ' );
			dataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
			dataSource.responseSchema = {fields: [ "x_axis", "y_axis" ]};

			var getDataTipText = function(item, index, series) {
				var toolTipText = Math.floor(item.y_axis/3600) +"h "+ Math.floor((item.y_axis%3600)/60) + "m";
				return toolTipText;
			};
			
			var myChart = new YAHOO.widget.ColumnChart( "statistic_chart", dataSource, {
				xField: "x_axis",
				yField: "y_axis",
				wmode: "opaque",
			dataTipFunction: getDataTipText
			});
		</script>' . $tb->getTable() . $nav_bar->getNavBar($ini) . getBackUi('index.php?modname=statistic&amp;op=statistic', $lang->def('_BACK')) . '</div>', 'content');
}
Exemplo n.º 20
0
function mycertificate(&$url)
{
    checkPerm('view');
    require_once _lms_ . '/lib/lib.course.php';
    require_once _base_ . '/lib/lib.table.php';
    $lang =& DoceboLanguage::createInstance('profile', 'framework');
    $lang =& DoceboLanguage::createInstance('course', 'lms');
    $lang =& DoceboLanguage::createInstance('certificate', 'lms');
    $admin_level = Docebo::user()->getUserLevelId();
    $show_preview = true;
    //($admin_level == ADMIN_GROUP_ADMIN || $admin_level == ADMIN_GROUP_GODADMIN);
    $title = $lang->def('_MY_CERTIFICATE', 'certificate');
    $html = getTitleArea($title, 'mycertificate') . '<div class="std_block">';
    //--- draw time periods dropdown ---------------------------------------------
    $period_start = '';
    $period_end = '';
    //extract checking period
    $p_model = new TimeperiodsAlms();
    $year = date("Y");
    $p_list = array("0" => $lang->def('_ALL'));
    $p_selected = Get::req('selected_period', DOTY_INT, 0);
    $p_data = $p_model->getTimePeriods('', true);
    if (count($p_data) > 0) {
        foreach ($p_data as $obj) {
            $p_list[$obj->id_period] = Format::date($obj->start_date, 'date') . ' - ' . Format::date($obj->end_date, 'date');
            if ($p_selected == $obj->id_period) {
                $period_start = $obj->start_date;
                $period_end = $obj->end_date;
            }
        }
    }
    if (!array_key_exists($p_selected, $p_list)) {
        $p_selected = 0;
        $period_start = '';
        $period_end = '';
    }
    //date dropdown
    $onchange = ' onchange="javascript:this.form.submit();"';
    $html_filter_cert = '' . Form::openForm('selected_period_form_cert', $url->getUrl()) . Form::openElementSpace() . Form::getDropdown(Lang::t('_TIME_PERIODS', 'menu'), 'selected_period_cert', 'selected_period', $p_list, $p_selected, '', '', $onchange) . Form::closeElementSpace() . Form::getHidden('current_tab_cert', 'current_tab', Get::req('current_tab', DOTY_STRING, 'cert')) . Form::getHidden('is_filtering_cert', 'is_filtering_cert', 1) . Form::closeForm();
    $html_filter_meta = '' . Form::openForm('selected_period_form_meta', $url->getUrl()) . Form::openElementSpace() . Form::getDropdown(Lang::t('_TIME_PERIODS', 'menu'), 'selected_period_meta', 'selected_period', $p_list, $p_selected, '', '', $onchange) . Form::closeElementSpace() . Form::getHidden('current_tab_meta', 'current_tab', Get::req('current_tab', DOTY_STRING, 'meta')) . Form::getHidden('is_filtering_meta', 'is_filtering_meta', 1) . Form::closeForm();
    //----------------------------------------------------------------------------
    $cert = new Certificate();
    /*
     * Print certificates tables, subdivided by year and course type
     */
    $html_cert = '';
    $tb_cert = new Table(0);
    $cont_h = array($lang->def('_YEAR', 'standard'), $lang->def('_COURSE_CODE', 'course'), $lang->def('_COURSE', 'course'), $lang->def('_CERTIFICATE_NAME', 'course'), $lang->def('_DATE_END', 'course'));
    //if ($show_preview) $cont_h[] = '<img src="'.getPathImage('lms').'certificate/preview.gif" alt="'.$lang->def('_PREVIEW').'" />';
    //$cont_h[] = '<img src="'.getPathImage('lms').'certificate/certificate.gif" alt="'.$lang->def('_ALT_TAKE_A_COPY').'" />';
    if ($show_preview) {
        $cont_h[] = '<span class="ico-sprite subs_view"><span>' . $lang->def('_PREVIEW') . '"</span></span>';
    }
    $cont_h[] = '<span class="ico-sprite subs_pdf"><span>' . $lang->def('_ALT_TAKE_A_COPY') . '</span></span>';
    $type_h = array('img-cell', '', '', 'align-center', 'align-center', 'img-cell', 'img-cell');
    if ($show_preview) {
        $type_h[] = 'nowarp';
    }
    $type_h[] = 'nowarp';
    $tb_cert->setColsStyle($type_h);
    $tb_cert->addHead($cont_h);
    $available_cert = $cert->certificateForCourses(false, false);
    $released = $cert->certificateReleased(Docebo::user()->getIdST());
    $query_courses = "" . " SELECT c.idCourse, c.code, c.name, u.status AS user_status, c.course_type, c.permCloseLO " . " FROM %lms_course AS c JOIN %lms_courseuser AS u ON (c.idCourse = u.idCourse) " . " WHERE u.idUser = '******' " . ($period_start != '' ? " AND u.date_complete >= '" . $period_start . "' " : "") . ($period_end != '' ? " AND u.date_complete <= '" . $period_end . "' " : "") . " ORDER BY u.date_complete DESC, u.status DESC ";
    $course_list = sql_query($query_courses);
    $arr_courses = array();
    $arr_courses_ids = array();
    while ($obj = sql_fetch_object($course_list)) {
        $arr_courses[$obj->course_type][] = array($obj->idCourse, $obj->code, $obj->name, $obj->user_status, $obj->permCloseLO);
        $arr_courses_ids[] = $obj->idCourse;
    }
    $arr_course_types = getCourseTypes();
    $table_displayed = false;
    //extract certificates details and availability by courses ids
    $arr_courses_ids = array_unique($arr_courses_ids);
    $arr_certificates_availability = array();
    $arr_certificates_details = array();
    if (count($arr_courses_ids) > 0) {
        $query = "SELECT id_certificate, id_course, available_for_status " . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_course" . " WHERE id_course IN (" . implode(",", $arr_courses_ids) . ")";
        //." WHERE id_certificate = '".$id_cert."'"
        //." AND id_course IN (".implode(",", $arr_courses_ids).")";
        $res = sql_query($query);
        while (list($id_certificate, $id_course, $available_for_status) = sql_fetch_row($res)) {
            $arr_certificates_availability[$id_course][$id_certificate] = $available_for_status;
        }
        $cont = array();
        $query = "SELECT idCourse, date_inscr, date_first_access, date_complete, status" . " FROM %lms_courseuser WHERE idUser = '******'" . " AND idCourse IN (" . implode(",", $arr_courses_ids) . ") " . ($period_start != '' ? " AND date_complete >= '" . $period_start . "' " : "") . ($period_end != '' ? " AND date_complete <= '" . $period_end . "' " : "");
        $res = sql_query($query);
        while (list($id_course, $date_inscr, $date_begin, $date_end, $status) = sql_fetch_row($res)) {
            $arr_certificate_details[$id_course] = array($date_inscr, $date_begin, $date_end, $status);
        }
    }
    //order arr_courses by key
    ksort($arr_courses);
    $years = array();
    foreach ($arr_courses as $course_type => $course_data) {
        if (in_array($course_type, array_keys($arr_course_types))) {
            //$html .= '';
            $tb = new Table(0);
            $tb->setColsStyle($type_h);
            $tb->addHead($cont_h);
            //filter and organize data to display
            $display_data = array();
            foreach ($course_data as $k => $value) {
                list($id_course, $code, $name, $user_status, $perm_close_lo) = $value;
                if (isset($available_cert[$id_course])) {
                    $can_rel_exceptional = false;
                    while (list($id_cert, $certificate) = each($available_cert[$id_course])) {
                        if ($cert->certificateAvailableForUser($id_cert, $id_course, getLogUserId())) {
                            if ($certificate[CERT_AV_POINT_REQUIRED] > 0) {
                                $course_score_final = false;
                                if ($perm_close_lo == 0) {
                                    require_once $GLOBALS['where_lms'] . '/lib/lib.orgchart.php';
                                    $org_man = new OrganizationManagement(false);
                                    $score_final = $org_man->getFinalObjectScore(array(getLogUserId()), array($id_course));
                                    if (isset($score_final[$id_course][getLogUserId()]) && $score_final[$id_course][getLogUserId()]['max_score']) {
                                        $course_score_final = $score_final[$id_course][getLogUserId()]['score'];
                                        $course_score_final_max = $score_final[$id_course][getLogUserId()]['max_score'];
                                    }
                                } else {
                                    require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php';
                                    $rep_man = new CourseReportManager();
                                    $score_course = $rep_man->getUserFinalScore(array(getLogUserId()), array($id_course));
                                    if (!empty($score_course)) {
                                        $course_score_final = isset($score_course[getLogUserId()][$id_course]) ? $score_course[getLogUserId()][$id_course]['score'] : false;
                                        $course_score_final_max = isset($score_course[getLogUserId()][$id_course]) ? $score_course[getLogUserId()][$id_course]['max_score'] : false;
                                    }
                                }
                                if ($course_score_final >= $certificate[CERT_AV_POINT_REQUIRED]) {
                                    $can_rel_exceptional = true;
                                }
                            }
                        }
                    }
                    reset($available_cert[$id_course]);
                    //count years for rowspans
                    while (list($id_cert, $certificate) = each($available_cert[$id_course])) {
                        //(aggiunto if prima dell'or)
                        if ($cert->certificateAvailableForUser($id_cert, $id_course, getLogUserId())) {
                            //$value[4] = $id_cert;
                            list($available_for_status) = $arr_certificates_availability[$id_course][$id_cert];
                            list($date_inscr, $date_begin, $date_end, $status) = $arr_certificate_details[$id_course];
                            if ($available_for_status == 3 && $status == 2 || $available_for_status == 2 && $status == 1 || $available_for_status == 1) {
                                //$year = substr($date_end, 0, 4);
                                switch ($available_for_status) {
                                    case 3:
                                        $cur_year = substr($date_end, 0, 4);
                                        break;
                                    case 2:
                                        $cur_year = substr($date_begin, 0, 4);
                                        break;
                                    case 1:
                                        $cur_year = substr($date_inscr, 0, 4);
                                        break;
                                    default:
                                        $cur_year = '-';
                                }
                                // (mi ricreo l'array value perchè manca di date_* BUG FIX)
                                $value = array($id_course, $code, $name, $date_begin, $date_end, $user_status, $perm_close_lo);
                                $value[6] = $id_cert;
                                $query = "SELECT name " . " FROM " . $GLOBALS['prefix_lms'] . "_certificate" . " WHERE id_certificate = " . $id_cert;
                                $res = sql_query($query);
                                list($cname) = sql_fetch_row($res);
                                $value[7] = $cname;
                                if ($can_rel_exceptional && $certificate[CERT_AV_POINT_REQUIRED] > 0) {
                                    if (isset($years[$course_type][$cur_year])) {
                                        $years[$course_type][$cur_year]++;
                                    } else {
                                        $years[$course_type][$cur_year] = 1;
                                    }
                                    $display_data[$cur_year][] = $value;
                                } elseif (!$can_rel_exceptional && $certificate[CERT_AV_POINT_REQUIRED] == 0) {
                                    if (isset($years[$course_type][$cur_year])) {
                                        $years[$course_type][$cur_year]++;
                                    } else {
                                        $years[$course_type][$cur_year] = 1;
                                    }
                                    $display_data[$cur_year][] = $value;
                                }
                            }
                        }
                    }
                }
            }
            if (count($display_data) > 0) {
                krsort($display_data);
            }
            $av_cert = 0;
            $prev_year = false;
            $rowspan_counter = 0;
            require_once $GLOBALS['where_lms'] . '/lib/lib.orgchart.php';
            $org_man = new OrganizationManagement(false);
            foreach ($display_data as $year => $rows) {
                $first = true;
                foreach ($rows as $row) {
                    // list($id_course, $code, $name, $user_status, $id_cert) = $row;
                    list($id_course, $code, $name, $date_begin, $date_end, $user_status, $id_cert, $cname) = $row;
                    $cont = array();
                    if ($first) {
                        $cont[] = array('rowspan' => isset($years[$course_type][$year]) ? $years[$course_type][$year] : 1, 'value' => $year, 'style' => $type_h[0] . ' mycertificate_rowspan' . ($rowspan_counter % 2 > 0 ? '_odd' : ''));
                        $rowspan_counter++;
                        $first = false;
                    }
                    // 2 - the code of the course
                    $cont[] = array('value' => $code, 'style' => $type_h[1]);
                    // 3 - the name of the course
                    $cont[] = array('value' => $name, 'style' => $type_h[2]);
                    // sostituito date_begin con certificate name
                    // 4 - starting date
                    //					$cont[] = array(
                    //						'value' => Format::date($date_begin, 'datetime'),
                    //						'style' => $type_h[3]
                    //					);
                    $cont[] = array('value' => $cname, 'style' => $type_h[3]);
                    // 5 - complete date
                    $cont[] = array('value' => Format::date($date_end, 'datetime'), 'style' => $type_h[4]);
                    //-- scores --
                    $score_start = $org_man->getStartObjectScore(array(Docebo::user()->getIdST()), array($id_course));
                    $score_final = $org_man->getFinalObjectScore(array(Docebo::user()->getIdST()), array($id_course));
                    $_value1 = isset($score_start[$id_course][Docebo::user()->getIdST()]) && $score_start[$id_course][Docebo::user()->getIdST()]['max_score'] ? $score_start[$id_course][Docebo::user()->getIdST()]['score'] . ' / ' . $score_start[$id_course][Docebo::user()->getIdST()]['max_score'] : '';
                    $_value2 = isset($score_final[$id_course][Docebo::user()->getIdST()]) && $score_final[$id_course][Docebo::user()->getIdST()]['max_score'] ? $score_final[$id_course][Docebo::user()->getIdST()]['score'] . ' / ' . $score_final[$id_course][Docebo::user()->getIdST()]['max_score'] : '';
                    /* hide course scores - remove comment to show
                    					// 6 - init score
                    					$cont[] = array(
                    						'value' => $_value1,
                    						'style' => $type_h[5]
                    					);
                    
                    					// 7 - end score
                    					$cont[] = array(
                    						'value' => $_value2,
                    						'style' => $type_h[6]
                    					);
                    					*/
                    if (isset($released[$id_course][$id_cert])) {
                        $av_cert++;
                        if ($show_preview) {
                            $cont[] = array('value' => '', 'style' => $type_h[7]);
                        }
                        $_value = '<a class="ico-wt-sprite subs_pdf" href="' . $url->getUrl('op=release_cert&id_certificate=' . $id_cert . '&id_course=' . $id_course) . '" ' . ' title="' . $lang->def('_TAKE_A_COPY') . '"><span>' . $lang->def('_TAKE_A_COPY') . '</span></a>';
                        $cont[] = array('value' => $_value, 'style' => $type_h[$show_preview ? 8 : 7]);
                    } else {
                        $av_cert++;
                        if ($show_preview) {
                            $_value = '<a class="ico-wt-sprite subs_view" href="' . $url->getUrl('op=preview_cert&id_certificate=' . $id_cert . '&id_course=' . $id_course) . '" ' . ' title="' . $lang->def('_PREVIEW') . '"><span>' . $lang->def('_PREVIEW') . '</span></a>';
                            $cont[] = array('value' => $_value, 'style' => $type_h[7]);
                        }
                        $_value = '<a class="ico-wt-sprite subs_pdf" href="' . $url->getUrl('op=release_cert&id_certificate=' . $id_cert . '&id_course=' . $id_course) . '" ' . ' title="' . $lang->def('_NEW_CERTIFICATE') . '"><span>' . $lang->def('_NEW_CERTIFICATE') . '</span></a>';
                        $cont[] = array('value' => $_value, 'style' => $type_h[$show_preview ? 8 : 7]);
                    }
                    $tb->addBody($cont);
                }
            }
            if ($av_cert > 0) {
                $table_displayed = true;
                $html_cert .= '<h2 class="mycertificate_title">' . $arr_course_types[$course_type] . '</h2>';
                $html_cert .= $tb->getTable();
            }
        }
    }
    //end course_type foreach
    if (!$table_displayed) {
        $is_filtering = Get::req('is_filtering_cert', DOTY_INT, 0);
        $html_cert .= '<p>' . ($is_filtering ? $html_filter_cert : '') . $lang->def('_NO_CONTENT') . '</p>';
    } else {
        $html_cert = $html_filter_cert . $html_cert;
    }
    //-------------------------------------------------------------------------------------------
    /*
     * Print meta-certificates table
     */
    $html_meta = '';
    $tb_meta_cert = new Table(0);
    $cont_h = array();
    $cont_h[] = $lang->def('_CODE');
    $cont_h[] = $lang->def('_NAME');
    $cont_h[] = $lang->def('_COURSE_LIST');
    //if ($show_preview) $cont_h[] = '<img src="'.getPathImage('lms').'certificate/preview.gif" alt="'.$lang->def('_PREVIEW').'" />';
    //$cont_h[] = '<img src="'.getPathImage('lms').'certificate/certificate.gif" alt="'.$lang->def('_ALT_TAKE_A_COPY').'" />';
    if ($show_preview) {
        $cont_h[] = '<span class="ico-sprite subs_view"><span>' . $lang->def('_PREVIEW') . '"</span></span>';
    }
    $cont_h[] = '<span class="ico-sprite subs_pdf"><span>' . $lang->def('_ALT_TAKE_A_COPY') . '</span></span>';
    $type_h = array();
    $type_h[] = '';
    $type_h[] = '';
    $type_h[] = '';
    if ($show_preview) {
        $type_h[] = 'img-cell';
    }
    //'nowrap';
    $type_h[] = 'img-cell';
    //'nowrap';
    $tb_meta_cert->setColsStyle($type_h);
    $tb_meta_cert->addHead($cont_h);
    $query = "SELECT c.idMetaCertificate, m.title, m.description, m.idCertificate" . " FROM %lms_certificate_meta_course as c" . " JOIN %lms_certificate_meta as m ON c.idMetaCertificate = m.idMetaCertificate" . " WHERE c.idUser = '******'" . " GROUP BY c.idMetaCertificate" . " ORDER BY m.title, m.description";
    $result = sql_query($query);
    $av_meta_cert = sql_num_rows($result);
    $cert_meta_html = '';
    while (list($id_meta, $name, $description, $id_certificate) = sql_fetch_row($result)) {
        $cont = array();
        $query = "SELECT code, name" . " FROM %lms_certificate" . " WHERE id_certificate = " . " (" . " SELECT idCertificate" . " FROM %lms_certificate_meta" . " WHERE idMetaCertificate = '" . $id_meta . "'" . " )";
        list($code, $name) = sql_fetch_row(sql_query($query));
        $cont[] = $code;
        $cont[] = $name;
        $query_released = "SELECT on_date" . " FROM %lms_certificate_meta_assign" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'";
        $result_released = sql_query($query_released);
        $query = "SELECT user_release" . " FROM %lms_certificate" . " WHERE id_certificate = '" . $id_certificate . "'";
        list($user_release) = sql_fetch_row(sql_query($query));
        if (sql_num_rows($result_released)) {
            $course_list = '';
            $first = true;
            $query_course = "SELECT code, name" . " FROM %lms_course" . " WHERE idCourse IN " . "(" . "SELECT idCourse" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'" . ")";
            $result_course = sql_query($query_course);
            while (list($code, $name) = sql_fetch_row($result_course)) {
                if ($first) {
                    $first = false;
                } else {
                    $course_list .= '<br/>';
                }
                $course_list .= '(' . $code . ') - ' . $name;
            }
            $cont[] = $course_list;
            if ($show_preview) {
                $cont[] = '';
            }
            list($date) = sql_fetch_row($result_released);
            $cont[] = '<a class="ico-wt-sprite subs_pdf" href="' . $url->getUrl('op=release_cert&id_certificate=' . $id_certificate . '&idmeta=' . $id_meta) . '" ' . ' title="' . $lang->def('_TAKE_A_COPY') . '"><span>' . $lang->def('_TAKE_A_COPY') . '</span></a>';
            $tb_meta_cert->addBody($cont);
        } elseif ($user_release == 0) {
            $av_meta_cert--;
        } else {
            $query = "SELECT idCourse" . " FROM %lms_certificate_meta_course" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'";
            $result_int = sql_query($query);
            $control = true;
            while (list($id_course) = sql_fetch_row($result_int)) {
                $query = "SELECT COUNT(*)" . " FROM %lms_courseuser" . " WHERE idCourse = '" . $id_course . "'" . " AND idUser = '******'" . " AND status = '" . _CUS_END . "'";
                list($number) = sql_fetch_row(sql_query($query));
                if (!$number) {
                    $control = false;
                }
            }
            if ($control) {
                $course_list = '';
                $first = true;
                $query_course = "SELECT code, name" . " FROM %lms_course" . " WHERE idCourse IN " . "(" . "SELECT idCourse" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'" . ")";
                $result_course = sql_query($query_course);
                while (list($code, $name) = sql_fetch_row($result_course)) {
                    if ($first) {
                        $first = false;
                    } else {
                        $course_list .= '<br/>';
                    }
                    $course_list .= '(' . $code . ') - ' . $name;
                }
                $cont[] = $course_list;
                if ($show_preview) {
                    $cont[] = '<a class="ico-wt-sprite subs_view" href="' . $url->getUrl('op=preview_cert&id_certificate=' . $id_certificate . '&idmeta=' . $id_meta) . '" ' . ' title="' . $lang->def('_PREVIEW') . '"><span>' . $lang->def('_PREVIEW') . '</span></a>';
                }
                $cont[] = '<a class="ico-wt-sprite subs_pdf" href="' . $url->getUrl('op=release_cert&id_certificate=' . $id_certificate . '&idmeta=' . $id_meta) . '" ' . ' title="' . $lang->def('_NEW_CERTIFICATE') . '"><span>' . $lang->def('_NEW_CERTIFICATE') . '</span></a>';
                $tb_meta_cert->addBody($cont);
            } else {
                $av_meta_cert--;
            }
        }
    }
    if ($av_meta_cert) {
        $html_meta .= $tb_meta_cert->getTable() . '<br/><br/>';
    } else {
        //$is_filtering = Get::req('is_filtering_meta', DOTY_INT, 0);
        //$html_meta .= '<p>'.($is_filtering>0 ? $html_filter_meta : '').$lang->def('_NO_CONTENT').'</p>';
        $html_meta .= '<p>' . $lang->def('_NO_CONTENT') . '</p>';
    }
    //-----------------------------------------------------------------------------
    $selected_tab = Get::req('current_tab', DOTY_STRING, 'cert');
    $html .= '<div id="mycertificate_tabs" class="yui-navset">
			<ul class="yui-nav">
					<li' . ($selected_tab == 'cert' ? ' class="selected"' : '') . '><a href="#cert"><em>' . Lang::t('_CERTIFICATE', 'menu') . '</em></a></li>
					<li' . ($selected_tab == 'meta' ? ' class="selected"' : '') . '><a href="#meta"><em>' . Lang::t('_TITLE_META_CERTIFICATE', 'certificate') . '</em></a></li>
			</ul>
			<div class="yui-content">
					<div>' . $html_cert . '</div>
					<div>' . $html_meta . '</div>
			</div>
		</div>';
    $html .= '</div>';
    //close std_block div
    cout($html, 'content');
    YuiLib::load('tabs');
    cout('<script type="text/javascript">var myTabs = new YAHOO.widget.TabView("mycertificate_tabs");</script>', 'scripts');
}
Exemplo n.º 21
0
 function _get_games_query($type = 'html', $report_data = NULL, $other = '')
 {
     require_once dirname(__FILE__) . '/report_tableprinter.php';
     if ($report_data == NULL) {
         $ref =& $_SESSION['report_tempdata'];
     } else {
         $ref =& $report_data;
     }
     $_ERR_NOUSER = Lang::t('_EMPTY_SELECTION', 'report');
     $_ERR_NOCOMP = Lang::t('_EMPTY_SELECTION', 'report');
     $_ERR_NODATA = Lang::t('_NO_CONTENT', 'report');
     require_once _lms_ . '/lib/lib.report.php';
     $lang_type = _getLOtranslations();
     $sel_all = $ref['rows_filter']['select_all'];
     $arr_selected_users = $ref['rows_filter']['selection'];
     //list of users selected in the filter (users, groups and org.branches)
     $comp_all = $ref['columns_filter']['all_games'];
     $arr_selected_comp = $ref['columns_filter']['comp_selection'];
     //list of communications selected in the filter
     $start_date = substr($ref['columns_filter']['comp_start_date'], 0, 10);
     $end_date = substr($ref['columns_filter']['comp_end_date'], 0, 10);
     //check and validate time period dates
     if (!preg_match('/^(\\d{4})\\D?(0[1-9]|1[0-2])\\D?([12]\\d|0[1-9]|3[01])$/', $start_date) || $start_date == '0000-00-00') {
         $start_date = '';
     }
     if (!preg_match('/^(\\d{4})\\D?(0[1-9]|1[0-2])\\D?([12]\\d|0[1-9]|3[01])$/', $end_date) || $end_date == '0000-00-00') {
         $end_date = '';
     }
     if ($start_date != '') {
         $start_date .= ' 00:00:00';
     }
     if ($end_date != '') {
         $end_date .= ' 23:59:59';
     }
     if ($start_date != '' && $end_date != '') {
         if ($start_date > $end_date) {
             //invalid time period
             $start_date = '';
             $end_date = '';
         }
     }
     //instantiate acl manager
     $acl_man = new DoceboACLManager();
     $acl_man->include_suspended = true;
     //extract user idst from selection
     if ($sel_all) {
         $arr_selected_users = $acl_man->getAllUsersIdst();
     } else {
         $arr_selected_users = $acl_man->getAllUsersFromIdst($arr_selected_users);
     }
     //admin users filter
     $userlevelid = Docebo::user()->getUserLevelId();
     if ($userlevelid != ADMIN_GROUP_GODADMIN && !Docebo::user()->isAnonymous()) {
         require_once _base_ . '/lib/lib.preference.php';
         $adminManager = new AdminPreference();
         $admin_tree = $adminManager->getAdminTree(Docebo::user()->getIdST());
         $admin_users = $acl_man->getAllUsersFromIdst($admin_tree);
         $admin_users = array_unique($admin_users);
         //filter users selection by admin visible users
         $arr_selected_users = array_intersect($arr_selected_users, $admin_users);
         //free some memory
         unset($admin_tree);
         unset($admin_users);
         unset($adminManager);
     }
     //Has the "All games" options been selected ?
     if ($comp_all) {
         $query = "SELECT id_game FROM %lms_games";
         $res = $this->db->query($query);
         $arr_selected_comp = array();
         while (list($id_game) = $this->db->fetch_row($res)) {
             $arr_selected_comp[] = $id_game;
         }
     }
     //check selected users ...
     //$arr_selected_users = array(); //list of users selected in the filter (users, groups and org.branches)
     if ($arr_selected_users <= 0) {
         cout('<p>' . $_ERR_NOUSER . '</p>');
         return;
     }
     //$arr_selected_comp = array(); //list of communications selected in the filter
     if ($arr_selected_comp <= 0) {
         cout('<p>' . $_ERR_NOCOMP . '</p>');
         return;
     }
     $arr_comp = array();
     //array $id_comm => list of generic idst
     foreach ($arr_selected_comp as $id_game) {
         $arr_comp[$id_game] = array();
     }
     //if no users have been assigned to the games, than display as 0 - 0
     $arr_idst = array();
     //flat list of idst
     $query = "SELECT * FROM %lms_games_access WHERE id_comp IN (" . implode(",", $arr_selected_comp) . ")";
     $res = $this->db->query($query);
     while (list($id_game, $idst) = $this->db->fetch_row($res)) {
         $arr_idst[] = $idst;
         $arr_comp[$id_game][] = $idst;
     }
     if (count($arr_idst) <= 0) {
         cout('<p>' . $_ERR_NOUSER . '</p>');
         return;
     }
     $arr_groups = array();
     //flat list of group idst
     $query = "SELECT idst FROM %adm_group WHERE idst IN (" . implode(",", $arr_idst) . ")";
     $res = $this->db->query($query);
     while (list($idst) = $this->db->fetch_row($res)) {
         $arr_groups[] = $idst;
     }
     //if any group selected, then extract users and create an array [id_group][id_user]
     $arr_idst_users_flat = array();
     $arr_members = array();
     //array $idst group => list of idst
     if (count($arr_groups) > 0) {
         $query = "SELECT idst, idstMember FROM %adm_group_members WHERE " . " idst IN (" . implode(",", $arr_groups) . ")" . " AND idstMember IN (" . implode(",", $arr_selected_users) . ")";
         $res = $this->db->query($query);
         while (list($idst, $idstMember) = $this->db->fetch_row($res)) {
             $arr_members[$idst][] = $idstMember;
             $arr_idst_users_flat[] = $idstMember;
         }
     }
     //set an array with all users idst ($_all)
     $diff = array_diff($arr_selected_users, $arr_groups);
     $_all_users = array_merge($arr_idst_users_flat, $diff);
     unset($diff);
     if (count($_all_users) <= 0) {
         cout('<p>' . $_ERR_NOUSER . '</p>');
         return;
     }
     //users have been extracted by group, now calculate report's rows ----------
     //get games info data and put it in an array by id_game => {info}
     $arr_comp_data = array();
     $query = "SELECT * FROM %lms_games WHERE id_game IN (" . implode(",", $arr_selected_comp) . ")";
     $res = $this->db->query($query);
     while ($obj = $this->db->fetch_obj($res)) {
         $arr_comp_data[$obj->id_game] = array('title' => $obj->title, 'type_of' => $obj->type_of, 'start_date' => $obj->start_date, 'end_date' => $obj->end_date);
     }
     //which selected communication has been seen by selected users?
     $arr_viewed = array();
     $query = "SELECT idReference, COUNT(idUser) as count " . " FROM %lms_games_track WHERE status IN ('completed', 'passed') " . " AND idUser IN (" . implode(",", $_all_users) . ") " . " AND idReference IN (" . implode(",", $arr_selected_comp) . ") " . ($start_date != '' ? " AND dateAttempt >= '" . $start_date . "' " : "") . ($end_date != '' ? " AND dateAttempt <= '" . $end_date . "' " : "") . " GROUP BY idReference";
     $res = $this->db->query($query);
     while ($obj = $this->db->fetch_obj($res)) {
         $arr_viewed[$obj->idReference] = $obj->count;
     }
     //calculate average values, no conditions on the status
     $arr_average = array();
     $query = "SELECT idReference, AVG(current_score) as average_current_score, " . " AVG(max_score) as average_max_score, AVG(num_attempts) as average_num_attempts " . " FROM %lms_games_track WHERE idUser IN (" . implode(",", $_all_users) . ") " . " AND idReference IN (" . implode(",", $arr_selected_comp) . ") " . ($start_date != '' ? " AND dateAttempt >= '" . $start_date . "' " : "") . ($end_date != '' ? " AND dateAttempt <= '" . $end_date . "' " : "") . " GROUP BY idReference";
     $res = $this->db->query($query);
     while ($obj = $this->db->fetch_obj($res)) {
         $arr_average[$obj->idReference] = $obj;
     }
     /*
     		//user details buffer
     		$acl_man = Docebo::user()->getAclManager();
     		$user_details = array();
     		$query = "SELECT idst, userid FROM %adm_user WHERE idst IN (".implode(",", $_all_users).")";
     		$res = $this->db->query($query);
     		while ($obj = $this->db->fetch_obj($res)) {
     			$user_details[$obj->idst] = $acl_man($obj->userid);
     		}
     */
     //set table properties and buffer
     $head = array(Lang::t('_GAMES_TITLE', 'report'), Lang::t('_GAMES_TYPE', 'report'), Lang::t('_FROM', 'standard'), Lang::t('_TO', 'standard'), Lang::t('_GAMES_ATTEMPTED', 'report'), Lang::t('_GAMES_TOTAL', 'report'), Lang::t('_GAMES_PERCENT', 'report'), Lang::t('_GAMES_AVG_SCORE', 'report'), Lang::t('_GAMES_AVG_MAX_SCORE', 'report'), Lang::t('_GAMES_AVG_NUM_ATTEMPTS', 'report'));
     $buffer = new ReportTablePrinter();
     $buffer->openTable('', '');
     $buffer->openHeader();
     $buffer->addHeader($head);
     $buffer->closeHeader();
     $buffer->openBody();
     //rows cycle
     foreach ($arr_comp as $id_game => $comp_id_list) {
         //calculate total assigned users for every communication
         $count = 0;
         foreach ($comp_id_list as $idst) {
             if (array_key_exists($idst, $arr_members)) {
                 foreach ($arr_members[$idst] as $idst_user) {
                     $count++;
                 }
             } else {
                 $count++;
             }
         }
         //line (one per communication)
         $line = array();
         $type_of = $arr_comp_data[$id_game]['type_of'];
         $completed_by = isset($arr_viewed[$id_game]) ? $arr_viewed[$id_game] : 0;
         $line[] = $arr_comp_data[$id_game]['title'];
         $line[] = isset($lang_type[$type_of]) ? $lang_type[$type_of] : '';
         $line[] = Format::date($arr_comp_data[$id_game]['start_date'], 'date');
         $line[] = Format::date($arr_comp_data[$id_game]['end_date'], 'date');
         $line[] = $completed_by;
         $line[] = $count;
         $line[] = number_format(($count > 0 ? $completed_by / $count : 0) * 100, 2, ',', '') . ' %';
         $avg1 = isset($arr_average[$id_game]) ? $arr_average[$id_game]->average_current_score : '';
         $avg2 = isset($arr_average[$id_game]) ? $arr_average[$id_game]->average_max_score : '';
         $avg3 = isset($arr_average[$id_game]) ? $arr_average[$id_game]->average_num_attempts : '';
         $line[] = number_format($avg1, 2, ',', '.');
         $line[] = number_format($avg2, 2, ',', '.');
         $line[] = number_format($avg3, 2, ',', '.');
         $buffer->addLine($line);
     }
     $buffer->closeBody();
     $buffer->closeTable();
     cout($buffer->get());
 }
 function getModUi($room_info)
 {
     require_once _base_ . '/lib/lib.form.php';
     addJs($GLOBALS['where_lms_relative'] . '/modules/conference/', 'ajax_conference.js');
     $lang =& DoceboLanguage::createInstance('conference', 'lms');
     cout(Form::openForm('create_conference', 'index.php?modname=conference&amp;op=modconf&id=' . $room_info['id']) . Form::openElementSpace() . Form::getTextfield($lang->def('_VIDEOCONFERENCE'), 'conference_name', 'conference_name', 255, $room_info['name']) . Form::getDatefield($lang->def('_START_DATE'), 'start_date', 'start_date', Format::date(date('Y-m-d', $room_info['starttime']), 'date')) . Form::getLineBox($lang->def('_AT_HOUR'), Form::getInputDropdown('', 'start_time_hour', 'start_time[hour]', range(0, 23), importVar('start_time_hour', false, date("H", $room_info['starttime'])), '') . ' : ' . Form::getInputDropdown('', 'start_time_minute', 'start_time[minute]', range(0, 59), importVar('start_time_hour', false, date("i", $room_info['starttime'])), '')) . Form::getLineBox($lang->def('_MEETING_HOURS'), Form::getInputDropdown('', 'meetinghours', 'meetinghours', range(0, 5), $room_info['meetinghours'], '')) . Form::getTextfield($lang->def('_MAX_PARTICIPANTS'), 'maxparticipants', 'maxparticipants', 6, $room_info['maxparticipants']) . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('update_conf', 'update_conf', $lang->def('_UPDATE')) . Form::getButton('undo', 'undo', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm());
 }
Exemplo n.º 23
0
 function loadCoursepathSelector($noprint = false)
 {
     require_once _base_ . '/lib/lib.table.php';
     require_once _base_ . '/lib/lib.form.php';
     $lang =& DoceboLanguage::createInstance('coursepath', 'lms');
     $output = '';
     // Filter
     $this->filter['coursepath_name'] = isset($_POST['coursepath_filter_name']) ? $_POST['coursepath_filter_name'] : '';
     if ($this->show_filter === true) {
         /*
         			$form = new Form();
         			$output .= $form->getOpenFieldset($lang->def('_COURSEPATH_FILTER'))
         				.Form::getTextfield($lang->def('_NAME'), 'coursepath_filter_name', 'coursepath_filter_name', '255',
         					( isset($_POST['coursepath_filter_name']) ? $_POST['coursepath_filter_name'] : '' ))
         				.$form->openButtonSpace()
         				.$form->getButton('coursepath_filter', 'coursepath_filter', $lang->def('_SEARCH'))
         				.$form->closeButtonSpace()
         				.$form->getCloseFieldset();*/
         $output .= '<div class="quick_search_form">' . '<div>' . Form::getInputTextfield("search_t", "coursepath_filter_name", "coursepath_filter_name", Get::req('coursepath_filter_name', DOTY_MIXED, ''), '', 255, '') . Form::getButton("coursepath_filter", "coursepath_filter", Lang::t('_SEARCH', 'standard'), "search_b") . '</div>' . '</div>';
     }
     // End Filter
     $tb = new Table(Get::sett('visuItem'), $lang->def('_COURSE_PATH_CAPTION'), $lang->def('_COURSE_PATH_SUMMARY'));
     $tb->initNavBar('ini_cpath', 'button');
     $ini = $tb->getSelectedElement();
     $select = "\r\n\t\tSELECT id_path, path_name, path_descr ";
     $query_coursepath = "\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_coursepath\r\n\t\tWHERE 1 ";
     if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
         $all_courses = false;
         require_once _base_ . '/lib/lib.preference.php';
         $adminManager = new AdminPreference();
         $admin_courses = $adminManager->getAdminCourse(Docebo::user()->getIdST());
         if (isset($admin_courses['course'][0])) {
             $all_courses = true;
         }
         if (isset($admin_courses['course'][-1])) {
             $query = "SELECT id_path" . " FROM %lms_coursepath_user" . " WHERE idUser = '******'";
             $result = sql_query($query);
             $admin_courses['coursepath'] = array();
             while (list($id_path) = sql_fetch_row($result)) {
                 $admin_courses['coursepath'][$id_path] = $id_path;
             }
             if (!empty($admin_courses['coursepath']) && Get::sett('on_catalogue_empty', 'off') == 'on') {
                 $all_courses = true;
             }
         }
         if (!$all_courses) {
             if (empty($admin_courses['coursepath'])) {
                 $query_coursepath .= " AND 0 ";
             } else {
                 $query_coursepath .= " AND id_path IN (" . implode(',', $admin_courses['coursepath']) . ") ";
             }
         }
     }
     if ($this->filter['coursepath_name'] != '') {
         $query_coursepath .= " AND path_name LIKE '%" . $this->filter['coursepath_name'] . "%'";
     }
     list($tot_coursepath) = sql_fetch_row(sql_query("SELECT COUNT(*) " . $query_coursepath));
     $query_coursepath .= "\r\n\t\tORDER BY path_name\r\n\t\tLIMIT " . $ini . "," . (int) Get::sett('visuItem');
     $re_coursepath = sql_query($select . $query_coursepath);
     $type_h = array('image', '', '', '');
     $cont_h = array('<span class="access-only">' . $lang->def('_SELECT') . '</span>', $lang->def('_NAME'), $lang->def('_DESCRIPTION'));
     $tb->setColsStyle($type_h);
     $tb->addHead($cont_h);
     while (list($id_path, $name, $descr) = sql_fetch_row($re_coursepath)) {
         $tb_content = array(Form::getInputCheckbox('new_coursepath_selected_' . $id_path, 'new_coursepath_selected[' . $id_path . ']', $id_path, isset($this->current_selection[$id_path]), ''), '<label for="new_coursepath_selected_' . $id_path . '">' . $name . '</label>', '<label for="new_coursepath_selected_' . $id_path . '">' . $descr . '</label>');
         $tb->addBody($tb_content);
         if (isset($this->current_selection[$id_path])) {
             unset($this->current_selection[$id_path]);
         }
     }
     $output .= $tb->getTable() . $tb->getNavBar($ini, $tot_coursepath) . $this->stateSelection();
     if ($noprint) {
         return $output;
     } else {
         cout($output, 'content');
     }
 }
Exemplo n.º 24
0
function getInteractionsTable($id_user, $idtrack)
{
    require_once _base_ . '/lib/lib.domxml.php';
    require_once _base_ . '/lib/lib.table.php';
    $tb = new Table(Get::sett('visu_course'));
    $lang = DoceboLanguage::CreateInstance('organization', 'lms');
    $id_org = Get::req('id_org', DOTY_INT, 0);
    $h_type = array('', '', '');
    $h_content = array($lang->def('_DESCRIPTION'), $lang->def('_TYPE'), $lang->def('_RESULT'));
    $tb->setColsStyle($h_type);
    $tb->addHead($h_content);
    $qry = "SELECT xmldata FROM " . $GLOBALS['prefix_lms'] . "_scorm_tracking WHERE idscorm_tracking={$idtrack} AND idUser={$id_user}";
    $res = sql_query($qry);
    $row = mysql_fetch_array($res);
    $doc = new DoceboDOMDocument();
    $doc->loadXML($row['xmldata']);
    $context = new DoceboDOMXPath($doc);
    $root = $doc->documentElement;
    $temp = $context->query('//interactions');
    $lines = array();
    for ($i = 0; $i < $temp->length; $i++) {
        $arr = array();
        $node =& $temp->item($i);
        //interaction index
        //$arr['index'] = $node->getAttribute('index');
        //get description
        $elem = $context->query('description/text()', $node);
        $elemNode =& $elem->item(0);
        if ($elemNode && isset($elemNode->textContent)) {
            $arr['description'] = $elemNode->textContent;
            //get type
            $elem = $context->query('type/text()', $node);
            $elemNode =& $elem->item(0);
            $arr['type'] = $elemNode->textContent;
            //get result
            $elem = $context->query('result/text()', $node);
            $elemNode =& $elem->item(0);
            $arr['result'] = $elemNode->textContent;
            //get id
            $elem = $context->query('id/text()', $node);
            $elemNode =& $elem->item(0);
            $id = $elemNode->textContent;
            if ($arr['result'] == '1') {
                $arr['result'] = 'true';
            } else {
                $arr['result'] = 'false';
            }
            $lines[$id] = array($arr['description'], $arr['type'], $arr['result']);
        }
    }
    foreach ($lines as $key => $line) {
        $tb->addBody($line);
    }
    //title
    cout(getTitleArea($lang->def('_SCORM_INTERACTIONS_TABLE')), 'content');
    cout('<div class="std_block">', 'content');
    //back button, back to treeview
    $back = getBackUi('index.php?modname=organization&amp;op=scorm_track&amp;id_user='******'&amp;id_org=' . $id_org, $lang->def('_BACK_TO_TRACK'));
    //'index.php?modname=organization&amp;op=history&amp;id_user='******'&amp;id_org='.$org , $lang->def('_BACK_TO_TRACK') );
    //back button, back to treeview
    cout($back, 'content');
    cout($tb->getTable(), 'content');
    cout($back, 'content');
    cout('</div>', 'content');
}
Exemplo n.º 25
0
 function loadCatalogueSelector($noprint = false)
 {
     require_once _base_ . '/lib/lib.table.php';
     require_once _base_ . '/lib/lib.form.php';
     $lang =& DoceboLanguage::createInstance('catalogue', 'lms');
     // Filter
     $this->filter['catalogue_name'] = isset($_POST['cat_filter_name']) ? $_POST['cat_filter_name'] : '';
     if ($this->show_filter === true) {
         $form = new Form();
         /*$GLOBALS['page']->add(
         			$form->getOpenFieldset($lang->def('_SEARCH'))
         			.Form::getTextfield($lang->def('_NAME'), 'cat_filter_name', 'cat_filter_name', '255',
         				( isset($_POST['cat_filter_name']) ? $_POST['cat_filter_name'] : '' ))
         			.$form->openButtonSpace()
         			.$form->getButton('catalogue_filter', 'catalogue_filter', $lang->def('_SEARCH'))
         			.$form->closeButtonSpace()
         			.$form->getCloseFieldset()
         		, 'content');
         		*/
         cout('<div class="quick_search_form">' . '<div>' . Form::getInputTextfield("search_t", "cat_filter_name", "cat_filter_name", Get::req('cat_filter_name', DOTY_MIXED, ''), '', 255, '') . Form::getButton("catalogue_filter", "catalogue_filter", Lang::t('_SEARCH', 'standard'), "search_b") . '</div>' . '</div>', 'content');
     }
     // End Filter
     $tb = new Table(Get::sett('visuItem'), $lang->def('_CATALOGUE'), $lang->def('_CATALOGUE_SUMMARY'));
     $tb->initNavBar('ini_cat', 'button');
     $ini = $tb->getSelectedElement();
     $select = "\r\n\t\tSELECT c.idCatalogue, c.name, c.description";
     $query_catalogue = "\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_catalogue AS c\r\n\t\tWHERE 1";
     // Retriving data
     if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
         $all_courses = false;
         require_once _base_ . '/lib/lib.preference.php';
         $adminManager = new AdminPreference();
         $admin_courses = $adminManager->getAdminCourse(Docebo::user()->getIdST());
         if (isset($admin_courses['course'][0])) {
             $all_courses = true;
         }
         if (isset($admin_courses['course'][-1])) {
             require_once _lms_ . '/lib/lib.catalogue.php';
             $cat_man = new Catalogue_Manager();
             $admin_courses['catalogue'] = $cat_man->getUserAllCatalogueId(Docebo::user()->getIdSt());
             if (count($admin_courses['catalogue']) == 0 && Get::sett('on_catalogue_empty', 'off') == 'on') {
                 $all_courses = true;
             }
         }
         if (!$all_courses) {
             if (empty($admin_courses['catalogue'])) {
                 $query_catalogue .= " AND 0 ";
             } else {
                 $query_catalogue .= " AND c.idCatalogue IN (0," . implode(',', $admin_courses['catalogue']) . ") ";
             }
         }
     }
     if ($this->filter['catalogue_name'] != '') {
         $query_catalogue .= " AND c.name LIKE '%" . $this->filter['catalogue_name'] . "%'";
     }
     list($tot_catalogue) = sql_fetch_row(sql_query("SELECT COUNT(*) " . $query_catalogue));
     $query_catalogue .= " ORDER BY c.name\r\n\t\t\t\t\t\t\tLIMIT " . $ini . "," . (int) Get::sett('visuItem');
     $re_catalogue = sql_query($select . $query_catalogue);
     $type_h = array('image', '', '', '');
     $cont_h = array('<span class="access-only">' . $lang->def('_CATALOGUE_SELECTION') . '</span>', $lang->def('_NAME'), $lang->def('_DESCRIPTION'));
     $tb->setColsStyle($type_h);
     $tb->addHead($cont_h);
     while (list($id_catalogue, $name, $descr) = sql_fetch_row($re_catalogue)) {
         $tb_content = array(Form::getInputCheckbox('new_catalogue_selected_' . $id_catalogue, 'new_catalogue_selected[' . $id_catalogue . ']', $id_catalogue, isset($this->current_selection[$id_catalogue]), ''), '<label for="new_catalogue_selected_' . $id_catalogue . '">' . $name . '</label>', '<label for="new_catalogue_selected_' . $id_catalogue . '">' . $descr . '</label>');
         $tb->addBody($tb_content);
         if (isset($this->current_selection[$id_catalogue])) {
             unset($this->current_selection[$id_catalogue]);
         }
     }
     $output = $tb->getTable() . $tb->getNavBar($ini, $tot_catalogue) . $this->stateSelection();
     if ($noprint) {
         return $output;
     } else {
         cout($output, 'content');
     }
 }
Exemplo n.º 26
0
function showResult($object_test, $id_param)
{
    if (!checkPerm('view', true, 'organization') && !checkPerm('view', true, 'storage')) {
        die("You can't access");
    }
    require_once _base_ . '/lib/lib.form.php';
    require_once $GLOBALS['where_lms'] . '/class.module/track.test.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.param.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.test.php';
    $lang =& DoceboLanguage::createInstance('test');
    $id_test = $object_test->getId();
    $id_reference = getLoParam($id_param, 'idReference');
    $url_coded = urlencode(serialize($object_test->back_url));
    $id_track = retriveTrack($id_reference, $id_test, Docebo::user()->getIdst());
    if ($id_track === false) {
        $GLOBALS['page']->add(getErrorUi($lang->def('_TEST_TRACK_FAILURE') . getBackUi(Util::str_replace_once('&', '&amp;', $object_test->back_url), $lang->def('_BACK'))), 'content');
    }
    $test_man = new TestManagement($id_test);
    $play_man = new PlayTestManagement($id_test, Docebo::user()->getIdst(), $id_track, $test_man);
    $test_info = $test_man->getTestAllInfo();
    $track_info = $play_man->getTrackAllInfo();
    $previous_page = importVar('previous_page', false, false);
    $new_info = array('last_page_seen' => $previous_page, 'score_status' => 'doing');
    if (isset($_POST['page_to_save']) && ($_POST['page_to_save'] > $track_info['last_page_saved'] || $test_info['mod_doanswer'])) {
        $play_man->storePage($_POST['page_to_save'], $test_info['mod_doanswer']);
        $play_man->closeTrackPageSession($_POST['page_to_save']);
    }
    $now = date('Y-m-d H:i:s');
    $point_do = 0;
    $max_score = 0;
    $num_manual = 0;
    $manual_score = 0;
    $point_do_cat = array();
    $re_visu_quest = sql_query("SELECT idQuest \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_testtrack_quest \r\n\tWHERE idTrack = '" . $id_track . "' ");
    while (list($id_q) = sql_fetch_row($re_visu_quest)) {
        $quest_see[] = $id_q;
    }
    $reQuest = sql_query("\r\n\tSELECT q.idQuest, q.type_quest, t.type_file, t.type_class, q.idCategory \r\n\tFROM %lms_testquest AS q JOIN " . $GLOBALS['prefix_lms'] . "_quest_type AS t\r\n\tWHERE q.idTest = '" . $id_test . "' AND q.type_quest = t.type_quest AND q.idQuest IN (" . implode($quest_see, ',') . ") \r\n\tORDER BY q.sequence");
    //#2093: Conto le domande
    $tot_questions = 0;
    $tot_answers = 0;
    $tot_rightanswers = 0;
    $tot_questions = $test_man->getNumberOfQuestion();
    while (list($id_quest, $type_quest, $type_file, $type_class, $id_cat) = sql_fetch_row($reQuest)) {
        require_once $GLOBALS['where_lms'] . '/modules/question/' . $type_file;
        $quest_point_do = 0;
        $quest_obj = new $type_class($id_quest);
        $quest_point_do = $quest_obj->userScore($id_track);
        $quest_max_score = $quest_obj->getMaxScore();
        if ($quest_obj->getScoreSetType() == 'manual') {
            ++$num_manual;
            $manual_score = round($manual_score + $quest_max_score, 2);
        }
        //#2093: Conto le risposte, conto le risposte corrette
        $tot_answers++;
        if ($quest_point_do == $quest_max_score) {
            $tot_rightanswers++;
        }
        $point_do = round($point_do + $quest_point_do, 2);
        $max_score = round($max_score + $quest_max_score, 2);
        if (isset($point_do_cat[$id_cat])) {
            $point_do_cat[$id_cat] = round($quest_point_do + $point_do_cat[$id_cat], 2);
        } else {
            $point_do_cat[$id_cat] = round($quest_point_do, 2);
        }
    }
    if ($test_info['point_type'] == '1') {
        // percentage score (%)
        // x:100=$point_do:$max_score
        //#2093: calcolo effettivo solo se ho tutte le risposte
        if ($tot_questions == $tot_answers) {
            $point_do = round(100 * $point_do / $max_score);
            //$max_score$test_info['point_required']
        } else {
            $point_do = round(100 * $tot_rightanswers / $tot_questions);
            //$max_score$test_info['point_required']
        }
    }
    $save_score = $point_do;
    // save new status in track
    if ($point_do >= $test_info['point_required']) {
        $next_status = 'passed';
        if ($test_info['show_only_status']) {
            $score_status = 'passed';
        }
    } else {
        $next_status = 'failed';
        if ($test_info['show_only_status']) {
            $score_status = 'not_passed';
        }
    }
    if (!$test_info['show_only_status']) {
        if ($num_manual != 0) {
            $score_status = 'not_checked';
        } else {
            $score_status = 'valid';
        }
    }
    $test_track = new Track_Test($id_track);
    $test_track->setDate($now);
    $test_track->status = $next_status;
    $test_track->update();
    // --
    require_once _lms_ . '/lib/lib.assessment_rule.php';
    $score_arr = array();
    $i = 0;
    foreach ($point_do_cat as $cat_id => $score) {
        $score_arr[$i]['score'] = $score;
        $score_arr[$i]['category_id'] = $cat_id;
        $i++;
    }
    // final score:
    $score_arr[$i]['score'] = $point_do;
    $score_arr[$i]['category_id'] = 0;
    $asrule = new AssessmentRuleManager($id_test);
    $feedback_txt = $asrule->setRulesFromScore($score_arr);
    $asrule->loadJs();
    // --
    $GLOBALS['page']->add(getTitleArea($lang->def('_TITLE') . ' : ' . $test_info['title'], 'test', $lang->def('_TEST_INFO')) . '<div class="std_block">' . ($next_status == 'failed' ? '<b>' . $lang->def('_TEST_FAILED') . '</b>' : $lang->def('_TEST_COMPLETED')) . '<br />', 'content');
    if ($test_info['point_type'] != '1') {
        $save_score = $point_do;
    } else {
        $save_score = $point_do;
        //round(round($point_do / $max_score, 2) * 100, 2);
    }
    $track_info = Track_Test::getTrackInfo(Docebo::user()->getIdst(), $id_test, $id_reference);
    if ($score_status == 'valid' || $score_status == 'not_checked' || $score_status == 'passed' || $score_status == 'not_passed') {
        $new_info['date_end_attempt'] = $now;
        $new_info['number_of_save'] = $track_info['number_of_save'] + 1;
        $new_info['score'] = $save_score;
        $new_info['score_status'] = $score_status;
        $new_info['number_of_attempt'] = $track_info['number_of_attempt'] + 1;
        $re_update = Track_Test::updateTrack($id_track, $new_info);
        if (!isset($_POST['show_review'])) {
            $time = fromDatetimeToTimestamp(date('Y-m-d H:i:s')) - fromDatetimeToTimestamp($_SESSION['test_date_begin']);
            sql_query("\r\n            INSERT INTO " . $GLOBALS['prefix_lms'] . "_testtrack_times\r\n            (idTrack, idReference, idTest, date_attempt, number_time, score, score_status, date_begin, date_end, time) VALUES\r\n            ('" . $id_track . "', '" . $id_reference . "', '" . $id_test . "', now(), '" . $new_info['number_of_save'] . "', '" . $new_info['score'] . "', '" . $new_info['score_status'] . "', '" . $_SESSION['test_date_begin'] . "', '" . date('Y-m-d H:i:s') . "', '" . $time . "')");
            unset($_SESSION['test_date_begin']);
        }
    }
    //--- check suspension conditions ----------------------------------------------
    if ($test_info['use_suspension']) {
        $suspend_info = array();
        if ($next_status == 'failed') {
            $suspend_info['attempts_for_suspension'] = $track_info['attempts_for_suspension'] + 1;
            if ($suspend_info['attempts_for_suspension'] >= $test_info['suspension_num_attempts'] && $test_info['suspension_num_hours'] > 0) {
                //should we reset learning_test.suspension_num_attempts ??
                $suspend_info['attempts_for_suspension'] = 0;
                //from now on, it uses the suspended_until parameter, so only the date is needed, we can reset the attempts count
                $suspend_info['suspended_until'] = date("Y-m-d H:i:s", time() + $test_info['suspension_num_hours'] * 3600);
            }
            //if num_hours is <= 0, never update attempts counter, so user won't never be de-suspended
            $re = Track_Test::updateTrack($id_track, $suspend_info);
        } else {
            if ($next_status == 'completed' || $next_status == 'passed') {
                $suspend_info['attempts_for_suspension'] = 0;
                $re = Track_Test::updateTrack($id_track, $suspend_info);
            }
        }
    }
    //--- end suspensions check ----------------------------------------------------
    list($bonus_score, $score_status) = sql_fetch_row(sql_query("\r\n\tSELECT bonus_score, score_status\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_testtrack \r\n\tWHERE idTrack = '" . (int) $id_track . "'"));
    if ($test_info['show_score'] && $test_info['point_type'] != '1') {
        //$GLOBALS['page']->add('<span class="test_score_note">'.$lang->def('_TEST_TOTAL_SCORE').'</span> '.($point_do + $bonus_score).' / '.$max_score.'<br />', 'content');
        $GLOBALS['page']->add('<span class="test_score_note">' . $lang->def('_TEST_TOTAL_SCORE') . '</span> ' . ($point_do + $bonus_score) . ' / 100<br />', 'content');
        if ($num_manual != 0 && $score_status != 'valid') {
            $GLOBALS['page']->add('<br />' . '<span class="test_score_note">' . $lang->def('_TEST_MANUAL_SCORE') . '</span> ' . $manual_score . ' ' . $lang->def('_TEST_SCORES') . '<br />', 'content');
        }
        if ($test_info['point_required'] != 0) {
            $GLOBALS['page']->add('<br />' . '<span class="test_score_note">' . $lang->def('_TEST_REQUIREDSCORE_RESULT') . '</span> ' . $test_info['point_required'] . '<br />', 'content');
        }
    }
    if ($test_info['show_score'] && $test_info['point_type'] == '1') {
        $GLOBALS['page']->add('<span class="test_score_note">' . $lang->def('_TEST_TOTAL_SCORE') . '</span> ' . $save_score . ' %' . '<br />', 'content');
        if ($num_manual != 0) {
            $GLOBALS['page']->add('<br />' . '<span class="test_score_note">' . $lang->def('_TEST_MANUAL_SCORE') . '</span> ' . $manual_score . ' ' . $lang->def('_TEST_SCORES') . '<br />', 'content');
        }
    }
    if ($test_info['show_score_cat']) {
        $re_category = sql_query("\r\n\t\tSELECT c.idCategory, c.name, COUNT(q.idQuest)\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_testquest AS q \r\n\t\t\tJOIN " . $GLOBALS['prefix_lms'] . "_quest_category AS c\r\n\t\tWHERE c.idCategory = q.idCategory AND q.idTest = '" . $id_test . "' AND q.idCategory != 0 \r\n\t\tGROUP BY c.idCategory \r\n\t\tORDER BY c.name");
        if (sql_num_rows($re_category)) {
            $GLOBALS['page']->add('<br />' . '<table summary="' . $lang->def('_TEST_CATEGORY_SCORE') . '" class="category_score">' . '<caption>' . $lang->def('_TEST_CATEGORY_SCORE') . '</caption>' . '<thead>' . '<tr>' . '<th>' . $lang->def('_TEST_QUEST_CATEGORY') . '</th>' . '<th class="number">' . $lang->def('_TEST_QUEST_NUMBER') . '</th' . '<th class="number">' . $lang->def('_TEST_TOTAL_SCORE') . '</th>' . '</tr>' . '</thead>' . '<tbody>', 'content');
            while (list($id_cat, $name_cat, $quest_number) = sql_fetch_row($re_category)) {
                $GLOBALS['page']->add('<tr><td>' . $name_cat . '</td>' . '<td class="number">' . $quest_number . '</td>' . '<td class="number">' . (isset($point_do_cat[$id_cat]) ? $point_do_cat[$id_cat] : 0) . '</td></tr>', 'content');
            }
            /*
            $GLOBALS['page']->add('<br />'
            	.'<span class="test_score_note">'.$lang->def('_TEST_CATEGORY_SCORE').'</span><br />', 'content');
            while(list($id_cat, $name_cat, $quest_number) = sql_fetch_row($re_category)) {
            	
            	$GLOBALS['page']->add($name_cat.', '.$lang->def('_TEST_SCORES').': '
            		.( isset($point_do_cat[$id_cat]) ? $point_do_cat[$id_cat] : 0 ).'<br />', 'content');
            }
            */
            $GLOBALS['page']->add('</tbody></table>', 'content');
        }
    }
    $GLOBALS['page']->add('<br /><br />', 'content');
    //--- if chart visualization enabled, then show it ---------------------------
    require_once _base_ . '/lib/lib.json.php';
    $json = new Services_JSON();
    if ($test_info['chart_options'] !== "") {
        $chart_options = $json->decode($test_info['chart_options']);
    } else {
        $chart_options = new stdClass();
    }
    if (!property_exists($chart_options, 'use_charts')) {
        $chart_options->use_charts = false;
    }
    if (!property_exists($chart_options, 'selected_chart')) {
        $chart_options->selected_chart = 'column';
    }
    if (!property_exists($chart_options, 'show_chart')) {
        $chart_options->show_chart = 'teacher';
    }
    if ($chart_options->use_charts && $chart_options->show_chart == 'course') {
        cout('<div class="align-center">', 'content');
        $chart = new Test_Charts($test_info['idTest'], Docebo::user()->getIdSt());
        $chart->render($chart_options->selected_chart, true);
        cout('</div><br /><br />', 'content');
    }
    //--- end show chart ---------------------------------------------------------
    if ($feedback_txt) {
        cout('<p>' . $feedback_txt . '</p><br />', 'content');
    }
    $points = $point_do + $bonus_score;
    if ($test_info['show_solution'] == 2 && $points >= $test_info['point_required']) {
        $GLOBALS['page']->add(Form::openForm('test_show', 'index.php?modname=test&amp;op=play') . Form::getHidden('next_step', 'next_step', 'test_review') . Form::getHidden('id_test', 'id_test', $id_test) . Form::getHidden('id_param', 'id_param', $id_param) . Form::getHidden('back_url', 'back_url', $url_coded) . Form::getHidden('idTrack', 'idTrack', $id_track) . Form::getButton('review', 'review', $lang->def('_TEST_REVIEW_ANSWER')) . Form::closeForm(), 'content');
    } elseif ($test_info['show_doanswer'] == 2 && $points >= $test_info['point_required']) {
        $GLOBALS['page']->add(Form::openForm('test_show', 'index.php?modname=test&amp;op=play') . Form::getHidden('next_step', 'next_step', 'test_review') . Form::getHidden('id_test', 'id_test', $id_test) . Form::getHidden('id_param', 'id_param', $id_param) . Form::getHidden('back_url', 'back_url', $url_coded) . Form::getHidden('idTrack', 'idTrack', $id_track) . Form::getButton('review', 'review', $lang->def('_TEST_REVIEW_ANSWER')) . Form::closeForm(), 'content');
    } elseif ($test_info['show_solution'] != 2 && $test_info['show_doanswer'] != 2) {
        if ($test_info['show_solution'] || $test_info['show_doanswer']) {
            $GLOBALS['page']->add(Form::openForm('test_show', 'index.php?modname=test&amp;op=play') . Form::getHidden('next_step', 'next_step', 'test_review') . Form::getHidden('id_test', 'id_test', $id_test) . Form::getHidden('id_param', 'id_param', $id_param) . Form::getHidden('back_url', 'back_url', $url_coded) . Form::getHidden('idTrack', 'idTrack', $id_track) . Form::getButton('review', 'review', $lang->def('_TEST_REVIEW_ANSWER')) . Form::closeForm(), 'content');
        }
    }
    $GLOBALS['page']->add(Form::openForm('test_show', Util::str_replace_once('&', '&amp;', $object_test->back_url)) . '<div class="align_right">' . Form::getButton('end_test', 'end_test', $lang->def('_TEST_END_BACKTOLESSON')) . '</div>' . Form::closeForm(), 'content');
    $GLOBALS['page']->add('</div>', 'content');
}
Exemplo n.º 27
0
<?php

YuiLib::load(array('animation' => 'my_animation', 'container' => 'container-min', 'container' => 'container_core-min'));
cout(Util::get_js(Get::rel_path('lms') . '/views/catalog/catalog.js', true), 'page_head');
require_once _lms_ . '/lib/lib.middlearea.php';
$ma = new Man_MiddleArea();
?>
<script type="text/javascript">
	YAHOO.util.Event.onDOMReady(function() {
		initialize("<?php 
echo Lang::t('_UNDO', 'standard');
?>
");
	});
</script>
<div id="global_conf" class="yui-navset yui-navset-top">
	<ul class="yui-nav">
		<li class="<?php 
echo $active_tab == 'all' ? 'selected' : '';
?>
 first">
			<a href="index.php?r=catalog/allCourse">
				<em><?php 
echo Lang::t('_ALL_COURSES', 'catalogue');
?>
</em>
			</a>
		</li>
		<li class="<?php 
echo $active_tab == 'new' ? 'selected' : '';
?>
Exemplo n.º 28
0
function presence()
{
    checkPerm('view');
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.table.php';
    YuiLib::load();
    Util::get_js(Get::rel_path('lms') . '/admin/views/classroom/classroom.js', true, true);
    $id_date = Get::req('id_date', DOTY_INT, 0);
    $lang =& DoceboLanguage::CreateInstance('admin_date', 'lms');
    $date_man = new DateManager();
    $user_date = $date_man->getUserDateForCourse(getLogUserId(), $_SESSION['idCourse']);
    $date_info = $date_man->getDateInfoForPublicPresence($user_date);
    foreach ($date_info as $info_date) {
        $date_for_dropdown[$info_date['id_date']] = $info_date['code'] . ' - ' . $info_date['name'] . ' (' . Format::date($info_date['date_begin'], 'date') . ')';
    }
    if ($id_date == 0) {
        $id_date = isset($date_info[0]['id_date']) ? $date_info[0]['id_date'] : 0;
    }
    cout(getTitleArea(Lang::t('_ATTENDANCE')) . '<div class="std_block">', 'content');
    if (isset($_POST['save'])) {
        require_once $GLOBALS['where_lms'] . '/lib/lib.date.php';
        $date_man = new DateManager();
        $id_date = Get::req('id_date', DOTY_INT, 0);
        $score_min = Get::req('score_min', DOTY_INT, 0);
        $user = $date_man->getUserForPresence($id_date);
        $day = $date_man->getDateDay($id_date);
        $test_type = $date_man->getTestType($id_date);
        foreach ($user as $id_user => $user_info) {
            $user[$id_user]['score'] = Get::req('score_' . $id_user, DOTY_INT, 0);
            $user[$id_user]['note'] = Get::req('note_' . $id_user, DOTY_MIXED, '');
            $user[$id_user]['day_presence'] = array();
            for ($i = 0; $i < count($day); $i++) {
                $user[$id_user]['day_presence'][$day[$i]['id_day']] = Get::req('date_' . $day[$i]['id_day'] . '_' . $id_user, DOTY_INT, 0);
            }
        }
        if ($date_man->insDatePresence($_SESSION['id_course_date'], $id_date, $user, $day, $score_min)) {
            UIFeedback::info(Lang::t('_ATTENDANCE_SAVED', 'admin_date'));
        } else {
            UIFeedback::error(Lang::t('_ATTENDANCE_SAVED_ERROR', 'admin_date'));
        }
    }
    if ($id_date == 0) {
        cout(Lang::t('_NO_CONTENT', 'admin_date'), 'content');
    } else {
        $user = $date_man->getUserForPresence($id_date);
        $day = $date_man->getDateDay($id_date);
        $test_type = $date_man->getTestType($id_date);
        $user_presence = $date_man->getUserPresenceForDate($id_date);
        $tb = new Table(0, Lang::t('_ATTENDANCE', 'admin_date'), Lang::t('_ATTENDANCE', 'admin_date'));
        $cont_h = array(Lang::t('_USERNAME', 'admin_date'), Lang::t('_FULLNAME', 'admin_date'));
        $type_h = array('', '');
        foreach ($day as $id_day => $day_info) {
            $cont_h[] = Format::date($day_info['date_begin'], 'date') . '<br />' . '<a href="javascript:;" onClick="checkAllDay(' . $id_day . ')">' . Get::img('standard/checkall.png', Lang::t('_CHECK_ALL_DAY', 'presence') . '</a>') . ' ' . '<a href="javascript:;" onClick="unCheckAllDay(' . $id_day . ')">' . Get::img('standard/uncheckall.png', Lang::t('_UNCHECK_ALL_DAY', 'presence') . '</a>');
            $type_h[] = 'align_center';
        }
        $cont_h[] = '';
        $type_h[] = 'img-cell';
        if ($test_type == _DATE_TEST_TYPE_PAPER) {
            $cont_h[] = Lang::t('_SCORE', 'admin_date');
            $type_h[] = 'align_center';
        }
        $cont_h[] = Lang::t('_NOTES', 'admin_date');
        $type_h[] = 'align_center';
        $tb->setColsStyle($type_h);
        $tb->addHead($cont_h);
        cout(Form::openForm('presence_form', 'index.php?modname=presence&amp;op=presence') . Form::openElementSpace() . Form::getDropdown(Lang::t('_SELECT_EDITION', 'admin_date'), 'id_date', 'id_date', $date_for_dropdown, $id_date) . Form::closeElementSpace() . Form::openElementSpace() . ($test_type == 1 ? Form::getTextfield(Lang::t('_MIN_SCORE', 'admin_date'), 'score_min', 'score_min', 255, '') : ''), 'content');
        $array_user_id = array();
        foreach ($user as $id_user => $user_info) {
            reset($day);
            $array_user_id[] = $id_user;
            $cont = array();
            $cont[] = $user_info['userid'];
            $cont[] = $user_info['lastname'] . ' ' . $user_info['firstname'];
            foreach ($day as $id_day => $day_info) {
                if (isset($user_presence[$id_user][substr($day_info['date_begin'], 0, 10)]) && $user_presence[$id_user][substr($day_info['date_begin'], 0, 10)]['presence'] == 1) {
                    $presence = true;
                } elseif (isset($user_presence[$id_user][substr($day_info['date_begin'], 0, 10)]) && $user_presence[$id_user][substr($day_info['date_begin'], 0, 10)]['presence'] == 0) {
                    $presence = false;
                } else {
                    $presence = false;
                }
                $cont[] = Form::getInputCheckbox('date_' . $id_day . '_' . $id_user, 'date_' . $id_day . '_' . $id_user, 1, $presence, false);
            }
            $cont[] = '<a href="javascript:;" onClick="checkAllUser(' . $id_user . ')">' . Get::img('standard/checkall.png', Lang::t('_CHECK_ALL_USER', 'presence') . '</a>') . '<br />' . '<a href="javascript:;" onClick="unCheckAllUser(' . $id_user . ')">' . Get::img('standard/uncheckall.png', Lang::t('_UNCHECK_ALL_USER', 'presence') . '</a>');
            if ($test_type == _DATE_TEST_TYPE_PAPER) {
                if (isset($user_presence[$id_user]['0000-00-00']) && $user_presence[$id_user]['0000-00-00']['presence'] == 1) {
                    $passed = true;
                } else {
                    $passed = false;
                }
                $cont[] = Form::getTextfield('', 'score_' . $id_user, 'score_' . $id_user, 255, isset($user_presence[$id_user]['0000-00-00']['score']) ? $user_presence[$id_user]['0000-00-00']['score'] : '0');
            }
            $cont[] = Form::getSimpleTextarea('', 'note_' . $id_user, 'note_' . $id_user, isset($user_presence[$id_user]['0000-00-00']['note']) ? $user_presence[$id_user]['0000-00-00']['note'] : '', false, false, false, 2);
            $tb->addBody($cont);
        }
        cout($tb->getTable() . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('save', 'save', Lang::t('_SAVE', 'admin_date')) . Form::closeElementSpace() . Form::closeForm() . '</div>', 'content');
        cout('<script type="text/javascript">' . 'var _MIN_SCORE_NOT_SET = "' . Lang::t('_MIN_SCORE_NOT_SET', 'admin_date') . '";' . 'YAHOO.util.Event.addListener("save", "click", controlMinScore);' . 'YAHOO.util.Event.addListener("id_date", "change", formSubmit);' . 'function checkAllDay(id_day)
{
	var days = YAHOO.util.Selector.query(\'input[id*=_\' + id_day + \'_]\');
	var i;

	for(i = 0; i < days.length; i++)
		days[i].checked = true;
}

function unCheckAllDay(id_day)
{
	var days = YAHOO.util.Selector.query(\'input[id*=_\' + id_day + \'_]\');
	var i;

	for(i = 0; i < days.length; i++)
		days[i].checked = false;
}

function checkAllUser(id_user)
{
	var days = YAHOO.util.Selector.query(\'input[id*=_\' + id_user + \']\');
	var i;

	for(i = 0; i < days.length; i++)
		days[i].checked = true;
}

function unCheckAllUser(id_user)
{
	var days = YAHOO.util.Selector.query(\'input[id*=_\' + id_user + \']\');
	var i;

	for(i = 0; i < days.length; i++)
		days[i].checked = false;
}' . '</script>', 'content');
    }
    cout('</div>', 'content');
}
Exemplo n.º 29
0
    // quick jump
    cout('<li class="yuimenuitem">' . '<a href="' . $GLOBALS['where_lms_relative'] . '">' . '<span class="admmenu_goto">' . $lang->def('_JUMP_TO_PLATFORM', 'menu', 'framework') . ' ' . $lang->def('_LMS', 'platform') . '</span>' . '</a>', 'menu_over');
    /*
    	cout('<div id="jumpto" class="yuimenu"><div class="bd"><ul>', 'menu_over');
    	foreach($platforms as $p_code => $p_name) {
    
    		if($p_code != 'scs' && $p_code != 'ecom' && $p_code != 'framework') {
    			
    			cout('<li class="yuimenuitem">'.
    				'<a href="'.$GLOBALS['where_'.$p_code.'_relative'].'">'.
    					$p_name.
    				'</a>'.
    				'</li>'
    			, 'menu_over');
    		}
    	}
    	cout('</ul></div></div>', 'menu_over');*/
    cout('</li>', 'menu_over');
    // add logout voice
    /*
    	cout('<li class="yuimenuitem">'.
    		'<a href="index.php?modname=login&amp;op=logout">'.
    			//Get::img('menu/logout.png', '.:', 'icon').' '.
    			'<span class="admmenu_logout">'. Lang::t('_LOGOUT', 'menu', 'framework').'</span>'.
    		'</a>'.
    		'</li>',
    	'menu_over');*/
    cout('</ul></div></div>', 'menu_over');
    // script needed in order to render the menu
    cout('<script type="text/javascript">' . "\n" . "// Initialize and render the MenuBar when it is available in the page" . "\n" . "YAHOO.util.Event.onContentReady('main_menu_container', function () {" . "\n" . "\tvar oMenuBar = new YAHOO.widget." . (Lang::direction() == 'rtl' ? 'MenuBarRtl' : 'MenuBar') . "('main_menu_container', {" . "\n" . "\t\tmaxheight : 600,minscrollheight : 550,lazyload : true" . "\n" . "\t});" . "\n" . "oMenuBar.render();" . "\n" . "});" . "\n" . "" . '</script>', 'scripts');
}
Exemplo n.º 30
0
 function _get_games_query($type = 'html', $report_data = NULL, $other = '')
 {
     require_once dirname(__FILE__) . '/report_tableprinter.php';
     if ($report_data == NULL) {
         $ref =& $_SESSION['report_tempdata'];
     } else {
         $ref =& $report_data;
     }
     $_ERR_NOUSER = Lang::t('_EMPTY_SELECTION', 'report');
     $_ERR_NOCOMP = Lang::t('_EMPTY_SELECTION', 'report');
     $_ERR_NODATA = Lang::t('_NO_CONTENT', 'report');
     //LO object types translations
     require_once _lms_ . '/lib/lib.report.php';
     $lang_type = _getLOtranslations();
     $sel_all = $ref['rows_filter']['all_users'];
     $arr_selected_users = $ref['rows_filter']['users'];
     //list of users selected in the filter (users, groups and org.branches)
     $comp_all = isset($ref['columns_filter']['all_games']) ? $ref['columns_filter']['all_games'] : false;
     $arr_selected_comp = isset($ref['columns_filter']['comp_selection']) ? $ref['columns_filter']['comp_selection'] : array();
     //list of communications selected in the filter
     $start_date = isset($ref['columns_filter']['comp_start_date']) ? substr($ref['columns_filter']['comp_start_date'], 0, 10) : '';
     $end_date = isset($ref['columns_filter']['comp_end_date']) ? substr($ref['columns_filter']['comp_end_date'], 0, 10) : '';
     //check and validate time period dates
     if (!preg_match('/^(\\d{4})\\D?(0[1-9]|1[0-2])\\D?([12]\\d|0[1-9]|3[01])$/', $start_date) || $start_date == '0000-00-00') {
         $start_date = '';
     }
     if (!preg_match('/^(\\d{4})\\D?(0[1-9]|1[0-2])\\D?([12]\\d|0[1-9]|3[01])$/', $end_date) || $end_date == '0000-00-00') {
         $end_date = '';
     }
     if ($start_date != '') {
         $start_date .= ' 00:00:00';
     }
     if ($end_date != '') {
         $end_date .= ' 23:59:59';
     }
     if ($start_date != '' && $end_date != '') {
         if ($start_date > $end_date) {
             //invalid time period
             $start_date = '';
             $end_date = '';
         }
     }
     //other checkings and validations
     if (!$sel_all && count($selection) <= 0) {
         cout('<p>' . $_ERR_NOUSER . '</p>');
         return;
     }
     $acl_man = new DoceboACLManager();
     $acl_man->include_suspended = true;
     //extract user idst from selection
     if ($sel_all) {
         $arr_selected_users = $acl_man->getAllUsersIdst();
     } else {
         $arr_selected_users = $acl_man->getAllUsersFromIdst($arr_selected_users);
     }
     if ($comp_all) {
         $query = "SELECT id_game FROM %lms_games";
         $res = $this->db->query($query);
         $arr_selected_comp = array();
         while (list($id_game) = $this->db->fetch_row($res)) {
             $arr_selected_comp[] = $id_game;
         }
     }
     //admin users filter
     $userlevelid = Docebo::user()->getUserLevelId();
     if ($userlevelid != ADMIN_GROUP_GODADMIN && !Docebo::user()->isAnonymous()) {
         require_once _base_ . '/lib/lib.preference.php';
         $adminManager = new AdminPreference();
         $admin_tree = $adminManager->getAdminTree(Docebo::user()->getIdST());
         $admin_users = $acl_man->getAllUsersFromIdst($admin_tree);
         $admin_users = array_unique($admin_users);
         //filter users selection by admin visible users
         $arr_selected_users = array_intersect($arr_selected_users, $admin_users);
         //free some memory
         unset($admin_tree);
         unset($admin_users);
         unset($adminManager);
     }
     //check selected users ...
     if (count($arr_selected_users) <= 0) {
         //message: no users selected
         cout('<p>' . $_ERR_NOUSER . '</p>');
         return;
     }
     //check selected communications ...
     if (count($arr_selected_comp) <= 0) {
         //message: no communications selected
         cout('<p>' . $_ERR_NOCOMP . '</p>');
         return;
     }
     //set table properties and buffer
     $head = array(Lang::t('_GAMES_TITLE', 'report'), Lang::t('_GAMES_TYPE', 'report'), Lang::t('_FROM', 'report'), Lang::t('_TO', 'report'), Lang::t('_USER', 'report'), Lang::t('_GAMES_ATTEMPTED', 'report'), Lang::t('_GAMES_ATTEMPT_DATE', 'report'), Lang::t('_GAMES_FIRST_ATTEMPT_DATE', 'report'), Lang::t('_GAMES_CURRENT_SCORE', 'report'), Lang::t('_GAMES_MAX_SCORE', 'report'), Lang::t('_GAMES_NUM_ATTEMPTS', 'report'));
     if ($this->use_mail) {
         $head[] = array('style' => 'img-cell', 'value' => $this->_loadEmailIcon());
     }
     $buffer = new ReportTablePrinter();
     $buffer->openTable('', '');
     $buffer->openHeader();
     $buffer->addHeader($head);
     $buffer->closeHeader();
     $buffer->openBody();
     //rows cycle
     //which selected communication has been seen by selected users?
     $_YES = Lang::t('_YES', 'standard');
     $_NO = Lang::t('_NO', 'standard');
     $arr_viewed = array();
     $query = "SELECT ct.idReference, c.title, c.type_of, c.start_date, c.end_date, ct.status, " . " ct.dateAttempt, ct.firstAttempt, ct.idUser, u.userid, u.firstname, u.lastname, " . " ct.current_score, ct.max_score, ct.num_attempts " . " FROM (%lms_games_track as ct " . " JOIN %lms_games as c ON (ct.idReference=c.id_game)) " . " JOIN %adm_user as u ON (ct.idUser=u.idst) " . " WHERE ct.idUser IN (" . implode(",", $arr_selected_users) . ") " . " AND c.id_game IN (" . implode(",", $arr_selected_comp) . ") " . ($start_date != '' ? " AND ct.dateAttempt >= '" . $start_date . "' " : "") . ($end_date != '' ? " AND ct.dateAttempt <= '" . $end_date . "' " : "") . " ORDER BY c.title, u.userid";
     $res = $this->db->query($query);
     if ($this->db->num_rows($res) <= 0) {
         cout('<p>' . $_ERR_NODATA . '</p>');
         return;
     }
     while ($obj = $this->db->fetch_obj($res)) {
         $line = array();
         $line[] = $obj->title;
         $line[] = isset($lang_type[$obj->type_of]) ? $lang_type[$obj->type_of] : '';
         $line[] = Format::date($obj->start_date, "date");
         $line[] = Format::date($obj->end_date, "date");
         $line[] = $acl_man->relativeId($obj->userid);
         $line[] = $obj->status == 'completed' || $obj->status == 'passed' ? $_YES : $_NO;
         $line[] = Format::date($obj->dateAttempt, "datetime");
         $line[] = Format::date($obj->firstAttempt, "datetime");
         $line[] = $obj->current_score;
         $line[] = $obj->max_score;
         $line[] = $obj->num_attempts;
         if ($this->use_mail) {
             $line[] = '<div class="align_center">' . Form::getInputCheckbox('mail_' . $obj->idUser, 'mail_recipients[]', $obj->idUser, isset($_POST['select_all']), '') . '</div>';
         }
         $buffer->addLine($line);
     }
     $buffer->closeBody();
     $buffer->closeTable();
     cout($buffer->get());
     $this->_loadEmailActions();
 }