$text .= '<script type="text/javascript">$(function() {$("#exttoolframe").css("height",$(window).height() - $(".midwrapper").position().top - ($(".midwrapper").height()-500) - ($("body").outerHeight(true) - $("body").innerHeight()));});</script>';
    } else {
        //redirect to post page
        $param .= '&target=new';
        header('Location: ' . $urlmode . $_SERVER['HTTP_HOST'] . $imasroot . '/filter/basiclti/post.php?' . $param);
        exit;
    }
} else {
    if (substr($text, 0, 4) == "http" && strpos(trim($text), " ") === false) {
        //is a web link
        $text = '<p><a href="' . $text . '" target="_blank">' . $title . '</a> (will open in a new tab or window)</p>';
    } else {
        if (substr(strip_tags($text), 0, 5) == "file:") {
            $filename = substr(strip_tags($text), 5);
            require_once "../includes/filehandler.php";
            $alink = getcoursefileurl($filename);
            //$imasroot . "/course/files/".$filename;
            $text = '<p>Download file: <a href="' . $alink . '">' . $title . '</a></p>';
        }
    }
}
$placeinhead = '';
if (isset($studentid)) {
    $rec = "data-base=\"linkedintext-{$_GET['id']}\" ";
    $text = str_replace('<a ', '<a ' . $rec, $text);
    $placeinhead = '<script type="text/javascript">
			function recunload() {
				if (!recordedunload) {
					$.ajax({
						type: "POST",
						url: "' . $imasroot . '/course/rectrack.php?cid=' . $cid . '",
Beispiel #2
0
        function getorg($it, $parent, &$res, $ind)
        {
            global $iteminfo, $newdir, $installname, $urlmode, $linktype, $urlmode, $imasroot, $ccnt, $module_meta, $htmldir, $filedir, $toplevelitems, $inmodule;
            global $usechecked, $checked;
            $out = '';
            foreach ($it as $k => $item) {
                $canvout = '';
                if (is_array($item)) {
                    if (!$usechecked || array_search($parent . '-' . ($k + 1), $checked) !== FALSE) {
                        if (strlen($ind) > 2) {
                            $canvout .= '<item identifier="BLOCK' . $item['id'] . '">' . "\n";
                            $canvout .= '<content_type>ContextModuleSubHeader</content_type>';
                            $canvout .= '<title>' . htmlentities($item['name'], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                            $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>";
                            $ccnt++;
                            $module_meta .= $canvout;
                        } else {
                            if ($inmodule) {
                                $module_meta .= '</items></module>';
                            }
                            $inmodule = true;
                            $module_meta .= '<module identifier="BLOCK' . $item['id'] . '">
							<title>' . htmlentities($item['name'], ENT_XML1, 'UTF-8', false) . '</title>
							<items>';
                        }
                        $out .= $ind . '<item identifier="BLOCK' . $item['id'] . '">' . "\n";
                        $out .= $ind . '  <title>' . htmlentities($item['name'], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                        $out .= $ind . getorg($item['items'], $parent . '-' . ($k + 1), $res, $ind . '  ');
                        $out .= $ind . '</item>' . "\n";
                    } else {
                        $out .= $ind . getorg($item['items'], $parent . '-' . ($k + 1), $res, $ind . '  ');
                    }
                } else {
                    if ($usechecked && array_search($item, $checked) === FALSE) {
                        continue;
                    }
                    if ($iteminfo[$item][0] == 'InlineText') {
                        $query = "SELECT title,text,fileorder FROM imas_inlinetext WHERE id='{$iteminfo[$item][1]}'";
                        $r = mysql_query($query) or die("Query failed : " . mysql_error());
                        $row = mysql_fetch_row($r);
                        if ($row[2] != '') {
                            $files = explode(',', $row[2]);
                            $query = "SELECT id,description,filename FROM imas_instr_files WHERE itemid='{$iteminfo[$item][1]}'";
                            $result = mysql_query($query) or die("Query failed : " . mysql_error());
                            $filesout = array();
                            while ($r = mysql_fetch_row($result)) {
                                //if s3 filehandler, do files as weblinks rather than including the file itself
                                if ($GLOBALS['filehandertypecfiles'] == 's3') {
                                    $r[2] = getcoursefileurl($r[2]);
                                } else {
                                    //copy("../course/files/{$r[2]}",$newdir.'/'.$r[2]);
                                    copycoursefile($r[2], $newdir . '/' . $filedir . basename($r[2]));
                                    $resitem = '<resource href="' . $filedir . basename($r[2]) . '" identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . 'file' . $r[0] . '" type="webcontent">' . "\n";
                                    $resitem .= '  <file href="' . $filedir . basename($r[2]) . '" />' . "\n";
                                    $resitem .= '</resource>';
                                    $res[] = $resitem;
                                }
                                $filesout[$r[0]] = array($r[1], $r[2]);
                            }
                        }
                        $out .= $ind . '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n";
                        $out .= $ind . '  <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                        $out .= $ind . '</item>' . "\n";
                        $canvout .= '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n";
                        $canvout .= '<content_type>WikiPage</content_type>';
                        $canvout .= '<identifierref>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</identifierref>';
                        $canvout .= '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                        $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>";
                        $ccnt++;
                        $fp = fopen($newdir . '/' . $htmldir . 'inlinetext' . $iteminfo[$item][1] . '.html', 'w');
                        fwrite($fp, '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">');
                        fwrite($fp, '<title>' . htmlentities($row[0]) . '</title>');
                        fwrite($fp, '<meta name="identifier" content="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '"/>');
                        if ($linktype == "canvas") {
                            fwrite($fp, '<meta name="editing_roles" content="teachers"/>');
                        }
                        fwrite($fp, "</head><body>");
                        fwrite($fp, filtercapture($row[1], $res));
                        if ($row[2] != '') {
                            fwrite($fp, '<ul>');
                            foreach ($files as $f) {
                                if ($GLOBALS['filehandertypecfiles'] == 's3') {
                                    fwrite($fp, '<li><a href="' . $filesout[$f][1] . '">' . htmlentities($filesout[$f][0]) . '</a></li>');
                                } else {
                                    fwrite($fp, '<li><a href="' . $filedir . basename($filesout[$f][1]) . '">' . htmlentities($filesout[$f][0]) . '</a></li>');
                                }
                            }
                            fwrite($fp, '</ul>');
                        }
                        fwrite($fp, '</body></html>');
                        fclose($fp);
                        $resitem = '<resource href="' . $htmldir . 'inlinetext' . $iteminfo[$item][1] . '.html" identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="webcontent">' . "\n";
                        $resitem .= '  <file href="' . $htmldir . 'inlinetext' . $iteminfo[$item][1] . '.html" />' . "\n";
                        $resitem .= '</resource>';
                        $res[] = $resitem;
                    } else {
                        if ($iteminfo[$item][0] == 'LinkedText') {
                            $query = "SELECT title,text,summary FROM imas_linkedtext WHERE id='{$iteminfo[$item][1]}'";
                            $r = mysql_query($query) or die("Query failed : " . mysql_error());
                            $row = mysql_fetch_row($r);
                            //if s3 filehandler, do files as weblinks rather than including the file itself
                            if ($GLOBALS['filehandertypecfiles'] == 's3' && substr(strip_tags($row[1]), 0, 5) == "file:") {
                                $row[1] = getcoursefileurl(trim(substr(strip_tags($row[1]), 5)));
                            }
                            if (substr($row[1], 0, 4) == "http" && strpos(trim($row[1]), " ") === false) {
                                //is a web link
                                $alink = trim($row[1]);
                                $fp = fopen($newdir . '/weblink' . $iteminfo[$item][1] . '.xml', 'w');
                                fwrite($fp, '<webLink xmlns="http://www.imsglobal.org/xsd/imsccv1p1/imswl_v1p1">');
                                fwrite($fp, ' <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>');
                                fwrite($fp, ' <url href="' . htmlentities($alink, ENT_XML1, 'UTF-8', false) . '" target="_blank"/>');
                                fwrite($fp, '</webLink>');
                                fclose($fp);
                                $out .= $ind . '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n";
                                $out .= $ind . '  <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                                $out .= $ind . '</item>' . "\n";
                                $canvout .= '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n";
                                $canvout .= '<content_type>ExternalUrl</content_type>';
                                $canvout .= '<identifierref>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</identifierref>';
                                $canvout .= '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                                $canvout .= '<url>' . htmlentities($alink, ENT_XML1, 'UTF-8', false) . '</url>';
                                $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>";
                                $ccnt++;
                                $resitem = '<resource identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="imswl_xmlv1p1">' . "\n";
                                $resitem .= '  <file href="weblink' . $iteminfo[$item][1] . '.xml" />' . "\n";
                                $resitem .= '</resource>';
                                $res[] = $resitem;
                            } else {
                                if (substr(strip_tags($row[1]), 0, 5) == "file:") {
                                    //is a file
                                    $filename = trim(substr(strip_tags($row[1]), 5));
                                    //copy("../course/files/$filename",$newdir.'/'.$filedir.$filename);
                                    copycoursefile($filename, $newdir . '/' . $filedir . basename($filename));
                                    $out .= $ind . '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n";
                                    $out .= $ind . '  <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                                    $out .= $ind . '</item>' . "\n";
                                    $canvout .= '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n";
                                    $canvout .= '<content_type>Attachment</content_type>';
                                    $canvout .= '<identifierref>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</identifierref>';
                                    $canvout .= '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                                    $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>";
                                    $ccnt++;
                                    $resitem = '<resource href="' . $filedir . basename($filename) . '" identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="webcontent">' . "\n";
                                    $resitem .= '  <file href="' . $filedir . basename($filename) . '" />' . "\n";
                                    $resitem .= '</resource>';
                                    $res[] = $resitem;
                                } else {
                                    //is text
                                    $out .= $ind . '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n";
                                    $out .= $ind . '  <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                                    $out .= $ind . '</item>' . "\n";
                                    $canvout .= '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n";
                                    $canvout .= '<content_type>WikiPage</content_type>';
                                    $canvout .= '<identifierref>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</identifierref>';
                                    $canvout .= '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                                    $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>";
                                    $ccnt++;
                                    $fp = fopen($newdir . '/' . $htmldir . 'linkedtext' . $iteminfo[$item][1] . '.html', 'w');
                                    fwrite($fp, '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">');
                                    fwrite($fp, '<title>' . htmlentities($row[0]) . '</title>');
                                    fwrite($fp, '<meta name="identifier" content="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '"/>');
                                    if ($linktype == "canvas") {
                                        fwrite($fp, '<meta name="editing_roles" content="teachers"/>');
                                    }
                                    fwrite($fp, "</head><body>");
                                    fwrite($fp, filtercapture($row[1], $res));
                                    fwrite($fp, '</body></html>');
                                    fclose($fp);
                                    $resitem = '<resource href="' . $htmldir . 'linkedtext' . $iteminfo[$item][1] . '.html" identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="webcontent">' . "\n";
                                    $resitem .= '  <file href="' . $htmldir . 'linkedtext' . $iteminfo[$item][1] . '.html" />' . "\n";
                                    $resitem .= '</resource>';
                                    $res[] = $resitem;
                                }
                            }
                        } else {
                            if ($iteminfo[$item][0] == 'Forum') {
                                $query = "SELECT name,description FROM imas_forums WHERE id='{$iteminfo[$item][1]}'";
                                $r = mysql_query($query) or die("Query failed : " . mysql_error());
                                $row = mysql_fetch_row($r);
                                $out .= $ind . '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n";
                                $out .= $ind . '  <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                                $out .= $ind . '</item>' . "\n";
                                $canvout .= '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n";
                                $canvout .= '<content_type>DiscussionTopic</content_type>';
                                $canvout .= '<identifierref>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</identifierref>';
                                $canvout .= '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                                $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>";
                                $ccnt++;
                                $fp = fopen($newdir . '/forum' . $iteminfo[$item][1] . '.xml', 'w');
                                fwrite($fp, '<topic xmlns="http://www.imsglobal.org/xsd/imsccv1p1/imsdt_v1p1">');
                                fwrite($fp, ' <title >' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>');
                                fwrite($fp, ' <text texttype="text/html">' . htmlentities(filtercapture($row[1], $res)) . '</text>');
                                fwrite($fp, '</topic>');
                                fclose($fp);
                                if ($linktype == 'canvas') {
                                    $fp = fopen($newdir . '/RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . 'meta.xml', 'w');
                                    fwrite($fp, '<?xml version="1.0" encoding="UTF-8"?>
							<topicMeta xsi:schemaLocation="http://canvas.instructure.com/xsd/cccv1p0 http://canvas.instructure.com/xsd/cccv1p0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . 'meta" xmlns="http://canvas.instructure.com/xsd/cccv1p0">
							  <topic_id>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</topic_id>
							  <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>
							  <type>topic</type>
							</topicMeta>');
                                    fclose($fp);
                                    $resitem = '<resource identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . 'meta" type="associatedcontent/imscc_xmlv1p1/learning-application-resource" href="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . 'meta.xml">' . "\n";
                                    $resitem .= '  <file href="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . 'meta.xml" />' . "\n";
                                    $resitem .= '</resource>';
                                    $res[] = $resitem;
                                    $resitem = '<resource identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="imsdt_xmlv1p1">' . "\n";
                                    $resitem .= '  <file href="forum' . $iteminfo[$item][1] . '.xml" />' . "\n";
                                    $resitem .= '  <dependency identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . 'meta"/>';
                                    $resitem .= '</resource>';
                                } else {
                                    $resitem = '<resource identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="imsdt_xmlv1p1">' . "\n";
                                    $resitem .= '  <file href="forum' . $iteminfo[$item][1] . '.xml" />' . "\n";
                                    $resitem .= '</resource>';
                                }
                                $res[] = $resitem;
                            } else {
                                if ($iteminfo[$item][0] == 'Assessment') {
                                    $query = "SELECT name,summary,defpoints,itemorder FROM imas_assessments WHERE id='{$iteminfo[$item][1]}'";
                                    $r = mysql_query($query) or die("Query failed : " . mysql_error());
                                    $row = mysql_fetch_row($r);
                                    //echo "encoding {$row[0]} as ".htmlentities($row[0],ENT_XML1,'UTF-8',false).'<br/>';
                                    $out .= $ind . '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n";
                                    $out .= $ind . '  <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                                    $out .= $ind . '</item>' . "\n";
                                    if ($linktype == 'canvas') {
                                        $canvout .= '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n";
                                        $canvout .= '<content_type>Assignment</content_type>';
                                        $canvout .= '<identifierref>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</identifierref>';
                                        $canvout .= '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                                        $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>";
                                        $ccnt++;
                                        $aitems = explode(',', $row[3]);
                                        foreach ($aitems as $k => $v) {
                                            if (strpos($v, '~') !== FALSE) {
                                                $sub = explode('~', $v);
                                                if (strpos($sub[0], '|') === false) {
                                                    //backwards compat
                                                    $aitems[$k] = $sub[0];
                                                    $aitemcnt[$k] = 1;
                                                } else {
                                                    $grpparts = explode('|', $sub[0]);
                                                    $aitems[$k] = $sub[1];
                                                    $aitemcnt[$k] = $grpparts[0];
                                                }
                                            } else {
                                                $aitemcnt[$k] = 1;
                                            }
                                        }
                                        $query = "SELECT points,id FROM imas_questions WHERE assessmentid='{$iteminfo[$item][1]}'";
                                        $result2 = mysql_query($query) or die("Query failed : {$query}: " . mysql_error());
                                        $totalpossible = 0;
                                        while ($r = mysql_fetch_row($result2)) {
                                            if (($k = array_search($r[1], $aitems)) !== false) {
                                                //only use first item from grouped questions for total pts
                                                if ($r[0] == 9999) {
                                                    $totalpossible += $aitemcnt[$k] * $row[2];
                                                    //use defpoints
                                                } else {
                                                    $totalpossible += $aitemcnt[$k] * $r[0];
                                                    //use points from question
                                                }
                                            }
                                        }
                                        mkdir($newdir . '/assn' . $iteminfo[$item][1]);
                                        $fp = fopen($newdir . '/assn' . $iteminfo[$item][1] . '/assignment_settings.xml', 'w');
                                        fwrite($fp, '<assignment xmlns="http://canvas.instructure.com/xsd/cccv1p0" identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://canvas.instructure.com/xsd/cccv1p0 http://canvas.instructure.com/xsd/cccv1p0.xsd">');
                                        fwrite($fp, '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>');
                                        fwrite($fp, '<points_possible>' . $totalpossible . '</points_possible>');
                                        fwrite($fp, '<grading_type>points</grading_type>');
                                        fwrite($fp, '<assignment_group_identifierref>assngroup</assignment_group_identifierref>');
                                        fwrite($fp, '<submission_types>external_tool</submission_types>');
                                        fwrite($fp, '<external_tool_url>' . $urlmode . $_SERVER['HTTP_HOST'] . $imasroot . '/bltilaunch.php?custom_place_aid=' . $iteminfo[$item][1] . '</external_tool_url>');
                                        fwrite($fp, '</assignment>');
                                        fclose($fp);
                                        $fp = fopen($newdir . '/assn' . $iteminfo[$item][1] . '/assignmenthtml' . $iteminfo[$item][1] . '.html', 'w');
                                        fwrite($fp, '<html><body> </body></html>');
                                        fclose($fp);
                                        $resitem = '<resource identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="associatedcontent/imscc_xmlv1p1/learning-application-resource" href="assn' . $iteminfo[$item][1] . '/assignmenthtml' . $iteminfo[$item][1] . '.html">' . "\n";
                                        $resitem .= '  <file href="assn' . $iteminfo[$item][1] . '/assignmenthtml' . $iteminfo[$item][1] . '.html" />' . "\n";
                                        $resitem .= '  <file href="assn' . $iteminfo[$item][1] . '/assignment_settings.xml" />' . "\n";
                                        $resitem .= '</resource>';
                                        $res[] = $resitem;
                                    } else {
                                        $fp = fopen($newdir . '/blti' . $iteminfo[$item][1] . '.xml', 'w');
                                        fwrite($fp, '<cartridge_basiclti_link xmlns="http://www.imsglobal.org/xsd/imslticc_v1p0" xmlns:blti="http://www.imsglobal.org/xsd/imsbasiclti_v1p0" xmlns:lticm ="http://www.imsglobal.org/xsd/imslticm_v1p0" xmlns:lticp ="http://www.imsglobal.org/xsd/imslticp_v1p0">');
                                        fwrite($fp, '<blti:title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</blti:title>');
                                        fwrite($fp, '<blti:description>' . htmlentities(html_entity_decode($row[1]), ENT_XML1, 'UTF-8', false) . '</blti:description>');
                                        if ($linktype == 'url') {
                                            $urladd = '?custom_place_aid=' . $iteminfo[$item][1];
                                        } else {
                                            fwrite($fp, '<blti:custom><lticm:property name="place_aid">' . $iteminfo[$item][1] . '</lticm:property></blti:custom>');
                                            $urladd = '';
                                        }
                                        fwrite($fp, '<blti:launch_url>http://' . $_SERVER['HTTP_HOST'] . $imasroot . '/bltilaunch.php' . $urladd . '</blti:launch_url>');
                                        if ($urlmode == 'https://') {
                                            fwrite($fp, '<blti:secure_launch_url>https://' . $_SERVER['HTTP_HOST'] . $imasroot . '/bltilaunch.php' . $urladd . '</blti:secure_launch_url>');
                                        }
                                        fwrite($fp, '<blti:vendor><lticp:code>IMathAS</lticp:code><lticp:name>' . $installname . '</lticp:name></blti:vendor>');
                                        fwrite($fp, '</cartridge_basiclti_link>');
                                        fclose($fp);
                                        $resitem = '<resource identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="imsbasiclti_xmlv1p0">' . "\n";
                                        $resitem .= '  <file href="blti' . $iteminfo[$item][1] . '.xml" />' . "\n";
                                        $resitem .= '</resource>';
                                        $res[] = $resitem;
                                    }
                                } else {
                                    if ($iteminfo[$item][0] == 'Wiki') {
                                        $query = "SELECT name FROM imas_wikis WHERE id='{$iteminfo[$item][1]}'";
                                        $r = mysql_query($query) or die("Query failed : " . mysql_error());
                                        $row = mysql_fetch_row($r);
                                        $out .= $ind . '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" identifierref="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n";
                                        $out .= $ind . '  <title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                                        $out .= $ind . '</item>' . "\n";
                                        $canvout .= '<item identifier="' . $iteminfo[$item][0] . $iteminfo[$item][1] . '">' . "\n";
                                        $canvout .= '<content_type>WikiPage</content_type>';
                                        $canvout .= '<identifierref>RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '</identifierref>';
                                        $canvout .= '<title>' . htmlentities($row[0], ENT_XML1, 'UTF-8', false) . '</title>' . "\n";
                                        $canvout .= "<position>{$ccnt}</position> <indent>" . max(strlen($ind) / 2 - 2, 0) . "</indent> </item>";
                                        $ccnt++;
                                        $fp = fopen($newdir . '/' . $htmldir . 'wikitext' . $iteminfo[$item][1] . '.html', 'w');
                                        fwrite($fp, '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">');
                                        fwrite($fp, '<title>' . htmlentities($row[0]) . '</title>');
                                        fwrite($fp, '<meta name="identifier" content="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '"/>');
                                        if ($linktype == "canvas") {
                                            fwrite($fp, '<meta name="editing_roles" content="teachers"/>');
                                        }
                                        fwrite($fp, "</head><body>");
                                        $query = "SELECT revision FROM imas_wiki_revisions WHERE wikiid='{$iteminfo[$item][1]}' AND stugroupid=0 ORDER BY id DESC LIMIT 1";
                                        $r = mysql_query($query) or die("Query failed : " . mysql_error());
                                        if (mysql_num_rows($r) > 0) {
                                            $row = mysql_fetch_row($r);
                                            $text = $row[0];
                                            if (strlen($text) > 6 && substr($text, 0, 6) == '**wver') {
                                                $wikiver = substr($text, 6, strpos($text, '**', 6) - 6);
                                                $text = substr($text, strpos($text, '**', 6) + 2);
                                            }
                                            fwrite($fp, filtercapture($text, $res));
                                        }
                                        fwrite($fp, '</body></html>');
                                        fclose($fp);
                                        $resitem = '<resource href="' . $htmldir . 'wikitext' . $iteminfo[$item][1] . '.html" identifier="RES' . $iteminfo[$item][0] . $iteminfo[$item][1] . '" type="webcontent">' . "\n";
                                        $resitem .= '  <file href="' . $htmldir . 'wikitext' . $iteminfo[$item][1] . '.html" />' . "\n";
                                        $resitem .= '</resource>';
                                        $res[] = $resitem;
                                    }
                                }
                            }
                        }
                    }
                    if (strlen($ind) > 2) {
                        $module_meta .= $canvout;
                    } else {
                        $toplevelitems .= $canvout;
                    }
                }
            }
            return $out;
        }
Beispiel #3
0
function showcalendar($refpage)
{
    global $imasroot, $cid, $userid, $teacherid, $previewshift, $latepasses, $urlmode, $latepasshrs, $myrights, $tzoffset, $tzname, $havecalcedviewedassess, $viewedassess;
    $now = time();
    if ($previewshift != -1) {
        $now = $now + $previewshift;
    }
    if (!isset($_COOKIE['calstart' . $cid]) || $_COOKIE['calstart' . $cid] == 0) {
        $today = $now;
    } else {
        $today = $_COOKIE['calstart' . $cid];
    }
    if (isset($_GET['calpageshift'])) {
        $pageshift = $_GET['calpageshift'];
    } else {
        $pageshift = 0;
    }
    if (!isset($_COOKIE['callength' . $cid])) {
        $callength = 4;
    } else {
        $callength = $_COOKIE['callength' . $cid];
    }
    $today = $today + $pageshift * 7 * $callength * 24 * 60 * 60;
    $dayofweek = tzdate('w', $today);
    $curmonum = tzdate('n', $today);
    $dayofmo = tzdate('j', $today);
    $curyr = tzdate('Y', $today);
    if ($tzname == '') {
        $serveroffset = date('Z') + $tzoffset * 60;
    } else {
        $serveroffset = 0;
        //don't need this if user's timezone has been set
    }
    $midtoday = mktime(12, 0, 0, $curmonum, $dayofmo, $curyr) + $serveroffset;
    $hdrs = array();
    $ids = array();
    $lastmo = '';
    for ($i = 0; $i < 7 * $callength; $i++) {
        $row = floor($i / 7);
        $col = $i % 7;
        list($thismo, $thisday, $thismonum, $datestr) = explode('|', tzdate('M|j|n|l F j, Y', $midtoday - ($dayofweek - $i) * 24 * 60 * 60));
        if ($thismo == $lastmo) {
            $hdrs[$row][$col] = $thisday;
        } else {
            $hdrs[$row][$col] = "{$thismo} {$thisday}";
            $lastmo = $thismo;
        }
        $ids[$row][$col] = "{$thismonum}-{$thisday}";
        $dates[$ids[$row][$col]] = $datestr;
    }
    ?>


<?php 
    //echo '<div class="floatleft">Jump to <a href="'.$refpage.'.php?calpageshift=0&cid='.$cid.'">Now</a></div>';
    $address = $urlmode . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/{$refpage}.php?cid={$cid}";
    echo '<script type="text/javascript">var calcallback = "' . $address . '";</script>';
    echo '<div class="floatright">Show <select id="callength" onchange="changecallength(this)">';
    for ($i = 2; $i < 26; $i++) {
        echo '<option value="' . $i . '" ';
        if ($i == $callength) {
            echo 'selected="selected"';
        }
        echo '>' . $i . '</option>';
    }
    echo '</select> weeks </div>';
    echo '<div class=center><a href="' . $refpage . '.php?calpageshift=' . ($pageshift - 1) . '&cid=' . $cid . '">&lt; &lt;</a> ';
    //echo $longcurmo.' ';
    if ($pageshift == 0 && (!isset($_COOKIE['calstart' . $cid]) || $_COOKIE['calstart' . $cid] == 0)) {
        echo "Now ";
    } else {
        echo '<a href="' . $refpage . '.php?calpageshift=0&calstart=0&cid=' . $cid . '">Now</a> ';
    }
    echo '<a href="' . $refpage . '.php?calpageshift=' . ($pageshift + 1) . '&cid=' . $cid . '">&gt; &gt;</a> ';
    echo '</div> ';
    echo "<table class=\"cal\" >";
    //onmouseout=\"makenorm()\"
    $exlowertime = mktime(0, 0, 0, $curmonum, $dayofmo - $dayofweek, $curyr) + $serveroffset;
    $lowertime = max($now, $exlowertime);
    $uppertime = mktime(0, 0, 0, $curmonum, $dayofmo - $dayofweek + 7 * $callength, $curyr) + $serveroffset;
    $exceptions = array();
    if (!isset($teacherid)) {
        $query = "SELECT assessmentid,startdate,enddate,islatepass,waivereqscore FROM imas_exceptions WHERE userid='{$userid}'";
        $result = mysql_query($query) or die("Query failed : {$query}" . mysql_error());
        while ($row = mysql_fetch_row($result)) {
            $exceptions[$row[0]] = array($row[1], $row[2], $row[3], $row[4]);
        }
    }
    $byid = array();
    $k = 0;
    $query = "SELECT id,name,startdate,enddate,reviewdate,gbcategory,reqscore,reqscoreaid,timelimit,allowlate,caltag,calrtag FROM imas_assessments WHERE avail=1 AND courseid='{$cid}' AND enddate<2000000000 ORDER BY name";
    $result = mysql_query($query) or die("Query failed : {$query}" . mysql_error());
    while ($row = mysql_fetch_row($result)) {
        $canundolatepass = false;
        $latepasscnt = 0;
        if (isset($exceptions[$row[0]])) {
            if ($exceptions[$row[0]][2] > 0 && ($now < $row[3] || $exceptions[$row[0]][1] > $now + $latepasshrs * 60 * 60)) {
                $canundolatepass = true;
            }
            $latepasscnt = round(($exceptions[$row[0]][1] - $row[3]) / ($latepasshrs * 3600));
            $row[2] = $exceptions[$row[0]][0];
            $row[3] = $exceptions[$row[0]][1];
        }
        //2: start, 3: end, 4: review
        //if enddate past end of calendar
        if ($row[3] > $uppertime && ($row[4] == 0 || $row[4] > $uppertime || $row[4] < $row[3])) {
            continue;
        }
        //if enddate is past, and reviewdate is past end of calendar
        if ($row[3] < $now && $row[4] > $uppertime) {
            //continue;
        }
        //echo "{$row[1]}, {$row[3]}, $uppertime, {$row[4]}<br/>";
        //if startdate is past now
        if ($row[2] > $now && !isset($teacherid)) {
            continue;
        }
        //if past reviewdate
        if ($row[4] > 0 && $now > $row[4] && !isset($teacherid)) {
            //if has reviewdate and we're past it   //|| ($now>$row[3] && $row[4]==0)
            //continue;
        }
        if (!isset($teacherid) && $row[6] > 0 && $row[7] > 0 && (!isset($exceptions[$row[0]]) || $exceptions[$row[0]][3] == 0)) {
            $query = "SELECT bestscores FROM imas_assessment_sessions WHERE assessmentid='{$row[7]}' AND userid='{$userid}'";
            $r2 = mysql_query($query) or die("Query failed : " . mysql_error());
            if (mysql_num_rows($r2) == 0) {
                continue;
            } else {
                $scores = explode(';', mysql_result($r2, 0, 0));
                if (getpts($scores[0]) < $row[6]) {
                    continue;
                }
            }
        }
        if ($row[4] < $uppertime && $row[4] > 0 && $now > $row[3]) {
            //has review, and we're past enddate
            list($moday, $time) = explode('~', tzdate('n-j~g:i a', $row[4]));
            $row[1] = htmlentities($row[1], ENT_COMPAT | ENT_HTML401, "UTF-8", false);
            $tag = htmlentities($row[11], ENT_COMPAT | ENT_HTML401, "UTF-8", false);
            if ($now < $row[4]) {
                $colors = '#99f';
            } else {
                $colors = '#ccc';
            }
            $json = "{type:\"AR\", time:\"{$time}\", tag:\"{$tag}\", ";
            if ($now < $row[4] || isset($teacherid)) {
                $json .= "id:\"{$row['0']}\",";
            }
            $json .= "color:\"" . $colors . "\",name:\"{$row['1']}\"" . (isset($teacherid) ? ", editlink:true" : "") . "}";
            if ($row[3] < $uppertime && $row[3] > $exlowertime) {
                //if going to do a second tag, need to increment.
                $byid['AR' . $row[0]] = array($moday, $tag, $colors, $json);
            }
        }
        if ($row[3] < $uppertime && $row[3] > $exlowertime) {
            // taking out "hide if past due" && ($now<$row[3] || isset($teacherid))) {
            /*if (isset($gbcats[$row[5]])) {
            			$tag = $gbcats[$row[5]];
            		} else {
            			$tag = '?';
            		}*/
            $tag = htmlentities($row[10], ENT_COMPAT | ENT_HTML401, "UTF-8", false);
            if (!$havecalcedviewedassess && $now > $row[3] && $row[9] > 10) {
                $havecalcedviewedassess = true;
                $viewedassess = array();
                $query = "SELECT typeid FROM imas_content_track WHERE courseid='{$cid}' AND userid='{$userid}' AND type='gbviewasid'";
                $r2 = mysql_query($query) or die("Query failed : " . mysql_error());
                while ($r = mysql_fetch_row($r2)) {
                    $viewedassess[] = $r[0];
                }
            }
            if (($row[9] % 10 == 1 || $row[9] % 10 - 1 > $latepasscnt) && $latepasses > 0 && ($now < $row[3] || $row[9] > 10 && $now - $row[3] < $latepasshrs * 3600 && !in_array($row[0], $viewedassess))) {
                $lp = 1;
            } else {
                $lp = 0;
            }
            if ($canundolatepass) {
                $ulp = 1;
            } else {
                $ulp = 0;
            }
            list($moday, $time) = explode('~', tzdate('n-j~g:i a', $row[3]));
            $row[1] = htmlentities($row[1], ENT_COMPAT | ENT_HTML401, "UTF-8", false);
            $colors = makecolor2($row[2], $row[3], $now);
            $json = "{type:\"A\", time:\"{$time}\", ";
            if ($now < $row[3] || $row[4] > $now || isset($teacherid) || $lp == 1) {
                $json .= "id:\"{$row['0']}\",";
            }
            if ($now > $row[3] && $now > $row[4] && !isset($teacherid)) {
                $json .= 'inactive:true,';
            }
            $json .= "name:\"{$row['1']}\", color:\"" . $colors . "\", allowlate:\"{$lp}\", undolate:\"{$ulp}\", tag:\"{$tag}\"" . ($row[8] != 0 ? ", timelimit:true" : "") . (isset($teacherid) ? ", editlink:true" : "") . "}";
            //"<span class=icon style=\"background-color:#f66\">?</span> <a href=\"../assessment/showtest.php?id={$row[0]}&cid=$cid\">{$row[1]}</a> Due $time<br/>";
            $byid['A' . $row[0]] = array($moday, $tag, $colors, $json);
        }
    }
    // 4/4/2011, changing tthis to code block below.  Not sure why change on 10/23 was made :/
    //if (isset($teacherid)) {
    //$query = "SELECT id,title,enddate,text,startdate,oncal,caltag,avail FROM imas_inlinetext WHERE ((oncal=2 AND enddate>$exlowertime AND enddate<$uppertime) OR (oncal=1 AND startdate<$uppertime AND startdate>$exlowertime)) AND (avail=1 OR (avail=2 AND startdate>0)) AND courseid='$cid'";
    //} else {
    //	$query = "SELECT id,title,enddate,text,startdate,oncal,caltag FROM imas_inlinetext WHERE ((oncal=2 AND enddate>$lowertime AND enddate<$uppertime AND startdate<$now) OR (oncal=1 AND startdate<$now AND startdate>$exlowertime)) AND avail=1 AND courseid='$cid'";  //chg 10/23/09: replace $now with $uppertime
    //}
    if (isset($teacherid)) {
        $query = "SELECT id,title,enddate,text,startdate,oncal,caltag,avail FROM imas_inlinetext WHERE ((oncal=2 AND enddate>{$exlowertime} AND enddate<{$uppertime}) OR (oncal=1 AND startdate<{$uppertime} AND startdate>{$exlowertime})) AND (avail=1 OR (avail=2 AND startdate>0)) AND courseid='{$cid}'";
    } else {
        $query = "SELECT id,title,enddate,text,startdate,oncal,caltag,avail FROM imas_inlinetext WHERE ";
        $query .= "((avail=1 AND ((oncal=2 AND enddate>{$exlowertime} AND enddate<{$uppertime} AND startdate<{$now}) OR (oncal=1 AND startdate<{$now} AND startdate>{$exlowertime}))) OR ";
        $query .= "(avail=2 AND oncal=1 AND startdate<{$uppertime} AND startdate>{$exlowertime})) AND courseid='{$cid}'";
    }
    $result = mysql_query($query) or die("Query failed : {$query}" . mysql_error());
    while ($row = mysql_fetch_row($result)) {
        if ($row[1] == '##hidden##') {
            $row[1] = strip_tags($row[3]);
        }
        if ($row[5] == 1) {
            list($moday, $time) = explode('~', tzdate('n-j~g:i a', $row[4]));
        } else {
            list($moday, $time) = explode('~', tzdate('n-j~g:i a', $row[2]));
        }
        $row[1] = htmlentities($row[1], ENT_COMPAT | ENT_HTML401, "UTF-8", false);
        $colors = makecolor2($row[4], $row[2], $now);
        if ($row[7] == 2) {
            $colors = "#0f0";
        }
        $tag = htmlentities($row[6], ENT_COMPAT | ENT_HTML401, "UTF-8", false);
        $json = "{type:\"I\", folder:\"@@@\", time:\"{$time}\", id:\"{$row['0']}\", name:\"{$row['1']}\", color:\"" . $colors . "\", tag:\"{$tag}\"" . (isset($teacherid) ? ", editlink:true" : "") . "}";
        //"<span class=icon style=\"background-color:#f66\">?</span> <a href=\"../assessment/showtest.php?id={$row[0]}&cid=$cid\">{$row[1]}</a> Due $time<br/>";
        $byid['I' . $row[0]] = array($moday, $tag, $colors, $json);
    }
    //$query = "SELECT id,title,enddate,text,startdate,oncal,caltag FROM imas_linkedtext WHERE ((oncal=2 AND enddate>$lowertime AND enddate<$uppertime AND startdate<$now) OR (oncal=1 AND startdate<$now AND startdate>$exlowertime)) AND avail=1 AND courseid='$cid'";
    if (isset($teacherid)) {
        $query = "SELECT id,title,enddate,text,startdate,oncal,caltag,avail FROM imas_linkedtext WHERE ((oncal=2 AND enddate>{$exlowertime} AND enddate<{$uppertime}) OR (oncal=1 AND startdate<{$uppertime} AND startdate>{$exlowertime})) AND (avail=1 OR (avail=2 AND startdate>0)) AND courseid='{$cid}' ORDER BY title";
    } else {
        $query = "SELECT id,title,enddate,text,startdate,oncal,caltag,avail FROM imas_linkedtext WHERE ";
        $query .= "((avail=1 AND ((oncal=2 AND enddate>{$exlowertime} AND enddate<{$uppertime} AND startdate<{$now}) OR (oncal=1 AND startdate<{$now} AND startdate>{$exlowertime}))) OR ";
        $query .= "(avail=2 AND oncal=1 AND startdate<{$uppertime} AND startdate>{$exlowertime})) AND courseid='{$cid}' ORDER BY title";
    }
    $result = mysql_query($query) or die("Query failed : {$query}" . mysql_error());
    while ($row = mysql_fetch_row($result)) {
        if ($row[5] == 1) {
            list($moday, $time) = explode('~', tzdate('n-j~g:i a', $row[4]));
        } else {
            list($moday, $time) = explode('~', tzdate('n-j~g:i a', $row[2]));
        }
        $row[1] = htmlentities($row[1], ENT_COMPAT | ENT_HTML401, "UTF-8", false);
        if (substr($row[3], 0, 4) == "http" && strpos($row[3], " ") === false) {
            //is a web link
            $alink = trim($row[3]);
        } else {
            if (substr($row[3], 0, 5) == "file:") {
                $filename = substr(strip_tags($row[3]), 5);
                $alink = getcoursefileurl($filename);
                //$alink = $imasroot . "/course/files/".$filename;
            } else {
                $alink = '';
            }
        }
        $colors = makecolor2($row[4], $row[2], $now);
        if ($row[7] == 2) {
            $colors = "#0f0";
        }
        $json = "{type:\"L\", time:\"{$time}\", ";
        if (isset($teacherid) || $now < $row[2] && $now > $row[4] || $row[7] == 2) {
            $json .= "id:\"{$row['0']}\", ";
        }
        $tag = htmlentities($row[6], ENT_COMPAT | ENT_HTML401, "UTF-8", false);
        $alink = htmlentities($alink, ENT_COMPAT | ENT_HTML401, "UTF-8", false);
        $json .= "name:\"{$row['1']}\", link:\"{$alink}\", color:\"" . $colors . "\", tag:\"{$tag}\"" . (isset($teacherid) ? ", editlink:true" : "") . "}";
        //"<span class=icon style=\"background-color:#f66\">?</span> <a href=\"../assessment/showtest.php?id={$row[0]}&cid=$cid\">{$row[1]}</a> Due $time<br/>";
        $byid['L' . $row[0]] = array($moday, $tag, $colors, $json);
    }
    $query = "SELECT id,name,postby,replyby,startdate,caltag FROM imas_forums WHERE enddate>{$exlowertime} AND ((postby>{$exlowertime} AND postby<{$uppertime}) OR (replyby>{$exlowertime} AND replyby<{$uppertime})) AND avail>0 AND courseid='{$cid}' ORDER BY name";
    $result = mysql_query($query) or die("Query failed : {$query}" . mysql_error());
    while ($row = mysql_fetch_row($result)) {
        if ($row[4] > $now && !isset($teacherid)) {
            continue;
        }
        list($posttag, $replytag) = explode('--', $row[5]);
        $posttag = htmlentities($posttag, ENT_COMPAT | ENT_HTML401, "UTF-8", false);
        $replytag = htmlentities($replytag, ENT_COMPAT | ENT_HTML401, "UTF-8", false);
        if ($row[2] != 2000000000) {
            //($row[2]>$now || isset($teacherid))
            list($moday, $time) = explode('~', tzdate('n-j~g:i a', $row[2]));
            $row[1] = htmlentities($row[1], ENT_COMPAT | ENT_HTML401, "UTF-8", false);
            $colors = makecolor2($row[4], $row[2], $now);
            $json = "{type:\"FP\", time:\"{$time}\", ";
            if ($row[2] > $now || isset($teacherid)) {
                $json .= "id:\"{$row['0']}\",";
            }
            $json .= "name:\"{$row['1']}\", color:\"" . $colors . "\", tag:\"{$posttag}\"" . (isset($teacherid) ? ", editlink:true" : "") . "}";
            $byid['FP' . $row[0]] = array($moday, $posttag, $colors, $json);
        }
        if ($row[3] != 2000000000) {
            //($row[3]>$now || isset($teacherid))
            list($moday, $time) = explode('~', tzdate('n-j~g:i a', $row[3]));
            $colors = makecolor2($row[4], $row[3], $now);
            $json = "{type:\"FR\", time:\"{$time}\",";
            if ($row[3] > $now || isset($teacherid)) {
                $json .= "id:\"{$row['0']}\",";
            }
            $json .= "name:\"{$row['1']}\", color:\"" . $colors . "\", tag:\"{$replytag}\"" . (isset($teacherid) ? ", editlink:true" : "") . "}";
            $byid['FR' . $row[0]] = array($moday, $replytag, $colors, $json);
        }
    }
    $query = "SELECT itemorder FROM imas_courses WHERE id='{$cid}'";
    $result = mysql_query($query) or die("Query failed : {$query}" . mysql_error());
    $itemorder = unserialize(mysql_result($result, 0, 0));
    $itemsimporder = array();
    $itemfolder = array();
    flattenitems($itemorder, $itemsimporder, $itemfolder, '0');
    $itemsassoc = array();
    $query = "SELECT id,itemtype,typeid FROM imas_items WHERE courseid='{$cid}'";
    $result = mysql_query($query) or die("Query failed : {$query}" . mysql_error());
    while ($row = mysql_fetch_row($result)) {
        $itemsassoc[$row[0]] = array($row[1], $row[2]);
    }
    $assess = array();
    $colors = array();
    $tags = array();
    $k = 0;
    foreach ($itemsimporder as $item) {
        if ($itemsassoc[$item][0] == 'Assessment') {
            if (isset($byid['A' . $itemsassoc[$item][1]])) {
                $moday = $byid['A' . $itemsassoc[$item][1]][0];
                $tags[$k] = $byid['A' . $itemsassoc[$item][1]][1];
                $colors[$k] = $byid['A' . $itemsassoc[$item][1]][2];
                $assess[$moday][$k] = $byid['A' . $itemsassoc[$item][1]][3];
                $k++;
            }
            if (isset($byid['AR' . $itemsassoc[$item][1]])) {
                $moday = $byid['AR' . $itemsassoc[$item][1]][0];
                $tags[$k] = $byid['AR' . $itemsassoc[$item][1]][1];
                $colors[$k] = $byid['AR' . $itemsassoc[$item][1]][2];
                $assess[$moday][$k] = $byid['AR' . $itemsassoc[$item][1]][3];
                $k++;
            }
        } else {
            if ($itemsassoc[$item][0] == 'Forum') {
                if (isset($byid['FP' . $itemsassoc[$item][1]])) {
                    $moday = $byid['FP' . $itemsassoc[$item][1]][0];
                    $tags[$k] = $byid['FP' . $itemsassoc[$item][1]][1];
                    $colors[$k] = $byid['FP' . $itemsassoc[$item][1]][2];
                    $assess[$moday][$k] = $byid['FP' . $itemsassoc[$item][1]][3];
                    $k++;
                }
                if (isset($byid['FR' . $itemsassoc[$item][1]])) {
                    $moday = $byid['FR' . $itemsassoc[$item][1]][0];
                    $tags[$k] = $byid['FR' . $itemsassoc[$item][1]][1];
                    $colors[$k] = $byid['FR' . $itemsassoc[$item][1]][2];
                    $assess[$moday][$k] = $byid['FR' . $itemsassoc[$item][1]][3];
                    $k++;
                }
            } else {
                if ($itemsassoc[$item][0] == 'InlineText') {
                    if (isset($byid['I' . $itemsassoc[$item][1]])) {
                        $moday = $byid['I' . $itemsassoc[$item][1]][0];
                        $tags[$k] = $byid['I' . $itemsassoc[$item][1]][1];
                        $colors[$k] = $byid['I' . $itemsassoc[$item][1]][2];
                        if (isset($itemfolder[$item])) {
                            $assess[$moday][$k] = str_replace('@@@', $itemfolder[$item], $byid['I' . $itemsassoc[$item][1]][3]);
                        } else {
                            $assess[$moday][$k] = str_replace('"@@@"', 'null', $byid['I' . $itemsassoc[$item][1]][3]);
                        }
                        $k++;
                    }
                } else {
                    if ($itemsassoc[$item][0] == 'LinkedText') {
                        if (isset($byid['L' . $itemsassoc[$item][1]])) {
                            $moday = $byid['L' . $itemsassoc[$item][1]][0];
                            $tags[$k] = $byid['L' . $itemsassoc[$item][1]][1];
                            $colors[$k] = $byid['L' . $itemsassoc[$item][1]][2];
                            $assess[$moday][$k] = $byid['L' . $itemsassoc[$item][1]][3];
                            $k++;
                        }
                    }
                }
            }
        }
    }
    $query = "SELECT title,tag,date FROM imas_calitems WHERE date>{$exlowertime} AND date<{$uppertime} and courseid='{$cid}' ORDER BY title";
    $result = mysql_query($query) or die("Query failed : {$query}" . mysql_error());
    while ($row = mysql_fetch_row($result)) {
        list($moday, $time) = explode('~', tzdate('n-j~g:i a', $row[2]));
        $row[0] = htmlentities($row[0], ENT_COMPAT | ENT_HTML401, "UTF-8", false);
        $row[1] = htmlentities($row[1], ENT_COMPAT | ENT_HTML401, "UTF-8", false);
        $assess[$moday][$k] = "{type:\"C\", time:\"{$time}\", tag:\"{$row['1']}\", name:\"{$row['0']}\"}";
        $tags[$k] = $row[1];
        $k++;
    }
    $jsarr = '{';
    foreach ($dates as $moday => $val) {
        if ($jsarr != '{') {
            $jsarr .= ',';
        }
        if (isset($assess[$moday])) {
            $jsarr .= '"' . $moday . '":{date:"' . $dates[$moday] . '",data:[' . implode(',', $assess[$moday]) . ']}';
        } else {
            $jsarr .= '"' . $moday . '":{date:"' . $dates[$moday] . '"}';
        }
    }
    $jsarr .= '}';
    echo '<script type="text/javascript">';
    echo "cid = {$cid};";
    echo "caleventsarr = {$jsarr};";
    echo '</script>';
    echo "<thead><tr><th>Sunday</th> <th>Monday</th> <th>Tuesday</th> <th>Wednesday</th> <th>Thursday</th> <th>Friday</th> <th>Saturday</th></tr></thead>";
    echo "<tbody>";
    for ($i = 0; $i < count($hdrs); $i++) {
        echo "<tr>";
        for ($j = 0; $j < count($hdrs[$i]); $j++) {
            if ($i == 0 && $j == $dayofweek && $pageshift == 0) {
                //onmouseover="makebig(this)"
                echo '<td id="' . $ids[$i][$j] . '" onclick="showcalcontents(this)" class="today"><div class="td"><span class=day>' . $hdrs[$i][$j] . "</span><div class=center>";
            } else {
                $addr = $refpage . ".php?cid={$cid}&calstart=" . ($midtoday + $i * 7 * 24 * 60 * 60 + ($j - $dayofweek) * 24 * 60 * 60);
                echo '<td id="' . $ids[$i][$j] . '" onclick="showcalcontents(this)" ><div class="td"><span class=day><a href="' . $addr . '" class="caldl">' . $hdrs[$i][$j] . "</a></span><div class=center>";
            }
            if (isset($assess[$ids[$i][$j]])) {
                foreach ($assess[$ids[$i][$j]] as $k => $info) {
                    //echo $assess[$ids[$i][$j]][$k];
                    if (strpos($info, 'type:"AR"') !== false) {
                        echo "<span class=\"calitem\" style=\"background-color:" . $colors[$k] . ";\">{$tags[$k]}</span> ";
                    } else {
                        if (strpos($info, 'type:"A"') !== false) {
                            echo "<span class=\"calitem\" style=\"background-color:" . $colors[$k] . ";\">{$tags[$k]}</span> ";
                        } else {
                            if (strpos($info, 'type:"F') !== false) {
                                echo "<span class=\"calitem\" style=\"background-color:" . $colors[$k] . ";\">{$tags[$k]}</span> ";
                            } else {
                                if (strpos($info, 'type:"C') !== false) {
                                    echo "<span class=\"calitem\" style=\"background-color: #0ff;\">{$tags[$k]}</span> ";
                                } else {
                                    //textitems
                                    if (isset($tags[$k])) {
                                        echo "<span class=\"calitem\" style=\"background-color:" . $colors[$k] . ";\">{$tags[$k]}</span> ";
                                    } else {
                                        echo "<span class=\"calitem\" style=\"background-color:" . $colors[$k] . ";\">!</span> ";
                                    }
                                }
                            }
                        }
                    }
                }
            }
            echo "</div></div></td>";
        }
        echo "</tr>";
    }
    echo "</tbody></table>";
    echo "<div style=\"margin-top: 10px; padding:10px; border:1px solid #000;\">";
    echo '<span class=right><a href="#" onclick="showcalcontents(' . 1000 * ($midtoday - $dayofweek * 24 * 60 * 60) . '); return false;"/>Show all</a></span>';
    echo "<div id=\"caleventslist\"></div><div class=\"clear\"></div></div>";
    if ($pageshift == 0) {
        echo "<script>showcalcontents(document.getElementById('{$ids[0][$dayofweek]}'));</script>";
    }
}
Beispiel #4
0
    ?>
</textarea>
	</div>
	
	<span class=form>
	Attached Files:</span>
	<span class=wideformright>

<?php 
    if (isset($_GET['id'])) {
        foreach ($page_FileLinks as $k => $arr) {
            echo generatemoveselect($page_fileorderCount, $k);
            ?>
			
		<a href="<?php 
            echo getcoursefileurl($arr['link']);
            ?>
" target="_blank">
		View</a>
		<input type="text" name="filedescr-<?php 
            echo $arr['fid'];
            ?>
" value="<?php 
            echo $arr['desc'];
            ?>
"/>
		Delete? <input type=checkbox name="delfile-<?php 
            echo $arr['fid'];
            ?>
"/><br/>	
<?php