예제 #1
0
 function getSubstitution()
 {
     $subs = array();
     $aclman =& Docebo::user()->getAclManager();
     $user = $aclman->getUser($this->id_user, false);
     $subs['[display_name]'] = $user[ACL_INFO_LASTNAME] . $user[ACL_INFO_FIRSTNAME] ? $user[ACL_INFO_LASTNAME] . ' ' . $user[ACL_INFO_FIRSTNAME] : $aclman->relativeId($user[ACL_INFO_USERID]);
     $subs['[username]'] = $aclman->relativeId($user[ACL_INFO_USERID]);
     $subs['[firstname]'] = $user[ACL_INFO_FIRSTNAME];
     $subs['[lastname]'] = $user[ACL_INFO_LASTNAME];
     //variable fields
     require_once $GLOBALS['where_framework'] . '/lib/lib.field.php';
     $temp = new FieldList();
     $fields = $temp->getFlatAllFields();
     foreach ($fields as $key => $value) {
         $subs['[userfield_' . $key . ']'] = $temp->showFieldForUser($this->id_user, $key);
     }
     return $subs;
 }
예제 #2
0
 function get_LO_filter()
 {
     //addCss('style_filterbox');
     $back_url = $this->back_url;
     $jump_url = $this->jump_url;
     $next_url = $this->next_url;
     require_once _base_ . '/lib/lib.form.php';
     require_once _lms_ . '/lib/lib.course.php';
     $ref =& $_SESSION['report_tempdata']['columns_filter'];
     YuiLib::load();
     Util::get_js(Get::rel_path('lms') . '/admin/modules/report/courses_filter.js', true, true);
     //back to columns category selection
     if (isset($_POST['undo_filter'])) {
         //go back at the previous step
         Util::jump_to($back_url);
     }
     //set $_POST data in $_SESSION['report_tempdata']
     $selector = new Selector_Course();
     if (isset($_POST['update_tempdata'])) {
         $selector->parseForState($_POST);
         $temp = array('all_courses' => $_POST['all_courses'] == 1 ? true : false, 'selected_courses' => $selector->getSelection(), 'lo_types' => isset($_POST['lo_types']) ? $_POST['lo_types'] : array(), 'lo_milestones' => isset($_POST['lo_milestones']) ? $_POST['lo_milestones'] : array(), 'showed_columns' => isset($_POST['cols']) ? $_POST['cols'] : array(), 'custom_fields' => array(), 'order_by' => Get::req('order_by', DOTY_STRING, 'userid'), 'order_dir' => Get::req('order_dir', DOTY_STRING, 'asc'), 'show_suspended' => Get::req('show_suspended', DOTY_INT, 0) > 0);
         foreach ($ref['custom_fields'] as $val) {
             $temp['custom_fields'][] = array('id' => $val['id'], 'label' => $val['label'], 'selected' => isset($_POST['custom'][$val['id']]) ? true : false);
         }
         $_SESSION['report_tempdata']['columns_filter'] = $temp;
     } else {
         //first loading of this page -> prepare $_SESSION data structure
         //if (isset($_SESSION['report_update']) /* && is equal to id_report */) break;
         //get users' custom fields
         require_once _adm_ . '/lib/lib.field.php';
         $fman = new FieldList();
         $fields = $fman->getFlatAllFields();
         $custom = array();
         foreach ($fields as $key => $val) {
             $custom[] = array('id' => $key, 'label' => $val, 'selected' => false);
         }
         if (!isset($_SESSION['report_tempdata']['columns_filter'])) {
             $_SESSION['report_tempdata']['columns_filter'] = array('all_courses' => false, 'selected_courses' => $selector->getSelection(), 'lo_types' => array(), 'lo_milestones' => array(), 'showed_columns' => array(), 'custom_fields' => $custom, 'order_by' => 'userid', 'order_dir' => 'asc', 'show_suspended' => 'show_suspended');
         }
     }
     //filter setting done, go to next step
     if (isset($_POST['import_filter']) || isset($_POST['show_filter']) || isset($_POST['pre_filter'])) {
         $temp_url = $next_url;
         if (isset($_POST['pre_filter'])) {
             $temp_url .= '&show=1&nosave=1';
         }
         if (isset($_POST['show_filter'])) {
             $temp_url .= '&show=1';
         }
         Util::jump_to($temp_url);
     }
     cout(Form::getHidden('update_tempdata', 'update_tempdata', 1), 'content');
     $lang = $this->lang;
     //box for direct course selection
     $selection =& $ref['selected_courses'];
     $selector->parseForState($_POST);
     $selector->resetSelection($selection);
     $temp = count($selection);
     $box = new ReportBox('course_selector');
     $box->title = Lang::t('_REPORT_COURSE_SELECTION', 'report');
     $box->description = false;
     $box->body .= '<div class="fc_filter_line filter_corr">';
     $box->body .= '<input id="all_courses" name="all_courses" type="radio" value="1" ' . ($ref['all_courses'] ? 'checked="checked"' : '') . ' />';
     $box->body .= ' <label for="all_courses">' . $lang->def('_ALL_COURSES') . '</label>';
     $box->body .= ' <input id="sel_courses" name="all_courses" type="radio" value="0" ' . ($ref['all_courses'] ? '' : 'checked="checked"') . ' />';
     $box->body .= ' <label for="sel_courses">' . $lang->def('_SEL_COURSES') . '</label>';
     $box->body .= '</div>';
     $box->body .= '<div id="selector_container"' . ($ref['all_courses'] ? ' style="display:none"' : '') . '>';
     //$box->body .= Form::openElementSpace();
     $box->body .= $selector->loadCourseSelector(true);
     //$box->body .= Form::closeElementSpace();
     $box->body .= '<br /></div>';
     $box->footer = $lang->def('_CURRENT_SELECTION') . ':&nbsp;<span id="csel_foot">' . ($ref['all_courses'] ? Lang::t('_ALL', 'standard') : ($temp != '' ? $temp : '0')) . '</span>';
     //.'</div>';
     cout($box->get(), 'content');
     cout('<script type="text/javascript">courses_count=' . ($temp == '' ? '0' : $temp) . ';' . 'courses_all="' . Lang::t('_ALL', 'standard') . '";' . "\n" . 'YAHOO.util.Event.addListener(window, "load", courses_selector_init);</script>', 'page_head');
     $box = new ReportBox('lo_selection');
     $box->title = $lang->def('_SELECT_LO_OPTIONS');
     //LO columns selection
     $lo_trans = $this->getLOTypesTranslations();
     $box->body .= Form::getOpenFieldset(Lang::t('_RU_LO_TYPES', 'report'), 'lotypes_fieldset');
     $res = sql_query("SELECT * FROM %lms_lo_types");
     while ($row = mysql_fetch_assoc($res)) {
         $trans = isset($lo_trans[$row['objectType']]) ? $lo_trans[$row['objectType']] : "";
         $box->body .= Form::getCheckBox($trans, 'lo_type_' . $row['objectType'], 'lo_types[' . $row['objectType'] . ']', $row['objectType'], in_array($row['objectType'], $ref['lo_types']) ? true : false);
     }
     $box->body .= Form::getCloseFieldset();
     $box->body .= Form::getOpenFieldset($lang->def('_RU_LO_MILESTONES'), 'lomilestones_fieldset');
     $box->body .= Form::getCheckBox($lang->def('_NONE'), 'lo_milestone_0', 'lo_milestones[]', _MILESTONE_NONE, in_array(_MILESTONE_NONE, $ref['lo_milestones']) ? true : false);
     $box->body .= Form::getCheckBox($lang->def('_START'), 'lo_milestone_1', 'lo_milestones[]', _MILESTONE_START, in_array(_MILESTONE_START, $ref['lo_milestones']) ? true : false);
     $box->body .= Form::getCheckBox($lang->def('_END'), 'lo_milestone_2', 'lo_milestones[]', _MILESTONE_END, in_array(_MILESTONE_END, $ref['lo_milestones']) ? true : false);
     $box->body .= Form::getCloseFieldset();
     cout($box->get(), 'content');
     function is_showed($which)
     {
         if (isset($_SESSION['report_tempdata']['columns_filter'])) {
             return in_array($which, $_SESSION['report_tempdata']['columns_filter']['showed_columns']);
         } else {
             return false;
         }
     }
     //box for columns selection
     $arr_fieldset = array('user' => '', 'course' => '', 'lo' => '');
     $box = new ReportBox('columns_selection');
     $box->title = $lang->def('_SELECT_THE_DATA_COL_NEEDED');
     $box->description = false;
     //prepare fieldsets
     foreach ($this->LO_columns as $val) {
         if ($val['select']) {
             $line = Form::getCheckBox($val['label'], 'col_sel_' . $val['key'], 'cols[]', $val['key'], is_showed($val['key']));
             switch ($val['group']) {
                 case 'user':
                     $arr_fieldset['user'] .= $line;
                     break;
                 case 'course':
                     $arr_fieldset['course'] .= $line;
                     break;
                 case 'lo':
                     $arr_fieldset['lo'] .= $line;
                     break;
             }
         } else {
             if ($val['key'] == '_CUSTOM_FIELDS_') {
                 //custom fields
                 if (count($ref['custom_fields']) > 0) {
                     foreach ($ref['custom_fields'] as $key => $val) {
                         $arr_fieldset['user'] .= Form::getCheckBox($val['label'], 'col_custom_' . $val['id'], 'custom[' . $val['id'] . ']', $val['id'], $val['selected']);
                     }
                 }
             }
         }
     }
     //print fieldsets
     foreach ($arr_fieldset as $fid => $fieldset) {
         $ftitle = '';
         switch ($fid) {
             case 'user':
                 $ftitle = Lang::t('_USER_CUSTOM_FIELDS', 'report');
                 break;
             case 'course':
                 $ftitle = Lang::t('_COURSE_FIELDS', 'report');
                 break;
             case 'lo':
                 $ftitle = Lang::t('_LEARNING_OBJECTS', 'standard');
                 break;
         }
         $box->body .= Form::getOpenFieldset($ftitle, 'fieldset_' . $fid . '_fields');
         $box->body .= $fieldset;
         $box->body .= Form::getCloseFieldset();
     }
     cout($box->get(), 'content');
     //other options
     $box = new ReportBox('other_options');
     $box->title = Lang::t('_OTHER_OPTION', 'course');
     $box->description = false;
     $sort_list = array('userid' => Lang::t('_USERID', 'standard'), 'firstname' => Lang::t('_FIRSTNAME', 'standard'), 'lastname' => Lang::t('_LASTNAME', 'standard'), 'email' => Lang::t('_EMAIL', 'standard'), 'course_code' => Lang::t('_COURSE_CODE', 'standard'), 'course_name' => Lang::t('_COURSE_NAME', 'standard'), 'object_title' => Lang::t('_LEARNING_OBJECTS', 'standard'), 'object_type' => Lang::t('_RU_LO_TYPES', 'report'), 'first_attempt' => Lang::t('_LO_COL_FIRSTATT', 'report'), 'last_attempt' => Lang::t('_LO_COL_LASTATT', 'report'));
     $dir_list = array('asc' => Lang::t('_ORD_ASC_TITLE', 'standard'), 'desc' => Lang::t('_ORD_DESC_TITLE', 'standard'));
     $sort_selected = array_key_exists($ref['order_by'], $sort_list) ? $ref['order_by'] : 'userid';
     $dir_selected = array_key_exists($ref['order_dir'], $dir_list) ? $ref['order_dir'] : 'asc';
     $sort_dir_dropdown = Form::getInputDropdown('', 'order_dir', 'order_dir', $dir_list, $dir_selected, '');
     $box->body .= Form::getDropdown(Lang::t('_ORDER_BY', 'standard'), 'order_by', 'order_by', $sort_list, $sort_selected, $sort_dir_dropdown);
     $box->body .= Form::getCheckbox(Lang::t('_SHOW_SUSPENDED', 'organization_chart'), 'show_suspended', 'show_suspended', 1, (bool) $ref['show_suspended']);
     cout($box->get(), 'content');
 }
