From: Dan Poltawski <dan.poltawski@lancaster.ac.uk>
Date: Fri, 30 Oct 2009 21:13:31 +0000 (+0000)
Subject: mod/assignment: MDL-16796 Support non-core assignment type titles
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=40fcf70c3d9d2b081f436d1efa06bf38571f0e39;p=moodle.git

mod/assignment: MDL-16796 Support non-core assignment type titles

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.
---

diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php
index 2094b425fb..5c757972e1 100644
--- a/mod/assignment/lib.php
+++ b/mod/assignment/lib.php
@@ -1995,6 +1995,10 @@ class assignment_base {
         $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
@@ -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;
@@ -3248,7 +3257,7 @@ function assignment_get_types() {
             $type = new object();
             $type->modclass = MOD_CLASS_ACTIVITY;
             $type->type = "assignment&amp;type=$assignmenttype";
-            $type->typestr = get_string("type$assignmenttype", 'assignment');
+            $type->typestr = get_string("type$assignmenttype", 'assignment_'.$assignmenttype);
             $types[] = $type;
         }
     }
diff --git a/mod/assignment/mod_form.php b/mod/assignment/mod_form.php
index 6aca75cdba..cd1d663676 100644
--- a/mod/assignment/mod_form.php
+++ b/mod/assignment/mod_form.php
@@ -56,7 +56,17 @@ class mod_assignment_mod_form extends moodleform_mod {
         $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();