format.php 12.4 KB
Newer Older
1
2
3
4
<?php

// Display the whole course as "topics" made of of modules
// Included from "view.php"
5
6
/**
 * Evaluation topics format for course display - NO layout tables, for accessibility, etc.
7
8
9
 *
 * A duplicate course format to enable the Moodle development team to evaluate
 * CSS for the multi-column layout in place of layout tables.
10
11
12
13
14
15
 * Less risk for the Moodle 1.6 beta release.
 *   1. Straight copy of topics/format.php
 *   2. Replace <table> and <td> with DIVs; inline styles.
 *   3. Reorder columns so that in linear view content is first then blocks;
 * styles to maintain original graphical (side by side) view.
 *
16
 * Target: 3-column graphical view using relative widths for pixel screen sizes
17
 * 800x600, 1024x768... on IE6, Firefox. Below 800 columns will shift downwards.
18
 *
19
20
21
22
23
24
 * http://www.maxdesign.com.au/presentation/em/ Ideal length for content.
 * http://www.svendtofte.com/code/max_width_in_ie/ Max width in IE.
 *
 * @copyright &copy; 2006 The Open University
 * @author N.D.Freear@open.ac.uk, and others.
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
25
 * @package
26
 */
27

28
29
defined('MOODLE_INTERNAL') || die();

30
require_once($CFG->libdir.'/filelib.php');
31

32
$topic = optional_param('topic', -1, PARAM_INT);
33

34
35
36
37
38
if ($topic != -1) {
    $displaysection = course_set_display($course->id, $topic);
} else {
    if (isset($USER->display[$course->id])) {
        $displaysection = $USER->display[$course->id];
39
    } else {
40
        $displaysection = course_set_display($course->id, 0);
41
    }
42
}
43

44
$context = get_context_instance(CONTEXT_COURSE, $course->id);
toyomoyo's avatar
toyomoyo committed
45

46
47
if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
    $course->marker = $marker;
48
    $DB->set_field("course", "marker", $marker, array("id"=>$course->id));
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
}

$streditsummary  = get_string('editsummary');
$stradd          = get_string('add');
$stractivities   = get_string('activities');
$strshowalltopics = get_string('showalltopics');
$strtopic         = get_string('topic');
$strgroups       = get_string('groups');
$strgroupmy      = get_string('groupmy');
$editing         = $PAGE->user_is_editing();

if ($editing) {
    $strtopichide = get_string('hidetopicfromothers');
    $strtopicshow = get_string('showtopicfromothers');
    $strmarkthistopic = get_string('markthistopic');
    $strmarkedthistopic = get_string('markedthistopic');
    $strmoveup   = get_string('moveup');
    $strmovedown = get_string('movedown');
}

// Print the Your progress icon if the track completion is enabled
$completioninfo = new completion_info($course);
$completioninfo->print_help_icon();

echo $OUTPUT->heading(get_string('topicoutline'), 2, 'headingblock header outline');

// Note, an ordered list would confuse - "1" could be the clipboard or summary.
echo "<ul class='topics'>\n";
77

78
79
80
81
82
83
84
85
/// If currently moving a file then show the current clipboard
if (ismoving($course->id)) {
    $stractivityclipboard = strip_tags(get_string('activityclipboard', '', $USER->activitycopyname));
    $strcancel= get_string('cancel');
    echo '<li class="clipboard">';
    echo $stractivityclipboard.'&nbsp;&nbsp;(<a href="mod.php?cancelcopy=true&amp;sesskey='.sesskey().'">'.$strcancel.'</a>)';
    echo "</li>\n";
}
86

87
/// Print Section 0 with general activities
88

89
90
$section = 0;
$thissection = $sections[$section];
91
unset($sections[0]);
92
93
94
95
96

