Forums | Mahara Community

Support /
CPD plugin in Mahara 18.04


Emma Coppins's profile picture
Posts: 1

08 November 2018, 5:23

Hi,

Has anyone used the CPD plugin in Mahara 18.04 please?

I have looked through some of the other posts on this subject, and as of September 2017, it hadn't been used by anyone in a version after 16.10.

Thank you

Emma

Robert Lyon's profile picture
Posts: 774

08 November 2018, 8:33

Hi Emma,

I'm currently using CPD plugin in 18.04 - but I had to make some adjustments to get it to work

Cheers

Robert

 

Here are the things I changed:

diff --git a/htdocs/artefact/cpds/blocktype/cpds/lib.php b/htdocs/artefact/cpds/blocktype/cpds/lib.php
index 47f2603..7a24f46 100644
--- a/htdocs/artefact/cpds/blocktype/cpds/lib.php
+++ b/htdocs/artefact/cpds/blocktype/cpds/lib.php
@@ -40,7 +40,7 @@ class PluginBlocktypeCpds extends PluginBlocktype {
         return array('general');
     }
 
-    public static function get_css_icon() {
+    public static function get_css_icon($blocktypename) {
         return 'check-square-o';
     }
 
@@ -107,7 +107,7 @@ class PluginBlocktypeCpds extends PluginBlocktype {
         return true;
     }
 
-    public static function instance_config_form($instance) {
+    public static function instance_config_form(BlockInstance $instance) {
         $configdata = $instance->get('configdata');
 
         $form = array(
diff --git a/htdocs/artefact/cpds/blocktype/cpds/theme/raw/content.tpl b/htdocs/artefact/cpds/blocktype/cpds/theme/raw/content.tpl
index 6f8d32e..ada01db 100644
--- a/htdocs/artefact/cpds/blocktype/cpds/theme/raw/content.tpl
+++ b/htdocs/artefact/cpds/blocktype/cpds/theme/raw/content.tpl
@@ -14,9 +14,9 @@
             {$activities.pagination|safe}
         </div>
         <script>
-        addLoadEvent(function() {literal}{{/literal}
+        jQuery(function() {literal}{{/literal}
             {$activities.pagination_js|safe}
-            removeElementClass('cpds_page_container', 'hidden');
+            jQuery('#cpds_page_container').removeClass('hidden');
         {literal}}{/literal});
         </script>
         {/if}
diff --git a/htdocs/artefact/cpds/cpd.php b/htdocs/artefact/cpds/cpd.php
index 3923e7b..da8cd54 100644
--- a/htdocs/artefact/cpds/cpd.php
+++ b/htdocs/artefact/cpds/cpd.php
@@ -51,16 +51,16 @@ $activities = ArtefactTypeActivity::get_activities($cpd->get('id'), $offset, $li
 ArtefactTypeActivity::build_activities_list_html($activities);
 
 $js = <<<EOF
-addLoadEvent(function () {
+jQuery(function () {
     {$activities['pagination_js']}
 });
 EOF;
 
 $smarty = smarty(array('paginator'));
-$smarty->assign_by_ref('activities', $activities);
-$smarty->assign_by_ref('cpd', $id);
-$smarty->assign_by_ref('tags', $cpd->get('tags'));
-$smarty->assign_by_ref('owner', $cpd->get('owner'));
+$smarty->assign('activities', $activities);
+$smarty->assign('cpd', $id);
+$smarty->assign('tags', $cpd->get('tags'));
+$smarty->assign('owner', $cpd->get('owner'));
 $smarty->assign('strnoactivitiesaddone',
     get_string('noactivitiesaddone', 'artefact.cpds',
     '<a href="' . get_config('wwwroot') . 'artefact/cpds/new.php?id=' . $cpd->get('id') . '">', '</a>'));
diff --git a/htdocs/artefact/cpds/export/html/lib.php b/htdocs/artefact/cpds/export/html/lib.php
index 3eed4ef..326e030 100644
--- a/htdocs/artefact/cpds/export/html/lib.php
+++ b/htdocs/artefact/cpds/export/html/lib.php
@@ -52,7 +52,7 @@ class HtmlExportCpds extends HtmlExportArtefactPlugin {
         foreach ($this->exporter->get('artefacts') as $artefact) {
             if ($artefact instanceof ArtefactTypeCPD) {
                 $cpds[] = array(
-                    'link' => 'files/cpds/' . PluginExportHtml::text_to_URLpath(PluginExportHtml::text_to_filename($artefact->get('title'))) . '/index.html',
+                    'link'  => 'files/cpds/' . PluginExportHtml::text_to_path($artefact->get('title')) . '/index.html',
                     'title' => $artefact->get('title'),
                 );
             }
diff --git a/htdocs/artefact/cpds/index.php b/htdocs/artefact/cpds/index.php
index 62776b2..9b79d9c 100644
--- a/htdocs/artefact/cpds/index.php
+++ b/htdocs/artefact/cpds/index.php
@@ -44,13 +44,13 @@ $cpds = ArtefactTypeCPD::get_cpds($offset, $limit);
 ArtefactTypeCPD::build_cpds_list_html($cpds);
 
 $js = <<< EOF
-addLoadEvent(function () {
+jQuery(function () {
     {$cpds['pagination_js']}
 });
 EOF;
 
 $smarty = smarty(array('paginator'));
-$smarty->assign_by_ref('cpds', $cpds);
+$smarty->assign('cpds', $cpds);
 $smarty->assign('strnocpdsaddone',
     get_string('nocpdsaddone', 'artefact.cpds',
     '<a href="' . get_config('wwwroot') . 'artefact/cpds/new.php">', '</a>'));
diff --git a/htdocs/artefact/cpds/lang/en.utf8/artefact.cpds.php b/htdocs/artefact/cpds/lang/en.utf8/artefact.cpds.php
index 7ae9cb2..7beb435 100644
--- a/htdocs/artefact/cpds/lang/en.utf8/artefact.cpds.php
+++ b/htdocs/artefact/cpds/lang/en.utf8/artefact.cpds.php
@@ -27,7 +27,6 @@
 defined('INTERNAL') || die();
 
 /* cpds */
-$string['dateformatguide'] = 'Use the format YYYY/MM/DD';
 $string['description'] = 'Description';
 $string['deletecpdconfirm'] = 'Are you sure you wish to delete this CPD? Deleting this CPD will also remove any activities it contains.';
 $string['deletecpd'] = 'Delete CPD';
diff --git a/htdocs/artefact/cpds/lib.php b/htdocs/artefact/cpds/lib.php
index 2bb79d1..e1f4fbd 100644
--- a/htdocs/artefact/cpds/lib.php
+++ b/htdocs/artefact/cpds/lib.php
@@ -136,7 +136,7 @@ class ArtefactTypeCPD extends ArtefactType {
      */
     public static function build_cpds_list_html(&$cpds) {
         $smarty = smarty_core();
-        $smarty->assign_by_ref('cpds', $cpds);
+        $smarty->assign('cpds', $cpds);
         $cpds['tablerows'] = $smarty->fetch('artefact:cpds:cpdslist.tpl');
         $pagination = build_pagination(array(
             'id'                      => 'cpdlist_pagination',
@@ -291,7 +291,7 @@ class ArtefactTypeCPD extends ArtefactType {
         ArtefactTypeActivity::render_activities($activities, $template, $options, $pagination);
 
         $smarty = smarty_core();
-        $smarty->assign_by_ref('activities', $activities);
+        $smarty->assign('activities', $activities);
         if (isset($options['viewid'])) {
             $smarty->assign('artefacttitle', '<a href="' . $baseurl . '">' . hsc($this->get('title')) . '</a>');
         }
@@ -418,7 +418,7 @@ class ArtefactTypeActivity extends ArtefactType {
         db_commit();
     }
 
-    public static function bulk_delete($artefactids) {
+    public static function bulk_delete($artefactids, $log=false) {
         if (empty($artefactids)) {
             return;
         }
@@ -462,6 +462,7 @@ class ArtefactTypeActivity extends ArtefactType {
     *
     */
     public static function get_activityform_elements($parent, $activity=null) {
+        require_once(get_config('libroot') . 'pieforms/pieform/elements/calendar.php');
         $elements = array(
             'title' => array(
                 'type'         => 'text',
@@ -491,7 +492,7 @@ class ArtefactTypeActivity extends ArtefactType {
                 ),
                 'defaultvalue' => null,
                 'title'        => get_string('startdate', 'artefact.cpds'),
-                'description'  => get_string('dateformatguide', 'artefact.cpds'),
+                'description'  => get_string('dateformatguide1', 'mahara', pieform_element_calendar_human_readable_dateformat()),
                 'rules'        => array(
                     'required' => true,
                 ),
@@ -504,7 +505,7 @@ class ArtefactTypeActivity extends ArtefactType {
                 ),
                 'defaultvalue' => null,
                 'title'        => get_string('enddate', 'artefact.cpds'),
-                'description'  => get_string('dateformatguide', 'artefact.cpds'),
+                'description'  => get_string('dateformatguide1', 'mahara', pieform_element_calendar_human_readable_dateformat()),
                 'rules'        => array(
                     'required' => false,
                 ),
@@ -611,13 +612,9 @@ class ArtefactTypeActivity extends ArtefactType {
             foreach ($results as $result) {
                 $grandtotalhours = $grandtotalhours + $result->hours;
                 if (!empty($result->startdate)) {
-                    $format = get_string('strftimedate');
-                    if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
-                        $format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
-                    }
-                    $result->startdate = strftime($format, $result->startdate);
+                    $result->startdate = strftime(get_string('strftimedate'), $result->startdate);
                     if (!empty($result->enddate)) {
-                        $result->enddate = strftime($format, $result->enddate);
+                        $result->enddate = strftime(get_string('strftimedate'), $result->enddate);
                     }
                 }
             }
@@ -642,7 +639,7 @@ class ArtefactTypeActivity extends ArtefactType {
      */
     public static function build_activities_list_html(&$activities) {
         $smarty = smarty_core();
-        $smarty->assign_by_ref('activities', $activities);
+        $smarty->assign('activities', $activities);
         $activities['tablerows'] = $smarty->fetch('artefact:cpds:activitieslist.tpl');
         $pagination = build_pagination(array(
             'id'                      => 'activitylist_pagination',
@@ -668,8 +665,8 @@ class ArtefactTypeActivity extends ArtefactType {
     // @TODO: make blocktype use this too
     public static function render_activities(&$activities, $template, $options, $pagination) {
         $smarty = smarty_core();
-        $smarty->assign_by_ref('activities', $activities);
-        $smarty->assign_by_ref('options', $options);
+        $smarty->assign('activities', $activities);
+        $smarty->assign('options', $options);
         $activities['tablerows'] = $smarty->fetch($template);
 
         if ($activities['limit'] && $pagination) {
diff --git a/htdocs/artefact/cpds/new.php b/htdocs/artefact/cpds/new.php
index 39f551f..ad5b2be 100644
--- a/htdocs/artefact/cpds/new.php
+++ b/htdocs/artefact/cpds/new.php
@@ -46,7 +46,7 @@ else {
     $form = ArtefactTypeCPD::get_form();
 }
 
-$smarty =& smarty();
-$smarty->assign_by_ref('form', $form);
-$smarty->assign_by_ref('PAGEHEADING', hsc(TITLE));
+$smarty = smarty();
+$smarty->assign('form', $form);
+$smarty->assign('PAGEHEADING', hsc(TITLE));
 $smarty->display('artefact:cpds:new.tpl');
diff --git a/htdocs/artefact/cpds/theme/raw/cpdslist.tpl b/htdocs/artefact/cpds/theme/raw/cpdslist.tpl
index 586f4a1..85067f6 100644
--- a/htdocs/artefact/cpds/theme/raw/cpdslist.tpl
+++ b/htdocs/artefact/cpds/theme/raw/cpdslist.tpl
@@ -1,39 +1,38 @@
 <div class="list-group list-group-lite">
-    {foreach from=$cpds.data item=cpd}
-        <div class="list-group-item">
-            <div class="clearfix">
-                <h3 class="list-group-item-heading">
-                    <a href="{$WWWROOT}artefact/cpds/cpd.php?id={$cpd->id}">
-                        {$cpd->title}
+{foreach from=$cpds.data item=cpd}
+    <div class="list-group-item">
+        <div class="clearfix">
+            <h3 class="list-group-item-heading">
+                <a href="{$WWWROOT}artefact/cpds/cpd.php?id={$cpd->id}">
+                    {$cpd->title}
+                </a>
+            </h3>
+            <div class="list-group-item-controls">
+                <div class="btn-group btn-group-top">
+                     <a href="{$WWWROOT}artefact/cpds/edit/index.php?id={$cpd->id}" title="{str tag="edit"}" class="btn btn-default btn-sm">
+                        <span class="icon icon-lg icon-pencil" aria-hidden="true" role="presentation"></span>
+                        <span class="sr-only">{str tag=edit}</span>
+                    </a>
+                     <a href="{$WWWROOT}artefact/cpds/cpd.php?id={$cpd->id}" title="{str tag=manageactivities section=artefact.cpds}" class="btn btn-default btn-sm">
+                        <span class="icon icon-lg icon-cog" aria-hidden="true" role="presentation"></span>
+                        <span class="sr-only">{str tag=managetasks section=artefact.plans}</span>
+                    </a>
+                     <a href="{$WWWROOT}artefact/cpds/delete/index.php?id={$cpd->id}" title="{str tag="delete"}" class="btn btn-default btn-sm">
+                        <span class="icon icon-trash text-danger icon-lg" aria-hidden="true" role="presentation"></span>
+                        <span class="sr-only">{str tag=delete}</span>
                     </a>
-                </h3>
-                <div class="list-group-item-controls">
-                    <div class="btn-group btn-group-top">
-                        <a href="{$WWWROOT}artefact/cpds/edit/index.php?id={$cpd->id}" title="{str tag="edit"}" class="btn btn-default btn-sm">
-                            <span class="icon icon-lg icon-pencil" aria-hidden="true" role="presentation"></span>
-                            <span class="sr-only">{str tag=edit}</span>
-                        </a>
-                        <a href="{$WWWROOT}artefact/cpds/cpd.php?id={$cpd->id}" title="{str tag=manageactivities section=artefact.cpds}" class="btn btn-default btn-sm">
-                            <span class="icon icon-lg icon-cog" aria-hidden="true" role="presentation"></span>
-                            <span class="sr-only">{str tag=managetasks section=artefact.plans}</span>
-                        </a>
-                        <a href="{$WWWROOT}artefact/cpds/delete/index.php?id={$cpd->id}" title="{str tag="delete"}" class="btn btn-default btn-sm">
-                            <span class="icon icon-trash text-danger icon-lg" aria-hidden="true" role="presentation"></span>
-                            <span class="sr-only">{str tag=delete}</span>
-                        </a>
-                    </div>
                 </div>
             </div>
+        </div>
 
-            <p class="detail">
-                {$cpd->description}
-            </p>
-            {if $cpd->tags}
+        <p class="detail">
+            {$cpd->description}
+        </p>
+        {if $cpd->tags}
 
-                <div class="tags">
-                    <strong>{str tag=tags}:</strong> {list_tags tags=$cpd->tags owner=$cpd->owner}
-                </div>
-            {/if}
+        <div class="tags">
+            <strong>{str tag=tags}:</strong> {list_tags tags=$cpd->tags owner=$cpd->owner}
         </div>
-    {/foreach}
-</div>
\ No newline at end of file
+        {/if}
+    </div>
+{/foreach}
diff --git a/htdocs/artefact/cpds/theme/raw/index.tpl b/htdocs/artefact/cpds/theme/raw/index.tpl
index 59642e0..f613fd4 100644
--- a/htdocs/artefact/cpds/theme/raw/index.tpl
+++ b/htdocs/artefact/cpds/theme/raw/index.tpl
@@ -2,7 +2,7 @@
 <div class="btn-top-right btn-group btn-group-top">
     <a <a class="btn btn-default settings" href="{$WWWROOT}artefact/cpds/new.php?id={$cpd}">
         <span class="icon icon-lg icon-plus left"></span>
-        {str section="artefact.cpds" tag="newcpd"}
+        {str section="artefact.cpds" tag="newactivity"}
     </a>
 </div>
 <div id="cpdslist" class="view-container">
diff --git a/htdocs/artefact/cpds/theme/raw/viewcpd.tpl b/htdocs/artefact/cpds/theme/raw/viewcpd.tpl
index e5fc298..f3c9110 100644
--- a/htdocs/artefact/cpds/theme/raw/viewcpd.tpl
+++ b/htdocs/artefact/cpds/theme/raw/viewcpd.tpl
@@ -11,8 +11,8 @@
 </div>
 <div id="cpds_page_container" class="hidden">{$activities.pagination|safe}</div>
 <script>
-addLoadEvent(function() {literal}{{/literal}
+jQuery(function() {literal}{{/literal}
     {$activities.pagination_js|safe}
-    removeElementClass('cpds_page_container', 'hidden');
+    jQuery('#cpds_page_container').removeClass('hidden');
 {literal}}{/literal});
-</script>
\ No newline at end of file
+</script>

 

Kristina Hoeppner's profile picture
Posts: 4866

08 November 2018, 10:00

Hi Emma,

Robert pushed his changes to the Git repository for the plugin: https://github.com/geoffrowland/mahara-artefact_cpds

Cheers

Kristina

 

Patric Lougheed's profile picture
Posts: 97

08 November 2018, 10:23

I just tried the new commits in a clean install and received a 500 error after installing on extensions page which is now not accessible:

Declaration of PluginBlocktypeCpds::render_instance(BlockInstance $instance, $editing = false) must be compatible with IPluginBlocktype::render_instance(BlockInstance $instance, $editing = false, $versioning = false) in /var/www/mahara/htdocs/artefact/cpds/blocktype/cpds/lib.php on line 0

Patric Lougheed's profile picture
Posts: 97

08 November 2018, 10:58

Adding to line 59 of artefact/cpds/blocktype/cpds/lib.php

public static function render_instance(BlockInstance $instance, $editing=false, $versioning = false)

seems to fix it.

Kristina Hoeppner's profile picture
Posts: 4866

23 November 2018, 1:33

Hi Patric,

Thank you for testing and the tip with what needs to be removed to make it work in 18.04. The code uploaded actually already supported Mahara 18.10 where we introduced versioning. ;-)

Cheers

Kristina

 

Jawyei Wong's profile picture
Posts: 23

09 November 2018, 13:48

When we upgraded to 18.04 we got the error of:

 

Database version of Mahara plugin artefact/cpds 0.0.7 (2013122400) is newer than files version 0.0.5 (2013092000). Please make sure you have the correct Mahara plugin files in place.

 

We got the latest version that Robert pushed but still getting this error. This appears when trying to go into admin home. Any ideas to work around this?

Robert Lyon's profile picture
Posts: 774

12 November 2018, 8:32

Hi Jawyei,

It looks like at some point your site installed/upgraded a version CPD plugin that had $version value of 2013122400 and $release value of 0.0.7 but looking at my version and the parent fork of geoffrowland's ours are on version release 0.0.5

I wonder if there was custom changes for your version?

If you look in your version of artefact/cpds/db/upgrade.php is it different to https://github.com/geoffrowland/mahara-artefact_cpds/blob/master/artefact/cpds/db/upgrade.php ?

If there are no custom configurations/changes then it should be ok to reset the values in the database back to what the plugin has

 UPDATE artefact_installed SET release = '0.0.5', version = '2013092000' WHERE name = 'cpds';

Cheers

Robert

Jawyei Wong's profile picture
Posts: 23

22 January 2019, 14:46

Hi Robert

 

That did the trick. I honestly did not see the email for this reply and did not try it until now.

 

The other issue we have at the moment that I do not know where to start looking is the CPD 'tab' does not appear in the content area. The blocktype is fine but I cannot anywhere to add info into CPD. Any ideas of what to check?

 

Jawyei

Robert Lyon's profile picture
Posts: 774

22 January 2019, 18:13

Hi Jawyei

First thing to do is check the artefact/cpds/lib.php file and make sure the menu items array is set correctly for the Mahara version. If on 18.10 then it should look like this:

    public static function menu_items() {
        return array(
            array(
                'path'   => 'create/cpds',
                'title'  => get_string('cpds', 'artefact.cpds'),
                'url'    => 'artefact/cpds/index.php',
                'weight' => 40,
            ),
        );
    }

And all the instances of MENUITEM in the cpds plugin need updating, eg: define('MENUITEM', 'create/cpds');

If using 18.04 then the 'path' should be 'content/cpds'

Then you should go to Administration -> Overview and click the 'Clear caches' button

Cheers

Robert

 

11 results