require_once '../../include/baseTheme.php'; //Module name $pageName = $langGradebook; $userID = $uid; $content = false; $grade_content = ''; $courses = Database::get()->queryArray("SELECT course.id course_id, code, title FROM course, course_user, user \n WHERE course.id = course_user.course_id\n AND course_user.user_id = ?d \n AND user.id = ?d\n AND course.visible != " . COURSE_INACTIVE . "", $userID, $userID); if (count($courses) > 0) { $grade_content .= "<div class ='table-responsive'>\n <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()->querySingle("SELECT id, students_semester,`range` FROM gradebook WHERE course_id = ?d", $course_id); if ($gradebook) { $gradebook_id = $gradebook->id; $grade = userGradeTotal($gradebook_id, $userID, $code); if ($grade) { $content = true; $grade_content .= "<tr><td>" . $course1->title . "</td>\n <td><a href='../../modules/gradebook/index.php?course={$code}'>" . $grade . "</a> <small>({$langMax}: " . $gradebook->range . ")</small></td></tr>"; } } } $grade_content .= "</table></div>"; if (!$content) { $tool_content .= "<div class='alert alert-warning'>{$langNoGradebook}</div>"; } else { $tool_content .= $grade_content; } } else { $tool_content .= "<div class='alert alert-warning'>{$langNoGradebook}</div>"; }
/** * @brief display user grades (student view) * @global type $tool_content * @global type $uid * @global type $langGradebookTotalGradeNoInput * @global type $langGradebookTotalGrade * @global type $langTitle * @global type $langGradebookActivityDate2 * @global type $langGradebookActivityDescription * @global type $langGradebookActivityWeight * @global type $langGradebookGrade * @global type $langGradebookAlertToChange * @param type $gradebook_id */ function student_view_gradebook($gradebook_id) { global $tool_content, $uid, $langGradebookTotalGradeNoInput, $langGradebookTotalGrade, $langGradebookSum, $langTitle, $langGradebookActivityDate2, $langGradebookNoTitle, $langGradebookActivityWeight, $langGradebookGrade, $langGradebookAlertToChange, $langBack, $course_code, $langType, $langAssignment, $langExercise, $langGradebookActivityAct, $langGradebookInsAut, $langGradebookInsMan, $langAttendanceActivity; //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 = 1 AND uid = ?d AND gradebook_activities.gradebook_id = ?d", $uid, $gradebook_id)->count; $tool_content .= action_bar(array( array( 'title' => $langBack, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code", 'icon' => 'fa-reply', 'level' => 'primary-label'), )); if (!$checkForRecords) { $tool_content .="<div class='alert alert-warning'>$langGradebookTotalGradeNoInput</div>"; } $result = Database::get()->queryArray("SELECT * FROM gradebook_activities WHERE gradebook_activities.visible = 1 AND gradebook_id = ?d ORDER BY `DATE` DESC", $gradebook_id); $results = count($result); if ($results > 0) { if ($checkForRecords) { $range = Database::get()->querySingle("SELECT `range` FROM gradebook WHERE id = ?d", $gradebook_id)->range; } if(weightleft($gradebook_id, 0) != 0) { $tool_content .= "<div class='alert alert-warning'>$langGradebookAlertToChange</div>"; } $tool_content .= "<table class='table-default' >"; $tool_content .= "<tr class='list-header'><th>$langTitle</th> <th>$langGradebookActivityDate2</th> <th>$langType</th> <th>$langGradebookActivityWeight</th> <th>$langGradebookGrade</th> <th>$langGradebookTotalGrade</th> </tr>"; } if ($result) { foreach ($result as $details) { //$content = standard_text_escape($details->description); $tool_content .= " <tr> <td> <b>" .(!empty($details->title) ? q($details->title) : $langGradebookNoTitle) . "</b> </td> <td> <div class='smaller'>" . nice_format($details->date, true, true) . "</div> </td>"; if ($details->module_auto_id) { if ($details->module_auto_type == GRADEBOOK_ACTIVITY_ASSIGNMENT) { $tool_content .= "<td class='smaller'>$langAssignment"; } if ($details->module_auto_type == GRADEBOOK_ACTIVITY_EXERCISE) { $tool_content .= "<td class='smaller'>$langExercise "; } if ($details->module_auto_type == GRADEBOOK_ACTIVITY_LP) { $tool_content .= "<td class='smaller'>$langGradebookActivityAct"; } $tool_content .= "</td>"; } else { $tool_content .= "<td class='smaller'>$langAttendanceActivity</td>"; } $tool_content .= "<td>" . q($details->weight) . "%</td>"; $tool_content .= "<td width='70' class='text-center'>"; //check user grade for this activity $sql = Database::get()->querySingle("SELECT grade FROM gradebook_book WHERE gradebook_activity_id = ?d AND uid = ?d", $details->id, $uid); if ($sql) { $tool_content .= $sql->grade * $range. ' / '.$range; } else { $tool_content .= "—"; } $tool_content .= "</td>"; $tool_content .= "<td width='70' class='text-center'>"; $tool_content .= $sql ? ($sql->grade * $range * $details->weight / 100)." / $range</td>" : "—"; $tool_content .= "</td> </tr>"; } // end of while $tool_content .= " <tr> <th colspan='5' class='text-right'>$langGradebookSum:</th> <th class='text-center'>".($sql ? userGradeTotal($gradebook_id, $uid) . " / $range" : "—")."</th> </tr>"; } $tool_content .= "</table>"; }
} } } 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);
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 { $tool_content .= "<div class='alert alert-warning'>$langNoGradebook</div>";