Exemplo n.º 1
0
    }
}

// Check if the teacher is allowed to create in the departments he chose
if (!$deps_valid) {    
    $tool_content .= "<div class='alert alert-danger'>$langCreateCourseNotAllowedNode</div>
                    <p class='pull-right'><a class='btn btn-default' href='$_SERVER[PHP_SELF]'>$langBack</a></p>";
    draw($tool_content, 1, null, $head_content);
    exit();
}


// display form
if (!isset($_POST['create_course'])) {
        // set skip_preloaded_defaults in order to not over-bloat pre-populating nodepicker with defaults in case of multiple allowance
        list($js, $html) = $tree->buildCourseNodePicker(array('defaults' => $allowables, 'allow_only_defaults' => $allow_only_defaults, 'skip_preloaded_defaults' => true));
        $head_content .= $js;
        foreach ($license as $id => $l_info) {
            if ($id and $id < 10) {
                $cc_license[$id] = $l_info['title'];
            }
        }
        $tool_content .= action_bar(array(
                                array('title' => $langBack,
                                      'url' => $urlServer,
                                      'icon' => 'fa-reply',
                                      'level' => 'primary-label',
                                      'button-class' => 'btn-default')
                            ),false);
        $tool_content .= "
<div class='form-wrapper'>
Exemplo n.º 2
0
    mkdir($restoreThis, 0755, true);
    archiveTables($course_id, $course_code, $restoreThis);
    recurse_copy($webDir . '/courses/' . $course_code,
        $restoreThis . '/html');

    register_posted_variables(array(
        'course_code' => true,
        'course_lang' => true,
        'course_title' => true,
        'course_desc' => true,
        'course_vis' => true,
        'course_prof' => true), 'all');

    create_restored_course($tool_content, $restoreThis, $course_code, $course_lang, $course_title, $course_desc, $course_vis, $course_prof);
    $course_code = $currentCourseCode; // revert course code to the correct value
} else {
    $desc = Database::get()->querySingle("SELECT description FROM course WHERE id = ?d", $course_id)->description;
    $old_deps = array();
    Database::get()->queryFunc("SELECT department FROM course_department WHERE course = ?d",
        function ($dep) use ($treeObj, &$old_deps) {
            $old_deps[] = array('name' => $treeObj->getFullPath($dep->department));
        }, $course_id);

    $tool_content = course_details_form($public_code, $currentCourseName, $titulaires, $currentCourseLanguage, null, $visible, $desc, $old_deps);
}

