/[drupal]/contributions/modules/uts/uts.hooks.analysis.php
ViewVC logotype

Contents of /contributions/modules/uts/uts.hooks.analysis.php

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


Revision 1.2 - (show annotations) (download) (as text)
Sun Aug 17 00:59:10 2008 UTC (15 months, 1 week ago) by boombatower
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-RC1, DRUPAL-6--1-0, DRUPAL-6--1-0-BETA2, HEAD
Changes since 1.1: +3 -3 lines
File MIME type: text/x-php
Change $headers to $header.
1 <?php
2 // $Id: uts.hooks.analysis.php,v 1.1 2008/08/16 22:04:38 boombatower Exp $
3 /**
4 * @file
5 * Provide data analysis hook documentation for Usability Testing Suite.
6 *
7 * Copyright 2008 by Jimmy Berry ("boombatower", http://drupal.org/user/214218)
8 */
9
10 /**
11 * Get a list of data analysis plug-ins.
12 *
13 * @return array List of data analysis plug-ins.
14 */
15 /**
16 * Define data analysis modes the module provides. This provides the modes of
17 * analysis that the module provides. The mode will be passed to subsequent
18 * analysis functions in order to request a particular analysis.
19 *
20 * @return array Data analysis plug-in modes.
21 *
22 * The array should use the module name as a key and contain an array of
23 * analysis modes that are provided.
24 */
25 function hook_uts_data_analysis() {
26 return array(
27 'uts_plugin' => array('list')
28 );
29 }
30
31 /**
32 * Generate an alysis of data to be displayed.
33 *
34 * @param string $module Data collection module from which data will be retrieved.
35 * @param string $mode The analysis mode.
36 * @param interger $study_nid Study NID.
37 * @param string $session_id Session ID.
38 * @param interger $start_timestamp Start timestamp.
39 * @param integer $stop_timestamp Stop timestamp.
40 * @return array Generated analysis elements.
41 *
42 * The analysis is returned in the same format as hook_view(). Each analysis
43 * piece to display is returned as an array containing keys: #data, and
44 * #weight. This will allow multiple analaysis modules to add pieces of
45 * analysis to a particular mode.
46 */
47 function hook_uts_data_display($module, $mode, $study_nid, $session_id = NULL, $start_timestamp = NULL, $stop_timestamp = NULL) {
48 if ($module == 'uts_plugin' && $mode == 'list') {
49 $data = uts_plugin_uts_data_get($study_nid, $session_id, $start_timestamp, $stop_timestamp);
50 $rows = $data['uts_plugin'];
51
52 // Format data.
53 foreach ($rows as &$row) {
54 $row['timestamp'] = format_date($row['timestamp']);
55 }
56
57 $header = array(t('Session id'), t('Timestamp'), t('Element 1'), t('Element 2'));
58 return array(
59 array(
60 '#data' => (empty($rows) ? t('<p>No data to display.</p>') : theme('table', $header, $rows)),
61 '#weight' => -10
62 )
63 );
64 }
65 }
66
67 /**
68 * Export the analysis for use in external programs, such as presentations. The
69 * exported analysis will be compressed as a ZIP archive so that multiple files
70 * can be included easily.
71 *
72 * @param string $module Data collection module from which data will be retrieved.
73 * @param string $mode The analysis mode.
74 * @param interger $study_nid Study NID.
75 * @param string $session_id Session ID.
76 * @param interger $start_timestamp Start timestamp.
77 * @param integer $stop_timestamp Stop timestamp.
78 * @return array Exported analysis.
79 *
80 * The exported analysis should be returned as a key-value array of filenames
81 * and data. The array will then be used to generate a ZIP archive and
82 * transfered to the user.
83 */
84 function hook_uts_data_analysis_export($module, $mode, $study_nid, $session_id = NULL, $start_timestamp = NULL, $stop_timestamp = NULL) {
85 if ($module == 'uts_plugin' && $mode == 'list') {
86 $data = uts_form_uts_data_get($study_nid, $session_id, $start_timestamp, $stop_timestamp);
87 $rows = $data['uts_plugin'];
88
89 $out = '"' . implode('","', array(t('Session id'), t('Timestamp'), t('Element 1'), t('Element 2'))) . "\"\n";
90 foreach ($rows as $row) {
91 $out .= '"' . implode('","', $row) . "\"\n";
92 }
93 return array(
94 'uts_plugin.list.csv' => $out
95 );
96 }
97 }

  ViewVC Help
Powered by ViewVC 1.1.2