| Update of /cvsroot/aimmath/moodle/mod/math_assignment
In directory sc8-pr-cvs1:/tmp/cvs-serv30468/mod/math_assignment
Modified Files:
	aimpage.php config.html index.php lib.php mod.html pdfgen.php 
	servers.php version.php 
Removed Files:
	subjects.php 
Log Message:
Changed to one aim subject per course
Index: aimpage.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/aimpage.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** aimpage.php	16 Sep 2003 19:13:03 -0000	1.7
--- aimpage.php	18 Sep 2003 23:57:57 -0000	1.8
***************
*** 56,60 ****
  // Process arguments
  
!     if (!$subject = get_record("math_assignment_subject", "id", $math_assignment->aimsubject)) {
          error(get_string("noaccess", "math_assignment"));
      }
--- 56,60 ----
  // Process arguments
  
!     if (!$subject = get_record("math_assignment_subject", "course", $course->id)) {
          error(get_string("noaccess", "math_assignment"));
      }
Index: config.html
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/config.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** config.html	16 Sep 2003 14:41:38 -0000	1.2
--- config.html	18 Sep 2003 23:57:57 -0000	1.3
***************
*** 1,13 ****
  <?php
      $strautoregister = get_string("autoregister", "math_assignment");
      $strgrademultiplier = get_string("grademultiplier", "math_assignment");
      $strlatexoutput = get_string("latexoutput", "math_assignment");
-     $strserverdisplay = get_string("serverdisplay", "math_assignment");
      $straimdisplay = get_string("aimdisplay", "math_assignment");
  ?>
! <form method="post" action="module.php" name="form">
  
  <table cellpadding="9" cellspacing="0">
  <tr>
      <td colspan="3" align="center">
          <?php helpbutton ("config", get_string("help"), "math_assignment", true, true); ?>
--- 1,20 ----
  <?php
+     $straimserverconfig = get_string("aimserverconfig", "math_assignment");
      $strautoregister = get_string("autoregister", "math_assignment");
      $strgrademultiplier = get_string("grademultiplier", "math_assignment");
      $strlatexoutput = get_string("latexoutput", "math_assignment");
      $straimdisplay = get_string("aimdisplay", "math_assignment");
+     $strcoursesettings = get_string("coursesettings", "math_assignment");
+     $straimserver = get_string("aimserver", "math_assignment");
+     $straimsubject = get_string("aimsubject", "math_assignment");
+     $straimsubjectpasswd = get_string("aimsubjectpasswd", "math_assignment");
  ?>
! <form method="post" action="<?php echo $CFG->wwwroot; ?>/mod/math_assignment/saveconfig.php" name="form">
  
  <table cellpadding="9" cellspacing="0">
  <tr>
+    <td colspan="3" align="center"><a href="<?php echo $CFG->wwwroot; ?>/mod/math_assignment/servers.php"><?php echo $straimserverconfig; ?></a></td>
+ </tr>
+ <tr>
      <td colspan="3" align="center">
          <?php helpbutton ("config", get_string("help"), "math_assignment", true, true); ?>
***************
*** 42,69 ****
  </tr>
  <tr valign="top">
-     <td align="right"><p><b><?php echo "Teachers choose AiM subject" ?>:</b></p></td>
-     <td align="left"><?php
-         unset($options);
-         $options[0] = "false";
-         $options[1] = "true";
- 
-         choose_from_menu ($options, "math_assignment_teachers_choose_subject", $CFG->math_assignment_teachers_choose_subject, "", "", "");
-     ?></td>
-     <td align="left"><?php helpbutton ("config_choosesubject", "Teachers choose AiM subject", "math_assignment"); ?></td>
- </tr>
- <tr valign="top">
-     <td align="right"><p><b><?php echo $strserverdisplay; ?>:</b></p></td>
-     <td align="left"><?php
-         unset($options);
-         $options[0] = get_string("never", "math_assignment");
-         $options[1] = get_string("ifduplicates", "math_assignment");
-         $options[2] = get_string("ifmultiple", "math_assignment");
-         $options[3] = get_string("always", "math_assignment");
- 
-         choose_from_menu ($options, "math_assignment_server_display", $CFG->math_assignment_server_display, "", "", "");
-     ?></td>
-     <td align="left"><?php helpbutton ("config_serverdisplay", $strserverdisplay, "math_assignment"); ?></td>
- </tr>
- <tr valign="top">
      <td align="right"><p><b><?php echo $straimdisplay; ?>:</b></p></td>
      <td align="left"><?php
