Poll (choice) Block

Poll (choice) Block

by Chardelle Busch -
Number of replies: 8
Picture of Core developers
A while back I saw a block someone created that showed a poll (choice).  Does anyone have any info on this?

Thx
Average of ratings: -
In reply to Chardelle Busch

Re: Poll (choice) Block

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
that was me..... smile
- I've got an old version of it running here:
http://learn2.lincoln.ac.nz/moodleblog

I've come across a slight problem in getting it good enough to be released in the Core of Moodle instead of as a custom block. I also want to be able to provide just a block to install instead of a block and some modified choice module code....

Here's the problem:

The choice is a module, so when a new choice is created it has to be attached to a section inside a course.

I want to reuse all the code from the module for the choice block, so that a block is just a different way of creating a choice - but I didn't want it to have to be attached to a section within a course. I may need to set the block up so that it uses it's own tables and libraries instead of re-using the existing ones to do this..... Unless a choice block just allows you to select to show a choice that is already set up...... - I might investigate this further..thinking along as I type, I might be able to add an option to allow the block to show even if the module is hidden in it's section......that could be a better alternative!

alas, due to these complications, I don't think it will be ready for 1.6 sad

anyone else have any good ideas?

smile

Dan
In reply to Dan Marsden

Re: Poll (choice) Block

by Chardelle Busch -
Picture of Core developers
Oh Hi Dan!

Now I remember where I saw it--when I was demoing your and Daryl's blog!  I don't think it's a real problem to have to set up a choice first--it follows along the lines of other blocks that "take their info" from mods.  I know that Jan's random glossary block can show entries from a hidden glossary, but I'm not sure how you will be able to submit info to a hidden activity.  I have a block that I use where you can add an activity, then hide the block but still have access to the activity from a link--that would probably work to hide the choice.  I'd like to test it out, would you send it to me? If not, no problemsmile.
In reply to Chardelle Busch

Re: Poll (choice) Block

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Chardelle,

I'm going to shelf the existing Block code and create a new one that works off an existing choice - I've cleaned up the choice module a bit in 1.6, and I might be able to release a block that doesn't alter any existing code as well.

- I'll post a link in this forum when I have a version available for testing - maybe later this week! smile

Dan
In reply to Dan Marsden

Re: Poll (choice) Block

by Justin Filip -
An easy way to deal with the fact that it needs to be attached to a course section is to start adding the choice modules to a really high course section. This is a technique I used for the Side Bar block (the latest code is in a zip towards the bottom of that discussion and is also in contrib as 'block_side_bar').

It's like the Main Menu bock on the site index page, which adds activities and resources to section 0 of the site course, whereas my block starts at (definable) section 1000 and up for each instance of the block in a course. This allows you to keep adding activities and resources to a course which are not tied to any one section and any student in any section may be able to view.

It's very simple code and means you don't have to worry about modifying too much of the existing choice module code (you can just use it) and you need not start creating new DB tables for your block.
In reply to Justin Filip

Re: Poll (choice) Block

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Justin,

I thought about that, but it seems like really bad practice to create inconsistant records in a table - I would prefer the patch not to use other tables/code for my own eevil purposes...... - but to use them as designed, or create some new ones that work for me! - I'm also trying to prepare this for inclusion in the standard moodle download - this won't happen if I don't use existing code/tables as designed. I need to either create new code, or propose changes to the existing tables/code to allow mine to sit in with it.

thanks,

smile

Dan
In reply to Dan Marsden

Re: Poll (choice) Block

by Justin Filip -
I understand where you're coming from but I don't see this as using the tables improperly.  The block is already using the choice module that that has to sit inside a course section.  You just have the block use a really high (visible) section value that will be created when the block code is first executed in a new instance.  That section value can be instance or globally configured.  You can even have more than one by just incrementing the section number if you add new blocks.

I see that as a more proper solution with less headache involved (such as creating new tables to do something that is already possible) or having the existing module code changed.

Anyway, my 2 cents.

Good luck.  smile
In reply to Justin Filip

Re: Poll (choice) Block

by Robert Brenstein -
Tying a block to an activity in the course does not sound wrong to me. After all a block is attached to the same course.

A clean approach would be to have activities in Moodle that are invisible but active. See Bug #4782. shy