예제 #3
0
 function _maskTemplateManager()
 {
     require_once _base_ . '/lib/lib.form.php';
     require_once $GLOBALS['where_framework'] . '/lib/lib.field.php';
     require_once _base_ . '/lib/lib.table.php';
     $lang =& DoceboLanguage::createInstance('configuration', 'framework');
     $field_man = new FieldList();
     $html = '';
     if (isset($_POST['save_and_refresh'])) {
         if (!sql_query("\r\n\t\t\tUPDATE " . $this->table . "\r\n\t\t\tSET param_value = '" . $_POST['templ_use_field'] . "'\r\n\t\t\tWHERE pack = 'main' AND param_name = 'templ_use_field'")) {
             $html .= getErrorUi('_ERROR_WHILE_SAVING_NEW_FIELD');
         } else {
             setTemplate($_POST['templ_use_field']);
         }
     }
     $drop_field = array();
     $drop_field = $field_man->getFlatAllFields(false, 'dropdown');
     $drop_field[0] = $lang->def('_NO');
     $html .= Form::getDropdown($lang->def('_TEMPL_USE_FIELD'), 'templ_use_field', 'templ_use_field', $drop_field, Get::sett('templ_use_field'));
     $html .= Form::getButton('save_and_refresh', 'save_and_refresh', $lang->def('_SAVE_AND_REFRESH'));
     if (Get::sett('templ_use_field') != 0) {
         $field_obj =& $field_man->getFieldInstance(Get::sett('templ_use_field'));
         if ($field_obj === NULL) {
             return $html . getErrorUi('_ERROR_WITH_THIS_FIELD');
         }
         $assignement = array();
         $query_template_assigned = "\r\n\t\t\tSELECT ref_id, template_code\r\n\t\t\tFROM " . $GLOBALS['prefix_fw'] . "_field_template\r\n\t\t\tWHERE id_common = '" . Get::sett('templ_use_field') . "'";
         $re_templ_assigned = sql_query($query_template_assigned);
         while (list($ref_id, $template_code) = sql_fetch_row($re_templ_assigned)) {
             $assignement[$ref_id] = $template_code;
         }
         $son_value = $field_obj->getAllSon();
         $template_list = getTemplateList(true);
         $default_template = getDefaultTemplate();
         $tb_son = new Table(0, $lang->def('_ASSIGN_DROPDOWN_VALUE_TEMPLATE'), $lang->def('_ASSIGN_DROPDOWN_VALUE_TEMPLATE_SUMMARY'));
         $cont_h = array($lang->def('_VALUE'), $lang->def('_TEMPLATE_VALUE'));
         $type_h = array('', '');
         $tb_son->setColsStyle($type_h);
         $tb_son->addHead($cont_h);
         while (list($id_son, $drop_son_name) = each($son_value)) {
             $cont = array('<label for="template_selected_' . $id_son . '">' . $drop_son_name . '</label>', Form::getInputDropdown('dropdown', 'template_selected_' . $id_son, 'template_selected[' . $id_son . ']', $template_list, isset($assignement[$id_son]) && isset($template_list[$assignement[$id_son]]) ? $assignement[$id_son] : $default_template, ''));
             $tb_son->addBody($cont);
         }
         $html .= $tb_son->getTable();
     }
     return $html;
 }
예제 #4
0
 public function run()
 {
     $num_tabs = 0;
     $selected_tab = false;
     if ($this->show_fncrole_selector) {
         $num_tabs++;
         $selected_tab = 'fncrole';
     }
     if ($this->show_orgchart_selector) {
         $num_tabs++;
         $selected_tab = 'orgchart';
     }
     if ($this->show_group_selector) {
         $num_tabs++;
         $selected_tab = 'group';
     }
     if ($this->show_user_selector) {
         $num_tabs++;
         $selected_tab = 'user';
     }
     if ($num_tabs <= 0 || !$selected_tab) {
         return;
     }
     //no tabs to display: do nothing
     //set selected tab, if specified a valid one
     $_check_tab = strtolower($this->selected_tab);
     switch ($_check_tab) {
         case 'user':
         case 'group':
         case 'orgchart':
         case 'fncrole':
             $selected_tab = $_check_tab;
             break;
     }
     $_selection = array();
     if (is_array($this->initial_selection) && count($this->initial_selection) > 0) {
         $_selection = $this->util->getInitialSelFromIdst($this->initial_selection);
     }
     //validate tab configuration
     $initial_selection = array('user' => isset($_selection['user']) ? $_selection['user'] : array(), 'group' => isset($_selection['group']) ? $_selection['group'] : array(), 'orgchart' => isset($_selection['orgchart']) ? $this->_filterOrgchartSelection($_selection['orgchart']) : array(), 'fncrole' => isset($_selection['fncrole']) ? $_selection['fncrole'] : array());
     //set view parameters
     $params = array('id' => $this->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, 'selected_tab' => $selected_tab, 'use_form_input' => (bool) $this->use_form_input, 'separate_input' => (bool) $this->separate_input, 'initial_selection' => $initial_selection, 'ajax_url' => '../widget/ajax.widget.php?r=userselector/gettreedata');
     //single tabs specific parameters:
     //--- USER SELECTOR PARAMETERS ---------------------------------------------
     if ($this->show_user_selector) {
         require_once _adm_ . '/lib/lib.field.php';
         $fman = new FieldList();
         $fields = $fman->getFlatAllFields(array('framework', 'lms'));
         $f_list = array('email' => Lang::t('_EMAIL', 'standard'), 'lastenter' => Lang::t('_DATE_LAST_ACCESS', 'profile'), 'register_date' => Lang::t('_DIRECTORY_FILTER_register_date', 'admin_directory'), 'language' => Lang::t('_LANGUAGE', 'standard'), 'level' => Lang::t('_LEVEL', 'standard'));
         $f_list = $f_list + $fields;
         $f_selected = $this->json->decode(Docebo::user()->getPreference('ui.directory.custom_columns'));
         if ($f_selected == false) {
             $f_selected = array('email', 'lastenter', 'register_date');
         }
         $js_arr = array();
         foreach ($f_list as $key => $value) {
             $js_arr[] = $key . ': ' . $this->json->encode($value);
         }
         $f_list_js = '{' . implode(',', $js_arr) . '}';
         require_once _adm_ . '/lib/user_selector/lib.dynamicuserfilter.php';
         $dyn_filter = new DynamicUserFilter("user_dyn_filter");
         $dyn_filter->init();
         $user_config = new stdClass();
         $user_config->num_var_fields = $this->nFields;
         //$this->numVarFields,
         $user_config->fieldlist = $f_list;
         $user_config->fieldlist_js = $f_list_js;
         $user_config->selected = $f_selected;
         $user_config->use_suspended = $this->use_suspended;
         $user_config->show_suspended = false;
         //$this-> _getSuspendedFilter(),
         $user_config->filter_text = "";
         //$this->_getTextFilter();
         $user_config->dynamic_filter = $dyn_filter;
         $params['user_config'] = $user_config;
     }
     //--- GROUP SELECTOR PARAMETERS --------------------------------------------
     if ($this->show_group_selector) {
         //...
     }
     //--- ORGCHART SELECTOR PARAMETERS -----------------------------------------
     if ($this->show_orgchart_selector) {
         $acl_man = Docebo::user()->getACLManager();
         $arr_idst = $acl_man->getArrGroupST(array('/oc_0', '/ocd_0'));
         $orgchart_config = new stdClass();
         $orgchart_config->root_node_id = $arr_idst['/oc_0'] . '_' . $arr_idst['/ocd_0'];
         //$acl_man->getGroupST('oc_0').'_'.$acl_man->getGroupST('ocd_0');
         $orgchart_config->can_select_root = (bool) $this->can_select_root;
         $params['orgchart_config'] = $orgchart_config;
     }
     //--- FNCROLES SELECTOR PARAMETERS -----------------------------------------
     if ($this->show_fncrole_selector) {
         //...
     }
     $this->render('userselector', $params);
 }