--- 49,52 ----
***************
*** 77,85 ****
      <td align="left"><?php helpbutton ("config_aimdisplay", $straimdisplay, "math_assignment"); ?></td>
  </tr>
! <tr>
!     <td colspan="3" align="center">
!         <p><a href="<?php echo $CFG->wwwroot; ?>/mod/math_assignment/servers.php"><?php print_string("aimserverconfig", "math_assignment"); ?></a></p>
!     </td>
! </tr>
  <tr>
      <td colspan="3" align="center">
--- 60,117 ----
      <td align="left"><?php helpbutton ("config_aimdisplay", $straimdisplay, "math_assignment"); ?></td>
  </tr>
! <?php
! 
!     // display rows for entering per course settings
!     if ($courses = get_courses()) {
!         ?>
!         <tr>
!             <th colspan="3" align="center"><?php echo $strcoursesettings; ?></th>
!         </tr>
!         <?php
! 
!         // get aim server
!         unset($options);
!         $servers = get_records("math_assignment_server", "", "", "name ASC");
!         foreach ($servers as $server) {
!             $option[$server->id] = $server->name;
!         }
! 
!         foreach ($courses as $course) {
!             if (!$subject = get_record("math_assignment_subject", "course", $course->id)) {
!                 $subject->name = "";
!                 $subject->server = 0;
!                 $subject->password = "";
!             }
!             echo "<tr>\n";
!             echo "<td colspan=\"3\" align=\"center\">{$course->fullname} ({$course->shortname})</td>\n";
!             echo "</tr>\n";
!             echo "<tr>\n";
!             echo "<td align=\"right\"><p><b>$straimserver : </b></p></td>\n";
!             echo "<td align=\"left\">";
!             choose_from_menu ($option, "server$course->id", $subject->server, "choose", "", 0);
!             echo "</td>\n";
!             echo "<td align=\"left\">";
!             helpbutton ("config_aimserver", $straimserver, "math_assignment");
!             echo "</td>\n";
!             echo "</tr>\n";
!             echo "<tr>\n";
!             echo "<td align=\"right\"><p><b>$straimsubject : </b></p></td>\n";
!             echo "<td align=\"left\"><input type=\"text\" name=\"name$course->id\" value=\"$subject->name\" /></td>\n";
!             echo "<td align=\"left\">";
!             helpbutton ("config_aimsubject", $straimsubject, "math_assignment");
!             echo "</td>\n";
!             echo "</tr>\n";
!             echo "<tr>\n";
!             echo "<td align=\"right\"><p><b>$straimsubjectpasswd : </b></p></td>\n";
!             echo "<td align=\"left\"><input type=\"password\" name=\"password$course->id\" value=\"$subject->password\" /></td>\n";
!             echo "<td align=\"left\">";
!             helpbutton ("config_aimsubjectpasswd", $straimsubjectpasswd, "math_assignment");
!             echo "</td>\n";
!             echo "</tr>\n";
!         }
!     }
! 
! ?>
! 
  <tr>
      <td colspan="3" align="center">
***************
*** 87,90 ****
--- 119,123 ----
      </td>
  </tr>
+ 
  </table>
  </form>
