/[drupal]/contributions/modules/uts/plugins/uts_path/uts_path.module
ViewVC logotype

Diff of /contributions/modules/uts/plugins/uts_path/uts_path.module

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

revision 1.19, Sat May 30 03:05:34 2009 UTC revision 1.20, Sat May 30 03:38:45 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: uts_path.module,v 1.18 2009/05/30 02:36:10 boombatower Exp $  // $Id: uts_path.module,v 1.19 2009/05/30 03:05:34 boombatower Exp $
3  /**  /**
4   * @file   * @file
5   * Collect the user path taken to complete a task and compare to defined ideal path.   * Collect the user path taken to complete a task and compare to defined ideal path.
# Line 117  function uts_path_theme() { Line 117  function uts_path_theme() {
117   */   */
118  function uts_path_init() {  function uts_path_init() {
119    $status = variable_get('uts_path_ideal_recorder', UTS_PATH_RECORDER_CLOSED);    $status = variable_get('uts_path_ideal_recorder', UTS_PATH_RECORDER_CLOSED);
   if ($status != UTS_PATH_RECORDER_CLOSED) {  
     drupal_add_css(drupal_get_path('module', 'uts_path') . '/uts-path.css');  
     drupal_add_css(drupal_get_path('module', 'uts_proctor') . '/uts-proctor.css');  
120    
121      $status_message = t('<b>Status</b>: @status', array('@status' => uts_path_get_recorder_status($status)));    if ($status != UTS_PATH_RECORDER_CLOSED) {
122      drupal_set_content('header', theme('uts_path_record', $status_message, drupal_get_form('uts_path_record_ideal_form')));      // Cause recorder to be closed before recoring is called, but allow status
123        // message to be accurate since recording occurs before it is generated.
124        $action_form = drupal_get_form('uts_path_record_ideal_form');
125    }    }
126    
127    // Record the current page if in ideal recording mode or proctor data record.    // Record the current page if in ideal recording mode or proctor data record.
# Line 132  function uts_path_init() { Line 131  function uts_path_init() {
131    else if (module_exists('uts_proctor') && uts_proctor_data_record()) {    else if (module_exists('uts_proctor') && uts_proctor_data_record()) {
132      uts_path_record(FALSE);      uts_path_record(FALSE);
133    }    }
134    
135      if ($status != UTS_PATH_RECORDER_CLOSED) {
136        drupal_add_css(drupal_get_path('module', 'uts_path') . '/uts-path.css');
137        drupal_add_css(drupal_get_path('module', 'uts_proctor') . '/uts-proctor.css');
138    
139        $status_message = t('<b>Status</b>: @status', array('@status' => uts_path_get_recorder_status($status)));
140    
141        if ($path = uts_path_ideal_get(variable_get('uts_path_ideal_recorder_task_nid', 0))) {
142          $status_message .= ' (' . format_plural(count($path), '1 step', '@count steps') . ')';
143        }
144    
145        drupal_set_content('header', theme('uts_path_record', $status_message, $action_form));
146      }
147  }  }
148    
149  /**  /**
# Line 177  function uts_path_record_ideal_form_subm Line 189  function uts_path_record_ideal_form_subm
189        variable_set('uts_path_ideal_recorder', UTS_PATH_RECORDER_CLOSED);        variable_set('uts_path_ideal_recorder', UTS_PATH_RECORDER_CLOSED);
190    
191        // Redirect to task page and display instructions.        // Redirect to task page and display instructions.
192        drupal_set_message(t('Please confirm that the ideal path is correct as it is automatically saved.'));        drupal_set_message(t('Please confirm that the ideal path is correct. The path is automatically saved.'));
193        $form_state['redirect'] = 'node/' . variable_get('uts_path_ideal_recorder_task_nid', 0) . '/edit';        $form_state['redirect'] = 'node/' . variable_get('uts_path_ideal_recorder_task_nid', 0) . '/edit';
194        break;        break;
195      case t('Clear'):      case t('Clear'):
# Line 254  function uts_path_open_record_ideal($for Line 266  function uts_path_open_record_ideal($for
266  }  }
267    
268  /**  /**
269   * Render the ideal path for the current task node.   * Get the ideal path for the specified task node.
270   *   *
271   * @param integer $task_nid The task NID to render ideal path for.   * @param integer $task_nid The task NID to render ideal path for.
272   * @return string HTML output.   * @return array Ideal path.
273   */   */
274  function uts_path_render_ideal($task_nid) {  function uts_path_ideal_get($task_nid) {
275    $rows = array();    $rows = array();
276    if ($task_nid) {    if ($task_nid) {
277      $result = db_query('SELECT path, breadcrumb, title      $result = db_query('SELECT path, breadcrumb, title
278                          FROM {uts_path_ideal}                          FROM {uts_path_ideal}
279                          WHERE task_nid = %d                          WHERE task_nid = %d
280                          ORDER BY weight ASC', $task_nid);                          ORDER BY weight ASC', $task_nid);
     $header = array(t('Path'), t('Breadcrumb'), t('Title'));  
281      while ($record = db_fetch_array($result)) {      while ($record = db_fetch_array($result)) {
282        $rows[] = $record;        $rows[] = $record;
283      }      }
284    }    }
285    return (count($rows) > 0 ? theme('table', $header, $rows) : t('No path to display.'));    return $rows;
286    }
287    
288    /**
289     * Render the ideal path for the specified task node.
290     *
291     * @param integer $task_nid The task NID to render ideal path for.
292     * @return string HTML output.
293     */
294    function uts_path_render_ideal($task_nid) {
295      $rows = array();
296      if ($task_nid) {
297        $header = array(t('Path'), t('Breadcrumb'), t('Title'));
298        $rows = uts_path_ideal_get($task_nid);
299      }
300      return ($rows ? theme('table', $header, $rows) : t('No path to display.'));
301  }  }
302    
303  /**  /**

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.2