Exemple #1
0
/**
 * @brief display users of gradebook
 * @global type $tool_content
 * @global type $course_id
 * @global type $course_code
 * @global type $langID
 * @global type $langName
 * @global type $langSurname
 * @global type $langAm
 * @global type $langRegistrationDateShort
 * @global type $langGradebookGrade
 * @global type $langGradebookGradeAlert 
 * @global type $langGradebookBooking
 * @global type $langGradebookOutRange
 * @param type $gradebook_id
 * @param type $actID
 */
function register_user_grades($gradebook_id, $actID) {

    global $tool_content, $course_id, $course_code,
            $langID, $langName, $langSurname, $langAm, $langRegistrationDateShort,
            $langGradebookGrade, $langGradebookNoTitle,
            $langGradebookBooking, $langGradebookTotalGrade,
            $langGradebookActivityWeight, $langCancel;

    //display form and list
    $gradebook_range = get_gradebook_range($gradebook_id);
    $result = Database::get()->querySingle("SELECT * FROM gradebook_activities WHERE id = ?d", $actID);
    $act_type = $result->activity_type; // type of activity
    $tool_content .= "<div class='alert alert-info'>" .(!empty($result->title) ? q($result->title) : $langGradebookNoTitle) . " <br>
                        <small>$langGradebookActivityWeight: $result->weight%</small></div>";
    //display users
    $resultUsers = Database::get()->queryArray("SELECT gradebook_users.id as recID, gradebook_users.uid as userID, user.surname as surname,
                                                    user.givenname as name, user.am as am, DATE(course_user.reg_date) AS reg_date
                                                FROM gradebook_users, user, course_user
                                                WHERE gradebook_id = ?d AND gradebook_users.uid = user.id
                                                    AND `user`.id = `course_user`.`user_id`
                                                    AND `course_user`.`course_id` = ?d ", $gradebook_id, $course_id);

    if ($resultUsers) {
        $tool_content .= "<div class='form-wrapper'>
        <form class='form-horizontal' id='user_grades_form' method='post' action='$_SERVER[SCRIPT_NAME]?course=$course_code&amp;gradebook_id=" . getIndirectReference($gradebook_id) . "&amp;ins=" . getIndirectReference($actID) . "'>
        <div class='row'>
        <div class='col-xs-12'>
        <table id='users_table{$course_id}' class='table-default custom_list_order'>
            <thead>
                <tr class='list-header'>
                    <th width='2'>$langID</th>
                    <th>$langName $langSurname</th>
                    <th>$langAm</th>
                    <th class='text-center' width='80'>$langRegistrationDateShort</th>
                    <th width='50' class='text-center'>$langGradebookGrade</th>
                    <th width='50'>$langGradebookTotalGrade</th>
                </tr>
            </thead>
            <tbody>";

        $cnt = 0;
        foreach ($resultUsers as $resultUser) {
            $cnt++;
            $q = Database::get()->querySingle("SELECT grade FROM gradebook_book
                                                            WHERE gradebook_activity_id = ?d
                                                        AND uid = ?d", $actID, $resultUser->userID);
            $user_grade = $q ? $q->grade : '-';
            $user_ind_id = getIndirectReference($resultUser->userID);
            $grade = Session::has($user_ind_id) ? Session::get($user_ind_id) : ($q ? $q->grade * $gradebook_range : '');
            $total_grade = is_numeric($grade) ? $grade * $result->weight / 100 : ' - ';
            $tool_content .= "
            <tr>
                <td>$cnt</td>
                <td>" . display_user($resultUser->userID). "</td>
                <td>$resultUser->am</td>
                <td>" . nice_format($resultUser->reg_date) . "</td>
                <td class='text-center form-group".(Session::getError(getIndirectReference($resultUser->userID)) ? " has-error" : "")."'>
                    <input class='form-control' type='text' name='usersgrade[".getIndirectReference($resultUser->userID)."]' value = '".$grade."'>
                    <input type='hidden' value='" . getIndirectReference($actID) . "' name='actID'>
                    <span class='help-block'>".Session::getError(getIndirectReference($resultUser->userID))."</span>
                </td>
                <td><input class='form-control' type='text' value='$total_grade' disabled></td>
            </tr>";
        }
        $tool_content .= "</tbody></table></div></div>";
        $tool_content .= "<div class='form-group'>";
        $tool_content .= "<div class='col-xs-12'>" .
                        form_buttons(array(
                            array(
                                'text' => $langGradebookBooking,
                                'name' => 'bookUsersToAct',
                                'value'=> $langGradebookBooking
                                ))).
                        "<a href='index.php?course=$course_code&amp;gradebook_id=" . getIndirectReference($gradebook_id) . "' class='btn btn-default'>$langCancel</a>";
        $tool_content .= "</div></div>";
        $tool_content .= generate_csrf_token_form_field()."</form></div>";
    }
}
Exemple #2
0
$courses = Database::get()->queryArray("SELECT course.id course_id, code, title FROM course, course_user, user 
                                            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&amp;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;
    }