예제 #5
0
function coursereport()
{
    checkPerm('view');
    require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.test.php';
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.table.php';
    // XXX: Initializaing
    $lang =& DoceboLanguage::createInstance('coursereport', 'lms');
    $out =& $GLOBALS['page'];
    $out->setWorkingZone('content');
    $included_test = array();
    $view_perm = checkPerm('view', true);
    $mod_perm = checkPerm('mod', true);
    // XXX: Instance management
    $acl_man = Docebo::user()->getAclManager();
    $test_man = new GroupTestManagement();
    $report_man = new CourseReportManager();
    // XXX: Find test from organization
    $org_tests =& $report_man->getTest();
    $tests_info = $test_man->getTestInfo($org_tests);
    // XXX: Find students
    /*
     * $id_students	=& $report_man->getStudentId();
     * $students_info 	=& $acl_man->getUsers($id_students);
     */
    $lang2 =& DoceboLanguage::createInstance('levels', 'lms');
    if (isset($_POST['type_filter'])) {
        $type_filter = $_POST['type_filter'];
    } else {
        $type_filter = false;
    }
    if ($type_filter == "false") {
        $type_filter = false;
    }
    $lev = $type_filter;
    $students = getSubscribedInfo((int) $_SESSION['idCourse'], FALSE, $lev, TRUE, false, false, true);
    $id_students = array_keys($students);
    $students_info =& $acl_man->getUsers($id_students);
    $i = 0;
    /*$students_info=array();
    	foreach( $students as $idst => $user_course_info )
    		$students_info[$idst] =& $acl_man->getUser( $idst, FALSE );
    */
    // XXX: Info for updates
    $query_tot_report = "\r\n\tSELECT COUNT(*)\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_coursereport\r\n\tWHERE id_course = '" . $_SESSION['idCourse'] . "'";
    list($tot_report) = sql_fetch_row(sql_query($query_tot_report));
    $query_tests = "\r\n\tSELECT id_report, id_source\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_coursereport\r\n\tWHERE id_course = '" . $_SESSION['idCourse'] . "' AND source_of = 'test'";
    $re_tests = sql_query($query_tests);
    while (list($id_r, $id_t) = sql_fetch_row($re_tests)) {
        $included_test[$id_t] = $id_t;
        $included_test_report_id[$id_r] = $id_r;
    }
    // XXX: Update if needed
    if ($tot_report == 0) {
        $report_man->initializeCourseReport($org_tests);
    } else {
        if (is_array($included_test)) {
            $test_to_add = array_diff($org_tests, $included_test);
        } else {
            $test_to_add = $org_tests;
        }
        if (is_array($included_test)) {
            $test_to_del = array_diff($included_test, $org_tests);
        } else {
            $test_to_del = $org_tests;
        }
        if (!empty($test_to_add) || !empty($test_to_del)) {
            $report_man->addTestToReport($test_to_add, 1);
            $report_man->delTestToReport($test_to_del);
            $included_test = $org_tests;
        }
    }
    $report_man->updateTestReport($org_tests);
    // XXX: Retrive all colums (test and so), and set it
    $img_mod = '<img src="' . getPathImage() . 'standard/edit.png" alt="' . $lang->def('_MOD') . '" />';
    $type_h = array('line_users');
    $cont_h = array($lang->def('_DETAILS'));
    $a_line_1 = array('');
    $a_line_2 = array('');
    $colums['max_score'] = array($lang->def('_MAX_SCORE'));
    $colums['required_score'] = array($lang->def('_REQUIRED_SCORE'));
    $colums['weight'] = array($lang->def('_WEIGHT'));
    $colums['show_to_user'] = array($lang->def('_SHOW_TO_USER'));
    $colums['use_for_final'] = array($lang->def('_USE_FOR_FINAL'));
    $query_report = "\r\n\tSELECT id_report, title, max_score, required_score, weight, show_to_user, use_for_final, source_of, id_source\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_coursereport\r\n\tWHERE id_course = '" . $_SESSION['idCourse'] . "'\r\n\tORDER BY sequence ";
    $re_report = sql_query($query_report);
    $total_weight = 0;
    $i = 1;
    while ($info_report = sql_fetch_assoc($re_report)) {
        $id = $info_report['id_source'];
        $reports[$info_report['id_report']] = $info_report;
        $reports_id[] = $info_report['id_report'];
        // XXX: set action colums
        $type_h[] = 'min-cell';
        switch ($info_report['source_of']) {
            case "test":
                $title = strip_tags($tests_info[$info_report['id_source']]['title']);
                if (!$mod_perm) {
                    if (!$view_perm) {
                        $my_action = '';
                        $a_line_2[] = '';
                    } else {
                        $my_action = '<a class="ico-sprite subs_chart" href="index.php?modname=coursereport&amp;op=testQuestion&amp;id_test=' . $id . '"><span><span>' . $lang->def('_TQ_LINK') . '</span></a>';
                        $a_line_2[] = '';
                    }
                } else {
                    $my_action = '<a class="ico-sprite subs_mod" href="index.php?modname=coursereport&amp;op=testvote&amp;type_filter=' . $type_filter . '&amp;id_test=' . $id . '"><span><span>' . $lang->def('_EDIT_SCORE') . '</span></a>' . ' <a class="ico-sprite subs_chart" href="index.php?modname=coursereport&amp;op=testQuestion&amp;type_filter=' . $type_filter . '&amp;id_test=' . $id . '"><span><span>' . $lang->def('_TQ_LINK') . '</span></a>';
                    $a_line_2[] = '<a href="index.php?modname=coursereport&amp;op=roundtest&amp;id_test=' . $id . '" ' . 'title="' . $lang->def('_ROUND_TEST_VOTE') . '">' . $lang->def('_ROUND_VOTE') . '</a>';
                }
                break;
            case "scoitem":
                $title = strip_tags($info_report['title']);
                if (!$mod_perm) {
                    $my_action = '';
                    $a_line_2[] = '';
                } else {
                    $my_action = $my_action = '<a class="ico-sprite subs_mod" href="index.php?modname=coursereport&amp;op=modactivityscore&amp;type_filter=' . $type_filter . '&amp;id_report=' . $info_report['id_report'] . '&amp;source_of=' . $info_report['source_of'] . '&amp;id_source=' . $info_report['id_source'] . '"><span><span>' . $lang->def('_CHANGE_ACTIVITY_VOTE') . '</span></a>' . ' <a class="ico-sprite subs_del" href="index.php?modname=coursereport&amp;op=delactivity&amp;id_report=' . $info_report['id_report'] . '"><span><span>' . $lang->def('_DELETE_ACTIVITY_VOTE') . '</span></a>';
                    $a_line_2[] = '<a href="index.php?modname=coursereport&amp;op=roundreport&amp;id_report=' . $info_report['id_report'] . '" ' . 'title="' . $lang->def('_ROUND_ACTIVITY_VOTE_TITLE') . '">' . $lang->def('_ROUND_VOTE') . '</a>';
                }
                break;
            case "activity":
                $title = strip_tags($info_report['title']);
                if (!$mod_perm) {
                    $my_action = '';
                    $a_line_2[] = '';
                } else {
                    $my_action = '<a class="ico-sprite subs_mod" href="index.php?modname=coursereport&amp;op=modactivityscore&amp;type_filter=' . $type_filter . '&amp;id_report=' . $info_report['id_report'] . '&amp;source_of=' . $info_report['source_of'] . '&amp;id_source=' . $info_report['id_source'] . '"><span><span>' . $lang->def('_CHANGE_ACTIVITY_VOTE') . '</span></a>' . ' <a class="ico-sprite subs_del" href="index.php?modname=coursereport&amp;op=delactivity&amp;id_report=' . $info_report['id_report'] . '"><span><span>' . $lang->def('_DELETE_ACTIVITY_VOTE') . '</span></a>';
                    $a_line_2[] = '<a href="index.php?modname=coursereport&amp;op=roundreport&amp;id_report=' . $info_report['id_report'] . '" ' . 'title="' . $lang->def('_ROUND_VOTE') . '">' . $lang->def('_ROUND_VOTE') . '</a>';
                }
                break;
            case "final_vote":
                $title = strip_tags($lang->def('_FINAL_SCORE'));
                $info_report['weight'] = $total_weight;
                if (!$mod_perm) {
                    $my_action = '';
                    $a_line_2[] = '';
                } else {
                    $my_action = '<a class="ico-sprite subs_mod" href="index.php?modname=coursereport&amp;op=finalvote&amp;type_filter=' . $type_filter . '&amp;id_report=' . $info_report['id_report'] . '"><span><span>' . $lang->def('_EDIT_SCORE') . '</span></a>';
                    $a_line_2[] = '' . '<a href="index.php?modname=coursereport&amp;op=redofinal&amp;id_report=' . $info_report['id_report'] . '" ' . 'title="' . $lang->def('_REDO_FINAL_VOTE_TITLE') . '">' . $lang->def('_REDO_FINAL_VOTE') . '</a></li>' . '<br/><a href="index.php?modname=coursereport&amp;op=roundreport&amp;id_report=' . $info_report['id_report'] . '" ' . 'title="' . $lang->def('_ROUND_FINAL_VOTE_TITLE') . '">' . $lang->def('_ROUND_VOTE') . '</a></li>' . '';
                }
                break;
        }
        $top = $title . '<br/>';
        if ($mod_perm) {
            if ($i > 1 && $info_report['source_of'] != 'final_vote') {
                $top .= '<a class="ico-sprite subs_left" href="index.php?modname=coursereport&amp;op=moveleft&amp;id_report=' . $info_report['id_report'] . '"><span><span>' . $lang->def('_MOVE_LEFT') . '</span></a>';
            }
        }
        $top .= $my_action;
        if ($mod_perm) {
            if ($i < $tot_report - 1 && $tot_report > 2) {
                $top .= '<a class="ico-sprite subs_right" href="index.php?modname=coursereport&amp;op=moveright&amp;id_report=' . $info_report['id_report'] . '"><span><span>' . $lang->def('_MOVE_RIGHT') . '</span></a>';
            }
        }
        $cont_h[] = $top;
        $i++;
        //set info colums
        $colums['max_score'][] = $info_report['max_score'];
        $colums['required_score'][] = $info_report['required_score'];
        $colums['weight'][] = $info_report['weight'];
        $colums['show_to_user'][] = $info_report['show_to_user'] == 'true' ? $lang->def('_YES') : $lang->def('_NO');
        $colums['use_for_final'][] = $info_report['use_for_final'] == 'true' ? $lang->def('_YES') : $lang->def('_NO');
        if ($info_report['use_for_final'] == 'true') {
            $total_weight += $info_report['weight'];
        }
    }
    // XXX: Set table intestation
    $tb_report = new Table(0, $lang->def('_COURSE_REPORT_CAPTION'), $lang->def('_COURSE_REPORT_SUMMARY'));
    $tb_report->setColsStyle($type_h);
    $tb_report->addHead($cont_h);
    $tb_report->addBody($a_line_2);
    $tb_report->addBody($colums['max_score']);
    $tb_report->addBody($colums['required_score']);
    $tb_report->addBody($colums['weight']);
    $tb_report->addBody($colums['show_to_user']);
    $tb_report->addBody($colums['use_for_final']);
    //$tb->addBodyExpanded('<span class="text_bold title_big">'.$lang->def('_STUDENTS_VOTE').'</span>', 'align-center');
    $tb_score = new Table(0, $lang->def('_STUDENTS_VOTE'), $lang->def('_COURSE_REPORT_SUMMARY'));
    $tb_score->setColsStyle($type_h);
    $cont_h[0] = $lang->def('_STUDENTS');
    $cont_old = $cont_h;
    // ALE aggiungo menu a tendina con valori utente:
    require_once _adm_ . '/lib/lib.field.php';
    $fman = new FieldList();
    $fields = $fman->getFlatAllFields(array('framework', 'lms'));
    $f_list = array('userid' => Lang::t('_USERNAME', 'standard'), 'firstname' => Lang::t('_FIRSTNAME', 'standard'), 'lastname' => Lang::t('_LASTNAME', 'standard'), 'email' => Lang::t('_EMAIL', 'standard'), 'lastenter' => Lang::t('_DATE_LAST_ACCESS', 'profile'), 'register_date' => Lang::t('_DIRECTORY_FILTER_register_date', 'admin_directory'), 'language' => Lang::t('_LANGUAGE', 'standard'), 'level' => Lang::t('_LEVEL', 'standard'));
    $f_list = $f_list + $fields;
    $js_arr = array();
    foreach ($f_list as $key => $value) {
        $js_arr[] = $key . ': ' . json_encode($value);
    }
    $f_list_js = '{' . implode(',', $js_arr) . '}';
    $fieldlist = $f_list;
    $dyn_labels = array();
    $dyn_filter = array();
    $num_var_fields = 1;
    $label = '<form name="formx" method="get">';
    for ($i = 0; $i < $num_var_fields; $i++) {
        $label .= '<select onchange="document.formx.submit()" id="_dyn_field_selector_0" name="_dyn_field_selector_0">';
        foreach ($fieldlist as $key => $value) {
            if ($i == 0) {
                $first = $key;
            }
            $label .= '<option value="' . $key . '"' . ($_GET['_dyn_field_selector_0'] == $key ? ' selected="selected"' : '') . '>' . $value . '</option>';
        }
        $label .= '</select>';
    }
    $label .= '</form>';
    $field_selected = $_GET['_dyn_field_selector_0'] ? $_GET['_dyn_field_selector_0'] : 'userid';
    $_SESSION['field_selected'] = $field_selected;
    // aggiungo un elemento in posizione 1
    $index = 1;
    $start = array_slice($cont_h, 0, $index);
    $end = array_slice($cont_h, $index);
    $start[] = $label;
    $cont_h = array_merge($start, $end);
    // fine inserimento
    // END ALE
    $tb_score->addHead($cont_h);
    $cont_h = $cont_old;
    // ripristino il vecchio array di intestazioni
    // 	$tb_score->addHead($cont_h);
    // XXX: Retrive Test info and scores
    $tests_score =& $test_man->getTestsScores($included_test, $id_students);
    // XXX: Calculate statistic
    $test_details = array();
    if (is_array($included_test)) {
        while (list($id_test, $users_result) = each($tests_score)) {
            while (list($id_user, $single_test) = each($users_result)) {
                if ($single_test['score_status'] == 'valid') {
                    // max
                    if (!isset($test_details[$id_test]['max_score'])) {
                        $test_details[$id_test]['max_score'] = $single_test['score'];
                    } elseif ($single_test['score'] > $test_details[$id_test]['max_score']) {
                        $test_details[$id_test]['max_score'] = $single_test['score'];
                    }
                    // min
                    if (!isset($test_details[$id_test]['min_score'])) {
                        $test_details[$id_test]['min_score'] = $single_test['score'];
                    } elseif ($single_test['score'] < $test_details[$id_test]['min_score']) {
                        $test_details[$id_test]['min_score'] = $single_test['score'];
                    }
                    //number of valid score
                    if (!isset($test_details[$id_test]['num_result'])) {
                        $test_details[$id_test]['num_result'] = 1;
                    } else {
                        $test_details[$id_test]['num_result']++;
                    }
                    // averange
                    if (!isset($test_details[$id_test]['averange'])) {
                        $test_details[$id_test]['averange'] = $single_test['score'];
                    } else {
                        $test_details[$id_test]['averange'] += $single_test['score'];
                    }
                }
            }
        }
        while (list($id_test, $single_detail) = each($test_details)) {
            if (isset($single_detail['num_result'])) {
                $test_details[$id_test]['averange'] /= $test_details[$id_test]['num_result'];
            }
        }
        reset($test_details);
    }
    // XXX: Retrive other source scores
    $reports_score =& $report_man->getReportsScores(isset($included_test_report_id) && is_array($included_test_report_id) ? array_diff($reports_id, $included_test_report_id) : $reports_id, $id_students);
    // XXX: Calculate statistic
    $report_details = array();
    while (list($id_report, $users_result) = each($reports_score)) {
        while (list($id_user, $single_report) = each($users_result)) {
            if ($single_report['score_status'] == 'valid') {
                // max
                if (!isset($report_details[$id_report]['max_score'])) {
                    $report_details[$id_report]['max_score'] = $single_report['score'];
                } elseif ($single_report['score'] > $report_details[$id_report]['max_score']) {
                    $report_details[$id_report]['max_score'] = $single_report['score'];
                }
                // min
                if (!isset($report_details[$id_report]['min_score'])) {
                    $report_details[$id_report]['min_score'] = $single_report['score'];
                } elseif ($single_report['score'] < $report_details[$id_report]['min_score']) {
                    $report_details[$id_report]['min_score'] = $single_report['score'];
                }
                //number of valid score
                if (!isset($report_details[$id_report]['num_result'])) {
                    $report_details[$id_report]['num_result'] = 1;
                } else {
                    $report_details[$id_report]['num_result']++;
                }
                // averange
                if (!isset($report_details[$id_report]['averange'])) {
                    $report_details[$id_report]['averange'] = $single_report['score'];
                } else {
                    $report_details[$id_report]['averange'] += $single_report['score'];
                }
            }
        }
    }
    while (list($id_report, $single_detail) = each($report_details)) {
        if (isset($single_detail['num_result'])) {
            $report_details[$id_report]['averange'] /= $report_details[$id_report]['num_result'];
        }
    }
    reset($report_details);
    // XXX: Display user scores
    if (!empty($students_info)) {
        while (list($idst_user, $user_info) = each($students_info)) {
            $user_name = $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]);
            $cont = array($user_name);
            $fman = new FieldList();
            $field_entries = $fman->getUsersFieldEntryData($user_info[0], $field_selected, true);
            $user = array('id' => $user_info[ACL_INFO_IDST], 'userid' => $user_info[ACL_INFO_USERID], 'firstname' => $user_info[ACL_INFO_FIRSTNAME], 'lastname' => $user_info[ACL_INFO_LASTNAME], 'email' => $user_info[ACL_INFO_EMAIL], 'register_date' => $user_info[ACL_INFO_REGISTER_DATE], 'lastenter' => $user_info[ACL_INFO_LASTENTER]);
            if (is_numeric($field_selected)) {
                $cont[] = $field_entries[$user_info[0]][$field_selected];
            } else {
                if ($field_selected == "userid") {
                    $pos = strrpos($user[$field_selected], "/");
                    if ($pos == 0) {
                        $cont[] = substr($user[$field_selected], 1);
                    }
                } else {
                    $cont[] = $user[$field_selected];
                }
            }
            // for every colum
            $results_test = array();
            $results_activity = array();
            $results_scorm_test = array();
            foreach ($reports as $id_report => $info_report) {
                switch ($info_report['source_of']) {
                    case "test":
                        $id_test = $info_report['id_source'];
                        if (isset($tests_score[$id_test][$idst_user])) {
                            switch ($tests_score[$id_test][$idst_user]['score_status']) {
                                case "not_complete":
                                    $cont[] = '-';
                                    break;
                                case "not_checked":
                                    $cont[] = '<span class="cr_not_check">' . $lang->def('_NOT_CHECKED') . '</span>';
                                    // Count not checked
                                    if (!isset($test_details[$id_test]['not_checked'])) {
                                        $test_details[$id_test]['not_checked'] = 1;
                                    } else {
                                        $test_details[$id_test]['not_checked']++;
                                    }
                                    break;
                                case "passed":
                                    //$cont[] = '<span class="cr_passed">'.$lang->def('_PASSED').'</span>';
                                    $cont[] = '<img src="' . getPathImage('fw') . 'emoticons/thumbs_up.gif" alt="' . $lang->def('_PASSED') . '" />';
                                    // Count passed
                                    if (!isset($test_details[$id_test]['passed'])) {
                                        $test_details[$id_test]['passed'] = 1;
                                    } else {
                                        $test_details[$id_test]['passed']++;
                                    }
                                    break;
                                case "not_passed":
                                    //$cont[] = '<span class="cr_not_passed">'.$lang->def('_NOT_PASSED').'</span>';
                                    $cont[] = '<img src="' . getPathImage('fw') . 'emoticons/thumbs_down.gif" alt="' . $lang->def('_NOT_PASSED') . '" />';
                                    // Count not passed
                                    if (!isset($test_details[$id_test]['not_passed'])) {
                                        $test_details[$id_test]['not_passed'] = 1;
                                    } else {
                                        $test_details[$id_test]['not_passed']++;
                                    }
                                    break;
                                case "valid":
                                    $score = $tests_score[$id_test][$idst_user]['score'];
                                    if ($tests_score[$id_test][$idst_user]['times'] > 0) {
                                        $tests_score[$id_test][$idst_user]['times'] = "<a href=\"index.php?modname=coursereport&op=testreport&idTest=" . $tests_score[$id_test][$idst_user]['idTest'] . "&idTrack=" . $tests_score[$id_test][$idst_user]['idTrack'] . "&testName=" . $tests_info[$info_report['id_source']]['title'] . "&studentName=" . $acl_man->relativeId($user_info[ACL_INFO_USERID]) . "\">" . $tests_score[$id_test][$idst_user]['times'] . "</a>";
                                    }
                                    $tt = "(" . $tests_score[$id_test][$idst_user]['times'] . ")";
                                    if ($score >= $info_report['required_score']) {
                                        if ($score == $test_details[$id_test]['max_score']) {
                                            $cont[] = '<span class="cr_max_score">' . $score . " " . $tt . '</span>';
                                        } else {
                                            $cont[] = $score . " " . $tt;
                                        }
                                        // Count passed
                                        if (!isset($test_details[$id_test]['passed'])) {
                                            $test_details[$id_test]['passed'] = 1;
                                        } else {
                                            $test_details[$id_test]['passed']++;
                                        }
                                    } else {
                                        if ($score == $test_details[$id_test]['max_score']) {
                                            $cont[] = '<span class="cr_max_score cr_not_passed">' . $score . " " . $tt . '</span>';
                                        } else {
                                            $cont[] = '<span class="cr_not_passed">' . $score . " " . $tt . '</span>';
                                        }
                                        // Count not passed
                                        if (!isset($test_details[$id_test]['not_passed'])) {
                                            $test_details[$id_test]['not_passed'] = 1;
                                        } else {
                                            $test_details[$id_test]['not_passed']++;
                                        }
                                    }
                                    if (isset($test_details[$id_test]['varianza']) && isset($test_details[$id_test]['averange'])) {
                                        $test_details[$id_test]['varianza'] += pow($tests_score[$id_test][$idst_user]['score'] - $test_details[$id_test]['averange'], 2);
                                    } else {
                                        $test_details[$id_test]['varianza'] = pow($tests_score[$id_test][$idst_user]['score'] - $test_details[$id_test]['averange'], 2);
                                    }
                                    break;
                                default:
                                    $cont[] = '-';
                            }
                        } else {
                            $cont[] = '-';
                        }
                        if ($info_report['use_for_final'] == 'true') {
                            array_push($results_test, $score * $info_report['weight']);
                        }
                        break;
                    case "scoitem":
                        $query_report = "\r\n\t\t\t\t\t\tSELECT *\r\n\t\t\t\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_scorm_tracking\r\n\t\t\t\t\t\tWHERE idscorm_item = '" . $info_report['id_source'] . "' AND idUser = '******'\r\n\t\t\t\t\t\t";
                        //echo $query_report;
                        $report = sql_fetch_assoc(sql_query($query_report));
                        if ($report['score_raw'] == NULL) {
                            $report['score_raw'] = "-";
                        }
                        //$cont[] = '<span class="cr_passed">'.$report['score_max'].'</span>';
                        if ($info_report['use_for_final'] == 'true') {
                            array_push($results_scorm_test, $report['score_raw'] * $info_report['weight']);
                        }
                        $id_track = isset($report['idscorm_tracking']) ? $report['idscorm_tracking'] : 0;
                        $query_report = "\r\n\t\t\t\t\t\tSELECT *\r\n\t\t\t\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_scorm_tracking_history\r\n\t\t\t\t\t\tWHERE idscorm_tracking = '" . $id_track . "'\r\n\t\t\t\t\t\t";
                        //echo $query_report;
                        $query = sql_query($query_report);
                        $num = sql_num_rows($query);
                        if ($num > 0) {
                            $storico = " (<a href=\"index.php?modname=coursereport&op=scormreport&idTest=" . $id_track . "\">" . $num . "</a>)";
                        } else {
                            $storico = "";
                        }
                        $cont[] = '<span class="cr_not_check">' . $report['score_raw'] . '</span>' . $storico;
                        break;
                    case "activity":
                        $id_report = $info_report['id_report'];
                        $score = 0;
                        if (isset($reports_score[$id_report][$idst_user])) {
                            switch ($reports_score[$id_report][$idst_user]['score_status']) {
                                case "not_complete":
                                    $cont[] = '-';
                                    break;
                                case "valid":
                                    $score = $reports_score[$id_report][$idst_user]['score'];
                                    if ($score >= $info_report['required_score']) {
                                        if ($score == $info_report['max_score']) {
                                            $cont[] = '<span class="cr_max_score">' . $score . '</span>';
                                        } else {
                                            $cont[] = $score;
                                        }
                                        // Count passed
                                        if (!isset($report_details[$id_report]['passed'])) {
                                            $report_details[$id_report]['passed'] = 1;
                                        } else {
                                            $report_details[$id_report]['passed']++;
                                        }
                                    } else {
                                        $cont[] = '<span class="cr_not_passed">' . $score . '</span>';
                                        // Count not passed
                                        if (!isset($report_details[$id_report]['not_passed'])) {
                                            $report_details[$id_report]['not_passed'] = 1;
                                        } else {
                                            $report_details[$id_report]['not_passed']++;
                                        }
                                    }
                                    if (isset($report_details[$id_report]['varianza']) && isset($report_details[$id_report]['averange'])) {
                                        $report_details[$id_report]['varianza'] += round(pow($reports_score[$id_report][$idst_user]['score'] - $report_details[$id_report]['averange'], 2), 2);
                                    } else {
                                        $report_details[$id_report]['varianza'] = round(pow($reports_score[$id_report][$idst_user]['score'] - $report_details[$id_report]['averange'], 2), 2);
                                    }
                                    break;
                            }
                        } else {
                            $cont[] = '<span class="cr_not_passed">-</span>';
                        }
                        if ($info_report['use_for_final'] == 'true') {
                            array_push($results_activity, $score * $info_report['weight']);
                        }
                        break;
                    case "final_vote":
                        //                            $divid = (count($results_test)) + (count($results_scorm_test)) + (count($results_activity));
                        $first_value = 0;
                        foreach ($results_test as $value) {
                            if (!is_numeric($value)) {
                                $value = 0;
                            }
                            $first_value += $value;
                        }
                        $second_value = 0;
                        foreach ($results_scorm_test as $value) {
                            if (!is_numeric($value)) {
                                $value = 0;
                            }
                            $second_value += $value;
                        }
                        $third_value = 0;
                        foreach ($results_activity as $value) {
                            if (!is_numeric($value)) {
                                $value = 0;
                            }
                            $third_value += $value;
                        }
                        // Reset array results
                        $results_scorm_test = array();
                        $results_test = array();
                        $results_activity = array();
                        $media = ($first_value + $second_value + $third_value) / $total_weight;
                        $media = sprintf("%01.2f", round($media, 2));
                        $cont[] = $media > 0 ? $media : '<span class="cr_not_passed">-</span>';
                        break;
                }
            }
            $tb_score->addBody($cont);
        }
    }
    // XXX: Display statistics
    $stats['passed'] = array($lang->def('_PASSED'));
    //, ''
    $stats['not_passed'] = array($lang->def('_NOT_PASSED'));
    //, ''
    $stats['not_checked'] = array($lang->def('_NOT_CHECKED'));
    //, ''
    $stats['averange'] = array($lang->def('_AVERANGE'));
    //, ''
    $stats['varianza'] = array($lang->def('_STANDARD_DEVIATION'));
    //, ''
    $stats['max_score'] = array($lang->def('_MAX_SCORE'));
    //, ''
    $stats['min_score'] = array($lang->def('_MIN_SCORE'));
    //, ''
    foreach ($reports as $id_report => $info_report) {
        switch ($info_report['source_of']) {
            case "test":
                $id_test = $info_report['id_source'];
                if (isset($test_details[$id_test]['passed']) || isset($test_details[$id_test]['not_passed'])) {
                    if (!isset($test_details[$id_test]['passed'])) {
                        $test_details[$id_test]['passed'] = 0;
                    }
                    if (!isset($test_details[$id_test]['not_passed'])) {
                        $test_details[$id_test]['not_passed'] = 0;
                    }
                    $test_details[$id_test]['varianza'] /= $test_details[$id_test]['passed'] + $test_details[$id_test]['not_passed'];
                    $test_details[$id_test]['varianza'] = sqrt($test_details[$id_test]['varianza']);
                }
                $stats['passed'][] = isset($test_details[$id_test]['passed']) ? round($test_details[$id_test]['passed'], 2) : '-';
                $stats['not_passed'][] = isset($test_details[$id_test]['not_passed']) ? round($test_details[$id_test]['not_passed'], 2) : '-';
                $stats['not_checked'][] = isset($test_details[$id_test]['not_checked']) ? round($test_details[$id_test]['not_checked'], 2) : '-';
                $stats['averange'][] = isset($test_details[$id_test]['averange']) ? round($test_details[$id_test]['averange'], 2) : '-';
                $stats['varianza'][] = isset($test_details[$id_test]['varianza']) ? round($test_details[$id_test]['varianza'], 2) : '-';
                $stats['max_score'][] = isset($test_details[$id_test]['max_score']) ? round($test_details[$id_test]['max_score'], 2) : '-';
                $stats['min_score'][] = isset($test_details[$id_test]['min_score']) ? round($test_details[$id_test]['min_score'], 2) : '-';
                break;
            case "scoitem":
                $query_report = "\r\n\t\t\t\t\t\tSELECT *\r\n\t\t\t\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_scorm_tracking\r\n\t\t\t\t\t\tWHERE idscorm_item = '" . $info_report['id_source'] . "'";
                $passed = 0;
                $total = 0;
                $media = 0;
                $varianza = 0;
                $votomassimo = 0;
                $votominimo = 9999;
                $result = sql_query($query_report);
                while ($report = sql_fetch_assoc($result)) {
                    if ($report['score_raw'] != NULL) {
                        if ($report['score_raw'] > $votomassimo) {
                            $votomassimo = $report['score_raw'];
                        }
                        if ($report['score_raw'] < $votominimo) {
                            $votominimo = $report['score_raw'];
                        }
                        $media = $media + $report['score_raw'];
                        $total = $total + 1;
                        if ($report['lesson_status'] == 'passed') {
                            $passed++;
                        }
                    }
                }
                $media = $total == 0 ? '0' : $media / $total;
                $result = sql_query($query_report);
                $var = 0;
                while ($report = sql_fetch_assoc($result)) {
                    if ($report['score_raw'] != NULL) {
                        $var = $var + pow($media - $report['score_raw'], 2);
                    }
                }
                $varianza = $total == 0 ? '0' : floor($var / $total);
                if ($votominimo == 9999) {
                    $votominimo = "";
                }
                $stats['passed'][] = $passed;
                $stats['not_passed'][] = $total - $passed;
                $stats['not_checked'][] = "-";
                $stats['averange'][] = $media;
                $stats['varianza'][] = $varianza;
                $stats['max_score'][] = $votomassimo;
                $stats['min_score'][] = $votominimo;
                break;
            case "activity":
            case "final_vote":
                if (isset($report_details[$id_report]['passed']) || isset($report_details[$id_report]['not_passed'])) {
                    if (!isset($report_details[$id_report]['passed'])) {
                        $report_details[$id_report]['passed'] = 0;
                    }
                    if (!isset($report_details[$id_report]['not_passed'])) {
                        $report_details[$id_report]['not_passed'] = 0;
                    }
                    $report_details[$id_report]['varianza'] /= $report_details[$id_report]['passed'] + $report_details[$id_report]['not_passed'];
                    $report_details[$id_report]['varianza'] = sqrt($report_details[$id_report]['varianza']);
                }
                $stats['passed'][] = isset($report_details[$id_report]['passed']) ? round($report_details[$id_report]['passed'], 2) : '-';
                $stats['not_passed'][] = isset($report_details[$id_report]['not_passed']) ? round($report_details[$id_report]['not_passed'], 2) : '-';
                $stats['not_checked'][] = isset($report_details[$id_report]['not_checked']) ? round($report_details[$id_report]['not_checked'], 2) : '-';
                $stats['averange'][] = isset($report_details[$id_report]['averange']) ? round($report_details[$id_report]['averange'], 2) : '-';
                $stats['varianza'][] = isset($report_details[$id_report]['varianza']) ? round(sqrt($report_details[$id_report]['varianza']), 2) : '-';
                $stats['max_score'][] = isset($report_details[$id_report]['max_score']) ? round($report_details[$id_report]['max_score'], 2) : '-';
                $stats['min_score'][] = isset($report_details[$id_report]['min_score']) ? round($report_details[$id_report]['min_score'], 2) : '-';
                break;
        }
    }
    $tb_stat = new Table(0, $lang->def('_SUMMARY_VOTE'), $lang->def('_COURSE_REPORT_SUMMARY'));
    $tb_stat->setColsStyle($type_h);
    $cont_h[0] = $lang->def('_STATISTICS');
    $tb_stat->addHead($cont_h);
    //$tb->addBodyExpanded('<span class="text_bold title_big">'.$lang->def('_SUMMARY_VOTE').'</span>', 'align-center');
    $tb_stat->addBody($stats['passed']);
    $tb_stat->addBody($stats['not_passed']);
    $tb_stat->addBody($stats['not_checked']);
    $tb_stat->addBody($stats['averange']);
    $tb_stat->addBody($stats['varianza']);
    $tb_stat->addBody($stats['max_score']);
    $tb_stat->addBody($stats['min_score']);
    // Write in output
    $out->add(getTitleArea($lang->def('_COURSEREPORT', 'menu_course'), 'coursereport') . '<div class="std_block">');
    $out->add('
		<div id="dhtmltooltip"></div>
	<style type="text/css">

#dhtmltooltip{
position: absolute;
width: 150px;
border: 2px solid black;
padding: 2px;
background-color: white;
visibility: hidden;
z-index: 100;
filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135);
}
</style>
	<script>
	var posx = 0;
	var posy = 0;
		document.onmousemove=function doSomething(e) {
	 if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)
  if (e)
  {
    if (e.pageX || e.pageY)
    {
      posx = e.pageX;
      posy = e.pageY;
    }
    else if (e.clientX || e.clientY)
    { // works on IE6,FF,Moz,Opera7
      posx = e.clientX + document.body.scrollLeft;
      posy = e.clientY + document.body.scrollTop;
    }
  }
}