load_js('jstree3');
list($js, $html) = $treeObj->buildCourseNodePicker();
$head_content .= $js;
draw($tool_content, 2, null, $head_content);
Exemplo n.º 3
0
    if (isDepartmentAdmin()) {
        $olddeps = $course->getDepartmentIds($cId);
        foreach ($departments as $depId) {
            if (!in_array($depId, $olddeps)) {
                validateNode(intval($depId), true);
            }
        }
        foreach ($olddeps as $depId) {
            if (!in_array($depId, $departments)) {
                validateNode($depId, true);
            }
        }
    }
    // Update query
    Database::get()->query("UPDATE course SET title = ?s,\n                    prof_names = ?s\n                    WHERE code = ?s", $_POST['title'], $_POST['titulary'], $_GET['c']);
    $course->refresh($cId, $departments);
    $tool_content .= "<div class='alert alert-success'>{$langModifDone}</div>";
} else {
    $row = Database::get()->querySingle("SELECT course.code AS code, course.title AS title, course.prof_names AS prof_name, course.id AS id\n                                            FROM course\n                                           WHERE course.code = ?s", $_GET['c']);
    $tool_content .= "<div class='form-wrapper'>\n\t<form role='form' class='form-horizontal' action='" . $_SERVER['SCRIPT_NAME'] . "?c=" . q($_GET['c']) . "' method='post' onsubmit='return validateNodePickerForm();'>\n\t<fieldset>\n        <div class='form-group'>\n\t    <label for='Faculty' class='col-sm-2 control-label'>{$langFaculty}:</label>\n            <div class='col-sm-10'>";
    if (isDepartmentAdmin()) {
        list($js, $html) = $tree->buildCourseNodePicker(array('defaults' => $course->getDepartmentIds($row->id), 'allowables' => $user->getDepartmentIds($uid)));
    } else {
        list($js, $html) = $tree->buildCourseNodePicker(array('defaults' => $course->getDepartmentIds($row->id)));
    }
    $head_content .= $js;
    $tool_content .= $html;
    $tool_content .= "</div></div>";
    $tool_content .= "<div class='form-group'>\n            <label for='fcode' class='col-sm-2 control-label'>{$langCode}</label>\n            <div class='col-sm-10'>\n                <input type='text' class='form-control' name='fcode' id='fcode' value='{$row->code}' size='60' />\n            </div>\n        </div>\n        <div class='form-group'>\n            <label for='title' class='col-sm-2 control-label'>{$langCourseTitle}:</label>\n            <div class='col-sm-10'>\n\t\t<input type='text' class='form-control' name='title' id='title' value='" . q($row->title) . "' size='60' />\n\t    </div>\n        </div>\n        <div class='form-group'>\n            <label for='titulary' class='col-sm-2 control-label'>{$langTeachers}:</label>\n            <div class='col-sm-10'>\n\t\t<input type='text' class='form-control' name='titulary' id='titulary' value='" . q($row->prof_name) . "' size='60' />\n\t    </div>\n        </div>\n        <div class='form-group'>\n            <div class='col-sm-10 col-sm-offset-4'>\n                <input class='btn btn-primary' type='submit' name='submit' value='{$langModify}'>\n            </div>\n        </div>\n        </fieldset>\n\t</form>\n        </div>";
}
draw($tool_content, 3, null, $head_content);
Exemplo n.º 4
0
$deps_valid = true;
foreach ($departments as $dep) {
    if (get_config('restrict_teacher_owndep') && !$is_admin && !in_array($dep, $user->getDepartmentIds($uid))) {
        $deps_valid = false;
    }
}
// Check if the teacher is allowed to create in the departments he chose
if (!$deps_valid) {
    $tool_content .= "<div class='alert alert-danger'>{$langCreateCourseNotAllowedNode}</div>\n                    <p class='pull-right'><a class='btn btn-default' href='{$_SERVER['PHP_SELF']}'>{$langBack}</a></p>";
    draw($tool_content, 1, null, $head_content);
    exit;
}
// display form
if (!isset($_POST['create_course'])) {
    $allow_only_defaults = get_config('restrict_teacher_owndep') && !$is_admin ? true : false;
    list($js, $html) = $tree->buildCourseNodePicker(array('defaults' => $user->getDepartmentIds($uid), 'allow_only_defaults' => $allow_only_defaults));
    $head_content .= $js;
    foreach ($license as $id => $l_info) {
        if ($id and $id < 10) {
            $cc_license[$id] = $l_info['title'];
        }
    }
    $tool_content .= "\n<div class='form-wrapper'>\n    <form class='form-horizontal' role='form' method='post' name='createform' action='{$_SERVER['SCRIPT_NAME']}' onsubmit=\"return validateNodePickerForm() && checkrequired(this, 'title', 'prof_names');\">\n        <fieldset>\n            <div class='form-group'>\n                <label for='title' class='col-sm-2 control-label'>{$langTitle}:</label>\n                <div class='col-sm-10'>\n                  <input name='title' id='title' type='text' class='form-control' id='exerciseTitle' value='" . q($title) . "' placeholder='{$langTitle}'>\n                </div>\n            </div>\n            <div class='form-group'>\n                <label for='dialog-set-value' class='col-sm-2 control-label'>{$langFaculty}:</label>\n                <div class='col-sm-10'>\n                  {$html}\n                </div>\n            </div>\n            <div class='form-group'>\n                <label for='prof_names' class='col-sm-2 control-label'>{$langTeachers}:</label>\n                <div class='col-sm-10'>\n                      <input class='form-control' type='text' name='prof_names' id='prof_names' value='" . q($prof_names) . "'>\n                </div>\n            </div>\n            <div class='form-group'>\n                <label for='localize' class='col-sm-2 control-label'>{$langLanguage}:</label>\n                <div class='col-sm-10'>\n                      " . lang_select_options('localize', "class='form-control'") . "\n                </div>\n            </div>\n            <div class='form-group'>\n                <label for='description' class='col-sm-2 control-label'>{$langDescrInfo} <small>{$langOptional}</small>:</label>\n                <div class='col-sm-10'>\n                      " . rich_text_editor('description', 4, 20, @$description) . "\n                </div>\n            </div>\n            <div class='form-group'>\n                <label class='col-sm-2 control-label'>{$langCourseFormat}:</label>\n                <div class='col-sm-10'>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='view_type' value='simple' id='simple'>\n                        {$langCourseSimpleFormat}\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='view_type' value='units' id='units' checked>\n                        {$langWithCourseUnits}\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='view_type' value='weekly' id='weekly'>\n                        {$langCourseWeeklyFormat}\n                      </label>\n                    </div>                         \n                </div>\n            </div>\n            <div class='form-group' id='weeklyDates'>\n                <div class='col-sm-10 col-sm-offset-2'>\n                      {$langStartDate} <input class='dateInForm form-control' type='text' name='start_date' value='' readonly>\n                </div>\n                <div class='col-sm-10 col-sm-offset-2'>\n                      {$langDuration} <input class='dateInForm form-control' type='text' name='finish_date' value='' readonly>\n                </div>                \n            </div>\n            <div class='form-group'>\n                <label class='col-sm-2 control-label'>{$langOpenCoursesLicense}:</label>\n                <div class='col-sm-10'>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='l_radio' value='0' checked>\n                        {$license[0]['title']}\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='l_radio' value='10'>\n                        {$license[10]['title']}\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input id='cc_license' type='radio' name='l_radio' value='cc'>\n                        {$langCMeta['course_license']}\n                      </label>\n                    </div>                         \n                </div>\n            </div>\n            <div class='form-group' id='cc'>\n                <div class='col-sm-10 col-sm-offset-2'>\n                      " . selection($cc_license, 'cc_use', "", 'class="form-control"') . "\n                </div>              \n            </div>\n            <div class='form-group'>\n                <label for='localize' class='col-sm-2 control-label'>{$langAvailableTypes}:</label>\n                <div class='col-sm-10'>\n                    <div class='radio'>\n                      <label>\n                        <input id='courseopen' type='radio' name='formvisible' value='2' checked>\n                        <img src='{$themeimg}/lock_open.png' alt='{$langOpenCourse}' title='{$langOpenCourse}' width='16'>&nbsp;{$langOpenCourse}\n                        <span class='help-block'><small>{$langPublic}</small></span>\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input id='coursewithregistration' type='radio' name='formvisible' value='1'>\n                        <img src='{$themeimg}/lock_registration.png' alt='{$m['legrestricted']}' title='{$m['legrestricted']}' width='16'>&nbsp;{$m['legrestricted']}\n                        <span class='help-block'><small>{$langPrivOpen}</small></span>\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input id='courseclose' type='radio' name='formvisible' value='0'>\n                        <img src='{$themeimg}/lock_closed.png' alt='{$langClosedCourse}' title='{$langClosedCourse}' width='16'>&nbsp;{$langClosedCourse}\n                        <span class='help-block'><small>{$langClosedCourseShort}</small></span>\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input id='courseinactive' type='radio' name='formvisible' value='3'>\n                        <img src='{$themeimg}/lock_inactive.png' alt='{$langInactiveCourse}' title='{$langInactiveCourse}' width='16'>&nbsp;{$langInactiveCourse}\n                        <span class='help-block'><small>{$langCourseInactiveShort}</small></span>\n                      </label>\n                    </div>                   \n                </div>\n                <div class='form-group'>\n                    <label for='coursepassword' class='col-sm-2 control-label'>{$langOptPassword}:</label>\n                    <div class='col-sm-10'>\n                          <input class='form-control' id='coursepassword' type='text' name='password' value='" . @q($password) . "' class='FormData_InputText' autocomplete='off'>\n                    </div>\n                </div>\n                <div class='form-group'>\n                    <div class='col-sm-10 col-sm-offset-2'>\n                          <input class='btn btn-primary' type='submit' name='create_course' value='" . q($langCourseCreate) . "'>\n                          <a href='{$urlServer}main/portfolio.php' class='btn btn-default'>{$langCancel}</a>\n                    </div>\n                </div>                 \n            </div>\n            <div class='text-right'><small>{$langFieldsOptionalNote}</small></div>\n        </fieldset>\n    </form>\n</div>";
} else {
    // create the course and the course database
    // validation in case it skipped JS validation
    $validationFailed = false;
    if (count($departments) < 1 || empty($departments[0])) {
        Session::Messages($langEmptyAddNode);
        $validationFailed = true;
    }