Exemplo n.º 1
0
    $tool_content .= action_bar(array(
        array(
            'title' => $langBack,
            'level' => 'primary-label',
            'icon' => 'fa-reply',
            'url' => "question_categories.php?course=$course_code"
        )
    ));
    $tool_content .= "
        <div class='form-wrapper'>
            <form class='form-horizontal' role='form' action='$form_action_url' method='post'>
                <div class='form-group ".(Session::getError('questionCatName') ? "has-error" : "")."'>
                    <label for='questionCatName' class='col-sm-2 control-label'>$langTitle:</label>
                    <div class='col-sm-10'>
                      <input name='questionCatName' type='text' class='form-control' id='questionCatName' placeholder='$langTitle' value='$questionCatName'>
                      <span class='help-block'>".Session::getError('questionCatName')."</span>
                    </div>
                </div>
                <div class='form-group'>
                    <div class='col-sm-10 col-sm-offset-2'>
                        <input class='btn btn-primary' name='submitCat' type='submit' value='$langSubmit'>
                        <a href='question_categories.php?course=$course_code' class='btn btn-default'>$langCancel</a>
                    </div>
                </div>                
            </form>
        </div>";
} elseif (isset($_GET['deleteCat'])) {
    $q_cat_id = $_GET['deleteCat'];
    if (Database::get()->query("DELETE FROM exercise_question_cats WHERE question_cat_id = ?d AND course_id = ?d", $q_cat_id, $course_id)->affectedRows > 0) { 
        Database::get()->query("UPDATE exercise_question SET category = ?d WHERE category = ?d AND course_id = ?d", 0, $q_cat_id, $course_id);
        Session::Messages($langDelCatSuccess, 'alert-success');
Exemplo n.º 2
0
function show_edit_assignment($id)
{
    global $tool_content, $m, $langEdit, $langBack, $course_code, $langCancel, $urlAppend, $works_url, $course_id, $head_content, $language, $langStudents, $langMove, $langWorkFile, $themeimg, $langDelWarnUserAssignment, $langLessOptions, $langMoreOptions, $langAutoJudgeInputNotSupported, $langAutoJudgeSum, $langAutoJudgeNewScenario, $langAutoJudgeEnable, $langAutoJudgeInput, $langAutoJudgeExpectedOutput, $langAutoJudgeOperator, $langAutoJudgeWeight, $langAutoJudgeProgrammingLanguage, $langAutoJudgeAssertions;
    load_js('bootstrap-datetimepicker');
    $head_content .= "<script type='text/javascript'>\n        \$(function() {\n            \$('#enddatepicker').datetimepicker({\n                format: 'dd-mm-yyyy hh:ii',\n                pickerPosition: 'bottom-left', language: '" . $language . "',\n                autoclose: true\n            });\n            \$('#hidden-opt-btn').on('click', function(e) {\n                e.preventDefault();\n                \$('#hidden-opt').collapse('toggle');\n            });\n            \$('#hidden-opt').on('shown.bs.collapse', function () {\n                \$('#hidden-opt-btn i').removeClass('fa-caret-down').addClass('fa-caret-up');\n                var caret = '<i class=\"fa fa-caret-up\"></i>';\n                \$('#hidden-opt-btn').html('{$langLessOptions} '+caret);\n            })\n            \$('#hidden-opt').on('hidden.bs.collapse', function () {\n                var caret = '<i class=\"fa fa-caret-down\"></i>';\n                \$('#hidden-opt-btn').html('{$langMoreOptions} '+caret);\n            })\n        });\n    </script>";
    $row = Database::get()->querySingle("SELECT * FROM assignment WHERE id = ?d", $id);
    if ($row->assign_to_specific) {
        //preparing options in select boxes for assigning to speficic users/groups
        $assignee_options = '';
        $unassigned_options = '';
        if ($row->group_submissions) {
            $assignees = Database::get()->queryArray("SELECT `group`.id AS id, `group`.name\n                                   FROM assignment_to_specific, `group`\n                                   WHERE `group`.id = assignment_to_specific.group_id AND assignment_to_specific.assignment_id = ?d", $id);
            $all_groups = Database::get()->queryArray("SELECT name,id FROM `group` WHERE course_id = ?d", $course_id);
            foreach ($assignees as $assignee_row) {
                $assignee_options .= "<option value='" . $assignee_row->id . "'>" . $assignee_row->name . "</option>";
            }
            $unassigned = array_udiff($all_groups, $assignees, function ($obj_a, $obj_b) {
                return $obj_a->id - $obj_b->id;
            });
            foreach ($unassigned as $unassigned_row) {
                $unassigned_options .= "<option value='{$unassigned_row->id}'>{$unassigned_row->name}</option>";
            }
        } else {
            $assignees = Database::get()->queryArray("SELECT user.id AS id, surname, givenname\n                                   FROM assignment_to_specific, user\n                                   WHERE user.id = assignment_to_specific.user_id AND assignment_to_specific.assignment_id = ?d", $id);
            $all_users = Database::get()->queryArray("SELECT user.id AS id, user.givenname, user.surname\n                                    FROM user, course_user\n                                    WHERE user.id = course_user.user_id\n                                    AND course_user.course_id = ?d AND course_user.status = 5\n                                    AND user.id", $course_id);
            foreach ($assignees as $assignee_row) {
                $assignee_options .= "<option value='{$assignee_row->id}'>{$assignee_row->surname} {$assignee_row->givenname}</option>";
            }
            $unassigned = array_udiff($all_users, $assignees, function ($obj_a, $obj_b) {
                return $obj_a->id - $obj_b->id;
            });
            foreach ($unassigned as $unassigned_row) {
                $unassigned_options .= "<option value='{$unassigned_row->id}'>{$unassigned_row->surname} {$unassigned_row->givenname}</option>";
            }
        }
    }
    if ((int) $row->deadline) {
        $deadline = date('d-m-Y H:i', strtotime($row->deadline));
    } else {
        $deadline = '';
    }
    $comments = trim($row->comments);
    $tool_content .= action_bar(array(array('title' => $langBack, 'level' => 'primary-label', 'url' => "{$_SERVER['PHP_SELF']}?course={$course_code}", 'icon' => 'fa-reply')));
    //Get possible validation errors
    $title_error = Session::getError('title');
    $max_grade_error = Session::getError('max_grade');
    $tool_content .= "\n    <div class='form-wrapper'>\n    <form class='form-horizontal' role='form' enctype='multipart/form-data' action='{$_SERVER['SCRIPT_NAME']}?course={$course_code}' method='post' onsubmit='return check_weights();'>\n    <input type='hidden' name='id' value='{$id}' />\n    <input type='hidden' name='choice' value='do_edit' />\n    <fieldset>\n            <div class='form-group " . ($title_error ? "has-error" : "") . "'>\n                <label for='title' class='col-sm-2 control-label'>{$m['title']}:</label>\n                <div class='col-sm-10'>\n                  <input name='title' type='text' class='form-control' id='title' value='" . q($row->title) . "' placeholder='{$m['title']}'>\n                  <span class='help-block'>{$title_error}</span>\n                </div>\n            </div>\n            <div class='form-group'>\n                <label for='desc' class='col-sm-2 control-label'>{$m['description']}:</label>\n                <div class='col-sm-10'>\n                " . rich_text_editor('desc', 4, 20, $row->description) . "\n                </div>\n            </div>";
    if (!empty($comments)) {
        $tool_content .= "<div class='form-group'>\n                <label for='desc' class='col-sm-2 control-label'>{$m['comments']}:</label>\n                <div class='col-sm-10'>\n                " . rich_text_editor('comments', 5, 65, $comments) . "\n                </div>\n            </div>";
    }
    $tool_content .= "\n            <div class='col-sm-10 col-sm-offset-2 margin-top-fat margin-bottom-fat'>\n                <a id='hidden-opt-btn' class='btn btn-success btn-xs' href='#' style='text-decoration:none;'>{$langMoreOptions} <i class='fa fa-caret-down'></i></a>\n            </div>\n            <div class='collapse " . (Session::hasErrors() ? "in" : "") . "' id='hidden-opt'>\n                <div class='form-group'>\n                    <label for='userfile' class='col-sm-2 control-label'>{$langWorkFile}:</label>\n                    <div class='col-sm-10'>\n                      " . ($row->file_name ? "<a href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;get={$row->id}&amp;file_type=1'>" . q($row->file_name) . "</a>" . "<a href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;id={$id}&amp;choice=do_delete_file' onClick='return confirmation(\"{$m['WorkDeleteAssignmentFileConfirm']}\");'>\n                                     <img src='{$themeimg}/delete.png' title='{$m['WorkDeleteAssignmentFile']}' /></a>" : "<input type='file' id='userfile' name='userfile' />") . "\n                    </div>\n                </div>\n                <div class='form-group " . ($max_grade_error ? "has-error" : "") . "'>\n                    <label for='max_grade' class='col-sm-2 control-label'>{$m['max_grade']}:</label>\n                    <div class='col-sm-10'>\n                        <input name='max_grade' type='text' class='form-control' id='max_grade' value='{$row->max_grade}' placeholder='{$m['max_grade']}'>\n                        <span class='help-block'>{$max_grade_error}</span>\n                    </div>\n                </div>\n                <div class='form-group'>\n                    <label class='col-sm-2 control-label'>{$m['deadline']}:</label>\n                    <div class='col-sm-10'>\n                        <div class='radio'>\n                          <label>\n                            <input type='radio' name='is_deadline' value='0' " . (!empty($deadline) ? "" : "checked") . " onclick='\$(\"#enddatepicker, #late_sub_row\").addClass(\"hide\");\$(\"#deadline\").val(\"\");'>\n                            {$m['no_deadline']}\n                          </label>\n                        </div>\n                        <div class='radio'>\n                          <label>\n                            <input type='radio' name='is_deadline' value='1' " . (!empty($deadline) ? "checked" : "") . " onclick='\$(\"#enddatepicker, #late_sub_row\").removeClass(\"hide\")'>\n                            {$m['with_deadline']}\n                          </label>\n                        </div>\n                    </div>\n                </div>\n                <div class='input-append date form-group " . (!empty($deadline) ? "" : "hide") . "' id='enddatepicker' data-date='{$deadline}' data-date-format='dd-mm-yyyy'>\n                    <div class='col-xs-8 col-xs-offset-2'>\n                        <input class='form-control' name='WorkEnd' id='deadline' type='text' value='{$deadline}'>\n                    </div>\n                    <div class='col-xs-2'>\n                        <span class='add-on'><i class='fa fa-times'></i></span>\n                        <span class='add-on'><i class='fa fa-calendar'></i></span>\n                    </div>\n                    <div class='col-xs-10 col-xs-offset-2'>{$m['deadline_notif']}</div>\n                </div>\n                <div class='form-group " . (!empty($deadline) ? "" : "hide") . "' id='late_sub_row'>\n                    <div class='col-xs-10 col-xs-offset-2'>\n                        <div class='checkbox'>\n                          <label>\n                            <input type='checkbox' name='late_submission' value='1' " . ($row->late_submission ? 'checked' : '') . ">\n                            {$m['late_submission_enable']}\n                          </label>\n                        </div>\n                    </div>\n                </div>\n                <div class='form-group'>\n                    <label class='col-sm-2 control-label'>{$m['group_or_user']}:</label>\n                    <div class='col-sm-10'>\n                        <div class='radio'>\n                          <label>\n                            <input type='radio' id='user_button' name='group_submissions' value='0' " . ($row->group_submissions == 1 ? '' : 'checked') . ">\n                            {$m['user_work']}\n                          </label>\n                        </div>\n                        <div class='radio'>\n                          <label>\n                            <input type='radio' id='group_button' name='group_submissions' value='1' " . ($row->group_submissions == 1 ? 'checked' : '') . ">\n                            {$m['group_work']}\n                          </label>\n                        </div>\n                    </div>\n                </div>\n                <div class='form-group'>\n                    <label class='col-sm-2 control-label'>{$m['WorkAssignTo']}:</label>\n                    <div class='col-sm-10'>\n                        <div class='radio'>\n                          <label>\n                            <input type='radio' id='assign_button_all' name='assign_to_specific' value='0' " . ($row->assign_to_specific == 1 ? '' : 'checked') . ">\n                            <span id='assign_button_all_text'>{$m['WorkToAllUsers']}</span>\n                          </label>\n                        </div>\n                        <div class='radio'>\n                          <label>\n                            <input type='radio' id='assign_button_some' name='assign_to_specific' value='1' " . ($row->assign_to_specific == 1 ? 'checked' : '') . ">\n                            <span id='assign_button_some_text'>{$m['WorkToUser']}</span>\n                          </label>\n                        </div>\n                    </div>\n                </div>\n                <table id='assignees_tbl' class='table " . ($row->assign_to_specific == 1 ? '' : 'hide') . "'>\n                <tr class='title1'>\n                  <td id='assignees'>{$langStudents}</td>\n                  <td class='text-center'>{$langMove}</td>\n                  <td>{$m['WorkAssignTo']}</td>\n                </tr>\n                <tr>\n                  <td>\n                    <select id='assign_box' size='15' multiple>\n                    " . (isset($unassigned_options) ? $unassigned_options : '') . "\n                    </select>\n                  </td>\n                  <td class='text-center'>\n                    <input type='button' onClick=\"move('assign_box','assignee_box')\" value='   &gt;&gt;   ' /><br /><input type='button' onClick=\"move('assignee_box','assign_box')\" value='   &lt;&lt;   ' />\n                  </td>\n                  <td width='40%'>\n                    <select id='assignee_box' name='ingroup[]' size='15' multiple>\n                    " . (isset($assignee_options) ? $assignee_options : '') . "\n                    </select>\n                  </td>\n                </tr>\n                </table>";
    $auto_judge = $row->auto_judge;
    $lang = $row->lang;
    $tool_content .= "\n                <div class='form-group'>\n                    <label class='col-sm-2 control-label'>{$langAutoJudgeEnable}:</label>\n                    <div class='col-sm-10'>\n                        <div class='radio'><input type='checkbox' id='auto_judge' name='auto_judge' value='1' " . ($auto_judge == true ? "checked='1'" : '') . " /></div>\n                        <table>\n                            <thead>\n                                <tr>\n                                    <th>{$langAutoJudgeInput}</th>\n                                    <th>{$langAutoJudgeOperator}</th>\n                                    <th>{$langAutoJudgeExpectedOutput}</th>\n                                    <th>{$langAutoJudgeWeight}</th>\n                                    <th>" . $m['delete'] . "</th>\n                                </tr>\n                            </thead>\n                            <tbody>";
    $auto_judge_scenarios = $auto_judge == true ? unserialize($row->auto_judge_scenarios) : null;
    $connector = q(get_config('autojudge_connector'));
    $connector = new $connector();
    $rows = 0;
    $display = 'visible';
    if ($auto_judge_scenarios != null) {
        $scenariosCount = count($auto_judge_scenarios);
        foreach ($auto_judge_scenarios as $aajudge) {
            $tool_content .= "<tr>\n                                        <td><input type='text' value='" . htmlspecialchars($aajudge['input'], ENT_QUOTES) . "' name='auto_judge_scenarios[{$rows}][input]' " . ($connector->supportsInput() ? '' : 'readonly="readonly" placeholder="' . $langAutoJudgeInputNotSupported . '"') . " /></td>";
            $tool_content .= "<td>\n                                        <select name='auto_judge_scenarios[{$rows}][assertion]' class='auto_judge_assertion'>\n                                            <option value='eq'";
            if ($aajudge['assertion'] === 'eq') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['eq'] . "</option>\n                                            <option value='same'";
            if ($aajudge['assertion'] === 'same') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['same'] . "</option>\n                                            <option value='notEq'";
            if ($aajudge['assertion'] === 'notEq') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['notEq'] . "</option>\n                                            <option value='notSame'";
            if ($aajudge['assertion'] === 'notSame') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['notSame'] . "</option>\n                                            <option value='integer'";
            if ($aajudge['assertion'] === 'integer') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['integer'] . "</option>\n                                            <option value='float'";
            if ($aajudge['assertion'] === 'float') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['float'] . "</option>\n                                            <option value='digit'";
            if ($aajudge['assertion'] === 'digit') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['digit'] . "</option>\n                                            <option value='boolean'";
            if ($aajudge['assertion'] === 'boolean') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['boolean'] . "</option>\n                                            <option value='notEmpty'";
            if ($aajudge['assertion'] === 'notEmpty') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['notEmpty'] . "</option>\n                                            <option value='notNull'";
            if ($aajudge['assertion'] === 'notNull') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['notNull'] . "</option>\n                                            <option value='string'";
            if ($aajudge['assertion'] === 'string') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['string'] . "</option>\n                                            <option value='startsWith'";
            if ($aajudge['assertion'] === 'startsWith') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['startsWith'] . "</option>\n                                            <option value='endsWith'";
            if ($aajudge['assertion'] === 'endsWith') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['endsWith'] . "</option>\n                                            <option value='contains'";
            if ($aajudge['assertion'] === 'contains') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['contains'] . "</option>\n                                            <option value='numeric'";
            if ($aajudge['assertion'] === 'numeric') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['numeric'] . "</option>\n                                            <option value='isArray'";
            if ($aajudge['assertion'] === 'isArray') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['isArray'] . "</option>\n                                            <option value='true'";
            if ($aajudge['assertion'] === 'true') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['true'] . "</option>\n                                            <option value='false'";
            if ($aajudge['assertion'] === 'false') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['false'] . "</option>\n                                            <option value='isJsonString'";
            if ($aajudge['assertion'] === 'isJsonString') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['isJsonString'] . "</option>\n                                            <option value='isObject'";
            if ($aajudge['assertion'] === 'isObject') {
                $tool_content .= " selected='selected'";
            }
            $tool_content .= ">" . $langAutoJudgeAssertions['isObject'] . "</option>\n                                        </select>\n                                    </td>";
            if (isset($aajudge['output'])) {
                $tool_content .= "<td><input type='text' value='" . htmlspecialchars($aajudge['output'], ENT_QUOTES) . "' name='auto_judge_scenarios[{$rows}][output]' class='auto_judge_output' /></td>";
            } else {
                $tool_content .= "<td><input type='text' value='' name='auto_judge_scenarios[{$rows}][output]' disabled='disabled' class='auto_judge_output' /></td>";
            }
            $tool_content .= "<td><input type='text' value='{$aajudge['weight']}' name='auto_judge_scenarios[{$rows}][weight]' class='auto_judge_weight'/></td>\n                                        <td><a href='#' class='autojudge_remove_scenario' style='display: " . ($rows <= 0 ? 'none' : 'visible') . ";'>X</a></td>\n                                    </tr>";
            $rows++;
        }
    } else {
        $tool_content .= "<tr>\n                                            <td><input type='text' name='auto_judge_scenarios[{$rows}][input]' /></td>\n                                            <td>\n                                                <select name='auto_judge_scenarios[{$rows}][assertion]' class='auto_judge_assertion'>\n                                                    <option value='eq' selected='selected'>" . $langAutoJudgeAssertions['eq'] . "</option>\n                                                    <option value='same'>" . $langAutoJudgeAssertions['same'] . "</option>\n                                                    <option value='notEq'>" . $langAutoJudgeAssertions['notEq'] . "</option>\n                                                    <option value='notSame'>" . $langAutoJudgeAssertions['notSame'] . "</option>\n                                                    <option value='integer'>" . $langAutoJudgeAssertions['integer'] . "</option>\n                                                    <option value='float'>" . $langAutoJudgeAssertions['float'] . "</option>\n                                                    <option value='digit'>" . $langAutoJudgeAssertions['digit'] . "</option>\n                                                    <option value='boolean'>" . $langAutoJudgeAssertions['boolean'] . "</option>\n                                                    <option value='notEmpty'>" . $langAutoJudgeAssertions['notEmpty'] . "</option>\n                                                    <option value='notNull'>" . $langAutoJudgeAssertions['notNull'] . "</option>\n                                                    <option value='string'>" . $langAutoJudgeAssertions['string'] . "</option>\n                                                    <option value='startsWith'>" . $langAutoJudgeAssertions['startsWith'] . "</option>\n                                                    <option value='endsWith'>" . $langAutoJudgeAssertions['endsWith'] . "</option>\n                                                    <option value='contains'>" . $langAutoJudgeAssertions['contains'] . "</option>\n                                                    <option value='numeric'>" . $langAutoJudgeAssertions['numeric'] . "</option>\n                                                    <option value='isArray'>" . $langAutoJudgeAssertions['isArray'] . "</option>\n                                                    <option value='true'>" . $langAutoJudgeAssertions['true'] . "</option>\n                                                    <option value='false'>" . $langAutoJudgeAssertions['false'] . "</option>\n                                                    <option value='isJsonString'>" . $langAutoJudgeAssertions['isJsonString'] . "</option>\n                                                    <option value='isObject'>" . $langAutoJudgeAssertions['isObject'] . "</option>\n                                                </select>\n                                            </td>\n                                            <td><input type='text' name='auto_judge_scenarios[{$rows}][output]' class='auto_judge_output' /></td>\n                                            <td><input type='text' name='auto_judge_scenarios[{$rows}][weight]' class='auto_judge_weight'/></td>\n                                            <td><a href='#' class='autojudge_remove_scenario' style='display: none;'>X</a></td>\n                                        </tr>\n                                ";
    }
    $tool_content .= "<tr>\n                                <td> </td>\n                                <td> </td>\n                                <td> </td>\n                                <td style='text-align:center;'> {$langAutoJudgeSum}: <span id='weights-sum'>0</span></td>\n                                <td> <input type='submit' value='{$langAutoJudgeNewScenario}' id='autojudge_new_scenario' /></td>\n                            </tr>\n                            </tbody>\n                        </table>\n                    </div>\n                </div>\n                <div class='form-group'>\n                  <label class='col-sm-2 control-label'>{$langAutoJudgeProgrammingLanguage}:</label>\n                  <div class='col-sm-10'>\n                    <select id='lang' name='lang'>";
    foreach ($connector->getSupportedLanguages() as $llang => $ext) {
        $tool_content .= "<option value='{$llang}' " . ($llang === $lang ? "selected='selected'" : "") . ">{$llang}</option>\n";
    }
    $tool_content .= "</select>\n                  </div>\n                </div>\n            </div>\n            <div class='col-sm-offset-2 col-sm-10'>\n                <input type='submit' class='btn btn-primary' name='do_edit' value='{$langEdit}' onclick=\"selectAll('assignee_box',true)\" />\n                <a href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}' class='btn btn-default'>{$langCancel}</a>\n            </div>\n    </fieldset>\n    </form></div>";
}
Exemplo n.º 3
0
/**
 * Generate html code of Wiki properties edit form
 * @param int wikiId ID of the wiki
 * @param string title wiki tile
 * @param string desc wiki description
 * @param int groupId id of the group the wiki belongs to
 *      (0 for a course wiki)
 * @param array acl wiki access control list
 * @param string script callback script url
 * @return string html code of the wiki properties form
 */
function claro_disp_wiki_properties_form($wikiId = 0, $title = '', $desc = '', $groupId = 0, $acl = null, $script = null) {
    global $langWikiDescriptionForm, $langWikiDescriptionFormText, $langWikiTitle
    , $langWikiDescription, $langWikiAccessControl, $langWikiAccessControlText
    , $langWikiCourseMembers, $langWikiGroupMembers, $langWikiOtherUsers
    , $langWikiOtherUsersText, $langWikiReadPrivilege, $langWikiEditPrivilege
    , $langWikiCreatePrivilege, $langCancel, $langSave, $langBack
    , $course_code;

    $title = ( $title != '' ) ? $title : '';

    $desc = ( $desc != '' ) ? $desc : '';

    if (is_null($acl) && $groupId == 0) {
        $acl = WikiAccessControl::defaultCourseWikiACL();
    } elseif (is_null($acl) && $groupId != 0) {
        $acl = WikiAccessControl::defaultGroupWikiACL();
    }

    // process ACL
    $group_read_checked = ( $acl['group_read'] == true ) ? ' checked="checked"' : '';
    $group_edit_checked = ( $acl['group_edit'] == true ) ? ' checked="checked"' : '';
    $group_create_checked = ( $acl['group_create'] == true ) ? ' checked="checked"' : '';
    $course_read_checked = ( $acl['course_read'] == true ) ? ' checked="checked"' : '';
    $course_edit_checked = ( $acl['course_edit'] == true ) ? ' checked="checked"' : '';
    $course_create_checked = ( $acl['course_create'] == true ) ? ' checked="checked"' : '';
    $other_read_checked = ( $acl['other_read'] == true ) ? ' checked="checked"' : '';
    $other_edit_checked = ( $acl['other_edit'] == true ) ? ' checked="checked"' : '';
    $other_create_checked = ( $acl['other_create'] == true ) ? ' checked="checked"' : '';

    $script = ( is_null($script) ) ? $_SERVER['SCRIPT_NAME'] . "?course=$course_code" : $script;

    $form = action_bar(array(
        array('title' => $langBack,
              'url' => "$_SERVER[SCRIPT_NAME]'?course=$course_code",
              'icon' => 'fa-reply',
              'level' => 'primary-label',)
    ));
                
    $form .= "<div class='form-wrapper'>
                <form class='form-horizontal' role='form' method='POST' id='wikiProperties' action='$script'>
                    <fieldset>
                        <input type='hidden' name='wikiId' value='$wikiId'>
                        <!-- groupId = 0 if course wiki, != 0 if group_wiki  -->
                        <input type='hidden' name='gid' value='$groupId'>                             
                        <div class='form-group".(Session::getError('title') ? " has-error" : "")."'>
                            <label for='title' class='col-sm-2 control-label'>$langWikiTitle:</label>
                            <div class='col-sm-10'>
                                <input name='title' type='text' class='form-control' id='wikiTitle' value='".q($title) ."' placeholder='$langWikiTitle'>
                                <span class='help-block'>".Session::getError('title')."</span>    
                            </div>
                        </div>
                        <div class='form-group'>
                            <label for='wikiDesc' class='col-sm-2 control-label'>".$langWikiDescription.":</label>
                            <div class='col-sm-10'>
                                <textarea class='form-control' id='wikiDesc' name='desc'>" . q($desc) . "</textarea>";

// atkyritsis
// hardwiring
    if ($groupId == 0) {
        $form .= "
                <input type='hidden' name='acl[course_read]' value='on'>
                <input type='hidden' name='acl[course_edit]' value='on'>
                <input type='hidden' name='acl[course_create]' value='on'>
                <input type='hidden' name='acl[other_read]' value='on'>
                <input type='hidden' name='acl[other_edit]' value='off'>
                <input type='hidden' name='acl[other_create]' value='off'>";
    } else {//default values for group wikis
        $form .= "
                <input type='hidden' name='acl[group_read]' value='on'>
                <input type='hidden' name='acl[group_edit]' value='on'>
                <input type='hidden' name='acl[group_create]' value='on'>
                <input type='hidden' name='acl[course_read]' value='on'>
                <input type='hidden' name='acl[course_edit]' value='off'>
                <input type='hidden' name='acl[course_create]' value='off'>
                <input type='hidden' name='acl[other_read]' value='off'>
                <input type='hidden' name='acl[other_edit]' value='off'>
                <input type='hidden' name='acl[other_create]' value='off'>";
    }

// hardwiring over

    $form .= "                  </div>
                            </div>
                            <div class='form-group'>
                                <div class='col-sm-10 col-sm-offset-2'>
                                    <input class='btn btn-primary' type='submit' name='action[exEdit]' value='$langSave'>
                                    <a class='btn btn-default' href='$_SERVER[SCRIPT_NAME]?course=$course_code'>$langCancel</a>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>";

    return $form;
}
Exemplo n.º 4
0
function formGroup($name, $label, $input) {
    global $tool_content;
    if (Session::hasError($name)) {
        $form_class = 'form-group has-error';
        $help_block = '<span class="help-block">' . Session::getError($name) . '</span>';
    } else {
        $form_class = 'form-group';
        $help_block = '';
    }
    $tool_content .= "
      <div class='$form_class'>
        <label for='$name' class='col-sm-2 control-label'>" . q($label) . ":</label>
        <div class='col-sm-10'>$input$help_block</div>
      </div>";
}
Exemplo n.º 5
0
            redirect_to_home_page("modules/questionnaire/admin.php?course={$course_code}&pid={$pid}");
        }
        $pageName = $question->question_text;
        $navigation[] = array('url' => "admin.php?course={$course_code}&amp;pid={$pid}&amp;editQuestion={$question->pqid}", 'name' => $langPollManagement);
    } else {
        $pageName = $langNewQu;
    }
    $action_url = "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;pid={$pid}" . (isset($_GET['modifyQuestion']) ? "&amp;modifyQuestion={$question->pqid}" : "&amp;newQuestion=yes");
    $action_url .= isset($_GET['questionType']) ? '&amp;questionType=label' : '';
    $tool_content .= action_bar(array(array('title' => $langBack, 'level' => 'primary-label', 'url' => "admin.php?course={$course_code}&pid={$pid}" . (isset($_GET['modifyQuestion']) ? "&editQuestion=" . $_GET['modifyQuestion'] : ""), 'icon' => 'fa-reply')));
    $questionName = Session::has('questionName') ? Session::get('questionName') : (isset($question) ? $question->question_text : '');
    $questionNameError = Session::getError('questionName');
    $questionNameErrorClass = $questionNameError ? "has-error" : "";
    $answerType = Session::has('answerType') ? Session::get('answerType') : (isset($question) ? $question->qtype : '');
    $questionScale = Session::has('questionScale') ? Session::get('questionScale') : (isset($question) ? $question->q_scale : 5);
    $questionScaleError = Session::getError('questionScale');
    $questionScaleErrorClass = $questionScaleError ? " has-error" : "";
    $questionScaleShowHide = $answerType == QTYPE_SCALE ? "" : " hidden";
    $tool_content .= "<div class='form-wrapper'><form class='form-horizontal' role='form' action='{$action_url}' method='post'>\r\n\t<fieldset>\r\n            <div class='form-group {$questionNameErrorClass}'>\r\n                <label for='questionName' class='col-sm-2 control-label'>" . (isset($_GET['questionType']) ? $langLabel : $langQuestion) . ":</label>\r\n                <div class='col-sm-10'>\r\n                  " . (isset($_GET['questionType']) || isset($question) && $question->qtype == QTYPE_LABEL ? rich_text_editor('questionName', 10, 10, $questionName) : "<input type='text' class='form-control' id='questionName' name='questionName' value='" . q($questionName) . "'>") . "\r\n                  <span class='help-block'>{$questionNameError}</span>    \r\n                </div>\r\n            </div>";
    if (isset($_GET['questionType']) || isset($question) && $question->qtype == QTYPE_LABEL) {
        $tool_content .= "<input type='hidden' name='answerType' value='" . QTYPE_LABEL . "'>";
    } else {
        $head_content .= "<script type='text/javascript'>\r\n        \$(function() {\r\n            \$('.answerType').change(function() {\r\n                if(\$(this).val()==5){\r\n                    \$('#questionScale').prop('disabled', false);\r\n                    \$('#questionScale').closest('div.form-group').removeClass('hidden');\r\n                } else {\r\n                    \$('#questionScale').prop('disabled', true);\r\n                    \$('#questionScale').closest('div.form-group').addClass('hidden');\r\n                }\r\n            });        \r\n        });\r\n        </script>";
        $tool_content .= "\r\n            <div class='form-group'>\r\n                <label for='answerType' class='col-sm-2 control-label'>{$langExerciseType}:</label>\r\n                <div class='col-sm-10'>            \r\n                    <div class='radio'>\r\n                      <label>\r\n                        <input type='radio' name='answerType' class='answerType' value='1' value='" . QTYPE_SINGLE . "' " . ($answerType == QTYPE_SINGLE || !isset($question) ? 'checked' : '') . ">\r\n                        " . $aType[QTYPE_SINGLE - 1] . "\r\n                      </label>\r\n                    </div>\r\n                    <div class='radio'>\r\n                      <label>\r\n                        <input type='radio' name='answerType' class='answerType' value='" . QTYPE_MULTIPLE . "' " . ($answerType == QTYPE_MULTIPLE ? 'checked' : '') . ">\r\n                        " . $aType[QTYPE_MULTIPLE - 1] . "\r\n                      </label>\r\n                    </div>\r\n                    <div class='radio'>\r\n                      <label>\r\n                        <input type='radio' name='answerType' class='answerType' value='" . QTYPE_FILL . "' " . ($answerType == QTYPE_FILL ? 'checked' : '') . ">\r\n                        " . $aType[QTYPE_FILL - 1] . "\r\n                      </label>\r\n                    </div>\r\n                    <div class='radio'>\r\n                      <label>\r\n                        <input type='radio' name='answerType' class='answerType' value='" . QTYPE_SCALE . "' " . ($answerType == QTYPE_SCALE ? 'checked' : '') . ">\r\n                        " . $aType[QTYPE_SCALE - 1] . "\r\n                      </label>\r\n                    </div>                    \r\n                </div>              \r\n            </div>\r\n            <div class='form-group{$questionScaleErrorClass}{$questionScaleShowHide}'>\r\n                <label for='questionName' class='col-sm-2 control-label'>{$langMax} {$langScale} (1-..):</label>\r\n                <div class='col-sm-10 col-md-3'>\r\n                    <input type='text' class='form-control' name='questionScale' id='questionScale' value='" . q($questionScale) . "'>\r\n                    <span class='help-block'>{$questionScaleError}</span>                    \r\n                </div>\r\n            </div>";
    }
    $tool_content .= "\r\n            <div class='col-md-10 col-md-offset-2'>\r\n                <input type='submit' class='btn btn-primary' name='submitQuestion' value='" . (isset($_GET['newQuestion']) ? $langCreate : $langModify) . "'>\r\n                <a href='admin.php?course={$course_code}&pid={$pid}" . (isset($_GET['modifyQuestion']) ? "&editQuestion=" . $_GET['modifyQuestion'] : "") . "' class='btn btn-default'>{$langCancel}</a>\r\n            </div>\r\n        </fieldset>\r\n    </form></div>";
    //Modify Answers
} elseif (isset($_GET['modifyAnswers'])) {
    $head_content .= "\r\n    <script>\r\n        \$(function() {\r\n            \$(poll_init);\r\n        });\r\n    </script>\r\n    ";
    $question_id = $_GET['modifyAnswers'];
    $question = Database::get()->querySingle('SELECT * FROM poll_question WHERE pid = ?d AND pqid = ?d', $pid, $question_id);
Exemplo n.º 6
0
	
	elseif (isset($_GET['editcategory'])) {
	   $id = $_GET['id'];
	   //$tool_content .= "<input type='hidden' name='id' value='" . getIndirectReference($id) . "' />";
       category_form_defaults($id);
	   $myrow = Database::get()->querySingle("SELECT name,description  FROM group_category WHERE course_id = ?d AND id = ?d", $course_id, $id);
       $form_legend = $langCategoryMod;
	   //$navigation[] = array('url' => "$_SERVER[SCRIPT_NAME]?course=$course_code", 'name' => $langGroups);
	   $tool_content .= "<div class = 'form-wrapper'>";
	   $tool_content .= "<form class = 'form-horizontal' role='form' method='post' action='index.php?course=$course_code&amp;editcategory=1' onsubmit=\"return checkrequired(this, 'categoryname');\">";
	   $tool_content .= "<fieldset>
                        <div class='form-group".(Session::getError('categoryname') ? " has-error" : "")."'>
                            <label for='CatName' class='col-sm-2 control-label'>$langCategoryName:</label>
                            <div class='col-sm-10'>
                                <input class='form-control' type='text' name='categoryname' size='53' placeholder='$langCategoryName' $form_name>
								<span class='help-block'>".Session::getError('categoryname')."</span>
                            </div>
                        </div>
                        <div class='form-group'>
                            <label for='CatDesc' class='col-sm-2 control-label'>$langDescription:</label>
                            <div class='col-sm-10'>
                                <textarea class='form-control' rows='5' name='description'>$form_description</textarea>
                            </div>
                        </div>
						<input type='hidden' name='id' value='" . getIndirectReference($id) . "' />
                        <div class='form-group'>
                            <div class='col-sm-10 col-sm-offset-2'>
                                <input type='submit' class='btn btn-primary' name='submitCategory' value='$form_legend' />
                                <a href='index.php?course=$course_code' class='btn btn-default'>$langCancel</a>
                            </div>
                        </div>
Exemplo n.º 7
0
         'icon' => 'fa-reply',
         'url' => "grading_scales.php?course=$course_code"
     ),
 ));
 $tool_content .= "
     <div class='row'>
         <div class='col-sm-12'>
             <div class='form-wrapper'>
                 <form class='form-horizontal' role='form' data-toggle='validator' method='post' action='$_SERVER[SCRIPT_NAME]?course=$course_code' id='scales_form'>
                 <fieldset>
                     $hidden_input
                     <div class='form-group".(Session::getError('title') ? " has-error" : "")."'>
                         <label for='title' class='col-sm-2 control-label'>$langTitle:</label>
                         <div class='col-sm-10'>
                           <input name='title' type='text' class='form-control' id='title' value='$title'".($scale_used ? " disabled" : "").">
                           ".(Session::getError('title') ? "<span class='help-block'>" . Session::getError('title') . "</span>" : "")."
                         </div>
                     </div>
                     <div class='form-group'>
                         <label class='col-sm-2 control-label'>$langScales:</label>
                         <div class='col-sm-10'>
                             <div class='table-responsive'>
                                 <table class='table-default' id='scale_table'>
                                     <thead>
                                         <tr>
                                             <th style='width:47%'>$langWording</th>
                                             <th style='width:47%'>$langValue</th>
                                             ".(!$scale_used ? "<th class='text-center option-btn-cell'  style='width:5%'>".icon('fa-gears')."</th>" : "")."
                                         </tr>
                                     </thead>
                                     <tbody>
