2 // In fact, this is very similar to the "topics" format.
3 // The main difference is that news forum is replaced by LAMS learner
6 require_once($CFG->dirroot
.'/mod/lams/constants.php');
7 require_once($CFG->dirroot
.'/lib/weblib.php');
9 $topic = optional_param('topic', -1, PARAM_INT
);
10 // Bounds for block widths
11 // more flexible for theme designers taken from theme config.php
12 $lmin = (empty($THEME->block_l_min_width
)) ?
100 : $THEME->block_l_min_width
;
13 $lmax = (empty($THEME->block_l_max_width
)) ?
210 : $THEME->block_l_max_width
;
14 $rmin = (empty($THEME->block_r_min_width
)) ?
100 : $THEME->block_r_min_width
;
15 $rmax = (empty($THEME->block_r_max_width
)) ?
210 : $THEME->block_r_max_width
;
17 define('BLOCK_L_MIN_WIDTH', $lmin);
18 define('BLOCK_L_MAX_WIDTH', $lmax);
19 define('BLOCK_R_MIN_WIDTH', $rmin);
20 define('BLOCK_R_MAX_WIDTH', $rmax);
22 $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT
]),
24 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT
]),
28 $displaysection = course_set_display($course->id
, $topic);
30 if (isset($USER->display
[$course->id
])) { // for admins, mostly
31 $displaysection = $USER->display
[$course->id
];
33 $displaysection = course_set_display($course->id
, 0);
37 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
39 if (($marker >=0) and has_capability('moodle/course:setcurrentsection', $context) and confirm_sesskey()) {
40 $course->marker
= $marker;
41 if (! set_field("course", "marker", $marker, "id", $course->id
)) {
42 error("Could not mark that topic for this course");
46 $streditsummary = get_string('editsummary');
47 $stradd = get_string('add');
48 $stractivities = get_string('activities');
49 $strshowalltopics = get_string('showalltopics');
50 $strtopic = get_string('topic');
51 $strgroups = get_string('groups');
52 $strgroupmy = get_string('groupmy');
53 $editing = $PAGE->user_is_editing();
56 $strstudents = moodle_strtolower($course->students
);
57 $strtopichide = get_string('topichide', '', $strstudents);
58 $strtopicshow = get_string('topicshow', '', $strstudents);
59 $strmarkthistopic = get_string('markthistopic');
60 $strmarkedthistopic = get_string('markedthistopic');
61 $strmoveup = get_string('moveup');
62 $strmovedown = get_string('movedown');
66 /// Layout the whole page as three big columns.
67 echo '<table id="layout-table" cellspacing="0" summary="'.get_string('layouttable').'"><tr>';
69 /// The left column ...
71 if (blocks_have_content($pageblocks, BLOCK_POS_LEFT
) ||
$editing) {
72 echo '<td style="width:'.$preferred_width_left.'px" id="left-column">';
73 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT
);
78 echo '<td id="middle-column"><a name="startofcontent"></a>';
80 print_heading_block(get_string('lamsoutline','lams'), 'outline');
82 echo '<table class="topics" width="100%" height="100%" summary="'.get_string('layouttable').'">';
84 /// If currently moving a file then show the current clipboard
85 if (ismoving($course->id
)) {
86 $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname
)));
87 $strcancel= get_string('cancel');
88 echo '<tr class="clipboard">';
89 echo '<td colspan="3">';
90 echo $stractivityclipboard.' (<a href="mod.php?cancelcopy=true&sesskey='.$USER->sesskey
.'">'.$strcancel.'</a>)';
98 $thissection = $sections[$section];
100 if ($thissection->summary
or $thissection->sequence
or isediting($course->id
)) {
102 echo '<tr id="section-0" class="section main">';
103 echo '<td class="left side"> </td>';
104 echo '<td class="content">';
106 echo '<div class="summary">';
107 $summaryformatoptions->noclean
= true;
108 echo format_text($thissection->summary
, FORMAT_HTML
, $summaryformatoptions);
110 if (isediting($course->id
) && has_capability('moodle/course:update', $course->id
)) {
111 echo '<a title="'.$streditsummary.'" '.
112 ' href="editsection.php?id='.$thissection->id
.'"><img src="'.$CFG->pixpath
.'/t/edit.gif" '.
113 ' class="iconsmall" alt="'.$streditsummary.'" /></a><br /><br />';
116 if(!isset($CFG->lams_serverurl
)||
!isset($CFG->lams_serverid
)||
!isset($CFG->lams_serverkey
)){
117 echo '<table width="100%" class="section">'.
119 '<td class="activity forum">'.
120 '<table align="center" width="100%" class="noticebox" border="0" cellpadding="15" cellspacing="0">'.
121 '<tr><td bgcolor="#FFAAAA" class="noticeboxcontent">'.
122 '<h3 class="main">All the LAMS module settings have not been set up!<br/> Please contact your administrator.</h3>'.
123 '</td></tr></table>'.
128 if(isediting($course->id
)){//editing turned on. In this case
129 echo '<table width="100%" class="section"><tr>';
130 echo '<td align="left"><img src="../mod/lams/icon.gif" class="iconsmall" boarder="1" alt="LAMS"/> LAMS course</td>';
132 $datetime = date("F d,Y g:i a");
133 $plaintext = trim($datetime).trim($USER->username
).trim($LAMSCONSTANTS->author_method
).trim($CFG->lams_serverid
).trim($CFG->lams_serverkey
);
134 $hash = sha1(strtolower($plaintext));
135 $author_url = $CFG->lams_serverurl
.$LAMSCONSTANTS->login_request
.
136 '?'.$LAMSCONSTANTS->param_uid
.'='.$USER->username
.
137 '&'.$LAMSCONSTANTS->param_method
.'='.$LAMSCONSTANTS->author_method
.
138 '&'.$LAMSCONSTANTS->param_timestamp
.'='.urlencode($datetime).
139 '&'.$LAMSCONSTANTS->param_serverid
.'='.$CFG->lams_serverid
.
140 '&'.$LAMSCONSTANTS->param_hash
.'='.$hash.
141 '&'.$LAMSCONSTANTS->param_courseid
.'='.$course->id
;
142 echo '<div style="text-align: right"><td align="right">';
143 //echo '<a target="popup" title="Open Author" href="../help.php?module=moodle&file=resource/types.html"><span class="helplink"><img class="iconhelp" alt="Open Author" src="../pix/help.gif" /></span></a>';
144 print_simple_box_start('right');
145 echo '<a target="LAMS Author" title="LAMS Author" href="'.$author_url.'">'.get_string("openauthor", "lams").'</a>';
146 print_simple_box_end();
148 $datetime = date("F d,Y g:i a");
149 $plaintext = trim($datetime).trim($USER->username
).trim($LAMSCONSTANTS->monitor_method
).trim($CFG->lams_serverid
).trim($CFG->lams_serverkey
);
150 $hash = sha1(strtolower($plaintext));
151 $monitor_url = $CFG->lams_serverurl
.$LAMSCONSTANTS->login_request
.
152 '?'.$LAMSCONSTANTS->param_uid
.'='.$USER->username
.
153 '&'.$LAMSCONSTANTS->param_method
.'='.$LAMSCONSTANTS->monitor_method
.
154 '&'.$LAMSCONSTANTS->param_timestamp
.'='.urlencode($datetime).
155 '&'.$LAMSCONSTANTS->param_serverid
.'='.$CFG->lams_serverid
.
156 '&'.$LAMSCONSTANTS->param_hash
.'='.$hash.
157 '&'.$LAMSCONSTANTS->param_courseid
.'='.$course->id
;
159 //echo '<a target="popup" title="Open Monitor" href="../help.php?module=moodle&file=resource/types.html"><span class="helplink"><img class="iconhelp" alt="Open Monitor" src="../pix/help.gif" /></span></a>';
160 print_simple_box_start('right');
161 echo '<a target="LAMS Monitor" title="LAMS Monitor" href="'.$monitor_url.'">'.get_string("openmonitor", "lams").'</a>';
162 print_simple_box_end();
165 echo '</tr></table>';
167 }else{//editing turned off
168 $datetime = date("F d,Y g:i a");
169 $plaintext = trim($datetime).trim($USER->username
).trim($LAMSCONSTANTS->learner_method
).trim($CFG->lams_serverid
).trim($CFG->lams_serverkey
);
170 $hash = sha1(strtolower($plaintext));
171 $url = $CFG->lams_serverurl
.$LAMSCONSTANTS->login_request
.
172 '?'.$LAMSCONSTANTS->param_uid
.'='.$USER->username
.
173 '&'.$LAMSCONSTANTS->param_method
.'='.$LAMSCONSTANTS->learner_method
.
174 '&'.$LAMSCONSTANTS->param_timestamp
.'='.urlencode($datetime).
175 '&'.$LAMSCONSTANTS->param_serverid
.'='.$CFG->lams_serverid
.
176 '&'.$LAMSCONSTANTS->param_hash
.'='.$hash.
177 '&'.$LAMSCONSTANTS->param_courseid
.'='.$course->id
;
179 echo '<table width="100%" height="600" class="section">'.
181 '<td class="activity forum">'.
182 '<iframe name="iframe" id="iframe" src="'.$url.'" width="100%" height="100%" frameborder="1">'.
189 //print_section($course, $thissection, $mods, $modnamesused);
191 /*if (isediting($course->id)) {
192 print_section_add_menus($course, $section, $modnames);
196 echo '<td class="right side"> </td>';
198 echo '<tr class="section separator"><td colspan="3" class="spacer"></td></tr>';
202 /// Now all the normal modules by topic
203 /// Everything below uses "section" terminology - each "section" is a topic.
207 $sectionmenu = array();
209 while ($section <= $course->numsections
) {
211 if (!empty($sections[$section])) {
212 $thissection = $sections[$section];
216 $thissection->course
= $course->id
; // Create a new section structure
217 $thissection->section
= $section;
218 $thissection->summary
= '';
219 $thissection->visible
= 1;
220 if (!$thissection->id
= insert_record('course_sections', $thissection)) {
221 notify('Error inserting new topic!');
225 $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible
or !$course->hiddensections
);
227 if (!empty($displaysection) and $displaysection != $section) {
229 $strsummary = ' - '.strip_tags($thissection->summary
);
230 if (strlen($strsummary) < 57) {
231 $strsummary = ' - '.$strsummary;
233 $strsummary = ' - '.substr($strsummary, 0, 60).'...';
235 $sectionmenu['topic='.$section] = s($section.$strsummary);
243 $currenttopic = ($course->marker
== $section);
245 if (!$thissection->visible
) {
246 $sectionstyle = ' hidden';
247 } else if ($currenttopic) {
248 $sectionstyle = ' current';
253 echo '<tr id="section-'.$section.'" class="section main'.$sectionstyle.'">';
255 echo '<td class="left side"> </td>';
257 echo '<td class="content">';
258 if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible
) { // Hidden for students
259 echo get_string('notavailable');
261 echo '<div class="summary">';
262 $summaryformatoptions->noclean
= true;
263 echo format_text($thissection->summary
, FORMAT_HTML
, $summaryformatoptions);
265 if (isediting($course->id
) && has_capability('moodle/course:update', $course->id
)) {
266 echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id
.'">'.
267 '<img src="'.$CFG->pixpath
.'/t/edit.gif" class="iconsmall" alt="'.$streditsummary.'" /></a><br /><br />';
271 print_section($course, $thissection, $mods, $modnamesused);
273 if (isediting($course->id
)) {
274 print_section_add_menus($course, $section, $modnames);
279 echo '<td class="right side">';
280 if ($displaysection == $section) { // Show the zoom boxes
281 echo '<a href="view.php?id='.$course->id
.'&topic=0#section-'.$section.'" title="'.$strshowalltopics.'">'.
282 '<img src="'.$CFG->pixpath
.'/i/all.gif" height="25" width="16" border="0" alt="'.$strshowalltopics.'" /></a><br />';
284 $strshowonlytopic = get_string('showonlytopic', '', $section);
285 echo '<a href="view.php?id='.$course->id
.'&topic='.$section.'" title="'.$strshowonlytopic.'">'.
286 '<img src="'.$CFG->pixpath
.'/i/one.gif" height="16" width="16" border="0" alt="'.$strshowonlytopic.'" /></a><br />';
289 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
290 if ($course->marker
== $section) { // Show the "light globe" on/off
291 echo '<a href="view.php?id='.$course->id
.'&marker=0&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strmarkedthistopic.'">'.
292 '<img src="'.$CFG->pixpath
.'/i/marked.gif" height="16" width="16" border="0" alt="'.$strmarkedthistopic.'" /></a><br />';
294 echo '<a href="view.php?id='.$course->id
.'&marker='.$section.'&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strmarkthistopic.'">'.
295 '<img src="'.$CFG->pixpath
.'/i/marker.gif" height="16" width="16" border="0" alt="'.$strmarkthistopic.'" /></a><br />';
298 if ($thissection->visible
) { // Show the hide/show eye
299 echo '<a href="view.php?id='.$course->id
.'&hide='.$section.'&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strtopichide.'">'.
300 '<img src="'.$CFG->pixpath
.'/i/hide.gif" height="16" width="16" border="0" alt="'.$strtopichide.'" /></a><br />';
302 echo '<a href="view.php?id='.$course->id
.'&show='.$section.'&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strtopicshow.'">'.
303 '<img src="'.$CFG->pixpath
.'/i/show.gif" height="16" width="16" border="0" alt="'.$strtopicshow.'" /></a><br />';
306 if ($section > 1) { // Add a arrow to move section up
307 echo '<a href="view.php?id='.$course->id
.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.$USER->sesskey
.'#section-'.($section-1).'" title="'.$strmoveup.'">'.
308 '<img src="'.$CFG->pixpath
.'/t/up.gif" class="iconsmall" alt="'.$strmoveup.'" /></a><br />';
311 if ($section < $course->numsections
) { // Add a arrow to move section down
312 echo '<a href="view.php?id='.$course->id
.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.$USER->sesskey
.'#section-'.($section+
1).'" title="'.$strmovedown.'">'.
313 '<img src="'.$CFG->pixpath
.'/t/down.gif" class="iconsmall" alt="'.$strmovedown.'" /></a><br />';
319 echo '<tr class="section separator"><td colspan="3" class="spacer"></td></tr>';
326 if (!empty($sectionmenu)) {
327 echo '<div align="center" class="jumpmenu">';
328 echo popup_form($CFG->wwwroot
.'/course/view.php?id='.$course->id
.'&', $sectionmenu,
329 'sectionmenu', '', get_string('jumpto'), '', '', true);
337 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT
) ||
$editing) {
338 echo '<td style="width:'.$preferred_width_right.'px" id="right-column">';
339 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT
);
343 echo '</tr></table>';