예제 #1
0
     $tool_content .= "<fieldset>";
     $tool_content .= "<script type='text/javascript' src='../auth/sorttable.js'></script>\n                                    <form method='post' action='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&book=" . $userID . "'>\n                                  <table class='table-default sortable' id='t2'>";
     $tool_content .= "<tr><th>" . $m['title'] . "</th>" . "<th>" . $langdate . "</th>" . "<th>{$langType}</th>";
     $tool_content .= "<th width='60' class='center'>" . $langAttendanceBooking . "</th>";
     $tool_content .= "</tr>";
 } else {
     $tool_content .= "<p class='alert1'>{$langAttendanceNoActMessage1} <a href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;addActivity=1'>{$langHere}</a> {$langAttendanceNoActMessage3}</p>\n";
 }
 //ui counter
 if ($result) {
     foreach ($result as $activ) {
         //check if there is auto mechanism
         if ($activ->auto == 1) {
             //check for auto activities
             if ($activ->module_auto_type) {
                 $userAttend = attendForAutoActivities($userID, $activ->module_auto_id, $activ->module_auto_type);
                 if ($userAttend == 0) {
                     $q = Database::get()->querySingle("SELECT attend FROM attendance_book WHERE attendance_activity_id = ?d AND uid = ?d", $activ->id, $userID);
                     if ($q) {
                         $userAttend = $q->attend;
                     }
                 }
             }
         } else {
             $q = Database::get()->querySingle("SELECT attend FROM attendance_book WHERE attendance_activity_id = ?d AND uid = ?d", $activ->id, $userID);
             if ($q) {
                 $userAttend = $q->attend;
             } else {
                 $userAttend = 0;
             }
         }
예제 #2
0
/**
 * @brief dislay user presences
 * @global type $course_code
 * @global type $tool_content
 * @global type $langTitle
 * @global type $langType
 * @global type $langAttendanceNewBookRecord
 * @global type $langDate
 * @global type $langAttendanceNoActMessage1
 * @global type $langAttendanceBooking
 * @global type $langAttendanceActAttend
 * @global type $langAttendanceActCour
 * @global type $langAttendanceInsAut
 * @global type $langAttendanceInsMan
 * @global type $langGradebookUpToDegree
 * @global type $langAttendanceBooking
 * @param type $attendance_id
 */
function display_user_presences($attendance_id) {
    
    global $course_code, $tool_content,
           $langTitle, $langType, $langAttendanceNewBookRecord, $langDate,
           $langAttendanceNoActMessage1, $langAttendanceBooking,
           $langAttendanceActAttend, $langAttendanceActCour,
           $langAttendanceInsAut, $langAttendanceInsMan,
           $langAttendanceBooking;
        
        $attendance_limit = get_attendance_limit($attendance_id);
    
        $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 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(attendance_book.id) AS count FROM attendance_book, attendance_activities 
                            WHERE attendance_book.attendance_activity_id = attendance_activities.id 
                            AND uid = ?d AND attendance_activities.attendance_id = ?d", $userID, $attendance_id)->count;
        if(!$checkForRecords) {
            $tool_content .="<div class='alert alert-success'>$langAttendanceNewBookRecord</div>";
        }

        //get all the activities
        $result = Database::get()->queryArray("SELECT * FROM attendance_activities WHERE attendance_id = ?d  ORDER BY `DATE` DESC", $attendance_id);
        $actNumber = count($result);
        if ($actNumber > 0) {
            $tool_content .= "<h5>". display_user($userID) ."</h5>";
            $tool_content .= "<form method='post' action='$_SERVER[SCRIPT_NAME]?course=$course_code&amp;attendance_id=$attendance_id&amp;book=" . $userID . "' onsubmit=\"return checkrequired(this, 'antitle');\">
                              <table class='table-default'>";
            $tool_content .= "<tr><th>$langTitle</th><th >$langDate</th><th>$langType</th>";
            $tool_content .= "<th width='10' class='text-center'>$langAttendanceBooking</th>";
            $tool_content .= "</tr>";
        } else {
            $tool_content .= "<div class='alert alert-warning'>$langAttendanceNoActMessage1</div>";
        }

        if ($result) {
            foreach ($result as $activity) {
                //check if there is auto mechanism
                if($activity->auto == 1) {                    
                    if($activity->module_auto_type) { //assignments, exercises, lp(scorms)
                        $userAttend = attendForAutoActivities($userID, $activity->module_auto_id, $activity->module_auto_type);
                        if ($userAttend == 0) {
                            $q = Database::get()->querySingle("SELECT attend FROM attendance_book WHERE attendance_activity_id = ?d AND uid = ?d", $activity->id, $userID);
                            if ($q) {
                                $userAttend = $q->attend;
                            }
                        }
                    }
                } else {
                    $q = Database::get()->querySingle("SELECT attend FROM attendance_book 
                                                        WHERE attendance_activity_id = ?d AND uid = ?d", $activity->id, $userID);
                    if ($q) {
                        $userAttend = $q->attend;
                    } else {
                        $userAttend = 0;
                    }                    
                }
                $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'>$langAttendanceActCour";
                    if ($activity->auto) {
                        $tool_content .= "<br>($langAttendanceInsAut)";
                    } else {
                        $tool_content .= "<br>($langAttendanceInsMan)";
                    }
                    $tool_content .= "</td>";
                } else {
                    $tool_content .= "<td class='smaller'>$langAttendanceActAttend</td>";
                }
                $tool_content .= "<td class='text-center'>
                <input type='checkbox' value='1' name='" . $activity->id . "'";
                if(isset($userAttend) && $userAttend) {
                    $tool_content .= " checked";
                }    
                $tool_content .= ">                                        
                <input type='hidden' value='" . $userID . "' name='userID'>    
                </td></tr>";
            } // end of while
        }
        $tool_content .= "</table>";                
        $tool_content .= "<div class='pull-right'><input class='btn btn-primary' type='submit' name='bookUser' value='$langAttendanceBooking'></div>";        
}