Exemplo n.º 8
0
        $endDateTime_obj = new DateTime();
        $endDateTime_obj->add(new DateInterval('P1Y'));
        $exerciseEndDate = $endDateTime_obj->format('d-m-Y H:i');
    } else {
        $endDateTime_obj = DateTime::createFromFormat('Y-m-d H:i:s', $objExercise->selectEndDate());
        $exerciseEndDate = $endDateTime_obj->format('d-m-Y H:i');
    }
    $exerciseTempSave = $objExercise->selectTempSave();
    $exerciseTimeConstraint = $objExercise->selectTimeConstraint();
    $exerciseAttemptsAllowed = $objExercise->selectAttemptsAllowed();
    $randomQuestions = $objExercise->isRandom();
    $displayResults = $objExercise->selectResults();
    $displayScore = $objExercise->selectScore();
}
// shows the form to modify the exercise
if (isset($_GET['modifyExercise']) or isset($_GET['NewExercise'])) {
    load_js('bootstrap-datetimepicker');
    $head_content .= "<script type='text/javascript'>\n        \$(function() {\n            \$('#startdatepicker, #enddatepicker').datetimepicker({\n                format: 'dd-mm-yyyy hh:ii', \n                pickerPosition: 'bottom-left', \n                language: '" . $language . "',\n                autoclose: true    \n            });\n            \$('.questionDrawnRadio').change(function() {\n                if(\$(this).val()==0){\n                    \$('#questionDrawnInput').val(''); \n                    \$('#questionDrawnInput').prop('disabled', true);\n                    \$('#questionDrawnInput').closest('div.form-group').addClass('hidden');\n                } else {\n                    \$('#questionDrawnInput').prop('disabled', true);\n                    \$('#questionDrawnInput').closest('div.form-group').removeClass('hidden');\n                }\n            });            \n            \$('#randomDrawnSubset').change(function() {\n                if(\$(this).prop('checked')){                   \n                    \$('#questionDrawnInput').prop('disabled', false);   \n                    \$('.questionDrawnRadio').prop('disabled', true); \n                } else {\n                    \$('#questionDrawnInput').prop('disabled', true);\n                    \$('.questionDrawnRadio').prop('disabled', false); \n                }\n            });\n        });\n    </script>";
    $tool_content .= action_bar(array(array('title' => $langBack, 'url' => $exerciseId ? "admin.php?course={$course_code}&exerciseId={$exerciseId}" : "index.php?course={$course_code}", 'icon' => 'fa-reply', 'level' => 'primary-label')));
    $tool_content .= "\n        <div class='form-wrapper'>\n            <form class='form-horizontal' role='form' method='post' action='{$_SERVER['SCRIPT_NAME']}?course={$course_code}" . (isset($_GET['modifyExercise']) ? "&amp;exerciseId={$exerciseId}" : "&amp;NewExercise=Yes") . "'>\n             <fieldset>       \n                 <div class='form-group " . (Session::getError('exerciseTitle') ? "has-error" : "") . "'>\n                   <label for='exerciseTitle' class='col-sm-2 control-label'>{$langExerciseName} :</label>\n                   <div class='col-sm-10'>\n                     <input name='exerciseTitle' type='text' class='form-control' id='exerciseTitle' value='" . q($exerciseTitle) . "' placeholder='{$langExerciseName}'>\n                     <span class='help-block'>" . Session::getError('exerciseTitle') . "</span>\n                   </div>\n                 </div>\n                 <div class='form-group'>\n                   <label for='exerciseDescription' class='col-sm-2 control-label'>{$langExerciseDescription}:</label>\n                   <div class='col-sm-10'>\n                   " . rich_text_editor('exerciseDescription', 4, 30, $exerciseDescription) . "\n                   </div>\n                 </div>\n                 <div class='form-group'>\n                     <label for='exerciseDescription' class='col-sm-2 control-label'>{$langExerciseType}:</label>\n                     <div class='col-sm-10'>            \n                         <div class='radio'>\n                           <label>\n                             <input type='radio' name='exerciseType' value='1' " . ($exerciseType <= 1 ? 'checked' : '') . ">\n                             {$langSimpleExercise}\n                           </label>\n                         </div>\n                         <div class='radio'>\n                           <label>\n                             <input type='radio' name='exerciseType' value='2' " . ($exerciseType >= 2 ? 'checked' : '') . ">\n                             {$langSequentialExercise}\n                           </label>\n                         </div>\n                     </div>\n                 </div>              \n                 <div class='input-append date form-group' id='startdatepicker' data-date='{$exerciseStartDate}' data-date-format='dd-mm-yyyy'>\n                     <label for='exerciseStartDate' class='col-sm-2 control-label'>{$langExerciseStart} :</label>\n                     <div class='col-xs-10 col-sm-9'>        \n                         <input class='form-control' name='exerciseStartDate' id='exerciseStartDate' type='text' value='{$exerciseStartDate}'>\n                     </div>\n                     <div class='col-xs-2 col-sm-1'>  \n                         <span class='add-on'><i class='fa fa-times'></i></span>\n                         <span class='add-on'><i class='fa fa-calendar'></i></span>\n                     </div>\n                 </div>            \n                 <div class='input-append date form-group' id='enddatepicker' data-date='{$exerciseEndDate}' data-date-format='dd-mm-yyyy'>\n                     <label for='exerciseEndDate' class='col-sm-2 control-label'>{$langExerciseEnd} :</label>\n                     <div class='col-xs-10 col-sm-9'>        \n                         <input class='form-control' name='exerciseEndDate' id='exerciseEndDate' type='text' value='{$exerciseEndDate}'>\n                     </div>\n                     <div class='col-xs-2 col-sm-1'>  \n                         <span class='add-on'><i class='fa fa-times'></i></span>\n                         <span class='add-on'><i class='fa fa-calendar'></i></span>\n                     </div>\n                 </div>\n                 <div class='form-group'>\n                     <label for='exerciseTempSave' class='col-sm-2 control-label'>{$langTemporarySave}:</label>\n                     <div class='col-sm-10'>            \n                         <div class='radio'>\n                           <label>\n                             <input type='radio' name='exerciseTempSave' value='0' " . ($exerciseTempSave == 0 ? 'checked' : '') . ">\n                             {$langDeactivate}\n                           </label>\n                         </div>\n                         <div class='radio'>\n                           <label>\n                             <input type='radio' name='exerciseTempSave' value='1' " . ($exerciseTempSave == 1 ? 'checked' : '') . ">\n                             {$langActivate}\n                           </label>\n                         </div>\n                     </div>\n                 </div>\n                 <div class='form-group " . (Session::getError('exerciseTimeConstraint') ? "has-error" : "") . "'>\n                   <label for='exerciseTimeConstraint' class='col-sm-2 control-label'>{$langExerciseConstrain}:</label>\n                   <div class='col-sm-10'>\n                     <input type='text' class='form-control' name='exerciseTimeConstraint' id='exerciseTimeConstraint' value='{$exerciseTimeConstraint}' placeholder='{$langExerciseConstrain}'>\n                     <span class='help-block'>" . (Session::getError('exerciseTimeConstraint') ? Session::getError('exerciseTimeConstraint') : "{$langExerciseConstrainUnit} ({$langExerciseConstrainExplanation})") . "</span>\n                   </div>\n                 </div>\n                 <div class='form-group " . (Session::getError('exerciseAttemptsAllowed') ? "has-error" : "") . "'>\n                   <label for='exerciseAttemptsAllowed' class='col-sm-2 control-label'>{$langExerciseAttemptsAllowed}:</label>\n                   <div class='col-sm-10'>\n                     <input type='text' class='form-control' name='exerciseAttemptsAllowed' id='exerciseAttemptsAllowed' value='{$exerciseAttemptsAllowed}' placeholder='{$langExerciseConstrain}'>\n                     <span class='help-block'>" . (Session::getError('exerciseAttemptsAllowed') ? Session::getError('exerciseAttemptsAllowed') : "{$langExerciseAttemptsAllowedUnit} ({$langExerciseAttemptsAllowedExplanation})") . "</span>\n                   </div>\n                 </div>\n                 <div class='form-group'>\n                     <label for='exerciseDescription' class='col-sm-2 control-label'>{$langRandomQuestions}:</label>\n                     <div class='col-sm-10'>            \n                         <div class='radio'>\n                           <label>\n                             <input type='radio' name='questionDrawn' class='questionDrawnRadio' value='0' " . ($randomQuestions == 0 ? 'checked' : '') . ($randomQuestions > 0 && $randomQuestions < 32767 ? ' disabled' : '') . ">\n                             {$langDeactivate}\n                           </label>\n                         </div>\n                         <div class='radio'>\n                           <label>\n                             <input type='radio' name='questionDrawn' class='questionDrawnRadio' value='32767'" . ($randomQuestions > 0 ? ' checked' : '') . ($randomQuestions > 0 && $randomQuestions < 32767 ? ' disabled' : '') . ">\n                             {$langActivate}\n                           </label>\n                         </div>\n                     </div>\n                 </div>                \n                 <div class='form-group " . ($randomQuestions > 0 ? '' : 'hidden') . "'>\n                    <div class='col-sm-5 col-sm-offset-2'>                 \n                        <input type='text' class='form-control' name='questionDrawn' id='questionDrawnInput' value='" . ($randomQuestions < 32767 ? $randomQuestions : null) . "'" . ($randomQuestions > 0 && $randomQuestions < 32767 ? '' : 'disabled') . ">\n                    </div>\n                    <div class='col-sm-5'>                 \n                        <div class='checkbox'>\n                          <label>\n                            <input id='randomDrawnSubset' value='1' type='checkbox' " . ($randomQuestions > 0 && $randomQuestions < 32767 ? 'checked' : '') . ">\n                            {$langFromRandomQuestions}\n                          </label>\n                        </div> \n                    </div>                   \n                 </div>                    \n                 <div class='form-group'>\n                     <label for='dispresults' class='col-sm-2 control-label'>{$langAnswers}:</label>\n                     <div class='col-sm-10'>            \n                         <div class='radio'>\n                           <label>\n                             <input type='radio' name='dispresults' value='1' " . ($displayResults == 1 ? 'checked' : '') . ">\n                             {$langAnswersDisp}\n                           </label>\n                         </div>\n                         <div class='radio'>\n                           <label>\n                             <input type='radio' name='dispresults' value='0' " . ($displayResults == 0 ? 'checked' : '') . ">\n                             {$langAnswersNotDisp}\n                           </label>\n                         </div>\n                     </div>\n                 </div>\n                 <div class='form-group'>\n                     <label for='dispresults' class='col-sm-2 control-label'>{$langScore}:</label>\n                     <div class='col-sm-10'>            \n                         <div class='radio'>\n                           <label>\n                             <input type='radio' name='dispscore' value='1' " . ($displayScore == 1 ? 'checked' : '') . ">\n                             {$langScoreDisp}\n                           </label>\n                         </div>\n                         <div class='radio'>\n                           <label>\n                             <input type='radio' name='dispscore' value='0' " . ($displayScore == 0 ? 'checked' : '') . ">\n                             {$langScoreNotDisp}\n                           </label>\n                         </div>\n                     </div>\n                 </div>\n                 <div class='form-group'>\n                   <div class='col-sm-offset-2 col-sm-10'>\n                     <input type='submit' class='btn btn-primary' name='submitExercise' value='" . (isset($_GET['NewExercise']) ? $langCreate : $langModify) . "'>\n                     <a href='" . ($exerciseId ? "admin.php?course={$course_code}&exerciseId={$exerciseId}" : "index.php?course={$course_code}") . "' class='btn btn-default'>{$langCancel}</a>    \n                   </div>\n                 </div>\n             </fieldset>\n             </form>\n        </div>";
} else {
    $disp_results_message = $displayResults == 1 ? $langAnswersDisp : $langAnswersNotDisp;
    $disp_score_message = $displayScore == 1 ? $langScoreDisp : $langScoreNotDisp;
    $exerciseDescription = standard_text_escape($exerciseDescription);
    $exerciseStartDate = nice_format(date("Y-m-d H:i", strtotime($exerciseStartDate)), true);
    $exerciseEndDate = nice_format(date("Y-m-d H:i", strtotime($exerciseEndDate)), true);
    $exerciseType = $exerciseType == 1 ? $langSimpleExercise : $langSequentialExercise;
    $exerciseTempSave = $exerciseTempSave == 1 ? $langActive : $langDeactivate;
    $tool_content .= action_bar(array(array('title' => $langBack, 'url' => "index.php?course={$course_code}", 'icon' => 'fa-reply', 'level' => 'primary-label')));
    $tool_content .= "\n    <div class='panel panel-primary'>\n        <div class='panel-heading'>\n            <h3 class='panel-title'>{$langInfoExercise} &nbsp;" . icon('fa-edit', $langModify, "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;exerciseId={$exerciseId}&amp;modifyExercise=yes") . "</h3>\n        </div>\n        <div class='panel-body'>\n            <div class='row  margin-bottom-fat'>\n                <div class='col-sm-3'>\n                    <strong>{$langExerciseName}:</strong>\n                </div>\n                <div class='col-sm-9'>\n                    {$exerciseTitle}\n                </div>                \n            </div>\n            <div class='row  margin-bottom-fat'>\n                <div class='col-sm-3'>\n                    <strong>{$langExerciseDescription}:</strong>\n                </div>\n                <div class='col-sm-9'>\n                    {$exerciseDescription}\n                </div>                \n            </div>\n            <div class='row  margin-bottom-fat'>\n                <div class='col-sm-3'>\n                    <strong>{$langExerciseType}:</strong>\n                </div>\n                <div class='col-sm-9'>\n                    {$exerciseType}\n                </div>                \n            </div>\n            <div class='row  margin-bottom-fat'>\n                <div class='col-sm-3'>\n                    <strong>{$langExerciseStart}:</strong>\n                </div>\n                <div class='col-sm-9'>\n                    {$exerciseStartDate}\n                </div>                \n            </div>\n            <div class='row  margin-bottom-fat'>\n                <div class='col-sm-3'>\n                    <strong>{$langExerciseEnd}:</strong>\n                </div>\n                <div class='col-sm-9'>\n                    {$exerciseEndDate}\n                </div>                \n            </div>  \n            <div class='row  margin-bottom-fat'>\n                <div class='col-sm-3'>\n                    <strong>{$langTemporarySave}:</strong>\n                </div>\n                <div class='col-sm-9'>\n                    {$exerciseTempSave}\n                </div>                \n            </div> \n            <div class='row  margin-bottom-fat'>\n                <div class='col-sm-3'>\n                    <strong>{$langExerciseConstrain}:</strong>\n                </div>\n                <div class='col-sm-9'>\n                    {$exerciseTimeConstraint} {$langExerciseConstrainUnit}\n                </div>                \n            </div>\n            <div class='row  margin-bottom-fat'>\n                <div class='col-sm-3'>\n                    <strong>{$langExerciseAttemptsAllowed}:</strong>\n                </div>\n                <div class='col-sm-9'>\n                    {$exerciseAttemptsAllowed} {$langExerciseAttemptsAllowedUnit}\n                </div>                \n            </div>\n            <div class='row  margin-bottom-fat'>\n                <div class='col-sm-3'>\n                    <strong>{$langRandomQuestions}:</strong>\n                </div>\n                <div class='col-sm-9'>\n                    {$langSelection} {$randomQuestions} {$langFromRandomQuestions}\n                </div>                \n            </div> \n            <div class='row  margin-bottom-fat'>\n                <div class='col-sm-3'>\n                    <strong>{$langAnswers}:</strong>\n                </div>\n                <div class='col-sm-9'>\n                    {$disp_results_message}\n                </div>                \n            </div>\n            <div class='row  margin-bottom-fat'>\n                <div class='col-sm-3'>\n                    <strong>{$langScore}:</strong>\n                </div>\n                <div class='col-sm-9'>\n                    {$disp_score_message}\n                </div>                \n            </div>              \n        </div>\n    </div>";
}
/**
 * Render custom profile fields in profile forms
 * @param array $context
 * @param boolean $valitron
 * @return string
 */
