Skip to content

Commit

Permalink
mod/assignment: MDL-16796 Support non-core assignment type titles
Browse files Browse the repository at this point in the history
Without this patch, the add actvitiy drop down displays ugly
broken lang strings.

This is ugly - hopefully in Moodle 2.0 we will eventually support fully
pluggable architecture in a clean way.
  • Loading branch information
danpoltawski committed Oct 30, 2009
1 parent a380f30 commit 40fcf70
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
11 changes: 10 additions & 1 deletion mod/assignment/lib.php
Expand Up @@ -1995,6 +1995,10 @@ function reset_userdata($data) {
$status = array();

$typestr = get_string('type'.$this->type, 'assignment');
// ugly hack to support pluggable assignment type titles...
if($typestr === '[[type'.$this->type.']]'){
$typestr = get_string('type'.$this->type, 'assignment_'.$this->type);
}

if (!empty($data->reset_assignment_submissions)) {
$assignmentssql = "SELECT a.id
Expand Down Expand Up @@ -3071,6 +3075,11 @@ function assignment_types() {
$names = get_plugin_list('assignment');
foreach ($names as $name=>$dir) {
$types[$name] = get_string('type'.$name, 'assignment');

// ugly hack to support pluggable assignment type titles..
if ($types[$name] == '[[type'.$name.']]') {
$types[$name] = get_string('type'.$name, 'assignment_'.$name);
}
}
asort($types);
return $types;
Expand Down Expand Up @@ -3248,7 +3257,7 @@ function assignment_get_types() {
$type = new object();
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "assignment&type=$assignmenttype";
$type->typestr = get_string("type$assignmenttype", 'assignment');
$type->typestr = get_string("type$assignmenttype", 'assignment_'.$assignmenttype);
$types[] = $type;
}
}
Expand Down
12 changes: 11 additions & 1 deletion mod/assignment/mod_form.php
Expand Up @@ -56,7 +56,17 @@ function definition() {
$mform->addElement('select', 'preventlate', get_string('preventlate', 'assignment'), $ynoptions);
$mform->setDefault('preventlate', 0);

$mform->addElement('header', 'typedesc', get_string('type'.$type,'assignment'));


$typetitle = get_string('type'.$type, 'assignment');

// hack to support pluggable assignment type titles
if ($typetitle === '[[type'.$type.']]') {
$typetitle = get_string('type'.$type, 'assignment_'.$type);
}

$mform->addElement('header', 'typedesc', $typetitle);

$assignmentinstance->setup_elements($mform);

$this->standard_coursemodule_elements();
Expand Down

0 comments on commit 40fcf70

Please sign in to comment.