本文整理汇总了PHP中CourseManager::get_user_list_from_course_code方法的典型用法代码示例。如果您正苦于以下问题:PHP CourseManager::get_user_list_from_course_code方法的具体用法?PHP CourseManager::get_user_list_from_course_code怎么用?PHP CourseManager::get_user_list_from_course_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CourseManager
的用法示例。
在下文中一共展示了CourseManager::get_user_list_from_course_code方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display_add_form
/**
* this function displays the form to upload a new item to the dropbox.
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006
*/
function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategory, $view)
{
$course_info = api_get_course_info();
$_user = api_get_user_info();
$is_courseAdmin = api_is_course_admin();
$is_courseTutor = api_is_course_tutor();
$origin = isset($_GET['origin']) ? $_GET['origin'] : null;
$token = Security::get_token();
$dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
$form = new FormValidator('sent_form', 'post', api_get_self() . '?view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&' . api_get_cidreq(), null, array('enctype' => 'multipart/form-data', 'onsubmit' => 'javascript: return checkForm(this);'));
$form->addElement('header', get_lang('UploadNewFile'));
$form->addElement('hidden', 'MAX_FILE_SIZE', dropbox_cnf('maxFilesize'));
$form->addElement('hidden', 'dropbox_unid', $dropbox_unid);
$form->addElement('hidden', 'sec_token', $token);
$form->addElement('hidden', 'origin', $origin);
$form->addElement('file', 'file', get_lang('UploadFile'), array('onChange' => 'javascript: checkfile(this.value);'));
if (dropbox_cnf('allowOverwrite')) {
$form->addElement('checkbox', 'cb_overwrite', null, get_lang('OverwriteFile'), array('id' => 'cb_overwrite'));
}
// List of all users in this course and all virtual courses combined with it
if (api_get_session_id()) {
$complete_user_list_for_dropbox = array();
if (api_get_setting('dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) {
$complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id());
}
$complete_user_list2 = CourseManager::get_coach_list_from_course_code($course_info['code'], api_get_session_id());
$complete_user_list_for_dropbox = array_merge($complete_user_list_for_dropbox, $complete_user_list2);
} else {
if (api_get_setting('dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) {
$complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id());
} else {
$complete_user_list_for_dropbox = CourseManager::get_teacher_list_from_course_code($course_info['code'], false);
}
}
if (!empty($complete_user_list_for_dropbox)) {
foreach ($complete_user_list_for_dropbox as $k => $e) {
$complete_user_list_for_dropbox[$k] = $e + array('lastcommafirst' => api_get_person_name($e['firstname'], $e['lastname']));
}
$complete_user_list_for_dropbox = TableSort::sort_table($complete_user_list_for_dropbox, 'lastcommafirst');
}
/*
Create the options inside the select box:
List all selected users their user id as value and a name string as display
*/
$current_user_id = '';
$options = array();
foreach ($complete_user_list_for_dropbox as $current_user) {
if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin || dropbox_cnf('allowStudentToStudent') || $current_user['status'] != 5 || $current_user['tutor_id'] == 1) && $current_user['user_id'] != $_user['user_id']) {
// Don't include yourself.
if ($current_user['user_id'] == $current_user_id) {
continue;
}
$full_name = $current_user['lastcommafirst'];
$current_user_id = $current_user['user_id'];
$options['user_' . $current_user_id] = $full_name;
//echo '<option value="user_' . $current_user_id . '">' . $full_name . '</option>';
}
}
/*
* Show groups
*/
if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin) && dropbox_cnf('allowGroup') || dropbox_cnf('allowStudentToStudent')) {
$complete_group_list_for_dropbox = GroupManager::get_group_list(null, dropbox_cnf('courseId'));
if (count($complete_group_list_for_dropbox) > 0) {
foreach ($complete_group_list_for_dropbox as $current_group) {
if ($current_group['number_of_members'] > 0) {
//echo '<option value="group_'.$current_group['id'].'">G: '.$current_group['name'].' - '.$current_group['number_of_members'].' '.get_lang('Users').'</option>';
$options['group_' . $current_group['id']] = 'G: ' . $current_group['name'] . ' - ' . $current_group['number_of_members'] . ' ' . get_lang('Users');
}
}
}
}
if (dropbox_cnf('allowJustUpload')) {
//echo '<option value="upload">'.get_lang('JustUploadInSelect').'</option>';
//echo '<option value="user_'.$_user['user_id'].'">'.get_lang('JustUploadInSelect').'</option>';
$options['user_' . $_user['user_id']] = get_lang('JustUploadInSelect');
}
$form->addElement('select', 'recipients', get_lang('SendTo'), $options, array('multiple' => 'multiple', 'size' => '10', 'class' => 'span4'));
$form->addElement('button', 'submitWork', get_lang('Upload'));
$form->display();
}
示例2: get_lang
$columns[] = $extra['1'];
$column_names[] = $extra['3'];
}
}
if (api_is_student_boss()) {
$columns[] = 'group';
$column_names[] = get_lang('Group');
}
if (!in_array($sidx, array('title'))) {
$sidx = 'title';
}
if (api_is_student_boss() && empty($userIdList)) {
$result = [];
break;
}
$result = CourseManager::get_user_list_from_course_code(null, null, "LIMIT {$start}, {$limit}", " {$sidx} {$sord}", null, null, true, false, null, $courseCodeList, $userIdList, null, $sessionIdList);
if (api_is_student_boss()) {
$userGroup = new UserGroup();
foreach ($result as &$item) {
$userGroups = $userGroup->get_groups_by_user($item['user_id']);
$item['group'] = implode(", ", array_column($userGroups, 'name'));
unset($item['user_id']);
}
}
break;
case 'get_user_skill_ranking':
$columns = array('photo', 'firstname', 'lastname', 'skills_acquired', 'currently_learning', 'rank');
$result = $skill->get_user_list_skill_ranking($start, $limit, $sidx, $sord, $whereCondition);
$result = ArrayClass::msort($result, 'skills_acquired', 'asc');
$skills_in_course = array();
if (!empty($result)) {
示例3: get_complete_list_of_users_that_can_be_added_to_group
/**
* Get a combined list of all users of the real course $course_code
* and all users in virtual courses linked to this course $course_code
* Filter user list: remove duplicate users; plus
* remove users that
* - are already in the current group $group_id;
* - do not have student status in these courses;
* - are not appointed as tutor (group assistent) for this group;
* - have already reached their maximum # of groups in this course.
*
* Originally to get the correct list of users a big SQL statement was used,
* but this has become more complicated now there is not just one real course but many virtual courses.
* Still, that could have worked as well.
*
* @version 1.1.3
* @author Roan Embrechts
*/
public static function get_complete_list_of_users_that_can_be_added_to_group($course_code, $group_id)
{
global $_course, $_user;
$category = self::get_category_from_group($group_id, $course_code);
$number_of_groups_limit = $category['groups_per_user'] == self::GROUP_PER_MEMBER_NO_LIMIT ? self::INFINITE : $category['groups_per_user'];
$real_course_code = $_course['sysCode'];
$real_course_info = Database::get_course_info($real_course_code);
$real_course_user_list = CourseManager::get_user_list_from_course_code($real_course_code);
//get list of all virtual courses
$user_subscribed_course_list = CourseManager::get_list_of_virtual_courses_for_specific_user_and_real_course($_user['user_id'], $real_course_code);
//add real course to the list
$user_subscribed_course_list[] = $real_course_info;
if (!is_array($user_subscribed_course_list)) {
return;
}
//for all courses...
foreach ($user_subscribed_course_list as $this_course) {
$this_course_code = $this_course['code'];
$course_user_list = CourseManager::get_user_list_from_course_code($this_course_code);
//for all users in the course
foreach ($course_user_list as $this_user) {
$user_id = $this_user['user_id'];
$loginname = $this_user['username'];
$lastname = $this_user['lastname'];
$firstname = $this_user['firstname'];
$status = $this_user['status'];
//$role = $this_user['role'];
$tutor_id = $this_user['tutor_id'];
$full_name = api_get_person_name($firstname, $lastname);
if ($lastname == "" || $firstname == '') {
$full_name = $loginname;
}
$complete_user['user_id'] = $user_id;
$complete_user['full_name'] = $full_name;
$complete_user['firstname'] = $firstname;
$complete_user['lastname'] = $lastname;
$complete_user['status'] = $status;
$complete_user['tutor_id'] = $tutor_id;
$student_number_of_groups = self::user_in_number_of_groups($user_id, $category['id']);
//filter: only add users that have not exceeded their maximum amount of groups
if ($student_number_of_groups < $number_of_groups_limit) {
$complete_user_list[] = $complete_user;
}
}
}
if (is_array($complete_user_list)) {
//sort once, on array field "full_name"
$complete_user_list = TableSort::sort_table($complete_user_list, "full_name");
//filter out duplicates, based on field "user_id"
$complete_user_list = self::filter_duplicates($complete_user_list, "user_id");
$complete_user_list = self::filter_users_already_in_group($complete_user_list, $group_id);
}
return $complete_user_list;
}
示例4: get_user_data
/**
* Get the users to display on the current page.
*/
function get_user_data($from, $number_of_items, $column, $direction)
{
global $origin;
global $course_info;
global $is_western_name_order;
global $session_id;
$a_users = array();
// limit
$limit = 'LIMIT ' . intval($from) . ',' . intval($number_of_items);
if (!in_array($direction, array('ASC', 'DESC'))) {
$direction = 'ASC';
}
switch ($column) {
case 2:
//official code
$order_by = 'ORDER BY user.official_code ' . $direction;
break;
case 3:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
} else {
$order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
}
break;
case 4:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
} else {
$order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
}
break;
case 5:
//username
$order_by = 'ORDER BY user.username ' . $direction;
break;
default:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
} else {
$order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
}
break;
}
$session_id = api_get_session_id();
$course_code = api_get_course_id();
$keyword = isset($_REQUEST['keyword']) ? $_REQUEST['keyword'] : null;
$a_course_users = CourseManager::get_user_list_from_course_code($course_code, $session_id, $limit, $order_by, null, $keyword);
foreach ($a_course_users as $user_id => $o_course_user) {
$groups_name = GroupManager::get_user_group_name($user_id);
$temp = array();
if (api_is_allowed_to_edit(null, true)) {
//if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
$temp[] = $user_id;
//}
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
$user_profile = UserManager::get_picture_user($user_id, $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
if (!api_is_anonymous()) {
$photo = '<a href="userInfo.php?' . api_get_cidreq() . '&origin=' . $origin . '&uInfo=' . $user_id . '" title="' . get_lang('Info') . '" ><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" title="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" /></a>';
} else {
$photo = '<img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" title="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" />';
}
$temp[] = $photo;
$temp[] = $o_course_user['official_code'];
if ($is_western_name_order) {
$temp[] = $o_course_user['firstname'];
$temp[] = $o_course_user['lastname'];
} else {
$temp[] = $o_course_user['lastname'];
$temp[] = $o_course_user['firstname'];
}
$temp[] = $o_course_user['username'];
$temp[] = isset($o_course_user['role']) ? $o_course_user['role'] : null;
//Description
$temp[] = implode(', ', $groups_name);
//Group
// Status
$default_status = '-';
if (isset($o_course_user['status_rel']) && $o_course_user['status_rel'] == 1 || isset($o_course_user['status_session']) && $o_course_user['status_session'] == 2) {
$default_status = get_lang('CourseManager');
} elseif (isset($o_course_user['tutor_id']) && $o_course_user['tutor_id'] == 1) {
$default_status = get_lang('Tutor');
}
$temp[] = $default_status;
//Active
$temp[] = $o_course_user['active'];
//User id for actions
$temp[] = $user_id;
} else {
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
if (!api_is_anonymous()) {
$photo = '<a href="userInfo.php?' . api_get_cidreq() . '&origin=' . $origin . '&uInfo=' . $user_id . '" title="' . get_lang('Info') . '" ><img src="' . $image_repository . $existing_image . '" alt="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" width="22" height="22" title="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" /></a>';
} else {
$photo = '<img src="' . $image_repository . $existing_image . '" alt="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" width="22" height="22" title="' . api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']) . '" />';
}
$temp[] = $user_id;
//.........这里部分代码省略.........
示例5: show_course_detail
/**
* Shows the user detail progress (when clicking in the details link)
* @param int $user_id
* @param string $course_code
* @param int $session_id
* @return string html code
*/
public static function show_course_detail($user_id, $course_code, $session_id)
{
$html = '';
if (isset($course_code)) {
$user_id = intval($user_id);
$session_id = intval($session_id);
$course = Database::escape_string($course_code);
$course_info = CourseManager::get_course_information($course);
$html .= Display::page_subheader($course_info['title']);
$html .= '<table class="data_table" width="100%">';
//Course details
$html .= '
<tr>
<th class="head" style="color:#000">' . get_lang('Exercises') . '</th>
<th class="head" style="color:#000">' . get_lang('Attempts') . '</th>
<th class="head" style="color:#000">' . get_lang('BestAttempt') . '</th>
<th class="head" style="color:#000">' . get_lang('Ranking') . '</th>
<th class="head" style="color:#000">' . get_lang('BestResultInCourse') . '</th>
<th class="head" style="color:#000">' . get_lang('Statistics') . ' ' . Display::return_icon('info3.gif', get_lang('OnlyBestResultsPerStudent'), array('align' => 'absmiddle', 'hspace' => '3px')) . '</th>
</tr>';
if (empty($session_id)) {
$user_list = CourseManager::get_user_list_from_course_code($course, $session_id, null, null, STUDENT);
} else {
$user_list = CourseManager::get_user_list_from_course_code($course, $session_id, null, null, 0);
}
// Show exercise results of invisible exercises? see BT#4091
$exercise_list = ExerciseLib::get_all_exercises($course_info, $session_id, false, null, false, 2);
$to_graph_exercise_result = array();
if (!empty($exercise_list)) {
$score = $weighting = $exe_id = 0;
foreach ($exercise_list as $exercices) {
$exercise_obj = new Exercise($course_info['real_id']);
$exercise_obj->read($exercices['id']);
$visible_return = $exercise_obj->is_visible();
$score = $weighting = $attempts = 0;
// Getting count of attempts by user
$attempts = Event::count_exercise_attempts_by_user(api_get_user_id(), $exercices['id'], $course_info['real_id'], $session_id);
$html .= '<tr class="row_even">';
$url = api_get_path(WEB_CODE_PATH) . "exercice/overview.php?cidReq={$course_info['code']}&id_session={$session_id}&exerciseId={$exercices['id']}";
if ($visible_return['value'] == true) {
$exercices['title'] = Display::url($exercices['title'], $url, array('target' => SESSION_LINK_TARGET));
}
$html .= Display::tag('td', $exercices['title']);
// Exercise configuration show results or show only score
if ($exercices['results_disabled'] == 0 || $exercices['results_disabled'] == 2) {
//For graphics
$best_exercise_stats = Event::get_best_exercise_results_by_user($exercices['id'], $course_info['real_id'], $session_id);
$to_graph_exercise_result[$exercices['id']] = array('title' => $exercices['title'], 'data' => $best_exercise_stats);
$latest_attempt_url = '';
$best_score = $position = $percentage_score_result = '-';
$graph = $normal_graph = null;
// Getting best results
$best_score_data = ExerciseLib::get_best_attempt_in_course($exercices['id'], $course_info['real_id'], $session_id);
$best_score = '';
if (!empty($best_score_data)) {
$best_score = ExerciseLib::show_score($best_score_data['exe_result'], $best_score_data['exe_weighting']);
}
if ($attempts > 0) {
$exercise_stat = ExerciseLib::get_best_attempt_by_user(api_get_user_id(), $exercices['id'], $course_info['real_id'], $session_id);
if (!empty($exercise_stat)) {
//Always getting the BEST attempt
$score = $exercise_stat['exe_result'];
$weighting = $exercise_stat['exe_weighting'];
$exe_id = $exercise_stat['exe_id'];
$latest_attempt_url .= api_get_path(WEB_CODE_PATH) . 'exercice/result.php?id=' . $exe_id . '&cidReq=' . $course_info['code'] . '&show_headers=1&id_session=' . $session_id;
$percentage_score_result = Display::url(ExerciseLib::show_score($score, $weighting), $latest_attempt_url);
$my_score = 0;
if (!empty($weighting) && intval($weighting) != 0) {
$my_score = $score / $weighting;
}
//@todo this function slows the page
$position = ExerciseLib::get_exercise_result_ranking($my_score, $exe_id, $exercices['id'], $course_info['code'], $session_id, $user_list);
$graph = self::generate_exercise_result_thumbnail_graph($to_graph_exercise_result[$exercices['id']]);
$normal_graph = self::generate_exercise_result_graph($to_graph_exercise_result[$exercices['id']]);
}
}
$html .= Display::div($normal_graph, array('id' => 'main_graph_' . $exercices['id'], 'class' => 'dialog', 'style' => 'display:none'));
if (empty($graph)) {
$graph = '-';
} else {
$graph = Display::url('<img src="' . $graph . '" >', $normal_graph, array('id' => $exercices['id'], 'class' => 'expand-image'));
}
$html .= Display::tag('td', $attempts, array('align' => 'center'));
$html .= Display::tag('td', $percentage_score_result, array('align' => 'center'));
$html .= Display::tag('td', $position, array('align' => 'center'));
$html .= Display::tag('td', $best_score, array('align' => 'center'));
$html .= Display::tag('td', $graph, array('align' => 'center'));
//$html .= Display::tag('td', $latest_attempt_url, array('align'=>'center', 'width'=>'25'));
} else {
// Exercise configuration NO results
$html .= Display::tag('td', $attempts, array('align' => 'center'));
$html .= Display::tag('td', '-', array('align' => 'center'));
$html .= Display::tag('td', '-', array('align' => 'center'));
//.........这里部分代码省略.........
示例6: search_courses
/**
* Search the courses database for a course that matches the search term.
* The search is done on the code, title and tutor field of the course table.
* @param string $search_term The string that the user submitted, what we are looking for
* @param array $limit
* @return array An array containing a list of all the courses matching the the search term.
*/
public function search_courses($search_term, $limit)
{
$courseTable = Database::get_main_table(TABLE_MAIN_COURSE);
$extraFieldTable = Database::get_main_table(TABLE_EXTRA_FIELD);
$extraFieldValuesTable = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$limitFilter = getLimitFilterFromArray($limit);
// get course list auto-register
$sql = "SELECT item_id\n FROM {$extraFieldValuesTable} tcfv\n INNER JOIN {$extraFieldTable} tcf ON tcfv.field_id = tcf.id\n WHERE\n tcf.variable = 'special_course' AND\n tcfv.value = 1 ";
$special_course_result = Database::query($sql);
if (Database::num_rows($special_course_result) > 0) {
$special_course_list = array();
while ($result_row = Database::fetch_array($special_course_result)) {
$special_course_list[] = '"' . $result_row['item_id'] . '"';
}
}
$without_special_courses = '';
if (!empty($special_course_list)) {
$without_special_courses = ' AND course.code NOT IN (' . implode(',', $special_course_list) . ')';
}
$search_term_safe = Database::escape_string($search_term);
$sql_find = "SELECT * FROM {$courseTable}\n WHERE (\n code LIKE '%" . $search_term_safe . "%' OR\n title LIKE '%" . $search_term_safe . "%' OR\n tutor_name LIKE '%" . $search_term_safe . "%'\n )\n {$without_special_courses}\n ORDER BY title, visual_code ASC\n {$limitFilter}\n ";
if (api_is_multiple_url_enabled()) {
$url_access_id = api_get_current_access_url_id();
if ($url_access_id != -1) {
$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql_find = "SELECT *\n FROM {$courseTable} as course\n INNER JOIN {$tbl_url_rel_course} as url_rel_course\n ON (url_rel_course.c_id = course.id)\n WHERE\n access_url_id = {$url_access_id} AND (\n code LIKE '%" . $search_term_safe . "%' OR\n title LIKE '%" . $search_term_safe . "%' OR\n tutor_name LIKE '%" . $search_term_safe . "%'\n )\n {$without_special_courses}\n ORDER BY title, visual_code ASC\n {$limitFilter}\n ";
}
}
$result_find = Database::query($sql_find);
$courses = array();
while ($row = Database::fetch_array($result_find)) {
$row['registration_code'] = !empty($row['registration_code']);
$count_users = count(CourseManager::get_user_list_from_course_code($row['code']));
$count_connections_last_month = Tracking::get_course_connections_count($row['id'], 0, api_get_utc_datetime(time() - 30 * 86400));
$point_info = CourseManager::get_course_ranking($row['id'], 0);
$courses[] = array('real_id' => $row['id'], 'point_info' => $point_info, 'code' => $row['code'], 'directory' => $row['directory'], 'visual_code' => $row['visual_code'], 'title' => $row['title'], 'tutor' => $row['tutor_name'], 'subscribe' => $row['subscribe'], 'unsubscribe' => $row['unsubscribe'], 'registration_code' => $row['registration_code'], 'creation_date' => $row['creation_date'], 'visibility' => $row['visibility'], 'count_users' => $count_users, 'count_connections' => $count_connections_last_month);
}
return $courses;
}
示例7: get_lang
}
// Checking "id" field
if (isset($user_data['id']) && !empty($user_data['id'])) {
$user_id = $user_data['id'];
}
if (UserManager::is_user_id_valid($user_id)) {
$clean_users[] = $user_id;
} else {
$invalid_users[] = $user_data;
}
}
if (empty($invalid_users)) {
$type = 'confirmation';
$message = get_lang('ListOfUsersSubscribedToCourse');
if ($unsubscribe_users) {
$current_user_list = CourseManager::get_user_list_from_course_code($course_code, $session_id);
if (!empty($current_user_list)) {
$user_ids = array();
foreach ($current_user_list as $user) {
$user_ids[] = $user['user_id'];
}
CourseManager::unsubscribe_user($user_ids, $course_code, $session_id);
}
}
foreach ($clean_users as $userId) {
$userInfo = api_get_user_info($userId);
CourseManager::subscribe_user($userId, $course_code, STUDENT, $session_id);
if (empty($session_id)) {
//just to make sure
if (CourseManager::is_user_subscribed_in_course($userId, $course_code)) {
$user_to_show[] = $userInfo['complete_name'];
示例8: ListCourses
/**
* List courses
*
* @param string API secret key
* @param string A list of visibility filter we want to apply
* @return array An array with elements of the form ('id' => 'Course internal id', 'code' => 'Course code', 'title' => 'Course title', 'language' => 'Course language', 'visibility' => 'Course visibility',
* 'category_name' => 'Name of the category of the course', 'number_students' => 'Number of students in the course', 'external_course_id' => 'External course id')
*/
public function ListCourses($secret_key, $visibility = 'public,public-registered,private,closed') {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$visibilities = split(',',$visibility);
$vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0');
foreach ($visibilities as $p => $visibility) {
$visibilities[$p] = $vis[$visibility];
}
$courses_result = array();
$category_names = array();
$courses = CourseManager::get_courses_list();
foreach($courses as $course) {
//skip elements that do not match required visibility
if (!in_array($course['visibility'],$visibilities)) { continue; }
$course_tmp = array();
$course_tmp['id'] = $course['id'];
$course_tmp['code'] = $course['code'];
$course_tmp['title'] = $course['title'];
$course_tmp['language'] = $course['course_language'];
$course_tmp['visibility'] = $course['visibility'];
// Determining category name
if($category_names[$course['category_code']]) {
$course_tmp['category_name'] = $category_names[$course['category_code']];
} else {
$category = CourseManager::get_course_category($course['category_code']);
$category_names[$course['category_code']] = $category['name'];
$course_tmp['category_name'] = $category['name'];
}
// Determining number of students registered in course
$user_list = CourseManager::get_user_list_from_course_code($course['code'], 0);
$course_tmp['number_students'] = count($user_list);
// Determining external course id - this code misses the external course id field name
// $course_tmp['external_course_id'] = CourseManager::get_course_extra_field_value($course_field_name, $course['code']);
$courses_result[] = $course_tmp;
}
return $courses_result;
}
}
示例9: foreach
foreach ($items as $data) {
$myUserId = $data['user_id'];
$usersAdded[] = $myUserId;
$userInfo = api_get_user_info($myUserId);
$url = api_get_path(WEB_CODE_PATH) . 'work/add_user.php?action=delete&id=' . $workId . '&user_id=' . $myUserId;
$link = Display::url('<em class="fa fa-trash"></em> ' . get_lang('Delete'), $url, array('class' => 'btn btn-danger btn-sm'));
echo '<li class="list-group-item">' . $userInfo['complete_name_with_username'] . '<div class="pull-right">' . $link . '</div></li>';
}
echo '</ul>';
}
if (empty($sessionId)) {
$status = STUDENT;
} else {
$status = 0;
}
$userList = CourseManager::get_user_list_from_course_code($courseInfo['code'], $sessionId, null, null, $status);
$userToAddList = array();
foreach ($userList as $user) {
if (!in_array($user['user_id'], $usersAdded)) {
$userToAddList[] = $user;
}
}
if (!empty($userToAddList)) {
echo Display::page_subheader(get_lang('UsersToAdd'));
echo '<ul class="list-group">';
foreach ($userToAddList as $user) {
$userName = api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ') ';
$url = api_get_path(WEB_CODE_PATH) . 'work/add_user.php?action=add&id=' . $workId . '&user_id=' . $user['user_id'];
$link = Display::url('<em class="fa fa-plus"></em> ' . get_lang('Add'), $url, array('class' => 'btn btn-primary btn-sm'));
echo '<li class="list-group-item">' . $userName . '<div class="pull-right"> ' . $link . '</div></li>';
}
示例10: getWorkUserList
/**
* @param string $courseCode
* @param int $sessionId
* @param int $groupId
* @param int $start
* @param int $limit
* @param string $sidx
* @param string $sord
* @param $getCount
* @return array|int
*/
function getWorkUserList($courseCode, $sessionId, $groupId, $start, $limit, $sidx, $sord, $getCount = false)
{
if (!empty($groupId)) {
$userList = GroupManager::get_users(
$groupId,
false,
$start,
$limit,
$getCount,
null,
$sidx,
$sord
);
} else {
$limitString = null;
if (!empty($start) && !empty($limit)) {
$start = intval($start);
$limit = intval($limit);
$limitString = " LIMIT $start, $limit";
}
$orderBy = null;
if (!empty($sidx) && !empty($sord)) {
if (in_array($sidx, array('firstname', 'lastname'))) {
$orderBy = "ORDER BY $sidx $sord";
}
}
if (empty($sessionId)) {
$userList = CourseManager::get_user_list_from_course_code(
$courseCode,
$sessionId,
$limitString,
$orderBy ,
STUDENT,
$getCount
);
} else {
$userList = CourseManager::get_user_list_from_course_code(
$courseCode,
$sessionId,
$limitString,
$orderBy,
0,
$getCount
);
}
if ($getCount == false) {
$userList = array_keys($userList);
}
}
return $userList;
}
示例11: api_get_path
if (Database::num_rows($result) > 1) {
Display::display_warning_message(get_lang('IdenticalSurveycodeWarning'));
}
// Invited / answered message
if ($survey_data['invited'] > 0 && !isset($_POST['submit'])) {
$message = '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/survey_invitation.php?view=answered&survey_id=' . $survey_data['survey_id'] . '">' . $survey_data['answered'] . '</a> ';
$message .= get_lang('HaveAnswered') . ' ';
$message .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/survey_invitation.php?view=invited&survey_id=' . $survey_data['survey_id'] . '">' . $survey_data['invited'] . '</a> ';
$message .= get_lang('WereInvited');
Display::display_normal_message($message, false);
}
// Building the form for publishing the survey
$form = new FormValidator('publish_form', 'post', api_get_self() . '?survey_id=' . $survey_id . '&' . api_get_cidReq());
$form->addElement('header', '', $tool_name);
// Course users
$complete_user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id(), '', api_sort_by_first_name() ? 'ORDER BY firstname' : 'ORDER BY lastname');
$possible_users = array();
foreach ($complete_user_list as &$user) {
$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
}
$users = $form->addElement('advmultiselect', 'course_users', get_lang('CourseUsers'), $possible_users, 'style="width: 250px; height: 200px;"');
$users->setElementTemplate('
{javascript}
<table{class}>
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th> </th><th>{label_3}</th></tr><!-- END label_3 -->
<tr>
<td valign="top">{unselected}</td>
<td align="center">{add}<br /><br />{remove}</td>
<td valign="top">{selected}</td>
</tr>
示例12: resultsAction
/**
*
* @Route("/results")
* @Method({"GET"})
*/
public function resultsAction()
{
$breadcrumbs = array(array('name' => get_lang('Curriculum'), 'url' => array('route' => 'curriculum_user.controller:indexAction', 'routeParameters' => array('course' => $this->getCourse()->getCode()))), array('name' => get_lang('Categories'), 'url' => array('route' => 'curriculum_category.controller:indexAction', 'routeParameters' => array('course' => $this->getCourse()->getCode()))), array('name' => get_lang('Results')));
$this->setBreadcrumb($breadcrumbs);
if (!api_is_allowed_to_edit(true, true, true)) {
$this->abort('405');
}
$session = $this->getSession();
$sessionId = 0;
if ($session) {
$sessionId = $this->getSession()->getId();
}
// @todo move in a function
$users = \CourseManager::get_user_list_from_course_code($this->getCourse()->getCode(), $sessionId, null, null, STUDENT);
$qb = $this->getManager()->createQueryBuilder()->select('node.id, u.userId, SUM(i.score) as score')->from('Entity\\CurriculumCategory', 'node')->innerJoin('node.course', 'c')->innerJoin('node.items', 'i')->innerJoin('i.userItems', 'u')->groupby('u.userId');
$this->setCourseParameters($qb, 'node');
$query = $qb->getQuery();
$userResults = $query->getResult();
$userResultsByUserId = array();
if (!empty($userResults)) {
foreach ($userResults as $item) {
$userResultsByUserId[$item['userId']] = $item['score'];
}
}
if (!empty($users)) {
foreach ($users as &$user) {
if (!empty($userResultsByUserId)) {
if (isset($userResultsByUserId[$user['user_id']])) {
$user['score'] = $userResultsByUserId[$user['user_id']];
} else {
$user['score'] = 0;
}
}
}
}
$template = $this->getTemplate();
$template->assign('users', $users);
$response = $template->render_template($this->getTemplatePath() . 'results.tpl');
return new Response($response, 200, array());
}
示例13: mkdir
}
if (!empty($courses)) {
if (!file_exists($archivePath)) {
mkdir($archivePath, api_get_permissions_for_new_directories(), true);
}
$archiveFile = 'export_courses_list_' . date('Y-m-d_H-i-s') . '.' . $file_type;
$fp = fopen($archivePath . $archiveFile, 'w');
if ($file_type == 'csv') {
$add = "Code;Title;CourseCategory;Teacher;Language;OtherTeachers;Users;" . PHP_EOL;
foreach ($courses as $course) {
$course['code'] = str_replace(';', ',', $course['code']);
$course['title'] = str_replace(';', ',', $course['title']);
$course['category_code'] = str_replace(';', ',', $course['category_code']);
$course['tutor_name'] = str_replace(';', ',', $course['tutor_name']);
$course['course_language'] = str_replace(';', ',', $course['course_language']);
$course['course_users'] = CourseManager::get_user_list_from_course_code($course['code']);
$course['students'] = '';
$course['teachers'] = '';
foreach ($course['course_users'] as $user) {
if ($user['status_rel'] == 1) {
$course['teachers'] .= $user['username'] . '|';
} else {
$course['students'] .= $user['username'] . '|';
}
}
$course['students'] = substr($course['students'], 0, -1);
$course['teachers'] = substr($course['teachers'], 0, -1);
$add .= $course['code'] . ';' . $course['title'] . ';' . $course['category_code'] . ';' . $course['tutor_name'] . ';' . $course['course_language'] . ';' . $course['teachers'] . ';' . $course['students'] . ';' . PHP_EOL;
}
fputs($fp, $add);
}
示例14: auto_add_page_users
/**
* Function wizard individual assignment
* @author Juan Carlos Raña <herodoto@telefonica.net>
*/
public function auto_add_page_users($values)
{
$assignment_type = $values['assignment'];
$session_id = $this->session_id;
$groupId = api_get_group_id();
if ($groupId == 0) {
//extract course members
if (!empty($session_id)) {
$a_users_to_add = CourseManager::get_user_list_from_course_code(api_get_course_id(), $session_id);
} else {
$a_users_to_add = CourseManager::get_user_list_from_course_code(api_get_course_id(), 0);
}
} else {
//extract group members
$subscribed_users = GroupManager::get_subscribed_users($groupId);
$subscribed_tutors = GroupManager::get_subscribed_tutors($groupId);
$a_users_to_add_with_duplicates = array_merge($subscribed_users, $subscribed_tutors);
//remove duplicates
$a_users_to_add = $a_users_to_add_with_duplicates;
//array_walk($a_users_to_add, create_function('&$value,$key', '$value = json_encode($value);'));
$a_users_to_add = array_unique($a_users_to_add);
//array_walk($a_users_to_add, create_function('&$value,$key', '$value = json_decode($value, true);'));
}
$all_students_pages = array();
// Data about teacher
$userId = api_get_user_id();
$userinfo = api_get_user_info($userId);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username'], ENT_QUOTES));
$name = $userinfo['complete_name'] . " - " . $username;
$photo = '<img src="' . $userinfo['avatar'] . '" alt="' . $name . '" width="40" height="50" align="top" title="' . $name . '" />';
// teacher assignment title
$title_orig = $values['title'];
// teacher assignment reflink
$link2teacher = $values['title'] = $title_orig . "_uass" . $userId;
// first: teacher name, photo, and assignment description (original content)
$content_orig_A = '<div align="center" style="background-color: #F5F8FB; border:solid; border-color: #E6E6E6">
<table border="0">
<tr><td style="font-size:24px">' . get_lang('AssignmentDesc') . '</td></tr>
<tr><td>' . $photo . '<br />' . Display::tag('span', api_get_person_name($userinfo['firstname'], $userinfo['lastname']), array('title' => $username)) . '</td></tr>
</table></div>';
$content_orig_B = '<br/><div align="center" style="font-size:24px">' . get_lang('AssignmentDescription') . ': ' . $title_orig . '</div><br/>' . $_POST['content'];
//Second: student list (names, photo and links to their works).
//Third: Create Students work pages.
foreach ($a_users_to_add as $o_user_to_add) {
if ($o_user_to_add['user_id'] != $userId) {
// except that puts the task
$assig_user_id = $o_user_to_add['user_id'];
// identifies each page as created by the student, not by teacher
$userPicture = UserManager::getUserPicture($assig_user_id);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $o_user_to_add['username'], ENT_QUOTES));
$name = api_get_person_name($o_user_to_add['firstname'], $o_user_to_add['lastname']) . " . " . $username;
$photo = '<img src="' . $userPicture . '" alt="' . $name . '" width="40" height="50" align="bottom" title="' . $name . '" />';
$is_tutor_of_group = GroupManager::is_tutor_of_group($assig_user_id, $groupId);
//student is tutor
$is_tutor_and_member = GroupManager::is_tutor_of_group($assig_user_id, $groupId) && GroupManager::is_subscribed($assig_user_id, $groupId);
// student is tutor and member
if ($is_tutor_and_member) {
$status_in_group = get_lang('GroupTutorAndMember');
} else {
if ($is_tutor_of_group) {
$status_in_group = get_lang('GroupTutor');
} else {
$status_in_group = " ";
//get_lang('GroupStandardMember')
}
}
if ($assignment_type == 1) {
$values['title'] = $title_orig;
$values['content'] = '<div align="center" style="background-color: #F5F8FB; border:solid; border-color: #E6E6E6">
<table border="0">
<tr><td style="font-size:24px">' . get_lang('AssignmentWork') . '</td></tr>
<tr><td>' . $photo . '<br />' . $name . '</td></tr></table>
</div>[[' . $link2teacher . ' | ' . get_lang('AssignmentLinktoTeacherPage') . ']] ';
//If $content_orig_B is added here, the task written by the professor was copied to the page of each student. TODO: config options
// AssignmentLinktoTeacherPage
$all_students_pages[] = '<li>' . Display::tag('span', strtoupper($o_user_to_add['lastname']) . ', ' . $o_user_to_add['firstname'], array('title' => $username)) . ' [[' . $_POST['title'] . "_uass" . $assig_user_id . ' | ' . $photo . ']] ' . $status_in_group . '</li>';
//don't change this line without guaranteeing that users will be ordered by last names in the following format (surname, name)
$values['assignment'] = 2;
}
$this->assig_user_id = $assig_user_id;
self::save_new_wiki($values);
}
}
foreach ($a_users_to_add as $o_user_to_add) {
if ($o_user_to_add['user_id'] == $userId) {
$assig_user_id = $o_user_to_add['user_id'];
if ($assignment_type == 1) {
$values['title'] = $title_orig;
$values['comment'] = get_lang('AssignmentDesc');
sort($all_students_pages);
$values['content'] = $content_orig_A . $content_orig_B . '<br/>
<div align="center" style="font-size:18px; background-color: #F5F8FB; border:solid; border-color:#E6E6E6">
' . get_lang('AssignmentLinkstoStudentsPage') . '
</div><br/>
<div style="background-color: #F5F8FB; border:solid; border-color:#E6E6E6">
<ol>' . implode($all_students_pages) . '</ol>
//.........这里部分代码省略.........
示例15: show_to_form
/**
* @param array $form
* @param $to_already_selected
*/
public static function show_to_form($form, $to_already_selected)
{
$order = 'lastname';
if (api_is_western_name_order()) {
$order = 'firstname';
}
$user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id(), null, $order);
$group_list = CourseManager::get_group_list_of_course(api_get_course_id(), api_get_session_id());
self::construct_not_selected_select_form_validator($form, $group_list, $user_list, $to_already_selected);
}