Esempio n. 1
0
     $tool_content .= "</tr>";
 } else {
     $tool_content .= "<div class='alert alert-warning'>{$langGradebookNoActMessage1} <a href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;addActivity=1'>{$langGradebookNoActMessage2}</a> {$langGradebookNoActMessage3}</p>\n";
 }
 //ui counter
 $k = 0;
 if ($result) {
     foreach ($result as $activity) {
         //check if there is auto mechanism
         if ($activity->auto == 1) {
             //check for autograde (if there is already a record do not propose the auto grade)
             //if there is not get the grade from the book table
             $checkForAuto = Database::get()->querySingle("SELECT id FROM gradebook_book WHERE gradebook_activity_id = ?d AND uid = ?d", $activity->id, $userID);
             if ($activity->module_auto_type && !$checkForAuto) {
                 //assignments, exercises, lp(scorms)
                 $userGrade = attendForAutoGrades($userID, $activity->module_auto_id, $activity->module_auto_type, $gradebook_range);
             } else {
                 $qusergrade = Database::get()->querySingle("SELECT grade FROM gradebook_book WHERE gradebook_activity_id = ?d AND uid = ?d", $activity->id, $userID);
                 if ($qusergrade) {
                     $userGrade = $qusergrade->grade;
                 }
             }
         } else {
             $qusergrade = Database::get()->querySingle("SELECT grade FROM gradebook_book  WHERE gradebook_activity_id = ?d AND uid = ?d", $activity->id, $userID);
             if ($qusergrade) {
                 $userGrade = $qusergrade->grade;
             }
         }
         $content = standard_text_escape($activity->description);
         $d = strtotime($activity->date);
         if ($k % 2 == 0) {
Esempio n. 2
0
/**
 * @brief display user grades (teacher view)
 * @global type $course_code
 * @global type $tool_content
 * @global type $langTitle
 * @global type $langGradebookActivityDate2
 * @global type $langType
 * @global type $langGradebookNewUser
 * @global type $langGradebookWeight
 * @global type $langGradebookBooking
 * @global type $langGradebookNoActMessage1
 * @global type $langGradebookNoActMessage2
 * @global type $langGradebookNoActMessage3
 * @global type $langGradebookActCour
 * @global type $langGradebookAutoGrade
 * @global type $langGradebookΝοAutoGrade
 * @global type $langGradebookActAttend
 * @global type $langGradebookOutRange
 * @global type $langGradebookUpToDegree
 * @global type $langGradeNoBookAlert
 * @global type $langGradebookGrade
 * @param type $gradebook_id
 */
function display_user_grades($gradebook_id) {

    global $course_code, $tool_content,
           $langTitle, $langGradebookActivityDate2, $langType, $langGradebookNewUser,
           $langGradebookWeight, $langGradebookBooking, $langGradebookNoActMessage1,
           $langGradebookNoActMessage2, $langGradebookNoActMessage3, $langGradebookActCour,
           $langGradebookAutoGrade, $langGradebookΝοAutoGrade, $langGradebookActAttend,
           $langGradebookOutRange, $langGradebookUpToDegree, $langGradeNoBookAlert, $langGradebookGrade;

    $gradebook_range = get_gradebook_range($gradebook_id);

    if(weightleft($gradebook_id, 0) == 0) {
        $userID = intval($_GET['book']); //user
        //check if there are booking records for the user, otherwise alert message for first 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 uid = ?d AND gradebook_activities.gradebook_id = ?d", $userID, $gradebook_id)->count;
        if(!$checkForRecords) {
            $tool_content .="<div class='alert alert-success'>$langGradebookNewUser</div>";
        }

        //get all the activities
        $result = Database::get()->queryArray("SELECT * FROM gradebook_activities  WHERE gradebook_id = ?d  ORDER BY `DATE` DESC", $gradebook_id);
        $actNumber = count($result);
        if ($actNumber > 0) {
            $tool_content .= "<h5>" . display_user($userID) . " ($langGradebookGrade: " . userGradeTotal($gradebook_id, $userID) . ")</h5>";
            $tool_content .= "<form method='post' action='$_SERVER[SCRIPT_NAME]?course=$course_code&amp;gradebook_id=" . getIndirectReference($gradebook_id) . "&amp;book=" . $userID . "' onsubmit=\"return checkrequired(this, 'antitle');\">
                              <table class='table-default'>";
            $tool_content .= "<tr><th>$langTitle</th><th >$langGradebookActivityDate2</th><th>$langType</th><th>$langGradebookWeight</th>";
            $tool_content .= "<th width='10' class='text-center'>$langGradebookBooking</th>";
            $tool_content .= "</tr>";
        } else {
            $tool_content .= "<div class='alert alert-warning'>$langGradebookNoActMessage1 <a href='$_SERVER[SCRIPT_NAME]?course=$course_code&amp;addActivity=1'>$langGradebookNoActMessage2</a> $langGradebookNoActMessage3</p>\n";
        }

        if ($result) {
            foreach ($result as $activity) {
                //check if there is auto mechanism
                if($activity->auto == 1){
                    //check for autograde (if there is already a record do not propose the auto grade)
                    //if there is not get the grade from the book table
                    $checkForAuto = Database::get()->querySingle("SELECT id FROM gradebook_book WHERE gradebook_activity_id = ?d AND uid = ?d", $activity->id, $userID);
                    if($activity->module_auto_type && !$checkForAuto) { //assignments, exercises, lp(scorms)
                        $userGrade = attendForAutoGrades($userID, $activity->module_auto_id, $activity->module_auto_type, $gradebook_range);
                    } else {
                        $qusergrade = Database::get()->querySingle("SELECT grade FROM gradebook_book WHERE gradebook_activity_id = ?d AND uid = ?d", $activity->id, $userID);
                        if ($qusergrade) {
                            $userGrade = $qusergrade->grade;
                        }
                    }
                } else {
                    $qusergrade = Database::get()->querySingle("SELECT grade FROM gradebook_book  WHERE gradebook_activity_id = ?d AND uid = ?d", $activity->id, $userID);
                    if ($qusergrade) {
                        $userGrade = $qusergrade->grade;
                    }
                }

                $content = standard_text_escape($activity->description);

                $tool_content .= "<tr><td><b>";

                if (!empty($activity->title)) {
                    $tool_content .= q($activity->title);
                }
                $tool_content .= "</b>";
                $tool_content .= "</td>";
                if($activity->date){
                    $tool_content .= "<td><div class='smaller'><span class='day'>" . nice_format($activity->date, true, true) . "</div></td>";
                } else {
                    $tool_content .= "<td>-</td>";
                }
                if ($activity->module_auto_id) {
                    $tool_content .= "<td class='smaller'>$langGradebookActCour";
                    if ($activity->auto) {
                        $tool_content .= "<br>($langGradebookAutoGrade)";
                    } else {
                        $tool_content .= "<br>($langGradebookΝοAutoGrade)";
                    }
                    $tool_content .= "</td>";
                } else {
                    $tool_content .= "<td class='smaller'>$langGradebookActAttend</td>";
                }
                $tool_content .= "<td width='' class='text-center'>" . $activity->weight . "%</td>";
                @$tool_content .= "<td class='text-center'>
                <input style='width:30px' type='text' value='".$userGrade."' name='" . getIndirectReference($activity->id) . "'"; //SOS 4 the UI!!
                $tool_content .= ">
                <input type='hidden' value='" . getIndirectReference($userID) . "' name='userID'>
                </td>";
            } // end of while
        }
        $tool_content .= "</tr></table>";
        $tool_content .= "<div class='pull-right'><input class='btn btn-primary' type='submit' name='bookUser' value='$langGradebookBooking'>".generate_csrf_token_form_field()."</div>";

        if(userGradeTotal($gradebook_id, $userID) > $gradebook_range){
            $tool_content .= "<br>" . $langGradebookOutRange;
        }
        $tool_content .= "<span class='help-block'><small>" . $langGradebookUpToDegree . $gradebook_range . "</small></span>";
    } else {
        $tool_content .= "<div class='alert alert-success'>$langGradeNoBookAlert " . weightleft($gradebook_id, 0) . "%</div>";
    }
}