1

I am developing a huge Questions bank, where teachers submit questions,which actually are nodes,and the topic subjects are taxonomies..NOw at the end of the term, teachers generate question papers of 100 questions each, but based on percentages of topics,say if it mathematics paper, so 30 percent questions from algebra(a taxonomy term) 20% from SETS( Taxonomy terms)....so how can i get this done?i am currently using database level custom procedure, but it is hardly being maintained...any suggestions plz

0

With so many different possibilities that might fit your project and its needs, I'll try to address the forks in the road with how you could do this in drupal.

You most likely wont find any appropriate functionality for this task built into drupal or a contrib module but it is simple enough to implement yourself.

Option 1 Keep it in the database, but still in drupal.

Build queries using the Database API (most likely the static method as it'll be quicker to get going, instead of the dynamic method), depending on your creativity you can loop through each taxonomy term and execute a number of possible queries to get count() results based on timeframes as well as other criteria. You could also have a specific set of queries that you run on the taxonomy terms as a whole to get a view of the whole database table, instead of looping through each term. Whichever appeals to you, this list of common mysql queries has aggregates, statistics, comparison, frequencies and just about every other basic math centric query to get you started.

Option 2 Maintain your numbers in close to realtime in a node, variable or database table

This option is really if you'd prefer to do most of your work not just on the PHP side of things but in just PHP. The example above puts the burden on your SQL server but all of your logic still actually resides in the PHP (instead of stored procedures).

This would be my second choice of the two. Instead of running a lot of heavy queries on a regular interval, simply write some code to keep track of the total numbers of each taxonomy term as they are added or removed (you can use a hook from the node API such as hook_node_presave() - any number of hooks to quickly sniff what taxonomy terms are being applied if you don't know where to do your addition and subtraction of the taxonomy terms as they are added or removed).

If you really want to hand this to drupal from your stored procedures...

Get ready to do a little battling with drupal depending on how light or heavy your code is. Queue API and batch API can help you with large background processes, otherwise you'll want to ensure things stay trim and quick if that means incremental updates to your taxonomy statistics or putting time constraints on your processes.

Good Luck!

  • Thank you very much for such a detailed answer..infact i had to read a whole book on stored procedures before starting this project..but still when i think over the stored procedure maintenance and portability..it turns me nuts..I liked your second option of auditing any changes to taxonomy on hook_node_presave..Thanks again – Azmat Jan 9 '13 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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