本文整理汇总了PHP中CourseManager::generate_course_code方法的典型用法代码示例。如果您正苦于以下问题:PHP CourseManager::generate_course_code方法的具体用法?PHP CourseManager::generate_course_code怎么用?PHP CourseManager::generate_course_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CourseManager
的用法示例。
在下文中一共展示了CourseManager::generate_course_code方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: define_course_keys
/**
* Defines the four needed keys to create a course based on several parameters.
* @param string The code you want for this course
* @param string Prefix added for ALL keys
* @param string Prefix added for databases only
* @param string Prefix added for paths only
* @param bool Add unique prefix
* @param bool Use code-independent keys
* @return array An array with the needed keys ['currentCourseCode'], ['currentCourseId'], ['currentCourseDbName'], ['currentCourseRepository']
* @todo Eliminate the global variables.
* @assert (null) === false
*/
public static function define_course_keys($wanted_code, $prefix_for_all = '', $prefix_for_base_name = '', $prefix_for_path = '', $add_unique_prefix = false, $use_code_indepedent_keys = true)
{
global $prefixAntiNumber, $_configuration;
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$wanted_code = CourseManager::generate_course_code($wanted_code);
$keys_course_code = $wanted_code;
if (!$use_code_indepedent_keys) {
$wanted_code = '';
}
if ($add_unique_prefix) {
$unique_prefix = substr(md5(uniqid(rand())), 0, 10);
} else {
$unique_prefix = '';
}
$keys = array();
$final_suffix = array('CourseId' => '', 'CourseDb' => '', 'CourseDir' => '');
$limit_numb_try = 100;
$keys_are_unique = false;
$try_new_fsc_id = $try_new_fsc_db = $try_new_fsc_dir = 0;
while (!$keys_are_unique) {
$keys_course_id = $prefix_for_all . $unique_prefix . $wanted_code . $final_suffix['CourseId'];
//$keys_course_db_name = $prefix_for_base_name . $unique_prefix . strtoupper($keys_course_id) . $final_suffix['CourseDb'];
$keys_course_repository = $prefix_for_path . $unique_prefix . $wanted_code . $final_suffix['CourseDir'];
$keys_are_unique = true;
// Check whether they are unique.
$query = "SELECT 1 FROM " . $course_table . " WHERE code='" . $keys_course_id . "' LIMIT 0,1";
$result = Database::query($query);
if (Database::num_rows($result)) {
$keys_are_unique = false;
$try_new_fsc_id++;
$final_suffix['CourseId'] = substr(md5(uniqid(rand())), 0, 4);
}
if (file_exists(api_get_path(SYS_COURSE_PATH) . $keys_course_repository)) {
$keys_are_unique = false;
$try_new_fsc_dir++;
$final_suffix['CourseDir'] = substr(md5(uniqid(rand())), 0, 4);
}
if ($try_new_fsc_id + $try_new_fsc_db + $try_new_fsc_dir > $limit_numb_try) {
return $keys;
}
}
$keys['currentCourseCode'] = $keys_course_code;
$keys['currentCourseId'] = $keys_course_id;
$keys['currentCourseRepository'] = $keys_course_repository;
return $keys;
}
示例2: WSEditCourse
function WSEditCourse($params)
{
global $_configuration;
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$courses_params = $params['courses'];
$results = array();
$orig_course_id_value = array();
foreach ($courses_params as $course_param) {
$tutor_id = $course_param['tutor_id'];
$title = $course_param['title'];
$category_code = $course_param['category_code'];
$department_name = $course_param['department_name'];
$department_url = $course_param['department_url'];
$course_language = $course_param['course_language'];
$visibility = $course_param['visibility'];
$subscribe = $course_param['subscribe'];
$unsubscribe = $course_param['unsubscribe'];
$visual_code = $course_param['visual_code'];
$original_course_id_name = $course_param['original_course_id_name'];
$original_course_id_value = $course_param['original_course_id_value'];
$orig_course_id_value[] = $original_course_id_value;
$extra_list = $course_param['extra'];
$courseInfo = CourseManager::getCourseInfoFromOriginalId($original_course_id_value, $original_course_id_name);
if (empty($courseInfo)) {
$results[] = 0;
// Original_course_id_value doesn't exist.
continue;
}
$course_code = $courseInfo['code'];
$courseId = $courseInfo['real_id'];
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT concat(lastname,'',firstname) as tutor_name\n FROM {$table_user} WHERE status='1' AND user_id = '{$tutor_id}'\n ORDER BY lastname,firstname";
$res = Database::query($sql);
$tutor_name = Database::fetch_row($res);
$dbnamelength = strlen($_configuration['db_prefix']);
$maxlength = 40 - $dbnamelength;
if (empty($visual_code)) {
$visual_code = CourseManager::generate_course_code(substr($title, 0, $maxlength));
}
$disk_quota = '50000';
// TODO: A hard-coded value.
$tutor_name = $tutor_name[0];
$sql = "UPDATE {$course_table} SET\n course_language='" . Database::escape_string($course_language) . "',\n title='" . Database::escape_string($title) . "',\n category_code='" . Database::escape_string($category_code) . "',\n tutor_name='" . Database::escape_string($tutor_name) . "',\n visual_code='" . Database::escape_string($visual_code) . "',\n department_name='" . Database::escape_string($department_name) . "',\n department_url='" . Database::escape_string($department_url) . "',\n disk_quota='" . Database::escape_string($disk_quota) . "',\n visibility = '" . Database::escape_string($visibility) . "',\n subscribe = '" . Database::escape_string($subscribe) . "',\n unsubscribe='" . Database::escape_string($unsubscribe) . "'\n WHERE id ='" . Database::escape_string($courseId) . "'";
$res = Database::query($sql);
if (is_array($extra_list) && count($extra_list) > 0) {
foreach ($extra_list as $extra) {
$extra_field_name = $extra['field_name'];
$extra_field_value = $extra['field_value'];
// Save the external system's id into course_field_value table.
$res = CourseManager::update_course_extra_field_value($course_code, $extra_field_name, $extra_field_value);
}
}
if ($res) {
$results[] = 1;
continue;
} else {
$results[] = 0;
continue;
}
}
// end principal foreach
$count_results = count($results);
$output = array();
for ($i = 0; $i < $count_results; $i++) {
$output[] = array('original_course_id_value' => $orig_course_id_value[$i], 'result' => $results[$i]);
}
return $output;
}
示例3: editNode
/**
* @param string $code
* @param string $name
* @param string $canHaveCourses
* @param string $old_code
* @return bool
*/
function editNode($code, $name, $canHaveCourses, $old_code)
{
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = trim(Database::escape_string($code));
$name = trim(Database::escape_string($name));
$old_code = Database::escape_string($old_code);
$canHaveCourses = Database::escape_string($canHaveCourses);
$code = CourseManager::generate_course_code($code);
// Updating category
$sql = "UPDATE {$tbl_category} SET name='{$name}', code='{$code}', auth_course_child = '{$canHaveCourses}'\n WHERE code = '{$old_code}'";
Database::query($sql);
// Updating children
$sql = "UPDATE {$tbl_category} SET parent_id = '{$code}'\n WHERE parent_id = '{$old_code}'";
Database::query($sql);
// Updating course category
$sql = "UPDATE {$tbl_course} SET category_code = '{$code}'\n WHERE category_code = '{$old_code}' ";
Database::query($sql);
return true;
}
示例4: store_survey
//.........这里部分代码省略.........
$sql = 'SELECT survey_version FROM ' . $table_survey . '
WHERE
c_id = ' . $course_id . ' AND
survey_id = ' . intval($values['parent_id']);
$rs = Database::query($sql);
$getversion = Database::fetch_array($rs, 'ASSOC');
if (empty($getversion['survey_version'])) {
$versionValue = ++$getversion['survey_version'];
} else {
$versionValue = $getversion['survey_version'];
}
} else {
$row = Database::fetch_array($rs, 'ASSOC');
$pos = api_strpos($row['survey_version']);
if ($pos === false) {
$row['survey_version'] = $row['survey_version'] + 1;
$versionValue = $row['survey_version'];
} else {
$getlast = explode('\\.', $row['survey_version']);
$lastversion = array_pop($getlast);
$lastversion = $lastversion + 1;
$add = implode('.', $getlast);
if ($add != '') {
$insertnewversion = $add . '.' . $lastversion;
} else {
$insertnewversion = $lastversion;
}
$versionValue = $insertnewversion;
}
}
$extraParams['survey_version'] = $versionValue;
}
}
$params = ['c_id' => $course_id, 'code' => strtolower(CourseManager::generate_course_code($values['survey_code'])), 'title' => $values['survey_title'], 'subtitle' => $values['survey_subtitle'], 'author' => $_user['user_id'], 'lang' => $values['survey_language'], 'avail_from' => $values['start_date'], 'avail_till' => $values['end_date'], 'is_shared' => $shared_survey_id, 'template' => 'template', 'intro' => $values['survey_introduction'], 'surveythanks' => $values['survey_thanks'], 'creation_date' => api_get_utc_datetime(), 'anonymous' => $values['anonymous'], 'session_id' => api_get_session_id(), 'visible_results' => $values['visible_results']];
$params = array_merge($params, $extraParams);
$survey_id = Database::insert($table_survey, $params);
if ($survey_id > 0) {
$sql = "UPDATE {$table_survey} SET survey_id = {$survey_id}\n WHERE iid = {$survey_id}";
Database::query($sql);
// Insert into item_property
api_item_property_update(api_get_course_info(), TOOL_SURVEY, $survey_id, 'SurveyAdded', api_get_user_id());
}
if ($values['survey_type'] == 1 && !empty($values['parent_id'])) {
SurveyManager::copy_survey($values['parent_id'], $survey_id);
}
Display::addFlash(Display::return_message(get_lang('SurveyCreatedSuccesfully'), 'success'));
$return['id'] = $survey_id;
} else {
// Check whether the code doesn't soon exists in this language
$sql = 'SELECT 1 FROM ' . $table_survey . '
WHERE
c_id = ' . $course_id . ' AND
code = "' . Database::escape_string($values['survey_code']) . '" AND
lang = "' . Database::escape_string($values['survey_language']) . '" AND
survey_id !=' . intval($values['survey_id']);
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
Display::addFlash(Display::return_message(get_lang('ThisSurveyCodeSoonExistsInThisLanguage'), 'error'));
$return['type'] = 'error';
$return['id'] = isset($values['survey_id']) ? $values['survey_id'] : 0;
return $return;
}
if (!isset($values['anonymous']) || isset($values['anonymous']) && $values['anonymous'] == '') {
$values['anonymous'] = 0;
}
$values['shuffle'] = isset($values['shuffle']) ? $values['shuffle'] : null;
示例5: store_survey
//.........这里部分代码省略.........
$additional['values'] .= ",'" . Database::escape_string($values['one_question_per_page']) . "'";
$additional['columns'] .= ', parent_id';
$additional['values'] .= ",'" . Database::escape_string($values['parent_id']) . "'";
// Logic for versioning surveys
if (!empty($values['parent_id'])) {
$additional['columns'] .= ', survey_version';
$sql = 'SELECT survey_version FROM ' . $table_survey . ' WHERE c_id = ' . $course_id . ' AND parent_id = ' . Database::escape_string($values['parent_id']) . ' ORDER BY survey_version DESC LIMIT 1';
$rs = Database::query($sql);
if (Database::num_rows($rs) === 0) {
$sql = 'SELECT survey_version FROM ' . $table_survey . ' WHERE c_id = ' . $course_id . ' survey_id = ' . Database::escape_string($values['parent_id']);
$rs = Database::query($sql);
$getversion = Database::fetch_array($rs, 'ASSOC');
if (empty($getversion['survey_version'])) {
$additional['values'] .= ",'" . ++$getversion['survey_version'] . "'";
} else {
$additional['values'] .= ",'" . $getversion['survey_version'] . ".1'";
}
} else {
$row = Database::fetch_array($rs, 'ASSOC');
$pos = api_strpos($row['survey_version']);
if ($pos === false) {
//$new_version = substr($row['survey_version'],$pos, count())
$row['survey_version'] = $row['survey_version'] + 1;
$additional['values'] .= ",'" . $row['survey_version'] . "'";
} else {
$getlast = api_split('\\.', $row['survey_version']);
$lastversion = array_pop($getlast);
$lastversion = $lastversion + 1;
$add = implode('.', $getlast);
if ($add != '') {
$insertnewversion = $add . '.' . $lastversion;
} else {
$insertnewversion = $lastversion;
}
$additional['values'] .= ",'" . $insertnewversion . "'";
}
}
}
}
$course_id = api_get_course_int_id();
$sql = "INSERT INTO {$table_survey} (c_id, code, title, subtitle, author, lang, avail_from, avail_till, is_shared, template, intro, surveythanks, creation_date, anonymous" . $additional['columns'] . ", session_id) VALUES (\n\t\t\t\t\t\t{$course_id},\n\t\t\t\t\t\t'" . Database::escape_string(strtolower(CourseManager::generate_course_code(api_substr($values['survey_code'], 0)))) . "',\n\t\t\t\t\t\t'" . Database::escape_string($values['survey_title']) . "',\n\t\t\t\t\t\t'" . Database::escape_string($values['survey_subtitle']) . "',\n\t\t\t\t\t\t'" . api_get_user_id() . "',\n\t\t\t\t\t\t'" . Database::escape_string($values['survey_language']) . "',\n\t\t\t\t\t\t'" . Database::escape_string($values['start_date']) . "',\n\t\t\t\t\t\t'" . Database::escape_string($values['end_date']) . "',\n\t\t\t\t\t\t'" . Database::escape_string($shared_survey_id) . "',\n\t\t\t\t\t\t'template',\n\t\t\t\t\t\t'" . Database::escape_string($values['survey_introduction']) . "',\n\t\t\t\t\t\t'" . Database::escape_string($values['survey_thanks']) . "',\n\t\t\t\t\t\t'" . api_get_utc_datetime() . "',\n\t\t\t\t\t\t'" . Database::escape_string($values['anonymous']) . "'" . $additional['values'] . ",\n\t\t\t\t\t\t" . api_get_session_id() . "\n\t\t\t\t\t\t)";
$result = Database::query($sql);
$survey_id = Database::insert_id();
if ($survey_id > 0) {
// Insert into item_property
api_item_property_update(api_get_course_info(), TOOL_SURVEY, $survey_id, 'SurveyAdded', api_get_user_id());
}
if ($values['survey_type'] == 1 && !empty($values['parent_id'])) {
self::copy_survey($values['parent_id'], $survey_id);
}
$return['message'] = 'SurveyCreatedSuccesfully';
$return['type'] = 'confirmation';
$return['id'] = $survey_id;
} else {
// Check whether the code doesn't soon exists in this language
$sql = 'SELECT 1 FROM ' . $table_survey . '
WHERE c_id = ' . $course_id . ' AND code="' . Database::escape_string($values['survey_code']) . '" AND lang="' . Database::escape_string($values['survey_language']) . '" AND survey_id!=' . intval($values['survey_id']);
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
$return['message'] = 'ThisSurveyCodeSoonExistsInThisLanguage';
$return['type'] = 'error';
$return['id'] = isset($values['survey_id']) ? $values['survey_id'] : 0;
return $return;
}
if ($values['anonymous'] == '') {
$values['anonymous'] = 0;
}
$additionalsets = ", shuffle = '" . Database::escape_string($values['shuffle']) . "'";
$additionalsets .= ", one_question_per_page = '" . Database::escape_string($values['one_question_per_page']) . "'";
if ($values['anonymous'] == 0) {
$additionalsets .= ", show_form_profile = '" . Database::escape_string($values['show_form_profile']) . "'";
if (isset($values['show_form_profile']) && $values['show_form_profile'] == 1) {
$fields = explode(',', $values['input_name_list']);
$field_values = '';
foreach ($fields as &$field) {
if ($field != '') {
if ($values[$field] == '') {
$values[$field] = 0;
}
$field_values .= $field . ':' . $values[$field] . '@';
}
}
$additionalsets .= ", form_fields = '" . Database::escape_string($field_values) . "'";
} else {
$additionalsets .= ", form_fields = '' ";
}
} else {
$additionalsets .= ", show_form_profile = '0'";
$additionalsets .= ", form_fields = '' ";
}
$sql = "UPDATE {$table_survey} SET\n title \t\t\t= '" . Database::escape_string($values['survey_title']) . "',\n code = '" . Database::escape_string(strtolower(CourseManager::generate_course_code(api_substr($values['survey_code'], 0)))) . "',\n subtitle \t\t= '" . Database::escape_string($values['survey_subtitle']) . "',\n author \t\t\t= '" . api_get_user_id() . "',\n lang \t\t\t= '" . Database::escape_string($values['survey_language']) . "',\n avail_from \t\t= '" . Database::escape_string($values['start_date']) . "',\n avail_till\t\t= '" . Database::escape_string($values['end_date']) . "',\n is_shared\t\t= '" . Database::escape_string($shared_survey_id) . "',\n template \t\t= 'template',\n intro\t\t\t= '" . Database::escape_string($values['survey_introduction']) . "',\n surveythanks\t= '" . Database::escape_string($values['survey_thanks']) . "',\n anonymous = '" . Database::escape_string($values['anonymous']) . "'" . $additionalsets . "\n\t\t\t\t\tWHERE c_id = {$course_id} AND survey_id = '" . Database::escape_string($values['survey_id']) . "'";
Database::query($sql);
// Update into item_property (update)
api_item_property_update(api_get_course_info(), TOOL_SURVEY, $values['survey_id'], 'SurveyUpdated', api_get_user_id());
$return['message'] = 'SurveyUpdatedSuccesfully';
$return['type'] = 'confirmation';
$return['id'] = $values['survey_id'];
}
return $return;
}
示例6: generate_nice_next_course_code
/**
* Creates a new course code based in a given code
*
* @param string wanted code
* <code> $wanted_code = 'curse' if there are in the DB codes like curse1 curse2 the function will return: course3</code>
* if the course code doest not exist in the DB the same course code will be returned
* @return string wanted unused code
*/
public static function generate_nice_next_course_code($wanted_code)
{
$course_code_ok = !self::course_code_exists($wanted_code);
if (!$course_code_ok) {
$wanted_code = CourseManager::generate_course_code($wanted_code);
$table = Database::get_main_table(TABLE_MAIN_COURSE);
$wanted_code = Database::escape_string($wanted_code);
$sql = "SELECT count(*) as count\n FROM {$table}\n WHERE code LIKE '{$wanted_code}%'";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$row = Database::fetch_array($result);
$count = $row['count'] + 1;
$wanted_code = $wanted_code . '_' . $count;
$result = api_get_course_info($wanted_code);
if (empty($result)) {
return $wanted_code;
}
}
return false;
}
return $wanted_code;
}
示例7: round
$(function() {
' . $extra['jquery_ready_content'] . '
});
</script>';
$form->addButtonUpdate(get_lang('ModifyCourseInfo'));
// Set some default values
$courseInfo['disk_quota'] = round(DocumentManager::get_course_quota($courseInfo['code']) / 1024 / 1024, 1);
$courseInfo['real_code'] = $courseInfo['code'];
$courseInfo['add_teachers_to_sessions_courses'] = isset($courseInfo['add_teachers_to_sessions_courses']) ? $courseInfo['add_teachers_to_sessions_courses'] : 0;
$form->setDefaults($courseInfo);
// Validate form
if ($form->validate()) {
$course = $form->getSubmitValues();
$visibility = $course['visibility'];
$visual_code = $course['visual_code'];
$visual_code = CourseManager::generate_course_code($visual_code);
// Check if the visual code is already used by *another* course
$visual_code_is_used = false;
$warn = get_lang('TheFollowingCoursesAlreadyUseThisVisualCode');
if (!empty($visual_code)) {
$list = CourseManager::get_courses_info_from_visual_code($visual_code);
foreach ($list as $course_temp) {
if ($course_temp['code'] != $course_code) {
$visual_code_is_used = true;
$warn .= ' ' . $course_temp['title'] . ' (' . $course_temp['code'] . '),';
}
}
$warn = substr($warn, 0, -1);
}
$teachers = isset($course['course_teachers']) ? $course['course_teachers'] : '';
$title = $course['title'];
示例8: array
$content = null;
// Validate the form.
if ($form->validate()) {
$course_values = $form->exportValues();
$wanted_code = $course_values['wanted_code'];
$category_code = $course_values['category_code'];
$title = $course_values['title'];
$course_language = $course_values['course_language'];
$exemplary_content = !empty($course_values['exemplary_content']);
if ($course_validation_feature) {
$description = $course_values['description'];
$objetives = $course_values['objetives'];
$target_audience = $course_values['target_audience'];
}
if ($wanted_code == '') {
$wanted_code = CourseManager::generate_course_code(api_substr($title, 0, CourseManager::MAX_COURSE_LENGTH_CODE));
}
// Check whether the requested course code has already been occupied.
if (!$course_validation_feature) {
$course_code_ok = !CourseManager::course_code_exists($wanted_code);
} else {
$course_code_ok = !CourseRequestManager::course_code_exists($wanted_code);
}
if ($course_code_ok) {
if (!$course_validation_feature) {
$params = array();
$params['title'] = $title;
$params['exemplary_content'] = $exemplary_content;
$params['wanted_code'] = $wanted_code;
$params['course_category'] = $category_code;
$params['course_language'] = $course_language;
示例9: addCourseAction
//.........这里部分代码省略.........
$form->addRule('legal', get_lang('YouHaveToAcceptTermsAndConditions'), 'required');
// Link to terms and conditions.
$link_terms_and_conditions = '
<script>
function MM_openBrWindow(theURL, winName, features) { //v2.0
window.open(theURL,winName,features);
}
</script>
';
$link_terms_and_conditions .= \Display::url(get_lang('ReadTermsAndConditions'), '#', ['onclick' => "javascript:MM_openBrWindow('{$terms_and_conditions_url}', 'Conditions', 'scrollbars=yes, width=800');"]);
$form->addElement('label', null, $link_terms_and_conditions);
}
}
$obj = new \GradeModel();
$obj->fill_grade_model_select_in_form($form);
$form->addElement('html', '</div>');
// Submit button.
$form->addButtonCreate($courseValidation ? get_lang('CreateThisCourseRequest') : get_lang('CreateCourseArea'));
// Set default values.
if (isset($_user['language']) && $_user['language'] != '') {
$values['course_language'] = $_user['language'];
} else {
$values['course_language'] = api_get_setting('language.platform_language');
}
$form->setDefaults($values);
$message = null;
$content = null;
// Validate the form.
if ($form->validate()) {
$course_values = $form->exportValues();
$wanted_code = $course_values['wanted_code'];
//$category_code = $course_values['category_code'];
$category_code = '';
$title = $course_values['title'];
$course_language = $course_values['course_language'];
$exemplary_content = !empty($course_values['exemplary_content']);
if ($courseValidation) {
$description = $course_values['description'];
$objetives = $course_values['objetives'];
$target_audience = $course_values['target_audience'];
}
if ($wanted_code == '') {
$wanted_code = \CourseManager::generate_course_code(api_substr($title, 0, \CourseManager::MAX_COURSE_LENGTH_CODE));
}
// Check whether the requested course code has already been occupied.
if (!$courseValidation) {
$course_code_ok = !\CourseManager::course_code_exists($wanted_code);
} else {
$course_code_ok = !\CourseRequestManager::course_code_exists($wanted_code);
}
if ($course_code_ok) {
if (!$courseValidation) {
$params = array();
$params['title'] = $title;
$params['exemplary_content'] = $exemplary_content;
$params['wanted_code'] = $wanted_code;
$params['course_category'] = $category_code;
$params['course_language'] = $course_language;
$params['gradebook_model_id'] = isset($course_values['gradebook_model_id']) ? $course_values['gradebook_model_id'] : null;
$course_info = \CourseManager::create_course($params);
if (!empty($course_info)) {
$url = api_get_path(WEB_CODE_PATH);
$url .= 'course_info/start.php?cidReq=';
$url .= $course_info['code'];
$url .= '&first=1';
header('Location: ' . $url);
exit;
} else {
$this->addFlash('error', $this->trans('CourseCreationFailed'));
// Display the form.
$content = $form->returnForm();
}
} else {
// Create a request for a new course.
$request_id = \CourseRequestManager::create_course_request($wanted_code, $title, $description, $category_code, $course_language, $objetives, $target_audience, api_get_user_id(), $exemplary_content);
if ($request_id) {
$course_request_info = \CourseRequestManager::get_course_request_info($request_id);
$message = (is_array($course_request_info) ? '<strong>' . $course_request_info['code'] . '</strong> : ' : '') . get_lang('CourseRequestCreated');
\Display::return_message($message, 'confirmation', false);
\Display::return_message('div', \Display::url(get_lang('Enter'), api_get_path(WEB_PATH) . 'user_portal.php', ['class' => 'btn btn-default']), ['style' => 'float: left; margin:0px; padding: 0px;']);
} else {
\Display::return_message(get_lang('CourseRequestCreationFailed'), 'error', false);
// Display the form.
$content = $form->returnForm();
}
}
} else {
\Display::return_message(get_lang('CourseCodeAlreadyExists'), 'error', false);
// Display the form.
$content = $form->returnForm();
}
} else {
if (!$courseValidation) {
$this->addFlash('warning', get_lang('Explanation'));
}
// Display the form.
$content = $form->returnForm();
}
return $this->render('ChamiloCoreBundle:Index:userportal.html.twig', array('content' => $content));
}
示例10: createCourseHelper
/**
* Creates a course (helper method)
*
* @param string Title
* @param string Category code
* @param string Wanted code. If it's not defined, it will be generated automatically
* @param string Tutor name
* @param string Course admin user id field name
* @param string Course admin user id value
* @param string Course language
* @param string Course id field name
* @param string Course id value
* @param array Course extra fields
* @return mixed Generated id if creation was successful, WSError otherwise
*/
protected function createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras)
{
// Add the original course id field name and value to the extra fields if needed
$extras_associative = array();
if ($course_id_field_name != "chamilo_course_id") {
$extras_associative[$course_id_field_name] = $course_id_value;
}
foreach ($extras as $extra) {
$extras_associative[$extra['field_name']] = $extra['field_value'];
}
$course_admin_id = $this->getUserId($course_admin_user_id_field_name, $course_admin_user_id_value);
if ($course_admin_id instanceof WSError) {
return $course_admin_id;
}
if ($wanted_code == '') {
$wanted_code = CourseManager::generate_course_code($title);
}
$result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0);
if (!$result) {
return new WSError(202, 'There was an error creating the course');
} else {
// Update extra fields
foreach ($extras_associative as $fname => $fvalue) {
CourseManager::update_course_extra_field_value($result, $fname, $fvalue);
}
// Get course id
$course_info = CourseManager::get_course_information($result);
return $course_info['real_id'];
}
}
示例11: get_lang
<script>
$(function() {
' . $extra['jquery_ready_content'] . '
});
</script>';
$form->addElement('style_submit_button', 'button', get_lang('ModifyCourseInfo'), 'onclick="valide()"; class="save"');
// Set some default values
//$course['disk_quota'] = round($course['disk_quota']/1024/1024, 1);
$course['disk_quota'] = round(DocumentManager::get_course_quota($course_code) / 1024 / 1024, 1);
$course['title'] = api_html_entity_decode($course['title'], ENT_QUOTES, $charset);
$course['real_code'] = $course['code'];
$form->setDefaults($course);
// Validate form
if ($form->validate()) {
$course = $form->getSubmitValues();
$visual_code = CourseManager::generate_course_code($course['visual_code']);
// make sure to rebase the disk quota (shown in MB but stored in bytes)
$course['disk_quota'] = $course['disk_quota'] * 1024 * 1024;
CourseManager::update($course);
// Check if the visual code is already used by *another* course
$visual_code_is_used = false;
$warn = get_lang('TheFollowingCoursesAlreadyUseThisVisualCode') . ':';
if (!empty($visual_code)) {
$list = CourseManager::get_courses_info_from_visual_code($visual_code);
foreach ($list as $course_temp) {
if ($course_temp['code'] != $course_code) {
$visual_code_is_used = true;
$warn .= ' ' . $course_temp['title'] . ' (' . $course_temp['code'] . '),';
}
}
$warn = substr($warn, 0, -1);
示例12: editNode
function editNode($code, $name, $canHaveCourses, $old_code)
{
global $tbl_category, $tbl_course;
$canHaveCourses = $canHaveCourses ? 'TRUE' : 'FALSE';
$code = Database::escape_string($code);
$name = Database::escape_string($name);
$old_code = Database::escape_string($old_code);
if ($code != $old_code) {
$result = Database::query("SELECT 1 FROM {$tbl_category} WHERE code='{$code}'");
if (Database::num_rows($result)) {
return false;
}
}
$code = CourseManager::generate_course_code($code);
Database::query("UPDATE {$tbl_category} SET name='{$name}', code='{$code}',auth_course_child='{$canHaveCourses}' WHERE code='{$old_code}'");
$sql = "UPDATE {$tbl_course} SET category_code = '{$code}' WHERE category_code = '{$old_code}' ";
Database::query($sql);
return true;
}
示例13: store_survey
//.........这里部分代码省略.........
WHERE
c_id = ' . $course_id . ' AND
survey_id = ' . intval($values['parent_id']);
$rs = Database::query($sql);
$getversion = Database::fetch_array($rs, 'ASSOC');
if (empty($getversion['survey_version'])) {
$versionValue = ++$getversion['survey_version'];
} else {
$versionValue = $getversion['survey_version'];
}
} else {
$row = Database::fetch_array($rs, 'ASSOC');
$pos = api_strpos($row['survey_version']);
if ($pos === false) {
$row['survey_version'] = $row['survey_version'] + 1;
$versionValue = $row['survey_version'];
} else {
$getlast = explode('\\.', $row['survey_version']);
$lastversion = array_pop($getlast);
$lastversion = $lastversion + 1;
$add = implode('.', $getlast);
if ($add != '') {
$insertnewversion = $add . '.' . $lastversion;
} else {
$insertnewversion = $lastversion;
}
$versionValue = $insertnewversion;
}
}
$extraParams['survey_version'] = $versionValue;
}
}
$course_id = api_get_course_int_id();
$params = ['c_id' => $course_id, 'code' => strtolower(CourseManager::generate_course_code($values['survey_code'])), 'title' => $values['survey_title'], 'subtitle' => $values['survey_subtitle'], 'author' => $_user['user_id'], 'lang' => $values['survey_language'], 'avail_from' => $values['start_date'], 'avail_till' => $values['end_date'], 'is_shared' => $shared_survey_id, 'template' => 'template', 'intro' => $values['survey_introduction'], 'surveythanks' => $values['survey_thanks'], 'creation_date' => api_get_utc_datetime(), 'anonymous' => $values['anonymous'], 'session_id' => api_get_session_id(), 'visible_results' => $values['visible_results']];
$params = array_merge($params, $extraParams);
$survey_id = Database::insert($table_survey, $params);
if ($survey_id > 0) {
$sql = "UPDATE {$table_survey} SET survey_id = {$survey_id}\n WHERE iid = {$survey_id}";
Database::query($sql);
// Insert into item_property
api_item_property_update(api_get_course_info(), TOOL_SURVEY, $survey_id, 'SurveyAdded', api_get_user_id());
}
if ($values['survey_type'] == 1 && !empty($values['parent_id'])) {
SurveyManager::copy_survey($values['parent_id'], $survey_id);
}
$return['message'] = 'SurveyCreatedSuccesfully';
$return['type'] = 'confirmation';
$return['id'] = $survey_id;
} else {
// Check whether the code doesn't soon exists in this language
$sql = 'SELECT 1 FROM ' . $table_survey . '
WHERE
c_id = ' . $course_id . ' AND
code = "' . Database::escape_string($values['survey_code']) . '" AND
lang = "' . Database::escape_string($values['survey_language']) . '" AND
survey_id !=' . intval($values['survey_id']);
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
$return['message'] = 'ThisSurveyCodeSoonExistsInThisLanguage';
$return['type'] = 'error';
$return['id'] = isset($values['survey_id']) ? $values['survey_id'] : 0;
return $return;
}
if (!isset($values['anonymous']) || isset($values['anonymous']) && $values['anonymous'] == '') {
$values['anonymous'] = 0;
}