function get_content()
 {
     global $CFG, $USER, $COURSE;
     if (!empty($this->content)) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->text = '';
     if (!($att = array_pop(get_all_instances_in_course('attforblock', $COURSE, NULL, true)))) {
         $this->content->text = get_string('needactivity', 'block_attendance');
         return $this->content;
     }
     $cmid = $att->coursemodule;
     require_once $CFG->dirroot . '/mod/attforblock/locallib.php';
     if (!($context = get_context_instance(CONTEXT_MODULE, $cmid))) {
         print_error('badcontext');
     }
     // link to attendance
     if (has_capability('mod/attforblock:takeattendances', $context) or has_capability('mod/attforblock:changeattendances', $context)) {
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/mod/attforblock/manage.php?id=' . $cmid . '&amp;from=block">' . get_string('takeattendance', 'attforblock') . '</a><br />';
     }
     if (has_capability('mod/attforblock:manageattendances', $context)) {
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/mod/attforblock/sessions.php?id=' . $cmid . '&amp;action=add">' . get_string('add', 'attforblock') . '</a><br />';
     }
     if (has_capability('mod/attforblock:viewreports', $context)) {
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/mod/attforblock/report.php?id=' . $cmid . '&amp;view=weeks">' . get_string('report', 'attforblock') . '</a><br />';
     }
     if (has_capability('mod/attforblock:export', $context)) {
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/mod/attforblock/export.php?id=' . $cmid . '">' . get_string('export', 'quiz') . '</a><br />';
     }
     if (has_capability('mod/attforblock:changepreferences', $context)) {
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/mod/attforblock/attsettings.php?id=' . $cmid . '">' . get_string('settings', 'attforblock') . '</a><br />';
     }
     $context2 = get_context_instance(CONTEXT_COURSE, $COURSE->id);
     if (has_capability('moodle/course:view', $context) && has_capability('mod/attforblock:view', $context)) {
         $complete = get_attendance($USER->id, $COURSE);
         if ($complete == 0) {
             //attendance not generated yet
             $this->content->text .= get_string('attendancenotstarted', 'attforblock');
         } else {
             //attendance taken
             $statuses = get_statuses($COURSE->id);
             foreach ($statuses as $st) {
                 $this->content->text .= $st->description . ':&nbsp;' . get_attendance($USER->id, $COURSE, $st->id) . '<br />';
             }
             $percent = get_percent($USER->id, $COURSE);
             $grade = get_grade($USER->id, $COURSE);
             $this->content->text .= get_string('attendancepercent', 'attforblock') . ':&nbsp;' . $percent . '&nbsp;%<br />';
             $this->content->text .= get_string('attendancegrade', 'attforblock') . ":&nbsp;{$grade}<br />";
             $this->content->text .= '<a href="' . $CFG->wwwroot . '/mod/attforblock/view.php?id=' . $cmid . '">' . get_string('indetail', 'attforblock') . '</a>';
         }
     }
     return $this->content;
 }
Esempio n. 2
0
 static function getTransferStatusAjax()
 {
     @(include dirname(__FILE__) . '/config.php');
     if (!$stage and $spectrum_server and $filemanager_sid) {
         $stage = 'start_active_mode';
     }
     list($stage, $postinst_url) = explode(' ', $stage);
     if ($app_hashid) {
         $postinst_url = 'https://cp-spectrum.jino.ru/joomla/' . $app_hashid . '/settings/';
     }
     if (!in_process($stage)) {
         self::updateCPBlockAjax($stage);
     }
     $percent = get_percent($stage, $stage_since);
     if ($percent) {
         $percent = $percent . '%';
     }
     $mode = $filemanager_sid ? 'active' : 'passive';
     return array('stage' => $stage, 'percent' => $percent, 'postinst_url' => $postinst_url, 'mode' => $mode);
 }
