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


PHP GradebookUtils::update_resource_from_course_gradebook方法代码示例

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


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


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