function render_profile_fields_form($context, $valitron = false) {
    global $langOptional, $langCompulsory;
    
    if ($context['origin'] == 'admin_edit_profile') { //admin editing users' profile
        $uid = $context['user_id'];
    } else {
        global $uid;
    }
    
    $return_string = "";
    
    $result = Database::get()->queryArray("SELECT id, name FROM custom_profile_fields_category ORDER BY sortorder DESC");
    
    foreach ($result as $c) {
        
        $args = array();
        $args[0] = $c->id;
        
        $registr = '';
        
        if ($context['origin'] == 'student_register') { //student registration form
            $registr = 'AND registration = ?d ';
            $args[] = 1;
            $args[] = CPF_USER_TYPE_PROF;
        } elseif ($context['origin'] == 'teacher_register') { //teacher registration form
            $registr = 'AND registration = ?d ';
            $args[] = 1;
            $args[] = CPF_USER_TYPE_STUD;
        } elseif ($context['origin'] == 'edit_profile') { //edit profile form
            if ($_SESSION['status'] == USER_TEACHER) {
                $args[] = CPF_USER_TYPE_STUD;
            } elseif ($_SESSION['status'] == USER_STUDENT) {
                $args[] = CPF_USER_TYPE_PROF;
            }
        } elseif ($context['origin'] == 'admin_edit_profile') { //admin edit user profile form
            $status = Database::get()->querySingle("SELECT status FROM user WHERE id = ?d", $uid)->status;
            if ($status == USER_TEACHER) {
                $args[] = CPF_USER_TYPE_STUD;
            } elseif ($status == USER_STUDENT) {
                $args[] = CPF_USER_TYPE_PROF;
            }
        }
        
        $res = Database::get()->queryArray("SELECT id, name, shortname, description, required, datatype, data 
                                            FROM custom_profile_fields WHERE categoryid = ?d ".$registr.
                                            "AND user_type <> ?d ORDER BY sortorder DESC", $args);
        
        if (count($res) > 0) {
            foreach ($res as $f) {
                
                if (isset($fdata)) {
                    unset($fdata);
                }
                
                if ($valitron) {
                    if (Session::hasError('cpf_'.$f->shortname)) {
                        $form_class = 'form-group has-error';
                        $help_block = '<span class="help-block">' . Session::getError('cpf_'.$f->shortname) . '</span>';
                    } else {
                        $form_class = 'form-group';
                        $help_block = '';
                    }
                } else {
                    $form_class = 'form-group';
                    $help_block = '';
                }
                $return_string .= '<div class="'.$form_class.'">';
                $return_string .= '<label class="col-sm-2 control-label" for="'.$f->shortname.'">'.q($f->name).'</label>';
                $return_string .= '<div class="col-sm-10">';
                
                //get data to prefill fields
                if ($context['origin'] == 'edit_profile' || $context['origin'] == 'admin_edit_profile') {
                    $data_res = Database::get()->querySingle("SELECT data FROM custom_profile_fields_data 
                                                          WHERE field_id = ?d AND user_id = ?d", $f->id, $uid);
                    if ($data_res) {
                        $fdata = $data_res->data;
                    }
                } elseif (isset($context['pending']) && $context['pending']) {
                    $data_res = Database::get()->querySingle("SELECT data FROM custom_profile_fields_data_pending
                                                          WHERE field_id = ?d AND user_request_id = ?d", $f->id, $context['user_request_id']);
                    if ($data_res) {
                        $fdata = $data_res->data;
                    }
                }
                
                if ($valitron) {
                    if (Session::has('cpf_'.$f->shortname)) {
                        $fdata = Session::get('cpf_'.$f->shortname);
                    }
                }
                
                $val = '';
                $placeholder = '';
                
                switch ($f->datatype) {
                    case CPF_TEXTBOX:
                        if (isset($fdata) && $fdata != '') {
                            $val = 'value="'.q($fdata).'"';
                        } elseif (isset($_REQUEST['cpf_'.$f->shortname]) && isset($_REQUEST['cpf_'.$f->shortname]) != '') {
                            $val = 'value="'.q($_REQUEST['cpf_'.$f->shortname]).'"';
                        }
                        if ($f->required == 0) {
                            $placeholder = 'placeholder="'.$langOptional.'"';
                        } else {
                            $placeholder = 'placeholder="'.$langCompulsory.'"';
                        }
                        $return_string .= '<input class="form-control" '.$val.' type="text" '.$placeholder.' name="cpf_'.$f->shortname.'">';
                        break;
                    case CPF_TEXTAREA:
                        if (isset($fdata) && $fdata != '') {
                            $val = $fdata;
                        } elseif (isset($_REQUEST['cpf_'.$f->shortname]) && isset($_REQUEST['cpf_'.$f->shortname]) != '') {
                            $val = $_REQUEST['cpf_'.$f->shortname];
                        }
                        $return_string .= rich_text_editor('cpf_'.$f->shortname, 8, 20, $val);
                        break;
                    case CPF_DATE:
                        if (isset($fdata) && $fdata != '') {
                            $val = 'value="'.q($fdata).'"';
                        } elseif (isset($_REQUEST['cpf_'.$f->shortname]) && isset($_REQUEST['cpf_'.$f->shortname]) != '') {
                            $val = 'value="'.q($_REQUEST['cpf_'.$f->shortname]).'"';
                        }
                        if ($f->required == 0) {
                            $placeholder = 'placeholder="'.$langOptional.'"';
                        } else {
                            $placeholder = 'placeholder="'.$langCompulsory.'"';
                        }
                        load_js('bootstrap-datepicker');
                        $return_string .= '<input class="form-control" '.$val.' type="text" '.$placeholder.' name="cpf_'.$f->shortname.'" data-provide="datepicker" data-date-format="dd-mm-yyyy">';
                        break;
                    case CPF_MENU:
                        if (isset($fdata) && $fdata != '') {
                            $def_selection = intval($fdata);
                        } elseif (isset($_REQUEST['cpf_'.$f->shortname]) && isset($_REQUEST['cpf_'.$f->shortname]) != '') {
                            $def_selection = intval($_REQUEST['cpf_'.$f->shortname]);
                        } else {
                            $def_selection = 0;
                        }
                        $options = unserialize($f->data);
                        $return_string .= selection($options, 'cpf_'.$f->shortname, $def_selection);
                        break;
                    case CPF_LINK:
                        if (isset($fdata) && $fdata != '') {
                            $val = 'value="'.q($fdata).'"';
                        } elseif (isset($_REQUEST['cpf_'.$f->shortname]) && isset($_REQUEST['cpf_'.$f->shortname]) != '') {
                            $val = 'value="'.q($_REQUEST['cpf_'.$f->shortname]).'"';
                        }
                        if ($f->required == 0) {
                            $placeholder = 'placeholder="'.$langOptional.'"';
                        } else {
                            $placeholder = 'placeholder="'.$langCompulsory.'"';
                        }
                        $return_string .= '<input class="form-control" '.$val.' type="text" '.$placeholder.' name="cpf_'.$f->shortname.'">';
                        break;
                }
                if (!empty($f->description)) {
                    $return_string .= '<small><em>'.standard_text_escape($f->description).'</em></small>';
                }
                $return_string .= $help_block.'</div></div>';
            }
        }
    }
    return $return_string;
}
Exemplo n.º 10
0
if ($editId !== false) {
    $tool_content .= "<input type='hidden' name='editId' value='" . getIndirectReference($editId) . "' />";
}
$tool_content .= "
                    <fieldset>
                        <div class='form-group'>
                            <label for='typSel' class='col-sm-2 control-label'>$langType:</label>
                            <div class='col-sm-10'>
                            " . selection($types, 'editType', $defaultType, 'class="form-control" id="typSel"') . "
                            </div>
                        </div>
                        <div class='form-group".(Session::getError('editTitle') ? " has-error" : "")."'>
                            <label for='titleSel' class='col-sm-2 control-label'>$langTitle:</label>
                            <div class='col-sm-10'>
                                <input type='text' name='editTitle' class='form-control' value='$cdtitle' size='40' id='titleSel'>
                                <span class='help-block'>".Session::getError('editTitle')."</span>                                    
                            </div>
                        </div>
                        <div class='form-group'>
                            <label for='editComments' class='col-sm-2 control-label'>$langContent:</label>
                            <div class='col-sm-10'>
                            " . @rich_text_editor('editComments', 4, 20, $comments) . "
                            </div>
                        </div>
                        <div class='form-group'>
                        <div class='col-sm-10 col-sm-offset-2'>".
                                form_buttons(array(
                                    array(
                                        'text'  =>  $langSave,
                                        'name'  =>  'saveCourseDescription',
                                        'value' =>  $langAdd
Exemplo n.º 11
0
/**
 * @brief dislay form for adding other activity in gradebook
 * @global type $tool_content
 * @global type $course_code
 * @global type $visible
 * @global type $langTitle
 * @global type $langGradebookActivityDate2
 * @global type $langGradebookActivityWeight
 * @global type $langGradeVisible
 * @global type $langComments
 * @global type $langGradebookInsAut
 * @global type $langAdd
 * @global type $langAdd
 * @global type $langType
 * @global type $langGradebookExams
 * @global type $langGradebookLabs
 * @global type $langGradebookOral
 * @global type $langGradebookProgress
 * @global type $langGradebookOtherType
 * @param type $gradebook_id
 */
function add_gradebook_other_activity($gradebook_id) {

    global $tool_content, $course_code, $visible,
           $langTitle, $langGradebookActivityDate2, $langGradebookActivityWeight,
           $langGradeVisible, $langComments, $langGradebookInsAut, $langAdd,
           $langAdd, $langType, $langGradebookExams, $langGradebookLabs,
           $langGradebookOral, $langGradebookProgress, $langGradebookOtherType,
           $langGradebookRemainingGrade, $langSave, $head_content, $language;
    
    load_js('bootstrap-datetimepicker');
    $head_content .= "
    <script type='text/javascript'>
    $(function() {
            $('#date').datetimepicker({    
                format: 'dd-mm-yyyy hh:ii', 
                pickerPosition: 'bottom-left', 
                language: '".$language."',
                autoclose: true 
            });
    });
    </script>";  
    
    $weight_error = Session::getError('weight'); 
    $date_error = Session::getError('date');  
    $tool_content .= "
    <div class='row'>
        <div class='col-sm-12'>
            <div class='form-wrapper'>
                <form class='form-horizontal' role='form' method='post' action='$_SERVER[SCRIPT_NAME]?course=$course_code&amp;gradebook_id=" . getIndirectReference($gradebook_id) . "'>
                    <fieldset>";
                        if (isset($_GET['modify'])) { // modify an existing gradebook activity
                            $id  = filter_var(getDirectReference($_GET['modify']), FILTER_VALIDATE_INT);
                            //All activity data (check if it's in this gradebook)
                            $modifyActivity = Database::get()->querySingle("SELECT * FROM gradebook_activities WHERE id = ?d AND gradebook_id = ?d", $id, $gradebook_id);
                            if ($modifyActivity) {
                                $titleToModify = $modifyActivity->title;
                                $contentToModify = $modifyActivity->description;
                                $date = Session::has('date') ? Session::get('date') : $modifyActivity->date;
                                $module_auto_id = $modifyActivity->module_auto_id;
                                $auto = $modifyActivity->auto;
                                $weight = Session::has('weight') ? Session::get('title') : $modifyActivity->weight;
                                $activity_type = $modifyActivity->activity_type;
                                $visible = $modifyActivity->visible;
                            } else {
                                $activity_type = '';
                            }
                            $gradebookActivityToModify = $id;
                        } else { //new activity
                            $gradebookActivityToModify = "";
                            $activity_type = "";
                            $date = date("Y-n-j", time());
                            $visible = 1;
                        }

                        if (!isset($contentToModify)) $contentToModify = "";
                        @$tool_content .= "
                        <div class='form-group'>
                            <label for='activity_type' class='col-sm-2 control-label'>$langType:</label>
                            <div class='col-sm-10'>
                                <select name='activity_type' class='form-control'>
                                    <option value=''  " . typeSelected($activity_type, '') . " >-</option>
                                    <option value='4' " . typeSelected($activity_type, 4) . " >" . $langGradebookExams . "</option>
                                    <option value='2' " . typeSelected($activity_type, 2) . " >" . $langGradebookLabs . "</option>
                                    <option value='1' " . typeSelected($activity_type, 1) . " >" . $langGradebookOral . "</option>
                                    <option value='3' " . typeSelected($activity_type, 3) . " >" . $langGradebookProgress . "</option>
                                    <option value='5' " . typeSelected($activity_type, 5) . " >" . $langGradebookOtherType . "</option>
                                </select>
                            </div>
                        </div>
                        <div class='form-group'>
                            <label for='actTitle' class='col-sm-2 control-label'>$langTitle:</label>
                            <div class='col-sm-10'>
                                <input type='text' class='form-control' name='actTitle' value='".q($titleToModify)."'/>
                            </div>
                        </div>
                        <div class='form-group".($date_error ? " has-error" : "")."'>
                            <label for='date' class='col-sm-2 control-label'>$langGradebookActivityDate2:</label>
                            <div class='col-sm-10'>
                                <input type='text' class='form-control' name='date' id='date' value='" . datetime_remove_seconds($date) . "'/>
                                <span class='help-block'>$date_error</span>
                            </div>
                        </div>
                        <div class='form-group".($weight_error ? " has-error" : "")."'>
                            <label for='weight' class='col-sm-2 control-label'>$langGradebookActivityWeight:</label>
                            <div class='col-sm-10'>
                                <input type='text' class='form-control' name='weight' value='$weight' size='5'>
                                <span class='help-block'>". ($weight_error ? $weight_error :  "($langGradebookRemainingGrade: " . weightleft($gradebook_id, '') . "%)")."</span>
                            </div>
                        </div>
                        <div class='form-group'>
                            <label for='visible' class='col-sm-2 control-label'>$langGradeVisible:</label>
                            <div class='col-sm-10'>
                                <input type='checkbox' id='visible' name='visible' value='1'";
                                if ($visible == 1) {
                                    $tool_content .= " checked";
                                }
                            $tool_content .= " /></div>
                        </div>
                        <div class='form-group'>
                            <label for='actDesc' class='col-sm-2 control-label'>$langComments:</label>
                            <div class='col-sm-10'>
                                " . rich_text_editor('actDesc', 4, 20, $contentToModify) . "
                            </div>
                        </div>";
                        if (isset($module_auto_id) && $module_auto_id != 0) { //accept the auto booking mechanism
                            $tool_content .= "<div class='form-group'>
                                <label for='weight' class='col-sm-2 control-label'>$langGradebookInsAut:</label>
                                    <div class='col-sm-10'><input type='checkbox' value='1' name='auto' ";
                            if ($auto) {
                                $tool_content .= " checked";
                            }
                            $tool_content .= "/></div></div>";
                        }
                        $tool_content .= "<div class='form-group'>
                                <div class='col-sm-10 col-sm-offset-2'>".form_buttons(array(
                                    array(
                                        'text' => $langSave,
                                        'name' => 'submitGradebookActivity',
                                        'value'=> $langAdd
                                    ),
                                    array(
                                        'href' => "$_SERVER[SCRIPT_NAME]?course=$course_code"
                                    )
                                ))."</div></div>";
                        if (isset($_GET['modify'])) {
                            $tool_content .= "<input type='hidden' name='id' value='" . getIndirectReference($gradebookActivityToModify) . "'>";
                        } else {
                            $tool_content .= " <input type='hidden' name='id' value='' >";
                        }
                    $tool_content .= "</fieldset>
                ". generate_csrf_token_form_field() ."
                </form>
            </div>
        </div>
    </div>";
}
Exemplo n.º 12
0
 <div class='form-group".(Session::getError('name') ? " has-error" : "")."'>
     <label class='col-sm-2 control-label'>$langGroupName:</label>
     <div class='col-sm-10'>
         <input class='form-control' type=text name='name' size='40' value='$tool_content_group_name'>
         <span class='help-block'>".Session::getError('name')."</span>
     </div>
 </div>
 <div class='form-group'>
   <label class='col-sm-2 control-label'>$langDescription $langOptional:</label>
   <div class='col-sm-10'><textarea class='form-control' name='description' rows='2' cols='60'>$tool_content_group_description</textarea></div>
 </div>
 <div class='form-group".(Session::getError('maxStudent') ? " has-error" : "")."'>
     <label class='col-sm-2 control-label'>$langMax $langGroupPlacesThis:</label>
     <div class='col-sm-10'>
         <input class='form-control' type=text name='maxStudent' size=2 value='$tool_content_max_student'>
         <span class='help-block'>".Session::getError('maxStudent')."</span>
     </div>
       
 </div>
 <div class='form-group'>
   <label class='col-sm-2 control-label'>$langGroupTutor:</label>
   <div class='col-sm-10'>
      $tool_content_tutor
   </div>
 </div>
 <div class='form-group'>
     <label class='col-sm-2 control-label'>$langGroupMembers:</label>
 <div class='col-sm-10'>
     <div class='table-responsive'>
         <table class='table-default'>
             <thead>
Exemplo n.º 13
0
/**
 * @brief insert/modify attendance settings
 * @global string $tool_content
 * @global type $course_code
 * @global type $langTitle
 * @global type $langSave
 * @global type $langAttendanceLimitNumber
 * @global type $langAttendanceUpdate
 * @global type $langSave
 * @global type $attendance_title
 * @param type $attendance_id
 */
function attendance_settings($attendance_id) {
    
    global $tool_content, $course_code, $language,
           $langTitle, $langSave, $langAttendanceLimitNumber,
           $langAttendanceUpdate, $langSave, $head_content,
           $attendance, $langStart, $langEnd;
    load_js('bootstrap-datetimepicker');
    $head_content .= "
    <script type='text/javascript'>
        $(function() {
            $('#start_date, #end_date').datetimepicker({
                format: 'dd-mm-yyyy hh:ii', 
                pickerPosition: 'bottom-left', 
                language: '".$language."',
                autoclose: true    
            });
        });
    </script>";
    $title_error = Session::getError('title');
    $title = Session::has('title') ? Session::get('title') : $attendance->title;
    $start_date_error = Session::getError('start_date');
    $start_date = Session::has('start_date') ? Session::get('start_date') : DateTime::createFromFormat('Y-m-d H:i:s', $attendance->start_date)->format('d-m-Y H:i');
    $end_date_error = Session::getError('end_date');
    $end_date = Session::has('end_date') ? Session::get('end_date') : DateTime::createFromFormat('Y-m-d H:i:s', $attendance->end_date)->format('d-m-Y H:i');     
    $limit_error  = Session::getError('limit');
    $limit = Session::has('limit') ? Session::get('limit') : get_attendance_limit($attendance_id);    
    // update attendance title
    $tool_content .= "<div class='row'>
        <div class='col-sm-12'>
            <div class='form-wrapper'>
                <form class='form-horizontal' role='form' method='post' action='$_SERVER[SCRIPT_NAME]?course=$course_code&attendance_id=$attendance_id'>
                    <div class='form-group".($title_error ? " has-error" : "")."'>
                        <label class='col-xs-12'>$langTitle</label>                           
                        <div class='col-xs-12'>
                            <input class='form-control' type='text' placeholder='$langTitle' name='title' value='$title'>
                            <span class='help-block'>$title_error</span>
                        </div>
                    </div>
                    <div class='form-group".($start_date_error ? " has-error" : "")."'>
                        <div class='col-xs-12'>
                            <label>$langStart</label>                      
                        </div>
                        <div class='col-xs-12'>
                            <input class='form-control' type='text' name='start_date' id='start_date' value='$start_date'>
                            <span class='help-block'>$start_date_error</span>
                        </div>
                    </div>
                    <div class='form-group".($end_date_error ? " has-error" : "")."'>
                        <div class='col-xs-12'>
                            <label>$langEnd</label>                      
                        </div>
                        <div class='col-xs-12'>
                            <input class='form-control' type='text' name='end_date' id='end_date' value='$end_date'>
                            <span class='help-block'>$end_date_error</span>
                        </div>
                    </div>                       
                    <div class='form-group".($limit_error ? " has-error" : "")."'>
                        <label class='col-xs-12'>$langAttendanceLimitNumber:</label>
                        <div class='col-sm-12'>
                            <input class='form-control' type='text' name='limit' value='$limit'/>
                            <span class='help-block'>$limit_error</span>
                        </div>
                    </div>                                        
                    <div class='form-group'>
                        <div class='col-xs-12'>".form_buttons(array(
                            array(
                                'text' => $langSave,
                                'name' => 'submitAttendanceBookSettings',
                                'value'=> $langAttendanceUpdate
                            ),
                            array(
                                'href' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;attendance_id=$attendance_id"
                            )
                        ))."</div>
                        </div>
                    </fieldset>
                </form>
            </div>
        </div>
    </div>";                            
}
Exemplo n.º 14
0
function show_edit_form($id, $sid, $assign) {
    global $m, $langGradeOk, $tool_content, $course_code, $langCancel,
           $langBack, $assign, $langWorkOnlineText, $course_id;
    $sub = Database::get()->querySingle("SELECT * FROM assignment_submit WHERE id = ?d",$sid);
    if (count($sub)>0) {
        $uid_2_name = display_user($sub->uid);
        if (!empty($sub->group_id)) {
            $group_submission = "($m[groupsubmit] $m[ofgroup] " .
                    "<a href='../group/group_space.php?course=$course_code&amp;group_id=$sub->group_id'>"
                     . gid_to_name($sub->group_id) . "</a>)";
        } else {
            $group_submission = '';
        }

        $grade = Session::has('grade') ? Session::get('grade') : $sub->grade;
        $comments = Session::has('comments') ? Session::get('comments') : q($sub->grade_comments);
        $email_status = !Session::has('email') ?: " checked";

        $pageName = $m['addgradecomments'];
        if($assign->submission_type){
            $submission = "
                    <div class='form-group'>
                        <label class='col-sm-3 control-label'>$langWorkOnlineText:</label>
                        <div class='col-sm-9'>
                            $sub->submission_text
                        </div>
                    </div>";
        } else {
            $submission = "
                    <div class='form-group'>
                        <label class='col-sm-3 control-label'>$m[filename]:</label>
                        <div class='col-sm-9'>
                            <a href='index.php?course=$course_code&amp;get=$sub->id'>".q($sub->file_name)."</a>
                        </div>
                    </div>";
        }
        if ($assign->grading_scale_id) {
            $serialized_scale_data = Database::get()->querySingle('SELECT scales FROM grading_scale WHERE id = ?d AND course_id = ?d', $assign->grading_scale_id, $course_id)->scales;
            $scales = unserialize($serialized_scale_data);
            $scale_options = "<option value> - </option>";
            $scale_values = array_value_recursive('scale_item_value', $scales);
            if (!in_array($sub->grade, $scale_values) && !is_null($sub->grade)) {
                $sub->grade = closest($sub->grade, $scale_values)['value'];
            }
            foreach ($scales as $scale) {
                $scale_options .= "<option value='$scale[scale_item_value]'".($sub->grade == $scale['scale_item_value'] ? " selected" : "").">$scale[scale_item_name]</option>";
            }
            $grade_field = "
                    <select name='grade' class='form-control' id='scales'>
                        $scale_options
                    </select>";
        } else {
            $grade_field = "<input class='form-control' type='text' name='grade' maxlength='4' size='3' value='$sub->grade'> ($m[max_grade]: $assign->max_grade)";
        }
        $tool_content .= action_bar(array(
                array(
                    'title' => $langBack,
                    'url' => "index.php?course=$course_code&id=$sub->assignment_id",
                    'icon' => "fa-reply",
                    'level' => 'primary-label'
                )
            ))."
            <div class='form-wrapper'>
                <form class='form-horizontal' role='form' method='post' action='index.php?course=$course_code'>
                <input type='hidden' name='assignment' value='$id'>
                <input type='hidden' name='submission' value='$sid'>
                <fieldset>
                    <div class='form-group'>
                        <label class='col-sm-3 control-label'>$m[username]:</label>
                        <div class='col-sm-9'>
                        $uid_2_name $group_submission
                        </div>
                    </div>
                    <div class='form-group'>
                        <label class='col-sm-3 control-label'>$m[sub_date]:</label>
                        <div class='col-sm-9'>
                            <span>".q($sub->submission_date)."</span>
                        </div>
                    </div>
                    $submission
                    <div class='form-group".(Session::getError('grade') ? " has-error" : "")."'>
                        <label for='grade' class='col-sm-3 control-label'>$m[grade]:</label>
                        <div class='col-sm-4'>
                            $grade_field
                            <span class='help-block'>".(Session::hasError('grade') ? Session::getError('grade') : "")."</span>
                        </div>
                    </div>
                    <div class='form-group'>
                        <label for='comments' class='col-sm-3 control-label'>$m[gradecomments]:</label>
                        <div class='col-sm-9'>
                            <textarea class='form-control' rows='3' name='comments'  id='comments'>$comments</textarea>
                        </div>
                    </div>
                    <div class='form-group'>
                        <div class='col-sm-9 col-sm-offset-3'>
                            <div class='checkbox'>
                                <label>
                                    <input type='checkbox' value='1' id='email_button' name='email'$email_status>
                                    $m[email_users]
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class='form-group'>
                        <div class='col-sm-9 col-sm-offset-3'>
                            <input class='btn btn-primary' type='submit' name='grade_comments' value='$langGradeOk'>
                            <a class='btn btn-default' href='index.php?course=$course_code&id=$sub->assignment_id'>$langCancel</a>
                        </div>
                    </div>
                </fieldset>
                </form>
            </div>";
    } else {
        Session::Messages($m['WorkNoSubmission'], 'alert-danger');
        redirect_to_home_page('modules/work/index.php?course='.$course_code.'&id='.$id);
    }
}
Exemplo n.º 15
0
                                      'icon' => 'fa-reply',
                                      'level' => 'primary-label',
                                      'class' => 'back_btn')
                            ));
    $tool_content .= "<div class='form-wrapper'>
    <form class='form-horizontal' role='form' action='$upload_target_url' method='post'>
      $htmlPath
      $group_hidden_input
      $ebook_section_select
      $htmlFileName

      <div class='form-group".(Session::getError('file_title') ? " has-error" : "")."'>
        <label for='file_title' class='col-sm-2 control-label'>$langTitle:</label>
        <div class='col-sm-10'>
          <input type='text' class='form-control' id='file_title' name='file_title'$htmlTitle>
          <span class='help-block'>".Session::getError('file_title')."</span>    
        </div>
      </div>
      <div class='form-group'>
        <label for='file_title' class='col-sm-2 control-label'>$langContent:</label>
        <div class='col-sm-10'>"
          . rich_text_editor('file_content', 20, 40, $fileContent) .
        "</div>
      </div>
	
	<div class='form-group'>
        <div class='col-xs-offset-2 col-xs-10'>".
            form_buttons(array(
                array(
                    'text' => $langSave,
                    'value'=> $langSubmit
Exemplo n.º 16
0
function show_assignment($id, $display_graph_results = false) {
    global $tool_content, $m, $langBack, $langNoSubmissions, $langSubmissions,
    $langEndDeadline, $langWEndDeadline, $langNEndDeadline, $langWorkOnlineText,
    $langDays, $langDaysLeft, $langGradeOk, $course_code, $webDir, $urlServer,
    $langGraphResults, $m, $course_code, $themeimg, $works_url, $course_id,
    $langDelWarnUserAssignment, $langQuestionView, $langDelete, $langEditChange,
    $langAutoJudgeShowWorkResultRpt;

    $assign = Database::get()->querySingle("SELECT *, CAST(UNIX_TIMESTAMP(deadline)-UNIX_TIMESTAMP(NOW()) AS SIGNED) AS time
                                FROM assignment
                                WHERE course_id = ?d AND id = ?d", $course_id, $id);

    $nav[] = $works_url;
    assignment_details($id, $assign);

    $rev = (@($_REQUEST['rev'] == 1)) ? 'DESC' : 'ASC';
    if (isset($_REQUEST['sort'])) {
        if ($_REQUEST['sort'] == 'am') {
            $order = 'am';
        } elseif ($_REQUEST['sort'] == 'date') {
            $order = 'submission_date';
        } elseif ($_REQUEST['sort'] == 'grade') {
            $order = 'grade';
        } elseif ($_REQUEST['sort'] == 'filename') {
            $order = 'file_name';
        } else {
            $order = 'surname';
        }
    } else {
        $order = 'surname';
    }

    $result1 = Database::get()->queryArray("SELECT * FROM assignment_submit AS assign, user
                                 WHERE assign.assignment_id = ?d AND user.id = assign.uid
                                 ORDER BY ?s ?s", $id, $order, $rev);

    $num_results = count($result1);
    if ($num_results > 0) {
        if ($num_results == 1) {
            $num_of_submissions = $m['one_submission'];
        } else {
            $num_of_submissions = sprintf("$m[more_submissions]", $num_results);
        }

        $gradeOccurances = array(); // Named array to hold grade occurances/stats
        $gradesExists = 0;
        foreach ($result1 as $row) {
            $theGrade = $row->grade;
            if ($theGrade) {
                $gradesExists = 1;
                if (!isset($gradeOccurances[$theGrade])) {
                    $gradeOccurances[$theGrade] = 1;
                } else {
                    if ($gradesExists) {
                        ++$gradeOccurances[$theGrade];
                    }
                }
            }
        }
        if (!$display_graph_results) {

            $result = Database::get()->queryArray("SELECT assign.id id, assign.file_name file_name,
                                                   assign.uid uid, assign.group_id group_id,
                                                   assign.submission_date submission_date,
                                                   assign.grade_submission_date grade_submission_date,
                                                   assign.grade grade, assign.comments comments,
                                                   assign.grade_comments grade_comments,
                                                   assignment.grading_scale_id grading_scale_id,
                                                   assignment.deadline deadline
                                                   FROM assignment_submit AS assign, user, assignment
                                                   WHERE assign.assignment_id = ?d AND assign.assignment_id = assignment.id AND user.id = assign.uid
                                                   ORDER BY $order $rev", $id);
            $tool_content .= "
                        <form action='$_SERVER[SCRIPT_NAME]?course=$course_code' method='post' class='form-inline'>
                        <input type='hidden' name='grades_id' value='$id' />
                        <br>
                        <div class='margin-bottom-thin'>
                            <b>$langSubmissions:</b>&nbsp; $num_results
                        </div>
                        <div class='table-responsive'>
                        <table class='table-default'>
                        <tbody>
                        <tr class='list-header'>
                      <th width='3'>&nbsp;</th>";
            sort_link($m['username'], 'username');
            sort_link($m['am'], 'am');
            $assign->submission_type ? $tool_content .= "<th>$langWorkOnlineText</th>" : sort_link($m['filename'], 'filename');
            sort_link($m['sub_date'], 'date');
            sort_link($m['grade'], 'grade');
            $tool_content .= "<th width='5%' class='text-center'><i class='fa fa-cogs'></i></th></tr>";

            $i = 1;
            foreach ($result as $row) {
                //is it a group assignment?
                if (!empty($row->group_id)) {
                    $subContentGroup = "$m[groupsubmit] " .
                            "<a href='../group/group_space.php?course=$course_code&amp;group_id=$row->group_id'>" .
                            "$m[ofgroup] " . gid_to_name($row->group_id) . "</a>";
                } else {
                    $subContentGroup = '';
                }
                $uid_2_name = display_user($row->uid);
                $stud_am = Database::get()->querySingle("SELECT am FROM user WHERE id = ?d", $row->uid)->am;
                if ($assign->submission_type) {
                    $filelink = "<a href='#' class='onlineText btn btn-xs btn-default' data-id='$row->id'>$langQuestionView</a>";
                } else {
                    $filelink = empty($row->file_name) ? '&nbsp;' :
                            ("<a href='$_SERVER[SCRIPT_NAME]?course=$course_code&amp;get=$row->id'>" .
                            q($row->file_name) . "</a>");
                }
                if(Session::has("grades")) {
                    $grades = Session::get('grades');
                    $grade = $grades[$row->id]['grade'];
                } else {
                    $grade = $row->grade;
                }
                if ($row->grading_scale_id) {
                    $serialized_scale_data = Database::get()->querySingle('SELECT scales FROM grading_scale WHERE id = ?d AND course_id = ?d', $row->grading_scale_id, $course_id)->scales;
                    $scales = unserialize($serialized_scale_data);
                    $scale_options = "<option value> - </option>";
                    $scale_values = array_value_recursive('scale_item_value', $scales);
                    if (!in_array($grade, $scale_values) && !is_null($grade)) {
                        $grade = closest($grade, $scale_values)['value'];
                    }
                    foreach ($scales as $scale) {
                        $scale_options .= "<option value='$scale[scale_item_value]'".($scale['scale_item_value'] == $grade ? " selected" : "").">$scale[scale_item_name]</option>";
                    }
                    $grade_field = "
                            <select name='grades[$row->id][grade]' class='form-control' id='scales'>
                                $scale_options
                            </select>";
                } else {
                    $grade_field = "<input class='form-control' type='text' value='$grade' name='grades[$row->id][grade]' maxlength='4' size='3'>";
                }
                $late_sub_text = $row->deadline && $row->submission_date > $row->deadline ?  "<div style='color:red;'><small>$m[late_submission]</small></div>" : '';
                $tool_content .= "
                                <tr>
                                <td align='right' width='4' rowspan='2' valign='top'>$i.</td>
                                <td>${uid_2_name}</td>
                                <td width='85'>" . q($stud_am) . "</td>
                                <td class='text-center' width='180'>
                                        $filelink
                                </td>
                                <td width='100'>" . nice_format($row->submission_date, TRUE) .$late_sub_text. "</td>
                                <td width='5'>
                                    <div class='form-group ".(Session::getError("grade.$row->id") ? "has-error" : "")."'>
                                        $grade_field
                                        <span class='help-block'>".Session::getError("grade.$row->id")."</span>
                                    </div>
                                </td>
                                <td class='option-btn-cell'>".
                                    action_button(array(
                                        array(
                                            'title' => $langEditChange,
                                            'url' => "grade_edit.php?course=$course_code&amp;assignment=$id&amp;submission=$row->id",
                                            'level' => 'primary',
                                            'icon' => 'fa-edit'
                                        ),
                                        array(
                                            'title' => $langDelete,
                                            'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=$id&amp;as_id=$row->id",
                                            'class' => 'delete',
                                            'icon' => 'fa-times',
                                            'confirm' => $langDelWarnUserAssignment
                                        )
                                    ))."
                                </td>
                                </tr>
                                <tr>
                                <td colspan='6'>
                                <div>$subContentGroup</div>";
                if (trim($row->comments != '')) {
                    $tool_content .= "<div style='margin-top: .5em;'>" .
                            q($row->comments) . '</div>';
                }
                //professor comments
                if ($row->grade_comments || $row->grade != '') {
                    $comments = "<br><div class='label label-primary'>" .
                            nice_format($row->grade_submission_date) . "</div>";
                }
                if (trim($row->grade_comments)) {
                    $label = '<b>'.$m['gradecomments'] . '</b>:';
                    $comments .= "&nbsp;<span>" . standard_text_escape($row->grade_comments) . "</span>";
                } else {
                    $label = '';
                    $comments = '';
                }
                $tool_content .= "<div style='padding-top: .5em;'>$label
				  $comments
                                ";
                if(AutojudgeApp::getAutojudge()->isEnabled()) {
                    $reportlink = "work_result_rpt.php?course=$course_code&amp;assignment=$id&amp;submission=$row->id";
                    $tool_content .= "<a href='$reportlink'><b>$langAutoJudgeShowWorkResultRpt</b></a>";
                }
                $tool_content .= "
                                </td>
                                </tr>";
                $i++;
            } //END of Foreach

            $tool_content .= "
                    </tbody>
                </table>
            </div>
            <div class='form-group'>
                <div class='col-xs-12'>
                    <div class='checkbox'>
                      <label>
                        <input type='checkbox' value='1' name='email'> $m[email_users]
                      </label>
                    </div>
                </div>
            </div>
            <div class='pull-right'>
                <button class='btn btn-primary' type='submit' name='submit_grades'>$langGradeOk</button>
            </div>
        </form>";
        } else {
        // display pie chart with grades results
            if ($gradesExists) {
                // Used to display grades distribution chart
                $graded_submissions_count = Database::get()->querySingle("SELECT COUNT(*) AS count FROM assignment_submit AS assign, user
                                                             WHERE assign.assignment_id = ?d AND user.id = assign.uid AND
                                                             assign.grade <> ''", $id)->count;
                $chart = new Plotter();
                $chart->setTitle("$langGraphResults");
                if ($assign->grading_scale_id) {
                    $serialized_scale_data = Database::get()->querySingle('SELECT scales FROM grading_scale WHERE id = ?d AND course_id = ?d', $assign->grading_scale_id, $course_id)->scales;
                    $scales = unserialize($serialized_scale_data);
                    $scale_values = array_value_recursive('scale_item_value', $scales);
                }
                foreach ($gradeOccurances as $gradeValue => $gradeOccurance) {
                    $percentage = round((100.0 * $gradeOccurance / $graded_submissions_count),2);
                    if ($assign->grading_scale_id) {
                        $key = closest($gradeValue, $scale_values, true)['key'];
                        $gradeValue = $scales[$key]['scale_item_name'];
                    }
                    $chart->growWithPoint("$gradeValue ($percentage%)", $percentage);
                }
                $tool_content .= $chart->plot();
            }
        }
    } else {
        $tool_content .= "
                      <p class='sub_title1'>$langSubmissions:</p>
                      <div class='alert alert-warning'>$langNoSubmissions</div>";
    }
}
Exemplo n.º 17
0
              <td style='width:70px;'>$section_id</td>
              <td>$section_title</td>
              <td class='text-center'>$section_tools</td>
            </tr>";          
        }
        $new_section_id = Session::has('new_section_id') ? Session::get('new_section_id') : '';
        if (!$section_editing) {
            $tool_content .= "
            <tr>
                <td style='width:70px'>
                    <input class='form-control' type='text' name='new_section_id' value='".q($new_section_id)."'>
                </td>
                <td>
                    <div class='form-group".(Session::getError('new_section_title') ? " has-error" : "")."'>
                        <input class='form-control' type='text' size='35' name='new_section_title'>
                        <span class='help-block'>".Session::getError('new_section_title')."</span>    
                    </div>
                </td>
                <td class='center'>
                    <input class='btn btn-primary' type='submit' name='new_section_submit' value='$langAdd'>
                </td>
            </tr>";
        }
        $tool_content .= "
          </table>
          </fieldset></form>";        
} elseif (isset($_POST['new_section_submit'])) {
    $v = new Valitron\Validator($_POST);
    $v->rule('required', array('new_section_title'));
    $v->labels(array(
        'new_section_title' => "$langTheField $langTitle"
Exemplo n.º 18
0
    } 

}

$tool_content .= action_bar(array(
    array('title' => $langBack,
          'url' => 'display_profile.php',
          'icon' => 'fa-reply',
          'level' => 'primary-label')));

if (!isset($_POST['changePass'])) {
    $old_pass_error = Session::getError('old_pass');
    $old_pass = Session::has('old_pass') ? Session::get('old_pass') : '';
    $password_form_error = Session::getError('password_form');
    $password_form = Session::has('password_form') ? Session::get('password_form') : '';
    $password_form1_error = Session::getError('password_form1');
    $password_form1 = Session::has('password_form1') ? Session::get('password_form1') : '';
    $tool_content .= "<div class='form-wrapper'>
    <form class='form-horizontal' role='form' method='post' action='$passUrl'>
    <fieldset>
    <div class='form-group".($old_pass_error ? " has-error" : "")."'>
      <label for='old_pass' class='col-sm-2 control-label'>$langOldPass: </label>
      <div class='col-sm-8'>
	    <input type='password' class='form-control' id='old_pass' name='old_pass' value='$old_pass' autocomplete='off'>
            <span class='help-block'>$old_pass_error</span>
      </div>
    </div>
    <div class='form-group".($password_form_error ? " has-error" : "")."'>
      <label for='password_form' class='col-sm-2 control-label'>$langNewPass1: </label>
      <div class='col-sm-8'>
	    <input type='password' class='form-control' id='password_form' name='password_form' value='$password_form' autocomplete='off'>
Exemplo n.º 19
0
          <input type='text' class='form-control' id='term' name='term' placeholder='$langGlossaryTerm' value='$term'>
          <span class='help-block'>".Session::getError('term')."</span>
      </div>
 </div>
 <div class='form-group".(Session::getError('definition') ? " has-error" : "")."'>
      <label for='term' class='col-sm-2 control-label'>$langGlossaryDefinition: </label>
      <div class='col-sm-10'>
          " . @text_area('definition', 4, 60, $definition) . "
          <span class='help-block'>".Session::getError('definition')."</span>    
      </div>
 </div>
 <div class='form-group".(Session::getError('url') ? " has-error" : "")."'>
      <label for='url' class='col-sm-2 control-label'>$langGlossaryUrl: </label>
      <div class='col-sm-10'>
          <input type='text' class='form-control' id='url' name='url' value='$url'>
          <span class='help-block'>".Session::getError('url')."</span>     
      </div>
 </div>
 <div class='form-group'>
      <label for='notes' class='col-sm-2 control-label'>$langCategoryNotes: </label>
      <div class='col-sm-10'>
          " . @rich_text_editor('notes', 4, 60, $notes) . "
      </div>
 </div>
 $category_selection
 <div class='form-group'>    
      <div class='col-sm-10 col-sm-offset-2'>".form_buttons(array(
                  array(
                      'text' => $langSave,
                      'value'=> $submit_value,
                      'name' => 'submit'
Exemplo n.º 20
0
            </label>
          </div>
      </div>
  </div>
  <div class='form-group ".(Session::getError('exercisePasswordLock') ? "has-error" : "")."'>
    <label for='exercisePasswordLock' class='col-sm-2 control-label'>$langPasswordUnlock:</label>
    <div class='col-sm-10'>
      <input name='exercisePasswordLock' type='text' class='form-control' id='exercisePasswordLock' value='$exercisePasswordLock' placeholder=''>
      <span class='help-block'>".Session::getError('exercisePasswordLock')."</span>
    </div>
  </div>                   
  <div class='form-group ".(Session::getError('exerciseIPLock') ? "has-error" : "")."'>
    <label for='exerciseIPLock' class='col-sm-2 control-label'>$langIPUnlock:</label>
    <div class='col-sm-10'>
      <input name='exerciseIPLock' type='hidden' class='form-control' id='exerciseIPLock' value='$exerciseIPLock' placeholder=''>
      <span class='help-block'>".Session::getError('exerciseIPLock')."</span>
    </div>
  </div>
 <div class='form-group'>
     <label class='col-sm-2 control-label'>$m[WorkAssignTo]:</label>
     <div class='col-sm-10'>
         <div class='radio'>
           <label>
             <input type='radio' id='assign_button_all' name='assign_to_specific' value='0'".($exerciseAssignToSpecific == 0 ? " checked" : "").">
             <span>$m[WorkToAllUsers]</span>
           </label>
         </div>
         <div class='radio'>
           <label>
             <input type='radio' id='assign_button_user' name='assign_to_specific' value='1'".($exerciseAssignToSpecific == 1 ? " checked" : "").">
             <span>$m[WorkToUser]</span>
Exemplo n.º 21
0
            redirect_to_home_page("modules/exercise/question_categories.php?course={$course_code}&modifyCat={$cat_id}");
        } else {
            redirect_to_home_page("modules/exercise/question_categories.php??course={$course_code}&newCat=yes");
        }
    }
} elseif (isset($_GET['modifyCat']) || isset($_GET['newCat'])) {
    $pageName = isset($_GET['newCat']) ? $langNewCat : $langEditCat;
    $navigation = array(array("url" => "index.php?course={$course_code}", "name" => $langExercices), array("url" => "question_categories.php?course={$course_code}", "name" => $langQuestionCats));
    $form_action_url = "{$_SERVER['SCRIPT_NAME']}?course={$course_code}";
    $form_action_url .= isset($_GET['modifyCat']) ? "&modifyCat=" . intval($_GET['modifyCat']) : "&newCat=yes";
    if (isset($_GET['modifyCat'])) {
        $q_cat = Database::get()->querySingle("SELECT * FROM exercise_question_cats WHERE question_cat_id = ?d", $_GET['modifyCat']);
    }
    $questionCatName = Session::has('questionCatName') ? Session::get('questionCatName') : (isset($q_cat) ? $q_cat->question_cat_name : '');
    $tool_content .= action_bar(array(array('title' => $langBack, 'level' => 'primary-label', 'icon' => 'fa-reply', 'url' => "question_categories.php?course={$course_code}")));
    $tool_content .= "\n        <div class='form-wrapper'>\n            <form class='form-horizontal' role='form' action='{$form_action_url}' method='post'>\n                <div class='form-group " . (Session::getError('questionCatName') ? "has-error" : "") . "'>\n                    <label for='questionCatName' class='col-sm-2 control-label'>{$langTitle}:</label>\n                    <div class='col-sm-10'>\n                      <input name='questionCatName' type='text' class='form-control' id='questionCatName' placeholder='{$langTitle}' value='{$questionCatName}'>\n                      <span class='help-block'>" . Session::getError('questionCatName') . "</span>\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' name='submitCat' type='submit' value='{$langSubmit}'>\n                        <a href='question_categories.php?course={$course_code}' class='btn btn-default'>{$langCancel}</a>\n                    </div>\n                </div>                \n            </form>\n        </div>";
} elseif (isset($_GET['deleteCat'])) {
    $q_cat_id = $_GET['deleteCat'];
    if (Database::get()->query("DELETE FROM exercise_question_cats WHERE question_cat_id = ?d AND course_id = ?d", $q_cat_id, $course_id)->affectedRows > 0) {
        Database::get()->query("UPDATE exercise_question SET category = ?d WHERE category = ?d AND course_id = ?d", 0, $q_cat_id, $course_id);
        Session::Messages($langDelCatSuccess, 'alert-success');
    }
    redirect_to_home_page("modules/exercise/question_categories.php?course={$course_code}");
} else {
    $pageName = $langQuestionCats;
    $navigation[] = array("url" => "index.php?course={$course_code}", "name" => $langExercices);
    $tool_content .= action_bar(array(array('title' => $langNewCat, 'level' => 'primary-label', 'icon' => 'fa-plus-circle', 'url' => "question_categories.php?course={$course_code}&newCat=yes", 'button-class' => 'btn-success'), array('title' => $langBack, 'level' => 'primary', 'icon' => 'fa-reply', 'url' => "index.php?course={$course_code}")));
    $q_cats = Database::get()->queryArray("SELECT * FROM exercise_question_cats WHERE course_id = ?d", $course_id);
    if (count($q_cats) > 0) {
        $tool_content .= "\n            <div class='table-responsive'>\n                <table class='table-default'>\n                    <tbody>\n                        <tr>\n                            <th>{$langTitle}</th>\n                            <th class='text-center'>" . icon('fa-gears') . "</th>\n                        </tr> \n                    ";
        foreach ($q_cats as $q_cat) {
Exemplo n.º 22
0
        $category = $objQuestion->selectCategory();
        $questionWeight = $objQuestion->selectWeighting();
    }
}
if (isset($_GET['newQuestion']) || isset($_GET['modifyQuestion'])) {
    $questionId = $objQuestion->selectId();
    // is picture set ?
    $okPicture = file_exists($picturePath . '/quiz-' . $questionId) ? true : false;
    // if there is an error message
    if (!empty($msgErr)) {
        $tool_content .= "<div class='alert alert-danger'>{$msgErr}</div>\n";
    }
    if (isset($_GET['newQuestion'])) {
        $form_submit_action = "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;" . (isset($exerciseId) ? "exerciseId={$exerciseId}" : "") . "&amp;newQuestion=" . urlencode($_GET['newQuestion']);
        $link_back = isset($exerciseId) ? "admin.php?course={$course_code}&exerciseId={$exerciseId}" : "question_pool.php?course={$course_code}";
    } else {
        $form_submit_action = "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;" . (isset($exerciseId) ? "exerciseId={$exerciseId}" : "") . "&amp;modifyQuestion=" . urlencode($_GET['modifyQuestion']);
        $link_back = "admin.php?course={$course_code}" . (isset($exerciseId) ? "&exerciseId={$exerciseId}" : "") . (isset($_GET['newQuestion']) ? "&editQuestion={$_GET['newQuestion']}" : "&editQuestion={$_GET['modifyQuestion']}");
    }
    $tool_content .= action_bar(array(array('title' => $langBack, 'url' => $link_back, 'icon' => 'fa-reply', 'level' => 'primary-label')));
    $q_cats = Database::get()->queryArray("SELECT * FROM exercise_question_cats WHERE course_id = ?d", $course_id);
    $options = "<option value='0'>-- {$langQuestionWithoutCat} --</option>\n";
    foreach ($q_cats as $q_cat) {
        $options .= "<option value='{$q_cat->question_cat_id}' " . ($category == $q_cat->question_cat_id ? "selected" : "") . ">{$q_cat->question_cat_name}</option>\n";
    }
    $tool_content .= "\n    <div class='form-wrapper'>\n        <form class='form-horizontal' role='form' enctype='multipart/form-data' method='post' action='{$form_submit_action}'>\n            <div class='form-group'>\n                <label for='questionCat' class='col-sm-2 control-label'>{$langQuestionCat}:</label>\n                <div class='col-sm-10'>\n                    <select name='category' id='questionCat' class='form-control'>\n                        {$options}\n                    </select>\n                </div>\n            </div>        \n            <div class='form-group " . (Session::getError('questionName') ? "has-error" : "") . "'>\n                <label for='questionName' class='col-sm-2 control-label'>{$langQuestion}:</label>\n                <div class='col-sm-10'>\n                  <input name='questionName' type='text' class='form-control' id='questionName' placeholder='{$langQuestion}' value='" . q($questionName) . "'>\n                  <span class='help-block'>" . Session::getError('questionName') . "</span>\n                </div>\n            </div>\n            <div class='form-group'>\n                <label for='questionDescription' class='col-sm-2 control-label'>{$langQuestionDescription}:</label>\n                <div class='col-sm-10'>\n                  " . rich_text_editor('questionDescription', 4, 50, $questionDescription) . "\n                </div>\n            </div>\n            <div class='form-group'>\n                <label for='questionDifficulty' class='col-sm-2 control-label'>{$langQuestionDiffGrade}:</label>\n                <div class='col-sm-10'>\n                    <input id='questionDifficulty' name='difficulty' data-slider-id='ex1Slider' type='text' data-slider-min='0' data-slider-max='5' data-slider-step='1' data-slider-value='{$difficulty}'/>                      \n                </div>\n                <div class='col-sm-1'>\n                <span id='questionDifficultyValue' class='label label-default'></span>  \n                </div>\n            </div>            \n            <div class='form-group'>\n                <label for='imageUpload' class='col-sm-2 control-label'>" . ($okPicture ? $langReplacePicture : $langAddPicture) . ":</label>\n                <div class='col-sm-10'>\n                  " . ($okPicture ? "<img src='../../{$picturePath}/quiz-{$questionId}'><br><br>" : "") . "\n                  <input type='file'  name='imageUpload' id='imageUpload'> \n                </div>\n            </div>";
    if ($okPicture) {
        $tool_content .= "\n            <div class='form-group'>\n\t\t<label class='col-sm-2 control-label'>{$langDeletePicture}:</label>\n                <div class='col-sm-10'>            \n                    <div class='checkbox'>\n                      <label>    \n                        <input type='checkbox' name='deletePicture' value='1' " . (isset($_POST['deletePicture']) ? "checked" : "") . ">\n                      </label>\n                    </div>\n                </div>\n            </div>";
    }
    $tool_content .= "<div class='form-group'>\n                <label class='col-sm-2 control-label'>{$langAnswerType}:</label>\n                <div class='col-sm-10'>            \n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='answerType' value='1' " . ($answerType == UNIQUE_ANSWER ? "checked" : "") . ">\n                        {$langUniqueSelect}\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='answerType' value='2' " . ($answerType == MULTIPLE_ANSWER ? "checked" : "") . ">\n                       {$langMultipleSelect}\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='answerType' value='3' " . ($answerType == FILL_IN_BLANKS ? "checked" : "") . ">\n                       {$langFillBlanks}\n                      </label>\n                    </div>                       \n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='answerType' value='4' " . ($answerType == MATCHING ? "checked" : "") . ">\n                       {$langMatching}\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' name='answerType' value='5' " . ($answerType == TRUE_FALSE ? "checked" : "") . ">\n                       {$langTrueFalse}\n                      </label>\n                    </div>\n                    <div class='radio'>\n                      <label>\n                        <input type='radio' id='free_text_selector' name='answerType' value='6' " . ($answerType == FREE_TEXT ? "checked" : "") . ">\n                       {$langFreeText}\n                      </label>\n                    </div>                       \n                </div>\n            </div>\n            <div class='form-group " . ($answerType != 6 ? "hide" : "") . "'>\n                <label for='questionGrade' class='col-sm-2 control-label'>{$m['grade']}:</label>\n                <div class='col-sm-10'>\n                  <input name='questionGrade' type='text' class='form-control' id='questionGrade' placeholder='{$m['grade']}' value='{$questionWeight}'" . ($answerType != 6 ? " disabled" : "") . ">\n                </div>\n            </div>\n            <div class='row'>\n                <div class='col-sm-10 col-sm-offset-2 '>            \n                    <input type='submit' class='btn btn-primary' name='submitQuestion' value='{$langOk}'>\n                    <a href='{$link_back}' class='btn btn-default'>{$langCancel}</a>      \n                </div>\n            </div>\n          </fieldset>\n\t</form>\n    </div>    \n    ";
}