/// Get all the appropriate data
- if (!$cms = get_coursemodules_in_course('chat', $course->id)) {
+ if (! $chats = get_all_instances_in_course('chat', $course)) {
notice(get_string('thereareno', 'moodle', $strchats), "../../course/view.php?id=$course->id");
die();
}
}
$currentsection = '';
-
- $modinfo = get_fast_modinfo($course);
- foreach ($modinfo->instances['chat'] as $cm) {
- if (!$cm->uservisible) {
- continue;
+ foreach ($chats as $chat) {
+ if (!$chat->visible) {
+ //Show dimmed if the mod is hidden
+ $link = "<a class=\"dimmed\" href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name,true)."</a>";
+ } else {
+ //Show normal if the mod is visible
+ $link = "<a href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name,true)."</a>";
}
-
- $class = $cm->visible ? '' : 'class="dimmed"';
- $link = "<a $class href=\"view.php?id=$cm->id\">".format_string($cm->name)."</a>";
-
$printsection = '';
- if ($cm->sectionnum !== $currentsection) {
- if ($cm->sectionnum) {
- $printsection = $cm->sectionnum;
+ if ($chat->section !== $currentsection) {
+ if ($chat->section) {
+ $printsection = $chat->section;
}
if ($currentsection !== '') {
$table->data[] = 'hr';
}
- $currentsection = $cm->sectionnum;
+ $currentsection = $chat->section;
}
if ($course->format == 'weeks' or $course->format == 'topics') {
$table->data[] = array ($printsection, $link);
print_header_simple("$strchoices", "", $navigation, "", "", true, "", navmenu($course));
- if (!$cms = get_coursemodules_in_course('choice', $course->id)) {
+ if (! $choices = get_all_instances_in_course("choice", $course)) {
notice(get_string('thereareno', 'moodle', $strchoices), "../../course/view.php?id=$course->id");
}
$currentsection = "";
- $modinfo = get_fast_modinfo($course);
- foreach ($modinfo->instances['choice'] as $cm) {
- if (!$cm->uservisible) {
- continue;
+ foreach ($choices as $choice) {
+ if (!empty($answers[$choice->id])) {
+ $answer = $answers[$choice->id];
+ } else {
+ $answer = "";
+ }
+ if (!empty($answer->optionid)) {
+ $aa = format_string(choice_get_option_text($choice, $answer->optionid));
+ } else {
+ $aa = "";
}
-
$printsection = "";
- if ($cm->sectionnum !== $currentsection) {
- if ($cm->sectionnum) {
- $printsection = $cm->sectionnum;
+ if ($choice->section !== $currentsection) {
+ if ($choice->section) {
+ $printsection = $choice->section;
}
if ($currentsection !== "") {
$table->data[] = 'hr';
}
- $currentsection = $cm->sectionnum;
+ $currentsection = $choice->section;
}
-
- $class = $cm->visible ? '' : 'class="dimmed"';
- $tt_href = "<a $class href=\"view.php?id=$cm->id\">".format_string($cm->name)."</a>";
-
- if (!empty($answers[$cm->instance])) {
- $answer = $answers[$cm->instance];
+
+ //Calculate the href
+ if (!$choice->visible) {
+ //Show dimmed if the mod is hidden
+ $tt_href = "<a class=\"dimmed\" href=\"view.php?id=$choice->coursemodule\">".format_string($choice->name,true)."</a>";
} else {
- $answer = "";
+ //Show normal if the mod is visible
+ $tt_href = "<a href=\"view.php?id=$choice->coursemodule\">".format_string($choice->name,true)."</a>";
}
- if (!empty($answer->optionid)) {
- $aa = format_string(choice_get_option_text(null, $answer->optionid));
- } else {
- $aa = "";
- }
-
if ($course->format == "weeks" || $course->format == "topics") {
$table->data[] = array ($printsection, $tt_href, $aa);
} else {
print_header_simple($strdata, '', $navigation, '', '', true, "", navmenu($course));
- if (!$cms = get_coursemodules_in_course('data', $course->id, 'm.intro, m.approval, m.rssarticles')) {
+ if (! $datas = get_all_instances_in_course("data", $course)) {
notice(get_string('thereareno', 'moodle',$strdataplural) , "$CFG->wwwroot/course/view.php?id=$course->id");
}
$currentsection = "";
- $modinfo = get_fast_modinfo($course);
- foreach ($modinfo->instances['data'] as $cm) {
- if (!$cm->uservisible) {
- continue;
- }
-
- $cm->intro = $cms[$cm->id]->intro;
- $cm->approval = $cms[$cm->id]->approval;
- $cm->rssarticles = $cms[$cm->id]->rssarticles;
+ foreach ($datas as $data) {
$printsection = "";
- $class = $cm->visible ? '' : 'class="dimmed"';
- $link = "<a $class href=\"view.php?id=$cm->id\">".format_string($cm->name,true)."</a>";
+ //Calculate the href
+ if (!$data->visible) {
+ //Show dimmed if the mod is hidden
+ $link = "<a class=\"dimmed\" href=\"view.php?id=$data->coursemodule\">".format_string($data->name,true)."</a>";
+ } else {
+ //Show normal if the mod is visible
+ $link = "<a href=\"view.php?id=$data->coursemodule\">".format_string($data->name,true)."</a>";
+ }
// TODO: add group restricted counts here, and limit unapproved to ppl with approve cap only + link to approval page
$numrecords = count_records_sql('SELECT COUNT(r.id) FROM '.$CFG->prefix.
- 'data_records r WHERE r.dataid ='.$cm->instance);
+ 'data_records r WHERE r.dataid ='.$data->id);
- if ($cm->approval == 1) {
+ if ($data->approval == 1) {
$numunapprovedrecords = count_records_sql('SELECT COUNT(r.id) FROM '.$CFG->prefix.
- 'data_records r WHERE r.dataid ='.$cm->instance.
+ 'data_records r WHERE r.dataid ='.$data->id.
' AND r.approved <> 1');
} else {
$numunapprovedrecords = '-';
}
$rsslink = '';
- if ($rss && $cm->rssarticles > 0) {
- $rsslink = rss_get_link($course->id, $USER->id, 'data', $cm->instance, 'RSS');
+ if ($rss && $data->rssarticles > 0) {
+ $rsslink = rss_get_link($course->id, $USER->id, 'data', $data->id, 'RSS');
}
if ($course->format == 'weeks' or $course->format == 'topics') {
- if ($cm->sectionnum !== $currentsection) {
- if ($cm->sectionnum) {
- $printsection = $cm->sectionnum;
+ if ($data->section !== $currentsection) {
+ if ($data->section) {
+ $printsection = $data->section;
}
if ($currentsection !== '') {
$table->data[] = 'hr';
}
- $currentsection = $cm->sectionnum;
+ $currentsection = $data->section;
}
- $row = array ($printsection, $link, $cm->intro, $numrecords, $numunapprovedrecords);
+ $row = array ($printsection, $link, $data->intro, $numrecords, $numunapprovedrecords);
} else {
- $row = array ($link, $cm->intro, $numrecords, $numunapprovedrecords);
+ $row = array ($link, $data->intro, $numrecords, $numunapprovedrecords);
}
if ($rss) {
/// Get all the appropriate data
- if (!$cms = get_coursemodules_in_course('glossary', $course->id, 'm.rsstype, m.rssarticles')) {
+ if (! $glossarys = get_all_instances_in_course("glossary", $course)) {
notice(get_string('thereareno', 'moodle', $strglossarys), "../../course/view.php?id=$course->id");
die;
}
$currentsection = "";
- $modinfo = get_fast_modinfo($course);
- foreach ($modinfo->instances['glossary'] as $cm) {
- if (!$cm->uservisible) {
+ foreach ($glossarys as $glossary) {
+ if (!$glossary->visible && has_capability('moodle/course:viewhiddenactivities', $context)) {
+ // Show dimmed if the mod is hidden.
+ $link = "<a class=\"dimmed\" href=\"view.php?id=$glossary->coursemodule\">".format_string($glossary->name,true)."</a>";
+ } else if ($glossary->visible) {
+ // Show normal if the mod is visible.
+ $link = "<a href=\"view.php?id=$glossary->coursemodule\">".format_string($glossary->name,true)."</a>";
+ } else {
+ // Don't show the glossary.
continue;
}
-
- $cm->rsstype = $cms[$cm->id]->rsstype;
- $cm->rssarticles = $cms[$cm->id]->rssarticles;
-
- $class = $cm->visible ? '' : 'class="dimmed"';
- $link = "<a $class href=\"view.php?id=$cm->id\">".format_string($cm->name)."</a>";
-
$printsection = "";
- if ($cm->sectionnum !== $currentsection) {
- if ($cm->sectionnum) {
- $printsection = $cm->sectionnum;
+ if ($glossary->section !== $currentsection) {
+ if ($glossary->section) {
+ $printsection = $glossary->section;
}
if ($currentsection !== "") {
$table->data[] = 'hr';
}
- $currentsection = $cm->sectionnum;
+ $currentsection = $glossary->section;
}
// TODO: count only approved if not allowed to see them
- $count = count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}glossary_entries where (glossaryid = $cm->instance or sourceglossaryid = $cm->instance)");
+ $count = count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}glossary_entries where (glossaryid = $glossary->id or sourceglossaryid = $glossary->id)");
//If this glossary has RSS activated, calculate it
if ($show_rss) {
$rsslink = '';
- if ($cm->rsstype and $cm->rssarticles) {
+ if ($glossary->rsstype and $glossary->rssarticles) {
//Calculate the tolltip text
- $tooltiptext = get_string("rsssubscriberss","glossary",format_string($cm->name));
+ $tooltiptext = get_string("rsssubscriberss","glossary",format_string($glossary->name));
if (empty($USER->id)) {
$userid = 0;
} else {
$userid = $USER->id;
}
//Get html code for RSS link
- $rsslink = rss_get_link($course->id, $userid, "glossary", $cm->instance, $tooltiptext);
+ $rsslink = rss_get_link($course->id, $userid, "glossary", $glossary->id, $tooltiptext);
}
}
}
foreach ($journals as $journal) {
- $cm = get_coursemodule_from_instance('journal', $journal->id, $course->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
- if (!coursemodule_visible_for_user($cm)) {
- continue;
- }
$journal->timestart = $course->startdate + (($journal->section - 1) * 608400);
if (!empty($journal->daysopen)) {
}
foreach ($lessons as $lesson) {
- $cm = get_coursemodule_from_instance('lesson', $lesson->id, $course->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
- if (!coursemodule_visible_for_user($cm)) {
- continue;
+ if (!$lesson->visible) {
+ //Show dimmed if the mod is hidden
+ $link = "<a class=\"dimmed\" href=\"view.php?id=$lesson->coursemodule\">".format_string($lesson->name,true)."</a>";
+ } else {
+ //Show normal if the mod is visible
+ $link = "<a href=\"view.php?id=$lesson->coursemodule\">".format_string($lesson->name,true)."</a>";
}
-
- $class = $cm->visible ? '' : 'class="dimmed"';
- $link = "<a $class href=\"view.php?id=$lesson->coursemodule\">".format_string($lesson->name)."</a>";
+ $cm = get_coursemodule_from_instance('lesson', $lesson->id);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
if ($lesson->deadline > $timenow) {
$due = userdate($lesson->deadline);
foreach ($quizzes as $quiz) {
$cm = get_coursemodule_from_instance('quiz', $quiz->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
- if (!coursemodule_visible_for_user($cm)) {
- continue;
- }
-
$data = array();
// Section number if necessary.
print_header("$course->shortname: $strresources", $course->fullname, $navigation,
"", "", true, "", navmenu($course));
- if (!$cms = get_coursemodules_in_course('resource', $course->id, 'm.timemodified, m.summary')) {
+ if (! $resources = get_all_instances_in_course("resource", $course)) {
notice(get_string('thereareno', 'moodle', $strresources), "../../course/view.php?id=$course->id");
exit;
}
$currentsection = "";
$options->para = false;
-
- $modinfo = get_fast_modinfo($course);
- foreach ($modinfo->instances['resource'] as $cm) {
- if (!$cm->uservisible) {
- continue;
- }
-
- $cm->summary = $cms[$cm->id]->summary;
- $cm->timemodified = $cms[$cm->id]->timemodified;
-
+ foreach ($resources as $resource) {
if ($course->format == "weeks" or $course->format == "topics") {
$printsection = "";
- if ($cm->sectionnum !== $currentsection) {
- if ($cm->sectionnum) {
- $printsection = $cm->sectionnum;
+ if ($resource->section !== $currentsection) {
+ if ($resource->section) {
+ $printsection = $resource->section;
}
if ($currentsection !== "") {
$table->data[] = 'hr';
}
- $currentsection = $cm->sectionnum;
+ $currentsection = $resource->section;
}
} else {
- $printsection = '<span class="smallinfo">'.userdate($cm->timemodified)."</span>";
+ $printsection = '<span class="smallinfo">'.userdate($resource->timemodified)."</span>";
+ }
+ if (!empty($resource->extra)) {
+ $extra = urldecode($resource->extra);
+ } else {
+ $extra = "";
+ }
+ if (!$resource->visible) { // Show dimmed if the mod is hidden
+ $table->data[] = array ($printsection,
+ "<a class=\"dimmed\" $extra href=\"view.php?id=$resource->coursemodule\">".format_string($resource->name,true)."</a>",
+ format_text($resource->summary, FORMAT_MOODLE, $options) );
+
+ } else { //Show normal if the mod is visible
+ $table->data[] = array ($printsection,
+ "<a $extra href=\"view.php?id=$resource->coursemodule\">".format_string($resource->name,true)."</a>",
+ format_text($resource->summary, FORMAT_MOODLE, $options) );
}
-
- $class = $cm->visible ? '' : 'class="dimmed"';
- $table->data[] = array ($printsection,
- "<a $class href=\"view.php?id=$cm->id\">".format_string($cm->name)."</a>",
- format_text($cm->summary, FORMAT_MOODLE, $options) );
}
echo "<br />";
}
foreach ($scorms as $scorm) {
- $cm = get_coursemodule_from_instance('scorm', $forum->id, $course->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
- if (!coursemodule_visible_for_user($cm)) {
- continue;
- }
+ $context = get_context_instance(CONTEXT_MODULE,$scorm->coursemodule);
$tt = "";
if ($course->format == "weeks" or $course->format == "topics") {
if ($scorm->section) {
$report = scorm_grade_user($scorm, $USER->id);
$reportshow = get_string('score','scorm').": ".$report;
}
-
- $class = $cm->visible ? '' : 'class="dimmed"';
- $table->data[] = array ($tt, "<a $class href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
- format_text($scorm->summary), $reportshow);
+ if (!$scorm->visible) {
+ //Show dimmed if the mod is hidden
+ $table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
+ format_text($scorm->summary), $reportshow);
+ } else {
+ //Show normal if the mod is visible
+ $table->data[] = array ($tt, "<a href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
+ format_text($scorm->summary), $reportshow);
+ }
}
echo "<br />";
print_header_simple("$strsurveys", "", $navigation,
"", "", true, "", navmenu($course));
- if (!$cms = get_coursemodules_in_course('survey', $course->id)) {
+ if (! $surveys = get_all_instances_in_course("survey", $course)) {
notice(get_string('thereareno', 'moodle', $strsurveys), "../../course/view.php?id=$course->id");
}
$currentsection = '';
- $modinfo = get_fast_modinfo($course);
- foreach ($modinfo->instances['survey'] as $cm) {
- if (!$cm->uservisible) {
- continue;
- }
-
- if (!empty($USER->id) and survey_already_done($cm->instance, $USER->id)) {
+ foreach ($surveys as $survey) {
+ if (!empty($USER->id) and survey_already_done($survey->id, $USER->id)) {
$ss = $strdone;
} else {
$ss = $strnotdone;
}
$printsection = "";
- if ($cm->sectionnum !== $currentsection) {
- if ($cm->sectionnum) {
- $printsection = $cm->sectionnum;
+ if ($survey->section !== $currentsection) {
+ if ($survey->section) {
+ $printsection = $survey->section;
}
if ($currentsection !== "") {
$table->data[] = 'hr';
}
- $currentsection = $cm->sectionnum;
+ $currentsection = $survey->section;
}
//Calculate the href
- $class = $cm->visible ? '' : 'class="dimmed"';
- $tt_href = "<a $class href=\"view.php?id=$cm->id\">".format_string($cm->name,true)."</a>";
+ if (!$survey->visible) {
+ //Show dimmed if the mod is hidden
+ $tt_href = "<a class=\"dimmed\" href=\"view.php?id=$survey->coursemodule\">".format_string($survey->name,true)."</a>";
+ } else {
+ //Show normal if the mod is visible
+ $tt_href = "<a href=\"view.php?id=$survey->coursemodule\">".format_string($survey->name,true)."</a>";
+ }
if ($course->format == "weeks" or $course->format == "topics") {
- $table->data[] = array ($printsection, $tt_href, "<a href=\"view.php?id=$cm->id\">$ss</a>");
+ $table->data[] = array ($printsection, $tt_href, "<a href=\"view.php?id=$survey->coursemodule\">$ss</a>");
} else {
- $table->data[] = array ($tt_href, "<a href=\"view.php?id=$cm->id\">$ss</a>");
+ $table->data[] = array ($tt_href, "<a href=\"view.php?id=$survey->coursemodule\">$ss</a>");
}
}
/// Get all the appropriate data
- if (!$cms = get_coursemodules_in_course('wiki', $course->id, 'm.summary, m.wtype, m.timemodified')) {
+ if (! $wikis = get_all_instances_in_course("wiki", $course)) {
notice(get_string('thereareno', 'moodle', $strwikis), "../../course/view.php?id=$course->id");
die;
}
$table->align = array ('LEFT', 'LEFT', 'LEFT', 'LEFT');
}
- $modinfo = get_fast_modinfo($course);
- foreach ($modinfo->instances['wiki'] as $cm) {
- if (!$cm->uservisible) {
- continue;
+ foreach ($wikis as $wiki) {
+ if (!$wiki->visible) {
+ //Show dimmed if the mod is hidden
+ $link = '<a class="dimmed" href="view.php?id='.$wiki->coursemodule.'">'.format_string($wiki->name,true).'</a>';
+ } else {
+ //Show normal if the mod is visible
+ $link = '<a href="view.php?id='.$wiki->coursemodule.'">'.format_string($wiki->name,true).'</a>';
}
- $cm->summary = $cms[$cm->id]->summary;
- $cm->wtype = $cms[$cm->id]->wtype;
- $cm->timemodified = $cms[$cm->id]->timemodified;
-
- $class = $cm->visible ? '' : 'class="dimmed"';
- $link = '<a '.$class.' href="view.php?id='.$cm->id.'">'.format_string($cm->name).'</a>';
-
- $timmod = '<span class="smallinfo">'.userdate($cm->timemodified).'</span>';
- $summary = '<span class="smallinfo">'.format_text($cm->summary).'</span>';
+ $timmod = '<span class="smallinfo">'.userdate($wiki->timemodified).'</span>';
+ $summary = '<span class="smallinfo">'.format_text($wiki->summary).'</span>';
$site = get_site();
- switch ($cm->wtype) {
+ switch ($wiki->wtype) {
case 'teacher':
$wtype = $site->teacher;
$wtype = '<span class="smallinfo">'.$wtype.'</span>';
if ($course->format == "weeks" or $course->format == "topics") {
- $table->data[] = array ($cm->sectionnum, $link, $summary, $wtype, $timmod);
+ $table->data[] = array ($wiki->section, $link, $summary, $wtype, $timmod);
} else {
$table->data[] = array ($link, $summary, $wtype, $timmod);
}
$strinfo = get_string("grade")."/".$strinfo = get_string("phase", "workshop");
$strdeadline = get_string("deadline", "workshop");
$strsubmitted = get_string("submitted", "assignment");
-
+
$navlinks = array();
$navlinks[] = array('name' => $strworkshops, 'link' => '', 'type' => 'activity');
$navigation = build_navigation($navlinks);
-
+
print_header_simple("$strworkshops", "", $navigation, "", "", true, "", navmenu($course));
if (! $workshops = get_all_instances_in_course("workshop", $course)) {
}
foreach ($workshops as $workshop) {
- $cm = get_coursemodule_from_instance('workshop', $workshop->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
- if (!coursemodule_visible_for_user($cm)) {
- continue;
- }
-
if (workshop_is_teacher($workshop, $USER->id)) { // teacher see info (students see grade)
$info = workshop_phase($workshop, 'short');
if (time() > $workshop->submissionstart) {