* @param stdClass $course The course entry from DB
* @param array $sections The course_sections entries from the DB
* @param int $sectionno The section number in the coruse which is being dsiplayed
- * @return string HTML to output.
+ * @return array associative array with previous and next section link
*/
protected function get_nav_links($course, $sections, $sectionno) {
// FIXME: This is really evil and should by using the navigation API.
$back = $sectionno - 1;
while ($back > 0 and empty($links['previous'])) {
if ($canviewhidden || $sections[$back]->visible) {
- $links['previous'] = html_writer::link(course_get_url($course, $back),
- $this->output->larrow().$this->output->spacer().get_section_name($course, $sections[$back]));
+ $previouslink = html_writer::tag('span', $this->output->larrow(), array('class' => 'larrow'));
+ $previouslink .= get_section_name($course, $sections[$back]);
+ $links['previous'] = html_writer::link(course_get_url($course, $back), $previouslink);
}
$back--;
}
$forward = $sectionno + 1;
while ($forward <= $course->numsections and empty($links['next'])) {
if ($canviewhidden || $sections[$forward]->visible) {
- $links['next'] = html_writer::link(course_get_url($course, $forward),
- get_section_name($course, $sections[$forward]).$this->output->spacer().$this->output->rarrow());
+ $nextlink = get_section_name($course, $sections[$forward]);
+ $nextlink .= html_writer::tag('span', $this->output->rarrow(), array('class' => 'rarrow'));
+ $links['next'] = html_writer::link(course_get_url($course, $forward), $nextlink);
}
$forward++;
}
- $o = '';
- $o.= html_writer::start_tag('div', array('class' => 'section-navigation yui3-g'));
- $o.= html_writer::tag('div', $links['previous'], array('class' => 'yui3-u'));
- $o.= html_writer::tag('div', $links['next'], array('class' => 'right yui3-u'));
- $o.= html_writer::end_tag('div');
-
- return $o;
+ return $links;
}
/**
echo $this->end_section_list();
}
- // Section next/previous links.
+ // Title with section navigation links.
$sectionnavlinks = $this->get_nav_links($course, $sections, $displaysection);
- echo $sectionnavlinks;
-
-
- // Title with completion help icon.
+ $sectiontitle = '';
+ $sectiontitle .= html_writer::start_tag('div', array('class' => 'section-navigation headingblock header'));
+ $sectiontitle .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'mdl-left'));
+ $sectiontitle .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'mdl-right'));
+ $sectiontitle .= html_writer::tag('div', get_section_name($course, $sections[$displaysection]), array('class' => 'mdl-align'));
+ $sectiontitle .= html_writer::end_tag('div');
+ echo $sectiontitle;
+
+ // Show completion help icon.
$completioninfo = new completion_info($course);
echo $completioninfo->display_help_icon();
- $title = get_section_name($course, $sections[$displaysection]);
- echo $this->output->heading($title, 2, 'headingblock header outline');
// Copy activity clipboard..
echo $this->course_activity_clipboard($course, $displaysection);
print_section_add_menus($course, $displaysection, $modnames);
}
echo $this->section_footer();
- echo $sectionnavlinks;
echo $this->end_section_list();
+
+ // Display section bottom navigation.
+ $courselink = html_writer::link(course_get_url($course), get_string('returntomaincoursepage'));
+ $sectionbottomnav = '';
+ $sectionbottomnav .= html_writer::start_tag('div', array('class' => 'section-navigation mdl-bottom'));
+ $sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'mdl-left'));
+ $sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'mdl-right'));
+ $sectionbottomnav .= html_writer::tag('div', $courselink, array('class' => 'mdl-align'));
+ $sectionbottomnav .= html_writer::end_tag('div');
+ echo $sectionbottomnav;
}
/**
} else {
// This will create a course section if it doesn't exist..
$thissection = get_course_section($section, $course->id);
+
+ // The returned section is only a bare database object rather than
+ // a section_info object - we will need at least the uservisible
+ // field in it.
+ $thissection->uservisible = true;
}
// Show the section if the user is permitted to access it, OR if it's not available
// but showavailability is turned on
require_once($CFG->libdir.'/completionlib.php');
require_once($CFG->libdir.'/filelib.php');
+require_once($CFG->dirroot.'/course/dnduploadlib.php');
define('COURSE_MAX_LOGS_PER_PAGE', 1000); // records
define('COURSE_MAX_RECENT_PERIOD', 172800); // Two days, in seconds
$filename = 'logs_'.userdate(time(),get_string('backupnameformat', 'langconfig'),99,false);
$filename .= '.txt';
header("Content-Type: application/download\n");
- header("Content-Disposition: attachment; filename=$filename");
+ header("Content-Disposition: attachment; filename=\"$filename\"");
header("Expires: 0");
header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
header("Pragma: public");
$cw->summaryformat = FORMAT_HTML;
$cw->sequence = "";
$id = $DB->insert_record("course_sections", $cw);
+ rebuild_course_cache($courseid, true);
return $DB->get_record("course_sections", array("id"=>$id));
}
+
/**
* Given a full mod object with section and course already defined, adds this module to that section.
*
// If we move the highlighted section itself, then just highlight the destination.
// Adjust the higlighted section location if we move something over it either direction.
if ($section == $course->marker) {
- course_set_marker($course, $destination);
+ course_set_marker($course->id, $destination);
} elseif ($moveup && $section > $course->marker && $course->marker >= $destination) {
- course_set_marker($course, $course->marker+1);
+ course_set_marker($course->id, $course->marker+1);
} elseif (!$moveup && $section < $course->marker && $course->marker <= $destination) {
- course_set_marker($course, $course->marker-1);
+ course_set_marker($course->id, $course->marker-1);
}
$transaction->allow_commit();
* @return string XHTML for the editing buttons
*/
function make_editing_buttons(stdClass $mod, $absolute_ignored = true, $moveselect = true, $indent=-1, $section=-1) {
- global $CFG, $OUTPUT;
+ global $CFG, $OUTPUT, $COURSE;
static $str;
$str->forcedgroupsnone = get_string('forcedmodeinbrackets', 'moodle', get_string("groupsnone"));
$str->forcedgroupsseparate = get_string('forcedmodeinbrackets', 'moodle', get_string("groupsseparate"));
$str->forcedgroupsvisible = get_string('forcedmodeinbrackets', 'moodle', get_string("groupsvisible"));
+ $str->edittitle = get_string('edittitle', 'moodle');
}
$baseurl = new moodle_url('/course/mod.php', array('sesskey' => sesskey()));
}
$actions = array();
+ // AJAX edit title
+ if ($mod->modname !== 'label' && $hasmanageactivities && course_ajax_enabled($COURSE)) {
+ $actions[] = new action_link(
+ new moodle_url($baseurl, array('update' => $mod->id)),
+ new pix_icon('t/editstring', $str->edittitle, 'moodle', array('class' => 'iconsmall visibleifjs')),
+ null,
+ array('class' => 'editing_title', 'title' => $str->edittitle)
+ );
+ }
+
// leftright
if ($hasmanageactivities) {
if (right_to_left()) { // Exchange arrows on RTL
}
}
+/**
+ * Determine whether course ajax should be enabled for the specified course
+ *
+ * @param stdClass $course The course to test against
+ * @return boolean Whether course ajax is enabled or note
+ */
+function course_ajax_enabled($course) {
+ global $CFG, $PAGE, $SITE;
+
+ // Ajax must be enabled globally
+ if (!$CFG->enableajax) {
+ return false;
+ }
+
+ // The user must be editing for AJAX to be included
+ if (!$PAGE->user_is_editing()) {
+ return false;
+ }
+
+ // Check that the theme suports
+ if (!$PAGE->theme->enablecourseajax) {
+ return false;
+ }
+
+ // Check that the course format supports ajax functionality
+ // The site 'format' doesn't have information on course format support
+ if ($SITE->id !== $course->id) {
+ $courseformatajaxsupport = course_format_ajax_support($course->format);
+ if (!$courseformatajaxsupport->capable) {
+ return false;
+ }
+ }
+
+ // All conditions have been met so course ajax should be enabled
+ return true;
+}
+
/**
* Include the relevant javascript and language strings for the resource
* toolbox YUI module
*
* @param integer $id The ID of the course being applied to
- * @param array $modules An array containing the names of the modules in
- * use on the page
- * @param object $config An object containing configuration parameters for ajax modules including:
+ * @param array $usedmodules An array containing the names of the modules in use on the page
+ * @param array $enabledmodules An array containing the names of the enabled (visible) modules on this site
+ * @param stdClass $config An object containing configuration parameters for ajax modules including:
* * resourceurl The URL to post changes to for resource changes
* * sectionurl The URL to post changes to for section changes
* * pageparams Additional parameters to pass through in the post
- * @return void
+ * @return bool
*/
-function include_course_ajax($course, $modules = array(), $config = null) {
- global $PAGE, $CFG, $USER;
+function include_course_ajax($course, $usedmodules = array(), $enabledmodules = null, $config = null) {
+ global $PAGE, $SITE;
// Ensure that ajax should be included
- $courseformatajaxsupport = course_format_ajax_support($course->format);
- if (!$PAGE->theme->enablecourseajax
- || !$CFG->enableajax
- || empty($USER->editing)
- || !$PAGE->user_is_editing()
- || ($course->id != SITEID && !$courseformatajaxsupport->capable)) {
- return;
+ if (!course_ajax_enabled($course)) {
+ return false;
}
if (!$config) {
);
// Include course dragdrop
- if ($course->id != SITEID) {
+ if ($course->id != $SITE->id) {
$PAGE->requires->yui_module('moodle-course-dragdrop', 'M.course.init_section_dragdrop',
array(array(
'courseid' => $course->id,
'moveleft',
'deletechecktype',
'deletechecktypename',
+ 'edittitle',
+ 'edittitleinstructions',
'show',
'hide',
'groupsnone',
), 'moodle');
// Include format-specific strings
- if ($course->id != SITEID) {
+ if ($course->id != $SITE->id) {
$PAGE->requires->strings_for_js(array(
'showfromothers',
'hidefromothers',
}
// For confirming resource deletion we need the name of the module in question
- foreach ($modules as $module => $modname) {
+ foreach ($usedmodules as $module => $modname) {
$PAGE->requires->string_for_js('pluginname', $module);
}
+
+ // Load drag and drop upload AJAX.
+ dndupload_add_to_course($course, $enabledmodules);
+
+ return true;
}
/**