Non-core contributed modules

Course dedication block: to see the dedication estimated time to a Moodle course

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.6, 1.9
  • Fix Version/s: None
  • Component/s: Block: Dedication
  • Labels:
    None
  • Affected Branches:
    MOODLE_16_STABLE, MOODLE_19_STABLE

Description

This block allows to see the dedication estimated time to a Moodle course by the participants of the course.

Session: set of two or more consecutive clicks in which the elapsed time between every pair of consecutive clicks does not overcome an established maximum time.

Session duration: elapsed time between the first and the last click of the session

With this block there can be obtained the total dedication (sum of the duration of every session) of all the participants of the course and the detailed dedication of a participant (duration of each one of his sessions). The total dedication can be downloaded in excel format. The block cannot be used in the site page, only in courses pages.

In Moodle 1.6 version only administrators can use the block.

In Moodle 1.9 version the capability To see course dedication is added and by default only administrator role has this capability allowed. Besides, in Moodle 1.9 the course participants will be those users in a role (different to administrator and course creator) in the course context that allows them to see the course.

All texts in English, EspaƱol-Internacional (es) and Portugues-Brasil (pt_br)

Activity

Hide
Anthony Borrow added a comment -

Borja,

Thanks for sharing the code. I am in the process of reviewing/testing it. The first thing I found was the following PHP notice.

Notice: Undefined property: stdClass::$pinned in /home/arborrow/Moodle/code/19stable/blocks/dedication/block_dedication.php on line 50

To catch these, I turn debugging mode on and set it to show All reasonable errors (not developer mode). I'll continue to comment as I find others. Generally speaking it is important to check the a variable is set or defined before using it. I find it helpful to initialize variables especially if they are optional params. Let me know if you have questions or need help fixing it. I would probably add the following line around line 14:

$this->instance->pinned = 0; //initialize to zero if not already defined

since you have already checked if it was empty and then set the context, I would then initialize it to zero so that when you use it later you do not get the PHP notice.

Once I did that, I clicked on calculate and received the following PHP Warning:

Warning: Invalid argument supplied for foreach() in /home/arborrow/Moodle/code/19stable/blocks/dedication/dedication.php on line 353

Again, this is likely due to not checking for the existence of something before using it in a foreach statement.

I would replace that foreach with something like:

if (!empty($students)) { //if there are no students then there is no need to print them, you could also add an else statement here and output that there are no student enrolled
foreach ($students as $student) { $name = "<a href='$baseurl&userid=".$student->id."'>".$student->lastname.', '.$student->firstname.'</a>'; $table->data[] = array ($name); }
}

Other warnings I found were:

Warning: Invalid argument supplied for foreach() in /home/arborrow/Moodle/code/19stable/blocks/dedication/dedication.php on line 228
Warning: array_shift() [function.array-shift]: The argument should be an array in /home/arborrow/Moodle/code/19stable/blocks/dedication/dedication.php on line 118
Notice: Trying to get property of non-object in /home/arborrow/Moodle/code/19stable/blocks/dedication/dedication.php on line 119
Warning: Invalid argument supplied for foreach() in /home/arborrow/Moodle/code/19stable/blocks/dedication/dedication.php on line 125

All that said, I see nothing preventing the code from being added to CVS. I will create a component in the tracker called Block: Dedication. I will bump your privileges in the tracker so that you can manage issues assigned to you. Any bugs, feature requests, etc. created for the Block: Dedication component in the CONTRIB section of the tracker will automatically be assigned to you. An email will be sent to you letting you know of the issue which helps keep you informed. The next thing to do (if you have not already) is to go to http://moodle.org/cvs/ and request CVS write access for contrib/plugins/blocks/dedication. If you could, comment here that you have done so and I will make sure to go in and approve that request. Once you have CVS write access you can test it by doing some of the above fixes. Generally speaking, I recommend having a tracker issue for any changes you make to your code as it helps with documentation. When you make a commit, there is an opportunity to add a comment describing what that commit is for. I recommend beginning the commit with the tracker issue number. For example, when I add the code to CVS you will see that I begin it with CONTRIB-982. As a result, when I look at this issue I'll be able to see the files that were changed related to this commit. Finally, I would encourage you to review http://docs.moodle.org/en/Development:Guidelines_for_contributed_code and follow the instructions (again, if you have not already done so) to add an entry in the Moodle.org Modules and Plugins database, create a documentation page for the Dedication block, etc. I realize that there are several steps and it can seem like a lot to learn from the beginning but attention to detail especially at the beginning really can make a big difference in helping to ensure that your code is well supported and shared with the community so that they have a positive initial experience with it. Do not hesitate to let me know if you have any questions or need help with these steps as that is part of my role as CONTRIB Coordinator. Thanks again for sharing your time and talent with the community.

