本文整理汇总了PHP中Category::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::load方法的具体用法?PHP Category::load怎么用?PHP Category::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
function render()
{
switch (@$_GET["type"]) {
case 'Content':
$this->type = 'Content';
break;
case 'Default':
default:
$this->type = 'Default';
}
if (@$_GET['a'] == "edit" && !empty($_GET['cat_id'])) {
$edit_cat = new Category();
$edit_cat->category_id = $_GET['cat_id'];
$edit_cat->load();
$this->edit_title = $edit_cat->name;
$this->edit_desc = $edit_cat->description;
$this->cat_id = $edit_cat->category_id;
$this->type = $edit_cat->type;
$parent_id = $edit_cat->find_parent($edit_cat->category_id);
$this->parent_id = $parent_id ? $parent_id : 0;
if ($this->parent_id) {
$edit_cat->category_id = $this->parent_id;
$edit_cat->load();
$this->parent_name = $edit_cat->name;
} else {
$this->parent_name = '';
}
}
$this->categories = Category::build_all_category_list('', '', '', $this->type);
$category = Category::build_root_list(NULL, $this->type);
if (is_array($category)) {
foreach ($category as $catg) {
$this->get_childs($catg);
}
}
$this->inner_HTML = $this->generate_inner_html();
$content = parent::render();
return $content;
}
示例2: all
public static function all()
{
$aCategories = [];
$oCon = new Connection();
$sSQL = 'SELECT CategoryID FROM tbcategory WHERE Active=1';
$oResultSet = $oCon->query($sSQL);
while ($aRow = $oCon->fetchArray($oResultSet)) {
$iCategoryID = $aRow['CategoryID'];
$oCategory = new Category();
$oCategory->load($iCategoryID);
$aCategories[] = $oCategory;
}
$oCon->close();
return $aCategories;
}
示例3: LinkAddEditForm
/**
* Constructor
* To add link, define category_object and link_type
* To edit link, define link_object
*/
function LinkAddEditForm($form_type, $category_object, $link_type, $link_object, $form_name, $action = null)
{
parent::__construct($form_name, 'post', $action);
// set or create link object
if (isset($link_object)) {
$link = $link_object;
} elseif (isset($link_type) && isset($category_object)) {
$link = LinkFactory::create($link_type);
$link->set_course_code(api_get_course_id());
} else {
die('LinkAddEditForm error: define link_type/category_object or link_object');
}
$defaults = array();
$this->addElement('hidden', 'zero', 0);
if (!empty($_GET['editlink'])) {
$this->addElement('header', '', get_lang('EditLink'));
}
// ELEMENT: name
if ($form_type == self::TYPE_ADD || $link->is_allowed_to_change_name()) {
if ($link->needs_name_and_description()) {
$this->add_textfield('name', get_lang('Name'), true, array('size' => '40', 'maxlength' => '40'));
} else {
$select = $this->addElement('select', 'select_link', get_lang('ChooseItem'));
foreach ($link->get_all_links() as $newlink) {
$select->addoption($newlink[1], $newlink[0]);
}
}
} else {
$this->addElement('label', get_lang('Name'), '<span class="freeze">' . $link->get_name() . ' [' . $link->get_type_name() . ']</span>');
$this->addElement('hidden', 'name_link', $link->get_name(), array('id' => 'name_link'));
}
if (count($category_object) == 1) {
$this->addElement('hidden', 'select_gradebook', $category_object[0]->get_id());
} else {
$select_gradebook = $this->addElement('select', 'select_gradebook', get_lang('SelectGradebook'), array(), array('id' => 'hide_category_id'));
$this->addRule('select_gradebook', get_lang('ThisFieldIsRequired'), 'nonzero');
$default_weight = 0;
if (!empty($category_object)) {
foreach ($category_object as $my_cat) {
if ($my_cat->get_course_code() == api_get_course_id()) {
$grade_model_id = $my_cat->get_grade_model_id();
if (empty($grade_model_id)) {
if ($my_cat->get_parent_id() == 0) {
$default_weight = $my_cat->get_weight();
$select_gradebook->addoption(get_lang('Default'), $my_cat->get_id());
} else {
$select_gradebook->addoption($my_cat->get_name(), $my_cat->get_id());
}
} else {
$select_gradebook->addoption(get_lang('Select'), 0);
}
if ($link->get_category_id() == $my_cat->get_id()) {
$default_weight = $my_cat->get_weight();
}
}
}
}
}
$this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. ' . $category_object[0]->get_weight() . '] '), true, array('size' => '4', 'maxlength' => '5', 'class' => 'span1'));
$this->addElement('hidden', 'weight');
/*
// ELEMENT: weight
$this->add_textfield('weight', array(get_lang('Weight'), null, '/ <span id="max_weight">'.$default_weight.'</span>'), true, array (
'size' => '4',
'maxlength' => '5',
'class' => 'span1'
));*/
$this->addRule('weight_mask', get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
if ($form_type == self::TYPE_EDIT) {
$parent_cat = Category::load($link->get_category_id());
if ($parent_cat[0]->get_parent_id() == 0) {
$values['weight'] = $link->get_weight();
} else {
$cat = Category::load($parent_cat[0]->get_parent_id());
//$global_weight = $cat[0]->get_weight();
//$values['weight'] = $link->get_weight()/$parent_cat[0]->get_weight()*$global_weight;
//$weight = $parent_cat[0]->get_weight()* $link->get_weight() / $global_weight;
//$values['weight'] = $weight;
$values['weight'] = $link->get_weight();
}
$defaults['weight_mask'] = $values['weight'];
$defaults['select_gradebook'] = $link->get_category_id();
}
// ELEMENT: max
if ($link->needs_max()) {
if ($form_type == self::TYPE_EDIT && $link->has_results()) {
$this->add_textfield('max', get_lang('QualificationNumeric'), false, array('size' => '4', 'maxlength' => '5', 'disabled' => 'disabled'));
} else {
$this->add_textfield('max', get_lang('QualificationNumeric'), true, array('size' => '4', 'maxlength' => '5'));
$this->addRule('max', get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array('max', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
}
if ($form_type == self::TYPE_EDIT) {
//.........这里部分代码省略.........
示例4: get_data
/**
* Get actual array data
* @return array 2-dimensional array - each array contains the elements:
* 0: user id
* 1: user lastname
* 2: user firstname
* 3+: evaluation/link scores
*/
public function get_data($users_sorting = 0, $users_start = 0, $users_count = null, $items_start = 0, $items_count = null, $ignore_score_color = false, $show_all = false)
{
// do some checks on users/items counts, redefine if invalid values
if (!isset($users_count)) {
$users_count = count($this->users) - $users_start;
}
if ($users_count < 0) {
$users_count = 0;
}
if (!isset($items_count)) {
$items_count = count($this->evals) + count($this->links) - $items_start;
}
if ($items_count < 0) {
$items_count = 0;
}
// copy users to a new array that we will sort
// TODO - needed ?
$userTable = array();
foreach ($this->users as $user) {
$userTable[] = $user;
}
// sort users array
if ($users_sorting & self::FVDG_SORT_LASTNAME) {
usort($userTable, array('FlatViewDataGenerator', 'sort_by_last_name'));
} elseif ($users_sorting & self::FVDG_SORT_FIRSTNAME) {
usort($userTable, array('FlatViewDataGenerator', 'sort_by_first_name'));
}
if ($users_sorting & self::FVDG_SORT_DESC) {
$userTable = array_reverse($userTable);
}
// select the requested users
$selected_users = array_slice($userTable, $users_start, $users_count);
// generate actual data array
$scoredisplay = ScoreDisplay::instance();
$data = array();
$displaytype = SCORE_DIV;
if ($ignore_score_color) {
$displaytype |= SCORE_IGNORE_SPLIT;
}
//@todo move these in a function
$sum_categories_weight_array = array();
$mainCategoryId = null;
$mainCourseCategory = $this->getMainCourseCategory();
if (!empty($mainCourseCategory)) {
$mainCategoryId = $mainCourseCategory->get_id();
}
if (isset($this->category) && !empty($this->category)) {
$categories = Category::load(null, null, null, $this->category->get_id());
if (!empty($categories)) {
foreach ($categories as $category) {
$sum_categories_weight_array[$category->get_id()] = $category->get_weight();
}
} else {
$sum_categories_weight_array[$this->category->get_id()] = $this->category->get_weight();
}
}
$parent_id = $this->category->get_parent_id();
if ($parent_id == 0 or $this->params['only_subcat'] == $this->category->get_id()) {
$main_weight = $this->category->get_weight();
$grade_model_id = $this->category->get_grade_model_id();
} else {
$main_cat = Category::load($parent_id, null, null);
$main_weight = $main_cat[0]->get_weight();
$grade_model_id = $main_cat[0]->get_grade_model_id();
}
$use_grade_model = true;
if (empty($grade_model_id) || $grade_model_id == -1) {
$use_grade_model = false;
}
$export_to_pdf = false;
if (isset($this->params['export_pdf']) && $this->params['export_pdf']) {
$export_to_pdf = true;
}
foreach ($selected_users as $user) {
$row = array();
if ($export_to_pdf) {
$row['user_id'] = $user_id = $user[0];
//user id
} else {
$row[] = $user_id = $user[0];
//user id
}
if (isset($this->params['show_official_code']) && $this->params['show_official_code']) {
if ($export_to_pdf) {
$row['official_code'] = $user[4];
//official code
} else {
$row[] = $user[4];
//official code
}
}
if (isset($this->params['join_firstname_lastname']) && $this->params['join_firstname_lastname']) {
//.........这里部分代码省略.........
示例5: get_students_content_html_for_drh
public function get_students_content_html_for_drh()
{
$attendance = new Attendance();
$students = $this->students;
$content = '<div style="margin:5px;">';
$content .= '<h3><font color="#000">' . get_lang('YourStudents') . '</font></h3>';
$students_table = null;
if (count($students) > 0) {
$students_table .= '<table class="data_table">';
$students_table .= '<tr>
<th>' . get_lang('User') . '</th>
<th>' . get_lang('AttendancesFaults') . '</th>
<th>' . get_lang('Evaluations') . '</th>
</tr>';
$i = 1;
foreach ($students as $student) {
$student_id = $student['user_id'];
$firstname = $student['firstname'];
$lastname = $student['lastname'];
$username = $student['username'];
// get average of faults in attendances by student
$results_faults_avg = $attendance->get_faults_average_inside_courses($student_id);
if (!empty($results_faults_avg)) {
$attendances_faults_avg = '<a title="' . get_lang('GoToStudentDetails') . '" href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student=' . $student_id . '">' . $results_faults_avg['faults'] . '/' . $results_faults_avg['total'] . ' (' . $results_faults_avg['porcent'] . '%)</a>';
} else {
$attendances_faults_avg = '0%';
}
$courses_by_user = CourseManager::get_courses_list_by_user_id($student_id, true);
$evaluations_avg = 0;
$score = $weight = 0;
foreach ($courses_by_user as $course) {
$course_code = $course['code'];
$cats = Category::load(null, null, $course_code, null, null, null, false);
$scoretotal = array();
if (isset($cats) && isset($cats[0])) {
$scoretotal = $cats[0]->calc_score($student_id, $course_code);
}
if (!empty($scoretotal)) {
$score += $scoretotal[0];
$weight += $scoretotal[1];
}
}
if (!empty($weight)) {
$evaluations_avg = '<a title="' . get_lang('GoToStudentDetails') . '" href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student=' . $student_id . '">' . round($score, 2) . '/' . round($weight, 2) . '(' . round($score / $weight * 100, 2) . ' %)</a>';
}
if ($i % 2 == 0) {
$class_tr = 'row_odd';
} else {
$class_tr = 'row_even';
}
$students_table .= '<tr class="' . $class_tr . '">
<td>' . api_get_person_name($firstname, $lastname) . ' (' . $username . ')</td>
<td>' . $attendances_faults_avg . '</td>
<td>' . $evaluations_avg . '</td>
</tr>';
$i++;
}
$students_table .= '</table>';
} else {
$students_table .= get_lang('ThereIsNoInformationAboutYourStudents');
}
$content .= $students_table;
if (count($students) > 0) {
$content .= '<div style="text-align:right;margin-top:10px;">
<a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/index.php?view=admin&display=yourstudents">' . get_lang('SeeMore') . '</a>
</div>';
}
$content .= '</div>';
return $content;
}
示例6: isset
if (!empty($keyword)) {
$users = GradebookUtils::find_students($keyword);
} else {
if (isset($alleval) && isset($alllinks)) {
$users = GradebookUtils::get_all_users($alleval, $alllinks);
} else {
$users = null;
}
}
$offset = isset($_GET['offset']) ? $_GET['offset'] : '0';
$addparams = array('selectcat' => $cat[0]->get_id());
if (isset($_GET['search'])) {
$addparams['search'] = $keyword;
}
// Main course category
$mainCourseCategory = Category::load(null, null, api_get_course_id(), null, null, api_get_session_id());
$flatviewtable = new FlatViewTable($cat[0], $users, $alleval, $alllinks, true, $offset, $addparams, $mainCourseCategory[0]);
$flatviewtable->setAutoFill(false);
$parameters = array('selectcat' => intval($_GET['selectcat']));
$flatviewtable->set_additional_parameters($parameters);
$params = array();
if (isset($_GET['export_pdf']) && $_GET['export_pdf'] == 'category') {
$params['only_total_category'] = true;
$params['join_firstname_lastname'] = true;
$params['show_official_code'] = true;
$params['export_pdf'] = true;
if ($cat[0]->is_locked() == true || api_is_platform_admin()) {
Display::set_header(null, false, false);
GradebookUtils::export_pdf_flatview($flatviewtable, $cat, $users, $alleval, $alllinks, $params, $mainCourseCategory[0]);
}
}
示例7: api_not_allowed
if ($link->is_locked() && !api_is_platform_admin()) {
api_not_allowed();
}
$linkcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : '';
$linkedit = isset($_GET['editlink']) ? Security::remove_XSS($_GET['editlink']) : '';
$session_id = api_get_session_id();
if ($session_id == 0) {
$cats = Category::load(null, null, $course_code, null, null, $session_id, false);
//already init
} else {
$cats = Category::load_session_categories(null, $session_id);
}
$form = new LinkAddEditForm(LinkAddEditForm::TYPE_EDIT, $cats, null, $link, 'edit_link_form', api_get_self() . '?selectcat=' . $linkcat . '&editlink=' . $linkedit . '&' . api_get_cidreq());
if ($form->validate()) {
$values = $form->exportValues();
$parent_cat = Category::load($values['select_gradebook']);
$final_weight = null;
/*
if ($parent_cat[0]->get_parent_id() == 0) {
$final_weight = $values['weight_mask'];
} else {
$cat = Category :: load($parent_cat[0]->get_parent_id());
$global_weight = $cat[0]->get_weight();
$final_weight = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight();
}*/
$final_weight = $values['weight_mask'];
$link->set_weight($final_weight);
if (!empty($values['select_gradebook'])) {
$link->set_category_id($values['select_gradebook']);
}
$link->set_visible(empty($values['visible']) ? 0 : 1);
示例8: api_get_cidreq
$buttonHomeUrl = 'lp_controller.php?' . api_get_cidreq() . '&' . http_build_query(['isStudentView' => 'false', 'action' => 'return_to_course_homepage']);
} else {
$buttonHomeUrl = 'lp_controller.php?' . api_get_cidreq() . '&' . http_build_query(['action' => 'return_to_course_homepage']);
}
$buttonHomeText = get_lang('CourseHomepageLink');
// Return to lp list
if (api_get_course_setting('lp_return_link') == 1) {
$buttonHomeUrl .= '&redirectTo=lp_list';
$buttonHomeText = get_lang('LearningPathList');
}
$lpPreviewImagePath = api_get_path(WEB_IMG_PATH) . 'icons/64/unknown.png';
if ($learnPath->get_preview_image()) {
$lpPreviewImagePath = $learnPath->get_preview_image_path();
}
if ($learnPath->current == $learnPath->get_last()) {
$categories = Category::load(null, null, $course_code, null, null, $sessionId);
if (!empty($categories)) {
$gradebookEvaluations = $categories[0]->get_evaluations();
$gradebookLinks = $categories[0]->get_links();
if (count($gradebookEvaluations) === 0 && count($gradebookLinks) === 1 && $gradebookLinks[0]->get_type() == LINK_LEARNPATH && $gradebookLinks[0]->get_ref_id() == $learnPath->lp_id) {
$gradebookMinScore = $categories[0]->get_certificate_min_score();
$userScore = $gradebookLinks[0]->calc_score($user_id, 'best');
if ($userScore[0] >= $gradebookMinScore) {
Category::register_user_certificate($categories[0]->get_id(), $user_id);
}
}
}
}
$template = \Chamilo\CoreBundle\Framework\Container::getTwig();
$template->addGlobal('glossary_extra_tools', api_get_setting('glossary.show_glossary_in_extra_tools'));
$fixLinkSetting = api_get_configuration_value('lp_fix_embed_content');
示例9: pageLoadGroup
function pageLoadGroup($group)
{
$access = $group->access_type;
$skip_group_modules = FALSE;
$is_admin = FALSE;
if ($group->access_type == $group->ACCESS_PRIVATE) {
if (PA::$login_uid) {
//if private group
if (GROUP::member_exists($group->collection_id, PA::$login_uid)) {
$skip_group_modules = FALSE;
} else {
// haha no way for non member of group
$skip_group_modules = TRUE;
}
} else {
//haha no way for anonymous user
$skip_group_modules = TRUE;
}
$access_type = 'Private';
} else {
$access_type = 'Public';
}
if ($group->reg_type == $group->REG_OPEN) {
$access_type .= ' Open';
} else {
$access_type .= ' Moderated';
}
if (Group::is_admin((int) $group->collection_id, (int) PA::$login_uid)) {
$is_admin = TRUE;
}
$members = $group->get_members($cnt = FALSE, 5, 1, 'created', 'DESC', FALSE);
$group_details = array();
$group_details['collection_id'] = $group->collection_id;
$group_details['type'] = $group->type;
$group_details['author_id'] = $group->author_id;
$user = new User();
$user->load((int) $group->author_id);
$login_name = $user->login_name;
$first_name = $user->first_name;
$last_name = $user->last_name;
$group_details['author_name'] = $login_name;
$group_details['author_picture'] = $user->picture;
$group_details['title'] = $group->title;
$group_details['description'] = $group->description;
$group_details['is_active'] = $group->is_active;
$group_details['picture'] = $group->picture;
$group_details['desktop_picture'] = @$group->desktop_picture;
$group_details['created'] = PA::datetime($group->created, 'long', 'short');
// date("F d, Y h:i A", $group->created);
$group_details['changed'] = $group->changed;
$group_details['category_id'] = $group->category_id;
$cat_obj = new Category();
$cat_obj->set_category_id($group->category_id);
$cat_obj->load();
$cat_name = stripslashes($cat_obj->name);
$cat_description = stripslashes($cat_obj->description);
$group_details['category_name'] = $cat_name;
$group_details['category_description'] = $cat_description;
$group_details['members'] = Group::get_member_count($group->collection_id);
$group_details['access_type'] = $access_type;
$group_details['is_admin'] = $is_admin;
//////////////////get details of group EOF
if (is_array($members)) {
$count = count($members);
foreach ($members as $member) {
$count_relations = Relation::get_relations($member['user_id'], APPROVED, PA::$network_info->network_id);
$user = new User();
$user->load((int) $member['user_id']);
$login_name = $user->login_name;
$user_picture = $user->picture;
$users_data[] = array('user_id' => $member['user_id'], 'picture' => $user_picture, 'login_name' => $login_name, 'no_of_relations' => count($count_relations));
}
$final_array = array('users_data' => $users_data, 'total_users' => $count);
}
$users = $final_array;
$is_member = Group::member_exists((int) $group->collection_id, (int) PA::$login_uid) ? TRUE : FALSE;
$group_details['is_member'] = $is_member;
$group_details['skip_group_modules'] = $skip_group_modules;
$group_details['users'] = $users;
return $group_details;
}
示例10: register_user_certificate
static function register_user_certificate($category_id, $user_id)
{
// generating the total score for a course
$cats_course = Category::load($category_id, null, null, null, null, null, false);
$alleval_course = $cats_course[0]->get_evaluations($user_id, true);
$alllink_course = $cats_course[0]->get_links($user_id, true);
$evals_links = array_merge($alleval_course, $alllink_course);
$item_total = 0;
//@todo move these in a function
$sum_categories_weight_array = array();
if (isset($cats_course) && !empty($cats_course)) {
$categories = Category::load(null, null, null, $category_id);
if (!empty($categories)) {
foreach ($categories as $category) {
$sum_categories_weight_array[$category->get_id()] = $category->get_weight();
}
} else {
$sum_categories_weight_array[$category_id] = $cats_course[0]->get_weight();
}
}
$main_weight = $cats_course[0]->get_weight();
$item_total_value = 0;
$item_value = 0;
for ($count = 0; $count < count($evals_links); $count++) {
$item = $evals_links[$count];
$score = $item->calc_score($user_id);
$divide = $score[1] == 0 ? 1 : $score[1];
$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
$item_value = $score[0] / $divide * $item->get_weight() * $sub_cat_percentage / $main_weight;
$item_total_value += $item_value;
}
$item_total_value = (double) $item_total_value;
$cattotal = Category::load($category_id);
$scoretotal = $cattotal[0]->calc_score($user_id);
//Do not remove this the gradebook/lib/fe/gradebooktable.class.php file load this variable as a global
$scoredisplay = ScoreDisplay::instance();
$my_score_in_gradebook = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE);
//Show certificate
$certificate_min_score = $cats_course[0]->get_certificate_min_score();
$scoretotal_display = $scoredisplay->display_score($scoretotal, SCORE_DIV_PERCENT);
//a student always sees only the teacher's repartition
if (isset($certificate_min_score) && $item_total_value >= $certificate_min_score) {
$my_certificate = get_certificate_by_user_id($cats_course[0]->get_id(), $user_id);
if (empty($my_certificate)) {
register_user_info_about_certificate($category_id, $user_id, $my_score_in_gradebook, api_get_utc_datetime());
$my_certificate = get_certificate_by_user_id($cats_course[0]->get_id(), $user_id);
}
if (!empty($my_certificate)) {
$certificate_obj = new Certificate($my_certificate['id']);
$url = Certificate::getCertificatePublicURL($my_certificate['id']);
$certificates = Display::url(Display::return_icon('certificate.png', get_lang('Certificates'), array(), 32), $url, array('target' => '_blank'));
$html = '<div class="actions" align="right">';
$html .= Display::url($url, $url, array('target' => '_blank'));
$html .= $certificates;
$html .= '</div>';
return $html;
}
} else {
return false;
}
}
示例11: getUserCertificatesInSessions
/**
* Get the achieved certificates for a user in course sessions
* @param int $userId The user id
* @param type $includeNonPublicCertificates Whether include the non-plublic certificates
* @return array
*/
public static function getUserCertificatesInSessions($userId, $includeNonPublicCertificates = true)
{
$userId = intval($userId);
$sessionList = [];
$sessions = SessionManager::get_sessions_by_user($userId);
foreach ($sessions as $session) {
if (empty($session['courses'])) {
continue;
}
$sessionCourses = SessionManager::get_course_list_by_session_id($session['session_id']);
foreach ($sessionCourses as $course) {
if (!$includeNonPublicCertificates) {
$allowPublicCertificates = api_get_course_setting('allow_public_certificates', $course['code']);
if (empty($allowPublicCertificates)) {
continue;
}
}
$courseGradebookCategory = Category::load(null, null, $course['code'], null, null, $session['session_id']);
if (empty($courseGradebookCategory)) {
continue;
}
$courseGradebookId = $courseGradebookCategory[0]->get_id();
$certificateInfo = GradebookUtils::get_certificate_by_user_id($courseGradebookId, $userId);
if (empty($certificateInfo)) {
continue;
}
$sessionList[] = ['session' => $session['session_name'], 'course' => $course['title'], 'score' => $certificateInfo['score_certificate'], 'date' => api_format_date($certificateInfo['created_at'], DATE_FORMAT_SHORT), 'link' => api_get_path(WEB_PATH) . "certificates/index.php?id={$certificateInfo['id']}"];
}
}
return $sessionList;
}
示例12: api_protect_course_script
<?php
/* For licensing terms, see /license.txt */
/**
* Script
* @package chamilo.gradebook
*/
//require_once '../inc/global.inc.php';
$current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script(true);
api_block_anonymous_users();
GradebookUtils::block_students();
$catadd = new Category();
$catadd->set_user_id(api_get_user_id());
$catadd->set_parent_id($_GET['selectcat']);
$catcourse = Category::load($_GET['selectcat']);
$form = new CatForm(CatForm::TYPE_SELECT_COURSE, $catadd, 'add_cat_form', null, api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&' . api_get_cidreq());
if ($form->validate()) {
$values = $form->exportValues();
$cat = new Category();
$cat->set_course_code($values['select_course']);
$cat->set_name($values['name']);
header('location: gradebook_add_link.php?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&course_code=' . Security::remove_XSS($values['select_course']) . '&' . api_get_cidreq());
exit;
}
$interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&' . api_get_cidreq(), 'name' => get_lang('Gradebook'));
Display::display_header(get_lang('NewCategory'));
$form->display();
Display::display_footer();
示例13: array
$courses = CourseManager::get_courses_list(0, 0, 'title');
$options = array();
foreach ($courses as $course) {
$options[$course['id']] = $course['title'];
}
$form->addElement('select', 'course', get_lang('Course'), $options);
$form->addElement('file', 'file', get_lang('File'));
$form->add_button('submit', get_lang('Submit'));
$form->display();
if ($form->validate()) {
$values = $form->getSubmitValues();
if (isset($_FILES['file']['tmp_name']) && !empty($_FILES['file']['tmp_name'])) {
$users = Import::csv_reader($_FILES['file']['tmp_name']);
$courseId = $values['course'];
$courseInfo = api_get_course_info_by_id($courseId);
$courseCode = $courseInfo['code'];
$cats = Category::load(null, null, $courseCode, null, null, 0, false);
if (isset($cats[0])) {
/** @var Category $cat */
$userList = array();
foreach ($users as $user) {
$userInfo = api_get_user_info_from_official_code($user['official_code']);
if (!empty($userInfo)) {
$userList[] = $userInfo;
}
}
Category::exportAllCertificates($cat->get_id(), $userList);
}
}
}
Display::display_footer();
示例14: api_get_path
<?php
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls
*/
require_once '../global.inc.php';
require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be.inc.php';
require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/gradebook_functions.inc.php';
api_protect_course_script(true);
$action = $_REQUEST['a'];
switch ($action) {
case 'get_gradebook_weight':
if (api_is_allowed_to_edit(null, true)) {
$cat_id = $_GET['cat_id'];
$cat = Category::load($cat_id);
if ($cat && isset($cat[0])) {
echo $cat[0]->get_weight();
} else {
echo 0;
}
}
break;
default:
echo '';
}
exit;
示例15: add_courses_to_session
/**
* Subscribes courses to the given session and optionally (default)
* unsubscribes previous users
* @author Carlos Vargas from existing code
* @param int $sessionId
* @param array $courseList List of courses int ids
* @param bool $removeExistingCoursesWithUsers Whether to unsubscribe
* existing courses and users (true, default) or not (false)
* @param $copyEvaluation from base course to session course
* @return void Nothing, or false on error
* */
public static function add_courses_to_session($sessionId, $courseList, $removeExistingCoursesWithUsers = true, $copyEvaluation = false)
{
$sessionId = intval($sessionId);
if (empty($sessionId) || empty($courseList)) {
return false;
}
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
// Get list of courses subscribed to this session
$sql = "SELECT c_id\n FROM {$tbl_session_rel_course}\n WHERE session_id = {$sessionId}";
$rs = Database::query($sql);
$existingCourses = Database::store_result($rs);
$nbr_courses = count($existingCourses);
// Get list of users subscribed to this session
$sql = "SELECT user_id\n FROM {$tbl_session_rel_user}\n WHERE\n session_id = {$sessionId} AND\n relation_type<>" . SESSION_RELATION_TYPE_RRHH . "";
$result = Database::query($sql);
$user_list = Database::store_result($result);
// Remove existing courses from the session.
if ($removeExistingCoursesWithUsers === true && !empty($existingCourses)) {
foreach ($existingCourses as $existingCourse) {
if (!in_array($existingCourse['c_id'], $courseList)) {
$sql = "DELETE FROM {$tbl_session_rel_course}\n WHERE\n c_id = " . $existingCourse['c_id'] . " AND\n session_id = {$sessionId}";
Database::query($sql);
$sql = "DELETE FROM {$tbl_session_rel_course_rel_user}\n WHERE\n c_id = " . $existingCourse['c_id'] . " AND\n session_id = {$sessionId}";
Database::query($sql);
Event::addEvent(LOG_SESSION_DELETE_COURSE, LOG_COURSE_ID, $existingCourse['c_id'], api_get_utc_datetime(), api_get_user_id(), $existingCourse['c_id'], $sessionId);
CourseManager::remove_course_ranking($existingCourse['c_id'], $sessionId);
$nbr_courses--;
}
}
}
// Pass through the courses list we want to add to the session
foreach ($courseList as $courseId) {
$courseInfo = api_get_course_info_by_id($courseId);
// If course doesn't exists continue!
if (empty($courseInfo)) {
continue;
}
$exists = false;
// check if the course we want to add is already subscribed
foreach ($existingCourses as $existingCourse) {
if ($courseId == $existingCourse['c_id']) {
$exists = true;
}
}
if (!$exists) {
// Copy gradebook categories and links (from base course)
// to the new course session
if ($copyEvaluation) {
$cats = Category::load(null, null, $courseInfo['code']);
if (!empty($cats)) {
$categoryIdList = [];
/** @var Category $cat */
foreach ($cats as $cat) {
$categoryIdList[$cat->get_id()] = $cat->get_id();
}
$newCategoryIdList = [];
foreach ($cats as $cat) {
$links = $cat->get_links(null, false, $courseInfo['code'], 0);
$cat->set_session_id($sessionId);
$oldCategoryId = $cat->get_id();
$newId = $cat->add();
$newCategoryIdList[$oldCategoryId] = $newId;
$parentId = $cat->get_parent_id();
if (!empty($parentId)) {
$newParentId = $newCategoryIdList[$parentId];
$cat->set_parent_id($newParentId);
$cat->save();
}
/** @var AbstractLink $link */
foreach ($links as $link) {
$newCategoryId = $newCategoryIdList[$link->get_category_id()];
$link->set_category_id($newCategoryId);
$link->add();
}
}
// Create
DocumentManager::generateDefaultCertificate($courseInfo, true, $sessionId);
}
}
// If the course isn't subscribed yet
$sql = "INSERT INTO {$tbl_session_rel_course} (session_id, c_id)\n VALUES ({$sessionId}, {$courseId})";
Database::query($sql);
Event::addEvent(LOG_SESSION_ADD_COURSE, LOG_COURSE_ID, $courseId, api_get_utc_datetime(), api_get_user_id(), $courseId, $sessionId);
// We add the current course in the existing courses array,
// to avoid adding another time the current course
$existingCourses[] = array('c_id' => $courseId);
//.........这里部分代码省略.........