예제 #1
0
function validatebadge($badgeid, $cid, $req, $userid = 0)
{
    //get student's scores
    global $secfilter;
    global $canviewall;
    if (isset($userid) && $userid != 0) {
        require "gbtable2.php";
        $secfilter = -1;
        $canviewall = true;
        $gbt = gbtable($userid);
    }
    $query = "SELECT id,name FROM imas_gbcats WHERE courseid='{$cid}' ORDER BY name";
    $result = mysql_query($query) or die("Query failed : " . mysql_error());
    $gtypes = array('0' => 'Past Due', '3' => 'Past and Attempted', '1' => 'Past and Available', '2' => 'All Items');
    $gbcats = array();
    while ($row = mysql_fetch_row($result)) {
        $gbcats[$row[0]] = $row[1];
    }
    $reqnameout = array();
    $reqout = array();
    $stuout = array();
    $metout = array();
    $reqmet = true;
    foreach ($req['data'] as $r) {
        //r = array(gbcat, gradetype, score)
        $metthis = false;
        if ($r[0] > 0) {
            //is a category total
            $reqnameout[] = $gbcats[$r[0]] . ' (' . $gtypes[$r[1]] . ')';
        } else {
            $reqnameout[] = 'Course Total (' . $gtypes[$r[1]] . ')';
        }
        $reqout[] = $r[2] . '%';
        if (isset($userid) && $userid != 0) {
            if ($r[0] > 0) {
                //is a category total
                foreach ($gbt[0][2] as $i => $catinfo) {
                    if ($catinfo[10] == $r[0]) {
                        //found category
                        if ($r[1] == 3) {
                            $mypercent = round(100 * $gbt[1][2][$i][3] / $gbt[1][2][$i][4], 1);
                        } else {
                            if ($catinfo[$r[1] + 3] == 0) {
                                $mypercent = 0;
                            } else {
                                $mypercent = round(100 * $gbt[1][2][$i][$r[1]] / $catinfo[$r[1] + 3], 1);
                            }
                        }
                        $stuout[] = $mypercent . '%';
                        if ($mypercent >= $r[2]) {
                            $metthis = true;
                        }
                    }
                }
            } else {
                //is a course total
                if ($r[1] == 3) {
                    //past and attempted
                    if ($gbt[1][3][8] == null) {
                        $mypercent = $gbt[1][3][6];
                    } else {
                        $mypercent = $gbt[1][3][8];
                    }
                } else {
                    if ($gbt[1][3][3 + $r[1]] == null) {
                        $mypercent = $gbt[1][3][$r[1]];
                    } else {
                        $mypercent = $gbt[1][3][3 + $r[1]];
                    }
                }
                $stuout[] = $mypercent . '%';
                if ($mypercent >= $r[2]) {
                    $metthis = true;
                }
            }
            if ($metthis == true) {
                $metout[] = 'Yes!';
            } else {
                $metout[] = 'No';
                $reqmet = false;
            }
        }
    }
    if ($reqmet) {
        if (isset($userid) && $userid != 0) {
            $query = "SELECT FirstName, LastName, email FROM imas_users WHERE id={$userid}";
            $result = mysql_query($query) or die("Query failed : " . mysql_error());
            $row = mysql_fetch_row($result);
            $stuname = $row[1] . ', ' . $row[0];
            $email = $row[2];
            $data = array($reqnameout, $reqout, $stuout, $metout, $stuname, $email);
            $data = addslashes(serialize($data));
            $query = "UPDATE imas_badgerecords SET data='{$data}' WHERE badgeid='{$badgeid}' AND userid='{$userid}'";
            mysql_query($query) or die("Query failed : " . mysql_error());
            if (mysql_affected_rows() == 0) {
                //no existing record
                $query = "INSERT INTO imas_badgerecords (badgeid,userid,data) VALUES ('{$badgeid}','{$userid}','{$data}')";
                mysql_query($query) or die("Query failed : " . mysql_error());
            }
        } else {
            $stuname = '';
            $email = '';
        }
        return array($reqnameout, $reqout, $stuout, $metout, $stuname, $email);
    } else {
        return false;
    }
}
예제 #2
0
     //	echo 'This page is only relevant to student.';
     //} else if (!isset($studentid)) {
     //	echo 'You are not authorized to view this page.';
 } else {
     $badgeid = intval($_GET['badgeid']);
     $query = "SELECT name, requirements FROM imas_badgesettings WHERE id={$badgeid} AND courseid='{$cid}'";
     $result = mysql_query($query) or die("Query failed : " . mysql_error());
     if (mysql_num_rows($result) == 0) {
         echo 'Invalid badge ID for this course';
     } else {
         list($name, $req) = mysql_fetch_row($result);
         $req = unserialize($req);
         //get student's scores
         require "gbtable2.php";
         $secfilter = -1;
         $gbt = gbtable($userid);
         $query = "SELECT id,name FROM imas_gbcats WHERE courseid='{$cid}' ORDER BY name";
         $result = mysql_query($query) or die("Query failed : " . mysql_error());
         $gtypes = array('0' => 'Past Due', '3' => 'Past and Attempted', '1' => 'Past and Available', '2' => 'All Items');
         while ($row = mysql_fetch_row($result)) {
             $gbcats[$row[0]] = $row[1];
         }
         $reqmet = true;
         echo '<h2>Badge: ' . $name . '</h2>';
         echo '<p>Badge requirements:</p>';
         echo '<table class="gb"><thead><tr><th>Category/Course Total</th><th>Score Required</th><th>Your Score</th><th>Requirement Met</th></tr></thead><tbody>';
         foreach ($req['data'] as $r) {
             //r = array(gbcat, gradetype, score)
             $metthis = false;
             echo '<tr><td>';
             if ($r[0] > 0) {
예제 #3
0
function gbinstrdisp()
{
    global $isteacher, $istutor, $cid, $stu, $isdiag, $catfilter, $secfilter, $imasroot, $tutorsection;
    $hidenc = 1;
    $gbt = gbtable();
    //print_r($gbt);
    echo "<script type=\"text/javascript\" src=\"{$imasroot}/javascript/tablesorter.js\"></script>\n";
    echo "<div id=\"tbl-container\">";
    echo "<table class=gb id=myTable><thead><tr>";
    $n = 0;
    for ($i = 0; $i < count($gbt[0][0]); $i++) {
        //biographical headers
        if ($i == 1 && $gbt[0][0][1] != 'ID') {
            continue;
        }
        echo '<th>' . $gbt[0][0][$i];
        if (($gbt[0][0][$i] == 'Section' || $isdiag && $i == 4) && (!$istutor || $tutorsection == '')) {
            echo "<br/><select id=\"secfiltersel\" onchange=\"chgsecfilter()\"><option value=\"-1\" ";
            if ($secfilter == -1) {
                echo 'selected=1';
            }
            echo '>All</option>';
            $query = "SELECT DISTINCT section FROM imas_students WHERE courseid='{$cid}' ORDER BY section";
            $result = mysql_query($query) or die("Query failed : " . mysql_error());
            while ($row = mysql_fetch_row($result)) {
                if ($row[0] == '') {
                    continue;
                }
                echo "<option value=\"{$row[0]}\" ";
                if ($row[0] == $secfilter) {
                    echo 'selected=1';
                }
                echo ">{$row[0]}</option>";
            }
            echo "</select>";
        } else {
            if ($gbt[0][0][$i] == 'Name') {
                echo '<br/><span class="small">N=' . (count($gbt) - 2) . '</span>';
            }
        }
        echo '</th>';
        $n++;
    }
    for ($i = 0; $i < count($gbt[0][1]); $i++) {
        //assessment headers
        if (!$isteacher && $gbt[0][1][$i][4] == 0) {
            //skip if hidden
            continue;
        }
        if ($hidenc == 1 && $gbt[0][1][$i][4] == 0) {
            //skip NC
            continue;
        } else {
            if ($hidenc == 2 && ($gbt[0][1][$i][4] == 0 || $gbt[0][1][$i][4] == 3)) {
                //skip all NC
                continue;
            }
        }
        //name and points
        echo '<th class="cat' . $gbt[0][1][$i][1] . '">' . $gbt[0][1][$i][0] . '<br/>';
        if ($gbt[0][1][$i][4] == 0 || $gbt[0][1][$i][4] == 3) {
            echo $gbt[0][1][$i][2] . ' (Not Counted)';
        } else {
            echo $gbt[0][1][$i][2] . '&nbsp;pts';
            if ($gbt[0][1][$i][4] == 2) {
                echo ' (EC)';
            }
        }
        if ($gbt[0][1][$i][5] == 1) {
            echo ' (PT)';
        }
        //links
        if ($isteacher) {
            if ($gbt[0][1][$i][6] == 0) {
                //online
                echo "<br/><a class=small href=\"addassessment.php?id={$gbt[0][1][$i][7]}&cid={$cid}&from=gb\">[Settings]</a>";
                echo "<br/><a class=small href=\"isolateassessgrade.php?cid={$cid}&aid={$gbt[0][1][$i][7]}\">[Isolate]</a>";
            } else {
                if ($gbt[0][1][$i][6] == 1) {
                    //offline
                    echo "<br/><a class=small href=\"addgrades.php?stu={$stu}&cid={$cid}&grades=all&gbitem={$gbt[0][1][$i][7]}\">[Settings]</a>";
                    echo "<br/><a class=small href=\"addgrades.php?stu={$stu}&cid={$cid}&grades=all&gbitem={$gbt[0][1][$i][7]}&isolate=true\">[Isolate]</a>";
                } else {
                    if ($gbt[0][1][$i][6] == 2) {
                        //discussion
                        echo "<br/><a class=small href=\"addforum.php?id={$gbt[0][1][$i][7]}&cid={$cid}&from=gb\">[Settings]</a>";
                    }
                }
            }
        }
        echo '</th>';
        $n++;
    }
    echo '</tr></thead><tbody>';
    //create student rows
    for ($i = 1; $i < count($gbt) - 1; $i++) {
        if ($i % 2 != 0) {
            echo "<tr class=even onMouseOver=\"this.className='highlight'\" onMouseOut=\"this.className='even'\">";
        } else {
            echo "<tr class=odd onMouseOver=\"this.className='highlight'\" onMouseOut=\"this.className='odd'\">";
        }
        echo '<td class="locked" scope="row">';
        echo "<a href=\"gradebook.php?cid={$cid}&stu={$gbt[$i][4][0]}\">";
        echo $gbt[$i][0][0];
        echo '</a></td>';
        for ($j = $gbt[0][0][1] == 'ID' ? 1 : 2; $j < count($gbt[0][0]); $j++) {
            echo '<td class="c">' . $gbt[$i][0][$j] . '</td>';
        }
        //assessment values
        for ($j = 0; $j < count($gbt[0][1]); $j++) {
            if ($gbt[0][1][$j][4] == 0) {
                //skip if hidden
                continue;
            }
            if ($hidenc == 1 && $gbt[0][1][$j][4] == 0) {
                //skip NC
                continue;
            } else {
                if ($hidenc == 2 && ($gbt[0][1][$j][4] == 0 || $gbt[0][1][$j][4] == 3)) {
                    //skip all NC
                    continue;
                }
            }
            echo '<td class="c">';
            if (isset($gbt[$i][1][$j][5])) {
                echo '<span style="font-style:italic">';
            }
            if ($gbt[0][1][$j][6] == 0) {
                //online
                if (isset($gbt[$i][1][$j][0])) {
                    if ($gbt[$i][1][$j][4] == 'average') {
                        echo "<a href=\"gb-itemanalysis.php?stu={$stu}&cid={$cid}&asid={$gbt[$i][1][$j][4]}&aid={$gbt[0][1][$j][7]}\">";
                    } else {
                        echo "<a href=\"gb-viewasid.php?stu={$stu}&cid={$cid}&asid={$gbt[$i][1][$j][4]}&uid={$gbt[$i][4][0]}\">";
                    }
                    echo $gbt[$i][1][$j][0];
                    if ($gbt[$i][1][$j][3] == 1) {
                        echo ' (NC)';
                    }
                    /*else if ($gbt[$i][1][$j][3]==2) {
                    			echo ' (IP)';
                    		} else if ($gbt[$i][1][$j][3]==3) {
                    			echo ' (OT)';
                    		} else if ($gbt[$i][1][$j][3]==4) {
                    			echo ' (PT)';
                    		} */
                    echo '</a>';
                    if ($gbt[$i][1][$j][1] == 1) {
                        echo '<sup>*</sup>';
                    }
                } else {
                    //no score
                    if ($gbt[$i][0][0] == 'Averages') {
                        echo '-';
                    } else {
                        echo "<a href=\"gb-viewasid.php?stu={$stu}&cid={$cid}&asid=new&aid={$gbt[0][1][$j][7]}&uid={$gbt[$i][4][0]}\">-</a>";
                    }
                }
            } else {
                if ($gbt[0][1][$j][6] == 1) {
                    //offline
                    if ($isteacher) {
                        if ($gbt[$i][0][0] == 'Averages') {
                            echo "<a href=\"addgrades.php?stu={$stu}&cid={$cid}&grades=all&gbitem={$gbt[0][1][$j][7]}\">";
                        } else {
                            echo "<a href=\"addgrades.php?stu={$stu}&cid={$cid}&grades={$gbt[$i][4][0]}&gbitem={$gbt[0][1][$j][7]}\">";
                        }
                    }
                    if (isset($gbt[$i][1][$j][0])) {
                        echo $gbt[$i][1][$j][0];
                        if ($gbt[$i][1][$j][3] == 1) {
                            echo ' (NC)';
                        }
                    } else {
                        echo '-';
                    }
                    if ($isteacher) {
                        echo '</a>';
                    }
                    if ($gbt[$i][1][$j][1] == 1) {
                        echo '<sup>*</sup>';
                    }
                } else {
                    if ($gbt[0][1][$j][6] == 2) {
                        //discuss
                        if (isset($gbt[$i][1][$j][0])) {
                            echo $gbt[$i][1][$j][0];
                        } else {
                            echo '-';
                        }
                    }
                }
            }
            if (isset($gbt[$i][1][$j][5])) {
                echo '<sub>d</sub></span>';
            }
            echo '</td>';
        }
    }
    echo "</tbody></table>";
    if ($n > 0) {
        $sarr = array_fill(0, $n - 1, "'N'");
    } else {
        $sarr = array();
    }
    array_unshift($sarr, "'S'");
    $sarr = implode(",", $sarr);
    if (count($gbt) < 500) {
        echo "<script>initSortTable('myTable',Array({$sarr}),true,false);</script>\n";
    }
}
예제 #4
0
function gbinstrdisp()
{
    global $hidenc, $isteacher, $istutor, $cid, $gbmode, $stu, $availshow, $catfilter, $secfilter, $totonleft, $imasroot, $isdiag, $tutorsection, $commentloc, $pointsln, $logincnt;
    if ($availshow == 4) {
        $availshow = 1;
        $hidepast = true;
    }
    $gbt = gbtable();
    echo '<table class="gb" id="myTable"><thead><tr>';
    $n = 0;
    for ($i = 0; $i < count($gbt[0][0]); $i++) {
        //biographical headers
        //if ($i==1 && $gbt[0][0][1]!='ID') { continue;}
        echo '<th>' . $gbt[0][0][$i];
        if ($gbt[0][0][$i] == 'Name') {
            if ($pointsln == 1) {
                echo '<br/>';
            } else {
                echo '&nbsp;';
            }
            echo '<span class="small">N=' . (count($gbt) - 2) . '</span>';
        }
        echo '</th>';
        $n++;
    }
    if ($totonleft && !$hidepast) {
        //total totals
        if ($catfilter < 0) {
            if (isset($gbt[0][3][0])) {
                //using points based
                echo '<th><span class="cattothdr">Total';
                if ($pointsln == 1) {
                    echo '<br/>';
                } else {
                    echo '&nbsp;';
                }
                echo $gbt[0][3][$availshow] . '&nbsp;pts</span></th>';
                echo '<th>%</th>';
                $n += 2;
            } else {
                echo '<th><span class="cattothdr">Weighted Total %</span></th>';
                $n++;
            }
        }
        if (count($gbt[0][2]) > 1 || $catfilter != -1) {
            //want to show cat headers?
            for ($i = 0; $i < count($gbt[0][2]); $i++) {
                //category headers
                if (($availshow < 2 || $availshow == 3) && $gbt[0][2][$i][2] > 1) {
                    continue;
                } else {
                    if ($availshow == 2 && $gbt[0][2][$i][2] == 3) {
                        continue;
                    }
                }
                echo '<th class="cat' . $gbt[0][2][$i][1] . '"><span class="cattothdr">';
                echo $gbt[0][2][$i][0];
                if ($pointsln == 1) {
                    echo '<br/>';
                } else {
                    echo '&nbsp;';
                }
                if ($availshow < 3) {
                    if (isset($gbt[0][3][0])) {
                        //using points based
                        echo $gbt[0][2][$i][3 + $availshow] . '&nbsp;', _('pts');
                    } else {
                        echo $gbt[0][2][$i][11] . '%';
                    }
                } else {
                    if (isset($gbt[0][2][$i][11])) {
                        echo $gbt[0][2][$i][11] . '%';
                    }
                }
                echo '</span></th>';
                $n++;
            }
        }
    }
    if ($catfilter > -2) {
        for ($i = 0; $i < count($gbt[0][1]); $i++) {
            //assessment headers
            if (!$isteacher && !$istutor && $gbt[0][1][$i][4] == 0) {
                //skip if hidden
                continue;
            }
            if ($hidenc == 1 && $gbt[0][1][$i][4] == 0) {
                //skip NC
                continue;
            } else {
                if ($hidenc == 2 && ($gbt[0][1][$i][4] == 0 || $gbt[0][1][$i][4] == 3)) {
                    //skip all NC
                    continue;
                }
            }
            if ($gbt[0][1][$i][3] > $availshow) {
                continue;
            }
            if ($hidepast && $gbt[0][1][$i][3] == 0) {
                continue;
            }
            //name and points
            echo '<th class="cat' . $gbt[0][1][$i][1] . '">' . $gbt[0][1][$i][0];
            if ($pointsln == 1) {
                echo '<br/>';
            } else {
                echo '&nbsp;';
            }
            if ($gbt[0][1][$i][4] == 0 || $gbt[0][1][$i][4] == 3) {
                echo $gbt[0][1][$i][2] . ' (Not Counted)';
            } else {
                echo $gbt[0][1][$i][2] . '&nbsp;pts';
                if ($gbt[0][1][$i][4] == 2) {
                    echo ' (EC)';
                }
            }
            if ($gbt[0][1][$i][5] == 1 && $gbt[0][1][$i][6] == 0) {
                echo ' (PT)';
            }
            echo '</th>';
            $n++;
            if ($commentloc == 0) {
                echo '<th>' . $gbt[0][1][$i][0] . ': Comments' . '</th>';
                $n++;
            }
        }
    }
    if (!$totonleft && !$hidepast) {
        if (count($gbt[0][2]) > 1 || $catfilter != -1) {
            //want to show cat headers?
            for ($i = 0; $i < count($gbt[0][2]); $i++) {
                //category headers
                if (($availshow < 2 || $availshow == 3) && $gbt[0][2][$i][2] > 1) {
                    continue;
                } else {
                    if ($availshow == 2 && $gbt[0][2][$i][2] == 3) {
                        continue;
                    }
                }
                echo '<th class="cat' . $gbt[0][2][$i][1] . '"><span class="cattothdr">';
                echo $gbt[0][2][$i][0];
                if ($pointsln == 1) {
                    echo '<br/>';
                } else {
                    echo '&nbsp;';
                }
                if ($availshow < 3) {
                    if (isset($gbt[0][3][0])) {
                        //using points based
                        echo $gbt[0][2][$i][3 + $availshow] . '&nbsp;', _('pts');
                    } else {
                        echo $gbt[0][2][$i][11] . '%';
                    }
                } else {
                    if (isset($gbt[0][2][$i][11])) {
                        echo $gbt[0][2][$i][11] . '%';
                    }
                }
                echo '</span></th>';
                $n++;
            }
        }
        //total totals
        if ($catfilter < 0) {
            if (isset($gbt[0][3][0])) {
                //using points based
                echo '<th><span class="cattothdr">Total';
                if ($pointsln == 1) {
                    echo '<br/>';
                } else {
                    echo '&nbsp;';
                }
                echo $gbt[0][3][$availshow] . '&nbsp;pts</span></th>';
                echo '<th>%</th>';
                $n += 2;
            } else {
                echo '<th><span class="cattothdr">Weighted Total %</span></th>';
                $n++;
            }
        }
    }
    echo '<th>Comment</th>';
    echo '<th>Instructor Note</th>';
    $n += 2;
    if ($commentloc == 1) {
        if ($catfilter > -2) {
            for ($i = 0; $i < count($gbt[0][1]); $i++) {
                //assessment comment headers
                if (!$isteacher && $gbt[0][1][$i][4] == 0) {
                    //skip if hidden
                    continue;
                }
                if ($hidenc == 1 && $gbt[0][1][$i][4] == 0) {
                    //skip NC
                    continue;
                } else {
                    if ($hidenc == 2 && ($gbt[0][1][$i][4] == 0 || $gbt[0][1][$i][4] == 3)) {
                        //skip all NC
                        continue;
                    }
                }
                if ($gbt[0][1][$i][3] > $availshow) {
                    continue;
                }
                //name and points
                echo '<th>' . $gbt[0][1][$i][0] . ': Comments' . '</th>';
                $n++;
            }
        }
    }
    echo '</tr></thead><tbody>';
    //get gb comments;
    $gbcomments = array();
    $query = "SELECT userid,gbcomment,gbinstrcomment FROM imas_students WHERE courseid='{$cid}'";
    $result = mysql_query($query) or die("Query failed : " . mysql_error());
    while ($row = mysql_fetch_row($result)) {
        $gbcomments[$row[0]] = array($row[1], $row[2]);
    }
    //create student rows
    for ($i = 1; $i < count($gbt); $i++) {
        if ($i % 2 != 0) {
            echo "<tr class=even onMouseOver=\"highlightrow(this)\" onMouseOut=\"unhighlightrow(this)\">";
        } else {
            echo "<tr class=odd onMouseOver=\"highlightrow(this)\" onMouseOut=\"unhighlightrow(this)\">";
        }
        echo '<td class="locked" scope="row">';
        echo $gbt[$i][0][0];
        for ($j = 1; $j < count($gbt[0][0]); $j++) {
            echo '<td class="c">' . $gbt[$i][0][$j] . '</td>';
        }
        if ($totonleft && !$hidepast) {
            //total totals
            if ($catfilter < 0) {
                if ($availshow == 3) {
                    if (isset($gbt[$i][3][8])) {
                        //using points based
                        echo '<td class="c">' . $insdiv . $gbt[$i][3][6] . '/' . $gbt[$i][3][7] . $enddiv . '</td>';
                        echo '<td class="c">' . $insdiv . $gbt[$i][3][8] . '%' . $enddiv . '</td>';
                    } else {
                        echo '<td class="c">' . $insdiv . $gbt[$i][3][6] . '%' . $enddiv . '</td>';
                    }
                } else {
                    if (isset($gbt[0][3][0])) {
                        //using points based
                        echo '<td class="c">' . $gbt[$i][3][$availshow] . '</td>';
                        echo '<td class="c">' . $gbt[$i][3][$availshow + 3] . '%</td>';
                    } else {
                        echo '<td class="c">' . $gbt[$i][3][$availshow] . '%</td>';
                    }
                }
            }
            //category totals
            if (count($gbt[0][2]) > 1 || $catfilter != -1) {
                //want to show cat headers?
                for ($j = 0; $j < count($gbt[0][2]); $j++) {
                    //category headers
                    if (($availshow < 2 || $availshow == 3) && $gbt[0][2][$j][2] > 1) {
                        continue;
                    } else {
                        if ($availshow == 2 && $gbt[0][2][$j][2] == 3) {
                            continue;
                        }
                    }
                    if ($catfilter != -1 && $availshow < 3 && $gbt[0][2][$j][$availshow + 3] > 0) {
                        echo '<td class="c">' . $gbt[$i][2][$j][$availshow] . ' (' . round(100 * $gbt[$i][2][$j][$availshow] / $gbt[0][2][$j][$availshow + 3]) . '%)</td>';
                    } else {
                        echo '<td class="c">';
                        if ($availshow == 3) {
                            echo $gbt[$i][2][$j][3] . ' of ' . $gbt[$i][2][$j][4];
                        } else {
                            if (isset($gbt[$i][3][8])) {
                                //using points based
                                echo $gbt[$i][2][$j][$availshow];
                            } else {
                                if ($gbt[0][2][$j][3 + $availshow] > 0) {
                                    echo round(100 * $gbt[$i][2][$j][$availshow] / $gbt[0][2][$j][3 + $availshow], 1) . '%';
                                } else {
                                    echo '0%';
                                }
                            }
                        }
                        echo '</td>';
                    }
                }
            }
        }
        //assessment values
        if ($catfilter > -2) {
            for ($j = 0; $j < count($gbt[0][1]); $j++) {
                if (!$isteacher && !$istutor && $gbt[0][1][$j][4] == 0) {
                    //skip if hidden
                    continue;
                }
                if ($hidenc == 1 && $gbt[0][1][$j][4] == 0) {
                    //skip NC
                    continue;
                } else {
                    if ($hidenc == 2 && ($gbt[0][1][$j][4] == 0 || $gbt[0][1][$j][4] == 3)) {
                        //skip all NC
                        continue;
                    }
                }
                if ($gbt[0][1][$j][3] > $availshow) {
                    continue;
                }
                if ($hidepast && $gbt[0][1][$j][3] == 0) {
                    continue;
                }
                echo '<td class="c">';
                if (isset($gbt[$i][1][$j][5]) && $gbt[$i][1][$j][5] & 1 << $availshow && !$hidepast) {
                    echo '<span style="font-style:italic">';
                }
                if ($gbt[0][1][$j][6] == 0) {
                    //online
                    if (isset($gbt[$i][1][$j][0])) {
                        echo $gbt[$i][1][$j][0];
                        if ($gbt[$i][1][$j][3] == 1) {
                            echo ' (NC)';
                        } else {
                            if ($gbt[$i][1][$j][3] == 2) {
                                echo ' (IP)';
                            } else {
                                if ($gbt[$i][1][$j][3] == 3) {
                                    echo ' (OT)';
                                } else {
                                    if ($gbt[$i][1][$j][3] == 4) {
                                        echo ' (PT)';
                                    }
                                }
                            }
                        }
                    } else {
                        //no score
                        if ($gbt[$i][0][0] == 'Averages') {
                            echo '-';
                        } else {
                            echo '-';
                        }
                    }
                    if (isset($gbt[$i][1][$j][6])) {
                        if ($gbt[$i][1][$j][6] > 1) {
                            if ($gbt[$i][1][$j][6] > 2) {
                                echo '<sup>LP (' . ($gbt[$i][1][$j][6] - 1) . ')</sup>';
                            } else {
                                echo '<sup>LP</sup>';
                            }
                        } else {
                            echo '<sup>e</sup>';
                        }
                    }
                } else {
                    if ($gbt[0][1][$j][6] == 1) {
                        //offline
                        if (isset($gbt[$i][1][$j][0])) {
                            echo $gbt[$i][1][$j][0];
                            if ($gbt[$i][1][$j][3] == 1) {
                                echo ' (NC)';
                            }
                        } else {
                            echo '-';
                        }
                        if ($gbt[$i][1][$j][1] == 1) {
                            echo '<sup>*</sup>';
                        }
                    } else {
                        if ($gbt[0][1][$j][6] == 2) {
                            //discuss
                            if (isset($gbt[$i][1][$j][0])) {
                                echo $gbt[$i][1][$j][0];
                            } else {
                                echo '-';
                            }
                        }
                    }
                }
                if (isset($gbt[$i][1][$j][5]) && $gbt[$i][1][$j][5] & 1 << $availshow && !$hidepast) {
                    echo '<sub>d</sub></span>';
                }
                echo '</td>';
                if ($commentloc == 0) {
                    if (isset($gbt[$i][1][$j][1])) {
                        echo '<td>' . $gbt[$i][1][$j][1] . '</td>';
                    } else {
                        echo '<td></td>';
                    }
                    $n++;
                }
            }
        }
        if (!$totonleft && !$hidepast) {
            //category totals
            if (count($gbt[0][2]) > 1 || $catfilter != -1) {
                //want to show cat headers?
                for ($j = 0; $j < count($gbt[0][2]); $j++) {
                    //category headers
                    if (($availshow < 2 || $availshow == 3) && $gbt[0][2][$j][2] > 1) {
                        continue;
                    } else {
                        if ($availshow == 2 && $gbt[0][2][$j][2] == 3) {
                            continue;
                        }
                    }
                    if ($catfilter != -1 && $availshow < 3 && $gbt[0][2][$j][$availshow + 3] > 0) {
                        echo '<td class="c">' . $gbt[$i][2][$j][$availshow] . ' (' . round(100 * $gbt[$i][2][$j][$availshow] / $gbt[0][2][$j][$availshow + 3]) . '%)</td>';
                    } else {
                        echo '<td class="c">';
                        if ($availshow == 3) {
                            echo $gbt[$i][2][$j][3] . ' of ' . $gbt[$i][2][$j][4];
                        } else {
                            if (isset($gbt[$i][3][8])) {
                                //using points based
                                echo $gbt[$i][2][$j][$availshow];
                            } else {
                                if ($gbt[0][2][$j][3 + $availshow] > 0) {
                                    echo round(100 * $gbt[$i][2][$j][$availshow] / $gbt[0][2][$j][3 + $availshow], 1) . '%';
                                } else {
                                    echo '0%';
                                }
                            }
                        }
                        echo '</td>';
                    }
                }
            }
            //total totals
            if ($catfilter < 0) {
                if ($availshow == 3) {
                    if (isset($gbt[$i][3][8])) {
                        //using points based
                        echo '<td class="c">' . $insdiv . $gbt[$i][3][6] . '/' . $gbt[$i][3][7] . $enddiv . '</td>';
                        echo '<td class="c">' . $insdiv . $gbt[$i][3][8] . '%' . $enddiv . '</td>';
                    } else {
                        echo '<td class="c">' . $insdiv . $gbt[$i][3][6] . '%' . $enddiv . '</td>';
                    }
                } else {
                    if (isset($gbt[0][3][0])) {
                        //using points based
                        echo '<td class="c">' . $gbt[$i][3][$availshow] . '</td>';
                        echo '<td class="c">' . $gbt[$i][3][$availshow + 3] . '%</td>';
                    } else {
                        echo '<td class="c">' . $gbt[$i][3][$availshow] . '%</td>';
                    }
                }
            }
        }
        if (isset($gbcomments[$gbt[$i][4][0]])) {
            echo '<td>' . $gbcomments[$gbt[$i][4][0]][0] . '</td>';
            echo '<td>' . $gbcomments[$gbt[$i][4][0]][1] . '</td>';
        } else {
            echo '<td></td>';
            echo '<td></td>';
        }
        $n += 2;
        if ($commentloc == 1) {
            if ($catfilter > -2) {
                for ($j = 0; $j < count($gbt[0][1]); $j++) {
                    if (!$isteacher && $gbt[0][1][$j][4] == 0) {
                        //skip if hidden
                        continue;
                    }
                    if ($hidenc == 1 && $gbt[0][1][$j][4] == 0) {
                        //skip NC
                        continue;
                    } else {
                        if ($hidenc == 2 && ($gbt[0][1][$j][4] == 0 || $gbt[0][1][$j][4] == 3)) {
                            //skip all NC
                            continue;
                        }
                    }
                    if ($gbt[0][1][$j][3] > $availshow) {
                        continue;
                    }
                    if (isset($gbt[$i][1][$j][1])) {
                        echo '<td>' . $gbt[$i][1][$j][1] . '</td>';
                    } else {
                        echo '<td></td>';
                    }
                    $n++;
                }
            }
        }
        echo '</tr>';
    }
    echo "</tbody></table>";
}
예제 #5
0
//(c) 2013 David Lippman, part of IMathAS
//
// Assessment "badness" report, based on
// Lumen Learning's ImprovOER model
require "../validate.php";
if (!isset($teacherid) && !isset($adminid)) {
    exit;
}
//set globals for gbtable2
$setorderby = 2;
$includeduedate = true;
$canviewall = true;
$catfilter = -1;
$secfilter = -1;
require "gbtable2.php";
$gbt = gbtable();
$lastrow = count($gbt) - 1;
$n = count($gbt) - 2;
if ($n == 0) {
    echo "Need at least 1 student's data";
    exit;
}
$assessmetrics = array();
$maxattemptratio = 0;
//estimate course start/end dates
$query = "SELECT min(enddate),max(enddate) FROM imas_assessments WHERE courseid='{$cid}' AND enddate<2000000000";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$row = mysql_fetch_row($result);
$mindate = $row[0];
$maxdate = $row[1];
$query = "SELECT min(showdate),max(showdate) FROM imas_gbitems WHERE courseid='{$cid}' AND showdate<2000000000";
예제 #6
0
function gbinstrdisp()
{
    global $hidenc, $showpics, $isteacher, $istutor, $cid, $gbmode, $stu, $availshow, $catfilter, $secfilter, $totonleft, $imasroot, $isdiag, $tutorsection, $avgontop, $hidelocked, $colorize, $urlmode, $overridecollapse, $includeduedate, $lastlogin;
    $curdir = rtrim(dirname(__FILE__), '/\\');
    if ($availshow == 4) {
        $availshow = 1;
        $hidepast = true;
    }
    $gbt = gbtable();
    if ($avgontop) {
        $avgrow = array_pop($gbt);
        array_splice($gbt, 1, 0, array($avgrow));
    }
    //print_r($gbt);
    //echo "<script type=\"text/javascript\" src=\"$imasroot/javascript/tablesorter.js\"></script>\n"; in placeinhead
    echo "<div id=\"tbl-container\">";
    echo '<div id="bigcontmyTable"><div id="tblcontmyTable">';
    echo '<table class="gb" id="myTable"><thead><tr>';
    $sortarr = array();
    for ($i = 0; $i < count($gbt[0][0]); $i++) {
        //biographical headers
        if ($i == 1) {
            echo '<th><div>&nbsp;</div></th>';
            $sortarr[] = 'false';
        }
        //for pics
        if ($i == 1 && $gbt[0][0][1] != 'ID') {
            continue;
        }
        if ($gbt[0][0][$i] == 'Section' || $gbt[0][0][$i] == 'Code' || $gbt[0][0][$i] == 'Last Login') {
            echo '<th class="nocolorize"><div>';
        } else {
            echo '<th><div>';
        }
        echo $gbt[0][0][$i];
        if (($gbt[0][0][$i] == 'Section' || $isdiag && $i == 4) && (!$istutor || $tutorsection == '')) {
            echo "<br/><select id=\"secfiltersel\" onchange=\"chgsecfilter()\"><option value=\"-1\" ";
            if ($secfilter == -1) {
                echo 'selected=1';
            }
            echo '>', _('All'), '</option>';
            $query = "SELECT DISTINCT section FROM imas_students WHERE courseid='{$cid}' ORDER BY section";
            $result = mysql_query($query) or die("Query failed : " . mysql_error());
            while ($row = mysql_fetch_row($result)) {
                if ($row[0] == '') {
                    continue;
                }
                echo "<option value=\"{$row[0]}\" ";
                if ($row[0] == $secfilter) {
                    echo 'selected=1';
                }
                echo ">{$row[0]}</option>";
            }
            echo "</select>";
        } else {
            if ($gbt[0][0][$i] == 'Name') {
                echo '<br/><span class="small">N=' . (count($gbt) - 2) . '</span><br/>';
                echo "<select id=\"toggle5\" onchange=\"chgtoggle()\">";
                echo "<option value=0 ";
                writeHtmlSelected($hidelocked, 0);
                echo ">", _('Show Locked'), "</option>";
                echo "<option value=2 ";
                writeHtmlSelected($hidelocked, 2);
                echo ">", _('Hide Locked'), "</option>";
                echo "</select>";
            }
        }
        echo '</div></th>';
        if ($gbt[0][0][$i] == 'Last Login') {
            $sortarr[] = "'D'";
        } else {
            if ($i != 1) {
                $sortarr[] = "'S'";
            }
        }
    }
    $n = 0;
    //get collapsed gb cat info
    if (count($gbt[0][2]) > 1) {
        $collapsegbcat = array();
        for ($i = 0; $i < count($gbt[0][2]); $i++) {
            if (isset($overridecollapse[$gbt[0][2][$i][10]])) {
                $collapsegbcat[$gbt[0][2][$i][1]] = $overridecollapse[$gbt[0][2][$i][10]];
            } else {
                $collapsegbcat[$gbt[0][2][$i][1]] = $gbt[0][2][$i][12];
            }
        }
    }
    if ($totonleft && !$hidepast) {
        //total totals
        if ($catfilter < 0) {
            if (isset($gbt[0][3][0])) {
                //using points based
                echo '<th><div><span class="cattothdr">', _('Total'), '<br/>' . $gbt[0][3][$availshow] . '&nbsp;', _('pts'), '</span></div></th>';
                echo '<th><div>%</div></th>';
                $n += 2;
            } else {
                echo '<th><div><span class="cattothdr">', _('Weighted Total %'), '</span></div></th>';
                $n++;
            }
        }
        if (count($gbt[0][2]) > 1 || $catfilter != -1) {
            //want to show cat headers?
            for ($i = 0; $i < count($gbt[0][2]); $i++) {
                //category headers
                if (($availshow < 2 || $availshow == 3) && $gbt[0][2][$i][2] > 1) {
                    continue;
                } else {
                    if ($availshow == 2 && $gbt[0][2][$i][2] == 3) {
                        continue;
                    }
                }
                echo '<th class="cat' . $gbt[0][2][$i][1] . '"><div><span class="cattothdr">';
                if ($availshow < 3) {
                    echo $gbt[0][2][$i][0] . '<br/>';
                    if (isset($gbt[0][3][0])) {
                        //using points based
                        echo $gbt[0][2][$i][3 + $availshow] . '&nbsp;', _('pts');
                    } else {
                        echo $gbt[0][2][$i][11] . '%';
                    }
                } else {
                    if ($availshow == 3) {
                        //past and attempted
                        echo $gbt[0][2][$i][0];
                        if (isset($gbt[0][2][$i][11])) {
                            echo '<br/>' . $gbt[0][2][$i][11] . '%';
                        }
                    }
                }
                if ($collapsegbcat[$gbt[0][2][$i][1]] == 0) {
                    echo "<br/><a class=small href=\"gradebook.php?cid={$cid}&amp;cat={$gbt[0][2][$i][10]}&amp;catcollapse=2\">", _('[Collapse]'), "</a>";
                } else {
                    echo "<br/><a class=small href=\"gradebook.php?cid={$cid}&amp;cat={$gbt[0][2][$i][10]}&amp;catcollapse=0\">", _('[Expand]'), "</a>";
                }
                echo '</span></div></th>';
                $n++;
            }
        }
    }
    if ($catfilter > -2) {
        for ($i = 0; $i < count($gbt[0][1]); $i++) {
            //assessment headers
            if (!$isteacher && !$istutor && $gbt[0][1][$i][4] == 0) {
                //skip if hidden
                continue;
            }
            if ($hidenc == 1 && $gbt[0][1][$i][4] == 0) {
                //skip NC
                continue;
            } else {
                if ($hidenc == 2 && ($gbt[0][1][$i][4] == 0 || $gbt[0][1][$i][4] == 3)) {
                    //skip all NC
                    continue;
                }
            }
            if ($gbt[0][1][$i][3] > $availshow) {
                continue;
            }
            if ($hidepast && $gbt[0][1][$i][3] == 0) {
                continue;
            }
            if ($collapsegbcat[$gbt[0][1][$i][1]] == 2) {
                continue;
            }
            //name and points
            echo '<th class="cat' . $gbt[0][1][$i][1] . '"><div>' . $gbt[0][1][$i][0] . '<br/>';
            if ($gbt[0][1][$i][4] == 0 || $gbt[0][1][$i][4] == 3) {
                echo $gbt[0][1][$i][2] . '&nbsp;', _('pts'), ' ', _('(Not Counted)');
            } else {
                echo $gbt[0][1][$i][2] . '&nbsp;', _('pts');
                if ($gbt[0][1][$i][4] == 2) {
                    echo ' (EC)';
                }
            }
            if ($gbt[0][1][$i][5] == 1 && $gbt[0][1][$i][6] == 0) {
                echo ' (PT)';
            }
            if ($includeduedate && $gbt[0][1][$i][11] < 2000000000 && $gbt[0][1][$i][11] > 0) {
                echo '<br/><span class="small">' . tzdate('n/j/y&\\n\\b\\s\\p;g:ia', $gbt[0][1][$i][11]) . '</span>';
            }
            //links
            if ($gbt[0][1][$i][6] == 0) {
                //online
                if ($isteacher) {
                    echo "<br/><a class=small href=\"addassessment.php?id={$gbt[0][1][$i][7]}&amp;cid={$cid}&amp;from=gb\">", _('[Settings]'), "</a>";
                    echo "<br/><a class=small href=\"isolateassessgrade.php?cid={$cid}&amp;aid={$gbt[0][1][$i][7]}\">", _('[Isolate]'), "</a>";
                    if ($gbt[0][1][$i][10] == true) {
                        echo "<br/><a class=small href=\"isolateassessbygroup.php?cid={$cid}&amp;aid={$gbt[0][1][$i][7]}\">", _('[By Group]'), "</a>";
                    }
                } else {
                    echo "<br/><a class=small href=\"isolateassessgrade.php?cid={$cid}&amp;aid={$gbt[0][1][$i][7]}\">", _('[Isolate]'), "</a>";
                }
            } else {
                if ($gbt[0][1][$i][6] == 1 && ($isteacher || $istutor && $gbt[0][1][$i][8] == 1)) {
                    //offline
                    if ($isteacher) {
                        echo "<br/><a class=small href=\"addgrades.php?stu={$stu}&amp;cid={$cid}&amp;grades=all&amp;gbitem={$gbt[0][1][$i][7]}\">", _('[Settings]'), "</a>";
                        echo "<br/><a class=small href=\"addgrades.php?stu={$stu}&amp;cid={$cid}&amp;grades=all&amp;gbitem={$gbt[0][1][$i][7]}&amp;isolate=true\">", _('[Isolate]'), "</a>";
                    } else {
                        echo "<br/><a class=small href=\"addgrades.php?stu={$stu}&amp;cid={$cid}&amp;grades=all&amp;gbitem={$gbt[0][1][$i][7]}&amp;isolate=true\">", _('[Scores]'), "</a>";
                    }
                } else {
                    if ($gbt[0][1][$i][6] == 2 && $isteacher) {
                        //discussion
                        echo "<br/><a class=small href=\"addforum.php?id={$gbt[0][1][$i][7]}&amp;cid={$cid}&amp;from=gb\">", _('[Settings]'), "</a>";
                    } else {
                        if ($gbt[0][1][$i][6] == 3 && $isteacher) {
                            //exttool
                            echo "<br/><a class=small href=\"addlinkedtext.php?id={$gbt[0][1][$i][7]}&amp;cid={$cid}&amp;from=gb\">", _('[Settings]'), "</a>";
                            echo "<br/><a class=small href=\"edittoolscores.php?stu={$stu}&amp;cid={$cid}&amp;uid=all&amp;lid={$gbt[0][1][$i][7]}&amp;isolate=true\">", _('[Isolate]'), "</a>";
                        }
                    }
                }
            }
            echo '</div></th>';
            $n++;
        }
    }
    if (!$totonleft && !$hidepast) {
        if (count($gbt[0][2]) > 1 || $catfilter != -1) {
            //want to show cat headers?
            for ($i = 0; $i < count($gbt[0][2]); $i++) {
                //category headers
                if (($availshow < 2 || $availshow == 3) && $gbt[0][2][$i][2] > 1) {
                    continue;
                } else {
                    if ($availshow == 2 && $gbt[0][2][$i][2] == 3) {
                        continue;
                    }
                }
                echo '<th class="cat' . $gbt[0][2][$i][1] . '"><div><span class="cattothdr">';
                if ($availshow < 3) {
                    echo $gbt[0][2][$i][0] . '<br/>';
                    if (isset($gbt[0][3][0])) {
                        //using points based
                        echo $gbt[0][2][$i][3 + $availshow] . '&nbsp;', _('pts');
                    } else {
                        echo $gbt[0][2][$i][11] . '%';
                    }
                } else {
                    if ($availshow == 3) {
                        //past and attempted
                        echo $gbt[0][2][$i][0];
                    }
                }
                if ($collapsegbcat[$gbt[0][2][$i][1]] == 0) {
                    echo "<br/><a class=small href=\"gradebook.php?cid={$cid}&amp;cat={$gbt[0][2][$i][10]}&amp;catcollapse=2\">", _('[Collapse]'), "</a>";
                } else {
                    echo "<br/><a class=small href=\"gradebook.php?cid={$cid}&amp;cat={$gbt[0][2][$i][10]}&amp;catcollapse=0\">", _('[Expand]'), "</a>";
                }
                echo '</span></div></th>';
                $n++;
            }
        }
        //total totals
        if ($catfilter < 0) {
            if (isset($gbt[0][3][0])) {
                //using points based
                echo '<th><div><span class="cattothdr">', _('Total'), '<br/>' . $gbt[0][3][$availshow] . '&nbsp;', _('pts'), '</span></div></th>';
                echo '<th><div>%</div></th>';
                $n += 2;
            } else {
                echo '<th><div><span class="cattothdr">', _('Weighted Total %'), '</span></div></th>';
                $n++;
            }
        }
    }
    echo '</tr></thead><tbody>';
    //create student rows
    if (isset($GLOBALS['CFG']['GEN']['AWSforcoursefiles']) && $GLOBALS['CFG']['GEN']['AWSforcoursefiles'] == true) {
        $userimgbase = $urlmode . "s3.amazonaws.com/{$GLOBALS['AWSbucket']}/cfiles";
    } else {
        $userimgbase = "{$imasroot}/course/files";
    }
    for ($i = 1; $i < count($gbt); $i++) {
        if ($i == 1) {
            $insdiv = "<div>";
            $enddiv = "</div>";
        } else {
            $insdiv = '';
            $enddiv = '';
        }
        if ($i % 2 != 0) {
            echo "<tr class=even onMouseOver=\"highlightrow(this)\" onMouseOut=\"unhighlightrow(this)\">";
        } else {
            echo "<tr class=odd onMouseOver=\"highlightrow(this)\" onMouseOut=\"unhighlightrow(this)\">";
        }
        echo '<td class="locked" scope="row"><div class="trld">';
        if ($gbt[$i][0][0] != "Averages" && $isteacher) {
            echo "<input type=\"checkbox\" name='checked[]' value='{$gbt[$i][4][0]}' />&nbsp;";
        }
        echo "<a href=\"gradebook.php?cid={$cid}&amp;stu={$gbt[$i][4][0]}\">";
        if ($gbt[$i][4][1] > 0) {
            echo '<span class="greystrike">' . $gbt[$i][0][0] . '</span>';
        } else {
            echo $gbt[$i][0][0];
        }
        echo '</a>';
        if ($gbt[$i][4][3] == 1) {
            echo '<sup>*</sup>';
        }
        echo '</div></td>';
        if ($showpics == 1 && $gbt[$i][4][2] == 1) {
            //file_exists("$curdir//files/userimg_sm{$gbt[$i][4][0]}.jpg")) {
            echo "<td>{$insdiv}<div class=\"trld\"><img src=\"{$userimgbase}/userimg_sm{$gbt[$i][4][0]}.jpg\"/></div></td>";
        } else {
            if ($showpics == 2 && $gbt[$i][4][2] == 1) {
                echo "<td>{$insdiv}<div class=\"trld\"><img src=\"{$userimgbase}/userimg_{$gbt[$i][4][0]}.jpg\"/></div></td>";
            } else {
                echo '<td>' . $insdiv . '<div class="trld">&nbsp;</div></td>';
            }
        }
        for ($j = $gbt[0][0][1] == 'ID' ? 1 : 2; $j < count($gbt[0][0]); $j++) {
            echo '<td class="c">' . $insdiv . $gbt[$i][0][$j] . $enddiv . '</td>';
        }
        if ($totonleft && !$hidepast) {
            //total totals
            if ($catfilter < 0) {
                if ($availshow == 3) {
                    if ($gbt[$i][0][0] == 'Averages') {
                        if (isset($gbt[$i][3][8])) {
                            //using points based
                            echo '<td class="c">' . $insdiv . $gbt[$i][3][6] . '%' . $enddiv . '</td>';
                        }
                        echo '<td class="c">' . $insdiv . $gbt[$i][3][6] . '%' . $enddiv . '</td>';
                    } else {
                        if (isset($gbt[$i][3][8])) {
                            //using points based
                            echo '<td class="c">' . $insdiv . $gbt[$i][3][6] . '/' . $gbt[$i][3][7] . $enddiv . '</td>';
                            echo '<td class="c">' . $insdiv . $gbt[$i][3][8] . '%' . $enddiv . '</td>';
                        } else {
                            echo '<td class="c">' . $insdiv . $gbt[$i][3][6] . '%' . $enddiv . '</td>';
                        }
                    }
                } else {
                    if (isset($gbt[0][3][0])) {
                        //using points based
                        echo '<td class="c">' . $insdiv . $gbt[$i][3][$availshow] . $enddiv . '</td>';
                        echo '<td class="c">' . $insdiv . $gbt[$i][3][$availshow + 3] . '%' . $enddiv . '</td>';
                    } else {
                        echo '<td class="c">' . $insdiv . $gbt[$i][3][$availshow] . '%' . $enddiv . '</td>';
                    }
                }
            }
            //category totals
            if (count($gbt[0][2]) > 1 || $catfilter != -1) {
                //want to show cat headers?
                for ($j = 0; $j < count($gbt[0][2]); $j++) {
                    //category headers
                    if (($availshow < 2 || $availshow == 3) && $gbt[0][2][$j][2] > 1) {
                        continue;
                    } else {
                        if ($availshow == 2 && $gbt[0][2][$j][2] == 3) {
                            continue;
                        }
                    }
                    if ($catfilter != -1 && $availshow < 3 && $gbt[0][2][$j][$availshow + 3] > 0) {
                        //echo '<td class="c">'.$gbt[$i][2][$j][$availshow].' ('.round(100*$gbt[$i][2][$j][$availshow]/$gbt[0][2][$j][$availshow+3])  .'%)</td>';
                        echo '<td class="c">' . $insdiv;
                        if ($gbt[$i][0][0] == 'Averages' && $availshow != 3) {
                            echo "<span onmouseover=\"tipshow(this,'", _('5-number summary:'), " {$gbt[0][2][$j][6 + $availshow]}')\" onmouseout=\"tipout()\" >";
                        }
                        echo $gbt[$i][2][$j][$availshow] . ' (' . round(100 * $gbt[$i][2][$j][$availshow] / $gbt[0][2][$j][$availshow + 3]) . '%)';
                        if ($gbt[$i][0][0] == 'Averages' && $availshow != 3) {
                            echo '</span>';
                        }
                        echo $enddiv . '</td>';
                    } else {
                        //echo '<td class="c">'.$gbt[$i][2][$j][$availshow].'</td>';
                        echo '<td class="c">' . $insdiv;
                        if ($gbt[$i][0][0] == 'Averages') {
                            echo "<span onmouseover=\"tipshow(this,'", _('5-number summary:'), " {$gbt[0][2][$j][6 + $availshow]}')\" onmouseout=\"tipout()\" >";
                        }
                        if ($availshow == 3) {
                            if ($gbt[$i][0][0] == 'Averages') {
                                echo $gbt[$i][2][$j][3] . '%';
                                //echo '-';
                            } else {
                                echo $gbt[$i][2][$j][3] . '/' . $gbt[$i][2][$j][4];
                            }
                        } else {
                            if (isset($gbt[$i][3][8])) {
                                //using points based
                                echo $gbt[$i][2][$j][$availshow];
                            } else {
                                if ($gbt[0][2][$j][3 + $availshow] > 0) {
                                    echo round(100 * $gbt[$i][2][$j][$availshow] / $gbt[0][2][$j][3 + $availshow], 1) . '%';
                                } else {
                                    echo '0%';
                                }
                            }
                        }
                        if ($gbt[$i][0][0] == 'Averages') {
                            echo '</span>';
                        }
                        echo $enddiv . '</td>';
                    }
                }
            }
        }
        //assessment values
        if ($catfilter > -2) {
            for ($j = 0; $j < count($gbt[0][1]); $j++) {
                if (!$isteacher && !$istutor && $gbt[0][1][$j][4] == 0) {
                    //skip if hidden
                    continue;
                }
                if ($hidenc == 1 && $gbt[0][1][$j][4] == 0) {
                    //skip NC
                    continue;
                } else {
                    if ($hidenc == 2 && ($gbt[0][1][$j][4] == 0 || $gbt[0][1][$j][4] == 3)) {
                        //skip all NC
                        continue;
                    }
                }
                if ($gbt[0][1][$j][3] > $availshow) {
                    continue;
                }
                if ($hidepast && $gbt[0][1][$j][3] == 0) {
                    continue;
                }
                if ($collapsegbcat[$gbt[0][1][$j][1]] == 2) {
                    continue;
                }
                //if online, not average, and either score exists and active, or score doesn't exist and assess is current,
                if ($gbt[0][1][$j][6] == 0 && $gbt[$i][1][$j][4] != 'average' && (isset($gbt[$i][1][$j][3]) && $gbt[$i][1][$j][3] > 9 || !isset($gbt[$i][1][$j][3]) && $gbt[0][1][$j][3] == 1)) {
                    echo '<td class="c isact">' . $insdiv;
                } else {
                    echo '<td class="c">' . $insdiv;
                }
                if (isset($gbt[$i][1][$j][5]) && $gbt[$i][1][$j][5] & 1 << $availshow && !$hidepast) {
                    echo '<span style="font-style:italic">';
                }
                if ($gbt[0][1][$j][6] == 0) {
                    //online
                    if (isset($gbt[$i][1][$j][0])) {
                        if ($istutor && $gbt[$i][1][$j][4] == 'average') {
                        } else {
                            if ($gbt[$i][1][$j][4] == 'average') {
                                echo "<a href=\"gb-itemanalysis.php?stu={$stu}&amp;cid={$cid}&amp;asid={$gbt[$i][1][$j][4]}&amp;aid={$gbt[0][1][$j][7]}\" ";
                                echo "onmouseover=\"tipshow(this,'", _('5-number summary:'), " {$gbt[0][1][$j][9]}')\" onmouseout=\"tipout()\" ";
                                echo ">";
                            } else {
                                echo "<a href=\"gb-viewasid.php?stu={$stu}&amp;cid={$cid}&amp;asid={$gbt[$i][1][$j][4]}&amp;uid={$gbt[$i][4][0]}\">";
                            }
                        }
                        if ($gbt[$i][1][$j][3] > 9) {
                            $gbt[$i][1][$j][3] -= 10;
                        }
                        echo $gbt[$i][1][$j][0];
                        if ($gbt[$i][1][$j][3] == 1) {
                            echo ' (NC)';
                        } else {
                            if ($gbt[$i][1][$j][3] == 2) {
                                echo ' (IP)';
                            } else {
                                if ($gbt[$i][1][$j][3] == 3) {
                                    echo ' (OT)';
                                } else {
                                    if ($gbt[$i][1][$j][3] == 4) {
                                        echo ' (PT)';
                                    }
                                }
                            }
                        }
                        if ($istutor && $gbt[$i][1][$j][4] == 'average') {
                        } else {
                            echo '</a>';
                        }
                        if ($gbt[$i][1][$j][1] == 1) {
                            echo '<sup>*</sup>';
                        }
                    } else {
                        //no score
                        if ($gbt[$i][0][0] == 'Averages') {
                            echo '-';
                        } else {
                            if ($isteacher) {
                                echo "<a href=\"gb-viewasid.php?stu={$stu}&amp;cid={$cid}&amp;asid=new&amp;aid={$gbt[0][1][$j][7]}&amp;uid={$gbt[$i][4][0]}\">-</a>";
                            } else {
                                echo '-';
                            }
                        }
                    }
                    if (isset($gbt[$i][1][$j][6])) {
                        if ($gbt[$i][1][$j][6] > 1) {
                            if ($gbt[$i][1][$j][6] > 2) {
                                echo '<sup>LP (' . ($gbt[$i][1][$j][6] - 1) . ')</sup>';
                            } else {
                                echo '<sup>LP</sup>';
                            }
                        } else {
                            echo '<sup>e</sup>';
                        }
                    }
                } else {
                    if ($gbt[0][1][$j][6] == 1) {
                        //offline
                        if ($isteacher) {
                            if ($gbt[$i][0][0] == 'Averages') {
                                echo "<a href=\"addgrades.php?stu={$stu}&amp;cid={$cid}&amp;grades=all&amp;gbitem={$gbt[0][1][$j][7]}\" ";
                                echo "onmouseover=\"tipshow(this,'", _('5-number summary:'), " {$gbt[0][1][$j][9]}')\" onmouseout=\"tipout()\" ";
                                echo ">";
                            } else {
                                echo "<a href=\"addgrades.php?stu={$stu}&amp;cid={$cid}&amp;grades={$gbt[$i][4][0]}&amp;gbitem={$gbt[0][1][$j][7]}\">";
                            }
                        } else {
                            if ($istutor && $gbt[0][1][$j][8] == 1) {
                                if ($gbt[$i][0][0] == 'Averages') {
                                    echo "<a href=\"addgrades.php?stu={$stu}&amp;cid={$cid}&amp;grades=all&amp;gbitem={$gbt[0][1][$j][7]}\">";
                                } else {
                                    echo "<a href=\"addgrades.php?stu={$stu}&amp;cid={$cid}&amp;grades={$gbt[$i][4][0]}&amp;gbitem={$gbt[0][1][$j][7]}\">";
                                }
                            }
                        }
                        if (isset($gbt[$i][1][$j][0])) {
                            echo $gbt[$i][1][$j][0];
                            if ($gbt[$i][1][$j][3] == 1) {
                                echo ' (NC)';
                            }
                        } else {
                            echo '-';
                        }
                        if ($isteacher || $istutor && $gbt[0][1][$j][8] == 1) {
                            echo '</a>';
                        }
                        if ($gbt[$i][1][$j][1] == 1) {
                            echo '<sup>*</sup>';
                        }
                    } else {
                        if ($gbt[0][1][$j][6] == 2) {
                            //discuss
                            if (isset($gbt[$i][1][$j][0])) {
                                if ($gbt[$i][0][0] != 'Averages') {
                                    echo "<a href=\"viewforumgrade.php?cid={$cid}&amp;stu={$stu}&amp;uid={$gbt[$i][4][0]}&amp;fid={$gbt[0][1][$j][7]}\">";
                                    echo $gbt[$i][1][$j][0];
                                    echo '</a>';
                                } else {
                                    echo "<span onmouseover=\"tipshow(this,'", _('5-number summary:'), " {$gbt[0][1][$j][9]}')\" onmouseout=\"tipout()\"> ";
                                    echo $gbt[$i][1][$j][0];
                                    echo '</span>';
                                }
                                if ($gbt[$i][1][$j][1] == 1) {
                                    echo '<sup>*</sup>';
                                }
                            } else {
                                if ($isteacher && $gbt[$i][0][0] != 'Averages') {
                                    echo "<a href=\"viewforumgrade.php?cid={$cid}&amp;stu={$stu}&amp;uid={$gbt[$i][4][0]}&amp;fid={$gbt[0][1][$j][7]}\">-</a>";
                                } else {
                                    echo '-';
                                }
                            }
                        } else {
                            if ($gbt[0][1][$j][6] == 3) {
                                //exttool
                                if ($isteacher) {
                                    if ($gbt[$i][0][0] == 'Averages') {
                                        echo "<a href=\"edittoolscores.php?stu={$stu}&amp;cid={$cid}&amp;uid=all&amp;lid={$gbt[0][1][$j][7]}\" ";
                                        echo "onmouseover=\"tipshow(this,'", _('5-number summary:'), " {$gbt[0][1][$j][9]}')\" onmouseout=\"tipout()\" ";
                                        echo ">";
                                    } else {
                                        echo "<a href=\"edittoolscores.php?stu={$stu}&amp;cid={$cid}&amp;uid={$gbt[$i][4][0]}&amp;lid={$gbt[0][1][$j][7]}\">";
                                    }
                                } else {
                                    if ($istutor && $gbt[0][1][$j][8] == 1) {
                                        if ($gbt[$i][0][0] == 'Averages') {
                                            echo "<a href=\"edittoolscores.php?stu={$stu}&amp;cid={$cid}&amp;uid=all&amp;lid={$gbt[0][1][$j][7]}\">";
                                        } else {
                                            echo "<a href=\"edittoolscores.php?stu={$stu}&amp;cid={$cid}&amp;uid={$gbt[$i][4][0]}&amp;lid={$gbt[0][1][$j][7]}\">";
                                        }
                                    }
                                }
                                if (isset($gbt[$i][1][$j][0])) {
                                    echo $gbt[$i][1][$j][0];
                                    if ($gbt[$i][1][$j][3] == 1) {
                                        echo ' (NC)';
                                    }
                                } else {
                                    echo '-';
                                }
                                if ($isteacher || $istutor && $gbt[0][1][$j][8] == 1) {
                                    echo '</a>';
                                }
                                if ($gbt[$i][1][$j][1] == 1) {
                                    echo '<sup>*</sup>';
                                }
                            }
                        }
                    }
                }
                if (isset($gbt[$i][1][$j][5]) && $gbt[$i][1][$j][5] & 1 << $availshow && !$hidepast) {
                    echo '<sub>d</sub></span>';
                }
                echo $enddiv . '</td>';
            }
        }
        if (!$totonleft && !$hidepast) {
            //category totals
            if (count($gbt[0][2]) > 1 || $catfilter != -1) {
                //want to show cat headers?
                for ($j = 0; $j < count($gbt[0][2]); $j++) {
                    //category headers
                    if (($availshow < 2 || $availshow == 3) && $gbt[0][2][$j][2] > 1) {
                        continue;
                    } else {
                        if ($availshow == 2 && $gbt[0][2][$j][2] == 3) {
                            continue;
                        }
                    }
                    if ($catfilter != -1 && $availshow < 3 && $gbt[0][2][$j][$availshow + 3] > 0) {
                        //echo '<td class="c">'.$gbt[$i][2][$j][$availshow].' ('.round(100*$gbt[$i][2][$j][$availshow]/$gbt[0][2][$j][$availshow+3])  .'%)</td>';
                        echo '<td class="c">' . $insdiv;
                        if ($gbt[$i][0][0] == 'Averages' && $availshow != 3) {
                            echo "<span onmouseover=\"tipshow(this,'", _('5-number summary:'), " {$gbt[0][2][$j][6 + $availshow]}')\" onmouseout=\"tipout()\" >";
                        }
                        echo $gbt[$i][2][$j][$availshow] . ' (' . round(100 * $gbt[$i][2][$j][$availshow] / $gbt[0][2][$j][$availshow + 3]) . '%)';
                        if ($gbt[$i][0][0] == 'Averages' && $availshow != 3) {
                            echo '</span>';
                        }
                        echo $enddiv . '</td>';
                    } else {
                        //echo '<td class="c">'.$gbt[$i][2][$j][$availshow].'</td>';
                        echo '<td class="c">' . $insdiv;
                        if ($gbt[$i][0][0] == 'Averages' && $availshow < 3) {
                            echo "<span onmouseover=\"tipshow(this,'", _('5-number summary:'), " {$gbt[0][2][$j][6 + $availshow]}')\" onmouseout=\"tipout()\" >";
                        }
                        if ($availshow == 3) {
                            if ($gbt[$i][0][0] == 'Averages') {
                                echo $gbt[$i][2][$j][3] . '%';
                            } else {
                                echo $gbt[$i][2][$j][3] . '/' . $gbt[$i][2][$j][4];
                            }
                        } else {
                            if (isset($gbt[$i][3][8])) {
                                //using points based
                                echo $gbt[$i][2][$j][$availshow];
                            } else {
                                if ($gbt[0][2][$j][3 + $availshow] > 0) {
                                    echo round(100 * $gbt[$i][2][$j][$availshow] / $gbt[0][2][$j][3 + $availshow], 1) . '%';
                                } else {
                                    echo '0%';
                                }
                            }
                        }
                        if ($gbt[$i][0][0] == 'Averages' && $availshow < 3) {
                            echo '</span>';
                        }
                        echo $enddiv . '</td>';
                    }
                }
            }
            //total totals
            if ($catfilter < 0) {
                if ($availshow == 3) {
                    if ($gbt[$i][0][0] == 'Averages') {
                        if (isset($gbt[$i][3][8])) {
                            //using points based
                            echo '<td class="c">' . $insdiv . $gbt[$i][3][6] . '%' . $enddiv . '</td>';
                        }
                        echo '<td class="c">' . $insdiv . $gbt[$i][3][6] . '%' . $enddiv . '</td>';
                    } else {
                        if (isset($gbt[$i][3][8])) {
                            //using points based
                            echo '<td class="c">' . $insdiv . $gbt[$i][3][6] . '/' . $gbt[$i][3][7] . $enddiv . '</td>';
                            echo '<td class="c">' . $insdiv . $gbt[$i][3][8] . '%' . $enddiv . '</td>';
                        } else {
                            echo '<td class="c">' . $insdiv . $gbt[$i][3][6] . '%' . $enddiv . '</td>';
                        }
                    }
                } else {
                    if (isset($gbt[0][3][0])) {
                        //using points based
                        echo '<td class="c">' . $insdiv . $gbt[$i][3][$availshow] . $enddiv . '</td>';
                        echo '<td class="c">' . $insdiv . $gbt[$i][3][$availshow + 3] . '%' . $enddiv . '</td>';
                    } else {
                        echo '<td class="c">' . $insdiv . $gbt[$i][3][$availshow] . '%' . $enddiv . '</td>';
                    }
                }
            }
        }
        echo '</tr>';
    }
    echo "</tbody></table></div></div>";
    if ($n > 1) {
        $sarr = array_merge($sortarr, array_fill(0, $n, "'N'"));
    } else {
        $sarr = array();
    }
    $sarr = implode(",", $sarr);
    if (count($gbt) < 500) {
        if ($avgontop) {
            echo "<script>initSortTable('myTable',Array({$sarr}),true,true,false);</script>\n";
        } else {
            echo "<script>initSortTable('myTable',Array({$sarr}),true,false);</script>\n";
        }
    }
    if ($colorize != '0') {
        echo '<script type="text/javascript">addLoadEvent( function() {updateColors(document.getElementById("colorsel"));} );</script>';
    }
}