if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {

    // Note, no need for a 'left side' cell or DIV.
    // Note, 'right side' is BEFORE content.
97
    echo '<li id="section-0" class="section main clearfix" >';
98
99
100
    echo '<div class="left side">&nbsp;</div>';
    echo '<div class="right side" >&nbsp;</div>';
    echo '<div class="content">';
101
102
103
    if (!is_null($thissection->name)) {
        echo $OUTPUT->heading($thissection->name, 3, 'sectionname');
    }
104
105
106
    echo '<div class="summary">';

    $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
107
    $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
108
    $summaryformatoptions = new stdClass();
109
    $summaryformatoptions->noclean = true;
110
    $summaryformatoptions->overflowdiv = true;
111
    echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
112
113
114

    if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $coursecontext)) {
        echo '<a title="'.$streditsummary.'" '.
115
             ' href="editsection.php?id='.$thissection->id.'"><img src="'.$OUTPUT->pix_url('t/edit') . '" '.
116
117
118
             ' class="icon edit" alt="'.$streditsummary.'" /></a>';
    }
    echo '</div>';
119

120
    print_section($course, $thissection, $mods, $modnamesused);
121

122
123
    if ($PAGE->user_is_editing()) {
        print_section_add_menus($course, $section, $modnames);
124
125
    }

126
127
128
    echo '</div>';
    echo "</li>\n";
}
129
130


131
132
/// Now all the normal modules by topic
/// Everything below uses "section" terminology - each "section" is a topic.
133

134
135
136
$timenow = time();
$section = 1;
$sectionmenu = array();
137

138
while ($section <= $course->numsections) {
139

140
141
    if (!empty($sections[$section])) {
        $thissection = $sections[$section];
142

143
    } else {
144
        $thissection = new stdClass;
145
146
        $thissection->course  = $course->id;   // Create a new section structure
        $thissection->section = $section;
147
        $thissection->name    = null;
148
        $thissection->summary  = '';
Petr Skoda's avatar
Petr Skoda committed
149
        $thissection->summaryformat = FORMAT_HTML;
150
151
152
        $thissection->visible  = 1;
        $thissection->id = $DB->insert_record('course_sections', $thissection);
    }
153

154
    $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
155

156
157
    if (!empty($displaysection) and $displaysection != $section) {  // Check this topic is visible
        if ($showsection) {
158
            $sectionmenu[$section] = get_section_name($course, $thissection);
159
160
161
162
        }
        $section++;
        continue;
    }
163

164
    if ($showsection) {
165

166
        $currenttopic = ($course->marker == $section);
moodler's avatar
moodler committed
167

168
169
170
171
172
173
        $currenttext = '';
        if (!$thissection->visible) {
            $sectionstyle = ' hidden';
        } else if ($currenttopic) {
            $sectionstyle = ' current';
            $currenttext = get_accesshide(get_string('currenttopic','access'));
moodler's avatar
moodler committed
174
        } else {
175
            $sectionstyle = '';
moodler's avatar
moodler committed
176
177
        }

178
        echo '<li id="section-'.$section.'" class="section main clearfix'.$sectionstyle.'" >'; //'<div class="left side">&nbsp;</div>';
179
180
181
182
183

            echo '<div class="left side">'.$currenttext.$section.'</div>';
        // Note, 'right side' is BEFORE content.
        echo '<div class="right side">';

184
        if ($displaysection == $section) {    // Show the zoom boxes
185
            echo '<a href="view.php?id='.$course->id.'&amp;topic=0#section-'.$section.'" title="'.$strshowalltopics.'">'.
186
                 '<img src="'.$OUTPUT->pix_url('i/all') . '" class="icon" alt="'.$strshowalltopics.'" /></a><br />';
187
188
189
        } else {
            $strshowonlytopic = get_string("showonlytopic", "", $section);
            echo '<a href="view.php?id='.$course->id.'&amp;topic='.$section.'" title="'.$strshowonlytopic.'">'.
190
                 '<img src="'.$OUTPUT->pix_url('i/one') . '" class="icon" alt="'.$strshowonlytopic.'" /></a><br />';
191
192
        }

193
        if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
194

195
            if ($course->marker == $section) {  // Show the "light globe" on/off
196
                echo '<a href="view.php?id='.$course->id.'&amp;marker=0&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strmarkedthistopic.'">'.'<img src="'.$OUTPUT->pix_url('i/marked') . '" alt="'.$strmarkedthistopic.'" /></a><br />';
197
            } else {
198
                echo '<a href="view.php?id='.$course->id.'&amp;marker='.$section.'&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strmarkthistopic.'">'.'<img src="'.$OUTPUT->pix_url('i/marker') . '" alt="'.$strmarkthistopic.'" /></a><br />';
199
            }
200

201
202
            if ($thissection->visible) {        // Show the hide/show eye
                echo '<a href="view.php?id='.$course->id.'&amp;hide='.$section.'&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strtopichide.'">'.
203
                     '<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon hide" alt="'.$strtopichide.'" /></a><br />';
204
            } else {
205
                echo '<a href="view.php?id='.$course->id.'&amp;show='.$section.'&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strtopicshow.'">'.
206
                     '<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon hide" alt="'.$strtopicshow.'" /></a><br />';
207
208
209
            }
            if ($section > 1) {                       // Add a arrow to move section up
                echo '<a href="view.php?id='.$course->id.'&amp;random='.rand(1,10000).'&amp;section='.$section.'&amp;move=-1&amp;sesskey='.sesskey().'#section-'.($section-1).'" title="'.$strmoveup.'">'.
210
                     '<img src="'.$OUTPUT->pix_url('t/up') . '" class="icon up" alt="'.$strmoveup.'" /></a><br />';
211
            }
212

213
214
            if ($section < $course->numsections) {    // Add a arrow to move section down
                echo '<a href="view.php?id='.$course->id.'&amp;random='.rand(1,10000).'&amp;section='.$section.'&amp;move=1&amp;sesskey='.sesskey().'#section-'.($section+1).'" title="'.$strmovedown.'">'.
215
                     '<img src="'.$OUTPUT->pix_url('t/down') . '" class="icon down" alt="'.$strmovedown.'" /></a><br />';
216
217
218
            }
        }
        echo '</div>';
219

220
221
        echo '<div class="content">';
        if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) {   // Hidden for students
222
            echo get_string('notavailable');
223
        } else {
224
225
226
            if (!is_null($thissection->name)) {
                echo $OUTPUT->heading($thissection->name, 3, 'sectionname');
            }
227
228
            echo '<div class="summary">';
            if ($thissection->summary) {
229
                $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
230
                $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
231
                $summaryformatoptions = new stdClass();
232
                $summaryformatoptions->noclean = true;
233
                $summaryformatoptions->overflowdiv = true;
234
                echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
moodler's avatar
moodler committed
235
            } else {
236
               echo '&nbsp;';
237
238
            }

239
            if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
240
                echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
241
                     '<img src="'.$OUTPUT->pix_url('t/edit') . '" class="icon edit" alt="'.$streditsummary.'" /></a><br /><br />';
242
243
244
            }
            echo '</div>';

