/[drupal]/contributions/modules/quiz/quiz.actions.inc
ViewVC logotype

Contents of /contributions/modules/quiz/quiz.actions.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Thu Aug 13 16:48:17 2009 UTC (3 months, 1 week ago) by sivaji
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +1 -1 lines
File MIME type: text/x-php
Merging GSoC code with HEAD.
1 <?php
2 // $Id: quiz.actions.inc,v 1.2 2009/05/28 16:52:06 mbutcher Exp $
3 /**
4 * @file
5 * Example Action Implementation.
6 *
7 * This does not provide functional code, but is an illustration of how actions can be created for
8 * Quiz.
9 *
10 * This file was created with the intent of providing
11 * some documentation for a good starting point when creating actions for utilization with
12 * the quiz module. Most of this documentation was taken from http://api.drupal.org, the API
13 * documentation provided by Drupal. For more understanding of these functions and hooks, please
14 * see that Drupal API documentation for further reading.
15 * @file
16 */
17
18
19 /**
20 * Implementation of hook_action_info().
21 * An action consists of two or three parts:
22 * (1) an action definition (returned by this hook),
23 * (2) a function which does the action
24 * (which by convention is named module + '_' + description of what the function does + '_action'),
25 * (3) and an optional form definition function that defines a configuration form
26 * (which has the name of the action with '_form' appended to it.)
27 *
28 */
29 function quiz_action_info() {
30 /*
31 //this is the name of your function to execute (custom_action)
32 //whatever your name here is you MUST have a function that matches
33 $info['custom_action'] = array(
34 //this is how we can filter the dropdown box on the quiz create page there will be an
35 //admin setting that will allow you to filter your dropdown results by 'type'
36 'type' => 'quiz',
37 //self explainatory
38 'description' => t('Custom Desription'),
39 //This allows you to configure your action with parameters through the admin
40 //If set to TRUE then you will need a custom form function for your options
41 'configurable' => TRUE,
42 //this will filter out actions based hooks, You will only use this if your going to get
43 //extremely advanced.
44 'hooks' => array(
45 'any' => TRUE,
46 ),
47 );
48 */
49 //return your array of actions
50 return $info;
51 }
52 /**
53 * This will be your custom action to perform. What do you want to happen?
54 * When creating your quiz and you select your custom_action you defined in quiz_action_info()
55 * then this function will be called to perform whatever you want to happen.
56 *
57 */
58 function quiz_custom_action() {
59 //perform your action here
60 }
61 /**
62 * Form for configurable Drupal action.
63 * This form will be called when you choose the 'Make a new advanced action available' from the
64 * actions page in the admin. An example of utilizing this type of dynamics would be if you were
65 * giving away playing cards. You could create a custom function that would take an 'id' as a parameter
66 * to query the playing card database by. So you would have ONE function that could give away any
67 * playing card based on the parameter (id). So you create a new action and this form will come
68 * up. In your form you select the playing card to give away, then click save and your new action
69 * that gives away the playing card is created. Then you just select that new action from the
70 * dropdown when creating/editing the quiz.
71 *
72 * @param array $context
73 * @return $form
74 */
75 function quiz_custom_action_form($context) {
76 /*
77 $options = get_a_list_of_playing_cards(); //you would need to create an option list from a function
78 $form['playing_card_id'] = array(
79 '#title' => t('Playing Card'),
80 '#type' => 'select',
81 '#description' => t('Please select the playing card to give away.'),
82 '#options' => $options,
83 '#default_value' => isset($context['playing_card_id']) ? $context['playing_card_id'] : '',
84 );
85 $form['submit'] = array(
86 '#type' => 'sumbit',
87 '#value' => t('Submit')
88 );
89 */
90 return $form;
91 }
92 /**
93 * Validates the custom action form to make sure they have selected a playing card
94 * when creating a new action
95 *
96 * @param array $form
97 * @param array $form_state
98 */
99 function quiz_custom_action_validate($form, $form_state) {
100 /*
101 $playing_card = $form_state['values']['playing_card_id'];
102 if(empty($playing_card)) {
103 form_set_error('playing_card_id', t('Please select the pllaying card to give away.'));
104 }
105 */
106 }
107 /**
108 * Custom submit handler when creating a new action for a playing card.
109 *
110 * @param array $form
111 * @param array $form_state
112 * @return array
113 */
114 function quiz_custom_action_submit($form, $form_state) {
115 /*
116 return array('playing_card_id' => (int) $form_state['values']['playing_card_id']);
117 */
118 }

  ViewVC Help
Powered by ViewVC 1.1.2