コード例 #1
0
ファイル: importlib.php プロジェクト: ericvanboven/IMathAS
function printlist($parent)
{
    global $parents, $names;
    $children = array_keys($parents, $parent);
    foreach ($children as $child) {
        if (!in_array($child, $parents)) {
            //if no children
            echo "<li><span class=dd>-</span><input type=checkbox name=\"libs[]\" value=\"{$child}\" CHECKED>{$names[$child]}</li>";
        } else {
            // if children
            echo "<li class=lihdr><span class=dd>-</span><span class=hdr onClick=\"toggle({$child})\"><span class=btn id=\"b{$child}\">+</span> ";
            echo "</span><input type=checkbox name=\"libs[]\" value={$child} CHECKED>";
            echo "<span class=hdr onClick=\"toggle({$child})\">{$names[$child]}</span>";
            echo "<ul class=hide id={$child}>\n";
            printlist($child);
            echo "</ul></li>\n";
        }
    }
}
コード例 #2
0
ファイル: managelibs.php プロジェクト: ericvanboven/IMathAS
function printlist($parent)
{
    global $names, $ltlibs, $count, $qcount, $cid, $rights, $sortorder, $ownerids, $userid, $isadmin, $groupids, $groupid, $isgrpadmin;
    $arr = $ltlibs[$parent];
    if ($sortorder[$parent] == 1) {
        $orderarr = array();
        foreach ($arr as $child) {
            $orderarr[$child] = $names[$child];
        }
        natcasesort($orderarr);
        $arr = array_keys($orderarr);
    }
    foreach ($arr as $child) {
        //if ($rights[$child]>0 || $ownerids[$child]==$userid || $isadmin) {
        if ($rights[$child] > 2 || $rights[$child] > 0 && $groupids[$child] == $groupid || $ownerids[$child] == $userid || $isgrpadmin && $groupids[$child] == $groupid || $isadmin) {
            if (!$isadmin) {
                if ($rights[$child] == 5 && $groupids[$child] != $groupid) {
                    $rights[$child] = 4;
                    //adjust coloring
                }
            }
            if (isset($ltlibs[$child])) {
                //library has children
                //echo "<li><input type=button id=\"b$count\" value=\"-\" onClick=\"toggle($count)\"> {$names[$child]}";
                echo "<li class=lihdr><span class=dd>-</span><span class=hdr onClick=\"toggle({$child})\"><span class=btn id=\"b{$child}\">+</span> ";
                echo "</span><input type=checkbox name=\"nchecked[]\" value={$child}> <span class=hdr onClick=\"toggle({$child})\"><span class=\"r{$rights[$child]}\">{$names[$child]}</span> </span>\n";
                //if ($isadmin) {
                echo " ({$qcount[$child]}) ";
                //}
                echo "<span class=op>";
                if ($ownerids[$child] == $userid || $isgrpadmin && $groupids[$child] == $groupid || $isadmin) {
                    echo "<a href=\"managelibs.php?cid={$cid}&modify={$child}\">Modify</a> | ";
                    echo "<a href=\"managelibs.php?cid={$cid}&remove={$child}\">Delete</a> | ";
                    echo "<a href=\"managelibs.php?cid={$cid}&transfer={$child}\">Transfer</a> | ";
                }
                echo "<a href=\"managelibs.php?cid={$cid}&modify=new&parent={$child}\">Add Sub</a> ";
                echo "<ul class=hide id={$child}>\n";
                echo "</span>";
                $count++;
                printlist($child);
                echo "</ul></li>\n";
            } else {
                //no children
                echo "<li><span class=dd>-</span><input type=checkbox name=\"nchecked[]\" value={$child}> <span class=\"r{$rights[$child]}\">{$names[$child]}</span> ";
                //if ($isadmin) {
                echo " ({$qcount[$child]}) ";
                //}
                echo "<span class=op>";
                if ($ownerids[$child] == $userid || $isgrpadmin && $groupids[$child] == $groupid || $isadmin) {
                    echo "<a href=\"managelibs.php?cid={$cid}&modify={$child}\">Modify</a> | ";
                    echo "<a href=\"managelibs.php?cid={$cid}&remove={$child}\">Delete</a> | ";
                    echo "<a href=\"managelibs.php?cid={$cid}&transfer={$child}\">Transfer</a> | ";
                }
                if ($qcount[$child] == 0) {
                    echo "<a href=\"managelibs.php?cid={$cid}&modify=new&parent={$child}\">Add Sub</a> ";
                } else {
                    echo "<a href=\"reviewlibrary.php?cid={$cid}&lib={$child}\">Preview</a>";
                }
                echo "</span>";
                echo "</li>\n";
            }
        }
    }
}
コード例 #3
0
ファイル: libtree.php プロジェクト: ericvanboven/IMathAS
function printlist($parent)
{
    global $names, $ltlibs, $checked, $toopen, $select, $isempty, $rights, $sortorder, $ownerids, $isadmin, $selectrights, $allsrights, $published, $userid, $locked, $groupids, $groupid, $isgrpadmin;
    $arr = array();
    if ($parent == 0 && isset($published)) {
        $arr = explode(',', $published);
    } else {
        $arr = $ltlibs[$parent];
    }
    if (count($arr) == 0) {
        return;
    }
    if ($sortorder[$parent] == 1) {
        $orderarr = array();
        foreach ($arr as $child) {
            $orderarr[$child] = $names[$child];
        }
        natcasesort($orderarr);
        $arr = array_keys($orderarr);
    }
    foreach ($arr as $child) {
        if ($rights[$child] > $allsrights || $rights[$child] % 3 > $selectrights && $groupids[$child] == $groupid || $ownerids[$child] == $userid || $isgrpadmin && $groupids[$child] == $groupid || $isadmin) {
            //if ($rights[$child]>$selectrights || $ownerids[$child]==$userid || $isadmin) {
            if (!$isadmin) {
                if ($rights[$child] == 5 && $groupids[$child] != $groupid) {
                    $rights[$child] = 4;
                    //adjust coloring
                }
            }
            if (isset($ltlibs[$child])) {
                //library has children
                //echo "<li><input type=button id=\"b$count\" value=\"-\" onClick=\"toggle($count)\"> {$names[$child]}";
                echo "<li class=lihdr><span class=dd>-</span><span class=hdr onClick=\"toggle({$child})\"><span class=btn id=\"b{$child}\">+</span> ";
                if ($select == "parent" || $select == "all") {
                    if ($_GET['type'] == "radio") {
                        if (in_array($child, $locked) || $select == "parent" && $rights[$child] > 2 && !$allownongrouplibs && !$isadmin && !$isgrpadmin) {
                            echo "</span><input type=radio disabled=\"disabled\" ";
                        } else {
                            echo "</span><input type=radio name=\"libs\" value={$child} ";
                        }
                        if (in_array($child, $checked)) {
                            echo "CHECKED";
                        }
                        echo "><span class=hdr onClick=\"toggle({$child})\">";
                    } else {
                        if (in_array($child, $locked)) {
                            echo "</span><input type=checkbox disabled=\"disabled\" ";
                        } else {
                            echo "</span><input type=checkbox name=\"libs[]\" value={$child} ";
                        }
                        if (in_array($child, $checked)) {
                            echo "CHECKED";
                        }
                        echo "><span class=hdr onClick=\"toggle({$child})\">";
                    }
                }
                echo " <span id=\"n{$child}\" class=\"r{$rights[$child]}\">{$names[$child]}</span> </span>\n";
                echo "<ul class=hide id={$child}>\n";
                printlist($child);
                echo "</ul></li>\n";
            } else {
                //no children
                if ($select == "child" || $select == "all" || $isempty[$child] == true) {
                    if ($_GET['type'] == "radio") {
                        if (in_array($child, $locked) || $select == "parent" && $rights[$child] > 2 && !$allownongrouplibs && !$isadmin && !$isgrpadmin) {
                            echo "<li><span class=dd>---</span> <input type=radio disabled=\"disabled\" ";
                        } else {
                            if ($select == "parent") {
                                echo "<li><span class=dd>---</span> <input type=radio name=\"libs\" value={$child} ";
                            } else {
                                echo "<li><span class=dd>-</span> <input type=radio name=\"libs\" value={$child} ";
                            }
                        }
                        if (in_array($child, $checked)) {
                            echo "CHECKED";
                        }
                        echo "> <span id=\"n{$child}\" class=\"r{$rights[$child]}\">{$names[$child]}</span></li>\n";
                    } else {
                        if (in_array($child, $locked)) {
                            echo "<li><span class=dd>-</span><input type=checkbox disabled=\"disabled\" ";
                        } else {
                            echo "<li><span class=dd>-</span><input type=checkbox name=\"libs[]\" value={$child} ";
                        }
                        if (in_array($child, $checked)) {
                            echo "CHECKED";
                        }
                        echo "> <span id=\"n{$child}\" class=\"r{$rights[$child]}\">{$names[$child]}</span></li>\n";
                    }
                } else {
                    echo "<li><span class=dd>---</span> <span id=\"n{$child}\" class=\"r{$rights[$child]}\">{$names[$child]}</span></li>\n";
                }
            }
        }
    }
}
コード例 #4
0
ファイル: libtree2.php プロジェクト: ericvanboven/IMathAS
function printlist($parent)
{
    global $names, $ltlibs, $checked, $toopen, $select, $isempty, $rights, $sortorder, $ownerids, $isadmin, $selectrights, $allsrights, $published, $userid, $locked, $groupids, $groupid, $isgrpadmin, $donefirst;
    $newchildren = array();
    $arr = array();
    if ($parent == 0 && isset($published)) {
        $arr = explode(',', $published);
    } else {
        $arr = $ltlibs[$parent];
    }
    if (count($arr) == 0) {
        return;
    }
    if ($donefirst[$parent] == 0) {
        echo ",\n{$parent}:[";
        $donefirst[$parent] == 1;
    }
    if ($sortorder[$parent] == 1) {
        $orderarr = array();
        foreach ($arr as $child) {
            $orderarr[$child] = $names[$child];
        }
        natcasesort($orderarr);
        $arr = array_keys($orderarr);
    }
    foreach ($arr as $child) {
        if ($rights[$child] > $allsrights || $rights[$child] % 3 > $selectrights && $groupids[$child] == $groupid || $ownerids[$child] == $userid || $isgrpadmin && $groupids[$child] == $groupid || $isadmin) {
            //if ($rights[$child]>$selectrights || $ownerids[$child]==$userid || $isadmin) {
            if (!$isadmin) {
                if ($rights[$child] == 5 && $groupids[$child] != $groupid) {
                    $rights[$child] = 4;
                    //adjust coloring
                }
            }
            if ($donefirst[$parent] == 2) {
                echo ",";
            } else {
                $donefirst[$parent] = 2;
            }
            echo "[{$child},{$rights[$child]},'{$names[$child]}',";
            if (isset($ltlibs[$child])) {
                //library has children
                if ($select == "parent" || $select == "all") {
                    if ($_GET['type'] == "radio") {
                        if (in_array($child, $locked)) {
                            //removed the following which prevented creation of sublibraries of "open to all" libs.  Not sure why I had that.   || ($select=="parent" && $rights[$child]>2 && !$allownongrouplibs && !$isadmin && !$isgrpadmin)) {
                            echo "1,";
                        } else {
                            echo ",";
                        }
                        if (in_array($child, $checked)) {
                            echo "1";
                        }
                        //else {echo "0";}
                        echo "]";
                    } else {
                        if (in_array($child, $locked)) {
                            echo "1,";
                        } else {
                            echo ",";
                        }
                        if (in_array($child, $checked)) {
                            echo "1";
                        }
                        //else {echo "0";}
                        echo "]";
                    }
                } else {
                    echo "-1,]";
                }
                $newchildren[] = $child;
            } else {
                //no children
                if ($select == "child" || $select == "all" || $isempty[$child] == true) {
                    if ($_GET['type'] == "radio") {
                        if (in_array($child, $locked) || $select == "parent" && $rights[$child] > 2 && !$allownongrouplibs && !$isadmin && !$isgrpadmin) {
                            echo "1,";
                        } else {
                            echo ",";
                        }
                        if (in_array($child, $checked)) {
                            echo "1";
                        }
                        //else {echo "0";}
                        echo "]";
                    } else {
                        if (in_array($child, $locked)) {
                            echo "1,";
                        } else {
                            echo ",";
                        }
                        if (in_array($child, $checked)) {
                            echo "1";
                        }
                        //else {echo "0";}
                        echo "]";
                    }
                } else {
                    echo "-1,]";
                }
            }
        }
    }
    echo "]";
    foreach ($newchildren as $newchild) {
        $donefirst[$newchild] = false;
        printlist($newchild);
    }
}
コード例 #5
0
ファイル: treereader.php プロジェクト: ericvanboven/IMathAS
function printlist($items)
{
    global $cid, $imasroot, $foundfirstitem, $foundopenitem, $openitem, $astatus, $studentinfo, $now, $viewall, $exceptions;
    $out = '';
    $isopen = false;
    foreach ($items as $item) {
        if (is_array($item)) {
            //is block
            //TODO check that it's available
            if ($viewall || $item['avail'] == 2 || $item['avail'] == 1 && $item['startdate'] < $now && $item['enddate'] > $now) {
                list($subcontent, $bisopen) = printlist($item['items']);
                if ($bisopen) {
                    $isopen = true;
                }
                if ($bisopen) {
                    $out .= "<li class=lihdr><span class=hdr onClick=\"toggle({$item['id']})\"><span class=btn id=\"b{$item['id']}\">-</span> <img src=\"{$imasroot}/img/folder_tiny.png\"> ";
                    $out .= "{$item['name']}</span>\n";
                    $out .= '<ul class="show nomark" id="' . $item['id'] . '">';
                } else {
                    $out .= "<li class=lihdr><span class=hdr onClick=\"toggle({$item['id']})\"><span class=btn id=\"b{$item['id']}\">+</span> <img src=\"{$imasroot}/img/folder_tiny.png\"> ";
                    $out .= "{$item['name']}</span>\n";
                    $out .= '<ul class="hide nomark" id="' . $item['id'] . '">';
                }
                $out .= $subcontent;
                $out .= '</ul></li>';
            }
        } else {
            $query = "SELECT itemtype,typeid FROM imas_items WHERE id='{$item}'";
            $result = mysql_query($query) or die("Query failed : {$query} " . mysql_error());
            $line = mysql_fetch_array($result, MYSQL_ASSOC);
            $typeid = $line['typeid'];
            $itemtype = $line['itemtype'];
            /*if ($line['itemtype']=="Calendar") {
            			$out .=  '<li><img src="'.$imasroot.'/img/calendar_tiny.png"> <a href="showcalendar.php?cid='.$cid.'" target="readerframe">Calendar</a></li>';
            			if ($openitem=='' && $foundfirstitem=='') {
            			 	 $foundfirstitem = '/course/showcalendar.php?cid='.$cid;
            			 	 $isopen = true;
            			}
            		} else*/
            if ($line['itemtype'] == 'Assessment') {
                //TODO check availability, timelimit, etc.
                //TODO: reqscoreaid, latepasses
                $query = "SELECT name,summary,startdate,enddate,reviewdate,deffeedback,reqscore,reqscoreaid,avail,allowlate,timelimit,displaymethod FROM imas_assessments WHERE id='{$typeid}'";
                $result = mysql_query($query) or die("Query failed : " . mysql_error());
                $line = mysql_fetch_array($result, MYSQL_ASSOC);
                if (isset($exceptions[$item])) {
                    $line['startdate'] = $exceptions[$item][0];
                    $line['enddate'] = $exceptions[$item][1];
                }
                if ($viewall || $line['avail'] == 1 && $line['startdate'] < $now && ($line['enddate'] > $now || $line['reviewdate'] > $now)) {
                    if ($openitem == '' && $foundfirstitem == '') {
                        $foundfirstitem = '/assessment/showtest.php?cid=' . $cid . '&amp;id=' . $typeid;
                        $isopen = true;
                    }
                    if ($itemtype . $typeid === $openitem) {
                        $foundopenitem = '/assessment/showtest.php?cid=' . $cid . '&amp;id=' . $typeid;
                        $isopen = true;
                    }
                    $out .= '<li>';
                    if ($line['displaymethod'] != 'Embed') {
                        $out .= '<img src="' . $imasroot . '/img/assess_tiny.png"> ';
                    } else {
                        if (!isset($astatus[$typeid]) || $astatus[$typeid] == 0) {
                            $out .= '<img id="aimg' . $typeid . '" src="' . $imasroot . '/img/q_fullbox.gif" /> ';
                        } else {
                            if ($astatus[$typeid] == 1) {
                                $out .= '<img id="aimg' . $typeid . '" src="' . $imasroot . '/img/q_halfbox.gif" /> ';
                            } else {
                                $out .= '<img id="aimg' . $typeid . '" src="' . $imasroot . '/img/q_emptybox.gif" /> ';
                            }
                        }
                    }
                    if (isset($studentinfo['timelimitmult'])) {
                        $line['timelimit'] *= $studentinfo['timelimitmult'];
                    }
                    $line['timelimit'] = abs($line['timelimit']);
                    if ($line['timelimit'] > 0) {
                        if ($line['timelimit'] > 3600) {
                            $tlhrs = floor($line['timelimit'] / 3600);
                            $tlrem = $line['timelimit'] % 3600;
                            $tlmin = floor($tlrem / 60);
                            $tlsec = $tlrem % 60;
                            $tlwrds = "{$tlhrs} " . _('hour');
                            if ($tlhrs > 1) {
                                $tlwrds .= "s";
                            }
                            if ($tlmin > 0) {
                                $tlwrds .= ", {$tlmin} " . _('minute');
                            }
                            if ($tlmin > 1) {
                                $tlwrds .= "s";
                            }
                            if ($tlsec > 0) {
                                $tlwrds .= ", {$tlsec} " . _('second');
                            }
                            if ($tlsec > 1) {
                                $tlwrds .= "s";
                            }
                        } else {
                            if ($line['timelimit'] > 60) {
                                $tlmin = floor($line['timelimit'] / 60);
                                $tlsec = $line['timelimit'] % 60;
                                $tlwrds = "{$tlmin} " . _('minute');
                                if ($tlmin > 1) {
                                    $tlwrds .= "s";
                                }
                                if ($tlsec > 0) {
                                    $tlwrds .= ", {$tlsec} " . _('second');
                                }
                                if ($tlsec > 1) {
                                    $tlwrds .= "s";
                                }
                            } else {
                                $tlwrds = $line['timelimit'] . _(' second(s)');
                            }
                        }
                    } else {
                        $tlwrds = '';
                    }
                    if ($tlwrds != '') {
                        $onclick = 'onclick="return confirm(\'' . sprintf(_('This assessment has a time limit of %s.  Click OK to start or continue working on the assessment.'), $tlwrds) . '\')"';
                    } else {
                        $onclick = 'onclick="recordlasttreeview(\'' . $itemtype . $typeid . '\')"';
                    }
                    $out .= '<a href="' . $imasroot . '/assessment/showtest.php?cid=' . $cid . '&amp;id=' . $typeid . '" ' . $onclick . ' target="readerframe">' . $line['name'] . '</a></li>';
                }
            } else {
                if ($line['itemtype'] == 'LinkedText') {
                    //TODO check availability, etc.
                    $query = "SELECT title,summary,text,startdate,enddate,avail,target FROM imas_linkedtext WHERE id='{$typeid}'";
                    $result = mysql_query($query) or die("Query failed : " . mysql_error());
                    $line = mysql_fetch_array($result, MYSQL_ASSOC);
                    if ($viewall || $line['avail'] == 2 || $line['avail'] == 1 && $line['startdate'] < $now && $line['enddate'] > $now) {
                        if ($openitem == '' && $foundfirstitem == '') {
                            $foundfirstitem = '/course/showlinkedtext.php?cid=' . $cid . '&amp;id=' . $typeid;
                            $isopen = true;
                        }
                        if ($itemtype . $typeid === $openitem) {
                            $foundopenitem = '/course/showlinkedtext.php?cid=' . $cid . '&amp;id=' . $typeid;
                            $isopen = true;
                        }
                        $out .= '<li><img src="' . $imasroot . '/img/html_tiny.png"> <a href="showlinkedtext.php?cid=' . $cid . '&amp;id=' . $typeid . '"  onclick="recordlasttreeview(\'' . $itemtype . $typeid . '\')"  target="readerframe">' . $line['title'] . '</a></li>';
                    }
                } else {
                    if ($line['itemtype'] == 'Wiki') {
                        //TODO check availability, etc.
                        $query = "SELECT id,name,description,startdate,enddate,editbydate,avail,settings,groupsetid FROM imas_wikis WHERE id='{$typeid}'";
                        $result = mysql_query($query) or die("Query failed : " . mysql_error());
                        $line = mysql_fetch_array($result, MYSQL_ASSOC);
                        if ($viewall || $line['avail'] == 2 || $line['avail'] == 1 && $line['startdate'] < $now && $line['enddate'] > $now) {
                            if ($openitem == '' && $foundfirstitem == '') {
                                $foundfirstitem = '/wikis/viewwiki.php?cid=' . $cid . '&amp;id=' . $typeid . '&framed=true';
                                $isopen = true;
                            }
                            if ($itemtype . $typeid === $openitem) {
                                $foundopenitem = '/wikis/viewwiki.php?cid=' . $cid . '&amp;id=' . $typeid . '&framed=true';
                                $isopen = true;
                            }
                            $out .= '<li><img src="' . $imasroot . '/img/wiki_tiny.png"> <a href="' . $imasroot . '/wikis/viewwiki.php?cid=' . $cid . '&amp;id=' . $typeid . '&framed=true"  onclick="recordlasttreeview(\'' . $itemtype . $typeid . '\')" target="readerframe">' . $line['name'] . '</a></li>';
                        }
                    }
                }
            }
        }
    }
    return array($out, $isopen);
}