Using code in a resource label

Using code in a resource label

by Stacy Clark -
Number of replies: 1

Is it possible to use PHP in a resource label?  I would like to be able to show display a user's name and show them what courses they have taken along with what is assigned to them. 

Ideally I would query the DB, then display this info.  Every time I try to save code throught the editor it disappears.  I also tried to hard code the PHP code into the mdl_label table and that didn't work either.

Any help would be appreciated.

Average of ratings: -
In reply to Stacy Clark

Re: Using code in a resource label

by Jan Dierckx -

PHP code inserted in label texts (even directly in the database) is never executed as this would pose some serious security threats.

A quick hack...

  • Copy the files of the courseformat you are using (in course/format) and create your own course format.

  • Add the code you would like to be included in course/format/yourformat/format.php

    I guess the bottom of section 0 could be a good place to display this kind of information. To do this look up

    echo '</td>';
    echo '<td class="right side">&nbsp;</td>';
    echo '</tr>';
    echo '<tr class="section separator"><td colspan="3" class="spacer"></td></tr>';
    

    and add your php code above these lines.