| Update of /cvsroot/aimmath/moodle/mod/math_assignment
In directory sc8-pr-cvs1:/tmp/cvs-serv21380/mod/math_assignment
Modified Files:
	mod.html 
Added Files:
	texedit.php 
Log Message:
Added an "Edit" link to mod.html which opens a new window in which the lecturer can edit the tex source of problem or solution sheets.
--- NEW FILE: texedit.php ---
<?PHP //
    require_once("../../config.php");
    
    require_variable($file);
    require_variable($id); // math_assignment id
    optional_variable($action, ""); 
    
    if (! $math_assignment = get_record("math_assignment", "id", $id)) {
        error("Course is misconfigured");
    }
    
    if (! $course = get_record("course", "id", $math_assignment->course)) {
        error("Course is misconfigured");
    }
    
    require_login($course->id);
    
    if (! isteacher($course->id) ) {
        error("Only teachers can edit files");
    }
    
    $basedir = "$CFG->dataroot/$course->id/";
    
    $strmath_assignments = get_string("modulenameplural", "math_assignment");
    $streditfile = get_string("edit", "", "<B>$file</B>");
    $navigation .= "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> -> ".
        "<a href=\"index.php?id=$course->id\">$strmath_assignments</a> -> ".
        "<a href=\"view.php?q=$id\">$math_assignment->name</a> -> ".$streditfile;
    print_header("$course->shortname: $strmath_assignments", "$course->fullname", "$navigation");
    
    if ($action == "edit") {
        $fileptr = fopen($basedir.$file,"w");
        fputs($fileptr, stripslashes($text));
        fclose($fileptr);
    }
                
    $fileptr  = fopen($basedir.$file, "r");
    $contents = fread($fileptr, filesize($basedir.$file));
    fclose($fileptr);
    print_heading("$streditfile");
    echo "<TABLE align=\"center\"><TR><TD COLSPAN=2>";
    echo "<FORM ACTION=\"texedit.php\" METHOD=\"post\" NAME=\"form\">";
    echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
    echo " <INPUT TYPE=hidden NAME=\"file\" VALUE=\"$file\">";
    echo " <INPUT TYPE=hidden NAME=\"action\" VALUE=\"edit\">";
    print_textarea(false, 25, 80, 680, 400, "text", $contents);
    echo "</TD></TR><TR><TD align=\"center\">";
    echo " <INPUT TYPE=submit VALUE=\"".get_string("savechanges")."\">";
    echo "</FORM>";
    echo "</TD><TD>";
    echo "<FORM ACTION=texedit.php METHOD=get>";
    echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
    echo " <INPUT TYPE=hidden NAME=file VALUE=\"$file\">";
    echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
    echo " <INPUT TYPE=submit VALUE=\"".get_string("cancel")."\">";
    echo "</FORM>";
    echo "</TD></TR></TABLE>";
    print_footer($course)
    
?>
Index: mod.html
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/mod.html,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** mod.html	22 Sep 2003 10:04:33 -0000	1.17
--- mod.html	24 Sep 2003 10:58:25 -0000	1.18
***************
*** 150,155 ****
--- 150,159 ----
              <?php choose_from_menu ($options, "problems", $form->problems, 
                  $strnone, "sheet_change('problems', 'list');", ""); ?>
+             <?php if (math_assignment_is_tex_file("$rootdir/$form->problems")) {
+               echo " <a href=\"$CFG->wwwroot/mod/math_assignment/texedit.php?id=$form->id&file=$form->problems\" target=\"_blank\">" . get_string("edit") . "</a>";
+             } ?>
            </td>
            <td rowspan="4"><?php helpbutton("addupdate_problems", $strproblems, "math_assignment"); ?>
+           </td>
          </tr>
          <tr>
***************
*** 195,200 ****
--- 199,208 ----
              <?php choose_from_menu ($options, "solutions", $form->solutions, 
                  $strnone, "sheet_change('solutions', 'list');", ""); ?>
+             <?php if (math_assignment_is_tex_file("$rootdir/$form->solutions")) {
+               echo " <a href=\"$CFG->wwwroot/mod/math_assignment/texedit.php?id=$form->id&file=$form->solutions\" target=\"texedit\">" . get_string("edit") . "</a>";
+             } ?>
            </td>
            <td rowspan="4"><?php helpbutton("addupdate_solutions", $strsolutions, "math_assignment"); ?>
+           </td>
          </tr>
          <tr>
 |