本文整理汇总了PHP中GradebookUtils::is_resource_in_course_gradebook方法的典型用法代码示例。如果您正苦于以下问题:PHP GradebookUtils::is_resource_in_course_gradebook方法的具体用法?PHP GradebookUtils::is_resource_in_course_gradebook怎么用?PHP GradebookUtils::is_resource_in_course_gradebook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GradebookUtils
的用法示例。
在下文中一共展示了GradebookUtils::is_resource_in_course_gradebook方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attendance_edit
/**
* edit attendances inside table
* @param int attendance id
* @param bool true for adding link in gradebook or false otherwise (optional)
* @return int last id
*/
public function attendance_edit($attendance_id, $link_to_gradebook = false)
{
$_course = api_get_course_info();
$tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
$table_link = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$session_id = api_get_session_id();
$user_id = api_get_user_id();
$attendance_id = intval($attendance_id);
$course_code = $_course['code'];
$course_id = $_course['real_id'];
$title_gradebook = $this->attendance_qualify_title;
$value_calification = 0;
$weight_calification = floatval($this->attendance_weight);
if (!empty($attendance_id)) {
$params = ['name' => $this->name, 'description' => $this->description, 'attendance_qualify_title' => $title_gradebook, 'attendance_weight' => $weight_calification];
Database::update($tbl_attendance, $params, ['c_id = ? AND id = ?' => [$course_id, $attendance_id]]);
api_item_property_update($_course, TOOL_ATTENDANCE, $attendance_id, "AttendanceUpdated", $user_id);
// add link to gradebook
if ($link_to_gradebook && !empty($this->category_id)) {
$description = '';
$link_id = GradebookUtils::is_resource_in_course_gradebook($course_code, 7, $attendance_id, $session_id);
if (!$link_id) {
GradebookUtils::add_resource_to_course_gradebook($this->category_id, $course_code, 7, $attendance_id, $title_gradebook, $weight_calification, $value_calification, $description, 1, $session_id);
} else {
Database::query('UPDATE ' . $table_link . ' SET weight=' . $weight_calification . ' WHERE id=' . $link_id . '');
}
}
return $attendance_id;
}
return null;
}
示例2: store_survey
//.........这里部分代码省略.........
}
$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;
$values['one_question_per_page'] = isset($values['one_question_per_page']) ? $values['one_question_per_page'] : null;
$values['show_form_profile'] = isset($values['show_form_profile']) ? $values['show_form_profile'] : null;
$extraParams = [];
$extraParams['shuffle'] = $values['shuffle'];
$extraParams['one_question_per_page'] = $values['one_question_per_page'];
$extraParams['shuffle'] = $values['shuffle'];
if ($values['anonymous'] == 0) {
$extraParams['show_form_profile'] = $values['show_form_profile'];
if ($values['show_form_profile'] == 1) {
$fields = explode(',', $values['input_name_list']);
$field_values = '';
foreach ($fields as &$field) {
if ($field != '') {
if (!isset($values[$field]) || isset($values[$field]) && $values[$field] == '') {
$values[$field] = 0;
}
$field_values .= $field . ':' . $values[$field] . '@';
}
}
$extraParams['form_fields'] = $field_values;
} else {
$extraParams['form_fields'] = '';
}
} else {
$extraParams['show_form_profile'] = 0;
$extraParams['form_fields'] = '';
}
$params = ['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'], 'anonymous' => $values['anonymous'], 'session_id' => api_get_session_id(), 'visible_results' => $values['visible_results']];
$params = array_merge($params, $extraParams);
Database::update($table_survey, $params, ['c_id = ? AND survey_id = ?' => [$course_id, $values['survey_id']]]);
// Update into item_property (update)
api_item_property_update(api_get_course_info(), TOOL_SURVEY, $values['survey_id'], 'SurveyUpdated', api_get_user_id());
Display::addFlash(Display::return_message(get_lang('SurveyUpdatedSuccesfully'), 'confirmation'));
$return['id'] = $values['survey_id'];
}
$survey_id = intval($return['id']);
// Gradebook
$gradebook_option = false;
if (isset($values['survey_qualify_gradebook'])) {
$gradebook_option = $values['survey_qualify_gradebook'] > 0;
}
$gradebook_link_type = 8;
$link_info = GradebookUtils::is_resource_in_course_gradebook($courseCode, $gradebook_link_type, $survey_id, $session_id);
$gradebook_link_id = $link_info ? $link_info->getId() : false;
if ($gradebook_option) {
if ($survey_id > 0) {
$title_gradebook = '';
// Not needed here.
$description_gradebook = '';
// Not needed here.
$survey_weight = floatval($_POST['survey_weight']);
$max_score = 1;
if (!$gradebook_link_id) {
GradebookUtils::add_resource_to_course_gradebook($values['category_id'], $courseCode, $gradebook_link_type, $survey_id, $title_gradebook, $survey_weight, $max_score, $description_gradebook, 1, $session_id);
} else {
GradebookUtils::update_resource_from_course_gradebook($gradebook_link_id, $courseCode, $survey_weight);
}
}
} else {
// Delete everything of the gradebook for this $linkId
GradebookUtils::remove_resource_from_course_gradebook($gradebook_link_id);
//comenting this line to correctly return the function msg
//exit;
}
return $return;
}
示例3: get_lang
// Adavanced Parameters
if (Gradebook::is_active()) {
if (!empty($attendance_qualify_title) || !empty($attendance_weight)) {
$form->addButtonAdvancedSettings('id_qualify');
$form->addElement('html', '<div id="id_qualify_options" style="display:block">');
$form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'), array('checked' => 'true', 'onclick' => 'javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}'));
$form->addElement('html', '<div id="options_field" style="display:block">');
} else {
$form->addButtonAdvancedSettings('id_qualify');
$form->addElement('html', '<div id="id_qualify_options" style="display:none">');
$form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'), 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
$form->addElement('html', '<div id="options_field" style="display:none">');
}
GradebookUtils::load_gradebook_select_in_tool($form);
$form->addElement('text', 'attendance_qualify_title', get_lang('TitleColumnGradebook'));
$form->applyFilter('attendance_qualify_title', 'html_filter');
$form->addElement('text', 'attendance_weight', get_lang('QualifyWeight'), 'value="0.00" Style="width:40px" onfocus="javascript: this.select();"');
$form->applyFilter('attendance_weight', 'html_filter');
$form->addElement('html', '</div>');
$form->addElement('html', '</div>');
}
$form->addButtonUpdate(get_lang('Save'));
// set default values
$default['title'] = Security::remove_XSS($title);
$default['description'] = Security::remove_XSS($description, STUDENT);
$default['attendance_qualify_title'] = $attendance_qualify_title;
$default['attendance_weight'] = $attendance_weight;
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 7, $attendance_id, api_get_session_id());
$default['category_id'] = $link_info->getCategoryId();
$form->setDefaults($default);
$form->display();
示例4: array
if ($_GET['action'] == 'add') {
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php?' . api_get_cidreq(), 'name' => get_lang('SurveyList'));
$tool_name = get_lang('CreateNewSurvey');
}
if ($_GET['action'] == 'edit' && is_numeric($survey_id)) {
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php?' . api_get_cidreq(), 'name' => get_lang('SurveyList'));
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'survey/survey.php?survey_id=' . $survey_id . '&' . api_get_cidreq(), 'name' => Security::remove_XSS($urlname));
$tool_name = get_lang('EditSurvey');
}
$gradebook_link_id = null;
// Getting the default values
if ($_GET['action'] == 'edit' && isset($survey_id) && is_numeric($survey_id)) {
$defaults = $survey_data;
$defaults['survey_id'] = $survey_id;
$defaults['anonymous'] = $survey_data['anonymous'];
$link_info = GradebookUtils::is_resource_in_course_gradebook($course_id, $gradebook_link_type, $survey_id, $session_id);
$gradebook_link_id = $link_info['id'];
if ($link_info) {
$defaults['category_id'] = $link_info['category_id'];
if ($sql_result_array = Database::fetch_array(Database::query('SELECT weight FROM ' . $table_gradebook_link . ' WHERE id=' . $gradebook_link_id))) {
$defaults['survey_qualify_gradebook'] = $gradebook_link_id;
$defaults['survey_weight'] = number_format($sql_result_array['weight'], 2, '.', '');
}
}
} else {
$defaults['survey_language'] = $_course['language'];
$defaults['start_date'] = date('Y-m-d', api_strtotime(api_get_local_time()));
$startdateandxdays = time() + 864000;
// today + 10 days
$defaults['end_date'] = date('Y-m-d', $startdateandxdays);
//$defaults['survey_share']['survey_share'] = 0;
示例5: store_edit_post
/**
* This function stores the edit of a post in the forum_post table.
*
* @param array
* @return void HTML
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function store_edit_post($values)
{
$threadTable = Database::get_course_table(TABLE_FORUM_THREAD);
$table_posts = Database::get_course_table(TABLE_FORUM_POST);
$course_id = api_get_course_int_id();
//check if this post is the first of the thread
// First we check if the change affects the thread and if so we commit
// the changes (sticky and post_title=thread_title are relevant).
$posts = getPosts($values['thread_id']);
$first_post = null;
if (!empty($posts) && count($posts) > 0 && isset($posts[0])) {
$first_post = $posts[0];
}
if (!empty($first_post) && $first_post['post_id'] == $values['post_id']) {
$params = ['thread_title' => $values['post_title'], 'thread_sticky' => isset($values['thread_sticky']) ? $values['thread_sticky'] : null, 'thread_title_qualify' => $values['calification_notebook_title'], 'thread_qualify_max' => $values['numeric_calification'], 'thread_weight' => $values['weight_calification'], 'thread_peer_qualify' => $values['thread_peer_qualify']];
$where = ['c_id = ? AND thread_id = ?' => [$course_id, $values['thread_id']]];
Database::update($threadTable, $params, $where);
}
// Update the post_title and the post_text.
$params = ['post_title' => $values['post_title'], 'post_text' => $values['post_text'], 'post_notification' => isset($values['post_notification']) ? $values['post_notification'] : ''];
$where = ['c_id = ? AND post_id = ?' => [$course_id, $values['post_id']]];
Database::update($table_posts, $params, $where);
// Update attached files
if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
foreach ($_POST['file_ids'] as $key => $id) {
editAttachedFile(array('comment' => $_POST['file_comments'][$key], 'post_id' => $values['post_id']), $id);
}
}
if (!empty($values['remove_attach'])) {
delete_attachment($values['post_id']);
}
if (empty($values['id_attach'])) {
add_forum_attachment_file(isset($values['file_comment']) ? $values['file_comment'] : null, $values['post_id']);
} else {
edit_forum_attachment_file(isset($values['file_comment']) ? $values['file_comment'] : null, $values['post_id'], $values['id_attach']);
}
if (api_is_course_admin() == true) {
$ccode = api_get_course_id();
$sid = api_get_session_id();
$link_info = GradebookUtils::is_resource_in_course_gradebook($ccode, 5, $values['thread_id'], $sid);
$link_id = $link_info['id'];
$thread_qualify_gradebook = isset($values['thread_qualify_gradebook']) ? $values['thread_qualify_gradebook'] : null;
if ($thread_qualify_gradebook != 1) {
if ($link_info !== false) {
GradebookUtils::remove_resource_from_course_gradebook($link_id);
}
} else {
if ($link_info === false && !$_GET['thread']) {
$weigthqualify = $values['weight_calification'];
GradebookUtils::add_resource_to_course_gradebook($values['category_id'], $ccode, 5, $values['thread_id'], Database::escape_string(stripslashes($values['calification_notebook_title'])), $weigthqualify, $values['numeric_calification'], null, 0, $sid);
}
}
}
// Storing the attachments if any.
//update_added_resources('forum_post', $values['post_id']);
$message = get_lang('EditPostStored') . '<br />';
$message .= get_lang('ReturnTo') . ' <a href="viewforum.php?' . api_get_cidreq() . '&forum=' . intval($_GET['forum']) . '&">
' . get_lang('Forum') . '</a><br />';
$message .= get_lang('ReturnTo') . ' <a href="viewthread.php?' . api_get_cidreq() . '&forum=' . intval($_GET['forum']) . '&thread=' . $values['thread_id'] . '&post=' . intval($_GET['post']) . '">' . get_lang('Message') . '</a>';
Session::erase('formelements');
Session::erase('origin');
Session::erase('breadcrumbs');
Session::erase('addedresource');
Session::erase('addedresourceid');
Display::display_confirmation_message($message, false);
}
示例6: change_visibility
/* Actions */
// Change visibility of a forum or a forum category.
if (($my_action == 'invisible' || $my_action == 'visible') && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_edit(false, true) && api_is_allowed_to_session_edit(false, true)) {
$message = change_visibility($_GET['content'], $_GET['id'], $_GET['action']);
}
// Locking and unlocking.
if (($my_action == 'lock' || $my_action == 'unlock') && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_edit(false, true) && api_is_allowed_to_session_edit(false, true)) {
$message = change_lock_status($_GET['content'], $_GET['id'], $my_action);
}
// Deleting.
if ($my_action == 'delete' && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_edit(false, true) && api_is_allowed_to_session_edit(false, true)) {
$locked = api_resource_is_locked_by_gradebook($_GET['id'], LINK_FORUM_THREAD);
if ($locked == false) {
$message = deleteForumCategoryThread($_GET['content'], $_GET['id']);
// Delete link
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 5, intval($_GET['id']), api_get_session_id());
$link_id = $link_info->getId();
if ($link_info) {
GradebookUtils::remove_resource_from_course_gradebook($link_id);
}
}
}
// Moving.
if ($my_action == 'move' && isset($_GET['thread']) && api_is_allowed_to_edit(false, true) && api_is_allowed_to_session_edit(false, true)) {
$message = move_thread_form();
}
// Notification.
if ($my_action == 'notify' && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_session_edit(false, true)) {
$return_message = set_notification($_GET['content'], $_GET['id']);
Display::display_confirmation_message($return_message, false);
}
示例7: class_visible_invisible
echo '<h1><a href="viewforum.php?&origin=' . $origin . '&forum=' . $current_forum['forum_id'] . '" ' . class_visible_invisible($current_forum['visibility']) . '>' . prepare4display($current_forum['forum_title']) . '</a></h1>';
echo '<p class="forum_description">' . prepare4display($current_forum['forum_comment']) . '</p>';
echo '</div>';
/* End new display forum */
// Set forum attachment data into $_SESSION
getAttachedFiles($current_forum['forum_id'], $current_thread['thread_id'], $current_post['post_id']);
$values = show_edit_post_form($forum_setting, $current_post, $current_thread, $current_forum, isset($_SESSION['formelements']) ? $_SESSION['formelements'] : '');
if (!empty($values) and isset($_POST['SubmitPost'])) {
store_edit_post($values);
$option_chek = isset($values['thread_qualify_gradebook']) ? $values['thread_qualify_gradebook'] : null;
// values 1 or 0
if (1 == $option_chek) {
$id = $values['thread_id'];
$title_gradebook = Security::remove_XSS(stripslashes($values['calification_notebook_title']));
$value_calification = $values['numeric_calification'];
$weight_calification = $values['weight_calification'];
$description = '';
$session_id = api_get_session_id();
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 5, $id, $session_id);
$link_id = $link_info['id'];
if (!$link_info) {
GradebookUtils::add_resource_to_course_gradebook($values['category_id'], api_get_course_id(), 5, $id, $title_gradebook, $weight_calification, $value_calification, $description, 1, api_get_session_id());
} else {
Database::query('UPDATE ' . $table_link . ' SET weight=' . $weight_calification . ' WHERE id=' . $link_id . '');
}
}
}
// Footer
if (isset($origin) && $origin != 'learnpath') {
Display::display_footer();
}
示例8: Exercise
Display::display_confirmation_message(sprintf(get_lang('XResultsCleaned'), $quantity_results_deleted));
}
}
// single exercise choice
// construction of Exercise
$objExerciseTmp = new Exercise();
$check = Security::check_token('get');
$exercise_action_locked = api_resource_is_locked_by_gradebook($exerciseId, LINK_EXERCISE);
if ($objExerciseTmp->read($exerciseId)) {
if ($check) {
switch ($choice) {
case 'delete':
// deletes an exercise
if ($exercise_action_locked == false) {
$objExerciseTmp->delete();
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 1, $exerciseId, api_get_session_id());
if ($link_info !== false) {
GradebookUtils::remove_resource_from_course_gradebook($link_info['id']);
}
Display::display_confirmation_message(get_lang('ExerciseDeleted'));
}
break;
case 'enable':
// enables an exercise
$objExerciseTmp->enable();
$objExerciseTmp->save();
api_item_property_update($courseInfo, TOOL_QUIZ, $objExerciseTmp->id, 'visible', $userId);
// "WHAT'S NEW" notification: update table item_property (previously last_tooledit)
Display::display_confirmation_message(get_lang('VisibilityChanged'));
break;
case 'disable':
示例9: delete
/**
* Static admin function allowing removal of a learnpath
* @param string Course code
* @param integer Learnpath ID
* @param string Whether to delete data or keep it (default: 'keep', others: 'remove')
* @return boolean True on success, false on failure (might change that to return number of elements deleted)
*/
public function delete($course = null, $id = null, $delete = 'keep')
{
$course_id = api_get_course_int_id();
// TODO: Implement a way of getting this to work when the current object is not set.
// In clear: implement this in the item class as well (abstract class) and use the given ID in queries.
// If an ID is specifically given and the current LP is not the same, prevent delete.
if (!empty($id) && $id != $this->lp_id) {
return false;
}
$lp = Database::get_course_table(TABLE_LP_MAIN);
$lp_item = Database::get_course_table(TABLE_LP_ITEM);
$lp_view = Database::get_course_table(TABLE_LP_VIEW);
$lp_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
// Delete lp item id.
foreach ($this->items as $id => $dummy) {
$sql = "DELETE FROM {$lp_item_view}\n WHERE c_id = {$course_id} AND lp_item_id = '" . $id . "'";
Database::query($sql);
}
// Proposed by Christophe (nickname: clefevre)
$sql = "DELETE FROM {$lp_item} WHERE c_id = " . $course_id . " AND lp_id = " . $this->lp_id;
Database::query($sql);
$sql = "DELETE FROM {$lp_view} WHERE c_id = " . $course_id . " AND lp_id = " . $this->lp_id;
Database::query($sql);
self::toggle_publish($this->lp_id, 'i');
if ($this->type == 2 || $this->type == 3) {
// This is a scorm learning path, delete the files as well.
$sql = "SELECT path FROM {$lp}\n WHERE c_id = " . $course_id . " AND id = " . $this->lp_id;
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$row = Database::fetch_array($res);
$path = $row['path'];
$sql = "SELECT id FROM {$lp}\n WHERE c_id = " . $course_id . " AND path = '{$path}' AND id != " . $this->lp_id;
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
// Another learning path uses this directory, so don't delete it.
if ($this->debug > 2) {
error_log('New LP - In learnpath::delete(), found other LP using path ' . $path . ', keeping directory', 0);
}
} else {
// No other LP uses that directory, delete it.
$course_rel_dir = api_get_course_path() . '/scorm/';
// scorm dir web path starting from /courses
$course_scorm_dir = api_get_path(SYS_COURSE_PATH) . $course_rel_dir;
// The absolute system path for this course.
if ($delete == 'remove' && is_dir($course_scorm_dir . $path) and !empty($course_scorm_dir)) {
if ($this->debug > 2) {
error_log('New LP - In learnpath::delete(), found SCORM, deleting directory: ' . $course_scorm_dir . $path, 0);
}
// Proposed by Christophe (clefevre).
if (strcmp(substr($path, -2), "/.") == 0) {
$path = substr($path, 0, -1);
// Remove "." at the end.
}
//exec('rm -rf ' . $course_scorm_dir . $path); // See Bug #5208, this is not OS-portable way.
rmdirr($course_scorm_dir . $path);
}
}
}
}
$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
$link = 'newscorm/lp_controller.php?action=view&lp_id=' . $this->lp_id;
// Delete tools
$sql = "DELETE FROM {$tbl_tool}\n WHERE c_id = " . $course_id . " AND (link LIKE '{$link}%' AND image='scormbuilder.gif')";
Database::query($sql);
$sql = "DELETE FROM {$lp} WHERE c_id = " . $course_id . " AND id = " . $this->lp_id;
Database::query($sql);
// Updates the display order of all lps.
$this->update_display_order();
api_item_property_update(api_get_course_info(), TOOL_LEARNPATH, $this->lp_id, 'delete', api_get_user_id());
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 4, $id, api_get_session_id());
if ($link_info !== false) {
GradebookUtils::remove_resource_from_course_gradebook($link_info['id']);
}
if (api_get_setting('search_enabled') == 'true') {
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
delete_all_values_for_item($this->cc, TOOL_LEARNPATH, $this->lp_id);
}
}
示例10: get_work_assignment_by_id
$homework = get_work_assignment_by_id($workId);
$locked = api_resource_is_locked_by_gradebook($workId, LINK_STUDENTPUBLICATION);
if (api_is_platform_admin() == false && $locked == true) {
api_not_allowed(true);
}
$htmlHeadXtra[] = to_javascript_work();
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'work/work.php?' . api_get_cidreq(), 'name' => get_lang('StudentPublications'));
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Edit'));
$form = new FormValidator('edit_dir', 'post', api_get_path(WEB_CODE_PATH) . 'work/edit_work.php?id=' . $workId . '&' . api_get_cidreq());
$form->addElement('header', get_lang('Edit'));
$title = !empty($workData['title']) ? $workData['title'] : basename($workData['url']);
$defaults = $workData;
$defaults['new_dir'] = Security::remove_XSS($title);
$there_is_a_end_date = false;
if (Gradebook::is_active()) {
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), LINK_STUDENTPUBLICATION, $workId);
if (!empty($link_info)) {
$defaults['weight'] = $link_info['weight'];
$defaults['category_id'] = $link_info['category_id'];
$defaults['make_calification'] = 1;
}
} else {
$defaults['category_id'] = '';
}
if (!empty($homework['expires_on'])) {
$homework['expires_on'] = api_get_local_time($homework['expires_on']);
$there_is_a_expire_date = true;
$defaults['enableExpiryDate'] = true;
} else {
$homework['expires_on'] = null;
$there_is_a_expire_date = false;
示例11: updatePublicationAssignment
/**
* @param int $workId
* @param array $params
* @param array $courseInfo
* @param int $groupId
*/
function updatePublicationAssignment($workId, $params, $courseInfo, $groupId)
{
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$workId = intval($workId);
$time = api_get_utc_datetime();
$course_id = $courseInfo['real_id'];
// Insert into agenda
$agendaId = 0;
if (isset($params['add_to_calendar']) && $params['add_to_calendar'] == 1) {
require_once api_get_path(SYS_CODE_PATH) . 'resourcelinker/resourcelinker.inc.php';
// Setting today date
$date = $end_date = $time;
if (isset($params['enableExpiryDate'])) {
$end_date = $params['expires_on'];
$date = $end_date;
}
$title = sprintf(get_lang('HandingOverOfTaskX'), $params['new_dir']);
$description = isset($params['description']) ? $params['description'] : '';
$content = '<a href="' . api_get_path(WEB_CODE_PATH) . 'work/work_list.php?' . api_get_cidreq() . '&id=' . $workId . '">' . $params['new_dir'] . '</a>' . $description;
$agendaId = agendaExistsForWork($workId, $courseInfo);
// Add/edit agenda
$agenda = new Agenda();
$agenda->set_course($courseInfo);
$agenda->type = 'course';
if (empty($agendaId)) {
$agendaId = $agenda->addEvent($date, $end_date, 'false', $title, $content, array('GROUP:' . $groupId));
} else {
$agenda->editEvent($agendaId, $end_date, $end_date, 'false', $title, $content);
}
}
$qualification = isset($params['qualification']) && !empty($params['qualification']) ? 1 : 0;
$expiryDate = isset($params['enableExpiryDate']) && $params['enableExpiryDate'] == 1 ? api_get_utc_datetime($params['expires_on']) : '';
$endDate = isset($params['enableEndDate']) && $params['enableEndDate'] == 1 ? api_get_utc_datetime($params['ends_on']) : '';
$data = get_work_assignment_by_id($workId, $course_id);
if (!empty($expiryDate)) {
$expiryDateCondition = "expires_on = '" . Database::escape_string($expiryDate) . "', ";
} else {
$expiryDateCondition = "expires_on = null, ";
}
if (!empty($endDate)) {
$endOnCondition = "ends_on = '" . Database::escape_string($endDate) . "', ";
} else {
$endOnCondition = "ends_on = null, ";
}
if (empty($data)) {
$sql = "INSERT INTO {$table} SET\n c_id = {$course_id} ,\n {$expiryDateCondition}\n {$endOnCondition}\n add_to_calendar = {$agendaId},\n enable_qualification = '{$qualification}',\n publication_id = '{$workId}'";
Database::query($sql);
$my_last_id = Database::insert_id();
if ($my_last_id) {
$sql = "UPDATE {$table} SET\n id = iid\n WHERE iid = {$my_last_id}";
Database::query($sql);
$sql = "UPDATE {$workTable} SET\n has_properties = {$my_last_id},\n view_properties = 1\n WHERE c_id = {$course_id} AND id = {$workId}";
Database::query($sql);
}
} else {
$sql = "UPDATE {$table} SET\n {$expiryDateCondition}\n {$endOnCondition}\n add_to_calendar = {$agendaId},\n enable_qualification = '" . $qualification . "'\n WHERE\n publication_id = {$workId} AND\n c_id = {$course_id} AND\n id = " . $data['id'];
Database::query($sql);
}
if (!empty($params['category_id'])) {
$link_info = GradebookUtils::is_resource_in_course_gradebook($courseInfo['code'], LINK_STUDENTPUBLICATION, $workId, api_get_session_id());
$linkId = null;
if (!empty($link_info)) {
$linkId = $link_info['id'];
}
if (isset($params['make_calification']) && $params['make_calification'] == 1) {
if (empty($linkId)) {
GradebookUtils::add_resource_to_course_gradebook($params['category_id'], $courseInfo['code'], LINK_STUDENTPUBLICATION, $workId, $params['new_dir'], (double) $params['weight'], (double) $params['qualification'], $params['description'], 1, api_get_session_id());
} else {
GradebookUtils::update_resource_from_course_gradebook($linkId, $courseInfo['code'], $params['weight']);
}
} else {
// Delete everything of the gradebook for this $linkId
GradebookUtils::remove_resource_from_course_gradebook($linkId);
}
}
}
示例12: attendance_edit
/**
* edit attendances inside table
* @param int attendance id
* @param bool true for adding link in gradebook or false otherwise (optional)
* @return int last id
*/
public function attendance_edit($attendance_id, $link_to_gradebook = false)
{
$_course = api_get_course_info();
$tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
$em = Database::getManager();
$session_id = api_get_session_id();
$user_id = api_get_user_id();
$attendance_id = intval($attendance_id);
$course_code = $_course['code'];
$course_id = $_course['real_id'];
$title_gradebook = $this->attendance_qualify_title;
$value_calification = 0;
$weight_calification = floatval($this->attendance_weight);
if (!empty($attendance_id)) {
$params = ['name' => $this->name, 'description' => $this->description, 'attendance_qualify_title' => $title_gradebook, 'attendance_weight' => $weight_calification];
Database::update($tbl_attendance, $params, ['c_id = ? AND id = ?' => [$course_id, $attendance_id]]);
api_item_property_update($_course, TOOL_ATTENDANCE, $attendance_id, "AttendanceUpdated", $user_id);
// add link to gradebook
if ($link_to_gradebook && !empty($this->category_id)) {
$description = '';
$link = GradebookUtils::is_resource_in_course_gradebook($course_code, 7, $attendance_id, $session_id);
if (!$link) {
GradebookUtils::add_resource_to_course_gradebook($this->category_id, $course_code, 7, $attendance_id, $title_gradebook, $weight_calification, $value_calification, $description, 1, $session_id);
} else {
$gradebookLink = $em->find('ChamiloCoreBundle:GradebookLink', $this->getId());
$gradebookLink->setWeight($weight_calification);
$em->persist($gradebookLink);
$em->flush();
}
}
return $attendance_id;
}
return null;
}