mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-41611 format_singleactivity: Only hide unnecessary elements
This commit is contained in:
parent
640ef17790
commit
d9203fb775
@ -250,6 +250,24 @@ abstract class format_base {
|
||||
return $this->course;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the course has a front page.
|
||||
*
|
||||
* This function is called to determine if the course has a view page, whether or not
|
||||
* it contains a listing of activities. It can be useful to set this to false when the course
|
||||
* format has only one activity and ignores the course page. Or if there are multiple
|
||||
* activities but no page to see the centralised information.
|
||||
*
|
||||
* Initially this was created to know if forms should add a button to return to the course page.
|
||||
* So if 'Return to course' does not make sense in your format your should probably return false.
|
||||
*
|
||||
* @return boolean
|
||||
* @since 2.6
|
||||
*/
|
||||
public function has_view_page() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this course format uses sections
|
||||
*
|
||||
|
@ -457,4 +457,14 @@ class format_singleactivity extends format_base {
|
||||
$activitynode->remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the course has a front page.
|
||||
*
|
||||
* @return boolean false
|
||||
*/
|
||||
public function has_view_page() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,4 @@
|
||||
/* Hide confusing form elements "Display description on course page" and
|
||||
"Save and return to course" from module edit form because they
|
||||
are not applicable in single activity course format */
|
||||
body.format-singleactivity.path-mod.pagelayout-admin form.mform #fitem_id_showdescription,
|
||||
body.format-singleactivity.path-mod.pagelayout-admin form.mform .fitem_actionbuttons#fgroup_id_buttonar #id_submitbutton {display:none;}
|
||||
|
||||
/* In mod_quiz hide "Back to course" button */
|
||||
body.format-singleactivity.path-mod-quiz .quizattempt .continuebutton {display:none;}
|
||||
.format-singleactivity.path-mod-quiz .quizattempt .continuebutton {display:none;}
|
||||
|
||||
body.format-singleactivity .tree_item.orphaned a {color:red;}
|
||||
.format-singleactivity .tree_item.orphaned a {color:red;}
|
||||
|
@ -55,7 +55,12 @@ abstract class moodleform_mod extends moodleform {
|
||||
*/
|
||||
protected $applyadminlockedflags = false;
|
||||
|
||||
/** @var object The course format of the current course. */
|
||||
protected $courseformat;
|
||||
|
||||
function moodleform_mod($current, $section, $cm, $course) {
|
||||
global $CFG;
|
||||
|
||||
$this->current = $current;
|
||||
$this->_instance = $current->instance;
|
||||
$this->_section = $section;
|
||||
@ -66,6 +71,10 @@ abstract class moodleform_mod extends moodleform {
|
||||
$this->context = context_course::instance($course->id);
|
||||
}
|
||||
|
||||
// Set the course format.
|
||||
require_once($CFG->dirroot . '/course/format/lib.php');
|
||||
$this->courseformat = course_get_format($course);
|
||||
|
||||
// Guess module name
|
||||
$matches = array();
|
||||
if (!preg_match('/^mod_([^_]+)_mod_form$/', get_class($this), $matches)) {
|
||||
@ -831,9 +840,9 @@ abstract class moodleform_mod extends moodleform {
|
||||
$mform->addRule('introeditor', get_string('required'), 'required', null, 'client');
|
||||
}
|
||||
|
||||
// If the 'show description' feature is enabled, this checkbox appears
|
||||
// below the intro.
|
||||
if ($this->_features->showdescription) {
|
||||
// If the 'show description' feature is enabled, this checkbox appears below the intro.
|
||||
// We want to hide that when using the singleactivity course format because it is confusing.
|
||||
if ($this->_features->showdescription && $this->courseformat->has_view_page()) {
|
||||
$mform->addElement('checkbox', 'showdescription', get_string('showdescription'));
|
||||
$mform->addHelpButton('showdescription', 'showdescription');
|
||||
}
|
||||
@ -861,7 +870,9 @@ abstract class moodleform_mod extends moodleform {
|
||||
// elements in a row need a group
|
||||
$buttonarray = array();
|
||||
|
||||
if ($submit2label !== false) {
|
||||
// Label for the submit button to return to the course.
|
||||
// Ignore this button in single activity format because it is confusing.
|
||||
if ($submit2label !== false && $this->courseformat->has_view_page()) {
|
||||
$buttonarray[] = &$mform->createElement('submit', 'submitbutton2', $submit2label);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user