Beispiel #1
0
        //
    } else {
        if (isset($_GET['selectcat']) && $_GET['selectcat'] == 0 || isset($_GET['cidReq']) && $_GET['cidReq'] !== '' || isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false') {
            $cats = Category::load(null, null, $course_code, null, null, $session_id, false);
        }
    }
}
if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true)) {
    echo '<meta http-equiv="refresh" content="0;url=' . api_get_self() . '?cidReq=' . $course_code . '" />';
} else {
    $cats = Category::load(null, null, $course_code, null, null, $session_id, false);
    if (!empty($cats)) {
        if (api_get_setting('gradebook.gradebook_enable_grade_model') == 'true' && (api_is_platform_admin() || api_is_allowed_to_edit(null, true) && api_get_setting('gradebook.teachers_can_change_grade_model_settings') == 'true')) {
            // Getting grade models.
            $obj = new GradeModel();
            $grade_models = $obj->get_all();
            $grade_model_id = $cats[0]->get_grade_model_id();
            // No children.
            if (count($cats) == 1 && empty($grade_model_id) || count($cats) == 1 && $grade_model_id != -1) {
                if (!empty($grade_models)) {
                    $form_grade = new FormValidator('grade_model_settings');
                    $obj->fill_grade_model_select_in_form($form_grade, 'grade_model_id', $grade_model_id);
                    $form_grade->addButtonSave(get_lang('Save'));
                    if ($form_grade->validate()) {
                        $value = $form_grade->exportValue('grade_model_id');
                        $gradebook = new Gradebook();
                        $gradebook->update(array('id' => $cats[0]->get_id(), 'grade_model_id' => $value), true);
                        //do something
                        $obj = new GradeModel();
                        $components = $obj->get_components($value);
                        foreach ($components as $component) {
function select_gradebook_default_grade_model_id()
{
    $grade_model = new GradeModel();
    $models = $grade_model->get_all();
    $options = array();
    $options[-1] = get_lang('None');
    if (!empty($models)) {
        foreach ($models as $model) {
            $options[$model['id']] = $model['name'];
        }
    }
    return $options;
}