Esempio n. 1
0
function course()
{
    checkPerm('view');
    require_once _base_ . '/lib/lib.form.php';
    //require_once(_i18n_.'/lib.lang.php');
    require_once _base_ . '/lib/lib.table.php';
    require_once _lms_ . '/lib/lib.course.php';
    $GLOBALS['page']->setWorkingZone('content');
    $lang =& DoceboLanguage::CreateInstance('course', 'lms');
    $db =& DbConn::getInstance();
    Util::get_js(Get::rel_path('base') . '/widget/dialog/dialog.js', true, true);
    // Setup the tree viewer class ----------------------------------------------
    require_once _lms_ . '/lib/folder_tree/class.category_tree.php';
    $treeView = new CategoryFolderTree('courses_categories', true);
    $treeView->useDOMReady = true;
    //to change
    $treeView->isGlobalVariable = true;
    //just for debug purpose
    $treeView->initLibraries();
    $print_tree = $treeView->get();
    // Setup the course table ---------------------------------------------------
    //$man_course = new Man_Course();
    //$course_list = $man_course->getCoursesRequest($table_status['startIndex'], Get::sett('visuItem'), $table_status['sort'], $table_status['dir']);
    //$db->num_rows($course_list),
    //$man_course->getCoursesCountFiltered(),
    if (!isset($_SESSION['course_category']['filter_status'])) {
        $_SESSION['course_category']['filter_status'] = array('c_category' => 0, 'c_filter' => '', 'c_flatview' => false, 'c_waiting' => false);
    }
    $filter_status =& $_SESSION['course_category']['filter_status'];
    if (isset($filter_status['c_flatview']) || isset($filter_status['c_waiting'])) {
        $open = true;
    } else {
        $open = false;
    }
    if (!isset($_SESSION['course_category']['table_status'])) {
        $_SESSION['course_category']['table_status'] = array('startIndex' => 0, 'sort' => 'name', 'dir' => 'asc');
    }
    $table_status =& $_SESSION['course_category']['table_status'];
    // Setup the course table ---------------------------------------------------
    $table_config = array('startIndex' => $table_status['startIndex'], 'results' => Get::sett('visuItem'), 'sort' => $table_status['sort'], 'dir' => $table_status['dir'], 'pageSize' => 0, 'totalRecords' => 0, 'recordsReturned' => array());
    require_once _lms_ . '/lib/table_view/class.coursetableview.php';
    $tableView = new CourseTableView("courses_list");
    $tableView->useDOMReady = true;
    //to change
    $tableView->isGlobalVariable = true;
    //just for debug purpose
    $tableView->initLibraries();
    $tableView->setInitialData($table_config);
    $print_table = $tableView->get();
    //Script for saving data from inline editor
    cout("\n" . '<script type="text/javascript">
			function saveData(callback, newData) {
			var new_value = newData;
			var col = this.getColumn().key;
			var old_value =  this.value;
			var datatable = this.getDataTable();
			var idCourse = this.getRecord().getData("idCourse");

			var myCallback =
			{
				success: function(o)
				{
					var r = YAHOO.lang.JSON.parse(o.responseText);
					if (r.success)
					{
						callback(true, stripSlashes(r.new_value));
					}
					else
					{
						callback(true, stripSlashes(r.old_value));
					}
				},
				failure:
				{
				}
			}

			var post =	"idCourse=" + idCourse
						+"&col=" + col
						+"&new_value=" + new_value
						+"&old_value=" + old_value;

			var url = "ajax.adm_server.php?plf=lms&file=coursetableview&sf=table_view&command=updateField&";

			YAHOO.util.Connect.asyncRequest("POST", url, myCallback, post);
			}
		</script>');
    // Js needed for this page in order to work
    cout("\n" . '<script type="text/javascript">
	//<!--
	course_tree_options = ' . $print_tree['options'] . ';
	-->
	</script>', 'scripts');
    cout("\n" . '<script type="text/javascript">
	//<!--
	course_table_options = ' . $print_table['options'] . ';
	--></script>', 'scripts');
    cout("\n" . '<script type="text/javascript" src="' . Get::rel_path('lms') . '/admin/modules/course/course.js"></script>', 'scripts');
    cout(getTitleArea($lang->def('_COURSES'), 'course') . '<div class="std_block">' . (isset($_GET['result']) ? guiResultStatus($lang, $_GET['result']) : ''), 'content');
    // Show tree
    cout('<h2>' . $lang->def('_CATEGORY') . '</h2>' . $print_tree['html'] . '<div class="folder_action_space">' . '<a id="add_folder_button" class="ico-wt-sprite subs_add" href="#"><span>' . $lang->def('_NEW_CATEGORY') . '</span></a>' . '</div>', 'content');
    // Show filter
    cout('<div class="quick_search_form">' . '<div class="common_options">' . Form::getInputCheckbox('c_flatview', 'c_flatview', '1', $filter_status['c_flatview'] ? true : false, '') . ' <label class="label_normal" for="c_flatview">' . Lang::t('_DIRECTORY_FILTER_FLATMODE', 'admin_directory') . '</label>' . '&nbsp;&nbsp;&nbsp;&nbsp;' . Form::getInputCheckbox('c_waiting', 'c_waiting', '1', $filter_status['c_waiting'] ? true : false, '') . ' <label class="label_normal" for="c_waiting">' . Lang::t('_WAITING_USERS', 'organization_chart') . '</label>' . '</div>' . '<br />' . '<div>' . Form::openForm('course_filters', 'index.php?modname=course&amp;op=course_list') . Form::getInputTextfield("search_t", "c_filter", "c_filter", $filter_status['c_filter'], '', 255, '') . Form::getButton("c_filter_set", "c_filter_set", Lang::t('_SEARCH', 'standard'), "search_b") . Form::getButton("c_filter_reset", "c_filter_reset", Lang::t('_RESET', 'standard'), "reset_b") . Form::closeForm() . '</div>' . '</div>', 'content');
    // show course table
    cout('' . '<div class="table-container-over">' . (checkPerm('add', true, 'course', 'lms') ? '<a class="ico-wt-sprite subs_add" href="index.php?modname=course&amp;op=new_course"><span>' . $lang->def('_NEW_COURSE') . '</span></a>' : '') . (checkPerm('subscribe', true, 'course', 'lms') ? '&nbsp;&nbsp;<a class="ico-wt-sprite subs_users" href="index.php?r=alms/subscription/multiplesubscription&amp;load=1"><span>' . Lang::t('_MULTIPLE_SUBSCRIPTION', 'course') . '</span></a>' : '') . '</div>' . $print_table['html'] . '<div class="table-container-below">' . (checkPerm('add', true, 'course', 'lms') ? '<a class="ico-wt-sprite subs_add" href="index.php?modname=course&amp;op=new_course"><span>' . $lang->def('_NEW_COURSE') . '</span></a>' : '') . (checkPerm('subscribe', true, 'course', 'lms') ? '&nbsp;&nbsp;<a class="ico-wt-sprite subs_users" href="index.php?r=alms/subscription/multiplesubscription&amp;load=1"><span>' . Lang::t('_MULTIPLE_SUBSCRIPTION', 'course') . '</span></a>' : '') . '</div>', 'content');
    //set event listeners to filter elements
    cout('<script type="text/javascript">$E=YAHOO.util.Event; $E.onDOMReady( function(e) {
			$E.addListener("c_filter_set", "click", filterEvent);
			$E.addListener("c_filter_reset", "click", function() { YAHOO.util.Dom.get("c_filter").value=""; filterEvent; });
			$E.addListener("c_flatview", "click", filterEvent);
			$E.addListener("c_waiting", "click", filterEvent);
			$E.addListener("course_filters", "submit", function(ev) { filterEvent(ev); YAHOO.util.Event.preventDefault(ev); });
		});</script>', 'scripts');
    cout('</div>', 'content');
}
Esempio n. 2
0
function modrule(&$url)
{
    checkPerm('mod');
    YuiLib::load(array('animation' => 'animation-min.js', 'dragdrop' => 'dragdrop-min.js', 'button' => 'button-min.js', 'container' => 'container-min.js', 'my_window' => 'windows.js'), array('container/assets/skins/sam' => 'container.css', 'button/assets/skins/sam' => 'button.css'));
    addJs($GLOBALS['where_lms_relative'] . '/admin/modules/preassessment/', 'ajax.preassessment.js');
    $id_assessment = importVar('id_assess', true, 0);
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    $course_man = new Man_Course();
    require_once $GLOBALS['where_lms'] . '/lib/lib.coursepath.php';
    $coursepath_man = new CoursePath_Manager();
    require_once $GLOBALS['where_lms'] . '/lib/lib.preassessment.php';
    $assess_man = new AssessmentList();
    $rule_man = new AssessmentRule();
    $lang =& DoceboLanguage::createInstance('preassessment');
    // recover assessment
    $assessment = $assess_man->getAssessment($id_assessment);
    $rule_list = $rule_man->getAllRule($id_assessment);
    // recover new type one
    require_once _base_ . '/lib/lib.table.php';
    $tb = new Table(0, $lang->def('_CAPTION_PREASSESSMENT_RULE'), $lang->def('_SUMMARY_PREASSESSMENT_RULE'));
    // table header --------------------------------------------------------------------------------------------
    $cont_h = array($lang->def('_RULE_TEXT'), $lang->def('_RULE_ACTION'), '<img src="' . getPathImage('lms') . 'standard/modelem.png" alt="' . $lang->def('_ALT_ADD_EFFECT') . '" />', '<img src="' . getPathImage('lms') . 'standard/edit.png" alt="' . $lang->def('_MOD') . '" />', '<img src="' . getPathImage('lms') . 'standard/delete.png" alt="' . $lang->def('_DEL') . '" />');
    $type_h = array('nowrap', '', 'image', 'image', 'image');
    $usedef = 1;
    $tb->addHead($cont_h, $type_h);
    while ($rule = $rule_man->fetch_row($rule_list)) {
        $id = $rule[RULE_ID];
        if ($rule[RULE_TYPE] == RULE_DEFAULT) {
            $usedef = 0;
        }
        $rule_name = $rule_man->resolveRuleTypePhrase($lang, $rule);
        $cont = array($rule_name);
        $effect = '';
        $effects = $rule_man->parseEffects($rule[RULE_EFFECT]);
        if (count($effects['course']) > 0) {
            $effect .= $lang->def('_COURSES') . ': ' . $course_man->listCourseName($effects['course']);
        }
        if (count($effects['coursepath']) > 0) {
            if (count($effects['course']) > 0) {
                $effect .= '<br/>';
            }
            $path_list =& $coursepath_man->getNames($effects['coursepath']);
            $effect .= $lang->def('_COURSEPATH') . ': ' . implode(', ', $path_list);
        }
        if (count($effects['course']) == 0 && count($effects['coursepath']) == 0) {
            $effect = $lang->def('_DO_NOTHING');
        }
        $cont[] = $effect;
        $cont[] = '<a href="' . $url->getUrl('op=assignrule&id_rule=' . $id . '&load=1') . '" title=""' . $lang->def('_ADD_EFFECT') . '">' . '<img src="' . getPathImage('lms') . 'standard/modelem.png" alt="' . $lang->def('_ALT_ADD_EFFECT') . '" />' . '</a>';
        $cont[] = '<a href="' . $url->getUrl('op=modrulet&id_rule=' . $id) . '" title="' . $lang->def('_MOD_TITLE') . '"' . '" onclick="mod_rule_mask(\'' . $id_assessment . '\', \'' . $id . '\'); return false;"' . '>' . '<img src="' . getPathImage('lms') . 'standard/edit.png" alt="' . $lang->def('_MOD') . '" />' . '</a>';
        $cont[] = '<a href="' . $url->getUrl('op=delrule&id_rule=' . $id) . '" title="' . $lang->def('_DEL') . ': ' . $rule_name . '"' . '	onclick="del_assessment_rule(\'' . $id . '\', \'' . strip_tags($rule_name) . '\'); return false;"' . '>' . '<img src="' . getPathImage('lms') . 'standard/delete.png" alt="' . $lang->def('_DEL') . '" />' . '</a>';
        $tb->addBody($cont);
    }
    require_once _base_ . '/lib/lib.dialog.php';
    setupHrefDialogBox('a[href*=delrule]');
    $tb->addActionAdd('<a class="new_element_link" ' . ' 	onclick="add_rule_mask(\'' . $id_assessment . '\', \'' . $usedef . '\'); return false;"' . ' id="add_rule" ' . 'href="#" ' . '>' . $lang->def('_ADD_RULE') . '</a>');
    $GLOBALS['page']->add('<script type="text/javascript">' . 'YAHOO.util.Event.onDOMReady( function(e) {' . ' setup_assessment(); ' . ' YAHOO.util.Event.addListener("add_rule", "click", function(e) { add_rule_mask(\'' . $id_assessment . '\', \'' . $usedef . '\'); });' . '});' . '</script>', 'page_head');
    $GLOBALS['page']->add(getTitleArea(array($url->getUrl() => $lang->def('_ASSESSMENT'), $lang->def('_RULES') . ': ' . $assessment['name']), 'preassessment') . '<div class="std_block">' . getInfoUi($lang->def('_RULE_OVERLAPPED')), 'content');
    if (isset($_GET['result'])) {
        $GLOBALS['page']->add(guiResultStatus($lang, $_GET['result']), 'content');
    }
    $GLOBALS['page']->add($tb->getTable(), 'content');
    $GLOBALS['page']->add(getBackUi($url->getUrl(), $lang->def('_BACK')) . '</div>', 'content');
}