Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.9.4
-
Fix Version/s: None
-
Component/s: Module: Newmodule
-
Labels:None
-
Affected Branches:MOODLE_19_STABLE
Description
Meta bug for improvements which need to be made to newmodule template
Attachments
-
$i18n.getText("admin.common.words.hide")
- NEWMODULE_2009060400.zip
- 04/Jun/09 9:10 PM
- 19 kB
- Daniele Cordella
-
- NEWMODULE/db/install.xml 2 kB
- NEWMODULE/db/upgrade.php 5 kB
- NEWMODULE/getparams.php 2 kB
- NEWMODULE/icon.gif 0.1 kB
- NEWMODULE/index.php 3 kB
- NEWMODULE/lang/.../newmodule/index.html 0.3 kB
- NEWMODULE/lang/.../newmodule/mods.html 1 kB
- NEWMODULE/lang/en_utf8/newmodule.php 1 kB
- NEWMODULE/lib.php 7 kB
- NEWMODULE/locallib.php 0.2 kB
- NEWMODULE/mod_form.php 3 kB
- NEWMODULE/moveto.php 1 kB
- NEWMODULE/README.txt 3 kB
- NEWMODULE/tab1/page1.php 0.2 kB
- NEWMODULE/tab2/page1.php 0.2 kB
- NEWMODULE/tab2/page2.php 0.2 kB
- NEWMODULE/tab2/page3.php 0.2 kB
- NEWMODULE/tab2/page4.php 0.2 kB
- NEWMODULE/tab2/page5.php 0.2 kB
- NEWMODULE/tab3/page1.php 0.2 kB
- NEWMODULE/tab3/page2.php 0.2 kB
- NEWMODULE/tabs.php 3 kB
- NEWMODULE/version.php 0.5 kB
- NEWMODULE/view.php 3 kB
$i18n.getText("admin.common.words.show")- NEWMODULE_2009060400.zip
- 04/Jun/09 9:10 PM
- 19 kB
- Daniele Cordella
Issue Links
| This issue is duplicated by: | ||||
| CONTRIB-52 | Improvements to make NEWMODULE really useful |
|
|
|
| This issue has a non-specific relationship to: | ||||
| CONTRIB-1385 | META: NEWMODULE 2.0 |
|
|
|
Activity
Also, some days ago I put 19_STABLE and HEAD in sync, copying some missing bits here and there and cleaning whitespace to have both ready for any improvement. I think those are the branches we should try to improve.
Finally, here there are some notes I had in my TODO about NEWMODULE. Perhaps it would be a good idea to convert them into subtasks:
- NEWMODULE: Add official credits
- NEWMODULE: Add savepoints on upgrade
- NEWMODULE: Add capabilities
- NEWMODULE: Add users + files + grades
- NEWMODULE: Add backup & restore
- NEWMODULE: Add 2.0 stuff (files, DB, install/upgrade...)
- NEWMODULE: Add official credits
- NEWMODULE: Add savepoints on upgrade
- NEWMODULE: Add capabilities
- NEWMODULE: Add users + files + grades
- NEWMODULE: Add backup & restore
- NEWMODULE: Add 2.0 stuff (files, DB, install/upgrade...)
I just merged my recent fixes from 1.9 to HEAD. They include:
- use nested dirname() instead of "../../" in require_once() paths
- use get_coursemodule_from_id() instead of plain get_record() [security issue]
- require_login() - provide the whole $course object if available [performance]
- do not indent the main program level of source code
+ some small details
- use nested dirname() instead of "../../" in require_once() paths
- use get_coursemodule_from_id() instead of plain get_record() [security issue]
- require_login() - provide the whole $course object if available [performance]
- do not indent the main program level of source code + some small details
Not sure if this is the correct place to put this, but according to netbeans, on line 52 of view.php in newmodule, there is a syntax error.
$strwidget = get_string('modulename', "widget');
The double quote in front of widget should be a single quote.
Thanks!
Chris
Chris - Yep, this looked like something that slipped past David. I've gone ahead and committed the fix. Thanks for reporting it. Peace - Anthony
Ciao moodlers.
Yesterday, playing with reports, I arrived to the "Activity report" and I got an error message pointing to the returned value of the function NEWMODULE/lib.php::function newmodule_user_outline
Actually I found that, in the NEWNMODULE layout provided in http://download.moodle.org/plugins/mod/NEWMODULE.zip,
the declared function (row 98 of lib.php) closes with:
return $return;
and the variable $return is not defined... fine!!!
What is getting me crazy is why I can't reproduce the bug any more.
Hoping this can help you, David, to drop off this silly bug.
Daniele,
thanks for the spot. I have added the variable initialization.
Ciao David,
it seems that the function
/**
- Tells if files in moddata are trusted and can be served without XSS protection.
- @return bool true if file can be served to all users (trusted), false otherwise
*/
function newmodule_is_moddata_trusted() {
return false;
}
is missing from newmodule/lib.php.
- Tells if files in moddata are trusted and can be served without XSS protection.
- @return bool true if file can be served to all users (trusted), false otherwise */ function newmodule_is_moddata_trusted() { return false; }
Hey Daniele,
the function is not in the template. However, it is not required by the core. The file.php checks if this function exists. IMO we should try to keep NEWMODULE as simple as possible and not to overload beginners with a lot of interface functions. So my proposal is to stay with the required module API only. If a developer wants her module to play with files and content security nicely, she should read file.php anyway so she will spot the existence of the function (like you did I suppose
)
I am going to ask Martin D and others at HQ for their opinion
Thanks David for your reply.
I hope to find the time to share here my "empty" model/layout of newmodule before your chat with HQ.
IMO it is a good starting point for every newmodule and I use it with success. ![]()
Ciao.
Hi,
first of all, thanks for any effort improving NEWMODULE!
then, one silly question: Are you keeping both 19_STABLE and HEAD improved or only HEAD ?
Ciao ![]()
This is the result of the HQ chat: all optional functions will be at the end of lib.php after a clear comment line
/**
- Following stuff are OPTIONAL functions that may be enabled depending of your module needs
*/
Eloy: so far, we are trying to maintain both 19 and HEAD. Although I am focusing on HEAD mainly.
- Following stuff are OPTIONAL functions that may be enabled depending of your module needs */
> Eloy: so far, we are trying to maintain both 19 and HEAD. Although I am focusing on HEAD mainly.
Yes, this seems to be a problem. I just downloaded the last NEWMODULE.zip from
http://download.moodle.org/plugins/mod/NEWMODULE.zip
but I found:
$this->add_intro_editor(false, get_string('introduction', 'newmodule'));
in mod_form.php
but this function is still not defined in Moodle 1.9
We should provide two different links to download NEWMODULE.zip maybe in this thread.
Where is the NEWMODULE.zip for Moodle 1.9 now?
[Gosh!!! I am starting to write "We should provide..." instead of "It should be provided..."... is this dangerous? :-)]
ok. This is the "empty layout" I use for my personal use.
Let me fire a suggestion:
1. please, try and review it
2. when it is optimized, I offer my contribution to add to this "empty layout":
-> a simple mform to post data
-> a simple flexible_table with posted data
-> a simple capability to distinguish between users
-> the creation of a PDF with posted data
-> logs
eventually:
-> score
-> backup
-> restore
never:
-> groups
Please take care because I used NEWMODULE and newmodule.
If you want to test my newmodule.zip, take care to be case sensitive at the find and replace time.
I ONLY WORK FOR MOODLE 1.9
I KNOW NOTHING ABOUT HEAD
Please let me know.
Ciao.
I decided to create CONTRIB-1385 to track modifications of NEWMODULE needed for Moodle 2.0. This issue will remain here to track improvements done at 1.9 branch.
Ciao David and congratulation for http://moodle.org/blog/index.php?postid=5430
After a discussion with Petr I found... in the just downloaded NEWMODULE package, in the file index.php
foreach ($newmodules as $newmodule) {
if (!$newmodule->visible) {
//Show dimmed if the mod is hidden
$link = "<a class=\"dimmed\" href=\"view.php?id=$newmodule->coursemodule\">$newmodule->name</a>";
} else {
//Show normal if the mod is visible
$link = "<a href=\"view.php?id=$newmodule->coursemodule\">$newmodule->name</a>";
}
where:
$link = "<a class=\"dimmed\" href=\"view.php?id=$newmodule->coursemodule\">$newmodule->name</a>"
should be:
$link = "<a class=\"dimmed\" href=\"view.php?id=$newmodule->coursemodule\">format_string($newmodule->name)</a>"
and
$link = "<a href=\"view.php?id=$newmodule->coursemodule\">$newmodule->name</a>";
should be:
$link = "<a href=\"view.php?id=$newmodule->coursemodule\">format_string($newmodule->name)</a>";
otherwise multilang will be breaked.
Do you agree?
Ciao Daniele, and thanks for spotting this. I just committed your fix into CVS.
Thanks David.
I also found that the set of three functions: newmodule_reset_course_form_definition, workshop_reset_course_form_defaults and workshop_reset_userdata described below, are still missing.
/**
- Called by course/reset.php
- @param $mform form passed by reference
*/
function newmodule_reset_course_form_definition(&$mform) {
$mform->addElement('header', ' newmoduleheader', get_string('modulenameplural', 'newmodule'));
$mform->addElement('checkbox', 'reset_newmodule_all', get_string('resetnewmoduleall','newmodule'));
}
/**
- Course reset form defaults.
*/
function workshop_reset_course_form_defaults($course) {
return array('reset_newmodule_all'=>1);
}
/**
- This function is used by the reset_course_userdata function in moodlelib.
- This function will remove all issued certificates from the specified course
- @param $data the data submitted from the reset course.
- @return array status array
*/
function workshop_reset_userdata($data) {
global $CFG;
$componentstr = get_string('modulenameplural', 'newmodule');
$typesstr = get_string('resetcertificateall', 'newmodule');
$status = array()
if (!empty($data->reset_newmodule_all)) {
// purge tables and moodledata if needed
$status[] = array('component'=>$componentstr, 'item'=>$typesstr, 'error'=>false);
}
return $status;
}
- Called by course/reset.php
- @param $mform form passed by reference */ function newmodule_reset_course_form_definition(&$mform) {
- Course reset form defaults. */ function workshop_reset_course_form_defaults($course) { return array('reset_newmodule_all'=>1); }
- This function is used by the reset_course_userdata function in moodlelib.
- This function will remove all issued certificates from the specified course
- @param $data the data submitted from the reset course.
- @return array status array */ function workshop_reset_userdata($data) { global $CFG;
again David,
in mod_form.php
it is written:
//-------------------------------------------------------------------------------
// add standard elements, common to all modules
$this->standard_coursemodule_elements();
instead of the more complete:
//-------------------------------------------------------------------------------
// add standard elements, common to all modules
$features = new object();
$features->groups = false;
$features->groupings = false;
$features->groupmembersonly = true;
$this->standard_coursemodule_elements($features);
Ciao David (or Dan, maybe).
In the view.php of the NEWMODULE.ZIP it is missing the following snippet of code to prevent direct access to hidden resources.
/// If it's hidden then it doesn't show anything. ![]()
if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) {
notice(get_string("activityiscurrentlyhidden"));
exit;
}
Two seconds time issue! ![]()
Hi Daniele,
no, this sort of checking is done by require_login() once it is provided $cm object.
d.
Available in
http://moodle.org/mod/forum/discuss.php?d=148581
a tool to look for useless strings during newmodule development.
the function "error" should be replaced with "print_error" even in NEW_MODULE for moodle 1.9
as written in moodle19/lib/weblib.php in the comments of the print_error function
Ciao Dan.
I just found that...
in the just downloaded version of NEWMODULE for 1.9, the variable $return is not defined in lib.php at line 98
Ciao.
Daniele, this is not actually a bug. Note that NEWMODULE is a scaffold and is not expected to work as-is. The developer should implement the function returning the requested object.
you are 50% right, David.
I may agree with you but, please, let me say that NEWMODULE has to default to a reasonable value, too.
I'm unassigning this from me, and giving it to 'Nobody' - because i've done such a terrible job of doing it & it'd be clearer if someone else knew they should pick it up.
Sorry everyone..
JFTR
The code is also available at https://github.com/moodlehq/moodle-mod_newmodule
@Dan: there is definitely no need to apologize for anything! You did what you had time for - thanks a lot for that!
@Frank: yes, that git repo is actually considered the primary source of the module now. I expect the CVS version would die sometime (the sooner, the better)
Yes, I am proposing that CVS could be disabled when support for Moodle 1.9 ends. I have been encouraging folks writing CONTRIB code for Moodle 2.0 to use some type of repository - preferably Git. Thanks Dan for all you have been able to do. I'll see if anyone at HQ might be interested in picking up maintaining NEWMODULE. Peace - Anthony
I am re-assigning to see if anyone at HQ is interested in helping to keep NEWMODULE updated. Peace - Anthony
Anthony: I can continue with occasional updating newmodule, please feel free to set me as the component lead.
Thanks David! That is very generous of you. Michael de Raadt is also interested in helping out some as well - looks like I mistakenly assigned it to him. I'll let you guys thumb wrestle for issues or at least tag team on them. Peace - Anthony
I've closed
CONTRIB-52(the original NEWMODULE contrib bug) in benefit of this. CiaoCONTRIB-52(the original NEWMODULE contrib bug) in benefit of this. Ciao