Export now saves file in correct course file area (ie, the current one).

Export now works for published courses where the teacher is not
a teacher on the 'remote' course.
See bug #3996 and bug #3985
This commit is contained in:
thepurpleblob 2005-08-30 15:13:37 +00:00
parent 7443a8c43e
commit cc93459372
2 changed files with 9 additions and 3 deletions

View file

@ -505,7 +505,7 @@ function quiz_print_cat_question_list($course, $categoryid, $quizid,
helpbutton("import", $strimportquestions, "quiz"); helpbutton("import", $strimportquestions, "quiz");
echo ' | '; echo ' | ';
} }
echo '<a href="export.php?category='.$category->id.'">'.$strexportquestions.'</a>'; echo "<a href=\"export.php?category={$category->id}&amp;courseid={$course->id}\">$strexportquestions</a>";
helpbutton("export", $strexportquestions, "quiz"); helpbutton("export", $strexportquestions, "quiz");
echo '</font></td></tr>'; echo '</font></td></tr>';

View file

@ -5,6 +5,7 @@
require_once("locallib.php"); require_once("locallib.php");
$category = required_param('category',PARAM_INT); $category = required_param('category',PARAM_INT);
$courseid = required_param('courseid',PARAM_INT);
$format = optional_param('format','', PARAM_CLEANFILE ); $format = optional_param('format','', PARAM_CLEANFILE );
$exportfilename = optional_param('exportfilename','',PARAM_CLEANFILE ); $exportfilename = optional_param('exportfilename','',PARAM_CLEANFILE );
@ -12,10 +13,14 @@
error("This wasn't a valid category!"); error("This wasn't a valid category!");
} }
if (! $course = get_record("course", "id", $category->course)) { if (! $categorycourse = get_record("course", "id", $category->course)) {
error("This category doesn't belong to a valid course!"); error("This category doesn't belong to a valid course!");
} }
if (! $course = get_record("course", "id", $courseid)) {
error("Course does not exist!");
}
require_login($course->id, false); require_login($course->id, false);
if (!isteacher($course->id)) { if (!isteacher($course->id)) {
@ -110,7 +115,7 @@
echo "<tr><td align=\"right\">\n"; echo "<tr><td align=\"right\">\n";
print_string("category", "quiz"); print_string("category", "quiz");
echo ":</td><td>"; echo ":</td><td>";
echo str_replace('&nbsp;', '', $categories[$category->id]) . " ($course->shortname)"; echo str_replace('&nbsp;', '', $category->name) . " ($categorycourse->shortname)";
echo "</td></tr>\n"; echo "</td></tr>\n";
echo "<tr><td align=\"right\">"; echo "<tr><td align=\"right\">";
@ -128,6 +133,7 @@
echo "<tr><td align=\"center\" colspan=\"2\">"; echo "<tr><td align=\"center\" colspan=\"2\">";
echo " <input type=\"hidden\" name=\"category\" value=\"$category->id\" />"; echo " <input type=\"hidden\" name=\"category\" value=\"$category->id\" />";
echo " <input type=\"hidden\" name=\"courseid\" value=\"$course->id\" />";
echo " <input type=\"submit\" name=\"save\" value=\"".get_string("exportquestions","quiz")."\" />"; echo " <input type=\"submit\" name=\"save\" value=\"".get_string("exportquestions","quiz")."\" />";
echo "</td></tr>\n"; echo "</td></tr>\n";