/** * @brief create copy of an existing gradebook. (with same activities and no users). * @global type $course_id * @param type $gradebook_id */ function clone_gradebook($gradebook_id) { global $course_id, $langCopyDuplicate; $newTitle = get_gradebook_title($gradebook_id)." $langCopyDuplicate"; $newRange = get_gradebook_range($gradebook_id); $new_gradebook_id = Database::get()->query("INSERT INTO gradebook SET course_id = ?d, students_semester = 1, `range` = ?d, active = 1, title = ?s", $course_id, $newRange, $newTitle)->lastInsertID; Database::get()->query("INSERT INTO gradebook_activities (gradebook_id, title, activity_type, date, description, weight, module_auto_id, module_auto_type, auto, visible) SELECT $new_gradebook_id, title, activity_type, " . DBHelper::timeAfter() . ", description, weight, module_auto_id, module_auto_type, auto, 1 FROM gradebook_activities WHERE gradebook_id = ?d", $gradebook_id); }
array('title' => $langBack, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&gradebook_id=" . getIndirectReference($gradebook_id), 'icon' => 'fa fa-reply ', 'level' => 'primary-label') )); } elseif (isset($_GET['new'])) { $navigation[] = array("url" => "$_SERVER[SCRIPT_NAME]?course=$course_code", "name" => $langGradebook); $pageName = $langNewGradebook; $tool_content .= action_bar(array( array('title' => $langBack, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code", 'icon' => 'fa-reply', 'level' => 'primary-label'))); } elseif (isset($_GET['gradebook_id']) && $is_editor) { $pageName = get_gradebook_title($gradebook_id); } elseif ( !isset($_GET['gradebook_id'])) { $tool_content .= action_bar( array( array('title' => $langNewGradebook, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&new=1", 'icon' => 'fa-plus', 'level' => 'primary-label', 'button-class' => 'btn-success'))); } $tool_content .= "</div></div>"; // update gradebook settings if (isset($_POST['submitGradebookSettings'])) { $v = new Valitron\Validator($_POST); $v->rule('required', array('title', 'degreerange', 'start_date', 'end_date'));
WHERE course.id = course_user.course_id AND course_user.user_id = ?d AND user.id = ?d AND course.visible != " . COURSE_INACTIVE . "", $uid, $uid); if (count($courses) > 0) { $grade_content .= "<div class ='table-responsive'> <table class='table-default'><tr><th>$langCourse</th><th>$langGradebookGrade</th></tr>"; foreach ($courses as $course1) { $course_id = $course1->course_id; $code = $course1->code; $gradebook = Database::get()->queryArray("SELECT * FROM gradebook_users WHERE uid = ?d AND gradebook_id IN (SELECT id FROM gradebook WHERE active = 1 AND course_id = ?d)", $uid, $course_id); foreach ($gradebook as $gd) { $gradebook_id = $gd->gradebook_id; // if course has one gradebook $range = get_gradebook_range($gradebook_id); $gd_title = get_gradebook_title($gradebook_id); $grade = userGradeTotal($gradebook_id, $uid, $code, true); if ($grade) { $content = true; $grade_content .= "<tr><td>" . $course1->title . " ($gd_title)</td> <td><a href='../../modules/gradebook/index.php?course=$code&gradebook_id=$gradebook_id'>" . $grade ." / " . $range . "</a></td></tr>"; } } } $grade_content .= "</table></div>"; if (!$content) { $tool_content .= "<div class='alert alert-warning'>$langNoGradebook</div>"; } else { $tool_content .= $grade_content; } } else {