? 616566_gradebook_options_fix.patch
? LICENSE.txt
Index: gradebook.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gradebook/gradebook.module,v
retrieving revision 1.15.4.2.2.13
diff -u -r1.15.4.2.2.13 gradebook.module
--- gradebook.module	20 Apr 2009 02:45:40 -0000	1.15.4.2.2.13
+++ gradebook.module	9 Nov 2009 13:59:04 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: gradebook.module,v 1.15.4.2.2.13 2009/04/20 02:45:40 mgn Exp $
+// $Id$
 /**
  * @file
  * Provides a simple gradebook
@@ -502,10 +502,10 @@
   $students = array();
   $student_grades = array();
   $assignment_order = array();
-  $default_order = variable_get('gradebook_page_order', array());
-  $order = isset($_GET['order']) ? $_GET['order'] : (isset($default_order[$gradebook->tid]) ? $default_order[$gradebook->tid] : '');
-  $default_sort = variable_get('gradebook_page_sort', array());
-  $sort = isset($_GET['sort']) ? (($_GET['sort'] == 'desc') ? 'DESC' : 'ASC') : (isset($default_sort[$gradebook->tid]) ? $default_sort[$gradebook->tid] : 'ASC');
+  $default_order = variable_get('gradebook_page_order-'. $gradebook->tid, 'category');
+  $order = isset($_GET['order']) ? $_GET['order'] : $default_order;
+  $default_sort = variable_get('gradebook_page_sort-'. $gradebook->tid, 'asc');
+  $sort = isset($_GET['sort']) ? (($_GET['sort'] == 'desc') ? 'DESC' : 'ASC') : $default_sort;
 
   $teacher = gradebookapi_is_teacher($gradebook);  
   // Make sure user has permission to be here.
@@ -1028,20 +1028,9 @@
     '#description' => t('These settings apply only to this gradebook.'),
   );
 
-  if (!is_array($form['local']['gradebook_page_order'])) {
-    $form['local']['gradebook_page_order'] = array(
-      '#tree' => TRUE,
-    );
-    $form['local']['gradebook_page_sort'] = array(
-      '#tree' => TRUE,
-    );
-  }
+  $default = variable_get('gradebook_page_order-'. $gradebook->tid, 'category');
 
-  $default = variable_get('gradebook_page_order', array());
-  if (!isset($default[$gradebook->tid])) {
-    $default[$gradebook->tid] = 'category';
-  }
-  $form['local']['gradebook_page_order'][$gradebook->tid] = array(
+  $form['local']['gradebook_page_order-'. $gradebook->tid] = array(
     '#type'        => 'radios',
     '#title'       => t('Default sort order of gradebook page'),
     '#type' => 'radios',
@@ -1050,22 +1039,19 @@
                         'due' => t('Due Date'),
                         'publish' => t('Publish Date'),
                         'possible' => t('Points Possible'), ),
-    '#default_value' => $default[$gradebook->tid],
+    '#default_value' => $default,
     '#description' => t('Select the default order to sort the gradebook page.'),
     '#required' => FALSE,
   );
 
-  $default = variable_get('gradebook_page_sort', array());
-  if (!isset($default[$gradebook->tid])) {
-    $default[$gradebook->tid] = 'asc';
-  }
+  $default = variable_get('gradebook_page_sort-'. $gradebook->tid, 'asc');
 
-  $form['local']['gradebook_page_sort'][$gradebook->tid] = array(
+  $form['local']['gradebook_page_sort-'. $gradebook->tid] = array(
     '#type'        => 'radios',
     '#title'       => t('Default sort direction of gradebook page'),
     '#type'        => 'radios',
     '#options'     => array('asc' => t('Ascending'), 'desc' => t('Descending'), ),
-    '#default_value' => $default[$gradebook->tid],
+    '#default_value' => $default,
     '#description' => t('Select the default order to sort the gradebook page.'),
     '#required' => FALSE,
   );
Index: gradebook_attachments/gradebook_attachments.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gradebook/gradebook_attachments/Attic/gradebook_attachments.module,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 gradebook_attachments.module
--- gradebook_attachments/gradebook_attachments.module	31 Oct 2009 02:06:54 -0000	1.1.2.4
+++ gradebook_attachments/gradebook_attachments.module	9 Nov 2009 13:59:04 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: gradebook_attachments.module,v 1.1.2.4 2009/10/31 02:06:54 mgn Exp $
+// $Id$
 /**
  * @file
  * Provides file attachments for gradebook grades.
@@ -190,21 +190,17 @@
   if ($form_id == 'gradebook_teacher_settings') {
     // Add options to the local gradebook settings form.
     $gid = $form['#gid'];
-    if (!is_array($form['local']['gradebook_attachment_settings'])) {
-      $form['local']['gradebook_attachment_settings'] = array('#tree' => TRUE, );
-    }
-    $default = variable_get('gradebook_attachment_settings', array());
-    if (!isset($default[$gid])) {
-      $default[$gid] = 0;
-    }
-    $form['local']['gradebook_attachment_settings'][$gid] = array(
+
+    $default = variable_get('gradebook_attachment_settings-'. $gid, 0);
+
+    $form['local']['gradebook_attachment_settings-'. $gid] = array(
       '#title' => t('Restrictions on student attachments'),
       '#type' => 'radios',
       '#options' => array(0 => t('Allow student attachments at all times'),
                           1 => t('Disable student attachments after due date has passed'),
                           2 => t('Disable student attachments after assignment has been graded'),
                           3 => t('Do not allow student attachments'), ),
-      '#default_value' => $default[$gid],
+      '#default_value' => $default,
       '#description' => t('Select default restrictions on student attachments. Restrictions selected for individual assignments will override this default behavior.'),
       '#required' => TRUE,
     );
@@ -456,8 +452,8 @@
 function gradebook_attachments_attachment_permitted_node($node, $gid, $teacher = FALSE, $graded = FALSE) {
   // Attachments are permitted unless there are restrictions.
   $permission = TRUE;
-  $gradebook_attach_restrictions = variable_get('gradebook_attachment_settings', array());
-  $attach_restrictions = (is_null($node->attach_status) || $node->attach_status == 4) ? $gradebook_attach_restrictions[$gid] : $node->attach_status;
+  $gradebook_attach_restrictions = variable_get('gradebook_attachment_settings-'. $gid, 0);
+  $attach_restrictions = (is_null($node->attach_status) || $node->attach_status == 4) ? $gradebook_attach_restrictions : $node->attach_status;
   if (!$teacher && isset($attach_restrictions)) {
     switch ($attach_restrictions) {
       case 1:
