Added extra warning if no templates are available
This commit is contained in:
parent
82838c57c5
commit
886a11d99e
3 changed files with 67 additions and 50 deletions
|
@ -100,6 +100,9 @@ class studyplan_fromtemplateform extends formbase {
|
||||||
$templatelist[$s->id()] = implode(" / ",$c['path']) . " / " . $s->name();
|
$templatelist[$s->id()] = implode(" / ",$c['path']) . " / " . $s->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count($templatelist) > 0) {
|
||||||
|
$mform->addElement('hidden','hastemplates','yes');
|
||||||
|
|
||||||
$field = 'template_id';
|
$field = 'template_id';
|
||||||
$mform->addElement('autocomplete', $field,
|
$mform->addElement('autocomplete', $field,
|
||||||
get_string('studyplan_fromtemplate','local_treestudyplan'),
|
get_string('studyplan_fromtemplate','local_treestudyplan'),
|
||||||
|
@ -128,11 +131,11 @@ class studyplan_fromtemplateform extends formbase {
|
||||||
$contextlist[$c['context_id']] = implode(" / ",$c['category']['path']);
|
$contextlist[$c['context_id']] = implode(" / ",$c['category']['path']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$mform->addElement('autocomplete', 'context_id',
|
$field = 'context_id';
|
||||||
|
$mform->addElement('autocomplete', $field,
|
||||||
get_string('studyplan_context','local_treestudyplan'),
|
get_string('studyplan_context','local_treestudyplan'),
|
||||||
$contextlist);
|
$contextlist);
|
||||||
|
$mform->addRule($field, null, 'required', null, 'client');
|
||||||
$mform->addRule('context_id', null, 'required', null, 'client');
|
|
||||||
|
|
||||||
$timeless = \get_config("local_treestudyplan","timelessperiods");
|
$timeless = \get_config("local_treestudyplan","timelessperiods");
|
||||||
if ( !$timeless) {
|
if ( !$timeless) {
|
||||||
|
@ -144,7 +147,15 @@ class studyplan_fromtemplateform extends formbase {
|
||||||
$mform->addRule($field, null, 'required', null, 'client');
|
$mform->addRule($field, null, 'required', null, 'client');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$mform->addElement('hidden','hastemplates','no');
|
||||||
|
|
||||||
|
$field = 'warning';
|
||||||
|
$mform->addElement('static', $field,
|
||||||
|
get_string('warning','core'),
|
||||||
|
get_string('no_templates','local_treestudyplan')
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,6 +167,7 @@ class studyplan_fromtemplateform extends formbase {
|
||||||
protected function process_submitted_data($entry) {
|
protected function process_submitted_data($entry) {
|
||||||
$customdata = (object)$this->_customdata;
|
$customdata = (object)$this->_customdata;
|
||||||
|
|
||||||
|
if($entry->hastemplates == "yes") {
|
||||||
// Find template study plan.
|
// Find template study plan.
|
||||||
$template = studyplan::find_by_id($entry->template_id);
|
$template = studyplan::find_by_id($entry->template_id);
|
||||||
// Copy template plan.
|
// Copy template plan.
|
||||||
|
@ -166,6 +178,9 @@ class studyplan_fromtemplateform extends formbase {
|
||||||
so we return it in a consistent way
|
so we return it in a consistent way
|
||||||
*/
|
*/
|
||||||
return studyplanservice::clean_returnvalue(studyplan::simple_structure(),$plan->simple_model());
|
return studyplanservice::clean_returnvalue(studyplan::simple_structure(),$plan->simple_model());
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -512,3 +512,4 @@ $string["line_is_enrolled"] = 'You are registered for this line';
|
||||||
$string["line_enrolled_in"] = 'Registered in {$a}';
|
$string["line_enrolled_in"] = 'Registered in {$a}';
|
||||||
$string["switch_coach_editmode"] = "Edit studyplan";
|
$string["switch_coach_editmode"] = "Edit studyplan";
|
||||||
$string["suspended"] = "Suspended";
|
$string["suspended"] = "Suspended";
|
||||||
|
$string["no_templates"] = "There are no templates available. Mark a study plan as template to enable template based creation.";
|
|
@ -512,3 +512,4 @@ $string["line_is_enrolled"] = 'Je bent ingeschreven voor deze leerlijn';
|
||||||
$string["line_enrolled_in"] = 'Ingeschreven in {$a}';
|
$string["line_enrolled_in"] = 'Ingeschreven in {$a}';
|
||||||
$string["switch_coach_editmode"] = "Studieplan bewerken";
|
$string["switch_coach_editmode"] = "Studieplan bewerken";
|
||||||
$string["suspended"] = "Tijdelijk uitgeschakeld";
|
$string["suspended"] = "Tijdelijk uitgeschakeld";
|
||||||
|
$string["no_templates"] = "Er zijn geen templates beschikbaar. Zet het vinkje 'Bruikbaar als template' aan bij een studieplan om deze als template te kunnen gebruiken.";
|
Loading…
Reference in a new issue