Project page: https://www.drupal.org/sandbox/webservant316/2808195
Git: git clone --branch 7.x-1.x https://git.drupal.org/sandbox/webservant316/2808195.git course_admin
webservant316 Drupal participation: https://www.drupal.org/user/586896/track
Extension to the 'course' module. Development prototype! Export, Import, Outline, and Delete Entire Courses. The module works in my use case, but please test and use at your own risk.
INTALLATION:
1. The module introduces NO database structure changes.
2. Drupal, 'Course', and other APIs are used to create Course Objects and Content.
3. The module is general purpose and works with many Content TYPES.
4. Enable 'Course Admin' at /admin/modules
5. Configure permissions at /admin/people/permissions#module-course
6. Execute functions at /admin/course/import and /node/COURSE-NID/admin
EXPORT:
Export a ZIP Course Archive for archival or transfer to another LMS. Allows Course Authors and LMS Admins to Export / Import individual courses. The structure of all related Course Content and Field TYPES must remain identical between the Course Export and Import function. Note that only files and images referenced as fields are exported. Files and images referenced within body text are not exported. For example images or files accessed through IMCE are not exported.
IMPORT:
Import a ZIP Course Archive previously exported from Course Admin Export. Allows Course Authors and LMS Admins to Export / Import individual courses.
OUTLINE:
Import a TAB delimited Course Outline with Content TYPE, TITLE, and optional BODY. Helps Course designers create Outlines more easily with tools outside of Drupal. This feature allows Course Designers to 'stub out' an entire course and then visit each Course Page to add their content, text, and fields.
DELETE:
Delete the entire Course, Course Outline, and Course Content. Optionally do not delete course Book and Quiz Content.
REFLECTIONS:
The 'course_admin' module prototype has proved that these functions are possible. This module has also shown that there is much work to do to move modules toward unified Entity handling and APIs. For example Course Export and Import functions would be more easily handled if all node TYPES could be simply copied...
$node = node_load($nid);
$node->nid = 0;
$node->is_new = TRUE;
node_save($node);However, more complicated nodes TYPES are not prepared for this simplicity. The node_clone() module is used to help properly populate the node for export. So 'webform' node TYPES worked great with this method. However, other node TYPES such as H5P and Quiz Scale nodes need custom consideration.
This patch is needed for Quiz Scale nodes, https://www.drupal.org/node/2802605.
This code was needed to add quiz questions, https://www.drupal.org/node/1892278.
This issue questions about H5P cloning, https://www.drupal.org/node/2799581.
Also 'node_clone' effectively clones nodes while relying on the immediate presence of all node resources such as files and images. However, these resources are not encapsualted into the $node object itself. So extra work
is needed to consider these external resources as well. This is also true for any resource that is only attached to the $node by reference such as entity_references, field_collections, and IMCE links in node body text. The list of complications is so large it is a good question whether such an effort really has a future. I only pressed this far toward a solution because my company and use case required it. I handled the external resources for the content types in my use case by first loading the $node, then assigning my own $node->eternal_resource_variable(s) loaded with the external resources. The $node is then serialized and exported. Upon import the $node is then unserialized and the $node->external_resource_variable(s) is unpacked and saved with the new $node via custom code. In the case of H5P nodes I create an entire Zip Archive of /h5p/content/nid and store it on the $node. It works great, but there is no standard API to handle this complicated process.
Any future for this module should consider modules like 'entity', 'entity_clone', and 'entity_relationship'. Future versions of Drupal will also likely tighten the Entity API to make entity exporting easier, hopefully including all the $node resources. The $node could then be easily imported as a new entity or a revision of the original. Even if there is a future with Drupal Entities, contributed modules may or may not participate voluntarily. Of course future versions of Drupal could force participation through a more restrictive API. But will the Entity API handle all the needs of more complicated Entities such as H5P nodes? Also how will the Entity API handle referenced resources that are too large for easy export and import? For example a $node could reference very large files.
Hopefully this prototype helps Drupal visionaries to understand the need and craft better solutions for the future.
Comments
Comment #2
PA robot commentedWe are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #3
visabhishek commentedAutomated Review
Please fix errors reported on http://pareview.sh/pareview/httpsgitdrupalorgsandboxwebservant3162808195git
Manual Review
ex : course_admin_delete(arg(1))course_admin_export(arg(1),$form_state['values']['export_print'],$form_state['values']['export_debug'])Ex :
variable_get('book_made_simple_forbid_main_page_creation','')The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
Comment #4
klausi@visabhishek: user input should only be sanitized for XSS when it is printed to HTML. So using arg() directly is fine, sanitization should only happen if the value is later printed to HTML.
Comment #5
visabhishek commented@klausi : Thanks, I will take care in next projects.
Comment #6
webservant316 commentedThanks for the comments. I hope to update the module and post back.
Comment #7
PA robot commentedClosing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #8
webservant316 commentedOkay still interested, but busy on another project. I'll get back in time.
Comment #9
webservant316 commentedRe-opening request to move this project out of the sandbox.
1. README.txt format fixed to Drupal standards.
2. Secure code issues, use of arg(1) NOT an issue as explained in comments above.
3. inc files used as requested.
4. code format fixed to Drupal standards with grammar_parser.
5. This module creates NO variable data, but only references variables from other modules.
One last thing. Notes above say that I am not following guidelines for master branch.
Could I get some help on the last point. What do I need to do? I am using TortoiseGIT.
Comment #10
webservant316 commentedHey I need help with properly setting the master branch of my project. I am using TortoiseGit on Windows. so what do I need to do?
Comment #11
webservant316 commentedOkay the repository is fixed as well as all the code issues listed. Please review again. Thanks!
Comment #12
webservant316 commentedPosting back after a week, still hoping for a review.
Comment #13
webservant316 commentedokay still hoping for a review. please.
Comment #14
webservant316 commentedFurther improvement of code comments to Drupal standards committed.
Comment #15
Drupal8 commentedHi you should solve the issue reported https://pareview.sh/node/1349
This is better to use Drupal PDO.
Comment #16
klausi@Drupal8: looks like you forgot to change the status. Using placeholders with db_query() is mandatory for security reasons before this can be approved.
Comment #17
webservant316 commentedThanks for this catch.
Placeholders are now used with all usage of db_query().
Comment #18
webservant316 commentedComment #19
webservant316 commented@cigotete reports
Thank you, that is fixed.
Comment #20
webservant316 commentedFurther cross-site scripting prevention implement and committed. Do not call t() with variables unless sanitized by filter_xss().
Comment #21
Cyclonecode commentedAutomated review
Pareview reports alot of warnings that you should consider fixing: https://pareview.sh/node/1349
Manual review
Individual user account
Yes: Follows
No duplication
Yes: Does not cause
Master Branch
Yes: Follows
Licensing
Yes: Follows
3rd party assets/code
Yes: Follows
README.txt/README.md
Yes: Follows
Code long/complex enough for review
Yes: Follows
Secure code
Yes: Follows
Coding style & Drupal API usage
(*) Major finding, needs work
(+) Release blocker
Rekommendations:
1. You might consider using drupals string functions instead of strtolower, strlen and so, since the drupal versions adds multibyte support.
2. I would keep any global and static variables used at the top of each function.
3. Consider using
drupal_dirname()overdirname().4. You should really spend some time adding useful comments to your functions.
5. Not really sure why you implemented your own function to check if a module exists i.e
_course_admin_module_exists? Why not simply usemodule_exists()?6. I would add an install file and remove any variables created by the module in a
course_admin_uninstall()hook.This review uses the Project Application Review Template.
Comment #22
webservant316 commentedThanks! I will make these fixes.
Comment #23
Aaron23 commentedHi ,
the pa review runs your old code for course module i,e, Git: git clone --branch 7.x-1.x https://git.drupal.org/sandbox/webservant316/2808195.git course_admin
Can you change that to latest version control. so that we can make coding standard and reduce errors and warnings
Thanks
Comment #24
webservant316 commentedok how do I fix that?
Comment #25
Cyclonecode commented@Aaron23 - You are saying that PA review runs the old code? I'm not really sure what you mean with this statement. The PA review runs on the branch 7.x-1.x and which should be the development branch for this module?
Comment #26
Aaron23 commentedCan you check this link https://pareview.sh/node/2532 I ran this git url " https://git.drupal.org/project/course.git "
Thanks,
Aaron23
Comment #27
webservant316 commentedthis is project/course_admin, NOT project/course
Comment #28
Aaron23 commentedOops a big sorry for the confusion. Yes its course_admin.
https://pareview.sh/node/2295 Please check this and fix all the bugs
Thanks,
Aaron
Comment #29
Aaron23 commentedI'm Unable to install this module
I enabled course 7.x-1.11
When I try to install course_admin module.
Sub modules missing. It says,
Clone (missing)
Thanks
aaron23
Comment #30
webservant316 commentedokay will do, thanks.
Comment #31
webservant316 commentednode_clone is a dependency. The dependency has to be specified as 'clone' even though the dependent module is named 'node_clone'. This is because the node_clone module is mis-named as clone.module. I will improve the readme to make that clear.
Comment #32
webservant316 commentedPer #28 and @Aaron23 all the warnings and errors have been removed as referenced at https://pareview.sh/pareview/https-git.drupal.org-sandbox-webservant316-.... There is one warning remaining saying that test scripts would be useful, but not required. Those may be added later.
Hoping that this project can be moved out of the sandbox and it is working wonderfully in production in my use case. Please check the module documentation for further insights into the value of this project.
Comment #33
webservant316 commentedAny help with this? All noted problems have been fixed.
Comment #34
avpadernoTo the reviewers: Please set the priority to Normal after reviewing the project.
Comment #35
sleitner commentedAutomated Review
Review of the 7.x-1.x branch (commit d7eb744):
This automated report was generated with PAReview.sh, your friendly project application review script.
Manual Review
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
Comment #36
avpadernoThank you for your contribution!
I am going to update your account so you can opt into security advisory coverage now.
These are some recommended readings to help with excellent maintainership:
You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
I thank all the dedicated reviewers as well.
Comment #37
avpadernoComment #38
webservant316 commentedThanks. Is the next step for my project to be promoted to a full project?
"Only promoted full projects may opt into security advisory coverage."
Comment #39
avpadernoYes, the project needs to be first promoted to full project, from https://www.drupal.org/node/2808195/edit/promote.