Forums | Mahara Community

Developers /
Mahara new feature


28 September 2011, 8:15 AM

Hi,

I started developping in mahara not long ago. I developed a blocktype that indicate a page as a evaluation. With this, I developed a tab wich the tutor can see a summary of all the homework he ask to be done and he can see who did it and when.
So I would just like to know if you guys were interested to see this code and may be add it to the source code of Mahara.

Thanks

Sorry for my english, my first language is french.

Melissa Newman's profile picture
Posts: 112

28 September 2011, 9:34 AM

I would be interested in seeing your code.  Thank you for offering to share it.

28 September 2011, 10:36 AM

Hi,

My code is not perfect and not well optimized, but it work.

You need to put this code in mahara/lib/group.php in the function group_get_menu_tabs, I put it after the members tab.

// If MEMBER = TUTEUR.    if (group_is_only_admin($group->id)){                  $menu['tableauBord'] = array(                'path' => 'groups/tableaubord',                'url' => 'group/tableaubord.php?id='.$group->id ,                'title' => get_string('suivievaluation', 'group'),                'weight' => 35);    }    ///////////***************///////////////

You need to add a files mahara/group/tableaubord.php with this code

<?php/** * Mahara: Electronic portfolio, weblog, resume builder and social networking * Copyright (C) 2006-2009 Catalyst IT Ltd and others; see: *                         http://wiki.mahara.org/Contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program.  If not, see <http://www.gnu.org/licenses/>. * * @package    mahara * @subpackage core * @author     Catalyst IT Ltd * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright  (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz * */
define('PUBLIC', 1);define('INTERNAL', 1);define('MENUITEM', 'groups/tableaubord');require(dirname(dirname(__FILE__)) . '/init.php');require_once('group.php');require_once('searchlib.php');require_once(get_config('docroot') . 'interaction/lib.php');
define('GROUP', param_integer('id'));//$groupid = param_integer('group');$membershiptype = param_variable('membershiptype', '');
$group = group_current_group();if (!is_logged_in() && !$group->public) {    throw new AccessDeniedException();}
define('TITLE', $group->name . ' - ' . 'Suivi d\'évaluation');
$role = group_user_access($group->id);
if (!empty($membershiptype) && $role != 'admin') {    throw new AccessDeniedException();}
$remove = param_variable('removeuser', null);$member = param_integer('member', null);if ($remove && $member) {    // Create the remove user pieform for the user that's being removed.    // The form's submit function will be called as soon as the form    // is generated.    //    // We do this now because the user could be on the 2nd page of    // results, so their remove form might never get generated on    // this page.  And also because generating the rest of the page    // would be a waste of time -- the submit function just redirects    // back here.    group_get_removeuser_form($member, $group->id);}
// Search related stuff for member pager$query  = trim(param_variable('query', ''));$offset = param_integer('offset', 0);$limit  = param_integer('limit', 10);
//Requête pour avoir la liste des travaux demander par le tuteur$sqlEvaluation = 'SELECT v.id idview, v.title titleView, bi.title titleBlock, v.stopdate dateRemise FROM block_instance bi                     left join view v on bi.view = v.id                    left join view_access va on v.id = va.view                    WHERE v.owner = ' . $USER->id . ' and                                     bi.blocktype = \'evaluation\' and                                     va.group = ' . $group->id . '                                    order by v.ctime';
$resultEvaluation = mysql_query($sqlEvaluation);
$html = '<h1>Suivi d\'évaluation(s)</h1>';
while ($rowEvaluation = mysql_fetch_array($resultEvaluation)){        $html .= listeEvaluation($rowEvaluation);        // Requête pour avoir la liste des élève du groupe    $sqlEleve = 'SELECT usr.id, usr.firstname, usr.lastname FROM group_member gm                LEFT JOIN usr on gm.member = usr.id                WHERE gm.role = \'member\' and gm.group = ' . $group->id;        $resultEleve = mysql_query($sqlEleve);
   // test() ;        while($rowEleve = mysql_fetch_array($resultEleve)){                      //Requête pour avoir la liste des travaux remis par les élèves.        $sqlEvaluationRemis = 'SELECT     v.submittedtime date,                                         v.id idview,                                         a.description comment,                                         a.author auteur,                                         c.deletedby commentdelete,                                        bi.title corriger                                FROM block_instance bi                                                     left join view v on bi.view = v.id                    left join artefact_comment_comment c on v.id = c.onview                    left join artefact a on c.artefact = a.id                                        WHERE v.owner = ' . $rowEleve['id'] . '                         and bi.blocktype = \'evaluation\'                         and (v.submittedgroup = ' . $group->id . ' or bi.title = \'Corriger\' )                         and lcase(replace(v.title, \' \', \'\')) like  \'%' . str_replace(" ","",strtolower($rowEvaluation['titleView'])) . '%\'                        and a.author <> ' . $rowEleve['id'] . '                        order by date asc, commentdelete asc, a.ctime desc';          //  var_dump($sqlEvaluationRemis);            $resultEvaluationRemis = mysql_query($sqlEvaluationRemis);          $rowEvaluationRemis = mysql_fetch_array($resultEvaluationRemis);         /*   $rowEvaluationRemis = null;            while($rowEvaluationRemisTMP = mysql_fetch_array($resultEvaluationRemis) )      {          if (($rowEvaluationRemisTMP[auteur] == $USER->id || $rowEvaluationRemisTMP[auteur] == null) && $resultEvaluationRemis != null)          {              $rowEvaluationRemis = $rowEvaluationRemisTMP;              var_dump($rowEvaluationRemisTMP[auteur]);          }      }     */                        $html .= listeEleve($rowEleve, $rowEvaluationRemis, $USER);          }    $html .= '</table> </br>';}$smarty = smarty(array('paginator'));
$smarty->assign('INLINEJAVASCRIPT', $js);$smarty->assign('heading', 'Suivi d\'évaluation du ' . $group->name);$smarty->assign('heading', $group->name);$smarty->assign('form', $searchform);$smarty->assign('results',$html);$smarty->assign('pagination', $pagination['html']);$smarty->assign('instructions', $instructions);$smarty->assign('membershiptype', $membershiptype);$smarty->display('group/tableaubord.tpl');$smarty->assign('heading',$group->name);
function search_submit(Pieform $form, $values) {    redirect('/group/members.php?id=' . $values['id'] . (!empty($values['query']) ? '&query=' . urlencode($values['query']) : '') . (!empty($values['membershiptype']) ? '&membershiptype=' . urlencode($values['membershiptype']) : ''));}
function listeEvaluation($rowEvaluation){    $html.= '<h2>'. '<a href="' . get_config('wwwroot') .  'view/view.php?id=' . $rowEvaluation[idview] . '">'. $rowEvaluation['titleView'] .'</a>';        if ($rowEvaluation[dateRemise])        $html .= '  (date de remise : '. substr($rowEvaluation[dateRemise],0,10) .')';                $html .= '</h2>';        $html .= ' <table border="1">
    <tr><td><h3>Élève(s)</h3></td><td><h3>Date remis</h3></td><td><h3>Commentaire</h3></td></tr>';        return $html;}
function listeEleve($rowEleve, $rowEvaluationRemis, $USER){    $html .= '<tr>';      // Élève      $html .= '<td>' . //'<img src="Bmw_Logor.jpg" alt="Big Boat" width="50" height="50" /><br />          '<a href="' . get_config('wwwroot') .  'user/view.php?id='. $rowEleve[id] .'">' . $rowEleve[firstname]. ' ' . $rowEleve[lastname] . '</a>' .             '</td>';      // Date remis      if ($rowEvaluationRemis[date] && !($rowEvaluationRemis[corriger] == 'Corriger')){      $html .= '<td>'.         '<a href="' . get_config('wwwroot') .  'view/view.php?id=' . $rowEvaluationRemis[idview] . '">'. substr($rowEvaluationRemis[date],0,10) .'</a>'.              '</td>';      }      else if ($rowEvaluationRemis[corriger] == 'Corriger'){          $html .= '<td>'.         '<a href="' . get_config('wwwroot') .  'view/view.php?id=' . $rowEvaluationRemis[idview] . '">Corrigé</a>'.              '</td>';      }       else{        $html .= '<td>Non remis</td>';      }      // Commentaire      $html .= '<td>';            if (!$rowEvaluationRemis[commentdelete] ){         $html .= '<a href="' . get_config('wwwroot') .  'view/view.php?id=' . $rowEvaluationRemis[idview] . '">' . trim(substr($rowEvaluationRemis[comment], 0,25), $charlist) . '</a>';      }
      $html .= '</td>';
      $html .= '</tr>';            return $html;}
function test() {    $sqlTEST = 'SELECT urltext test FROM notification_internal_activity where id = 17';        $resultTEST = mysql_query($sqlTEST);        while ($rowTEST = mysql_fetch_array($resultTEST))    {        var_dump($rowTEST[test]);    }}

 

In the files mahara/view/view.php you need to add the code in the function releaseview_submit() just after

global $USER, $SESSION, $view;    $groupid = $view->get('submittedgroup');    $view->release($USER); 

 

///// IF évalué, Indique que l'évaluation a été évalué par le tuteur. ////////////////    $sqlEvalue = 'update block_instance bi                                                     left join view v on bi.view = v.id                    set bi.title = \'Corriger\'                    WHERE v.id = ' . $view->get('id') . '                         and bi.blocktype = \'evaluation\' ';        $resultEvalue = mysql_query($sqlEvalue);        //////////////////////////////////////////////////////////////////////////////////////

There is some language files to modify to, but with this you will get the tab when you log in as tutor or admin and then you need to go in one of your group and the tab will be there.

To see an exemple you need to add a page with the blocktype I create and share the page with a group, the you will see.

The blocktype is pretty simple, there is nothing in, here the lib.php of the blocktype, the other files are not really important, they are like other one

<?php/** * Mahara: Electronic portfolio, weblog, resume builder and social networking * Copyright (C) 2006-2009 Catalyst IT Ltd and others; see: *                         http://wiki.mahara.org/Contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program.  If not, see <http://www.gnu.org/licenses/>. * * @package    mahara * @subpackage blocktype-evaluation * @author     Christian * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright  (C) 2011 Gregor Anzelj, gregor.anzelj@gmail.com * */
defined('INTERNAL') || die();
class PluginBlocktypeEvaluation extends SystemBlocktype {
    public static function single_only() {        return true;    }
    public static function get_title() {        return get_string('title', 'blocktype.evaluation');    }
    public static function get_description() {        return get_string('description', 'blocktype.evaluation');    }
    public static function get_categories() {        return array('general');    }    public static function get_viewtypes() {        return array('portfolio');    }
    public static function render_instance(BlockInstance $instance, $editing=false) {        return 'Cette page ne servira qu\'à l\'évaluation';    }       public static function has_instance_config() {        return false;    }
    public static function default_copy_type() {        return 'full';    }
}
?>

 

If you ave question or improvement you want to make i'll be please to received them. I'm sorry for the moment it's in french, I will translate it.

Thanks

Andrew Nicols's profile picture
Posts: 214

28 September 2011, 10:54 AM

Any chance you could make this available to download from somewhere? It doesn't place well with TinyMCE :(

Andrew Nicols's profile picture
Posts: 214

28 September 2011, 10:30 AM

Hi Christian,

That's great - it would be really good to see your plugin in action. Is it possible to download it from somewhere? The first step to getting your plugin included within Mahara would be to publish it on the wiki - https://wiki.mahara.org/index.php/Plugins and announce it in the forums. Before a new plugin is included, we ideally need to see that people are using it, and for it to be requested by the community. 

Are you familiar with Git? The easiest approach to having a plugin included in mahara core would be to submit it to the review system. There are details on how you can contributed code here: https://wiki.mahara.org/index.php/Developer_Area/Contributing_Code. It will also need to comply with the mahara coding guidelines (https://wiki.mahara.org/index.php/Developer_Area/Coding_guidelines). From Mahara 1.5 we'll also have unit testing so for extra brownie points, if you can write some unit tests for your plugin that would be appreciated (https://wiki.mahara.org/index.php/Developer_Area/Unit_Testing).

If you can find the time, you should try and make the developer meeting next Wednesday (https://wiki.mahara.org/index.php/Developer_Area/Developer_Meetings). If you can take an active part in the mahara community then that would probably make it easier in some respects to have your plugin included as you'll have more subject knowledge on the plugin and will (hopefully) be able to assist users with any issues relating to it.

Good luck!

Andrew

28 September 2011, 10:49 AM

Hi Andrew,

I will check everything you told me and give you feedback. I just want to say that I'm new to php so it's possible my code is not really clean and need some modification.

Christian

Andrew Nicols's profile picture
Posts: 214

28 September 2011, 10:53 AM

Hi Christian,

That's no problem - we'll try and help in any way that we can.

The coding guidelines are pretty strict, but that's actually quite helpful in many ways.

If you make the code available somewhere, we can try and provide peer review. I work full time, but I do try and make time for mahara community work so I'll try and reserve some time in the upcoming week to have a look at your code and give you some feedback.

Andrew

Melissa Newman's profile picture
Posts: 112

28 September 2011, 12:11 PM

If you would change LocalSettings.php in MediaWiki she would be able to place it in the files area there.  MediaWiki will not accept .zip files with specifically allowing it.  Or if you added the Code Highlighting extension in MediaWiki, she could place the code in a sub-page and it would be formatted very nicly including with color.

Okay, I admit it.  I like MediaWiki.  It was my top choice for my student portfolio project until I found Mahara.  It is a tough choice between the two technologies. They both have many positives.  Cool  I guess that is why I would like to see a Mahara plugin that could accept MediaWiki formatting and template inclusions.

Melissa

8 results