Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit e4c9d38
Author: drlippman <drlippman@yahoo.com>
Date:   Mon Apr 3 17:47:56 2017 -0700

    Bug fix variables not declared global

commit 77ce44a
Author: drlippman <drlippman@yahoo.com>
Date:   Mon Apr 3 08:04:31 2017 -0700

    Add coursemap to the left nav

commit a4c3c46
Author: drlippman <drlippman@yahoo.com>
Date:   Sun Apr 2 18:08:38 2017 -0700

    Add coursemap
    Add exception loading to loaditemshowdata

commit 0a32409
Author: drlippman <drlippman@yahoo.com>
Date:   Thu Mar 23 16:44:13 2017 -0700

    Move exception load to loaditemshowdata
Add course map tool

commit b150f00
Author: drlippman <drlippman@yahoo.com>
Date:   Tue Mar 21 22:56:24 2017 -0700

    Move loadItemShowData to an include file for future reuse
  • Loading branch information
drlippman committed Apr 11, 2017
1 parent b2682a5 commit 48872c8
Show file tree
Hide file tree
Showing 8 changed files with 426 additions and 213 deletions.
54 changes: 18 additions & 36 deletions course/course.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,27 +168,7 @@
$now = time();
$exceptions = array();
if (!isset($teacherid) && !isset($tutorid)) {
//DB $query = "SELECT items.id,ex.startdate,ex.enddate,ex.islatepass,ex.waivereqscore,ex.itemtype FROM ";
//DB $query .= "imas_exceptions AS ex,imas_items as items,imas_assessments as i_a WHERE ex.userid='$userid' AND ";
//DB $query .= "ex.assessmentid=i_a.id AND (items.typeid=i_a.id AND items.itemtype='Assessment' AND items.courseid='$cid') ";
//DB $query .= "UNION SELECT items.id,ex.startdate,ex.enddate,ex.islatepass,ex.waivereqscore,ex.itemtype FROM ";
//DB $query .= "imas_exceptions AS ex,imas_items as items,imas_forums as i_f WHERE ex.userid='$userid' AND ";
//DB $query .= "ex.assessmentid=i_f.id AND (items.typeid=i_f.id AND items.itemtype='Forum' AND items.courseid='$cid') ";
$query = "SELECT items.id,ex.startdate,ex.enddate,ex.islatepass,ex.waivereqscore,ex.itemtype FROM ";
$query .= "imas_exceptions AS ex,imas_items as items,imas_assessments as i_a WHERE ex.userid=:userid AND ";
$query .= "ex.assessmentid=i_a.id AND (items.typeid=i_a.id AND items.itemtype='Assessment' AND items.courseid=:courseid) ";
$query .= "UNION SELECT items.id,ex.startdate,ex.enddate,ex.islatepass,ex.waivereqscore,ex.itemtype FROM ";
$query .= "imas_exceptions AS ex,imas_items as items,imas_forums as i_f WHERE ex.userid=:userid2 AND ";
$query .= "ex.assessmentid=i_f.id AND (items.typeid=i_f.id AND items.itemtype='Forum' AND items.courseid=:courseid2) ";
$stm = $DBH->prepare($query);
$stm->execute(array(':userid'=>$userid, ':courseid'=>$cid, ':userid2'=>$userid, ':courseid2'=>$cid));
// $query .= "AND (($now<i_a.startdate AND ex.startdate<$now) OR ($now>i_a.enddate AND $now<ex.enddate))";
//$query .= "AND (ex.startdate<$now AND $now<ex.enddate)";
//DB $result = mysql_query($query) or die("Query failed : $query " . mysql_error());
//DB while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
while ($line = $stm->fetch(PDO::FETCH_ASSOC)) {
$exceptions[$line['id']] = array($line['startdate'],$line['enddate'],$line['islatepass'],$line['waivereqscore'],$line['itemtype']);
}
$exceptions = loadExceptions($cid, $userid);
}
//update block start/end dates to show blocks containing items with exceptions
if (count($exceptions)>0) {
Expand Down Expand Up @@ -524,7 +504,8 @@ function additem(blk,tb) {
<a href="coursereports.php?cid=<?php echo $cid ?>">Reports</a><br/>
<a href="managestugrps.php?cid=<?php echo $cid ?>"><?php echo _('Groups'); ?></a><br/>
<a href="addoutcomes.php?cid=<?php echo $cid ?>"><?php echo _('Outcomes'); ?></a><br/>
<a href="showcalendar.php?cid=<?php echo $cid ?>"><?php echo _('Calendar'); ?></a>
<a href="showcalendar.php?cid=<?php echo $cid ?>"><?php echo _('Calendar'); ?></a><br/>
<a href="coursemap.php?cid=<?php echo $cid ?>"><?php echo _('Course Map'); ?></a>
</p>
<?php
}
Expand Down Expand Up @@ -582,21 +563,22 @@ function additem(blk,tb) {
</p>
<?php
}
if ($msgset<4 || ($toolset&2)==0 || ($toolset&1)==0) {
echo '<p>';
if ($msgset<4) {
echo '<a href="'.$imasroot.'/msgs/msglist.php?cid='.$cid.'&amp;folder='.$_GET['folder'].'" class="essen"> ';
echo _('Messages').'</a> '.$newmsgs .' <br/>';
}
if (($toolset&2)==0) {
echo '<a href="'.$imasroot.'/forums/forums.php?cid='.$cid.'&amp;folder='.$_GET['folder'].'" class="essen">';
echo _('Forums').'</a> '.$newpostscnt.'<br/>';
}
if (($toolset&1)==0) {
echo '<a href="showcalendar.php?cid='.$cid.'" class="essen">'._('Calendar').'</a>';
}
echo '</p>';

echo '<p>';
if ($msgset<4) {
echo '<a href="'.$imasroot.'/msgs/msglist.php?cid='.$cid.'&amp;folder='.$_GET['folder'].'" class="essen"> ';
echo _('Messages').'</a> '.$newmsgs .' <br/>';
}
if (($toolset&2)==0) {
echo '<a href="'.$imasroot.'/forums/forums.php?cid='.$cid.'&amp;folder='.$_GET['folder'].'" class="essen">';
echo _('Forums').'</a> '.$newpostscnt.'<br/>';
}
if (($toolset&1)==0) {
echo '<a href="showcalendar.php?cid='.$cid.'" class="essen">'._('Calendar').'</a><br/>';
}
echo '<a href="coursemap.php?cid='.$cid.'">'._('Course Map').'</a>';
echo '</p>';

?>

<p>
Expand Down
183 changes: 183 additions & 0 deletions course/coursemap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
<?php
//IMathAS: Course Map view
//(c) 2017 David Lippman

require("../validate.php");
require('../includes/loaditemshowdata.php');

$placeinhead = '<style type="text/css">
ul.qview ul { border-left: 1px dashed #ccc; padding-left: 10px;}
</style>';

require("../header.php");

if (!isset($teacherid) && !isset($tutorid) && !isset($studentid) && !isset($instrPreviewId)) { // loaded by an unauthorized person
echo _("You are not enrolled in this course. Please return to the <a href=\"../index.php\">Home Page</a> and enroll\n");
require("../footer.php");
exit;
}

$viewall = (isset($teacherid) || isset($tutorid));

$stm = $DBH->prepare("SELECT itemorder FROM imas_courses WHERE id=:id");
$stm->execute(array(':id'=>$cid));
$items = unserialize($stm->fetchColumn(0));

if (!$viewall) {
$exceptions = loadExceptions($cid, $userid);
}
//update block start/end dates to show blocks containing items with exceptions
if (count($exceptions)>0) {
upsendexceptions($items);
}

$itemshowdata = loadItemShowData($items, false, $viewall, false, false);

//echo '<pre>';
//print_r($itemshowdata[1215702]);
//echo '</pre>';

$havecalcedviewedassess = false;
$now = time();

function showicon($type,$alt='') {
global $CFG,$imasroot;
if ($alt=='') {$alt = $type;}
if (isset($CFG['CPS']['miniicons'][$type])) {
echo '<img alt="'.$alt.'" src="'.$imasroot.'/img/'.$CFG['CPS']['miniicons'][$type].'" class="mida icon" /> ';
}
}

function showitemtree($items,$parent) {
global $DBH, $CFG, $itemshowdata, $typelookups, $imasroot, $cid, $userid, $exceptions, $viewedassess, $havecalcedviewedassess, $now, $viewall, $studentinfo;

foreach ($items as $k=>$item) {
if (is_array($item)) {
if (isset($item['grouplimit']) && count($item['grouplimit'])>0 && !$viewall) {
if (!in_array('s-'.$studentinfo['section'],$item['grouplimit'])) {
continue;
}
}
if (($item['avail']==2 || ($item['avail']==1 && $item['startdate']<$now && $item['enddate']>$now)) ||
($viewall || ($item['SH'][0]=='S' && $item['avail']>0))) {
if ($item['SH'][1]=='T') { //just link to treereader item
echo '<li><a href="course.php?cid='.$cid.'&folder='.$parent.'#B'.$item['id'].'">';
showicon('tree', 'treereader');
echo $item['name'];
echo '</a></li>';
} else { //show block contents
echo '<li><a href="course.php?cid='.$cid.'&folder='.$parent.'-'.($k+1).'">';
showicon('folder');
echo $item['name'];
echo '</a><ul class="qview">';
showitemtree($item['items'], $parent .'-'.($k+1));
echo '</ul></li>';
}
}
} else {
if ($itemshowdata[$item]['itemtype']=='Calendar') {
continue; //no need to show calendars in map
}
echo '<li>';;
$line = $itemshowdata[$item];
if ($line['itemtype']=='Assessment') {
if (!$viewall && isset($exceptions[$item])) {
require_once("../includes/exceptionfuncs.php");
$useexception = getCanUseAssessException($exceptions[$item], $line, true);
if ($useexception) {
$line['startdate'] = $exceptions[$item][0];
$line['enddate'] = $exceptions[$item][1];
}
}
$nothidden = true; $showgreyedout = false;
if (abs($line['reqscore'])>0 && $line['reqscoreaid']>0 && !$viewall && $line['enddate']>$now
&& (!isset($exceptions[$item]) || $exceptions[$item][3]==0)) {
if ($line['reqscore']<0) {
$showgreyedout = true;
}
$stm = $DBH->prepare("SELECT bestscores FROM imas_assessment_sessions WHERE assessmentid=:assessmentid AND userid=:userid");
$stm->execute(array(':assessmentid'=>$line['reqscoreaid'], ':userid'=>$userid));
if ($stm->rowCount()==0) {
$nothidden = false;
} else {
//DB $scores = explode(';',mysql_result($result,0,0));
$scores = explode(';',$stm->fetchColumn(0));
if (round(getpts($scores[0]),1)+.02<abs($line['reqscore'])) {
$nothidden = false;
}
}
}
if (($line['avail']==1 && $line['startdate']<$now && $line['enddate']>$now && ($nothidden || $showgreyedout)) ||
($line['avail']==1 && $line['enddate']<$now && $line['reviewdate']>$now) || $viewall) {

echo '<li><a href="course.php?cid='.$cid.'&folder='.$parent.'#'.$item.'">';
showicon('assess', 'Assessment');
echo $line['name'];
echo '</a></li>';
}

} else if ($line['itemtype']=='InlineText') {
if ($viewall || $line['avail']==2 || ($line['avail']==1 && $line['startdate']<$now && $line['enddate']>$now)) {
echo '<li><a href="course.php?cid='.$cid.'&folder='.$parent.'#inline'.$line['id'].'">';
showicon('inline', 'Inline Text');
if ($line['title']!='##hidden##') {
echo $line['title'];
} else {
echo _('Inline text item');
}
echo '</a></li>';
}
} else if ($line['itemtype']=='LinkedText') {
if ($viewall || $line['avail']==2 || ($line['avail']==1 && $line['startdate']<$now && $line['enddate']>$now)) {
echo '<li><a href="course.php?cid='.$cid.'&folder='.$parent.'#'.$item.'">';
showicon('linked', 'Link');
echo $line['title'];
echo '</a></li>';
}
} else if ($line['itemtype']=='Drill') {
if ($viewall || $line['avail']==2 || ($line['avail']==1 && $line['startdate']<$now && $line['enddate']>$now)) {
echo '<li><a href="course.php?cid='.$cid.'&folder='.$parent.'#'.$item.'">';
showicon('drill', 'Drill');
echo $line['name'];
echo '</a></li>';
}
} else if ($line['itemtype']=='Forum') {
if (!$viewall && isset($exceptions[$item])) {
require_once("../includes/exceptionfuncs.php");
list($canundolatepassP, $canundolatepassR, $canundolatepass, $canuselatepassP, $canuselatepassR, $line['postby'], $line['replyby'], $line['enddate']) = getCanUseLatePassForums($exceptions[$item], $line);
}

if ($viewall || $line['avail']==2 || ($line['avail']==1 && $line['startdate']<$now && $line['enddate']>$now)) {
echo '<li><a href="course.php?cid='.$cid.'&folder='.$parent.'#'.$item.'">';
showicon('forum', 'Forum');
echo $line['name'];
echo '</a></li>';
}
} else if ($line['itemtype']=='Wiki') {
if ($viewall || $line['avail']==2 || ($line['avail']==1 && $line['startdate']<$now && $line['enddate']>$now)) {
echo '<li><a href="course.php?cid='.$cid.'&folder='.$parent.'#'.$item.'">';
showicon('wiki', 'Wiki');
echo $line['name'];
echo '</a></li>';
}
}
echo '</li>';
}
}
}

echo '<div class="breadcrumb">';
echo $breadcrumbbase;
echo "<a href=\"course.php?cid=$cid&folder=0\">$coursename</a> &gt; ";
echo _('Course Map');
echo '</div>';

echo '<div id="headercoursemap" class="pagetitle"><h2>'._('Course Map').'</h2></div>';
echo '<p>'._('Select an item to jump to its location in the course, or a folder to view the contents').'</p>';
echo '<ul class="qview coursemap">';
showitemtree($items,'0');
echo '</ul>';

require("../footer.php");

?>
Loading

0 comments on commit 48872c8

Please sign in to comment.