245
246
247
248
            print_section($course, $thissection, $mods, $modnamesused);
            echo '<br />';
            if ($PAGE->user_is_editing()) {
                print_section_add_menus($course, $section, $modnames);
moodler's avatar
moodler committed
249
            }
250
        }
moodler's avatar
moodler committed
251

252
        echo '</div>';
253
        echo "</li>\n";
moodler's avatar
moodler committed
254
    }
255

256
    unset($sections[$section]);
257
258
    $section++;
}
259

260
if (!$displaysection and $PAGE->user_is_editing() and has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
261
262
263
264
265
266
267
    // print stealth sections if present
    $modinfo = get_fast_modinfo($course);
    foreach ($sections as $section=>$thissection) {
        if (empty($modinfo->sections[$section])) {
            continue;
        }

268
        echo '<li id="section-'.$section.'" class="section main clearfix orphaned hidden">'; //'<div class="left side">&nbsp;</div>';
269
270
271
272
273
274
275

        echo '<div class="left side">';
        echo '</div>';
        // Note, 'right side' is BEFORE content.
        echo '<div class="right side">';
        echo '</div>';
        echo '<div class="content">';
276
        echo $OUTPUT->heading(get_string('orphanedactivities'), 3, 'sectionname');
277
278
279
280
281
282
283
        print_section($course, $thissection, $mods, $modnamesused);
        echo '</div>';
        echo "</li>\n";
    }
}


284
285
286
echo "</ul>\n";

if (!empty($sectionmenu)) {
287
288
289
290
291
    $select = new single_select(new moodle_url('/course/view.php', array('id'=>$course->id)), 'topic', $sectionmenu);
    $select->label = get_string('jumpto');
    $select->class = 'jumpmenu';
    $select->formid = 'sectionmenu';
    echo $OUTPUT->render($select);
292
}