3

I'm working on a drupal project that collects information about a business and then offers advice based on the information submitted.

Following the initial sign up process, a user can add a new business profile content type. This will be the entity referenced by all other nodes related to this entity aka the "business profile". Based on the answers provided within this initial questionnaire, I want to require the user to complete other supplemental questionnaires (basically other content types with entity reference to the main business profile content type) before submitting a finalized business profile.

For example, in the initial business profile there may be the question "Do you have any foreign operations?", if the user answer yes, I would want to make them complete the "foreign operations" content type questionnaire with many fields that relate to foreign operations. Further, if the user answers no to a question such as "do you have any employees?" I don't want to make the user complete an extended questionnaire (aka an employee related content type) regarding employees. In addition to simple yes/no answers, if a user selected a certain business industry SIC code from a select list, I would want to require specific content types to be completed with questions related to this industry. In my mind, I could have 50 content types with questions, but for each business's unique operations, they may only need to complete 5 of those content types. Finally, I would need a dashboard to keep track of what content types are required, pending and have been completed - then once all of the required supplemental content type questionnaires are verified completed, allow the user to submit a finalized profile.

I would say my level of drupal is intermediate as I understand the basics of entity referencing, structure and views; however, admittedly my experience in rules is limited. I'm using drupal 7.x.

I'm hoping someone can help to offer me a rough step by step of how best to accomplish this. (i.e. use this module, within rules conditions add blah, etc. etc.) Is my approach the correct one or is there a better solution such as webform, etc.?

Any help or guidance is appreciated.

3 Answers 3

2

Interesting question (challenge), with quite some background info (so well documented question). It seems that at its core, this is the key challenge you need to address:

Finally, I would need a dashboard to keep track of what content types are required, pending and have been completed - then once all of the required supplemental content type questionnaires are verified completed, allow the user to submit a finalized profile.

Here is a "rough step by step" answer you asked for:

  • Use the Flag module to introduce a set of flags related to your business content type. That set consist of 1 flag for each extra questionnaire (content type) that might possibly be needed. E.g. 1 flag related to "foreign operations" and another flag related to "employees".
  • Use the Rules module to automatically set the appropriate flags to indicate that some related content type is required, but still missing (or not fully completed yet).
  • Whenever such related content type gets completed, you "unset" (automatically, via Rules) its corresponding flag.
  • Should you want to implement some review process (as per your "review completed" you mentioned), you may want to add the Workbench module to the mix (maybe some of its related modules also?), so that the "unset" of these flags only happens after the "status" of some related content type became something like "approved".
  • As soon as a business profile no longer has any of such flags set, your business content type can be considered as a "finalized" profile.
  • Possibly you may want to add the Content Access module to the mix, to implement some additional features that you may want to use.
  • To implement your "dashboard", you just have to build a few (rather basic) reports using the Views module, with appropriate fields, filters, etc related to the various flags.

If you're not familiar (enough/yet) with Rules, checkout the 32 (!!!) great, and free, video tutorials Learn the Rules framework. Possibly also the similar set of 8 video tutorials about the Flag module.

1
  • This is very helpful, thanks! I will try your suggestions and then respond back with an update.
    – whoisjosh
    Commented Nov 29, 2015 at 4:09
0

If it's questionnaire, try using Entityform instead of content type.

Then investigate Rules Forms which extends Rules with triggers/actions specially designed for forms (which can invoke on form validation, build, submit, etc.).

1
  • 1
    I certainly appreciate the suggestion. In reading into the Entityform and Rules Forms modules further, I don't believe it would be the best solution for this portion of my project; however, your suggestion actually helps to give me an idea on how to solve a separate issue. Thanks for the help.
    – whoisjosh
    Commented Nov 29, 2015 at 4:13
0

I wanted to elaborate on how I used @Pierre.Vriens answer to accomplish a “proof of concept” for my question using rules and his suggestions. At this point, I only used rules as it seems to work for what I’m trying to accomplish. I didn’t see the need to use flags; instead, I’m going to create another Boolean field for the question content types and set it to TRUE if required based on the client content type answers.

Primary modules used:

  • Rules
  • Entity Views Attach
  • Conditional Rules.

Content types for my project:

  • Clients – contains the Boolean field “do you have employees, yes/no” and a term reference field “SIC Codes”
  • Report – the node that we will add the required questions to. This entity references Clients.
  • Employee Questions – one of the question content types. This specific set of questions contains the additional questions related to employees.

Basic concept: Once a new client is created, I add a report node referencing that client. Then depending on the client questions, I add other question content types referencing the report node.

Rule

Event: After saving new content of type Clients

Condition: Entity has field Parameter: Entity: [node], Field: field_clients_termref_sic_codes

Actions Create a new entity Parameter: Entity type: Node, Content type: Reports, Title: First Report, Author: [site:current-user] Provides variables: Created entity Reports (entity_created_report)

Save entity Parameter: Entity: [entity-created-report], Force saving immediately: true

Set a data value Parameter: Data: [entity-created-report:field_report_entityref_clients, Value: [node]

Show a message on the site Parameter: Message: We created the first report for this client!

Conditional

If: Data comparison Parameter: Data to compare: [node:field-client-has-employees], Data value: Yes, we have employees Provides variables: Created entity Employee Questions (entity_created_employeeq)

Create a new entity Parameter: Entity type: Node, Content type: Employee Questions, Title: New Employee Questions, Author: [site:current-user] Provides variables: Created entity Employee Questions (entity_created_employeeq)

Save entity Parameter: Entity: [entity-created-employeeq], Force saving immediately: true

Set a data value Parameter: Data: [entity-created-employeeq:field_employeequestion_entityRef_reports, Value: [entity-created-report]

Show a message on the site Parameter: Message: We created the Employee questions!


…I then created additional conditional actions within this rule for each of the other answers provided in the initial clients page. Using Entity Views Attached I will then list all the referenced questions (all the question content types) to the Reports node for the user to complete one by one.

Eventually I plan to have a button at the bottom of my Reports display page allowing the user to submit a final report. I plan to use rules to validate if they’ve completed all the required fields for each content type, and I’ll change the status of all the required question content types to “submitted” and disable any further editing. (That’s my plan at least, I haven’t gotten that far.)

I hope this helps someone else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.