} } else { //==========Student View============== $userID = $uid; //visible flag $visible = 1; //check if there are grade records for the user, otherwise alert message that there is no input $checkForRecords = Database::get()->querySingle("SELECT COUNT(gradebook_book.id) as count FROM gradebook_book, gradebook_activities WHERE gradebook_book.gradebook_activity_id = gradebook_activities.id AND gradebook_activities.visible = ?d AND uid = ?d AND gradebook_activities.gradebook_id = ?d", $visible, $userID, $gradebook_id)->count; if (!$checkForRecords) { $tool_content .= "<div class='alert alert-warning'>{$langGradebookTotalGradeNoInput}</div>"; } $result = Database::get()->queryArray("SELECT * FROM gradebook_activities WHERE gradebook_activities.visible = ?d AND gradebook_id = ?d ORDER BY `DATE` DESC", $visible, $gradebook_id); $announcementNumber = count($result); if ($announcementNumber > 0) { $tool_content .= "<div class='alert alert-info'>{$langGradebookTotalGrade}: <b>" . userGradeTotal($gradebook_id, $userID) . "</b> </div>"; if (weightleft($gradebook_id, 0) != 0) { $tool_content .= "<div class='alert alert-warning'>{$langGradebookAlertToChange}</p>"; } $tool_content .= "<table class='table-default' >"; $tool_content .= "<tr><th>{$langTitle}</th><th>{$langGradebookActivityDate2}</th><th>{$langGradebookActivityDescription}</th><th>{$langGradebookActivityWeight}</th><th>{$langGradebookGrade}</th></tr>"; } if ($result) { foreach ($result as $announce) { $content = standard_text_escape($announce->description); $announce->date = claro_format_locale_date($dateFormatLong, strtotime($announce->date)); $tool_content .= "<tr><td><b>"; if (empty($announce->title)) { $tool_content .= $langAnnouncementNoTille; } else { $tool_content .= q($announce->title); }
//UPDATE/INSERT DB: new activity from exersices, assignments, learning paths elseif(isset($_GET['addCourseActivity'])) { $id = getDirectReference($_GET['addCourseActivity']); $type = intval($_GET['type']); add_gradebook_activity($gradebook_id, $id, $type); Session::Messages("$langGradebookSucInsert","alert-success"); redirect_to_home_page("modules/gradebook/index.php?course=$course_code&gradebook_id=" . getIndirectReference($gradebook_id)); $display = FALSE; } //UPDATE/INSERT DB: add or edit activity to gradebook module (edit concerns and course activities like lps) elseif(isset($_POST['submitGradebookActivity'])) { $v = new Valitron\Validator($_POST); $v->rule('numeric', array('weight')); $v->rule('min', array('weight'), 0); $v->rule('max', array('weight'), weightleft($gradebook_id, getDirectReference($_POST['id']))); $v->rule('date', array('date')); $v->labels(array( 'weight' => "$langTheField $langGradebookActivityWeight", 'date' => "$langTheField $langGradebookActivityDate2" )); if($v->validate()) { if (!isset($_POST['token']) || !validate_csrf_token($_POST['token'])) csrf_token_error(); $actTitle = isset($_POST['actTitle']) ? trim($_POST['actTitle']) : ''; $actDesc = purify($_POST['actDesc']); $auto = isset($_POST['auto']) ? 1 : 0; $weight = $_POST['weight']; $type = $_POST['activity_type']; $actDate = !empty($_POST['date']) ? $_POST['date'] : NULL; $visible = isset($_POST['visible']) ? 1 : 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&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>"; }