Esempio n. 3
0
function get_subtasks($parent, $level = 1, $type = "", $where = "", $orderby = "", $bg = "", $preview = false)
{
    //echo "$orderby<br />";
    global $db, $slave, $priorities, $parent_task_id, $expand_collapse, $target_path, $total_tasks;
    if ($orderby != "") {
        $parent = null;
    }
    //if (!is_null($parent)) echo "parent is $parent";
    $expand_collapse = array("expand", "collapse");
    $creator_id = $_SESSION['user_id'];
    if ($_SESSION['project_user_id']) {
        $creator_id = $_SESSION['project_user_id'];
    }
    if (($_GET['today'] or $_GET['user_id'] or $_GET['week']) and ($_GET['action'] != "complete" and $_GET['action'] != "log")) {
        $where2 = "LEFT OUTER JOIN Task_Acknowledgement as A ON T.Task_ID=A.Task_ID WHERE (A.Accepted=1 OR T.Creator_ID=" . $creator_id . ") AND ";
    } else {
        $where2 = "LEFT OUTER JOIN Task_Acknowledgement as A ON T.Task_ID=A.Task_ID WHERE ";
    }
    //$where2="WHERE ";
    if (!is_null($parent)) {
        if (strlen($where) == 4) {
            $where = "";
        }
        if ($parent === 0) {
            if ($_GET['assign']) {
                $where2 = $where2 . "(Parent_Task_ID={$parent} OR Parent_Task_ID NOT IN (SELECT Task_ID FROM Tasks as T2 LEFT OUTER JOIN User_Departments as D2 ON T2.Department_ID=D2.Department_ID LEFT OUTER JOIN Users as L2 ON D2.User_ID=L2.User_ID WHERE " . str_replace(".", "2.", substr($where, 4)) . ")) {$where}";
            } else {
                $where2 = $where2 . "(Parent_Task_ID={$parent} OR Parent_Task_ID NOT IN (SELECT Task_ID FROM Tasks as T2 LEFT OUTER JOIN User_Departments as D2 ON T2.Department_ID=D2.Department_ID LEFT OUTER JOIN Users as U2 ON D2.User_ID=U2.User_ID WHERE " . str_replace(".", "2.", substr($where, 4)) . ")) {$where}";
            }
        } else {
            $where2 = $where2 . "Parent_Task_ID={$parent} {$where}";
        }
    } else {
        $where2 = $where2 . substr($where, 4);
    }
    //$where2=$where2."T.Task_ID NOT IN (SELECT Parent_Task_ID FROM Tasks) $where"; //if (is_null($parent) AND $subtasks[$t]['Parent_Task_ID']>0)
    if ($type == "complete" and $orderby == "") {
        $orderby = "Log_date DESC, Task_Name";
    }
    //else if ($orderby=="" and $parent==0) $orderby="Task_Name";
    //else if ($orderby!="") $orderby=$orderby." Task_Name";
    if ($orderby and !strstr($orderby, "Task_Name")) {
        $orderby = "ORDER BY " . $orderby . " Task_Name";
    }
    if ($orderby and !strstr($orderby, "ORDER BY")) {
        $orderby = "ORDER BY " . $orderby;
    }
    if (!$orderby and $parent == 0) {
        $orderby2 = "ORDER BY Finish_Date IS NULL, Finish_Date";
    }
    if (!strstr($where, "L.User_ID")) {
        $log = "AND L.Log_Progress=100";
    }
    if (strstr($orderby, "Request_Username")) {
        $orderby = str_replace("Request_Username", "RL.Username", $orderby);
        $query = "SELECT T.*, Project_Name, Log_Date, AD.Department_Name as Affected_Department_Name, RL.Username FROM Login as RL, Users as U, Tasks as T LEFT OUTER JOIN Departments as AD ON T.Affected_Department=AD.Department_ID LEFT OUTER JOIN Projects as P ON T.Project_ID=P.Project_ID LEFT OUTER JOIN Task_Logs as L ON T.Task_ID=L.Task_ID {$log} LEFT OUTER JOIN User_Departments as D ON T.Department_ID=D.Department_ID LEFT OUTER JOIN Departments as M ON D.Department_ID=M.Department_ID LEFT OUTER JOIN Login as G ON T.User_ID=G.User_ID {$where2} AND U.User_ID=T.Request_User_ID AND U.User_ID=RL.User_ID GROUP BY T.Task_ID {$orderby} {$orderby2}";
        //echo $query;
    } elseif (strstr($orderby, "Username")) {
        $query = "SELECT T.*, Project_Name, Log_Date, AD.Department_Name as Affected_Department_Name FROM Tasks as T LEFT OUTER JOIN Departments as AD ON T.Affected_Department=AD.Department_ID LEFT OUTER JOIN Projects as P ON T.Project_ID=P.Project_ID LEFT OUTER JOIN Task_Logs as L ON T.Task_ID=L.Task_ID {$log} LEFT OUTER JOIN User_Departments as D ON T.Department_ID=D.Department_ID LEFT OUTER JOIN Departments as M ON D.Department_ID=M.Department_ID LEFT OUTER JOIN Users as U ON D.User_ID=U.User_ID LEFT OUTER JOIN Login as G ON T.User_ID=G.User_ID {$where2} GROUP BY T.Task_ID {$orderby} {$orderby2}";
    } else {
        $query = "SELECT T.*, Project_Name, Log_Date, AD.Department_Name as Affected_Department_Name FROM Tasks as T LEFT OUTER JOIN Departments as AD ON T.Affected_Department=AD.Department_ID LEFT OUTER JOIN Projects as P ON T.Project_ID=P.Project_ID LEFT OUTER JOIN Task_Logs as L ON T.Task_ID=L.Task_ID {$log} LEFT OUTER JOIN User_Departments as D ON T.Department_ID=D.Department_ID LEFT OUTER JOIN Users as U ON D.User_ID=U.User_ID {$where2} GROUP BY T.Task_ID {$orderby} {$orderby2}";
    }
    //echo $query;
    //exit;
    $subtasks = $slave->select($query);
    //where parents are not assigned to user
    if (is_null($parent)) {
        $query = "SELECT T.*, Project_Name, Log_Date, AD.Department_Name as Affected_Department_Name FROM Tasks as T LEFT OUTER JOIN Departments as AD ON T.Affected_Department=AD.Department_ID LEFT OUTER JOIN Projects as P ON T.Project_ID=P.Project_ID LEFT OUTER JOIN Task_Logs as L ON T.Task_ID=L.Task_ID {$log} LEFT OUTER JOIN User_Departments as D ON T.Department_ID=D.Department_ID LEFT OUTER JOIN Users as U ON D.User_ID=U.User_ID {$where2} GROUP BY T.Task_ID {$orderby} {$orderby2}";
    }
    /*
    $query="SELECT T.*, Project_Name, Log_Date FROM Tasks as T LEFT OUTER JOIN Projects as P ON T.Project_ID=P.Project_ID LEFT OUTER JOIN Task_Logs as L ON T.Task_ID=L.Task_ID $log LEFT OUTER JOIN User_Departments as D ON T.Department_ID=D.Department_ID LEFT OUTER JOIN Users as U ON D.User_ID=U.User_ID $where2 AND Finish_Date IS NULL GROUP BY T.Task_ID ORDER BY $orderby Task_Name";
    $subtasks2 = $slave->select($query);
    if ($subtasks2) {
    if ($subtasks) $subtasks=array_merge($subtasks,$subtasks2);
    else $subtasks=$subtasks2;
    }
    */
    //if ($_SESSION['user_id']==6) print_r($subtasks);
    $expand = true;
    if ($level == 0 and $type != "option") {
        if ($type == "date") {
            echo "<form action=\"tasks.php\" method=\"GET\" onSubmit=\"this.today.value=this.today.value.replace(/(\\d\\d)\\/(\\d\\d)\\/(\\d\\d\\d\\d)/, '\$3-\$1-\$2')\">\n";
            echo "View Date <input name=\"today\" type=\"text\" value=\"" . display_date($_GET['today']) . "\" onfocus=\"this.select();lcs(this)\" onclick=\"event.cancelBubble=true;this.select();lcs(this)\"/>";
            echo "<input type=\"submit\" value=\"Go\">";
            echo "</form>\n";
        }
        if ($type != "complete") {
            echo "<div id=\"expand\">";
            $expand = false;
            if ($_SESSION['expand']['all'] == 1) {
                echo "<a href=\"" . clean_url($expand_collapse) . "expand=none\"><img src=\"" . CDN . "img/collapse.png\" alt=\"Collapse\" /></a>";
            } else {
                echo "<a href=\"" . clean_url($expand_collapse) . "expand=all\"><img src=\"" . CDN . "img/expand.png\" alt=\"Expand\" /></a>";
            }
            echo " all</div>\n";
        }
    }
    if ($subtasks) {
        if ($level == 0 and $type != "option") {
            echo "<table><tr>";
            //if ($type!="complete") echo "<th><a href=".get_order_url('T.Progress',$dir).">Work</a></th>";
            echo "<th>&nbsp;</th>";
            echo "<th><a href=" . get_order_url('T.Priority', $dir) . ">Severity</a></th>";
            echo "<th><a href=" . get_order_url('T.Task_ID', $dir) . ">ID</a></th>";
            echo "<th><a href=" . get_order_url('Task_Name', $dir) . ">Task</a></th>";
            echo "<th><a href=" . get_order_url('Project_Name', $dir) . ">Project</a></th>";
            echo "<th><a href=" . get_order_url('Affected_Department_Name', $dir) . ">Department</a></th>";
            echo "<th>File</th>";
            echo "<th><a href=" . get_order_url('Username', $dir) . ">Assigned</a></th>";
            echo "<th>Last</th>";
            echo "<th><a href=" . get_order_url('Request_Username', $dir) . ">Request</a></th>";
            echo "<th nowrap><a href=" . get_order_url('T.Request_Date', $dir) . ">Req Date</a></th>";
            if ($type == "complete") {
                echo "<th><a href=" . get_order_url('L.Log_Date', $dir) . ">Completed</a></th>";
            } else {
                echo "<th><a href=" . get_order_url('T.Finish_Date', $dir) . ">Due</a></th>";
            }
            if ($type != "complete") {
                echo "<th>Days</th>";
            }
            echo "</tr>\n";
        }
        $space = str_repeat(' &nbsp; ', $level);
        $ptid = 0;
        for ($t = 0; $t < count($subtasks); $t++) {
            $total_tasks[$priorities[$subtasks[$t]['Priority']]['Name']]++;
            if ($type != "option" and $type != "complete" and (is_null($parent) or $parent === 0) and $subtasks[$t]['Parent_Task_ID'] > 0 and $subtasks[$t]['Parent_Task_ID'] != $ptid) {
                $ptid = $subtasks[$t]['Parent_Task_ID'];
                echo "<tr {$bg} class=\"gray\">";
                echo "<td>&nbsp;</td>";
                echo "<td>&nbsp;</td>";
                echo "<td>&nbsp;</td>";
                echo "<td colspan=\"10\"><small>";
                get_parent($ptid, true);
                echo "</small></td>";
                echo "</tr>\n";
            } else {
                $ptid = $subtasks[$t]['Parent_Task_ID'];
            }
            $small_img = $use_file = "";
            $expand = false;
            if ($preview == true or !$_SESSION['expand'] or $_SESSION['expand']['all'] == 1 and (!isset($_SESSION['expand'][$subtasks[$t]['Task_ID']]) or $_SESSION['expand'][$subtasks[$t]['Task_ID']] != 0) or $_SESSION['expand']['all'] == 0 and $_SESSION['expand'][$subtasks[$t]['Task_ID']] == 1) {
                $expand = true;
            }
            if ($type == "option") {
                echo "<option value=\"" . $subtasks[$t]['Task_ID'] . "\"";
                if ($subtasks[$t]['Task_ID'] == $parent_task_id) {
                    echo " selected";
                }
                echo ">" . $space . $subtasks[$t]['Task_Name'] . "</option>\n";
            } else {
                $num_sub = 0;
                $percent_sub = $subtasks[$t]['Progress'];
                if ($type == "complete") {
                    $finish_date = $subtasks[$t]['Log_Date'];
                } else {
                    $finish_date = $subtasks[$t]['Finish_Date'];
                }
                //if (!is_null($parent))
                list($num_sub, $percent_sub, $finish_date) = get_percent($subtasks[$t]['Task_ID'], $num_sub, $percent_sub, $finish_date);
                //$finish_date=$subtasks[$t]['Finish_Date'];
                //if ($subtasks[$t]['Log_Date']) $finish_date=$subtasks[$t]['Log_Date'];
                //if ($level==0) {
                //    if ($t%2==0) $bg="class=\"highlight\"";
                //    else $bg="";
                //}
                //$haschildren=$slave->select("SELECT * FROM Tasks WHERE Parent_Task_ID=".$subtasks[$t]['Task_ID']);
                //$users=$slave->select("SELECT IF (UD.User_ID IS NOT NULL, UD.User_ID, U.User_ID) AS User_ID, Username, U.First_Name, U.Last_Name, Department_Name FROM Task_Users as T LEFT OUTER JOIN User_Departments as UD ON T.Department_ID=UD.Department_ID AND UD.User_ID=6 LEFT OUTER JOIN Departments as D ON UD.Department_ID=D.Department_ID LEFT OUTER JOIN Users as U ON T.User_ID=U.User_ID AND U.User_ID=6 LEFT OUTER JOIN Login as L ON U.User_ID=L.User_ID WHERE Task_ID=".$subtasks[$t]['Task_ID']." ORDER BY IF (Department_Name IS NOT NULL, Department_Name, Username)");
                //if ((!$haschildren AND $user) OR ($haschildren)) {
                echo "<tr {$bg}>";
                //if ($type!="complete") {
                echo "<td align='right' nowrap>";
                if (!$preview and $num_sub > 0) {
                    //echo number_format($percent_sub/$num_sub,1)."% ";
                    if ($expand == true) {
                        echo "<a href=\"" . clean_url($expand_collapse) . "collapse=" . $subtasks[$t]['Task_ID'] . "\" class=\"expand\"><img src=\"" . CDN . "img/collapse.png\" alt=\"Collapse\" /></a>";
                    } else {
                        echo "<a href=\"" . clean_url($expand_collapse) . "expand=" . $subtasks[$t]['Task_ID'] . "\" class=\"expand\"><img src=\"" . CDN . "img/expand.png\" alt=\"Expand\" /></a>";
                    }
                }
                //else if ($type=="complete") echo $percent_sub."%";
                //else echo $percent_sub."%";
                //if ($percent_sub<100) echo " | <a href=\"tasks.php?work=".$subtasks[$t]['Task_ID']."\">Add</a>";
                echo "</td>";
                //}
                if ($preview) {
                    echo "<td></td><td></td>\n";
                } else {
                    echo "<td nowrap><small>";
                    if ($subtasks[$t]['High_Priority']) {
                        echo "<img src=\"" . CDN . "img/fire.png\" alt=\"High Priority\" />\n";
                    }
                    echo $subtasks[$t]['Priority'] . " " . $priorities[$subtasks[$t]['Priority']]['Name'] . "</small></td>";
                    echo "<td><small>" . $subtasks[$t]['Task_ID'] . "</small></td>";
                }
                echo "<td>";
                if ($preview) {
                    echo "<small>";
                }
                if ($type != "complete" and $level > 0) {
                    echo "{$space} - ";
                } elseif (is_null($parent) and $subtasks[$t]['Parent_Task_ID'] > 0) {
                    echo "{$space} - ";
                    //echo "…";
                }
                echo "<a href=\"tasks.php?task_id=" . $subtasks[$t]['Task_ID'] . "\"";
                if ($subtasks[$t]['Parent_Task_ID'] > 0) {
                    $pname = $slave->select("SELECT Task_Name FROM Tasks WHERE Task_ID=" . $subtasks[$t]['Parent_Task_ID']);
                    echo "title=\"" . $pname[0]['Task_Name'] . "\"";
                }
                if ($subtasks[$t]['Progress'] == 100) {
                    echo "><strike>" . $subtasks[$t]['Task_Name'] . "</strike></a>";
                } else {
                    echo ">" . $subtasks[$t]['Task_Name'] . "</a>";
                }
                //get_child($subtasks[$t]['Task_ID'],true);
                if ($preview) {
                    echo "</small>";
                }
                echo "</td>";
                echo "<td nowrap>";
                if ($subtasks[$t]['Project_ID']) {
                    echo "<small><a href=\"projects.php?project_id=" . $subtasks[$t]['Project_ID'] . "\">" . $subtasks[$t]['Project_Name'] . "</a></small></td>";
                } else {
                    echo "<small>Non Project Ticket</small>";
                }
                echo "</td>";
                echo "<td nowrap><small>";
                if ($subtasks[$t]['Affected_Department'] > 0) {
                    //$afdep=$slave->select("SELECT Department_Name FROM Departments WHERE Department_ID=".$subtasks[$t]['Affected_Department']);
                    echo $subtasks[$t]['Affected_Department_Name'];
                } else {
                    echo "No Department";
                }
                echo "</small></td>";
                echo "<td align=\"center\">";
                /*
                if ($handle = opendir($target_path)) {
                while (false !== ($file = readdir($handle))) {
                if (preg_match('/^'.$subtasks[$t]['Task_ID'].'.+/',$file)) {
                if (strstr($file,'_sm.jpg')) $small_img=$file;
                else $use_file=$file;
                }
                }
                closedir($handle);
                } else echo "could not open";
                
                if ($small_img) echo "<a href=\"${target_path}$use_file\" target=\"_blank\"><img src=\"".CDN."img/icons/111.png\" border=0 /></a>";
                else if ($use_file) echo "<a href=\"${target_path}$use_file\" target=\"_blank\"><img src=\"".CDN."img/icons/3.png\" border=0 /></a>";
                */
                $files = $slave->select("SELECT * FROM Files as F, File_Types as T WHERE F.File_Type_ID=T.File_Type_ID AND Task_ID=" . $subtasks[$t]['Task_ID'] . " ORDER BY Image");
                if ($files) {
                    $img = $multi = "";
                    foreach ($files as $f) {
                        if ($img != $f['Image'] or $img == 0) {
                            $img = $f['Image'];
                            if ($f['Image'] == 1) {
                                $icon = "111.png";
                                echo "<a href=\"" . CDN . "img.php?id=" . $subtasks[$t]['Task_ID'] . "\" alt=\"\" target=\"_blank\"><img src=\"" . CDN . "img/icons/{$icon}\" border=0 /></a>";
                            } else {
                                $icon = "3.png";
                                echo "<a href=\"{$target_path}" . $f['File_ID'] . "." . $f['Extention'] . "\" alt=\"\" target=\"_blank\"><img src=\"" . CDN . "img/icons/{$icon}\" border=0 /></a>";
                            }
                        } elseif ($img == 1) {
                            $mult = "+";
                        }
                    }
                    echo $mult;
                }
                echo "</td>";
                echo "<td><small>";
                $users = $slave->select("SELECT IF (UD.User_ID IS NOT NULL, UD.User_ID, U.User_ID) AS User_ID, Username, U.First_Name, U.Last_Name, Department_Name FROM Tasks as T LEFT OUTER JOIN User_Departments as UD ON T.Department_ID=UD.Department_ID LEFT OUTER JOIN Departments as D ON UD.Department_ID=D.Department_ID LEFT OUTER JOIN Users as U ON T.User_ID=U.User_ID LEFT OUTER JOIN Login as L ON U.User_ID=L.User_ID WHERE Task_ID=" . $subtasks[$t]['Task_ID'] . " ORDER BY IF (Department_Name IS NOT NULL, Department_Name, Username)");
                if ($users) {
                    $dep = "";
                    for ($u = 0; $u < count($users); $u++) {
                        if ($u > 0 && ($users[$u]['Department_Name'] == "" or $users[$u]['Department_Name'] != $dep)) {
                            echo ", ";
                        }
                        if ($users[$u]['Department_Name']) {
                            if ($users[$u]['Department_Name'] != $dep) {
                                $dep = $users[$u]['Department_Name'];
                                echo $users[$u]['Department_Name'];
                            }
                        } else {
                            echo $users[$u]['Username'];
                        }
                    }
                } else {
                    echo "none";
                }
                echo "</small></td>";
                echo "<td><small>";
                $users = $slave->select("SELECT U.User_ID, Username, U.First_Name, U.Last_Name FROM Tasks as T, Task_Logs as L, Users as U, Login as O WHERE T.Task_ID=L.Task_ID AND L.User_ID=U.User_ID AND O.User_ID=U.User_ID AND T.Task_ID=" . $subtasks[$t]['Task_ID'] . " ORDER BY Log_ID DESC LIMIT 1");
                if (!$users) {
                    $users = $slave->select("SELECT U.User_ID, Username, U.First_Name, U.Last_Name FROM Tasks as T, Users as U, Login as O WHERE T.Creator_ID=U.User_ID AND O.User_ID=U.User_ID AND T.Task_ID=" . $subtasks[$t]['Task_ID']);
                }
                if ($users) {
                    echo $users[0]['Username'];
                } else {
                    echo "none";
                }
                echo "</small></td>";
                echo "<td><small>";
                $users = $slave->select("SELECT U.User_ID, Username, U.First_Name, U.Last_Name FROM Tasks as T, Users as U, Login as L WHERE U.User_ID=L.User_ID AND T.Request_User_ID=U.User_ID AND Task_ID=" . $subtasks[$t]['Task_ID']);
                if ($users) {
                    echo $users[0]['Username'];
                } else {
                    echo "none";
                }
                echo "</small></td>";
                if (display_date($subtasks[$t]['Request_Date']) == "00/00/0000" or display_date($subtasks[$t]['Request_Date']) == "NULL") {
                    echo "<td>Not Set</td>";
                } else {
                    echo "<td><small>" . display_date($subtasks[$t]['Request_Date']) . "</small></td>";
                }
                //echo "<td>".$subtasks[$t]['Durration']."</td>";
                //$isparent=$slave->select("SELECT Task_ID FROM Tasks WHERE Parent_Task_ID=".$subtasks[$t]['Task_ID']);
                //if ($isparent) {
                //    echo "<td>&nbsp;</td>";
                //} else
                if (display_date($finish_date) == "NULL") {
                    echo "<td><small>Not Set</small></td>";
                    if ($type != "complete") {
                        echo "<td>-</td>";
                    }
                } else {
                    echo "<td><small>" . display_date($finish_date) . "</small></td>";
                    if ($type != "complete" and $subtasks[$t]['Progress'] < 100) {
                        echo "<td><small>" . dateDiff(date("Y-m-d"), $finish_date) . "</small></td>";
                    }
                }
                echo "</tr>\n";
                if ($expand == true and ($_GET['today'] or $_GET['week']) and !isset($parent_task_id)) {
                    get_subtasks($subtasks[$t]['Task_ID'], $level + 1, "", "AND T.Progress<100", "", "class=\"gray\"", true);
                }
                if ($expand == true and $parent === 0) {
                    get_subtasks($subtasks[$t]['Task_ID'], $level + 1, "", "AND T.Progress<100 AND NOT (T.User_ID=" . $_SESSION['user_id'] . " OR U.User_ID=" . $_SESSION['user_id'] . ")", "", "class=\"gray\"", true);
                }
                //}
            }
            if ($expand === true and !is_null($parent) and !$preview) {
                get_subtasks($subtasks[$t]['Task_ID'], $level + 1, $type, $where, $orderby, $bg);
            }
            //if ($add=="no")
            //$space=str_replace('/ &nbsp; $/','',$space);
        }
        if ($level == 0 and $type != "option") {
            echo "</table>";
            echo "<p>";
            $totaltt = 0;
            foreach ($total_tasks as $tk => $tv) {
                echo "Total {$tk} Tasks: {$tv}<br />";
                $totaltt = $totaltt + $tv;
            }
            echo "Grand Total: {$totaltt}";
            echo "</p>\n";
        }
    } else {
        if ($level == 0 and $type != "option") {
            echo "<h2 align=\"center\">No Tasks</h2>";
        }
        return false;
    }
}
}
function isCoordinator($student, $session)
{
    if ($session['coordinator'] == "1" && $session['year_pass'] == $student['year_pass']) {
        return true;
    } else {
        return false;
    }
}
$output = array();
//print_r($students_search);
foreach ($students_search as $student) {
    $enc_usr = $this->encrypt->encode($student["username"] . "@#\$");
    //print_r($marks_search);
    $cgpa = get_cgpa($student["regno"], $marks_search);
    $percent = get_percent($student["regno"], $marks_search);
    $arrier = get_arrier($student["regno"], $marks_search);
    //echo "perc:".$percent;
    if (!($percent >= $this->input->post('percent_min') && $percent <= $this->input->post('percent_max'))) {
        // echo "here";
        continue;
    }
    if (!($cgpa >= $this->input->post('cgpa_min') && $cgpa <= $this->input->post('cgpa_max'))) {
        // echo "here";
        continue;
    }
    if (!($arrier >= $this->input->post('arrier_min') && $arrier <= $this->input->post('arrier_max'))) {
        // echo "here1";
        continue;
    }
    $privacy_settings = array("privacy_profile_pic" => $student["privacy_profile_pic"], "privacy_personal" => $student["privacy_personal"], "privacy_academic" => $student["privacy_academic"], "privacy_resume" => $student["privacy_resume"]);
    <div class="container">
<input id="year_pass" name="year_pass" type="hidden" value="<?php 
echo $session["year_pass"];
?>
">
        <div class="row about">
            <div class="col-md-12">
                <div id="container_id" class="home_steps well text-justify noborder">
                    <h2>Marks</h2>
                    <br>
                    <br>
                    <?php 
if (isset($marks_details[0])) {
    ?>
                    <h4 class="text-center">Percentage : <?php 
    echo get_percent($marks_details[0]['regno'], $marks_details);
    ?>
%</h4>
                    <h4 class="text-center">CGPA : <?php 
    echo get_cgpa($marks_details[0]['regno'], $marks_details);
    ?>
</h4>
                    <h4 class="text-center">Arriers : <?php 
    echo get_arriers($marks_details[0]['regno'], $marks_details);
    ?>
</h4>
                    <br>
                    <br>
                    <?php 
}
?>
/**
 * Return grade for given user or all users.
 *
 * @param int $attforblockid id of attforblock
 * @param int $userid optional user id, 0 means all users
 * @return array array of grades, false if none
 */
function attforblock_get_user_grades($attforblock, $userid = 0)
{
    global $CFG;
    require_once 'locallib.php';
    if (!($course = get_record('course', 'id', $attforblock->course))) {
        error("Course is misconfigured");
    }
    $result = false;
    if ($userid) {
        $result = array();
        $result[$userid]->userid = $userid;
        $result[$userid]->rawgrade = $attforblock->grade * get_percent($userid, $course) / 100;
    } else {
        if ($students = get_course_students($course->id)) {
            $result = array();
            foreach ($students as $student) {
                $result[$student->id]->userid = $student->id;
                $result[$student->id]->rawgrade = $attforblock->grade * get_percent($student->id, $course) / 100;
            }
        }
    }
    return $result;
}
function print_attendance_table($user, $course)
{
    $complete = get_attendance($user->id, $course);
    $percent = get_percent($user->id, $course) . '&nbsp;%';
    $grade = get_grade($user->id, $course);
    echo '<table border="0" cellpadding="0" cellspacing="0" class="list">';
    attendance_print_row(get_string('sessionscompleted', 'attforblock') . ':', "<strong>{$complete}</strong>");
    $statuses = get_statuses($course->id);
    foreach ($statuses as $st) {
        attendance_print_row($st->description . ': ', '<strong>' . get_attendance($user->id, $course, $st->id) . '</strong>');
    }
    attendance_print_row(get_string('attendancepercent', 'attforblock') . ':', "<strong>{$percent}</strong>");
    attendance_print_row(get_string('attendancegrade', 'attforblock') . ':', "<strong>{$grade}</strong> / " . get_maxgrade($user->id, $course));
    attendance_print_row('&nbsp;', '&nbsp;');
    echo '</table>';
}
            $table->data[$student->id][] = print_user_picture($student->id, $course->id, $student->picture, 20, true, true);
            $table->data[$student->id][] = "<a href=\"view.php?id={$id}&amp;student={$student->id}\">" . fullname($student) . '</a>';
            foreach ($course_sess as $sessdata) {
                if ($att = get_record('attendance_log', 'sessionid', $sessdata->id, 'studentid', $student->id)) {
                    if (isset($statuses[$att->statusid])) {
                        $table->data[$student->id][] = $statuses[$att->statusid]->acronym;
                    } else {
                        $table->data[$student->id][] = '<font color="red"><b>' . $allstatuses[$att->statusid]->acronym . '</b></font>';
                    }
                } else {
                    $table->data[$student->id][] = '-';
                }
            }
            foreach ($statuses as $st) {
                $table->data[$student->id][] = get_attendance($student->id, $course, $st->id);
            }
            $table->data[$student->id][] = get_grade($student->id, $course) . '&nbsp;/&nbsp;' . get_maxgrade($student->id, $course);
            $table->data[$student->id][] = get_percent($student->id, $course) . '%';
        }
        echo '<br />';
        print_table($table);
    } else {
        print_heading(get_string('nothingtodisplay'), 'center');
    }
    echo get_string('status', 'attforblock') . ':<br />';
    foreach ($statuses as $st) {
        echo $st->acronym . ' - ' . $st->description . '<br />';
    }
}
print_footer($course);
exit;
            if (isset($fromform->ident['id'])) {
                $data->table[$i][] = $student->id;
            }
            if (isset($fromform->ident['uname'])) {
                $data->table[$i][] = $student->username;
            }
            $data->table[$i][] = $student->lastname;
            $data->table[$i][] = $student->firstname;
            foreach ($sessions as $sess) {
                if ($rec = $DB->get_record('attendance_log', array('sessionid' => $sess->id, 'studentid' => $student->id))) {
                    $data->table[$i][] = $statuses[$rec->statusid]->acronym;
                } else {
                    $data->table[$i][] = '-';
                }
            }
            $data->table[$i][] = get_percent($student->id, $course) . '%';
            $i++;
        }
        if ($fromform->format === 'text') {
            ExportToCSV($data, $filename);
        } else {
            ExportToTableEd($data, $filename, $fromform->format);
        }
        exit;
    } else {
        print_error('Students not found!', 'report.php?id=' . $id);
    }
} else {
    /// Print headers
    $navlinks[] = array('name' => $attforblock->name, 'link' => "view.php?id={$id}", 'type' => 'activity');
    $navlinks[] = array('name' => get_string('export', 'quiz'), 'link' => null, 'type' => 'activityinstance');
Esempio n. 10
0
function print_query_table($field_title, $db_field, $contrib_hash)
{
    global $total_hash;
    print "<table border=\"1\" width=100%\n";
    print "<tr>\n";
    print "<th align=center bgcolor='" . THCOLOR . "'>\n";
    print $field_title . "\n";
    print "</th>\n";
    print "<th align=center colspan=2 bgcolor='" . LYELLOW . "'>\n";
    print "MPI Installs\n";
    print "</th>\n";
    print "<th align=center colspan=2 bgcolor='" . LGREEN . "'>\n";
    print "Test Builds\n";
    print "</th>\n";
    print "<th align=center colspan=2 bgcolor='" . LRED . "'>\n";
    print "Test Runs\n";
    print "</th>\n";
    print "<th align=center colspan=2 bgcolor='" . LBLUE . "'>\n";
    print "Performance Runs\n";
    print "</th>\n";
    print "<tr>\n";
    print "<th align=center bgcolor='" . THCOLOR . "'>\n";
    print "&nbsp;\n";
    print "</th>\n";
    for ($i = 0; $i < 4; ++$i) {
        print "<th align=center bgcolor='" . THCOLOR . "'>\n";
        print "# Tests\n";
        print "</th>\n";
        print "<th align=center bgcolor='" . THCOLOR . "'>\n";
        print "% Contrib\n";
        print "</th>\n";
    }
    print "</tr>\n";
    for ($i = 0; $i < sizeof($contrib_hash); ++$i) {
        print "<tr>\n";
        print "<td align=right>\n";
        if (0 < strlen($contrib_hash[$i][$db_field])) {
            print $contrib_hash[$i][$db_field] . "\n";
        } else {
            print "Unknown\n";
        }
        print "</td>\n";
        print "<td align=right bgcolor='" . LYELLOW . "'>\n";
        print pretty_print_big_num($contrib_hash[$i]["mpi_install"]) . "\n";
        print "</td>\n";
        print "<td align=right bgcolor='" . LYELLOW . "'>\n";
        printf("%4.1f %s\n", get_percent($contrib_hash[$i]["mpi_install"], $total_hash[0]["mpi_install"]), "%");
        print "</td>\n";
        print "<td align=right bgcolor='" . LGREEN . "'>\n";
        print pretty_print_big_num($contrib_hash[$i]["test_build"]) . "\n";
        print "</td>\n";
        print "<td align=right bgcolor='" . LGREEN . "'>\n";
        printf("%4.1f %s\n", get_percent($contrib_hash[$i]["test_build"], $total_hash[0]["test_build"]), "%");
        print "</td>\n";
        print "<td align=right bgcolor='" . LRED . "'>\n";
        print pretty_print_big_num($contrib_hash[$i]["test_run"]) . "\n";
        print "</td>\n";
        print "<td align=right bgcolor='" . LRED . "'>\n";
        printf("%4.1f %s\n", get_percent($contrib_hash[$i]["test_run"], $total_hash[0]["test_run"]), "%");
        print "</td>\n";
        print "<td align=right bgcolor='" . LBLUE . "'>\n";
        print pretty_print_big_num($contrib_hash[$i]["perf"]) . "\n";
        print "</td>\n";
        print "<td align=right bgcolor='" . LBLUE . "'>\n";
        printf("%4.1f %s\n", get_percent($contrib_hash[$i]["perf"], $total_hash[0]["perf"]), "%");
        print "</td>\n";
        print "</tr>\n";
    }
    print "<tr><b>\n";
    print "<th align=right>\n";
    print "Total\n";
    print "</th>\n";
    print "<th align=right>\n";
    print pretty_print_big_num($total_hash[0]["mpi_install"]) . "\n";
    print "</th>\n";
    print "<th align=right>\n";
    print "100.0 %\n";
    print "</th>\n";
    print "<th align=right>\n";
    print pretty_print_big_num($total_hash[0]["test_build"]) . "\n";
    print "</th>\n";
    print "<th align=right>\n";
    print "100.0 %\n";
    print "</th>\n";
    print "<th align=right>\n";
    print pretty_print_big_num($total_hash[0]["test_run"]) . "\n";
    print "</th>\n";
    print "<th align=right>\n";
    print "100.0 %\n";
    print "</th>\n";
    print "<th align=right>\n";
    print pretty_print_big_num($total_hash[0]["perf"]) . "\n";
    print "</th>\n";
    print "<th align=right>\n";
    print "100.0 %\n";
    print "</th>\n";
    print "</tr>\n";
    print "</table>\n";
}
                         foreach ($statuses as $st) {
                             echo '<th>' . $st->description . '</th>';
                         }
                         echo '<th>' . get_string('grade') . '</th>';
                         echo '<th>%</th></tr><tr><td></td>';
                         echo '</tr></thead>';
                         echo '<tbody><tr>';
                         echo '<td id="tshowstudent" name="tshowstudent">';
                         echo "<a href=\"view.php?id={$id}&amp;student={$student->id}\">" . fullname($student);
                         echo '</a></td><td id="tshowcourse" name="tshowcourse">';
                         echo "<a href=\"{$CFG->wwwroot}/course/view.php?id={$course->id}\">" . $course->fullname . '</a></td>';
                         foreach ($statuses as $st) {
                             echo '<td>' . get_attendance($student->id, $course, $st->id) . '</td>';
                         }
                         echo '<td>' . get_grade($studentselected, $course) . '&nbsp;/&nbsp;' . get_maxgrade($student->id, $course) . '</td>';
                         echo '<td>' . get_percent($studentselected, $course) . '%' . '</td>';
                         echo '</tr></tbody></table>';
                     }
                     if ($reportselected === 'all' or $reportselected === 'detailed') {
                         echo '<h3>' . "<a href=\"{$CFG->wwwroot}/course/view.php?id={$course->id}\">" . $course->fullname . '</a></h3>';
                         print_detailed_report($studentselected, $cm, $course->id);
                     }
                 }
             }
         }
     }
     if ($reportselected === 'detailed') {
         echo '</table>';
     }
 }
 print_footer($course);
