diff --git a/course/editsection.php b/course/editsection.php index 092a3016ddd56..cc61e615061ee 100644 --- a/course/editsection.php +++ b/course/editsection.php @@ -48,7 +48,13 @@ $currenttext = file_prepare_draft_area($draftitemid, $context->id, 'course_section', $section->id, array('subdirs'=>true), $section->summary); $mform = new editsection_form(null, $course); -$data = array('id'=>$section->id, 'summary'=>array('text'=>$currenttext, 'format'=>FORMAT_HTML, 'itemid'=>$draftitemid)); +$data = array( + 'id'=>$section->id, + 'usedefaultname'=>(is_null($section->name)), + 'name'=>$section->name, + 'summary'=>array('text'=>$currenttext, 'format'=>FORMAT_HTML, 'itemid'=>$draftitemid) +); + $mform->set_data($data); // set defaults /// If data submitted, then process and store. @@ -56,9 +62,13 @@ redirect($CFG->wwwroot.'/course/view.php?id='.$course->id); } else if ($data = $mform->get_data()) { - - $text = file_save_draft_area_files($data->summary['itemid'], $context->id, 'course_section', $section->id, array('subdirs'=>true), $data->summary['text']); - $DB->set_field("course_sections", "summary", $text, array("id"=>$section->id)); + if (empty($data->usedefaultname)) { + $section->name = $data->name; + } else { + $section->name = null; + } + $section->summary = file_save_draft_area_files($data->summary['itemid'], $context->id, 'course_section', $section->id, array('subdirs'=>true), $data->summary['text']); + $DB->update_record('course_sections', $section); add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section"); redirect("view.php?id=$course->id"); } @@ -76,7 +86,6 @@ $PAGE->set_title($stredit); $PAGE->navbar->add($stredit); -$PAGE->set_focuscontrol('theform.summary'); echo $OUTPUT->header(); echo $OUTPUT->heading_with_help($strsummaryof, 'summaries'); diff --git a/course/editsection_form.php b/course/editsection_form.php index b517ec7f2498f..0958edbe4707e 100644 --- a/course/editsection_form.php +++ b/course/editsection_form.php @@ -10,6 +10,13 @@ function definition() { $mform = $this->_form; $course = $this->_customdata; + $mform->addElement('checkbox', 'usedefaultname', get_string('sectionusedefaultname')); + $mform->setDefault('usedefaultname', true); + + $mform->addElement('text', 'name', get_string('sectionname'), array('size'=>'30')); + $mform->setType('name', PARAM_TEXT); + $mform->disabledIf('name','usedefaultname','checked'); + $mform->addElement('editor', 'summary', get_string('summary'), null, array('changeformat'=>false, 'maxfiles'=>-1)); $mform->addElement('hidden', 'id'); diff --git a/course/format/scorm/lib.php b/course/format/scorm/lib.php index 09eba86d80758..663ceea92a5b1 100644 --- a/course/format/scorm/lib.php +++ b/course/format/scorm/lib.php @@ -39,7 +39,7 @@ function callback_scorm_definition() { * * @return string */ -function callback_scorm_request_keyscorm() { +function callback_scorm_request_key() { return 'scorm'; } diff --git a/course/format/social/lib.php b/course/format/social/lib.php index 7e19bce9dce6f..60a4bfa56ee38 100644 --- a/course/format/social/lib.php +++ b/course/format/social/lib.php @@ -33,8 +33,8 @@ * @param stdClass $modinfo The mod info object for the current course * @return bool Returns true */ -function load_course_format_social(&$navigation, $keys, $course) { - $navigation->add_course_section_generic($keys, $course, get_string('social'), 'social'); +function callback_social_load_content(&$navigation, $course, $coursenode) { + return $navigation->load_generic_course_sections($course, $coursenode, 'social'); } /** diff --git a/course/format/topics/lib.php b/course/format/topics/lib.php index b47a986c1796c..8bf95c1393b64 100644 --- a/course/format/topics/lib.php +++ b/course/format/topics/lib.php @@ -34,7 +34,7 @@ * @return bool Returns true */ function callback_topics_load_content(&$navigation, $course, $coursenode) { - return $navigation->load_generic_course_sections($course, $coursenode, get_string('topic'), 'topic', get_string('section0name', 'format_topics')); + return $navigation->load_generic_course_sections($course, $coursenode, 'topics'); } /** @@ -57,3 +57,13 @@ function callback_topics_request_key() { return 'topic'; } +function callback_topics_get_section_name($course, $section) { + // We can't add a node without any text + if (!is_empty($section->name)) { + return $section->name; + } else if ($section->section == 0) { + return get_string('section0name', 'format_topics'); + } else { + return get_string('topic').' '.$section->section; + } +} \ No newline at end of file diff --git a/course/format/weeks/format.php b/course/format/weeks/format.php index f1d0fa4c0fd37..0fd93d81539ec 100644 --- a/course/format/weeks/format.php +++ b/course/format/weeks/format.php @@ -87,6 +87,10 @@ echo '