/[drupal]/contributions/modules/jeopardy/jeopardy.module
ViewVC logotype

Diff of /contributions/modules/jeopardy/jeopardy.module

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

revision 1.2, Sun Aug 31 12:20:53 2008 UTC revision 1.3, Mon Sep 1 02:27:45 2008 UTC
# Line 254  function jeopardy_view(&$node, $teaser = Line 254  function jeopardy_view(&$node, $teaser =
254      $category = $node->$c;      $category = $node->$c;
255      $output .= '<th class="jeopardy-table-header">'. $category .'</th>';      $output .= '<th class="jeopardy-table-header">'. $category .'</th>';
256    }    }
257    
258      $width = floor(100/$cols);
259    $output .= '</tr>';    $output .= '</tr>';
260    for ($j = 1; $j <= $rows; $j++) {    for ($j = 1; $j <= $rows; $j++) {
261      $output .= '<tr class="jeopardy-table-question-row">';      $output .= '<tr class="jeopardy-table-question-row">';
# Line 262  function jeopardy_view(&$node, $teaser = Line 263  function jeopardy_view(&$node, $teaser =
263        $q = "jeopardy_question$k$j";        $q = "jeopardy_question$k$j";
264        $a = "jeopardy_answer$k$j";        $a = "jeopardy_answer$k$j";
265    
266        $output .= '<td class="jeopardy-table-question" id="jeopardy-'. $j .'-'. $k .'" >'. ($j*100) .'</td>';        $output .= '<td class="jeopardy-table-question" style="width: '. $width .'%; height: 25px;" id="jeopardy-'. $j .'-'. $k .'" >'. ($j*100) .'</td>';
267        $output .= '<div class="jeopardy-completely-hidden-question" id="question-'. $j .'-'. $k .'">'. filter_xss($node->$q) .'</div>';        $output .= '<div class="jeopardy-completely-hidden-question" id="question-'. $j .'-'. $k .'">'. filter_xss($node->$q) .'</div>';
268        $output .= '<div class="jeopardy-completely-hidden-answer" id="answer-'. $j .'-'. $k .'">'. filter_xss($node->$a) .'</div>';        $output .= '<div class="jeopardy-completely-hidden-answer" id="answer-'. $j .'-'. $k .'">'. filter_xss($node->$a) .'</div>';
269      }      }
# Line 277  function jeopardy_view(&$node, $teaser = Line 278  function jeopardy_view(&$node, $teaser =
278      '#weight' => 1      '#weight' => 1
279    );    );
280    
   //echo '<pre>';  
   //print_r($node);  
   //echo '</pre>';  
   
281    return $node;    return $node;
282  }  }
283    
# Line 341  function jeopardy_update(&$node) { Line 338  function jeopardy_update(&$node) {
338      for ($k = 1; $k <= $rows; $k++) {      for ($k = 1; $k <= $rows; $k++) {
339        $q = "jeopardy_question$j$k";        $q = "jeopardy_question$j$k";
340        $a = "jeopardy_answer$j$k";        $a = "jeopardy_answer$j$k";
341    
342        db_query("UPDATE {jeopardy_questions} SET category = '%s', question = '%s', answer = '%s' WHERE row = %d AND col = %d", $node->$c, $node->$q, $node->$a, $j, $k);        // does this row and column have an entry? if so, update it
343          $count = db_result(db_query("SELECT COUNT(*) FROM {jeopardy_questions} WHERE nid = %d AND col = %d AND row = %d", $nid, $j, $k));
344    
345          // update the entry that is present
346          if ($count) {
347            db_query("UPDATE {jeopardy_questions} SET category = '%s', question = '%s', answer = '%s' WHERE row = %d AND col = %d AND nid = %d", $node->$c, $node->$q, $node->$a, $j, $k, $nid);
348          }
349          // we must have changed the number of rows and columns
350          else {
351            db_query("INSERT INTO {jeopardy_questions} (nid, category, question, answer, row, col) VALUES (%d, '%s', '%s', '%s', %d, %d)", $nid, $node->$c, $node->$q, $node->$a, $j, $k);
352          }
353          // TODO: Deal with orphaned questions (when a Jeopardy game is reduced in size)
354      }      }
355    }    }
356    db_query("UPDATE {jeopardy_rows_cols} SET rows = %d, cols = %d WHERE nid = %d", $rows, $cols, $nid);    db_query("UPDATE {jeopardy_rows_cols} SET rows = %d, cols = %d WHERE nid = %d", $rows, $cols, $nid);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2