Esempio n. 12
0
/**
 * Return grade for given user or all users.
 *
 * @param int $attforblockid id of attforblock
 * @param int $userid optional user id, 0 means all users
 * @return array array of grades, false if none
 */
function attforblock_get_user_grades($attforblock, $userid = 0)
{
    global $CFG, $DB;
    require_once 'locallib.php';
    if (!($course = $DB->get_record('course', array('id' => $attforblock->course)))) {
        error("Course is misconfigured");
    }
    $result = false;
    if ($userid) {
        $result = array();
        $result[$userid]->userid = $userid;
        $result[$userid]->rawgrade = $attforblock->grade * get_percent($userid, $course) / 100;
    } else {
        $sql = "SELECT u.id\n            FROM {user} u \n            INNER JOIN {role_assignments} ra on u.id=ra.userid \n            INNER JOIN {role_capabilities} rc ON ra.roleid=rc.roleid \n            INNER JOIN {context} c ON c.id=ra.contextid \n            LEFT OUTER JOIN {user_lastaccess} ul on ul.userid=ra.userid\n            WHERE rc.contextid = ?";
        //if ($students = get_course_students($course->id)) {
        if ($students = $DB->get_records_sql($sql, array($course->id))) {
            $result = array();
            foreach ($students as $student) {
                $result[$student->id]->userid = $student->id;
                $result[$student->id]->rawgrade = $attforblock->grade * get_percent($student->id, $course) / 100;
            }
        }
    }
    return $result;
}
function print_attendance_line($student, $course)
{
    echo '<table class="generaltable"><thead><tr>';
    foreach ($statuses as $st) {
        echo '<th>' . $st->description . '</th>';
    }
    echo '<th>' . get_string('grade') . '</th>';
    echo '<th>%</th></tr><tr><td></td>';
    echo '</tr></thead><tbody><tr>';
    foreach ($statuses as $st) {
        echo '<td>' . get_attendance($student->id, $course, $st->id) . '</td>';
    }
    echo '<td>' . get_grade($student, $course) . '&nbsp;/&nbsp;' . get_maxgrade($student->id, $course) . '</td>';
    echo '<td>' . get_percent($student, $course) . '%' . '</td>';
    echo '</tr></tbody></table>';
}
Esempio n. 14
0
function get_post_viewed_coverage($view_type = 'normal', $time_span = 'total', $output_type = 'content', $direction = '+', $percent = '')
{
    global $wpdb;
    $post_count = $wpdb->get_var($wpdb->prepare("SELECT count(ID) FROM " . WP_POST_TABLE . " where post_date < '" . current_time('mysql') . "' AND post_status = 'publish' AND post_password = ''", APP_POST_TYPE));
    $need_count = get_post_viewed_count($view_type, $time_span, $output_type);
    if ($direction == '+') {
        if ($percent == '%') {
            return get_percent($need_count / $post_count);
        } else {
            if ($percent == '100') {
                return ceil($need_count / $post_count * 100);
            } else {
                return number_format($need_count / $post_count, 2, '.', '');
            }
        }
    } else {
        if ($percent == '%') {
            return get_percent(1 - $need_count / $post_count);
        } else {
            if ($percent == '100') {
                return ceil((1 - $need_count / $post_count) * 100);
            } else {
                return number_format(1 - $need_count / $post_count, 2, '.', '');
            }
        }
    }
}