Index: index.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/index.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** index.php	13 Sep 2003 13:01:16 -0000	1.4
--- index.php	18 Sep 2003 23:57:57 -0000	1.5
***************
*** 122,126 ****
              if ($showaim && $math_assignment->aimquiz) {
                  // lookup subject
!                 if (! $subject = get_record("math_assignment_subject", "id", $math_assignment->aimsubject)) {
                      $subject->server = 0;
                      $subject->name = "Unknown";
--- 122,126 ----
              if ($showaim && $math_assignment->aimquiz) {
                  // lookup subject
!                 if (! $subject = get_record("math_assignment_subject", "course", $course->id)) {
                      $subject->server = 0;
                      $subject->name = "Unknown";
Index: lib.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/lib.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** lib.php	18 Sep 2003 11:16:16 -0000	1.13
--- lib.php	18 Sep 2003 23:57:57 -0000	1.14
***************
*** 225,252 ****
  }
  
- function math_assignment_list_all_subjects($select) {
-     global $db, $CFG;
- 
-     $rs = $db->Execute("SELECT {$CFG->prefix}math_assignment_subject.id AS id,{$CFG->prefix}math_assignment_subject.name AS subject,{$CFG->prefix}math_assignment_server.name AS server FROM {$CFG->prefix}math_assignment_subject LEFT JOIN {$CFG->prefix}math_assignment_server ON {$CFG->prefix}math_assignment_subject.server={$CFG->prefix}math_assignment_server.id ORDER BY server,subject ASC");
-     if (empty($rs))
-         return ($select == 0); // empty list
-     if ($CFG->math_assignment_server_display == 0) // never
-         $showserver = false;
-     else if ($CFG->math_assignment_server_display == 1) // duplicates
-         $showserver = count_records_sql("SELECT `name` from `{$CFG->prefix}math_assignment_subject`;") - count_records_sql("SELECT DISTINCT `name` from `{$CFG->prefix}math_assignment_subject`;");
-     else if ($CFG->math_assignment_server_display == 2) // multiple
-         $showserver = count_records_sql("SELECT `id` from `{$CFG->prefix}math_assignment_server`;") > 1;
-     else // always
-         $showserver = true;
-     while ($record = $rs->FetchRow()) {
-         if ($record['id'] == $select)
-             echo "<option selected=\"true\"";
-         else
-             echo "<option";
-         echo " value=\"{$record['id']}\">" . htmlspecialchars("{$record['subject']}" . ($showserver ? " on {$record['server']}" : "")) . "</option>\n";
-     }
-     return true;
- }
- 
  function math_assignment_help_button($page, $name, $print=true) {
  /// Function which outputs / returns the output required for a help button for this module
--- 225,228 ----
***************
*** 484,493 ****
  
      if (empty($math_assignment->aimquiz)) { // no aim questions
-         $math_assignment->aimsubject = 0;
          $math_assignment->aimgrade = 0;
          return true;
      }
  
!     if (!$subject = get_record("math_assignment_subject", "id", $math_assignment->aimsubject))
          return false;
      if (!$server = get_record("math_assignment_server", "id", $subject->server))
--- 460,468 ----
  
      if (empty($math_assignment->aimquiz)) { // no aim questions
          $math_assignment->aimgrade = 0;
          return true;
      }
  
!     if (!$subject = get_record("math_assignment_subject", "course", $math_assignment->course))
          return false;
      if (!$server = get_record("math_assignment_server", "id", $subject->server))
***************
*** 524,528 ****
  
      if (is_null($subject)) {
!         if (!$subject = get_record("math_assignment_subject", "id", $math_assignment->aimsubject))
              return false;
          $server = null;
--- 499,503 ----
  
      if (is_null($subject)) {
!         if (!$subject = get_record("math_assignment_subject", "course", $math_assignment->course))
              return false;
          $server = null;
Index: mod.html
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/mod.html,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** mod.html	18 Sep 2003 12:48:06 -0000	1.13
--- mod.html	18 Sep 2003 23:57:57 -0000	1.14
***************
*** 26,32 ****
      $form->solutionscompile = true;
  }
- if (!isset($form->aimsubject)) {
-     $form->aimsubject = 0;
- }
  if (!isset($form->aimquiz)) {
      $form->aimquiz = "";
--- 26,29 ----
***************
*** 45,54 ****
      $form->name = get_string("modulename", "math_assignment");
  
! if (!$form->aimsubject > 0) {
!     // get aimsubject from database
!     if (!$form->aimsubject = get_field("math_assignment_subject", "id", "course", $form->course)) {
!         $form->aimsubject = 0;
!     };
! }
  // Process problems and solutions
  $form->problemsurl = "";
--- 42,49 ----
      $form->name = get_string("modulename", "math_assignment");
  
! // get aimsubject from database
! if (!$aimsubject = get_field("math_assignment_subject", "name", "course", $form->course))
!     $aimsubject = 0;
! 
  // Process problems and solutions
  $form->problemsurl = "";
***************
*** 225,275 ****
          <input type="text" name="papergrade" size="10" maxlength="10" value="<?php p($form->papergrade); ?>" /> <?php
          // print the following clarification only if there can be an AiM component
!         if (($CFG->math_assignment_teachers_choose_subject > 0) or ($form->aimsubject > 0)) {
              print_string("maxgradepaperonly", "math_assignment");
-         }
          helpbutton("addupdate_maxgrade", $strmaxgrade, "math_assignment");
          ?>
      </td>
  </tr>
- 
- <?php 
- if ($CFG->math_assignment_teachers_choose_subject) {
-     ?>
-     <tr valign="top">
-     <td align="right"><p><b><?php echo "$straimsubject"; ?>:</b></p></td>
-     <td>
-         <select name="aimsubject">
-              <?php math_assignment_list_all_subjects($form->aimsubject); ?>
-         </select>
-         <?php
-         helpbutton ("addupdate_serversubject", $straimsubject, "math_assignment");
-         if (isadmin()) {
-             if (!empty($update)) {
-                 $newreturn = "update=$update";
-                 if (!empty($return)) {
-                     $newreturn .= "&return=$return";
-                 }
-             }
-             else if (isset($id) && isset($section) && isset($add)) {
-                 $newreturn = "id=$id§ion=$section&add=$add";
-             }
-             else {
-                 $newreturn = "";
-             }
-             if (!empty($newreturn)) {
-                 $newreturn = "?return=" . htmlspecialchars(urlencode($newreturn));
-             }
-             echo "<a href=\"$CFG->wwwroot/mod/math_assignment/servers.php$newreturn\">" . get_string("aimserverconfig", "math_assignment") . "</a>";
-         }
-         ?>
      </td>
      </tr>
-     <?php
- }
- else echo "<input type=\"hidden\" name=\"aimsubject\" value=\"$form->aimsubject\">";
- ?>
  
  <?php 
! if (($CFG->math_assignment_teachers_choose_subject > 0) or ($form->aimsubject > 0)) {
      ?>
      <tr valign="top">
--- 220,234 ----
          <input type="text" name="papergrade" size="10" maxlength="10" value="<?php p($form->papergrade); ?>" /> <?php
          // print the following clarification only if there can be an AiM component
!         if ($aimsubject > 0)
              print_string("maxgradepaperonly", "math_assignment");
          helpbutton("addupdate_maxgrade", $strmaxgrade, "math_assignment");
          ?>
      </td>
  </tr>
      </td>
      </tr>
  
  <?php 
! if ($aimsubject > 0) {
      ?>
      <tr valign="top">
***************
*** 277,282 ****
      <td>
          <input type="text" name="aimquiz" size="40" maxlength="255" value="<?php p($form->aimquiz); ?>" /> <?php helpbutton("addupdate_quiz", $straimquiz, "math_assignment"); ?>
!         <?php if ($form->aimsubject > 0) {
!             echo "<a href=\"$CFG->wwwroot/mod/math_assignment/subjectpage.php?id=$form->course\" target=\"suject\">AiM administration</a>";
          } ?>
      </td>
--- 236,240 ----
      <td>
          <input type="text" name="aimquiz" size="40" maxlength="255" value="<?php p($form->aimquiz); ?>" /> <?php helpbutton("addupdate_quiz", $straimquiz, "math_assignment"); ?>
!         echo "<a href=\"$CFG->wwwroot/mod/math_assignment/subjectpage.php?id=$form->course\" target=\"subject\">AiM administration</a>";
          } ?>
      </td>
Index: pdfgen.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/pdfgen.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** pdfgen.php	18 Sep 2003 20:15:12 -0000	1.4
--- pdfgen.php	18 Sep 2003 23:57:57 -0000	1.5
***************
*** 62,66 ****
      if ($math_assignment->aimquiz) {
  
!         if (!$subject = get_record("math_assignment_subject", "id", $math_assignment->aimsubject)) {
              error(get_string("noaccess", "math_assignment"));
          }
--- 62,66 ----
      if ($math_assignment->aimquiz) {
  
!         if (!$subject = get_record("math_assignment_subject", "course", $course->id)) {
              error(get_string("noaccess", "math_assignment"));
          }
Index: servers.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/servers.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** servers.php	9 Sep 2003 18:31:07 -0000	1.1
--- servers.php	18 Sep 2003 23:57:57 -0000	1.2
***************
*** 11,16 ****
      optional_variable($student_passwd); // student AiM password
      optional_variable($delete); // delete button
-     optional_variable($return); // return options (passed to mod.php to go back to add / update page)
-     $return = htmlspecialchars(stripslashes($return));
  
      if (! $site = get_site()) {
--- 11,14 ----
***************
*** 32,36 ****
                  $server = substr($server, 0, strpos($server, "(") - 1);
                  if (!$server = get_record("math_assignment_server", "name", $server)) {
!                     error(get_string("failed","math_assignment"), "servers.php?return=$return");
                  }
                  // check that there are no assignments dependent on the server
--- 30,34 ----
                  $server = substr($server, 0, strpos($server, "(") - 1);
                  if (!$server = get_record("math_assignment_server", "name", $server)) {
!                     error(get_string("failed","math_assignment"), "servers.php");
                  }
                  // check that there are no assignments dependent on the server
***************
*** 39,43 ****
                  foreach ($subjects as $subject) {
                      if (record_exists("math_assignment", "subject", $subject->id)) {
!                         error(get_string("serverinuse","math_assignment"), "servers.php?return=$return");
                      }
                  }
--- 37,41 ----
                  foreach ($subjects as $subject) {
                      if (record_exists("math_assignment", "subject", $subject->id)) {
!                         error(get_string("serverinuse","math_assignment"), "servers.php");
                      }
                  }
***************
*** 45,49 ****
                  // does the user really want to delete?
                  print_header("$site->shortname: $straimserverconfig", "$site->fullname");
!                 notice_yesno(get_string("deletequery", "math_assignment") . "<br />$server->name ($server->address)", "deleteserver.php?id=$server->id&return=$return", "servers.php?return=$return");
                  print_footer();
                  exit;
--- 43,47 ----
                  // does the user really want to delete?
                  print_header("$site->shortname: $straimserverconfig", "$site->fullname");
!                 notice_yesno(get_string("deletequery", "math_assignment") . "<br />$server->name ($server->address)", "deleteserver.php?id=$server->id", "servers.php");
                  print_footer();
                  exit;
***************
*** 87,95 ****
  
      $stradministration = get_string("administration");
      $strmanagemodules = get_string("managemodules");
!     $strmathassignmentsettings = get_string("mathassignmentsettings", "math_assignment");
  
      print_header("$site->shortname: $straimserverconfig", "$site->fullname", 
!                  "<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> -> <a href=\"$CFG->wwwroot/$CFG->admin/modules.php\">$strmanagemodules</a> -> <a href=\"$CFG->wwwroot/mod/math_assignment/config.php\">$strmathassignmentsettings</a> -> $straimserverconfig");
  
  /// Print the main part of the page
--- 85,94 ----
  
      $stradministration = get_string("administration");
+     $strconfiguration = get_string("configuration");
      $strmanagemodules = get_string("managemodules");
!     $strmathassignment = get_string("modulename", "math_assignment");
  
      print_header("$site->shortname: $straimserverconfig", "$site->fullname", 
!                  "<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> -> <a href=\"$CFG->wwwroot/$CFG->admin/configure.php\">$strconfiguration</a> -> <a href=\"$CFG->wwwroot/$CFG->admin/modules.php\">$strmanagemodules</a> -> <a href=\"$CFG->wwwroot/$CFG->admin/module.php?module=math_assignment\">$strmathassignment</a> -> $straimserverconfig");
  
  /// Print the main part of the page
***************
*** 120,143 ****
    }
  
-   // function to load manage subjects form if a server has been selected
-   function manageSubjects() {
- 
-     // check that the new item is not selected
-     frm = document.mainform;
-     server = frm.server.options[frm.server.selectedIndex].text;
-     if (server != "<?php print_string("newitem", "math_assignment") ?>") {
- 
-       // fill in server name value and submit password form
-       frm = document.subjectform;
-       frm.server.value = server.slice(0, server.indexOf("(") - 1);
-       frm.submit();
-     }
-   }
- 
  //end hiding --></script>
  
  <form name="mainform" method="post" action="<?php echo $ME ?>">
  <center>
- <input type="hidden" name="return" value="<?php echo "$return"; ?>" />
  
  <?php print_heading_with_help($straimserverconfig, "server", "math_assignment"); ?>
--- 119,126 ----
***************
*** 191,201 ****
                      </form>
                  </td>
-                 <td align="left">
-                     <form name="subjectform" method="post" action="subjects.php">
-                         <input type="hidden" name="server" value="0" />
-                         <input type="hidden" name="return" value="<?php echo "$return"; ?>" />
-                         <input type="button" name="subjects" value="<?php print_string("managesubjects","math_assignment"); ?>" onClick="manageSubjects();" />
-                     </form>
-                 </td>
              </tr>
          </table>
--- 174,177 ----
***************
*** 204,213 ****
  
  </table>
- 
- <?php
- if (!empty($return)) {
-     echo "<p><a href=\"$CFG->wwwroot/course/mod.php?$return\">" . get_string("continue") . "</a></p>";
- }
- ?>
  
  </center>
--- 180,183 ----
Index: version.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/version.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** version.php	18 Sep 2003 11:16:16 -0000	1.3
--- version.php	18 Sep 2003 23:57:57 -0000	1.4
***************
*** 6,10 ****
  /////////////////////////////////////////////////////////////////////////////////
  
! $module->version  = 2003091812;   // The (date) version of this module
  $module->cron     = 0;            // How often should cron check this module (seconds)?
  
--- 6,10 ----
  /////////////////////////////////////////////////////////////////////////////////
  
! $module->version  = 2003091900;   // The (date) version of this module
  $module->cron     = 0;            // How often should cron check this module (seconds)?
  
--- subjects.php DELETED ---
 |