当前位置: 首页>>代码示例>>PHP>>正文


PHP GradebookUtils::add_resource_to_course_gradebook方法代码示例

本文整理汇总了PHP中GradebookUtils::add_resource_to_course_gradebook方法的典型用法代码示例。如果您正苦于以下问题:PHP GradebookUtils::add_resource_to_course_gradebook方法的具体用法?PHP GradebookUtils::add_resource_to_course_gradebook怎么用?PHP GradebookUtils::add_resource_to_course_gradebook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GradebookUtils的用法示例。


在下文中一共展示了GradebookUtils::add_resource_to_course_gradebook方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
    }
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:101,代码来源:survey.lib.php

示例2: 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;
 }
开发者ID:daffef,项目名称:chamilo-lms,代码行数:37,代码来源:attendance.lib.php

示例3: 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);
}
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:75,代码来源:forumfunction.inc.php

示例4: 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();
}
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:31,代码来源:editpost.php

示例5: intval

            $survey_id = intval($return['id']);
            if ($survey_id > 0) {
                $title_gradebook = '';
                // Not needed here.
                $description_gradebook = '';
                // Not needed here.
                $survey_weight = floatval($_POST['survey_weight']);
                $max_score = 1;
                $date = time();
                // TODO: Maybe time zones implementation is needed here.
                $visible = 1;
                // 1 = visible
                $link_info = GradebookUtils::is_resource_in_course_gradebook($course_id, $gradebook_link_type, $survey_id, $session_id);
                $gradebook_link_id = $link_info['id'];
                if (!$gradebook_link_id) {
                    GradebookUtils::add_resource_to_course_gradebook($course_id, $gradebook_link_type, $survey_id, $title_gradebook, $survey_weight, $max_score, $description_gradebook, 1, $session_id);
                } else {
                    Database::query('UPDATE ' . $table_gradebook_link . ' SET weight=' . $survey_weight . ' WHERE id=' . $gradebook_link_id);
                }
            }
        }
    }
    Display::addFlash(Display::return_message($return['message'] == 'SurveyUpdatedSuccesfully' ? get_lang($return['message']) : $return['message'], false));
    // Redirecting to the survey page (whilst showing the return message)
    header('location: ' . api_get_path(WEB_CODE_PATH) . 'survey/survey.php?survey_id=' . $return['id'] . '&message=' . $return['message'] . '&' . api_get_cidreq());
    exit;
} else {
    // Displaying the header
    Display::display_header($tool_name);
    $form->display();
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:create_new_survey.php

示例6: 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);
        }
    }
}
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:83,代码来源:work.lib.php

示例7: 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;
 }
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:40,代码来源:attendance.lib.php


注:本文中的GradebookUtils::add_resource_to_course_gradebook方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。