Peace - Anthony

p.s. - I noticed there was a 1.6 version; however, I am not going to add that at this time. Most folks are on either 1.8 and 1.9. However, if you want me to add it just let me know and we can create a MOODLE_16_STABLE branch for this block. With CONTRIB code, I usually consider HEAD to be the development version and we start with that. If you find that it would be helpful to also have a 1.9 branch just let me know.

Show
Anthony Borrow added a comment - Borja, Thanks for sharing the code. I am in the process of reviewing/testing it. The first thing I found was the following PHP notice. Notice: Undefined property: stdClass::$pinned in /home/arborrow/Moodle/code/19stable/blocks/dedication/block_dedication.php on line 50 To catch these, I turn debugging mode on and set it to show All reasonable errors (not developer mode). I'll continue to comment as I find others. Generally speaking it is important to check the a variable is set or defined before using it. I find it helpful to initialize variables especially if they are optional params. Let me know if you have questions or need help fixing it. I would probably add the following line around line 14: $this->instance->pinned = 0; //initialize to zero if not already defined since you have already checked if it was empty and then set the context, I would then initialize it to zero so that when you use it later you do not get the PHP notice. Once I did that, I clicked on calculate and received the following PHP Warning: Warning: Invalid argument supplied for foreach() in /home/arborrow/Moodle/code/19stable/blocks/dedication/dedication.php on line 353 Again, this is likely due to not checking for the existence of something before using it in a foreach statement. I would replace that foreach with something like: if (!empty($students)) { //if there are no students then there is no need to print them, you could also add an else statement here and output that there are no student enrolled foreach ($students as $student) { $name = "<a href='$baseurl&userid=".$student->id."'>".$student->lastname.', '.$student->firstname.'</a>'; $table->data[] = array ($name); } } Other warnings I found were: Warning: Invalid argument supplied for foreach() in /home/arborrow/Moodle/code/19stable/blocks/dedication/dedication.php on line 228 Warning: array_shift() [function.array-shift]: The argument should be an array in /home/arborrow/Moodle/code/19stable/blocks/dedication/dedication.php on line 118 Notice: Trying to get property of non-object in /home/arborrow/Moodle/code/19stable/blocks/dedication/dedication.php on line 119 Warning: Invalid argument supplied for foreach() in /home/arborrow/Moodle/code/19stable/blocks/dedication/dedication.php on line 125 All that said, I see nothing preventing the code from being added to CVS. I will create a component in the tracker called Block: Dedication. I will bump your privileges in the tracker so that you can manage issues assigned to you. Any bugs, feature requests, etc. created for the Block: Dedication component in the CONTRIB section of the tracker will automatically be assigned to you. An email will be sent to you letting you know of the issue which helps keep you informed. The next thing to do (if you have not already) is to go to http://moodle.org/cvs/ and request CVS write access for contrib/plugins/blocks/dedication. If you could, comment here that you have done so and I will make sure to go in and approve that request. Once you have CVS write access you can test it by doing some of the above fixes. Generally speaking, I recommend having a tracker issue for any changes you make to your code as it helps with documentation. When you make a commit, there is an opportunity to add a comment describing what that commit is for. I recommend beginning the commit with the tracker issue number. For example, when I add the code to CVS you will see that I begin it with CONTRIB-982. As a result, when I look at this issue I'll be able to see the files that were changed related to this commit. Finally, I would encourage you to review http://docs.moodle.org/en/Development:Guidelines_for_contributed_code and follow the instructions (again, if you have not already done so) to add an entry in the Moodle.org Modules and Plugins database, create a documentation page for the Dedication block, etc. I realize that there are several steps and it can seem like a lot to learn from the beginning but attention to detail especially at the beginning really can make a big difference in helping to ensure that your code is well supported and shared with the community so that they have a positive initial experience with it. Do not hesitate to let me know if you have any questions or need help with these steps as that is part of my role as CONTRIB Coordinator. Thanks again for sharing your time and talent with the community. Peace - Anthony p.s. - I noticed there was a 1.6 version; however, I am not going to add that at this time. Most folks are on either 1.8 and 1.9. However, if you want me to add it just let me know and we can create a MOODLE_16_STABLE branch for this block. With CONTRIB code, I usually consider HEAD to be the development version and we start with that. If you find that it would be helpful to also have a 1.9 branch just let me know.
Hide
Anthony Borrow added a comment -

