Update of /cvsroot/aimmath/moodle/mod/math_assignment
In directory sc8-pr-cvs1:/tmp/cvs-serv23041/mod/math_assignment
Modified Files:
index.php lib.php mod.html pdfgen.php
Log Message:
Problems and solutions links now point to pdfgen.php if the file (or URL) has a .tex extension. Also some bug fixes in the display of the links.
Index: index.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/index.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** index.php 11 Sep 2003 21:15:32 -0000 1.3
--- index.php 13 Sep 2003 13:01:16 -0000 1.4
***************
*** 118,122 ****
}
! math_assignment_get_file_urls($course->id, $math_assignment, $proburl, $solurl);
if ($teacher) {
if ($showaim && $math_assignment->aimquiz) {
--- 118,122 ----
}
! math_assignment_get_file_urls($math_assignment, $proburl, $solurl);
if ($teacher) {
if ($showaim && $math_assignment->aimquiz) {
Index: lib.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/lib.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** lib.php 10 Sep 2003 20:47:51 -0000 1.3
--- lib.php 13 Sep 2003 13:01:16 -0000 1.4
***************
*** 11,14 ****
--- 11,16 ----
/// of the new instance.
+ $math_assignment->problems = trim($math_assignment->problems);
+ $math_assignment->solutions = trim($math_assignment->solutions);
$math_assignment->timedue = make_timestamp($math_assignment->dueyear, $math_assignment->duemonth,$math_assignment->dueday, $math_assignment->duehour, $math_assignment->dueminute);
$math_assignment->timemodified = time();
***************
*** 24,27 ****
--- 26,31 ----
/// will update an existing instance with new data.
+ $math_assignment->problems = trim($math_assignment->problems);
+ $math_assignment->solutions = trim($math_assignment->solutions);
$math_assignment->timedue = make_timestamp($math_assignment->dueyear, $math_assignment->duemonth,$math_assignment->dueday, $math_assignment->duehour, $math_assignment->dueminute);
$math_assignment->timemodified = time();
***************
*** 185,212 ****
}
! function math_assignment_get_file_urls($courseid, $math_assignment, &$proburl, &$solurl) {
/// Function which creates the URLs for the problem sheet and solution sheet
global $CFG;
! if ($CFG->slasharguments) {
! $proburl = "$CFG->wwwroot/file.php/$courseid/$math_assignment->problems";
! $solurl = "$CFG->wwwroot/file.php/$courseid/$math_assignment->solutions";
! } else {
! $proburl = "$CFG->wwwroot/file.php?file=/$courseid/$math_assignment->problems";
! $solurl = "$CFG->wwwroot/file.php?file=/$courseid/$math_assignment->solutions";
}
}
! function math_assignment_get_file_links($cm, $math_assignment, $align="left") {
/// Function which prints the problem and solution sheet links
/// Note that if $align is empty we assume we are already in a paragraph, else we put the links in a paragraph
! math_assignment_get_file_urls($cm->course, $math_assignment, $proburl, $solurl);
if ($math_assignment->problems) {
if (isset($return))
$return .= "<br />\n";
else if ($align)
! $return .= "<p align=\"$align\">";
$strviewproblems = get_string("viewproblems", "math_assignment");
$return .= "<a href=\"$proburl\" target=\"problems\">$strviewproblems</a>";
--- 189,233 ----
}
! function math_assignment_get_file_urls($math_assignment, &$proburl, &$solurl) {
/// Function which creates the URLs for the problem sheet and solution sheet
global $CFG;
! if ($math_assignment->problems) {
! if(strcasecmp(substr($math_assignment->problems, -4), ".tex") == 0)
! $proburl = "pdfgen.php?id=$math_assignment->id&type=problems";
! else if ($CFG->slasharguments)
! $proburl = "$CFG->wwwroot/file.php/$math_assignment->course/$math_assignment->problems";
! else
! $proburl = "$CFG->wwwroot/file.php?file=/$math_assignment->course/$math_assignment->problems";
! }
! else
! $proburl = "";
! if ($math_assignment->solutions) {
! if(strcasecmp(substr($math_assignment->solutions, -4), ".tex") == 0)
! $solurl = "pdfgen.php?id=$math_assignment->id&type=solutions";
! else if ($CFG->slasharguments)
! $solurl = "$CFG->wwwroot/file.php/$math_assignment->course/$math_assignment->solutions";
! else
! $solurl = "$CFG->wwwroot/file.php?file=/$math_assignment->course/$math_assignment->solutions";
}
+ else
+ $solurl = "";
}
! function math_assignment_get_file_links($math_assignment, $align="left") {
/// Function which prints the problem and solution sheet links
/// Note that if $align is empty we assume we are already in a paragraph, else we put the links in a paragraph
! math_assignment_get_file_urls($math_assignment, $proburl, $solurl);
! $proburl = htmlspecialchars($proburl);
! $solurl = htmlspecialchars($solurl);
if ($math_assignment->problems) {
if (isset($return))
$return .= "<br />\n";
else if ($align)
! $return = "<p align=\"$align\">";
! else
! $return = "";
$strviewproblems = get_string("viewproblems", "math_assignment");
$return .= "<a href=\"$proburl\" target=\"problems\">$strviewproblems</a>";
***************
*** 217,236 ****
$return .= "<br />\n";
else if ($align)
! $return .= "<p align=\"$align\">";
$strviewsolutions = get_string("viewsolutions", "math_assignment");
$return .= "<a href=\"$solurl\" target=\"solutions\">$strviewsolutions</a>";
$return .= math_assignment_help_button("viewsolutions", $strviewsolutions, false);
}
! else if(($math_assignment->solutions) && isteacher($cm->course)) {
if (isset($return))
$return .= "<br />\n";
else if ($align)
! $return .= "<p align=\"$align\">";
$strviewsolutions = get_string("viewsolutions", "math_assignment");
$return .= "<a href=\"$solurl\" target=\"solutions\">$strviewsolutions (" . get_string("notavailabletostudentsyet", "math_assignment") . ")</a>";
$return .= math_assignment_help_button("viewsolutionsteacher", $strviewsolutions, false);
}
! if (isset($return) && $align){
! $return .= "</p>\n";
return $return;
}
--- 238,262 ----
$return .= "<br />\n";
else if ($align)
! $return = "<p align=\"$align\">";
! else
! $return = "";
$strviewsolutions = get_string("viewsolutions", "math_assignment");
$return .= "<a href=\"$solurl\" target=\"solutions\">$strviewsolutions</a>";
$return .= math_assignment_help_button("viewsolutions", $strviewsolutions, false);
}
! else if(($math_assignment->solutions) && isteacher($math_assignment->course)) {
if (isset($return))
$return .= "<br />\n";
else if ($align)
! $return = "<p align=\"$align\">";
! else
! $return = "";
$strviewsolutions = get_string("viewsolutions", "math_assignment");
$return .= "<a href=\"$solurl\" target=\"solutions\">$strviewsolutions (" . get_string("notavailabletostudentsyet", "math_assignment") . ")</a>";
$return .= math_assignment_help_button("viewsolutionsteacher", $strviewsolutions, false);
}
! if (isset($return)) {
! if ($align)
! $return .= "</p>\n";
return $return;
}
***************
*** 242,246 ****
$return = "";
! $filelinks = math_assignment_get_file_links($cm, $math_assignment, "");
if ($math_assignment->aimquiz) {
$return = "<p align=\"$align\">$filelinks";
--- 268,272 ----
$return = "";
! $filelinks = math_assignment_get_file_links($math_assignment, "");
if ($math_assignment->aimquiz) {
$return = "<p align=\"$align\">$filelinks";
Index: mod.html
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/mod.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** mod.html 9 Sep 2003 18:31:07 -0000 1.1
--- mod.html 13 Sep 2003 13:01:16 -0000 1.2
***************
*** 89,93 ****
$options["$dir"] = $dir;
}
! choose_from_menu ($options, "problems", $form->problems);
helpbutton("addupdate_problems", $strproblems, "math_assignment");
?>
--- 89,93 ----
$options["$dir"] = $dir;
}
! choose_from_menu ($options, "problems", $form->problems, "choose", "", "");
helpbutton("addupdate_problems", $strproblems, "math_assignment");
?>
***************
*** 107,111 ****
$options["$dir"] = $dir;
}
! choose_from_menu ($options, "solutions", $form->solutions);
helpbutton("addupdate_solutions", $strsolutions, "math_assignment");
?>
--- 107,111 ----
$options["$dir"] = $dir;
}
! choose_from_menu ($options, "solutions", $form->solutions, "choose", "", "");
helpbutton("addupdate_solutions", $strsolutions, "math_assignment");
?>
Index: pdfgen.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/pdfgen.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pdfgen.php 11 Sep 2003 14:40:55 -0000 1.1
--- pdfgen.php 13 Sep 2003 13:01:16 -0000 1.2
***************
*** 6,10 ****
require_once("lib.php");
! require_variable($id); // Course Module ID, or
optional_variable($type, "problems"); // "problems" or "solutions"
--- 6,10 ----
require_once("lib.php");
! require_variable($id); // math_assignment id
optional_variable($type, "problems"); // "problems" or "solutions"
***************
*** 15,39 ****
}
! if (! $cm = get_record("course_modules", "id", $id)) {
! error("Course Module ID was incorrect");
}
! if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
- if (! $math_assignment = get_record("math_assignment", "id", $cm->instance)) {
- error("Course module is incorrect");
- }
-
require_login($course->id);
! add_to_log($course->id, "math_assignment", "pdfgen", "pdfgen.php?id=$cm->id", "$math_assignment->id");
// check that the request is valid
if ($solutions) {
if (time() < $math_assignment->timedue) {
error("You can not view the solutions until the assignment has closed!");
}
}
--- 15,43 ----
}
! if (! $math_assignment = get_record("math_assignment", "id", $id)) {
! error("Course module is incorrect");
}
! if (! $course = get_record("course", "id", $math_assignment->course)) {
error("Course is misconfigured");
}
require_login($course->id);
! add_to_log($course->id, "math_assignment", "pdfgen", "pdfgen.php?id=$math_assignment->id", $type);
// check that the request is valid
+ if ($problems) {
+ if (strcasecmp(substr($math_assignment->problems, -4), ".tex")) {
+ error("Not a dynamic problem sheet."); // this should never happen as we only link to this page if needed
+ }
+ }
if ($solutions) {
if (time() < $math_assignment->timedue) {
error("You can not view the solutions until the assignment has closed!");
+ }
+ if (strcasecmp(substr($math_assignment->solutions, -4), ".tex")) {
+ error("Not a dynamic solution sheet."); // this should never happen as we only link to this page if needed
}
}
|