Update of /cvsroot/aimmath/moodle/mod/math_assignment
In directory sc8-pr-cvs1:/tmp/cvs-serv26206/mod/math_assignment
Modified Files:
pdfgen.php
Added Files:
problems.tex solutions.tex
Log Message:
when no tex file is provided uses problems.tex or solutions.tex
--- NEW FILE: problems.tex ---
%123456789012345678901234567890123456789012345678901234567890123456789
\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
%Remove following six lines if not using A4 paper:
\topmargin=-0.5truecm \oddsidemargin=10pt \evensidemargin=10pt
\textheight=9 truein \textwidth=6.2 truein
\parskip=5pt plus 2pt
\newcounter{question}
\setcounter{question}{0}
\newcommand{\nextq}{\addtocounter{question}{1}\vspace{0.3truecm}
\noindent{\bf\arabic{question}.$\quad$}}
\begin{document}
\begin{center}
\bf \coursename -- \assignmentname
\end{center}
--- NEW FILE: solutions.tex ---
%123456789012345678901234567890123456789012345678901234567890123456789
\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
%Remove following six lines if not using A4 paper:
\topmargin=-0.5truecm \oddsidemargin=10pt \evensidemargin=10pt
\textheight=9 truein \textwidth=6.2 truein
\parskip=5pt plus 2pt
\newcounter{question}
\setcounter{question}{0}
\newcommand{\nextq}{\addtocounter{question}{1}\vspace{0.3truecm}
\noindent{\bf\arabic{question}.$\quad$}}
\begin{document}
\begin{center}
\bf \coursename -- \assignmentname -- Solutions
\end{center}
Index: pdfgen.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/pdfgen.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** pdfgen.php 25 Sep 2003 23:02:42 -0000 1.9
--- pdfgen.php 27 Sep 2003 09:19:27 -0000 1.10
***************
*** 39,75 ****
// Create temp directory if it doesn't exist
$tempdir = "$CFG->dataroot/temp/math_assignment/$math_assignment->id";
! mkdir("$CFG->dataroot/temp", $CFG->directorypermissions);
! mkdir("$CFG->dataroot/temp/math_assignment", $CFG->directorypermissions);
! mkdir($tempdir, $CFG->directorypermissions);
!
! // Load lecturer's tex files or use dummy and store in $latex
!
! if ($type == "problems") {
! if ($math_assignment->problemsisurl) {
! $texfile = $math_assignment->problems;
! }
! else {
! $texfile = "$CFG->dataroot/$course->id/$math_assignment->problems";
! }
! }
! else if ($type == solutions) {
! if ($math_assignment->solutionsisurl) {
! $texfile = $math_assignment->solutions;
! }
! else {
! $texfile = "$CFG->dataroot/$course->id/$math_assignment->solutions";
! }
! }
!
! if (math_assignment_is_tex_file($texfile)) {
! $latex = file_get_contents($texfile);
! }
! else {
! $latex = file_get_contents("$CFG->dirroot/mod/math_assignment/$type.tex");
! }
!
! // Insert course and assignment name if required
! $latex = str_replace("\coursename","$course->fullname",$latex);
! $latex = str_replace("\assignmentname","$math_assignment->name",$latex);
// if there is an aim quiz load it into $data
--- 39,45 ----
// Create temp directory if it doesn't exist
$tempdir = "$CFG->dataroot/temp/math_assignment/$math_assignment->id";
! @mkdir("$CFG->dataroot/temp", $CFG->directorypermissions);
! @mkdir("$CFG->dataroot/temp/math_assignment", $CFG->directorypermissions);
! @mkdir($tempdir, $CFG->directorypermissions);
// if there is an aim quiz load it into $data
***************
*** 108,112 ****
}
-
// convert images
--- 78,81 ----
***************
*** 123,134 ****
}
! // convert AiM questions or solutions in $data and add to $latex
$questions = preg_split("/id=\"question(\d+)\"/",$data);
array_shift($questions);
! foreach ($questions as $question) {
! //$latex = preg_replace("/(?<!newcommand\{)\\\aimquestion/",addslashes(math_assignment_aim_to_latex($question,$type)),$latex,1);
! $latex = str_replace_once("\aimquestion","$\\sphericalangle$ ".math_assignment_aim_to_latex($question,$type),$latex);
}
// generate pdf file from $latex
--- 92,138 ----
}
! // split into individual questions
$questions = preg_split("/id=\"question(\d+)\"/",$data);
array_shift($questions);
!
!
! // Add questions to lecturer's tex file or to dummy
!
! if ($type == "problems") {
! if ($math_assignment->problemsisurl) {
! $texfile = $math_assignment->problems;
! }
! else {
! $texfile = "$CFG->dataroot/$course->id/$math_assignment->problems";
! }
! }
! else if ($type == solutions) {
! if ($math_assignment->solutionsisurl) {
! $texfile = $math_assignment->solutions;
! }
! else {
! $texfile = "$CFG->dataroot/$course->id/$math_assignment->solutions";
! }
! }
!
! if (math_assignment_is_tex_file($texfile)) {
! $latex = file_get_contents($texfile);
! foreach ($questions as $question) {
! $latex = str_replace_once("\aimquestion","$\\sphericalangle$ ".math_assignment_aim_to_latex($question,$type),$latex);
! }
}
+ else {
+ $latex = file_get_contents("$CFG->dirroot/mod/math_assignment/$type.tex");
+ foreach ($questions as $question) {
+ $latex .= "\n\n\\nextq $\\sphericalangle$ ".math_assignment_aim_to_latex($question,$type);
+ }
+ $latex .= "\n\n\\end{document}";
+ }
+
+ // Insert course and assignment name if required
+ $latex = str_replace("\coursename","$course->fullname",$latex);
+ $latex = str_replace("\assignmentname","$math_assignment->name",$latex);
+
// generate pdf file from $latex
***************
*** 195,200 ****
// Parts
$data = preg_replace("/id=\"question(\d+).(\d+)\"/i",
! "<latex>\n\n\vspace{2mm}\\noindent{\\bf Part \$2}\n\n</latex>",$data);
// replace radio buttons
--- 199,206 ----
// Parts
+ //$data = preg_replace("/id=\"question(\d+).(\d+)\"/i",
+ // "<latex>\n\n\vspace{2mm}\\noindent{\\bf Part \$2}\n\n</latex>",$data);
$data = preg_replace("/id=\"question(\d+).(\d+)\"/i",
! "<latex>\n\n\vspace{1mm}{\\bf (\$2)} </latex>",$data);
// replace radio buttons
|