moving to Block: Dedication

Show
Anthony Borrow added a comment - moving to Block: Dedication
Hide
Anthony Borrow added a comment -

Resolving as fixed, code added to CVS, tracker privileges bumped, component created. Just waiting for Borja to apply for CVS write access.

Show
Anthony Borrow added a comment - Resolving as fixed, code added to CVS, tracker privileges bumped, component created. Just waiting for Borja to apply for CVS write access.
Hide
Borja Rubio Reyes added a comment -

Hi Anthony,

I have just request CVS write access for contrib/plugins/blocks/dedication. I have just fixed all the warnings in version 1.9 of the block too. I will apply the changes to CVS when I have write access.

I have no problem with to have only version 1.9 of the block in CVS.

Thank you very much and regards.

Show
Borja Rubio Reyes added a comment - Hi Anthony, I have just request CVS write access for contrib/plugins/blocks/dedication. I have just fixed all the warnings in version 1.9 of the block too. I will apply the changes to CVS when I have write access. I have no problem with to have only version 1.9 of the block in CVS. Thank you very much and regards.
Hide
Anthony Borrow added a comment -

Thanks Borja - I have approved the CVS write request so you should be good to go. Let me know if you need anything else. Peace - Anthony

Show
Anthony Borrow added a comment - Thanks Borja - I have approved the CVS write request so you should be good to go. Let me know if you need anything else. Peace - Anthony
Hide
Anthony Borrow added a comment -

Borja - Rather than Moodle messages, let's use the tracker to communicate about these issues. Have you been able to apply the suggested changes? Let me know if you have any troubles. Peace - Anthony

Show
Anthony Borrow added a comment - Borja - Rather than Moodle messages, let's use the tracker to communicate about these issues. Have you been able to apply the suggested changes? Let me know if you have any troubles. Peace - Anthony
Hide
Borja Rubio Reyes added a comment -

Hi Anthony,

I made a commit of block_dedication.php and dedication.php files with comment "Fixed all notices and warnings" (I forgot to add CONTRIB-982 text at the beginning of the comment).

It is my first time so i would like to know if everything is ok.

Regards.

Show
Borja Rubio Reyes added a comment - Hi Anthony, I made a commit of block_dedication.php and dedication.php files with comment "Fixed all notices and warnings" (I forgot to add CONTRIB-982 text at the beginning of the comment). It is my first time so i would like to know if everything is ok. Regards.
Hide
Anthony Borrow added a comment -

Borja - I do not have the opportunity at the moment to actually test the code but just giving the commit a quick review all looked fine. Keep up the fine work. Peace - Anthony

Show
Anthony Borrow added a comment - Borja - I do not have the opportunity at the moment to actually test the code but just giving the commit a quick review all looked fine. Keep up the fine work. Peace - Anthony
Hide
Anthony Borrow added a comment -

Closing all of my resolved issues. Peace - Anthony

Show
Anthony Borrow added a comment - Closing all of my resolved issues. Peace - Anthony

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: