Access Drupal's Voting API from theme - drupal

I'm a king of a noob in drupal.
I'm trying to use Voting API and Advanced Pool module, now I'm customizing node-advpoll_binary.tpl.php template, and i can access only the total votes.
I'd like to know how get the poll results for each answer in order to calculate percentage results.
Does anyone have the solution??

You don't typically want to do calculations in the theme layer. You may be able to output the numbers you're looking for using the Views module.

Related

How to enable web users to interact with a REST API

Hi and thank you for looking into this.
(Disclaimer: I have little-to-no technical background and would like to find the least complex solution. Ideally, only "connecting" different out-of-the-box components and no coding.)
HIGH-LEVEL PROBLEM:
I have trained a model for text classification using Google AutoML. I want to make this model available on a website, ie I want to enable visitors to enter their text and to receive the model's predicted class.
CONSIDERATIONS SO FAR: AutoML allows us to deploy the model via REST API and I understand that what I want are the API's PUT and GET function (right?). Ideally, I would use some form of plug-in or script to create an input field for the user which accepts the PUT and then delivers the GET.
Are you aware of any services for this? I'm also happy to host the website in an content management system like WordPress.
I'm very open regarding other approaches to solving my problem and highly appreciate any constructive input.
Many thanks!
AutoML Documentation https://cloud.google.com/natural-language/automl/docs/predict
EDIT Jan 10 There is another question related to this and a depo is shared which supposedly provided a solution. I'm not able to access the depo but the question might help you to understand my issue. Is there a way to use Googles AutoML with JavaScript?
EDIT Jan 16 I have learned that in order to provide the input to the model the POST function could be used instead of the PUT.

Create a system select from different lists and then make a total in wordpress

I know, the question isn't clear in itself. Let me explain.
I want to create a system where a visitor can choose options from different lists and result will be the total amount with all the details of the selected components.
Theoretically it's a simple formula but i have no idea how to apply it on wordpress. i am not even on moderate level in programming.
So, anyone has any idea, how it can be achieved, any plugin or functions.
Thanks in advance!
If your not comfortable coding this is a bit tough. It sounds like you're talking about some type of store (total amount?). A list of items with details and price and lists of add ons or features that change the price and product configuration? Something like that?
Coding this would I think be a bunch of jQuery/javascript. Otherwise try the Gravity Forms plugin (which I've used and should be able to do this for you) or perhaps a straight ecommerce plugin - there are lots. Then I think you just have to learn the plugin to get the setup you want.

How to implement reservation system in week view in drupal?

I want to implement reservation system in my project which should display bookings available for a week (in week view)and users can select the slot which is not booked. I am completely new in drupal. Can anyone tell me how to do this and which module is suitable?
The trick in Drupal is to always search for modules that get you closer to what you want, since there are so many that can save you days of work. I would suggest starting by reviewing this comparison of Booking modules: https://groups.drupal.org/node/137544 before rolling your own.
If none of them suits you, the basic concept would be to have bookings created (a content type) and the some calendar that displays the available dates, then you could use Views for this last part.
The whole solution can be accomplish with a combination of Views and one of the Booking modules above.
Your question is rather general so review that comparison and you will find something you can use for sure.

Managing Plone vocabularies through the web

I am currently working on a Plone project with several custom content types. These content types have several fields that in turn fetch their values from vocabularies. Currently, I've just hard coded my values in a vocabularies.py file as such:
from Products.Archetypes import atapi
CITIES_LIST = atapi.DisplayList((
('nairobi', 'Nairobi'),
('kisumu', 'Kisumu'),
('mombasa', 'Mombasa'),
('eldoret', 'Eldoret'),
('nakuru', 'Nakuru'),
))
This works well and there is no problem with it.
The only drawback is that the vocabulary is etched in code and it will need a programmer/developer to modify the existing vocabulary.
What I need is a way for site administrators and users who are not necessarily programmers to be able to modify the vocabulary in future through the web interface i.e. a client from another country to be able to change the list of available cities.
I've looked at Products.ATVocabularyManager but I don't think it fits the bill. Perhaps if there was an interface with a grid to manage the vocabularies. This I guess I will have to manage them by storing them as ArcheTypes.
Is there a way to handle such a situation in Plone 4? How would one go about it?
Products.ATVocabularyManager should work fine for your use case. I've used it with success many times in the past.
It provides an admin UI to manage your vocabularies.
If the UI to manage to vocabs is not to your liking, perhaps you could contribute to the project to make it better?

How to write custom reports in Drupal

What's the "right" way in Drupal to create reports? I was hoping to use a view but am not having much luck. My goal is to create a table of rows containing three fields: user name, location, SUM of volunteer hours. Once I have this part working, I plan to expose filters for Location and Date.
Views Calc only allows you to group by one field. I know Crystal Reports and MSSQL Reporting Services and I was hoping to find a similar kind of thing for Drupal. Is there a framework, examples, or a module to help with this, or do I need to write a custom module implementing the views_alter_SQL hook to get the desired data for each report?
EDIT: I ended up getting it to work with BIRT reports, which gave a lot more power than Views could allow. Code is on my blog: http://nicholaiburton.com/blog/2010/creating-custom-reports-for-drupal
You could implement a views_query_alter but you might be better off implementing a custom views field handler, because I assume that your user.uid joins to hours.uid. This will probably be your best long term solution.
All you'd need to do is just tell views how your tables join and define the handler for the total hours. You can find help/docs -> http://views-help.doc.logrus.com/help/views/api
in any way, for Sum of Volunteer hours you need to build custom module, so building custom query more simpler, than attaching custom field to Views via it's hooks...

Resources