Drupal 7 questionnaire webform - drupal-7

What is the best method to create a questionnaire in drupal 7?
We use multiple choice questions. (+/- 20)
Is it possible to have one question per page? How?
Is there a way to give the user the end-score of this questionnaire? How?

You will need to install a Field Group module and Views module.
Add a content type "Test1"
To the Test1, add a Text field, "Question1"
Also, add a List (text) field, enter
q1|Answer one
q2|Answer two
Repeat for more questions
Use Field Group module to divide questions by pages.
To take the test, add Test1 "/node/add/test1".
To create an answer sheet, take the test and use the Node ID of the test for the next step.
Create a view, using Views. Match any taken test against the Node Id of the answer sheet. You can do so, by including a link at the end of the test, which links to "/score/%NID%", %NID% being the Node ID of the current TEST1. Create a page in views, with "/score/%" as a path. Use the Contextual Filter to get the NID from the path and match it against the NID of the cheat sheet.
You can get it more advanced by using referencing fields, via Entity API and Entity Reference modules.
Enjoy!

Related

How can the category and product fields in Shopizer be customized, if possible at all?

I am currently using Shopizer as a sort of headless CMS, leveraging its out of the box admin pages and REST API for the content. There is a page for editing products in the admin system but I would like to add and/or remove specific fields. Making changes to the base code seems to be the most obvious solution but it is taking me a significant amount of time to implement it successfully.
Is there some sort of a config file or an initialization process to customize the fields for creating categories and products using Shopizer's admin page? What is the best practice for this scenario if the former approach is not possible?
If you need to add fields the easiest way is to add them in model objects
com.salesmanager.core.model.*
Example of an annotated field
#Column (name ="IP_ADDRESS")
private String ipAddress;
Once you restart your instance the new field will be available.

Cakedc users plugin new table entry

I am using Cakedc Users plugin and I want to add a small entry to the Users table which is "Balance" (integer)
I read the extending part in the documentation and I honestly got dizzy from all the modifications that I have to do
I don't want to rewrite the whole thing just for a small entry, Is there anyway I can add it to the table with minumum modification or rename another entry that I don't need, like "tos_date" or something
Well, let me try to help about how extending the model should be:
Modify the users table (via migrations or manually) and add the columns you want.
Copy the template files with the forms, from the plugin itself to your app under the folder src/Template/Plugin/CakeDC/Users/name_of_the_controller/name_of_the_action, then modify the forms to add a new control for your custom column
You're done
Thanks!

Drupal 7 unable to get referenced node in view

I have a node called "Student" I have another node called "Personal details".
I have made relations between them using entity reference module.
Now I am creating a view to get details of all students. I created a view of students and selected Content "Personal details" on fileds of the view. But I am only getting the id of the "Personal details".
I am struging to get the name and other fields of personal details node.
I used Relationships-> Entity Reference: Personal details and added content entityreference in fields but it is not displaying aything when i printing the view using get_view API.
Please help me on this.
I think this should work. Try to create a view for all types.
Select the fields that you want to display (the fields from students and personal info ). Chose to display both Id's from Student node and from the Personal info node, but make 1 of them invisible, to not be shown. ( you will understand why in step 4 ).
Add a filter, the Global: Fields comparison.
Select the two fields that have to be equal (the ID's).

Drupal dynamic Taxonomy term values

I'm new to Drupal, and somehow miss a feature. (or I guess just don't know how to activate it)
Let's say I have a content type which is using the term reference (taxonomy field type)
Is it possible to have it filled dynamically (e.g. with already existing content from my site?
I don't want to type in all possible Tag/Term options, but instead want some kind of dynamic category choice for an author, e.g. feeded by existing content (articles/pages) from the drupal site itself.
Is there a certain module I need or how is it done?
If you want to add to your nodes a reference to another node in your site you need to use a node reference field and not a term reference. To be able to add that kind of field to your content type, you need to install References module, and probably Views to show pages that leverage your references. If you provide some details of your requirements I can be more specific.

Show custom object in related list under page layout

I have been trying this whole day but cant figure out... I have custom object called Dev which has many to many relationship with Accounts... I want this object Dev to show under related list of page layout of account... But it is not showing there how can i add that to related list?
Assuming you have a lookup relation from Account to Dev and also a lookup from Dev to Account (creating your many-to-many), then this will work fine.
Try re-creating your lookup relationship from Account to Dev. Then make sure that you add the related list and add to the page layouts in steps 5 & 6:
Step 5. Add reference field to Page Layouts (Yes to All)
Step 6. Add custom related lists (Yes)
That's all you need. If, however, your many-to-many relationship is unique or otherwise configured differently (with a junction table, for example) then the above may not work for you.
We always tend to use joining objects for these relationships, obviously you can show the list of joining objects as a related list, and you could display other fields from the dev object by use of formulae.
One thing we've tended to do is create an inline VF page which can then show all of the objects related to the current record.

Resources