var offsetxpoint=-60
var offsetypoint=20
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth,pos,html){
if (ns6||ie){

tipobj.innerHTML="' . $lang->def('_EXPORT') . ':"+html+"<a id=\\"cambia_link\\" class=\\""+thetext+"\\" href=\\"./index.php?modname=coursereport&op=export&amp;type_filter=' . $lev . '\\">' . $lang->def('_EXPORT_STATS') . '</a>";
enabletip=true
tipobj.style.width="200px"
tipobj.style.height="auto"

tipobj.style.left=posx+"px"
tipobj.style.top=posy+"px"
tipobj.style.visibility="visible"
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;

var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

if (rightedge<tipobj.offsetWidth)

tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else

tipobj.style.left=curX+offsetxpoint+"px"

if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=""
tipobj.style.width=""
}
}

//document.onmousemove=positiontip

var lista=new Array();
function tool(arm,pos,htm){

var tipobj=document.getElementById("dhtmltooltip").style.visibility;
if(tipobj=="visible"){
hideddrivetip()
lista=new Array();
}
else
	ddrivetip(arm,"","",pos,htm);
	//else
	//tooltip.hide();
	}
var url="./index.php?modname=coursereport&op=export&amp;type_filter=' . $lev . '";

	function cambialink(num,fare){
	if(fare)
lista[lista.length+1]=num;
else
{
i=0;
while(i<lista.length)
	{if (lista[i]==num)
		lista[i]=null;
	i++;
	}
}
	document.getElementById("cambia_link").href=url;//+document.getElementById("cambia_link").className;

	i=0;
	stringaurl="&aggiuntivi=";
while(i<lista.length)
	{if (lista[i]!=null)
		stringaurl=stringaurl+lista[i]+",";
	i++;
	}

	document.getElementById("cambia_link").href=document.getElementById("cambia_link").href+stringaurl;
	//alert(document.getElementById("cambia_link").href);
	}
	</script>');
    $sql = "SELECT * FROM core_field";
    $filler = "";
    $filler = "<br>";
    $result_quest = sql_query($sql) or die(mysql_error());
    while ($quests = sql_fetch_array($result_quest)) {
        $filler .= "<input type=\\'checkbox\\' onclick=\\'cambialink(" . $quests['idField'] . ",this.checked)\\' value=\\'" . $quests['idField'] . "\\'>" . $quests['translation'] . "<br>";
    }
    $filler .= "<input type=\\'checkbox\\' onclick=\\'cambialink(9999,this.checked)\\' value=\\'999\\'>" . $lang->def('_QUESTION_ANSWERED') . "<br>";
    $filler .= "<input type=\\'checkbox\\' onclick=\\'cambialink(1999,this.checked)\\' value=\\'1999\\'>" . $lang->def('_TOT_QUESTION') . "<br>";
    $filler .= "<input type=\\'checkbox\\' onclick=\\'cambialink(1199,this.checked)\\' value=\\'1199\\'>" . $lang->def('_DATE') . "<br>";
    $filler .= "<input type=\\'checkbox\\' onclick=\\'cambialink(1299,this.checked)\\' value=\\'1299\\'>" . $lang->def('_TOTAL') . "<br>";
    if (checkPerm('mod', true)) {
        $out->add('<div class="table-container-below">' . '<ul class="link_list_inline">' . '<li><a class="ico-wt-sprite subs_add" href="index.php?modname=coursereport&amp;op=addactivity" title="' . $lang->def('_ADD_ACTIVITY_TITLE') . '">' . '<span>' . $lang->def('_ADD_ACTIVITY') . '</span></a></li>' . '<li><a class="ico-wt-sprite subs_plus" href="index.php?modname=coursereport&amp;op=addscorm" title="' . $lang->def('_ADD_SCORM_RESULTS') . '">' . '<span>' . $lang->def('_ADD_SCORM_RESULTS') . '</span></a></li>' . '<li><a class="ico-wt-sprite subs_csv" href="index.php?modname=coursereport&amp;op=export&amp;type_filter=' . $lev . '" title="' . $lang->def('_EXPORT_CSV') . '" onclick="window.open(this.href); return false;">' . '<span>' . $lang->def('_EXPORT_CSV') . '</span></a></li>
			</ul>' . '</div>');
    }
    $out->add(Form::openForm("statuserfilter", "index.php?modname=coursereport&amp;op=coursereport"));
    $type_groups = array('false' => $lang->def('_ALL'), '1' => $lang2->def('_LEVEL_1'), '2' => $lang2->def('_LEVEL_2'), '3' => $lang2->def('_LEVEL_3'), '4' => $lang2->def('_LEVEL_4'), '5' => $lang2->def('_LEVEL_5'), '6' => $lang2->def('_LEVEL_6'), '7' => $lang2->def('_LEVEL_7'));
    $out->add(Form::getDropdown($lang->def('_LEVEL'), 'type_filter', 'type_filter', $type_groups, $type_filter));
    $out->add(Form::getButton('gofilter', 'gofilter', $lang->def('_SEARCH')));
    $out->add(Form::closeForm());
    $out->add($tb_report->getTable() . '<br /><br />' . $tb_score->getTable() . '<br /><br />' . $tb_stat->getTable() . '<br /><br />');
    if (checkPerm('mod', true)) {
        $out->add('<div class="table-container-below">' . '<ul class="link_list_inline">
				<li><a class="ico-wt-sprite subs_add" href="index.php?modname=coursereport&amp;op=addactivity" title="' . $lang->def('_ADD_ACTIVITY_TITLE') . '">' . '<span>' . $lang->def('_ADD_ACTIVITY') . '</span></a></li>' . '<li><a class="ico-wt-sprite subs_plus" href="index.php?modname=coursereport&amp;op=addscorm" title="' . $lang->def('_ADD_SCORM_RESULTS') . '">' . '<span>' . $lang->def('_ADD_SCORM_RESULTS') . '</span></a></li>' . '<li><a class="ico-wt-sprite subs_csv" href="index.php?modname=coursereport&amp;op=export&amp;type_filter=' . $lev . '" title="' . $lang->def('_EXPORT_CSV') . '" onclick="window.open(this.href); return false;">' . '<span>' . $lang->def('_EXPORT_CSV') . '</span></a></li>
			</ul>' . '</div>');
    }
    $out->add('</div>');
}
 public function gap_analisysTask()
 {
     $back_url = 'index.php?r=adm/functionalroles/show';
     $id_fncrole = Get::req('id', DOTY_INT, -1);
     if ($id_fncrole <= 0) {
         $this->render('invalid', array('message' => $this->_getErrorMessage('invalid fncrole'), 'back_url' => $back_url));
         return;
     }
     $title_arr = array($back_url => Lang::t('_FUNCTIONAL_ROLE', 'fncroles'), Lang::t('_GAP_ANALYSIS', 'fncroles') . ': ' . $this->model->getFunctionalRoleName($id_fncrole));
     $result = Get::req('res', DOTY_ALPHANUM, '');
     $result_message = "";
     /*
     		switch ($result) {
     			case "ok_gap": $result_message = Lang::t('_RESULT_GAP_OK', 'fncroles'); break;
     			case "err_gap": $result_message = Lang::t('_RESULT_GAP_ERR', 'fncroles'); break;
     		}
     */
     require_once _adm_ . '/lib/user_selector/lib.dynamicuserfilter.php';
     $dyn_filter = new DynamicUserFilter("user_dyn_filter");
     $dyn_filter->init();
     require_once _adm_ . '/lib/lib.field.php';
     $fman = new FieldList();
     $fields = $fman->getFlatAllFields(array('framework', 'lms'));
     $f_list = array('email' => Lang::t('_EMAIL', 'standard'), 'lastenter' => Lang::t('_DATE_LAST_ACCESS', 'profile'), 'register_date' => Lang::t('_DIRECTORY_FILTER_register_date', 'admin_directory'), 'language' => Lang::t('_LANGUAGE', 'standard'), 'level' => Lang::t('_LEVEL', 'standard'));
     $f_list = $f_list + $fields;
     $f_selected = $this->json->decode(Docebo::user()->getPreference('ui.directory.custom_columns'));
     if ($f_selected == false) {
         $f_selected = array('email', 'lastenter', 'register_date');
     }
     $js_arr = array();
     foreach ($f_list as $key => $value) {
         $js_arr[] = $key . ': ' . $this->json->encode($value);
     }
     $f_list_js = '{' . implode(',', $js_arr) . '}';
     $this->render('gap_analisys', array('id_fncrole' => $id_fncrole, 'num_var_fields' => 1, 'fieldlist' => $f_list, 'fieldlist_js' => $f_list_js, 'selected' => $f_selected, 'title_arr' => $title_arr, 'filter_text' => "", 'result_message' => $result_message, 'advanced_filter' => array('active' => false, 'gap_filter' => 0, 'expire_filter' => 0)));
 }
예제 #7
0
 public function getCustomFields($lang_code = false, $indexes = false)
 {
     require_once _adm_ . '/lib/lib.field.php';
     $output = array();
     $fl = new FieldList();
     $fields = $fl->getFlatAllFields(false, false, $lang_code);
     foreach ($fields as $key => $val) {
         if ($indexes) {
             $output[$key] = $val;
         } else {
             $output[] = array('id' => $key, 'name' => $val);
         }
     }
     return $output;
 }
예제 #8
0
function subscribemod()
{
    checkPerm('subscribe', false, 'course');
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    require_once _base_ . '/lib/lib.form.php';
    require_once $GLOBALS['where_framework'] . '/lib/lib.field.php';
    require_once _base_ . '/lib/lib.table.php';
    $id_course = importVar('id_course', true, 0);
    $course_info = Man_Course::getCourseInfo($id_course);
    $edition_id = getCourseEditionId();
    $fman = new FieldList();
    //addScriptaculousJs();
    YuiLib::load(array('json' => 'json-min.js'));
    $GLOBALS['page']->add('<script type="text/javascript">' . ' function reloadInfo() {
		  var $ = YAHOO.util.Dom.get;
			var selection = $("extra_info").value;
			var id_course = $("id_course").value;
		
			var data = "op=get_info&id_course="+id_course+"&id_field=" + selection;
			
			var objAjax = YAHOO.util.Connect.asyncRequest("POST",
		        "' . $GLOBALS['where_lms_relative'] . '/ajax.adm_server.php?mn=subscribe",
		        {onSuccess: callback_change}, data
		    );
			$("extra_info").disabled = true;
		} ' . ' function callback_change(o) {
			
			var result = YAHOO.lang.JSON.parse(o.responseText);
			var table = $("subscribed_list");
			for(var i= 0;i < table.rows.length;i++) {
				var ind = table.rows[i].id.indexOf("user_");
				if(ind >= 0) {
					var id_user = table.rows[i].id.substr(5);
					table.rows[i].cells[1].innerHTML = result[id_user];
				}
			}
			$("extra_info").disabled = false;
		}' . '</script>', 'page_head');
    $out =& $GLOBALS['page'];
    $lang =& DoceboLanguage::CreateInstance('subscribe', 'lms');
    $acl_man =& Docebo::user()->getAclManager();
    $levels = CourseLevel::getLevels();
    $arr_absent = array(0 => $lang->def('_NO'), 1 => $lang->def('_JUSTIFIED'), 2 => $lang->def('_NOT_JUSTIFIED'));
    $arr_status = array(_CUS_CONFIRMED => $lang->def('_USER_STATUS_CONFIRMED'), _CUS_SUBSCRIBED => $lang->def('_USER_STATUS_SUBS'), _CUS_BEGIN => $lang->def('_USER_STATUS_BEGIN'), _CUS_END => $lang->def('_USER_STATUS_END'), _CUS_SUSPEND => $lang->def('_USER_STATUS_SUSPEND'), _CUS_CANCELLED => $lang->def('_USER_STATUS_CANCELLED'));
    $field = $fman->getFlatAllFields();
    $field = array('name' => $lang->def('_FULLNAME'), 'email' => $lang->def('_EMAIL')) + $field;
    // Retrive info about the selected user
    $user_alredy_subscribed = getSubscribed($id_course, false, false, true, $edition_id);
    $user_levels = getSubscribedInfo($id_course, false, false, false, false, $edition_id);
    require_once $GLOBALS['where_framework'] . '/lib/lib.adminmanager.php';
    $adminManager = new AdminManager();
    $acl_manager = new DoceboACLManager();
    $idst_associated = $adminManager->getAdminTree(getLogUserId());
    $array_user_associated =& $acl_manager->getAllUsersFromIdst($idst_associated);
    $user_level = Docebo::user()->getUserLevelId();
    if ($user_level != ADMIN_GROUP_GODADMIN) {
        $user_alredy_subscribed = array_intersect($user_alredy_subscribed, $array_user_associated);
    }
    $user_selected_info =& $acl_man->getUsers($user_alredy_subscribed);
    $page_title = array('index.php?modname=course&op=course_list' => $lang->def('_COURSES'), $course_info['name'], $lang->def('_SUBSCRIBE'));
    $GLOBALS['page']->add(getTitleArea($page_title, 'subscribe') . '<div class="std_block">' . Form::openForm('levelselection', 'index.php?modname=subscribe&amp;op=subscribeupdate') . Form::getHidden('id_course', 'id_course', $id_course) . Form::getHidden('edition_id', 'edition_id', $edition_id), 'content');
    $tb = new Table(0, $lang->def('_CAPTION_SELECT_LEVELS'), $lang->def('_SUMMARY_SELECT_LEVEL'));
    $tb->setTableId('subscribed_list');
    $type_h = array('', '');
    $content_h = array($lang->def('_USERNAME'), Form::getInputDropdown('dropdown_nowh', 'extra_info', 'extra_info', $field, 0, ' onchange="reloadInfo();"'));
    foreach ($levels as $lv => $lv_name) {
        $type_h[] = 'image';
        $content_h[] = '<a href="javascript:SelAll(\'' . $lv . '\');">' . $lv_name . '</a>';
    }
    $type_h[] = 'image';
    $content_h[] = $lang->def('_STATUS');
    if ($course_info['course_type'] != 'elearning') {
        $type_h[] = 'image';
        $content_h[] = $lang->def('_ABSENT');
    }
    $tb->addHead($content_h, $type_h);
    $num_user_sel = 0;
    if (is_array($user_selected_info)) {
        reset($user_selected_info);
        $jsArr = "var elementi = new Array(";
        $i = 0;
        while (list($id_user, $user_info) = each($user_selected_info)) {
            if ($i != 0) {
                $jsArr .= ",";
            }
            $i++;
            $jsArr .= "'" . $id_user . "'";
            // if the user isn't alredy subscribed to the course
            $content = array(substr($user_info[ACL_INFO_USERID], 1), $user_info[ACL_INFO_LASTNAME] . ' ' . $user_info[ACL_INFO_FIRSTNAME]);
            foreach ($levels as $lv => $lv_name) {
                $content[] = Form::getInputRadio('user_level_sel_' . $id_user . '_' . $lv, 'user_level_sel[' . $id_user . ']', $lv, $lv == $user_levels[$id_user]['level'], '') . '<label class="access-only" for="user_level_sel_' . $id_user . '_' . $lv . '">' . $lv_name . '</label>';
            }
            $content[] = Form::getInputDropdown('dropdown', 'user_status_sel_' . $id_user . '', 'user_status_sel[' . $id_user . ']', $arr_status, $user_levels[$id_user]['status'], '') . '<label class="access-only" for="user_status_sel_' . $id_user . '">' . $lang->def('_STATUS') . '</label>';
            if ($course_info['course_type'] != 'elearning') {
                $content[] = Form::getInputDropdown('dropdown_nowh', 'user_absent' . $id_user . '', 'user_absent[' . $id_user . ']', $arr_absent, $user_levels[$id_user]['absent'], '') . '<label class="access-only" for="user_absent_' . $id_user . '">' . $lang->def('_ABSENT') . '</label>';
            }
            $tb->addBody($content, false, false, 'user_' . $id_user);
        }
        $GLOBALS['page']->add($tb->getTable(), 'content');
    }
    $GLOBALS['page']->add(Form::openButtonSpace() . '<br />' . Form::getButton('subscribe', 'subscribe', $lang->def('_MOD')) . Form::getButton('cancelselector', 'cancelselector', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm(), 'content');
    $GLOBALS['page']->add('</div>', 'content');
    $GLOBALS['page']->add('                                 
<script>                
' . $jsArr . ');
function SelAll (lvl)           
{                                                                                                       
        var nb;                                                                                         
        ne = elementi.length;
        mod = document.getElementById(\'levelselection\');
        for (var i=0;i<ne;i++)                                                                          
        {                                               
                elem = \'user_level_sel_\'+elementi[i]+\'_\'+lvl;
                var e = document.getElementById(elem);
                e.checked = 1;                                                                          
        }                                                                                               
}
</script>');
}
 /**
  * @param string $id_folder folder destination of fields
  * @param array $arr_fields an array with fields to attach to folder
  * 							any element of folder is an array:
  * 							key => array( 'fvalue', 'mandatory' )
  * 							- key is the field name in current language
  * 							- fvalue is the value of the field
  * 							- mandatory is TRUE if this field is mandatory
  */
 function _add_custom_fields($id_folder, $arr_fields)
 {
     require_once $GLOBALS['where_framework'] . '/lib/lib.field.php';
     $fl = new FieldList();
     $fl->setGroupFieldsTable($GLOBALS['prefix_fw'] . ORGCHAR_FIELDTABLE);
     $fl->setFieldEntryTable($GLOBALS['prefix_fw'] . ORGCHAR_FIELDENTRYTABLE);
     $arr_all_fields = $fl->getFlatAllFields(false, false, $this->default_lang);
     // remove all fields
     foreach ($arr_all_fields as $id_field => $ftranslation) {
         $fl->removeFieldFromGroup($id_field, $id_folder);
     }
     $arr_all_fields_translation = array_flip($arr_all_fields);
     $arr_fields_value = array();
     // add selected fields
     foreach ($arr_fields as $field_translation => $field_data) {
         if (isset($arr_all_fields_translation[$field_translation])) {
             $field_id = $arr_all_fields_translation[$field_translation];
             $fl->addFieldToGroup($field_id, $id_folder, $field_data['mandatory']);
             $arr_fields_value[$field_id] = $field_data['fvalue'];
         } else {
             die("Field non trovato: {$field_translation}");
         }
     }
     $fl->storeDirectFieldsForUser($id_folder, $arr_fields_value, FALSE);
 }
 public function show()
 {
     if (!$this->permissions['subscribe_course']) {
         // the user cannot use this function
         $this->render('invalid', array('message' => $this->_getErrorMessage('no permission'), 'back_url' => 'index.php?r=' . $this->link_course . '/show'));
         return;
     }
     Util::get_js(Get::rel_path('base') . '/lib/lib.elem_selector.js', true, true);
     Util::get_js(Get::rel_path('base') . '/lib/js_utils.js', true, true);
     Util::get_js(Get::rel_path('lms') . '/admin/views/subscription/subscription.js', true, true);
     if (isset($_GET['res']) && $_GET['res'] !== '') {
         UIFeedback::info(Lang::t(strtoupper($_GET['res']), 'subscription'));
     }
     if (isset($_GET['err']) && $_GET['err'] !== '') {
         UIFeedback::error(Lang::t(strtoupper($_GET['err']), 'subscription'));
     }
     Form::loadDatefieldScript();
     //some dialogs use date inputs
     $umodel = new UsermanagementAdm();
     $course_info = $this->model->getCourseInfoForSubscription();
     $course_name = ($course_info['code'] !== '' ? '[' . $course_info['code'] . '] ' : '') . $course_info['name'];
     //generate field list for dynamic user column
     require_once _adm_ . '/lib/lib.field.php';
     $fman = new FieldList();
     $fields = $fman->getFlatAllFields(array('framework', 'lms'));
     $f_list = array('email' => Lang::t('_EMAIL', 'standard'), 'lastenter' => Lang::t('_DATE_LAST_ACCESS', 'profile'), 'register_date' => Lang::t('_DIRECTORY_FILTER_register_date', 'admin_directory'), 'level' => Lang::t('_LEVEL', 'standard'), 'language' => Lang::t('_LANGUAGE', 'standard'));
     $f_list = $f_list + $fields;
     $f_selected = $this->json->decode(Docebo::user()->getPreference('ui.directory.custom_columns'));
     if ($f_selected == false) {
         $f_selected = array('email');
     }
     $js_arr = array();
     foreach ($f_list as $key => $value) {
         $js_arr[] = $key . ': ' . $this->json->encode($value);
     }
     $f_list_js = '{' . implode(',', $js_arr) . '}';
     $params = array('back_link' => $this->_getBackLink(), 'id_course' => $this->id_course, 'id_edition' => $this->id_edition, 'id_date' => $this->id_date, 'level_list_js' => $this->_getJsArrayLevel(), 'status_list_js' => $this->_getJsArrayStatus(), 'orgchart_list' => $umodel->getOrgChartDropdownList(), 'is_active_advanced_filter' => false, 'filter_text' => "", 'filter_orgchart' => 0, 'filter_descendants' => false, 'filter_date_valid' => "", 'filter_show' => 0, 'course_name' => $course_name, 'use_overbooking' => isset($course_info['overbooking']) ? (bool) $course_info['overbooking'] : false, 'num_var_fields' => 1, 'fieldlist' => $f_list, 'fieldlist_js' => $f_list_js, 'selected' => $f_selected, 'hidden_validity' => false);
     $this->render('show', $params);
 }
 public function multimodTask()
 {
     if (!$this->permissions['mod_user']) {
         $output = array('success' => false, 'message' => $this->_getErrorMessage('no permission'));
         echo $this->json->encode($output);
         return;
     }
     $title = Lang::t('_MOD', 'admin_directory');
     $users_count = Get::req('users_count', DOTY_INT, 0);
     if ($users_count <= 0) {
         $output = array('success' => true, 'header' => $title, 'body' => Lang::t('_EMPTY_SELECTION', 'admin_directory'));
         echo $this->json->encode($output);
         return;
     }
     $acl_man = Docebo::user()->getAclManager();
     $level = ADMIN_GROUP_USER;
     $arr_levels = $acl_man->getAdminLevels();
     //index = idst; value = groupid;
     $levels = array();
     foreach ($arr_levels as $groupid_level => $idst_level) {
         $levels[$groupid_level] = Lang::t('_DIRECTORY_' . $groupid_level, 'admin_directory');
     }
     $info = array('firstname' => '', 'lastname' => '', 'email' => '', 'level' => '', 'facebook_id' => '', 'twitter_id' => '', 'linkedin_id' => '', 'google_id' => '');
     $language = getDefaultLanguage();
     $languages = Docebo::langManager()->getAllLanguages();
     require_once _base_ . '/lib/lib.platform.php';
     $pman =& PlatformManager::createInstance();
     // = new PlatformManager();
     $platforms = $pman->getPlatformList();
     require_once _adm_ . '/lib/lib.field.php';
     $fman = new FieldList();
     $field_list = $fman->getFlatAllFields(array_keys($platforms));
     $fields_to_exclude = $fman->getFieldsByType('upload');
     $preference = new UserPreferences(0);
     $modify_mask = $preference->getModifyMask('ui.', true, true);
     $fields_mask = $fman->playFieldsForUser(-1, false, false, true, false, true);
     //build edit mask
     $this->render('multimod', array('users_count' => $users_count, 'title' => $title, 'levels' => $levels, 'modify_mask' => $modify_mask, 'fields_mask' => $fields_mask, 'fields_to_exclude' => is_array($fields_to_exclude) ? $fields_to_exclude : array(), 'info' => $info, 'json' => $this->json));
 }
예제 #12
0
 function _step0()
 {
     require_once $GLOBALS['where_framework'] . '/lib/lib.field.php';
     $field_man = new FieldList();
     $field_list = $field_man->getFlatAllFields();
     $out = '';
     // ---- name -----
     $out = $this->form->getTextfield($this->lang->def('_NAME'), $this->_get_base_name() . '_name', $this->_get_base_name() . '[name]', 255, $this->post_params['name']);
     // ---- description -----
     $out .= $this->form->getSimpleTextarea($this->lang->def('_DESCRIPTION'), $this->_get_base_name() . '_description', $this->_get_base_name() . '[description]', $this->post_params['description']);
     // --- cid field --------
     $out .= $this->form->getDropdown($this->lang->def('_CID'), $this->_get_base_name() . '_cid_field', $this->_get_base_name() . '[cid_field]', $field_list, $this->post_params['cid_field']);
     return $out;
 }