From: Matt L. v. a. <we...@ma...> - 2007-06-29 19:09:54
|
Log Message: ----------- Modified Files: -------------- wwmoodle/wwassignment: lib.php Revision Data ------------- Index: lib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment/lib.php,v retrieving revision 1.14 retrieving revision 1.15 diff -Lwwassignment/lib.php -Lwwassignment/lib.php -u -r1.14 -r1.15 --- wwassignment/lib.php +++ wwassignment/lib.php @@ -152,6 +152,7 @@ /** * @desc Updates and resynchronizes all information related to the a moodle assignment <-> webwork problem set tie. +* @param The ID of the wwassignment to update. */ function wwassignment_update_instance($wwassignment) { global $COURSE; @@ -267,27 +268,6 @@ * @param integer $wwassignmentid The problem set */ function wwassignment_grades($wwassignmentid) { -/// Must return an array of grades for a given instance of this module, -/// indexed by user. It also returns a maximum allowed grade. -/// -/// $return->grades = array of grades; -/// $return->maxgrade = maximum allowed grade; -/// -/// return $return; - // here's how we compute the grade: - // NOTE: each set has P problems in it. - // NOTE: each problem may be attempted M times. - // NOTE: each problem has been attempted A times (by a given user). - // NOTE: each problem was gotten correct C times (by a given user). - // NOTE: each problem was gotten incorrect I times (by a given user). - // Thus, a users grade is: sigma(over P) C/A - // And the max score is P - // Alternately, code is provided for: - // sigma(over P) { if( C > 0) 1 else 0 } - // again with a max of P - - // redefine it here, 'cause for some reason we can't global it... - //debug_log("start grades ".$wwassignmentid); global $COURSE; $webworkclient =& new webwork_client(); $studentgrades->grades = array(); @@ -507,7 +487,7 @@ $this->client = new soap_client(WWASSIGNMENT_WEBWORK_WSDL,'wsdl'); $err = $this->client->getError(); if ($err) { - print_error("Constructor Error"); + print_error("Constructor Error $err"); } $this->defaultparams = array(); $this->defaultparams['authenKey'] = WWASSIGNMENT_WEBWORK_KEY; @@ -534,7 +514,9 @@ if(!$override) { $params = array_merge($this->defaultparams,$params); } + var_dump($params); $result = $this->client->call($functioncall,$params); + var_dump($result); //$result = call_user_func_array(array(&$this->client,$functioncall),$params); if($err = $this->client->getError()) { print_error(get_string("rpc_fault","wwassignment") . " " . $functioncall. " ". $err); @@ -717,6 +699,7 @@ * @return Returns 1 on success. */ function create_user($webworkcourse,&$userdata,$permission="0") { + echo "Creating user" . $permission; $studentid = $userid; $this->handler("add_user",array("courseName" => $webworkcourse, "record" => array( "user_id" => $userdata->username, |
From: Matt L. v. a. <we...@ma...> - 2007-07-13 21:30:34
|
Log Message: ----------- Modified Files: -------------- wwmoodle/wwquestion: questiontype.php Revision Data ------------- Index: questiontype.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwquestion/questiontype.php,v retrieving revision 1.7 retrieving revision 1.8 diff -Lwwquestion/questiontype.php -Lwwquestion/questiontype.php -u -r1.7 -r1.8 --- wwquestion/questiontype.php +++ wwquestion/questiontype.php @@ -5,7 +5,7 @@ require_once("htmlparser.php"); //Path to the WSDL file on the Webwork Server -define('PROBLEMSERVER_WSDL','http://128.151.231.20/problemserver_wsdl/'); +define('PROBLEMSERVER_WSDL','http://128.151.231.20/WSDL.wsdl'); define('PROBLEMSERVER_DISPLAYMODE','images'); @@ -253,6 +253,7 @@ //var_dump($state); $code = base64_encode($question->code); $seed = $state->responses['seed']; + echo $seed; //get answers $answerarray = array(); foreach($state->responses as $key => $value) { @@ -313,7 +314,9 @@ function get_correct_responses(&$question, &$state) { $code = base64_encode($question->code); + $seed = $state->responses['seed']; + echo $seed; //tricks checkAnswer into believing we are sending an anwer $answerarray = array(array('field'=>'','answer'=>'')); |
From: Matt L. v. a. <we...@ma...> - 2007-07-20 18:24:17
|
Log Message: ----------- Modified Files: -------------- wwmoodle/wwassignment: mod_form.php Revision Data ------------- Index: mod_form.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment/mod_form.php,v retrieving revision 1.5 retrieving revision 1.6 diff -Lwwassignment/mod_form.php -Lwwassignment/mod_form.php -u -r1.5 -r1.6 --- wwassignment/mod_form.php +++ wwassignment/mod_form.php @@ -12,7 +12,7 @@ $coursemapped = _wwassignment_mapped_course($COURSE->id); if($coursemapped == -1) { - $mform->addElement('link','mainpage',get_string('mainpage_link_desc','wwassignment'),"view.php",get_string('mainpage_link_name','wwassignment')); + $mform->addElement('link','mainpage',get_string('mainpage_link_desc','wwassignment'),"view.php?id=$COURSE->id",get_string('mainpage_link_name','wwassignment')); return; } |
From: Matt L. v. a. <we...@ma...> - 2007-09-09 02:59:46
|
Log Message: ----------- Modified Files: -------------- wwmoodle/wwquestion: README.txt display.html edit_webwork_form.php file.php questiontype.php version.php wwmoodle/wwquestion/db: install.xml wwmoodle/wwquestion/lang/en_utf8: qtype_webwork.php Added Files: ----------- wwmoodle/wwquestion: files.php locallib.php version.txt Revision Data ------------- Index: display.html =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwquestion/display.html,v retrieving revision 1.6 retrieving revision 1.7 diff -Lwwquestion/display.html -Lwwquestion/display.html -u -r1.6 -r1.7 --- wwquestion/display.html +++ wwquestion/display.html @@ -4,7 +4,7 @@ <div class="qtext"> <?php echo $problemhtml; ?> <input id="resp<?php echo $qid; ?>_seed" name="resp<?php echo $qid; ?>_seed" type="hidden" value="<?php echo $seed; ?>" /> - <input id="resp<?php echo $qid; ?>_derivedid" name="resp<?php echo $qid; ?>_derivedid" type="hidden" value="<?php echo $derivedid; ?>" /> + <input id="resp<?php echo $qid; ?>_derivationid" name="resp<?php echo $qid; ?>_derivationid" type="hidden" value="<?php echo $derivationid; ?>" /> </div> <?php if ($image) { ?> @@ -12,6 +12,8 @@ <?php } ?> <div class="ablock clearfix"> + <?php $this->print_question_submit_buttons($question, $state, $cmoptions, $options); ?> + <br> <?php if($state->event == QUESTION_EVENTGRADE) { ?> <table class="answer"> <tr class="header"> @@ -59,5 +61,5 @@ </div> <?php } ?> - <?php $this->print_question_submit_buttons($question, $state, $cmoptions, $options); ?> + </div> \ No newline at end of file --- /dev/null +++ wwquestion/version.txt @@ -0,0 +1,10 @@ +Old versions: + +Version .2 (August 2007) +* DB consistency issues fixed (thanks to Jean-Marc) +* New code checking, makes sure PG code is correct +* Images are now copied locally for faster problem loading +* Minor bug Fixes + +Version .1 (July 2007) +* Initial Release \ No newline at end of file --- /dev/null +++ wwquestion/files.php @@ -0,0 +1,839 @@ +<?php // $Id: files.php,v 1.1 2007/09/09 02:53:16 mleventi Exp $ + +// Manage all uploaded files in a course file area + +// All the Moodle-specific stuff is in this top section +// Configuration and access control occurs here. +// Must define: USER, basedir, baseweb, html_header and html_footer +// USER is a persistent variable using sessions + + require('../../../config.php'); + require($CFG->libdir.'/filelib.php'); + require($CFG->libdir.'/adminlib.php'); + require($CFG->dirroot.'/question/type/webwork/locallib.php'); + + $id = required_param('id', PARAM_INT); + $qid = required_param('qid',PARAM_INT); + $file = optional_param('file', '', PARAM_PATH); + $wdir = optional_param('wdir', '', PARAM_PATH); + $action = optional_param('action', '', PARAM_ACTION); + $name = optional_param('name', '', PARAM_FILE); + $oldname = optional_param('oldname', '', PARAM_FILE); + $choose = optional_param('choose', '', PARAM_FILE); //in fact it is always 'formname.inputname' + $userfile= optional_param('userfile','',PARAM_FILE); + $save = optional_param('save', 0, PARAM_BOOL); + $text = optional_param('text', '', PARAM_RAW); + $confirm = optional_param('confirm', 0, PARAM_BOOL); + + if ($choose) { + if (count(explode('.', $choose)) > 2) { + print_error('Incorrect format for choose parameter'); + } + } + + if (! $course = get_record("course", "id", $id) ) { + print_error("That's an invalid course id"); + } + + //access is needed + require_login($course); + require_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $course->id)); + + + $baseweb = $CFG->wwwroot; + $basedir = $CFG->dataroot; + $userid = $USER->id; + + if($qid == -1) { + $searcher = webwork_get_tmp_path(); + } else { + $searcher = webwork_get_wwquestion_path($qid); + } + $wdir = str_replace($searcher,'',$wdir); + + if ($wdir == '') { + $wdir = "/"; + } + + if ($wdir{0} != '/') { + $wdir = "/".$wdir; + } + + //prefix the filepath + if($qid == -1) { + webwork_make_tmp_dir(); + $wdir = webwork_get_tmp_path() . $wdir; + } else { + if(!$question = get_record('question_webwork','id',$qid)) { + print_error("That's an invalid question id."); + } + $wdir = webwork_get_wwquestion_path($qid) . $wdir; + } + + if (!is_dir($basedir.$wdir)) { + //html_header($course, $wdir); + print_error("Requested directory does not exist."); + } + print_header(); + switch ($action) { + + case "upload": + //html_header($course, $wdir); + require_once($CFG->dirroot.'/lib/uploadlib.php'); + + if ($save and confirm_sesskey()) { + $course->maxbytes = 0; // We are ignoring course limits + $um = new upload_manager('userfile',false,false,$course,false,0); + $dir = "$basedir$wdir"; + if ($um->process_file_uploads($dir)) { + notify(get_string('uploadedfile')); + } + // um will take care of error reporting. + displaydir($wdir); + } else { + $upload_max_filesize = get_max_upload_file_size($CFG->maxbytes); + $filesize = display_size($upload_max_filesize); + + $struploadafile = get_string("uploadafile"); + $struploadthisfile = get_string("uploadthisfile"); + $strmaxsize = get_string("maxsize", "", $filesize); + $strcancel = get_string("cancel"); + + echo "<p>$struploadafile ($strmaxsize) --> <b>$wdir</b></p>"; + echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"files.php\">"; + echo "<div>"; + echo "<table><tr><td colspan=\"2\">"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"upload\" />"; + echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />"; + upload_print_form_fragment(1,array('userfile'),null,false,null,$upload_max_filesize,0,false); + echo " </td></tr></table>"; + echo " <input type=\"submit\" name=\"save\" value=\"$struploadthisfile\" />"; + echo "</div>"; + echo "</form>"; + echo "<form action=\"files.php\" method=\"get\">"; + echo "<div>"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; + echo " <input type=\"submit\" value=\"$strcancel\" />"; + echo "</div>"; + echo "</form>"; + } + //html_footer(); + break; + + case "delete": + if ($confirm and confirm_sesskey()) { + //html_header($course, $wdir); + if (!empty($USER->filelist)) { + foreach ($USER->filelist as $file) { + $fullfile = $basedir.'/'.$file; + if (! fulldelete($fullfile)) { + echo "<br />Error: Could not delete: $fullfile"; + } + } + } + clearfilelist(); + displaydir($wdir); + //html_footer(); + + } else { + //html_header($course, $wdir); + + if (setfilelist($_POST)) { + notify(get_string('deletecheckwarning').':'); + print_simple_box_start("center"); + printfilelist($USER->filelist); + print_simple_box_end(); + echo "<br />"; + + require_once($CFG->dirroot.'/mod/resource/lib.php'); + $block = resource_delete_warning($course, $USER->filelist); + + if (empty($CFG->resource_blockdeletingfile) or $block == '') { + $optionsyes = array('id'=>$id, 'qid'=>$qid, 'wdir'=>$wdir, 'action'=>'delete', 'confirm'=>1, 'sesskey'=>sesskey(), 'choose'=>$choose); + $optionsno = array('id'=>$id, 'qid'=>$qid, 'wdir'=>$wdir, 'action'=>'cancel', 'choose'=>$choose); + notice_yesno (get_string('deletecheckfiles'), 'files.php', 'files.php', $optionsyes, $optionsno, 'post', 'get'); + } else { + + notify(get_string('warningblockingdelete', 'resource')); + $options = array('id'=>$id, 'qid'=>$qid, 'wdir'=>$wdir, 'action'=>'cancel', 'choose'=>$choose); + print_continue("files.php?id=$id&qid=$qid&wdir=$wdir&action=cancel&choose=$choose"); + } + } else { + displaydir($wdir); + } + //html_footer(); + } + break; + + case "move": + //html_header($course, $wdir); + if (($count = setfilelist($_POST)) and confirm_sesskey()) { + $USER->fileop = $action; + $USER->filesource = $wdir; + echo "<p class=\"centerpara\">"; + print_string("selectednowmove", "moodle", $count); + echo "</p>"; + } + displaydir($wdir); + //html_footer(); + break; + + case "paste": + //html_header($course, $wdir); + if (isset($USER->fileop) and ($USER->fileop == "move") and confirm_sesskey()) { + foreach ($USER->filelist as $file) { + $shortfile = basename($file); + $oldfile = $basedir.'/'.$file; + $newfile = $basedir.$wdir."/".$shortfile; + if (!rename($oldfile, $newfile)) { + echo "<p>Error: $shortfile not moved</p>"; + } + } + } + clearfilelist(); + displaydir($wdir); + //html_footer(); + break; + + case "rename": + if (($name != '') and confirm_sesskey()) { + //html_header($course, $wdir); + $name = clean_filename($name); + if (file_exists($basedir.$wdir."/".$name)) { + echo "<center>Error: $name already exists!</center>"; + } else if (!rename($basedir.$wdir."/".$oldname, $basedir.$wdir."/".$name)) { + echo "<p align=\"center\">Error: could not rename $oldname to $name</p>"; + } else { + //file was renamed now update resources if needed + require_once($CFG->dirroot.'/mod/resource/lib.php'); + resource_renamefiles($course, $wdir, $oldname, $name); + } + displaydir($wdir); + + } else { + $strrename = get_string("rename"); + $strcancel = get_string("cancel"); + $strrenamefileto = get_string("renamefileto", "moodle", $file); + //html_header($course, $wdir, "form.name"); + echo "<p>$strrenamefileto:</p>"; + echo "<table><tr><td>"; + echo "<form action=\"files.php\" method=\"post\">"; + echo "<fieldset class=\"invisiblefieldset\">"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"rename\" />"; + echo " <input type=\"hidden\" name=\"oldname\" value=\"$file\" />"; + echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />"; + echo " <input type=\"text\" name=\"name\" size=\"35\" value=\"$file\" />"; + echo " <input type=\"submit\" value=\"$strrename\" />"; + echo "</fieldset>"; + echo "</form>"; + echo "</td><td>"; + echo "<form action=\"files.php\" method=\"get\">"; + echo "<div>"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; + echo " <input type=\"submit\" value=\"$strcancel\" />"; + echo "</div>"; + echo "</form>"; + echo "</td></tr></table>"; + } + //html_footer(); + break; + + case "makedir": + if (($name != '') and confirm_sesskey()) { + //html_header($course, $wdir); + $name = clean_filename($name); + if (file_exists("$basedir$wdir/$name")) { + echo "Error: $name already exists!"; + } else if (! make_upload_directory("$wdir/$name")) { + echo "Error: could not create $name"; + } + displaydir($wdir); + + } else { + $strcreate = get_string("create"); + $strcancel = get_string("cancel"); + $strcreatefolder = get_string("createfolder", "moodle", $wdir); + //html_header($course, $wdir, "form.name"); + echo "<p>$strcreatefolder:</p>"; + echo "<table><tr><td>"; + echo "<form action=\"files.php\" method=\"post\">"; + echo "<fieldset class=\"invisiblefieldset\">"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"makedir\" />"; + echo " <input type=\"text\" name=\"name\" size=\"35\" />"; + echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />"; + echo " <input type=\"submit\" value=\"$strcreate\" />"; + echo "</fieldset>"; + echo "</form>"; + echo "</td><td>"; + echo "<form action=\"files.php\" method=\"get\">"; + echo "<div>"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; + echo " <input type=\"submit\" value=\"$strcancel\" />"; + echo "</div>"; + echo "</form>"; + echo "</td></tr></table>"; + } + //html_footer(); + break; + + case "edit": + //html_header($course, $wdir); + if (($text != '') and confirm_sesskey()) { + $fileptr = fopen($basedir.'/'.$file,"w"); + $text = preg_replace('/\x0D/', '', $text); // http://moodle.org/mod/forum/discuss.php?d=38860 + fputs($fileptr, stripslashes($text)); + fclose($fileptr); + displaydir($wdir); + + } else { + $streditfile = get_string("edit", "", "<b>$file</b>"); + $fileptr = fopen($basedir.'/'.$file, "r"); + $contents = fread($fileptr, filesize($basedir.'/'.$file)); + fclose($fileptr); + + if (mimeinfo("type", $file) == "text/html") { + $usehtmleditor = can_use_html_editor(); + } else { + $usehtmleditor = false; + } + $usehtmleditor = false; // Always keep it off for now + + print_heading("$streditfile"); + + echo "<table><tr><td colspan=\"2\">"; + echo "<form action=\"files.php\" method=\"post\">"; + echo "<div>"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"file\" value=\"$file\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"edit\" />"; + echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />"; + print_textarea($usehtmleditor, 25, 80, 680, 400, "text", $contents); + echo "</td></tr><tr><td>"; + echo " <input type=\"submit\" value=\"".get_string("savechanges")."\" />"; + echo "</div>"; + echo "</form>"; + echo "</td><td>"; + echo "<form action=\"files.php\" method=\"get\">"; + echo "<div>"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; + echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />"; + echo "</div>"; + echo "</form>"; + echo "</td></tr></table>"; + + if ($usehtmleditor) { + use_html_editor(); + } + + + } + //html_footer(); + break; + + case "zip": + if (($name != '') and confirm_sesskey()) { + //html_header($course, $wdir); + $name = clean_filename($name); + + $files = array(); + foreach ($USER->filelist as $file) { + $files[] = "$basedir/$file"; + } + + if (!zip_files($files,"$basedir$wdir/$name")) { + error(get_string("zipfileserror","error")); + } + + clearfilelist(); + displaydir($wdir); + + } else { + //html_header($course, $wdir, "form.name"); + + if (setfilelist($_POST)) { + echo "<p align=\"center\">".get_string("youareabouttocreatezip").":</p>"; + print_simple_box_start("center"); + printfilelist($USER->filelist); + print_simple_box_end(); + echo "<br />"; + echo "<p align=\"center\">".get_string("whattocallzip")."</p>"; + echo "<table><tr><td>"; + echo "<form action=\"files.php\" method=\"post\">"; + echo "<fieldset class=\"invisiblefieldset\">"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"zip\" />"; + echo " <input type=\"text\" name=\"name\" size=\"35\" value=\"new.zip\" />"; + echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />"; + echo " <input type=\"submit\" value=\"".get_string("createziparchive")."\" />"; + echo "<fieldset>"; + echo "</form>"; + echo "</td><td>"; + echo "<form action=\"files.php\" method=\"get\">"; + echo "<div>"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; + echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />"; + echo "</div>"; + echo "</form>"; + echo "</td></tr></table>"; + } else { + displaydir($wdir); + clearfilelist(); + } + } + //html_footer(); + break; + + case "unzip": + //html_header($course, $wdir); + if (($file != '') and confirm_sesskey()) { + $strok = get_string("ok"); + $strunpacking = get_string("unpacking", "", $file); + + echo "<p align=\"center\">$strunpacking:</p>"; + + $file = basename($file); + + if (!unzip_file("$basedir$wdir/$file")) { + error(get_string("unzipfileserror","error")); + } + + echo "<div style=\"text-align:center\"><form action=\"files.php\" method=\"get\">"; + echo "<div>"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; + echo " <input type=\"submit\" value=\"$strok\" />"; + echo "</div>"; + echo "</form>"; + echo "</div>"; + } else { + displaydir($wdir); + } + //html_footer(); + break; + + case "listzip": + //html_header($course, $wdir); + if (($file != '') and confirm_sesskey()) { + $strname = get_string("name"); + $strsize = get_string("size"); + $strmodified = get_string("modified"); + $strok = get_string("ok"); + $strlistfiles = get_string("listfiles", "", $file); + + echo "<p align=\"center\">$strlistfiles:</p>"; + $file = basename($file); + + include_once("$CFG->libdir/pclzip/pclzip.lib.php"); + $archive = new PclZip(cleardoubleslashes("$basedir$wdir/$file")); + if (!$list = $archive->listContent(cleardoubleslashes("$basedir$wdir"))) { + notify($archive->errorInfo(true)); + + } else { + echo "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\" width=\"640\" class=\"files\">"; + echo "<tr class=\"file\"><th align=\"left\" class=\"header name\" scope=\"col\">$strname</th><th align=\"right\" class=\"header size\" scope=\"col\">$strsize</th><th align=\"right\" class=\"header date\" scope=\"col\">$strmodified</th></tr>"; + foreach ($list as $item) { + echo "<tr>"; + print_cell("left", s($item['filename']), 'name'); + if (! $item['folder']) { + print_cell("right", display_size($item['size']), 'size'); + } else { + echo "<td> </td>"; + } + $filedate = userdate($item['mtime'], get_string("strftimedatetime")); + print_cell("right", $filedate, 'date'); + echo "</tr>"; + } + echo "</table>"; + } + echo "<br /><center><form action=\"files.php\" method=\"get\">"; + echo "<div>"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; + echo " <input type=\"submit\" value=\"$strok\" />"; + echo "</div>"; + echo "</form>"; + echo "</center>"; + } else { + displaydir($wdir); + } + //html_footer(); + break; + + case "restore": + //html_header($course, $wdir); + if (($file != '') and confirm_sesskey()) { + echo "<p align=\"center\">".get_string("youaregoingtorestorefrom").":</p>"; + print_simple_box_start("center"); + echo $file; + print_simple_box_end(); + echo "<br />"; + echo "<p align=\"center\">".get_string("areyousuretorestorethisinfo")."</p>"; + $restore_path = "$CFG->wwwroot/backup/restore.php"; + notice_yesno (get_string("areyousuretorestorethis"), + $restore_path."?id=".$id."&qid=".$qid."&file=".cleardoubleslashes($id.$wdir."/".$file)."&method=manual", + "files.php?id=$id&qid=$qid&wdir=$wdir&action=cancel"); + } else { + displaydir($wdir); + } + //html_footer(); + break; + + case "cancel": + clearfilelist(); + + default: + //html_header($course, $wdir); + displaydir($wdir); + //html_footer(); + break; +} + + +/// FILE FUNCTIONS /////////////////////////////////////////////////////////// + + +function setfilelist($VARS) { + global $USER; + + $USER->filelist = array (); + $USER->fileop = ""; + + $count = 0; + foreach ($VARS as $key => $val) { + if (substr($key,0,4) == "file") { + $count++; + $val = rawurldecode($val); + $USER->filelist[] = clean_param($val, PARAM_PATH); + } + } + return $count; +} + +function clearfilelist() { + global $USER; + + $USER->filelist = array (); + $USER->fileop = ""; +} + + +function printfilelist($filelist) { + global $CFG, $basedir; + + $strfolder = get_string("folder"); + $strfile = get_string("file"); + + foreach ($filelist as $file) { + if (is_dir($basedir.'/'.$file)) { + echo "<img src=\"$CFG->pixpath/f/folder.gif\" class=\"icon\" alt=\"$strfolder\" /> $file<br />"; + $subfilelist = array(); + $currdir = opendir($basedir.'/'.$file); + while (false !== ($subfile = readdir($currdir))) { + if ($subfile <> ".." && $subfile <> ".") { + $subfilelist[] = $file."/".$subfile; + } + } + printfilelist($subfilelist); + + } else { + $icon = mimeinfo("icon", $file); + echo "<img src=\"$CFG->pixpath/f/$icon\" class=\"icon\" alt=\"$strfile\" /> $file<br />"; + } + } +} + + +function print_cell($alignment='center', $text=' ', $class='') { + if ($class) { + $class = ' class="'.$class.'"'; + } + echo '<td align="'.$alignment.'" style="white-space:nowrap "'.$class.'>'.$text.'</td>'; +} + +function displaydir ($wdir) { +// $wdir == / or /a or /a/b/c/d etc + + global $basedir; + global $id; + global $qid; + global $USER, $CFG; + global $choose; + + $fullpath = $basedir.$wdir; + $dirlist = array(); + + $directory = opendir($fullpath); // Find all files + while (false !== ($file = readdir($directory))) { + if ($file == "." || $file == "..") { + continue; + } + + if (is_dir($fullpath."/".$file)) { + $dirlist[] = $file; + } else { + $filelist[] = $file; + } + } + closedir($directory); + + $strname = get_string("name"); + $strsize = get_string("size"); + $strmodified = get_string("modified"); + $straction = get_string("action"); + $strmakeafolder = get_string("makeafolder"); + $struploadafile = get_string("uploadafile"); + $strselectall = get_string("selectall"); + $strselectnone = get_string("deselectall"); + $strwithchosenfiles = get_string("withchosenfiles"); + $strmovetoanotherfolder = get_string("movetoanotherfolder"); + $strmovefilestohere = get_string("movefilestohere"); + $strdeletecompletely = get_string("deletecompletely"); + $strcreateziparchive = get_string("createziparchive"); + $strrename = get_string("rename"); + $stredit = get_string("edit"); + $strunzip = get_string("unzip"); + $strlist = get_string("list"); + $strrestore= get_string("restore"); + $strchoose = get_string("choose"); + $strfolder = get_string("folder"); + $strfile = get_string("file"); + + + echo "<form action=\"files.php\" method=\"post\" id=\"dirform\">"; + echo "<div>"; + echo '<input type="hidden" name="choose" value="'.$choose.'" />'; + // echo "<hr align=\"center\" noshade=\"noshade\" size=\"1\" />"; + echo "<hr/>"; + echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\" class=\"files\">"; + echo "<tr>"; + echo "<th scope=\"col\"></th>"; + echo "<th class=\"header name\" scope=\"col\">$strname</th>"; + echo "<th class=\"header size\" scope=\"col\">$strsize</th>"; + echo "<th class=\"header date\" scope=\"col\">$strmodified</th>"; + echo "<th class=\"header commands\" scope=\"col\">$straction</th>"; + echo "</tr>\n"; + + if ($wdir != "/") { + $dirlist[] = '..'; + } + + $count = 0; + + if (!empty($dirlist)) { + asort($dirlist); + foreach ($dirlist as $dir) { + echo "<tr class=\"folder\">"; + + if ($dir == '..') { + //only display parent if we are not in root of question + if($qid == -1) { + $tempstr = webwork_get_tmp_path() . '/'; + } else { + $tempstr = WWQUESTION_ROOTDIR . '/' . $qid . '/'; + } + if($tempstr != $wdir) { + $fileurl = rawurlencode(dirname($wdir)); + print_cell(); + // alt attribute intentionally empty to prevent repetition in screen reader + print_cell('left', '<a href="files.php?id='.$id.'&qid='.$qid.'&wdir='.$fileurl.'&choose='.$choose.'"><img src="'.$CFG->pixpath.'/f/parent.gif" class="icon" alt="" /> '.get_string('parentfolder').'</a>', 'name'); + print_cell(); + print_cell(); + print_cell(); + } + + } else { + $count++; + $filename = $fullpath."/".$dir; + $fileurl = rawurlencode($wdir."/".$dir); + $filesafe = rawurlencode($dir); + $filesize = display_size(get_directory_size("$fullpath/$dir")); + $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p"); + print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\" />", 'checkbox'); + print_cell("left", "<a href=\"files.php?id=$id&qid=$qid&wdir=$fileurl&choose=$choose\"><img src=\"$CFG->pixpath/f/folder.gif\" class=\"icon\" alt=\"$strfolder\" /> ".htmlspecialchars($dir)."</a>", 'name'); + print_cell("right", $filesize, 'size'); + print_cell("right", $filedate, 'date'); + print_cell("right", "<a href=\"files.php?id=$id&qid=$qid&wdir=$wdir&file=$filesafe&action=rename&choose=$choose\">$strrename</a>", 'commands'); + } + + echo "</tr>"; + } + } + + + if (!empty($filelist)) { + asort($filelist); + foreach ($filelist as $file) { + + $icon = mimeinfo("icon", $file); + + $count++; + $filename = $fullpath."/".$file; + $fileurl = trim($wdir, "/")."/$file"; + $filesafe = rawurlencode($file); + $fileurlsafe = rawurlencode($fileurl); + $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p"); + + $selectfile = trim($fileurl, "/"); + + echo "<tr class=\"file\">"; + + print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\" />", 'checkbox'); + echo "<td align=\"left\" style=\"white-space:nowrap\" class=\"name\">"; + if ($CFG->slasharguments) { + $ffurl = str_replace('//', '/', "/file.php/$fileurl"); + } else { + $ffurl = str_replace('//', '/', "/file.php?file=/$fileurl"); + } + link_to_popup_window ($ffurl, "display", + "<img src=\"$CFG->pixpath/f/$icon\" class=\"icon\" alt=\"$strfile\" /> ".htmlspecialchars($file), + 480, 640); + echo "</td>"; + + $file_size = filesize($filename); + print_cell("right", display_size($file_size), 'size'); + print_cell("right", $filedate, 'date'); + + if ($choose) { + $edittext = "<strong><a onclick=\"return set_value('$selectfile')\" href=\"#\">$strchoose</a></strong> "; + } else { + $edittext = ''; + } + + + if ($icon == "text.gif" || $icon == "html.gif") { + $edittext .= "<a href=\"files.php?id=$id&qid=$qid&wdir=$wdir&file=$fileurl&action=edit&choose=$choose\">$stredit</a>"; + } else if ($icon == "zip.gif") { + $edittext .= "<a href=\"files.php?id=$id&qid=$qid&wdir=$wdir&file=$fileurl&action=unzip&sesskey=$USER->sesskey&choose=$choose\">$strunzip</a> "; + $edittext .= "<a href=\"files.php?id=$id&qid=$qid&wdir=$wdir&file=$fileurl&action=listzip&sesskey=$USER->sesskey&choose=$choose\">$strlist</a> "; + if (!empty($CFG->backup_version) and has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) { + $edittext .= "<a href=\"files.php?id=$id&qid=$qid&wdir=$wdir&file=$filesafe&action=restore&sesskey=$USER->sesskey&choose=$choose\">$strrestore</a> "; + } + } + + print_cell("right", "$edittext <a href=\"files.php?id=$id&qid=$qid&wdir=$wdir&file=$filesafe&action=rename&choose=$choose\">$strrename</a>", 'commands'); + + echo "</tr>"; + } + } + echo "</table>"; + echo "<hr />"; + //echo "<hr width=\"640\" align=\"center\" noshade=\"noshade\" size=\"1\" />"; + + echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\">"; + echo "<tr><td>"; + echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo '<input type="hidden" name="choose" value="'.$choose.'" />'; + echo "<input type=\"hidden\" name=\"wdir\" value=\"$wdir\" /> "; + echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />"; + $options = array ( + "move" => "$strmovetoanotherfolder", + "delete" => "$strdeletecompletely", + "zip" => "$strcreateziparchive" + ); + if (!empty($count)) { + choose_from_menu ($options, "action", "", "$strwithchosenfiles...", "javascript:getElementById('dirform').submit()"); + } + echo "</td></tr></table>"; + echo "</div>"; + echo "</form>"; + echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\"><tr>"; + echo "<td align=\"center\">"; + if (!empty($USER->fileop) and ($USER->fileop == "move") and ($USER->filesource <> $wdir)) { + echo "<form action=\"files.php\" method=\"get\">"; + echo "<div>"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"paste\" />"; + echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />"; + echo " <input type=\"submit\" value=\"$strmovefilestohere\" />"; + echo "</div>"; + echo "</form>"; + } + echo "</td>"; + echo "<td align=\"right\">"; + echo "<form action=\"files.php\" method=\"get\">"; + echo "<div>"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"makedir\" />"; + echo " <input type=\"submit\" value=\"$strmakeafolder\" />"; + echo "</div>"; + echo "</form>"; + echo "</td>"; + echo "<td align=\"right\">"; + echo "<form action=\"files.php\" method=\"get\">"; //dummy form - alignment only + echo "<fieldset class=\"invisiblefieldset\">"; + echo " <input type=\"button\" value=\"$strselectall\" onclick=\"checkall();\" />"; + echo " <input type=\"button\" value=\"$strselectnone\" onclick=\"uncheckall();\" />"; + echo "</fieldset>"; + echo "</form>"; + echo "</td>"; + echo "<td align=\"right\">"; + echo "<form action=\"files.php\" method=\"get\">"; + echo "<div>"; + echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; + echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; + echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; + echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; + echo " <input type=\"hidden\" name=\"action\" value=\"upload\" />"; + echo " <input type=\"submit\" value=\"$struploadafile\" />"; + echo "</div>"; + echo "</form>"; + echo "</td></tr>"; + echo "</table>"; + echo "<hr/>"; + //echo "<hr width=\"640\" align=\"center\" noshade=\"noshade\" size=\"1\" />"; + +} + +?> + Index: README.txt =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwquestion/README.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -Lwwquestion/README.txt -Lwwquestion/README.txt -u -r1.4 -r1.5 --- wwquestion/README.txt +++ wwquestion/README.txt @@ -1,21 +1,25 @@ Webwork Question Type ---------------------- -Version: 0.2 (stable) +Version: 0.3 (stable) Released 9/9/2007 Maintainer: Matthew Leventi <mle...@gm...> CVS: cvs.webwork.rochester.edu:/webwork/cvs/system wwmoodle/wwquestion -**If your using this send me an email.** +This is a moodle questiontype module that will allow webwork questions to be asked in Moodle Quizzes and Lessons. Currently it supports many of the features found in the webwork2 system. -Whats coming soon (sept 1): -* Question Importer (alpha at CVS: cvs.webwork.rochester.edu:/webwork/cvs/system wwmoodle/wwquestion_importer) -* Applet & External Dep. support for PG files. - -Whats New: -* DB consistency issues fixed (thanks to Jean-Marc) -* New code checking, makes sure PG code is correct -* Images are now copied locally for faster problem loading -* Minor bug Fixes +* If you are using this send me an email. Feedback is appreciated. * +Current Release: +* Derivation mismatch bugs fixed. +* New Test file +* External File support! (applet,images,graphs,etc) +* Code Refactoring +* New levels of Code Checking including warnings + +PG Language: What is supported? +Simple and complex pg problems including those which use applets, images, graph generation problems, etc. + +PG Language: What is not supported? +Currently the only PG files that don't fully work are those with custom graders. Hence problems will reveal which answers the student has correct despite the showCorrectAnswer flag being off. Upgrading (from 0.1): A database column was added called codecheck. If you have data that you don't want to lose your going to have to add the new column manually to the db @@ -23,15 +27,17 @@ Then you can delete the webwork directory and recreate it from the CVS ** I am not really sure if this is backward compatible to 0.1. If you are having problems with questions edit them and submit to regenerate derived copies. + Setup: 1) Make a new folder named 'webwork' in the question/type directory. 2) Copy all the files from this directory into . 3) Point your browser to http://yourmoodle/admin to setup the question_webwork database table. Configuration: -1) Change the WSDL path variable in the webwork/questiontype.php file to point to your Webwork Problem Server's WSDL file. +1) Change the WSDL path variable in the webwork/config.php file to point to your Webwork Problem Server's WSDL file. Use: +Go into the question bank and create a new WeBWorK question. A webwork question only has three special fields. -code: Paste the perl code that renders the webwork question here. -seed: The starting seed to use to generate random problems @@ -43,7 +49,7 @@ Note: Previewing the question will use random seeds. -ex problem) +Example Problem: ##DESCRIPTION Index: version.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwquestion/version.php,v retrieving revision 1.3 retrieving revision 1.4 diff -Lwwquestion/version.php -Lwwquestion/version.php -u -r1.3 -r1.4 --- wwquestion/version.php +++ wwquestion/version.php @@ -1,5 +1,5 @@ <?PHP // $Id$ -$plugin->version = 2007082900; // TODO. +$plugin->version = 2007090700; $plugin->requires = 2006032200; ?> \ No newline at end of file Index: questiontype.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwquestion/questiontype.php,v retrieving revision 1.11 retrieving revision 1.12 diff -Lwwquestion/questiontype.php -Lwwquestion/questiontype.php -u -r1.11 -r1.12 --- wwquestion/questiontype.php +++ wwquestion/questiontype.php @@ -1,12 +1,9 @@ <?php -require_once("$CFG->libdir/soap/nusoap.php"); - -require_once("htmlparser.php"); - -//Path to the WSDL file on the Webwork Server -define('PROBLEMSERVER_WSDL','YOUR WSDL PATH HERE'); - +require_once("$CFG->dirroot/question/type/webwork/config.php"); +require_once("$CFG->dirroot/question/type/webwork/locallib.php"); +require_once("$CFG->dirroot/question/type/questiontype.php"); +require_once("$CFG->dirroot/backup/lib.php"); /** * The question type class for the webwork question type. @@ -15,7 +12,6 @@ * @author mle...@gm... * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package webwork_qtype - * **/ /** @@ -24,27 +20,32 @@ * Allows webwork questions to be used in Moodle through a new question type. */ class webwork_qtype extends default_questiontype { - + + ////////////////////////////////////////////////////////////////// + // Functions overriding default_questiontype functions + ////////////////////////////////////////////////////////////////// + + /** + * @desc Required function that names the question type. + * @return string webwork. + */ function name() { return 'webwork'; } - function _derivedquestions($derivedquestions = null) { - static $temp = null; - if($derivedquestions == null) { - return $temp; - } - $temp = $derivedquestions; - return true; + /** + * @desc Gives the label in the Create Question dropdown. + * @return string WeBWorK + */ + function menu_name() { + return 'WeBWorK'; } - + /** - * @desc Retrieves the seed and decoded code out of the question_webwork table. + * @desc Retrieves information out of question_webwork table and puts it into question object. * @return boolean to indicate success of failure. */ function get_question_options(&$question) { - // TODO code to retrieve the extra data you stored in the database into - // $question->options. if (!$record = get_record('question_webwork', 'question', $question->id)) { notify('Error: Missing question options!'); return false; @@ -53,251 +54,123 @@ $question->seed = $record->seed; $question->code = base64_decode($record->code); $question->codecheck = $record->codecheck; + //hold onto the ID of the question_webwork record $question->webworkid = $record->id; return true; } - + /** * @desc Saves the webwork question code and default seed setting into question_webwork. Will recreate all corresponding derived questions. + * @param $question object The question object holding new data. * @return boolean to indicate success of failure. */ function save_question_options($question) { - - //UPDATE OR INSERTION - if ($record = get_record("question_webwork", "question", $question->id)) { - $isupdate = true; - } else { + //determing update or insert + $oldrecord = get_record('question_webwork','question',$question->id); + if(!$oldrecord) { $isupdate = false; - unset($record); + } else { + $isupdate = true; } - //set new variables for update or insert + //set new variables for DB entry + $record = new stdClass; $record->question = $question->id; $record->codecheck = $question->codecheck; $record->code = base64_encode(stripslashes($question->code)); $record->seed = $question->seed; $record->trials = $question->trials; - - //create the derived questions and check for errors - //$results = $question->derivedquestions; - - //do the database action on question_webwork + //insert or update question in DB if($isupdate) { + //update + $record->id = $oldrecord->id; $errresult = update_record("question_webwork", $record); if (!$errresult) { - $errresult->error = "Could not update quiz webwork options! (id=$record->id)"; + $errresult->error = "Could not update question_webwork record! (id=$record->id)"; return $errresult; } } else { + //insert $errresult = insert_record("question_webwork", $record); if (!$errresult) { - $errresult->error = "Could not insert quiz webwork options!"; + $errresult->error = "Could not insert question_webwork record!"; return $errresult; } + //set the new record id $record->id = $errresult; } - - //delete the derived questions - $this->delete_derived_questions($record->id); - - //do the database action on question_webwork_derived - $err = $this->insert_derived_questions($record->id,$this->_derivedquestions()); - if($err != 0) { - return $err; + $wwquestionid = $record->id; + //copy the tmp directory to the question one + if($isupdate == false) { + rename(webwork_get_tmp_path_full(),webwork_get_wwquestion_path_full($wwquestionid)); } - return true; - } - - /** - * @desc Deletes all derived questions that are children of the ID passed in. - * @param $webworkquestionid integer The ID of the parent question - */ - function delete_derived_questions($webworkquestionid) { - delete_records("question_webwork_derived", "question_webwork", $webworkquestionid); - return true; - } - - /** - * @desc Gets derived questions from a webworkquestion record object by calling the SOAP object. - * @param $webworkquestion The record to create from - * - */ - function get_derived_questions($webworkquestion) { - //parameters needed from the webworkquestion object - $code = $webworkquestion->code; - $seed = $webworkquestion->seed; - $trials = $webworkquestion->trials; - //problem to be generated - $problem = array(); - $problem['code'] = $code; - $problem['seed'] = $seed; - - //requested # times for generation - $request = array(); - $request['trials'] = $trials; - $request['problem'] = $problem; - - //SOAP CALL - $params = array($request); - $client = new problemserver_client(); - $response = $client->handler('generateProblem',$params); - return $response; - } - - - /** - * @desc Inserts the derived questions into the DB. - * @param $parentid The parent ID of the derived questions. - * @param $derivedrecordset The recordset to create from. - */ - function insert_derived_questions($parentid,$derivedrecordset) { - - foreach($derivedrecordset as $problem) { - unset($record); - //set the parent id for the derived questions - $record->question_webwork = $parentid; - $record->html = $problem['output']; - $record->seed = $problem['seed']; - //initial insert - $result = insert_record("question_webwork_derived",$record); - if (!$result) { - $result->error = "Could not insert quiz webwork derived options!"; - return $result; - } - $record->id = $result; - - //brings image files to local drive - //THIS SHOULD ALSO DO APPLETS SOON - $err = $this->copy_derived_question_data($record); - if($err != 0) { - return $err; - } - - $result = update_record("question_webwork_derived",$record); - if(!$result) { - $result->error = "Could not update quiz webwork derived options! (id=$record->id)"; - return $result; - } - - } - return false; - } - - function copy_derived_question_data(&$derivedrecord) { - global $CFG; - //make the base directory if needed - $dir = $CFG->dataroot . '/wwquestions'; - mkdir($dir); - //make the directory for this question - $dir = $CFG->dataroot . '/wwquestions/'.$derivedrecord->id; - mkdir($dir); - - //first we need to find the image paths - $imagestocopy = array(); - $problemhtml = ""; - $unparsedhtml = base64_decode($derivedrecord->html); - $parser = new HtmlParser($unparsedhtml); - while($parser->parse()) { - if ($parser->iNodeType == NODE_TYPE_ELEMENT) { - $nodename = $parser->iNodeName; - //rewrite the images - if(($nodename == "IMG") || ($nodename == "img")) { - //found one - $srcpath = $parser->iNodeAttributes['src']; - $srcfilename = strrchr($srcpath,'/'); - $parser->iNodeAttributes['src'] = $CFG->wwwroot . "/question/type/webwork/file.php/wwquestions/" . $derivedrecord->id . '/' . $srcfilename; - //NOTE explore the possibility of having an existence check here, filenames hashed? - //copy it - $err = copy($srcpath,$CFG->dataroot.'/wwquestions/'.$derivedrecord->id.$srcfilename); - if($err == false) { - $err->error = 'Copy Failed for: '.$srcpath; - return $err; - } - - - } - } - $problemhtml .= $parser->printTag(); - } - $html = base64_encode($problemhtml); - $derivedrecord->html = $html; - return false; - } - - - /** - * @desc Deletes question from the question_webwork table - * @param integer $questionid The question being deleted - * @return boolean to indicate success of failure. - */ - function delete_question($questionid) { - //Deleting the webwork derived questions - $records = get_records('question_webwork','question',$questionid,'','id'); - foreach($records as $record) { - $this->delete_derived_questions($record->id); - } - //Deleting the webwork questions - delete_records("question_webwork", "question", $questionid); + //update the derivations + $this->_update_derivations($wwquestionid); return true; } /** - * @desc Creates an empty response before student answers a question. This contains the possibly randomized seed for that particular student. Sticky seeds are created here. + * @desc Creates an empty response before a student answers a question. This contains the possibly randomized seed for that particular student. Sticky seeds are created here. + * @param $question object The question object. + * @param $state object The state object. + * @param $cmoptions object The cmoptions containing the course ID + * @param $attempt id The attempt ID. + * @return bool true. */ function create_session_and_responses(&$question, &$state, $cmoptions, $attempt) { global $CFG,$USER; - - //directory housekeeping (insure directories are setup) - mkdir($CFG->dataroot.'/wwquestions/users'); - mkdir($CFG->dataroot.'/wwquestions/users/'.$USER->id); - - - //here we get the derived results for this question - $results = get_records("question_webwork_derived","question_webwork",$question->webworkid,'','id'); - if(!$results) { + $derivations = get_records("question_webwork_derived","question_webwork",$question->webworkid,'','id'); + if(!$derivations) { print_error(get_string('error_db_webwork_derived','qtype_webwork')); return false; } + //make sure its not 0 - if(count($results) == 0) { + if(count($derivations) == 0) { print_error(get_string('error_no_webwork_derived','qtype_webwork')); return false; } + //pick a random question based on time srand(time()); - $random = rand(0,count($results)-1); - $values = array_values($results); - $derivedid = $values[$random]->id; - - //more directory housekeeping - mkdir($CFG->dataroot.'/wwquestions/users/'.$USER->id.'/'.$derivedid); + $random = rand(0,count($derivations)-1); + $values = array_values($derivations); + $derivationid = $values[$random]->id; //get the actual data - $results = get_record('question_webwork_derived','id',$derivedid); - $state->responses['seed'] = $results->seed; - $state->responses['derivedid'] = $derivedid; + $derivation = get_record('question_webwork_derived','id',$derivationid); + //build state + $state->responses['seed'] = $derivation->seed; + $state->responses['derivationid'] = $derivation->id; + return true; + } + + /** + * @desc Deletes question from the question_webwork table + * @param integer $questionid The question being deleted + * @return boolean to indicate success of failure. + */ + function delete_question($questionid) { + //Get wwquestion from DB + $record = get_record('question_webwork','question',$questionid); + $wwquestionid = $record->id; + + //delete DB and Files + webwork_delete_wwquestion_dir($wwquestionid); + delete_records('question_webwork', 'id' , $wwquestionid); - $unparsedhtml = base64_decode($results->html); - //parse source to figure out the fields - $parser = new HtmlParser($unparsedhtml); - $currentselect = ""; - while($parser->parse()) { - if ($parser->iNodeType == NODE_TYPE_ELEMENT) { - $nodename = $parser->iNodeName; - $name = $parser->iNodeAttributes['name']; - if(($nodename == "INPUT") || ($nodename == "SELECT") || ($nodename == "TEXTAREA")) { - //THIS IS A FIELD WE NEED TO KNOW ABOUT - $state->responses['answers'][$name] = ""; - } - } - } + //delete derivations + webwork_delete_derivations_db($wwquestionid); return true; } /** * @desc Decodes and unserializes a students response into the response array carried by state + * @param $question object The question object. + * @param $state object The state that needs to be restored. + * @return bool true. */ function restore_session_and_responses(&$question, &$state) { $serializedresponse = $state->responses['']; @@ -309,10 +182,11 @@ /** * @desc Serialize, encodes and inserts a students response into the question_states table. + * @param $question object The question object for the session. + * @param $state object The state to save. + * @return true, or error on db change. */ function save_session_and_responses(&$question, &$state) { - // TODO package up the students response from the $state->responses - // array into a string and save it in the question_states.answer field. $responses = $state->responses; $serialized = serialize($responses); $serialized = base64_encode($serialized); @@ -320,7 +194,11 @@ } /** - * @desc Prints the question. Calls the Webwork Server for appropriate HTML output and image paths. + * @desc Prints the question. Calls question_webwork_derived, and prints out the html associated with derivedid. + * @param $question object The question object to print. + * @param $state object The state of the responses for the question. + * @param $cmoptions object Options containing c... [truncated message content] |
From: Matt L. v. a. <we...@ma...> - 2007-09-11 23:01:39
|
Log Message: ----------- Removed Files: ------------- wwmoodle/wwquestion/db: install.xml Revision Data ------------- --- wwquestion/db/install.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<XMLDB PATH="question/type/webwork/db" VERSION="20070903" COMMENT="XMLDB file for this question type" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd" -> - <TABLES> - <TABLE NAME="question_webwork" COMMENT="Options for webwork questions" NEXT="question_webwork_derived"> - <FIELDS> - <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="question"/> - <FIELD NAME="question" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="codecheck"/> - <FIELD NAME="codecheck" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="question" NEXT="code"/> - <FIELD NAME="code" TYPE="text" LENGTH="medium" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="codecheck" NEXT="seed"/> - <FIELD NAME="seed" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="code" NEXT="trials"/> - <FIELD NAME="trials" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" NEXT="grading" PREVIOUS="seed"/> - <FIELD NAME="grading" TYPE="int" LENGTH="10" NUTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="trials"/> - </FIELDS> - <KEYS> - <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for question_webwork" NEXT="question"/> - <KEY NAME="question" TYPE="foreign" FIELDS="question" REFTABLE="questions" REFFIELDS="id" PREVIOUS="primary"/> - </KEYS> - </TABLE> - <TABLE NAME="question_webwork_derived" COMMENT="Options for derived webwork questions" PREVIOUS="question_webwork"> - <FIELDS> - <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="question_webwork"/> - <FIELD NAME="question_webwork" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="html"/> - <FIELD NAME="html" TYPE="text" LENGTH="medium" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="question_webwork" NEXT="seed"/> - <FIELD NAME="seed" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="html"/> - </FIELDS> - <KEYS> - <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for question_webwork_derived" NEXT="question_webwork"/> - <KEY NAME="question_webwork" TYPE="foreign" FIELDS="question_webwork" REFTABLE="question_webwork" REFFIELDS="id" PREVIOUS="primary"/> - </KEYS> - </TABLE> - </TABLES> -</XMLDB> \ No newline at end of file |
From: Matt L. v. a. <we...@ma...> - 2007-09-11 23:04:46
|
Log Message: ----------- Removed Files: ------------- wwmoodle/wwquestion: config.php display.html edit_webwork_form.php file.php files.php htmlparser.php icon.gif locallib.php questiontype.php test.php version.php Revision Data ------------- --- wwquestion/config.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -//Path to the WSDL file on the Webwork Server -define('WWQUESTION_WSDL','ENTER YOUR WSDL PATH HERE','WSDL Path Test'); - -//Leave the rest alone -define('WWQUESTION_PREFIX','/wwquestions'); -define('WWQUESTION_ROOTDIR','/' . SITEID . WWQUESTION_PREFIX); - -define('WWQUESTION_RESPONSE_TIMEOUT',120); - - -?> --- wwquestion/display.html +++ /dev/null @@ -1,70 +0,0 @@ -<div class="qtext"> - <?php echo $questiontext; ?> -</div> -<div class="qtext"> - <?php echo $problemhtml; ?> - <input id="resp<?php echo $qid; ?>_seed" name="resp<?php echo $qid; ?>_seed" type="hidden" value="<?php echo $seed; ?>" /> - <input id="resp<?php echo $qid; ?>_derivationid" name="resp<?php echo $qid; ?>_derivationid" type="hidden" value="<?php echo $derivationid; ?>" /> -</div> - -<?php if ($image) { ?> - <img class="qimage" src="<?php echo $image; ?>" alt="" /> -<?php } ?> - -<div class="ablock clearfix"> - <?php $this->print_question_submit_buttons($question, $state, $cmoptions, $options); ?> - <br> - <?php if($state->event == QUESTION_EVENTGRADE) { ?> - <table class="answer"> - <tr class="header"> - - <th class="c0"></th> - <?php if($showPartiallyCorrectAnswers == 1) { ?> - <th class="c0"></th> - <th class="c0">Result</th> - <?php } ?> - <th class="c0">Answer</th> - <th class="c0">Preview</th> - <th class="c0">Evaluated</th> - <th class="c0">Errors</th> - </tr> - <?php $i = 1; ?> - <?php $row = 1; foreach ($answerfields as $answerobj) { ?> - <tr class="<?php echo 'r'.$row = $row ? 0 : 1; ?>"> - <td class="c0"> - <?php echo $i . ')'; ?> - </td> - <?php if($showPartiallyCorrectAnswers == 1) { ?> - <td class="c0"> - <?php echo question_get_feedback_image($answerobj['score']); ?> - </td> - <td class="c0" style="width: 15%;"> - <?php if($answerobj['score'] == 1) { $class = 'correct'; echo "Correct"; } else { $class = 'incorrect'; echo "Incorrect"; } ?> - </td> - <?php } ?> - <td class="c0" style="width: 15%;"> - <?php echo $answerobj['answer']; ?> - </td> - <td class="c0" style="width: 15%;"> - <?php echo $answerobj['preview']; ?> - </td> - <td class="c0" style="width: 15%;"> - <?php echo $answerobj['evaluated']; ?> - </td> - <td class="c0" style="width: 40%;"> - <?php echo $answerobj['answer_msg']; ?> - </td> - </tr> - <?php $i++; ?> - <?php } ?> - </table> - <?php } ?> - - <?php if ($feedback) { ?> - <div class="feedback"> - <?php echo $feedback; ?> - </div> - <?php } ?> - - -</div> \ No newline at end of file --- wwquestion/files.php +++ /dev/null @@ -1,839 +0,0 @@ -<?php // $Id: files.php,v 1.1 2007/09/09 02:53:16 mleventi Exp $ - -// Manage all uploaded files in a course file area - -// All the Moodle-specific stuff is in this top section -// Configuration and access control occurs here. -// Must define: USER, basedir, baseweb, html_header and html_footer -// USER is a persistent variable using sessions - - require('../../../config.php'); - require($CFG->libdir.'/filelib.php'); - require($CFG->libdir.'/adminlib.php'); - require($CFG->dirroot.'/question/type/webwork/locallib.php'); - - $id = required_param('id', PARAM_INT); - $qid = required_param('qid',PARAM_INT); - $file = optional_param('file', '', PARAM_PATH); - $wdir = optional_param('wdir', '', PARAM_PATH); - $action = optional_param('action', '', PARAM_ACTION); - $name = optional_param('name', '', PARAM_FILE); - $oldname = optional_param('oldname', '', PARAM_FILE); - $choose = optional_param('choose', '', PARAM_FILE); //in fact it is always 'formname.inputname' - $userfile= optional_param('userfile','',PARAM_FILE); - $save = optional_param('save', 0, PARAM_BOOL); - $text = optional_param('text', '', PARAM_RAW); - $confirm = optional_param('confirm', 0, PARAM_BOOL); - - if ($choose) { - if (count(explode('.', $choose)) > 2) { - print_error('Incorrect format for choose parameter'); - } - } - - if (! $course = get_record("course", "id", $id) ) { - print_error("That's an invalid course id"); - } - - //access is needed - require_login($course); - require_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $course->id)); - - - $baseweb = $CFG->wwwroot; - $basedir = $CFG->dataroot; - $userid = $USER->id; - - if($qid == -1) { - $searcher = webwork_get_tmp_path(); - } else { - $searcher = webwork_get_wwquestion_path($qid); - } - $wdir = str_replace($searcher,'',$wdir); - - if ($wdir == '') { - $wdir = "/"; - } - - if ($wdir{0} != '/') { - $wdir = "/".$wdir; - } - - //prefix the filepath - if($qid == -1) { - webwork_make_tmp_dir(); - $wdir = webwork_get_tmp_path() . $wdir; - } else { - if(!$question = get_record('question_webwork','id',$qid)) { - print_error("That's an invalid question id."); - } - $wdir = webwork_get_wwquestion_path($qid) . $wdir; - } - - if (!is_dir($basedir.$wdir)) { - //html_header($course, $wdir); - print_error("Requested directory does not exist."); - } - print_header(); - switch ($action) { - - case "upload": - //html_header($course, $wdir); - require_once($CFG->dirroot.'/lib/uploadlib.php'); - - if ($save and confirm_sesskey()) { - $course->maxbytes = 0; // We are ignoring course limits - $um = new upload_manager('userfile',false,false,$course,false,0); - $dir = "$basedir$wdir"; - if ($um->process_file_uploads($dir)) { - notify(get_string('uploadedfile')); - } - // um will take care of error reporting. - displaydir($wdir); - } else { - $upload_max_filesize = get_max_upload_file_size($CFG->maxbytes); - $filesize = display_size($upload_max_filesize); - - $struploadafile = get_string("uploadafile"); - $struploadthisfile = get_string("uploadthisfile"); - $strmaxsize = get_string("maxsize", "", $filesize); - $strcancel = get_string("cancel"); - - echo "<p>$struploadafile ($strmaxsize) --> <b>$wdir</b></p>"; - echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"files.php\">"; - echo "<div>"; - echo "<table><tr><td colspan=\"2\">"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"upload\" />"; - echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />"; - upload_print_form_fragment(1,array('userfile'),null,false,null,$upload_max_filesize,0,false); - echo " </td></tr></table>"; - echo " <input type=\"submit\" name=\"save\" value=\"$struploadthisfile\" />"; - echo "</div>"; - echo "</form>"; - echo "<form action=\"files.php\" method=\"get\">"; - echo "<div>"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; - echo " <input type=\"submit\" value=\"$strcancel\" />"; - echo "</div>"; - echo "</form>"; - } - //html_footer(); - break; - - case "delete": - if ($confirm and confirm_sesskey()) { - //html_header($course, $wdir); - if (!empty($USER->filelist)) { - foreach ($USER->filelist as $file) { - $fullfile = $basedir.'/'.$file; - if (! fulldelete($fullfile)) { - echo "<br />Error: Could not delete: $fullfile"; - } - } - } - clearfilelist(); - displaydir($wdir); - //html_footer(); - - } else { - //html_header($course, $wdir); - - if (setfilelist($_POST)) { - notify(get_string('deletecheckwarning').':'); - print_simple_box_start("center"); - printfilelist($USER->filelist); - print_simple_box_end(); - echo "<br />"; - - require_once($CFG->dirroot.'/mod/resource/lib.php'); - $block = resource_delete_warning($course, $USER->filelist); - - if (empty($CFG->resource_blockdeletingfile) or $block == '') { - $optionsyes = array('id'=>$id, 'qid'=>$qid, 'wdir'=>$wdir, 'action'=>'delete', 'confirm'=>1, 'sesskey'=>sesskey(), 'choose'=>$choose); - $optionsno = array('id'=>$id, 'qid'=>$qid, 'wdir'=>$wdir, 'action'=>'cancel', 'choose'=>$choose); - notice_yesno (get_string('deletecheckfiles'), 'files.php', 'files.php', $optionsyes, $optionsno, 'post', 'get'); - } else { - - notify(get_string('warningblockingdelete', 'resource')); - $options = array('id'=>$id, 'qid'=>$qid, 'wdir'=>$wdir, 'action'=>'cancel', 'choose'=>$choose); - print_continue("files.php?id=$id&qid=$qid&wdir=$wdir&action=cancel&choose=$choose"); - } - } else { - displaydir($wdir); - } - //html_footer(); - } - break; - - case "move": - //html_header($course, $wdir); - if (($count = setfilelist($_POST)) and confirm_sesskey()) { - $USER->fileop = $action; - $USER->filesource = $wdir; - echo "<p class=\"centerpara\">"; - print_string("selectednowmove", "moodle", $count); - echo "</p>"; - } - displaydir($wdir); - //html_footer(); - break; - - case "paste": - //html_header($course, $wdir); - if (isset($USER->fileop) and ($USER->fileop == "move") and confirm_sesskey()) { - foreach ($USER->filelist as $file) { - $shortfile = basename($file); - $oldfile = $basedir.'/'.$file; - $newfile = $basedir.$wdir."/".$shortfile; - if (!rename($oldfile, $newfile)) { - echo "<p>Error: $shortfile not moved</p>"; - } - } - } - clearfilelist(); - displaydir($wdir); - //html_footer(); - break; - - case "rename": - if (($name != '') and confirm_sesskey()) { - //html_header($course, $wdir); - $name = clean_filename($name); - if (file_exists($basedir.$wdir."/".$name)) { - echo "<center>Error: $name already exists!</center>"; - } else if (!rename($basedir.$wdir."/".$oldname, $basedir.$wdir."/".$name)) { - echo "<p align=\"center\">Error: could not rename $oldname to $name</p>"; - } else { - //file was renamed now update resources if needed - require_once($CFG->dirroot.'/mod/resource/lib.php'); - resource_renamefiles($course, $wdir, $oldname, $name); - } - displaydir($wdir); - - } else { - $strrename = get_string("rename"); - $strcancel = get_string("cancel"); - $strrenamefileto = get_string("renamefileto", "moodle", $file); - //html_header($course, $wdir, "form.name"); - echo "<p>$strrenamefileto:</p>"; - echo "<table><tr><td>"; - echo "<form action=\"files.php\" method=\"post\">"; - echo "<fieldset class=\"invisiblefieldset\">"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"rename\" />"; - echo " <input type=\"hidden\" name=\"oldname\" value=\"$file\" />"; - echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />"; - echo " <input type=\"text\" name=\"name\" size=\"35\" value=\"$file\" />"; - echo " <input type=\"submit\" value=\"$strrename\" />"; - echo "</fieldset>"; - echo "</form>"; - echo "</td><td>"; - echo "<form action=\"files.php\" method=\"get\">"; - echo "<div>"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; - echo " <input type=\"submit\" value=\"$strcancel\" />"; - echo "</div>"; - echo "</form>"; - echo "</td></tr></table>"; - } - //html_footer(); - break; - - case "makedir": - if (($name != '') and confirm_sesskey()) { - //html_header($course, $wdir); - $name = clean_filename($name); - if (file_exists("$basedir$wdir/$name")) { - echo "Error: $name already exists!"; - } else if (! make_upload_directory("$wdir/$name")) { - echo "Error: could not create $name"; - } - displaydir($wdir); - - } else { - $strcreate = get_string("create"); - $strcancel = get_string("cancel"); - $strcreatefolder = get_string("createfolder", "moodle", $wdir); - //html_header($course, $wdir, "form.name"); - echo "<p>$strcreatefolder:</p>"; - echo "<table><tr><td>"; - echo "<form action=\"files.php\" method=\"post\">"; - echo "<fieldset class=\"invisiblefieldset\">"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"makedir\" />"; - echo " <input type=\"text\" name=\"name\" size=\"35\" />"; - echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />"; - echo " <input type=\"submit\" value=\"$strcreate\" />"; - echo "</fieldset>"; - echo "</form>"; - echo "</td><td>"; - echo "<form action=\"files.php\" method=\"get\">"; - echo "<div>"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; - echo " <input type=\"submit\" value=\"$strcancel\" />"; - echo "</div>"; - echo "</form>"; - echo "</td></tr></table>"; - } - //html_footer(); - break; - - case "edit": - //html_header($course, $wdir); - if (($text != '') and confirm_sesskey()) { - $fileptr = fopen($basedir.'/'.$file,"w"); - $text = preg_replace('/\x0D/', '', $text); // http://moodle.org/mod/forum/discuss.php?d=38860 - fputs($fileptr, stripslashes($text)); - fclose($fileptr); - displaydir($wdir); - - } else { - $streditfile = get_string("edit", "", "<b>$file</b>"); - $fileptr = fopen($basedir.'/'.$file, "r"); - $contents = fread($fileptr, filesize($basedir.'/'.$file)); - fclose($fileptr); - - if (mimeinfo("type", $file) == "text/html") { - $usehtmleditor = can_use_html_editor(); - } else { - $usehtmleditor = false; - } - $usehtmleditor = false; // Always keep it off for now - - print_heading("$streditfile"); - - echo "<table><tr><td colspan=\"2\">"; - echo "<form action=\"files.php\" method=\"post\">"; - echo "<div>"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"file\" value=\"$file\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"edit\" />"; - echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />"; - print_textarea($usehtmleditor, 25, 80, 680, 400, "text", $contents); - echo "</td></tr><tr><td>"; - echo " <input type=\"submit\" value=\"".get_string("savechanges")."\" />"; - echo "</div>"; - echo "</form>"; - echo "</td><td>"; - echo "<form action=\"files.php\" method=\"get\">"; - echo "<div>"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; - echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />"; - echo "</div>"; - echo "</form>"; - echo "</td></tr></table>"; - - if ($usehtmleditor) { - use_html_editor(); - } - - - } - //html_footer(); - break; - - case "zip": - if (($name != '') and confirm_sesskey()) { - //html_header($course, $wdir); - $name = clean_filename($name); - - $files = array(); - foreach ($USER->filelist as $file) { - $files[] = "$basedir/$file"; - } - - if (!zip_files($files,"$basedir$wdir/$name")) { - error(get_string("zipfileserror","error")); - } - - clearfilelist(); - displaydir($wdir); - - } else { - //html_header($course, $wdir, "form.name"); - - if (setfilelist($_POST)) { - echo "<p align=\"center\">".get_string("youareabouttocreatezip").":</p>"; - print_simple_box_start("center"); - printfilelist($USER->filelist); - print_simple_box_end(); - echo "<br />"; - echo "<p align=\"center\">".get_string("whattocallzip")."</p>"; - echo "<table><tr><td>"; - echo "<form action=\"files.php\" method=\"post\">"; - echo "<fieldset class=\"invisiblefieldset\">"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"zip\" />"; - echo " <input type=\"text\" name=\"name\" size=\"35\" value=\"new.zip\" />"; - echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />"; - echo " <input type=\"submit\" value=\"".get_string("createziparchive")."\" />"; - echo "<fieldset>"; - echo "</form>"; - echo "</td><td>"; - echo "<form action=\"files.php\" method=\"get\">"; - echo "<div>"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; - echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />"; - echo "</div>"; - echo "</form>"; - echo "</td></tr></table>"; - } else { - displaydir($wdir); - clearfilelist(); - } - } - //html_footer(); - break; - - case "unzip": - //html_header($course, $wdir); - if (($file != '') and confirm_sesskey()) { - $strok = get_string("ok"); - $strunpacking = get_string("unpacking", "", $file); - - echo "<p align=\"center\">$strunpacking:</p>"; - - $file = basename($file); - - if (!unzip_file("$basedir$wdir/$file")) { - error(get_string("unzipfileserror","error")); - } - - echo "<div style=\"text-align:center\"><form action=\"files.php\" method=\"get\">"; - echo "<div>"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; - echo " <input type=\"submit\" value=\"$strok\" />"; - echo "</div>"; - echo "</form>"; - echo "</div>"; - } else { - displaydir($wdir); - } - //html_footer(); - break; - - case "listzip": - //html_header($course, $wdir); - if (($file != '') and confirm_sesskey()) { - $strname = get_string("name"); - $strsize = get_string("size"); - $strmodified = get_string("modified"); - $strok = get_string("ok"); - $strlistfiles = get_string("listfiles", "", $file); - - echo "<p align=\"center\">$strlistfiles:</p>"; - $file = basename($file); - - include_once("$CFG->libdir/pclzip/pclzip.lib.php"); - $archive = new PclZip(cleardoubleslashes("$basedir$wdir/$file")); - if (!$list = $archive->listContent(cleardoubleslashes("$basedir$wdir"))) { - notify($archive->errorInfo(true)); - - } else { - echo "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\" width=\"640\" class=\"files\">"; - echo "<tr class=\"file\"><th align=\"left\" class=\"header name\" scope=\"col\">$strname</th><th align=\"right\" class=\"header size\" scope=\"col\">$strsize</th><th align=\"right\" class=\"header date\" scope=\"col\">$strmodified</th></tr>"; - foreach ($list as $item) { - echo "<tr>"; - print_cell("left", s($item['filename']), 'name'); - if (! $item['folder']) { - print_cell("right", display_size($item['size']), 'size'); - } else { - echo "<td> </td>"; - } - $filedate = userdate($item['mtime'], get_string("strftimedatetime")); - print_cell("right", $filedate, 'date'); - echo "</tr>"; - } - echo "</table>"; - } - echo "<br /><center><form action=\"files.php\" method=\"get\">"; - echo "<div>"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />"; - echo " <input type=\"submit\" value=\"$strok\" />"; - echo "</div>"; - echo "</form>"; - echo "</center>"; - } else { - displaydir($wdir); - } - //html_footer(); - break; - - case "restore": - //html_header($course, $wdir); - if (($file != '') and confirm_sesskey()) { - echo "<p align=\"center\">".get_string("youaregoingtorestorefrom").":</p>"; - print_simple_box_start("center"); - echo $file; - print_simple_box_end(); - echo "<br />"; - echo "<p align=\"center\">".get_string("areyousuretorestorethisinfo")."</p>"; - $restore_path = "$CFG->wwwroot/backup/restore.php"; - notice_yesno (get_string("areyousuretorestorethis"), - $restore_path."?id=".$id."&qid=".$qid."&file=".cleardoubleslashes($id.$wdir."/".$file)."&method=manual", - "files.php?id=$id&qid=$qid&wdir=$wdir&action=cancel"); - } else { - displaydir($wdir); - } - //html_footer(); - break; - - case "cancel": - clearfilelist(); - - default: - //html_header($course, $wdir); - displaydir($wdir); - //html_footer(); - break; -} - - -/// FILE FUNCTIONS /////////////////////////////////////////////////////////// - - -function setfilelist($VARS) { - global $USER; - - $USER->filelist = array (); - $USER->fileop = ""; - - $count = 0; - foreach ($VARS as $key => $val) { - if (substr($key,0,4) == "file") { - $count++; - $val = rawurldecode($val); - $USER->filelist[] = clean_param($val, PARAM_PATH); - } - } - return $count; -} - -function clearfilelist() { - global $USER; - - $USER->filelist = array (); - $USER->fileop = ""; -} - - -function printfilelist($filelist) { - global $CFG, $basedir; - - $strfolder = get_string("folder"); - $strfile = get_string("file"); - - foreach ($filelist as $file) { - if (is_dir($basedir.'/'.$file)) { - echo "<img src=\"$CFG->pixpath/f/folder.gif\" class=\"icon\" alt=\"$strfolder\" /> $file<br />"; - $subfilelist = array(); - $currdir = opendir($basedir.'/'.$file); - while (false !== ($subfile = readdir($currdir))) { - if ($subfile <> ".." && $subfile <> ".") { - $subfilelist[] = $file."/".$subfile; - } - } - printfilelist($subfilelist); - - } else { - $icon = mimeinfo("icon", $file); - echo "<img src=\"$CFG->pixpath/f/$icon\" class=\"icon\" alt=\"$strfile\" /> $file<br />"; - } - } -} - - -function print_cell($alignment='center', $text=' ', $class='') { - if ($class) { - $class = ' class="'.$class.'"'; - } - echo '<td align="'.$alignment.'" style="white-space:nowrap "'.$class.'>'.$text.'</td>'; -} - -function displaydir ($wdir) { -// $wdir == / or /a or /a/b/c/d etc - - global $basedir; - global $id; - global $qid; - global $USER, $CFG; - global $choose; - - $fullpath = $basedir.$wdir; - $dirlist = array(); - - $directory = opendir($fullpath); // Find all files - while (false !== ($file = readdir($directory))) { - if ($file == "." || $file == "..") { - continue; - } - - if (is_dir($fullpath."/".$file)) { - $dirlist[] = $file; - } else { - $filelist[] = $file; - } - } - closedir($directory); - - $strname = get_string("name"); - $strsize = get_string("size"); - $strmodified = get_string("modified"); - $straction = get_string("action"); - $strmakeafolder = get_string("makeafolder"); - $struploadafile = get_string("uploadafile"); - $strselectall = get_string("selectall"); - $strselectnone = get_string("deselectall"); - $strwithchosenfiles = get_string("withchosenfiles"); - $strmovetoanotherfolder = get_string("movetoanotherfolder"); - $strmovefilestohere = get_string("movefilestohere"); - $strdeletecompletely = get_string("deletecompletely"); - $strcreateziparchive = get_string("createziparchive"); - $strrename = get_string("rename"); - $stredit = get_string("edit"); - $strunzip = get_string("unzip"); - $strlist = get_string("list"); - $strrestore= get_string("restore"); - $strchoose = get_string("choose"); - $strfolder = get_string("folder"); - $strfile = get_string("file"); - - - echo "<form action=\"files.php\" method=\"post\" id=\"dirform\">"; - echo "<div>"; - echo '<input type="hidden" name="choose" value="'.$choose.'" />'; - // echo "<hr align=\"center\" noshade=\"noshade\" size=\"1\" />"; - echo "<hr/>"; - echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\" class=\"files\">"; - echo "<tr>"; - echo "<th scope=\"col\"></th>"; - echo "<th class=\"header name\" scope=\"col\">$strname</th>"; - echo "<th class=\"header size\" scope=\"col\">$strsize</th>"; - echo "<th class=\"header date\" scope=\"col\">$strmodified</th>"; - echo "<th class=\"header commands\" scope=\"col\">$straction</th>"; - echo "</tr>\n"; - - if ($wdir != "/") { - $dirlist[] = '..'; - } - - $count = 0; - - if (!empty($dirlist)) { - asort($dirlist); - foreach ($dirlist as $dir) { - echo "<tr class=\"folder\">"; - - if ($dir == '..') { - //only display parent if we are not in root of question - if($qid == -1) { - $tempstr = webwork_get_tmp_path() . '/'; - } else { - $tempstr = WWQUESTION_ROOTDIR . '/' . $qid . '/'; - } - if($tempstr != $wdir) { - $fileurl = rawurlencode(dirname($wdir)); - print_cell(); - // alt attribute intentionally empty to prevent repetition in screen reader - print_cell('left', '<a href="files.php?id='.$id.'&qid='.$qid.'&wdir='.$fileurl.'&choose='.$choose.'"><img src="'.$CFG->pixpath.'/f/parent.gif" class="icon" alt="" /> '.get_string('parentfolder').'</a>', 'name'); - print_cell(); - print_cell(); - print_cell(); - } - - } else { - $count++; - $filename = $fullpath."/".$dir; - $fileurl = rawurlencode($wdir."/".$dir); - $filesafe = rawurlencode($dir); - $filesize = display_size(get_directory_size("$fullpath/$dir")); - $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p"); - print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\" />", 'checkbox'); - print_cell("left", "<a href=\"files.php?id=$id&qid=$qid&wdir=$fileurl&choose=$choose\"><img src=\"$CFG->pixpath/f/folder.gif\" class=\"icon\" alt=\"$strfolder\" /> ".htmlspecialchars($dir)."</a>", 'name'); - print_cell("right", $filesize, 'size'); - print_cell("right", $filedate, 'date'); - print_cell("right", "<a href=\"files.php?id=$id&qid=$qid&wdir=$wdir&file=$filesafe&action=rename&choose=$choose\">$strrename</a>", 'commands'); - } - - echo "</tr>"; - } - } - - - if (!empty($filelist)) { - asort($filelist); - foreach ($filelist as $file) { - - $icon = mimeinfo("icon", $file); - - $count++; - $filename = $fullpath."/".$file; - $fileurl = trim($wdir, "/")."/$file"; - $filesafe = rawurlencode($file); - $fileurlsafe = rawurlencode($fileurl); - $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p"); - - $selectfile = trim($fileurl, "/"); - - echo "<tr class=\"file\">"; - - print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\" />", 'checkbox'); - echo "<td align=\"left\" style=\"white-space:nowrap\" class=\"name\">"; - if ($CFG->slasharguments) { - $ffurl = str_replace('//', '/', "/file.php/$fileurl"); - } else { - $ffurl = str_replace('//', '/', "/file.php?file=/$fileurl"); - } - link_to_popup_window ($ffurl, "display", - "<img src=\"$CFG->pixpath/f/$icon\" class=\"icon\" alt=\"$strfile\" /> ".htmlspecialchars($file), - 480, 640); - echo "</td>"; - - $file_size = filesize($filename); - print_cell("right", display_size($file_size), 'size'); - print_cell("right", $filedate, 'date'); - - if ($choose) { - $edittext = "<strong><a onclick=\"return set_value('$selectfile')\" href=\"#\">$strchoose</a></strong> "; - } else { - $edittext = ''; - } - - - if ($icon == "text.gif" || $icon == "html.gif") { - $edittext .= "<a href=\"files.php?id=$id&qid=$qid&wdir=$wdir&file=$fileurl&action=edit&choose=$choose\">$stredit</a>"; - } else if ($icon == "zip.gif") { - $edittext .= "<a href=\"files.php?id=$id&qid=$qid&wdir=$wdir&file=$fileurl&action=unzip&sesskey=$USER->sesskey&choose=$choose\">$strunzip</a> "; - $edittext .= "<a href=\"files.php?id=$id&qid=$qid&wdir=$wdir&file=$fileurl&action=listzip&sesskey=$USER->sesskey&choose=$choose\">$strlist</a> "; - if (!empty($CFG->backup_version) and has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) { - $edittext .= "<a href=\"files.php?id=$id&qid=$qid&wdir=$wdir&file=$filesafe&action=restore&sesskey=$USER->sesskey&choose=$choose\">$strrestore</a> "; - } - } - - print_cell("right", "$edittext <a href=\"files.php?id=$id&qid=$qid&wdir=$wdir&file=$filesafe&action=rename&choose=$choose\">$strrename</a>", 'commands'); - - echo "</tr>"; - } - } - echo "</table>"; - echo "<hr />"; - //echo "<hr width=\"640\" align=\"center\" noshade=\"noshade\" size=\"1\" />"; - - echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\">"; - echo "<tr><td>"; - echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo '<input type="hidden" name="choose" value="'.$choose.'" />'; - echo "<input type=\"hidden\" name=\"wdir\" value=\"$wdir\" /> "; - echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />"; - $options = array ( - "move" => "$strmovetoanotherfolder", - "delete" => "$strdeletecompletely", - "zip" => "$strcreateziparchive" - ); - if (!empty($count)) { - choose_from_menu ($options, "action", "", "$strwithchosenfiles...", "javascript:getElementById('dirform').submit()"); - } - echo "</td></tr></table>"; - echo "</div>"; - echo "</form>"; - echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\"><tr>"; - echo "<td align=\"center\">"; - if (!empty($USER->fileop) and ($USER->fileop == "move") and ($USER->filesource <> $wdir)) { - echo "<form action=\"files.php\" method=\"get\">"; - echo "<div>"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"paste\" />"; - echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />"; - echo " <input type=\"submit\" value=\"$strmovefilestohere\" />"; - echo "</div>"; - echo "</form>"; - } - echo "</td>"; - echo "<td align=\"right\">"; - echo "<form action=\"files.php\" method=\"get\">"; - echo "<div>"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"makedir\" />"; - echo " <input type=\"submit\" value=\"$strmakeafolder\" />"; - echo "</div>"; - echo "</form>"; - echo "</td>"; - echo "<td align=\"right\">"; - echo "<form action=\"files.php\" method=\"get\">"; //dummy form - alignment only - echo "<fieldset class=\"invisiblefieldset\">"; - echo " <input type=\"button\" value=\"$strselectall\" onclick=\"checkall();\" />"; - echo " <input type=\"button\" value=\"$strselectnone\" onclick=\"uncheckall();\" />"; - echo "</fieldset>"; - echo "</form>"; - echo "</td>"; - echo "<td align=\"right\">"; - echo "<form action=\"files.php\" method=\"get\">"; - echo "<div>"; - echo ' <input type="hidden" name="choose" value="'.$choose.'" />'; - echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />"; - echo " <input type=\"hidden\" name=\"qid\" value=\"$qid\" />"; - echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />"; - echo " <input type=\"hidden\" name=\"action\" value=\"upload\" />"; - echo " <input type=\"submit\" value=\"$struploadafile\" />"; - echo "</div>"; - echo "</form>"; - echo "</td></tr>"; - echo "</table>"; - echo "<hr/>"; - //echo "<hr width=\"640\" align=\"center\" noshade=\"noshade\" size=\"1\" />"; - -} - -?> - --- wwquestion/htmlparser.php +++ /dev/null @@ -1,389 +0,0 @@ -<?php - -/* - * Copyright (c) 2003 Jose Solorzano. All rights reserved. - * Redistribution of source must retain this copyright notice. - * - * Jose Solorzano (http://jexpert.us) is a software consultant. - * - * Contributions by: - * - Leo West (performance improvements) - */ - -define ("NODE_TYPE_START",0); -define ("NODE_TYPE_ELEMENT",1); -define ("NODE_TYPE_ENDELEMENT",2); -define ("NODE_TYPE_TEXT",3); -define ("NODE_TYPE_COMMENT",4); -define ("NODE_TYPE_DONE",5); - -/** - * Class HtmlParser. - * To use, create an instance of the class passing - * HTML text. Then invoke parse() until it's false. - * When parse() returns true, $iNodeType, $iNodeName - * $iNodeValue and $iNodeAttributes are updated. - * - * To create an HtmlParser instance you may also - * use convenience functions HtmlParser_ForFile - * and HtmlParser_ForURL. - */ -class HtmlParser { - - /** - * Field iNodeType. - * May be one of the NODE_TYPE_* constants above. - */ - var $iNodeType; - - /** - * Field iNodeName. - * For elements, it's the name of the element. - */ - var $iNodeName = ""; - - /** - * Field iNodeValue. - * For text nodes, it's the text. - */ - var $iNodeValue = ""; - - /** - * Field iNodeAttributes. - * A string-indexed array containing attribute values - * of the current node. Indexes are always lowercase. - */ - var $iNodeAttributes; - - // The following fields should be - // considered private: - - var $iHtmlText; - var $iHtmlTextLength; - var $iHtmlTextIndex = 0; - var $iHtmlCurrentChar; - var $BOE_ARRAY; - var $B_ARRAY; - var $BOS_ARRAY; - - /** - * Constructor. - * Constructs an HtmlParser instance with - * the HTML text given. - */ - function HtmlParser ($aHtmlText) { - $this->iHtmlText = $aHtmlText; - $this->iHtmlTextLength = strlen($aHtmlText); - $this->iNodeAttributes = array(); - $this->setTextIndex (0); - - $this->BOE_ARRAY = array (" ", "\t", "\r", "\n", "=" ); - $this->B_ARRAY = array (" ", "\t", "\r", "\n" ); - $this->BOS_ARRAY = array (" ", "\t", "\r", "\n", "/" ); - } - - /** - * Method parse. - * Parses the next node. Returns false only if - * the end of the HTML text has been reached. - * Updates values of iNode* fields. - */ - function parse() { - $text = $this->skipToElement(); - if ($text != "") { - $this->iNodeType = NODE_TYPE_TEXT; - $this->iNodeName = "Text"; - $this->iNodeValue = $text; - return true; - } - return $this->readTag(); - } - function printTag() { - if($this->iNodeType == NODE_TYPE_ELEMENT) { - $temp = "<"; - $temp .= $this->iNodeName; - if(isset($this->iNodeAttributes['selected'])) { - $temp .= " selected"; - } - foreach($this->iNodeAttributes as $key => $value) { - if($key == 'selected') { - } else { - $temp .= " " . $key . "=" . '"' . $value . '"'; - } - } - $temp .= ">"; - } else if($this->iNodeType == NODE_TYPE_ENDELEMENT) { - $temp = "</" . $this->iNodeName . ">"; - } else if($this->iNodeType == NODE_TYPE_TEXT) { - $temp = $this->iNodeValue; - } else { - } - return $temp; - - - } - - function clearAttributes() { - $this->iNodeAttributes = array(); - } - - function readTag() { - if ($this->iCurrentChar != "<") { - $this->iNodeType = NODE_TYPE_DONE; - return false; - } - $this->clearAttributes(); - $this->skipMaxInTag ("<", 1); - if ($this->iCurrentChar == '/') { - $this->moveNext(); - $name = $this->skipToBlanksInTag(); - $this->iNodeType = NODE_TYPE_ENDELEMENT; - $this->iNodeName = $name; - $this->iNodeValue = ""; - $this->skipEndOfTag(); - return true; - } - $name = $this->skipToBlanksOrSlashInTag(); - if (!$this->isValidTagIdentifier ($name)) { - $comment = false; - if (strpos($name, "!--") === 0) { - $ppos = strpos($name, "--", 3); - if (strpos($name, "--", 3) === (strlen($name) - 2)) { - $this->iNodeType = NODE_TYPE_COMMENT; - $this->iNodeName = "Comment"; - $this->iNodeValue = "<" . $name . ">"; - $comment = true; - } - else { - $rest = $this->skipToStringInTag ("-->"); - if ($rest != "") { - $this->iNodeType = NODE_TYPE_COMMENT; - $this->iNodeName = "Comment"; - $this->iNodeValue = "<" . $name . $rest; - $comment = true; - // Already skipped end of tag - return true; - } - } - } - if (!$comment) { - $this->iNodeType = NODE_TYPE_TEXT; - $this->iNodeName = "Text"; - $this->iNodeValue = "<" . $name; - return true; - } - } - else { - $this->iNodeType = NODE_TYPE_ELEMENT; - $this->iNodeValue = ""; - $this->iNodeName = $name; - while ($this->skipBlanksInTag()) { - $attrName = $this->skipToBlanksOrEqualsInTag(); - if ($attrName != "" && $attrName != "/") { - $this->skipBlanksInTag(); - if ($this->iCurrentChar == "=") { - $this->skipEqualsInTag(); - $this->skipBlanksInTag(); - $value = $this->readValueInTag(); - $this->iNodeAttributes[strtolower($attrName)] = $value; - } - else { - $this->iNodeAttributes[strtolower($attrName)] = ""; - } - } - } - } - $this->skipEndOfTag(); - return true; - } - - function isValidTagIdentifier ($name) { - return ereg ("^[A-Za-z0-9_\\-]+$", $name); - } - - function skipBlanksInTag() { - return "" != ($this->skipInTag ($this->B_ARRAY)); - } - - function skipToBlanksOrEqualsInTag() { - return $this->skipToInTag ($this->BOE_ARRAY); - } - - function skipToBlanksInTag() { - return $this->skipToInTag ($this->B_ARRAY); - } - - function skipToBlanksOrSlashInTag() { - return $this->skipToInTag ($this->BOS_ARRAY); - } - - function skipEqualsInTag() { - return $this->skipMaxInTag ("=", 1); - } - - function readValueInTag() { - $ch = $this->iCurrentChar; - $value = ""; - if ($ch == "\"") { - $this->skipMaxInTag ("\"", 1); - $value = $this->skipToInTag ("\""); - $this->skipMaxInTag ("\"", 1); - } - else if ($ch == "'") { - $this->skipMaxInTag ("'", 1); - $value = $this->skipToInTag ("'"); - $this->skipMaxInTag ("'", 1); - } - else { - $value = $this->skipToBlanksInTag(); - } - return $value; - } - - function setTextIndex ($index) { - $this->iHtmlTextIndex = $index; - if ($index >= $this->iHtmlTextLength) { - $this->iCurrentChar = -1; - } - else { - $this->iCurrentChar = $this->iHtmlText{$index}; - } - } - - function moveNext() { - if ($this->iHtmlTextIndex < $this->iHtmlTextLength) { - $this->setTextIndex ($this->iHtmlTextIndex + 1); - return true; - } - else { - return false; - } - } - - function skipEndOfTag() { - while (($ch = $this->iCurrentChar) !== -1) { - if ($ch == ">") { - $this->moveNext(); - return; - } - $this->moveNext(); - } - } - - function skipInTag ($chars) { - $sb = ""; - while (($ch = $this->iCurrentChar) !== -1) { - if ($ch == ">") { - return $sb; - } else { - $match = false; - for ($idx = 0; $idx < count($chars); $idx++) { - if ($ch == $chars[$idx]) { - $match = true; - break; - } - } - if (!$match) { - return $sb; - } - $sb .= $ch; - $this->moveNext(); - } - } - return $sb; - } - - function skipMaxInTag ($chars, $maxChars) { - $sb = ""; - $count = 0; - while (($ch = $this->iCurrentChar) !== -1 && $count++ < $maxChars) { - if ($ch == ">") { - return $sb; - } else { - $match = false; - for ($idx = 0; $idx < count($chars); $idx++) { - if ($ch == $chars[$idx]) { - $match = true; - break; - } - } - if (!$match) { - return $sb; - } - $sb .= $ch; - $this->moveNext(); - } - } - return $sb; - } - - function skipToInTag ($chars) { - $sb = ""; - while (($ch = $this->iCurrentChar) !== -1) { - $match = $ch == ">"; - if (!$match) { - for ($idx = 0; $idx < count($chars); $idx++) { - if ($ch == $chars[$idx]) { - $match = true; - break; - } - } - } - if ($match) { - return $sb; - } - $sb .= $ch; - $this->moveNext(); - } - return $sb; - } - - function skipToElement() { - $sb = ""; - while (($ch = $this->iCurrentChar) !== -1) { - if ($ch == "<") { - return $sb; - } - $sb .= $ch; - $this->moveNext(); - } - return $sb; - } - - /** - * Returns text between current position and $needle, - * inclusive, or "" if not found. The current index is moved to a point - * after the location of $needle, or not moved at all - * if nothing is found. - */ - function skipToStringInTag ($needle) { - $pos = strpos ($this->iHtmlText, $needle, $this->iHtmlTextIndex); - if ($pos === false) { - return ""; - } - $top = $pos + strlen($needle); - $retvalue = substr ($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex); - $this->setTextIndex ($top); - return $retvalue; - } -} - -function HtmlParser_ForFile ($fileName) { - return HtmlParser_ForURL($fileName); -} - -function HtmlParser_ForURL ($url) { - $fp = fopen ($url, "r"); - $content = ""; - while (true) { - $data = fread ($fp, 8192); - if (strlen($data) == 0) { - break; - } - $content .= $data; - } - fclose ($fp); - return new HtmlParser ($content); -} - -?> --- wwquestion/version.php +++ /dev/null @@ -1,5 +0,0 @@ -<?PHP // $Id: version.php,v 1.4 2007/09/09 02:53:16 mleventi Exp $ - -$plugin->version = 2007090700; -$plugin->requires = 2006032200; -?> \ No newline at end of file --- wwquestion/test.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php -//base configuration file for moodle -require_once('../../../config.php'); - -echo "<b>Testing WeBWorK Question Type Setup</b><br>"; -echo "------------------------------------------<br>"; - -//Tests configuration file existance -echo "1) Configuration File<br>"; -require_once("$CFG->dirroot/question/type/webwork/config.php"); -echo "WSDL Path: '" . WWQUESTION_WSDL . "'<br>"; -echo "WeBWorK Question Root Directory: '" . $CFG->dataroot . WWQUESTION_ROOTDIR . "'<br>"; -echo "Success<br><br>"; - -//Tests communication to server -echo "2) Connection to WeBWorK Question Server<br>"; -require_once('locallib.php'); -$client = new webwork_client(); -echo "Initalized...<br>"; -$response = $client->handler('hello'); -echo "Connected....<br>"; -echo "Response: $response<br>"; -echo "Success<br><br>"; - -echo "All tests completed successfully.<br>"; -echo "WeBWorK Question Type is setup.<br>"; - - - - - - - -?> --- wwquestion/questiontype.php +++ /dev/null @@ -1,688 +0,0 @@ -<?php - -require_once("$CFG->dirroot/question/type/webwork/config.php"); -require_once("$CFG->dirroot/question/type/webwork/locallib.php"); -require_once("$CFG->dirroot/question/type/questiontype.php"); -require_once("$CFG->dirroot/backup/lib.php"); - -/** - * The question type class for the webwork question type. - * - * @copyright © 2007 Matthew Leventi - * @author mle...@gm... - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * @package webwork_qtype -**/ - -/** - * The webwork question class - * - * Allows webwork questions to be used in Moodle through a new question type. - */ -class webwork_qtype extends default_questiontype { - - ////////////////////////////////////////////////////////////////// - // Functions overriding default_questiontype functions - ////////////////////////////////////////////////////////////////// - - /** - * @desc Required function that names the question type. - * @return string webwork. - */ - function name() { - return 'webwork'; - } - - /** - * @desc Gives the label in the Create Question dropdown. - * @return string WeBWorK - */ - function menu_name() { - return 'WeBWorK'; - } - - /** - * @desc Retrieves information out of question_webwork table and puts it into question object. - * @return boolean to indicate success of failure. - */ - function get_question_options(&$question) { - if (!$record = get_record('question_webwork', 'question', $question->id)) { - notify('Error: Missing question options!'); - return false; - } - $question->trials = $record->trials; - $question->seed = $record->seed; - $question->code = base64_decode($record->code); - $question->codecheck = $record->codecheck; - $question->grading = $record->grading; - //hold onto the ID of the question_webwork record - $question->webworkid = $record->id; - return true; - } - - /** - * @desc Saves the webwork question code and default seed setting into question_webwork. Will recreate all corresponding derived questions. - * @param $question object The question object holding new data. - * @return boolean to indicate success of failure. - */ - function save_question_options($question) { - //determing update or insert - $oldrecord = get_record('question_webwork','question',$question->id); - if(!$oldrecord) { - $isupdate = false; - } else { - $isupdate = true; - } - //set new variables for DB entry - $record = new stdClass; - $record->question = $question->id; - $record->codecheck = $question->codecheck; - $record->code = base64_encode(stripslashes($question->code)); - $record->seed = $question->seed; - $record->trials = $question->trials; - - $results = webwork_qtype::_derivations(); - if(count($results) > 0) { - $record->grading = $results[0]['grading']; - } - - //insert or update question in DB - if($isupdate) { - //update - $record->id = $oldrecord->id; - $errresult = update_record("question_webwork", $record); - if (!$errresult) { - $errresult->error = "Could not update question_webwork record! (id=$record->id)"; - return $errresult; - } - } else { - //insert - $errresult = insert_record("question_webwork", $record); - if (!$errresult) { - $errresult->error = "Could not insert question_webwork record!"; - return $errresult; - } - //set the new record id - $record->id = $errresult; - } - $wwquestionid = $record->id; - //copy the tmp directory to the question one - if($isupdate == false) { - rename(webwork_get_tmp_path_full(),webwork_get_wwquestion_path_full($wwquestionid)); - } - - - //update the derivations - $this->_update_derivations($wwquestionid); - return true; - } - - /** - * @desc Creates an empty response before a student answers a question. This contains the possibly randomized seed for that particular student. Sticky seeds are created here. - * @param $question object The question object. - * @param $state object The state object. - * @param $cmoptions object The cmoptions containing the course ID - * @param $attempt id The attempt ID. - * @return bool true. - */ - function create_session_and_responses(&$question, &$state, $cmoptions, $attempt) { - global $CFG,$USER; - //here we get the derived results for this question - $derivations = get_records("question_webwork_derived","question_webwork",$question->webworkid,'','id'); - if(!$derivations) { - print_error(get_string('error_db_webwork_derived','qtype_webwork')); - return false; - } - - //make sure its not 0 - if(count($derivations) == 0) { - print_error(get_string('error_no_webwork_derived','qtype_webwork')); - return false; - } - - //pick a random question based on time - srand(time()); - $random = rand(0,count($derivations)-1); - $values = array_values($derivations); - $derivationid = $values[$random]->id; - - //get the actual data - $derivation = get_record('question_webwork_derived','id',$derivationid); - //build state - $state->responses['seed'] = $derivation->seed; - $state->responses['derivationid'] = $derivation->id; - return true; - } - - /** - * @desc Deletes question from the question_webwork table - * @param integer $questionid The question being deleted - * @return boolean to indicate success... [truncated message content] |
From: Matt L. v. a. <we...@ma...> - 2007-09-11 23:05:57
|
Log Message: ----------- Removed Files: ------------- wwmoodle/wwquestion/lang/en_utf8: qtype_webwork.php wwmoodle/wwquestion/lang/en_utf8/help/quiz: webwork.html Revision Data ------------- --- wwquestion/lang/en_utf8/qtype_webwork.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php // $Id: qtype_webwork.php,v 1.5 2007/09/11 20:10:03 mleventi Exp $ -/** - * The language strings for the QTYPENAME question type. - * - * @copyright © 2006 YOURNAME - * @author YOUREMAILADDRESS - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * @package YOURPACKAGENAME - *//** */ - -$string['editingwebwork'] = 'Editing WeBWorK'; -$string['webwork'] = 'WeBWorK'; - -$string['error_client_construction'] = 'Error constructing client to Problem Server. Perhaps your WSDL Path is wrong?'; -$string['error_client_call'] = 'Error in communication with the Problem Server.'; - -$string['edit_codeheader'] = 'WeBWorK Code'; -$string['edit_fileheader'] = 'WeBWorK Files'; -$string['edit_optionheader'] = 'WeBWorK Options'; -$string['edit_codecheck'] = 'Code Checking'; - $string['edit_codecheck0'] = 'Turn Off (unadvised)'; - $string['edit_codecheck1'] = 'Reject Problem Seeds w/ Errors (silent)'; - $string['edit_codecheck2'] = 'Reject Question if any Errors exist (strict)'; - $string['edit_codecheck3'] = 'Reject Problem Seeds w/ Errors or Warnings (silent)'; - $string['edit_codecheck4'] = 'Reject Question if any Errors or Warnings exist (strict)'; -$string['edit_codefile'] = 'Question File'; -$string['edit_addcodefiles'] = 'Add More Question Files'; -$string['edit_code'] = 'Code'; -$string['edit_seed'] = 'Seed'; -$string['edit_trials'] = 'Trials'; -// TODO add any other requred strings. - -?> \ No newline at end of file |
From: Matt L. v. a. <we...@ma...> - 2007-09-11 23:15:03
|
Log Message: ----------- Removed Files: ------------- wwmoodle/wwquestion/simpletest: sampleProblem.pg testquestiontype.php Revision Data ------------- --- wwquestion/simpletest/sampleProblem.pg +++ /dev/null @@ -1,30 +0,0 @@ -# marks_first_test.pg #Standard Probability Problem #Drawing colored marbles from a bag - -DOCUMENT(); - -loadMacros("PG.pl", - "PGbasicmacros.pl", - "PGchoicemacros.pl", - "PGanswermacros.pl", - "PGauxiliaryFunctions.pl"); - -TEXT(beginproblem()); -$showPartialCorrectAnswers = 0; - -$total = random(15,25,1); -$some = random(5,10,1); - -BEGIN_TEXT; -You own $total CDs. You want to randomly arrange $some of them in a CD rack. -What is the probability that the rack ends up in alphabetical order? -$BR -$BR -The probability that the CDs are in alphabetical order is \{ans_rule(15)\}. -END_TEXT - -$ans = 1/fact($some); - -ANS(num_cmp($ans, mode => 'std')); - -ENDDOCUMENT(); - --- wwquestion/simpletest/testquestiontype.php +++ /dev/null @@ -1,153 +0,0 @@ -<?php -require_once(dirname(__FILE__) . '/../../../../config.php'); - -global $CFG; -require_once($CFG->libdir . '/simpletestlib.php'); -require_once($CFG->dirroot . '/question/type/webwork/questiontype.php'); -require_once($CFG->dirroot . '/question/type/webwork/locallib.php'); -require_once($CFG->dirroot . '/question/type/webwork/config.php'); - - -class webwork_qtype_test extends UnitTestCase { - var $qtype; - var $questioncode; - - function setUp() { - global $CFG; - $this->qtype = new webwork_qtype(); - $filepath = $CFG->dirroot . '/question/type/webwork/simpletest/sampleProblem.pg'; - if(!file_exists($filepath)) { - die('Test PG file doesnt exist.'); - } - $this->questioncode = file_get_contents($filepath); - } - - function tearDown() { - $this->qtype = null; - } - - /** - * @desc Test Module Name. - */ - function test_name() { - $this->assertEqual($this->qtype->name(),'webwork','Module Test'); - } - - /** - * @desc Test WSDL Path is set. - */ - function test_wsdl_path() { - $this->assertNotEqual(WWQUESTION_WSDL,'ENTER YOUR WSDL PATH HERE','WSDL Path Test'); - } - - /** - * @desc Test Menu Name - */ - function test_menu_name() { - $this->assertEqual($this->qtype->menu_name(),'WeBWorK','Menu Test'); - } - - /** - * @desc Test Basic Communication - */ - function test_basic_communication() { - $client = new webwork_client(); - $response = $client->handler('hello'); - $this->assertEqual('hello world!',$response,'Webwork Server Communication Test.'); - } - - /** - * @desc Test that problem is rendered - */ - function test_render_communication() { - $question->code = base64_encode(stripslashes($this->questioncode)); - $question->trials = 10; - $question->seed = 0; - $results = webwork_get_derivations($question); - $numresults = count($results); - $warning = false; - $error = false; - $ret = $this->assertEqual('10',$numresults,'PG Count Test'); - if($ret) { - foreach($results as $record) { - if((isset($record['errors'])) && ($record['errors'] != '') && ($record['errors'] != null)) { - $error = true; - $theerror = $record['errors']; - //$this->assertEqual(false,true); - } - if((isset($record['warnings'])) && ($record['warnings'] != '') && ($record['warnings'] != null)) { - $warning = true; - //$this->assertEqual(false,true); - } - } - } - $this->assertEqual(false,$error,'Sample PG Error Test'); - $this->assertEqual(false,$warning,'Sample PG Warning Test'); - } - - /** - * @desc Test creation of a wwquestion directory - */ - function test_create_wwquestion_directory() { - webwork_make_wwquestion_dir('SIMPLETEST'); - $path = webwork_get_wwquestion_path_full('SIMPLETEST'); - $this->assertEqual(is_dir($path),true,'Webwork Question Directory Creation Test.'); - webwork_delete_wwquestion_dir('SIMPLETEST'); - } - - /** - * @desc Test creation of a derivation directory - */ - function test_create_derivation_directory() { - webwork_make_derivation_dir('SIMPLETEST','SIMPLETEST'); - $path = webwork_get_derivation_path_full('SIMPLETEST','SIMPLETEST'); - $this->assertEqual(is_dir($path),true,'Webwork Derivation Directory Test.'); - webwork_delete_derivation_dir('SIMPLETEST','SIMPLETEST'); - } - -// function test_get_question_options() { -// } -// -// function test_get_numerical_units() { -// } -// -// function test_get_default_numerical_unit() { -// } -// -// function test_save_question_options() { -// } -// -// function test_save_numerical_units() { -// } -// -// function test_delete_question() { -// } -// -// function test_compare_responses() { -// } -// -// function test_test_response() { -// } -// -// function test_check_response(){ -// } -// -// function test_grade_responses() { -// } -// -// function test_get_correct_responses() { -// } -// -// function test_get_all_responses() { -// } - - -// function test_backup() { -// } -// -// function test_restore() { -// } -} - -?> - |
From: Matt L. v. a. <we...@ma...> - 2007-09-11 23:16:11
|
Log Message: ----------- Removed Files: ------------- wwmoodle/wwquestion/lang/en_utf8/help/webwork: code.html codecheck.html codeheader.html fileheader.html seed.html trials.html webwork.html Revision Data ------------- --- wwquestion/lang/en_utf8/help/webwork/webwork.html +++ /dev/null @@ -1,4 +0,0 @@ -<p align="center"><b>WeBWorK</b></p> - -<p>TODO describe your question type and how to edit it here. This help file is -linked to from the top of the question editing form for you question type.</p> |
From: Matt L. v. a. <we...@ma...> - 2007-09-13 00:33:47
|
Log Message: ----------- Modified Files: -------------- wwmoodle/wwquestion/moodle/lang/en_utf8/help/quiz: webwork.html wwmoodle/wwquestion/moodle/lang/en_utf8/help/webwork: code.html codecheck.html fileheader.html seed.html trials.html Removed Files: ------------- wwmoodle/wwquestion/moodle/lang/en_utf8/help/webwork: codeheader.html webwork.html Revision Data ------------- Index: webwork.html =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwquestion/moodle/lang/en_utf8/help/quiz/webwork.html,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwquestion/moodle/lang/en_utf8/help/quiz/webwork.html -Lwwquestion/moodle/lang/en_utf8/help/quiz/webwork.html -u -r1.1 -r1.2 --- wwquestion/moodle/lang/en_utf8/help/quiz/webwork.html +++ wwquestion/moodle/lang/en_utf8/help/quiz/webwork.html @@ -0,0 +1,3 @@ +<h1>WeBWorK questions</h1> + +<p>This is a WeBWorK question within Moodle. For information on each of the fields click the corresponding help icon.</p> --- wwquestion/moodle/lang/en_utf8/help/webwork/webwork.html +++ /dev/null @@ -1,4 +0,0 @@ -<p align="center"><b>WeBWorK</b></p> - -<p>TODO describe your question type and how to edit it here. This help file is -linked to from the top of the question editing form for you question type.</p> Index: code.html =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwquestion/moodle/lang/en_utf8/help/webwork/code.html,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwquestion/moodle/lang/en_utf8/help/webwork/code.html -Lwwquestion/moodle/lang/en_utf8/help/webwork/code.html -u -r1.1 -r1.2 --- wwquestion/moodle/lang/en_utf8/help/webwork/code.html +++ wwquestion/moodle/lang/en_utf8/help/webwork/code.html @@ -0,0 +1,3 @@ +<h1>PG Code</h1> + +<p>Paste in the PG code for this WeBWorK problem.</p> \ No newline at end of file Index: seed.html =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwquestion/moodle/lang/en_utf8/help/webwork/seed.html,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwquestion/moodle/lang/en_utf8/help/webwork/seed.html -Lwwquestion/moodle/lang/en_utf8/help/webwork/seed.html -u -r1.1 -r1.2 --- wwquestion/moodle/lang/en_utf8/help/webwork/seed.html +++ wwquestion/moodle/lang/en_utf8/help/webwork/seed.html @@ -0,0 +1,3 @@ +<h1>Seed</h1> + +<p>This is the starting seed used in the random number generator.</p> \ No newline at end of file Index: fileheader.html =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwquestion/moodle/lang/en_utf8/help/webwork/fileheader.html,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwquestion/moodle/lang/en_utf8/help/webwork/fileheader.html -Lwwquestion/moodle/lang/en_utf8/help/webwork/fileheader.html -u -r1.1 -r1.2 --- wwquestion/moodle/lang/en_utf8/help/webwork/fileheader.html +++ wwquestion/moodle/lang/en_utf8/help/webwork/fileheader.html @@ -0,0 +1,5 @@ +<h1>File Handler</h1> + +<p>This allows you to upload any files that the PG code requires as external dependencies. Examples would be images, java applet code, etc. Please only upload necessary files. The more you upload the slower question creation will be. Although the number of files will not effect the speed a question is displayed.</p> + +<p>The derivations directory holds information about the current question derivations.</p> \ No newline at end of file Index: codecheck.html =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwquestion/moodle/lang/en_utf8/help/webwork/codecheck.html,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwquestion/moodle/lang/en_utf8/help/webwork/codecheck.html -Lwwquestion/moodle/lang/en_utf8/help/webwork/codecheck.html -u -r1.1 -r1.2 --- wwquestion/moodle/lang/en_utf8/help/webwork/codecheck.html +++ wwquestion/moodle/lang/en_utf8/help/webwork/codecheck.html @@ -0,0 +1,26 @@ +<h1>Code Checking</h1> + +<p>This field determines how strictly Moodle will check your PG code. If a question fails to clear code checking the question edit form will be displayed with the errors and warnings the question produced. There are five levels of code checking:</p> + +<ul> + <li> + <b>Turn Off (unadvised)</b><br> + This will turn of Code Checking completely. It is strongly recommended that you do not use this setting. + </li> + <li> + <b>Reject Problem Seeds w/ Errors (silent)</b><br> + This setting will reject any seeds that are generated with errors. Warnings are ignored. If any error-free seeds are found within the alloted trials they will be used as derivations. + </li> + <li> + <b>Reject Question if any Errors exist (strict)</b><br> + This setting will reject the question if any errors are found on any seeds. Warnings are ignored. + </li> + <li> + <b>Problem Seeds w/ Errors or Warnings (silent)</b><br> + This setting will reject any seeds that are generated with any errors or warnings. If any error-free seeds are found within the alloted trials they will be used as derivations. + </li> + <li> + <b>Reject Question if any Errors or Warnings exist (strict)</b><br> + This setting will reject the question if any errors or warnings are found on any seeds. + </li> +</ul> \ No newline at end of file Index: trials.html =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwquestion/moodle/lang/en_utf8/help/webwork/trials.html,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwquestion/moodle/lang/en_utf8/help/webwork/trials.html -Lwwquestion/moodle/lang/en_utf8/help/webwork/trials.html -u -r1.1 -r1.2 --- wwquestion/moodle/lang/en_utf8/help/webwork/trials.html +++ wwquestion/moodle/lang/en_utf8/help/webwork/trials.html @@ -0,0 +1,3 @@ +<h1>Trials</h1> + +<p>This is the number of attempts the WeBWorK Question Server will make to render question derivations. Depending on your code checking settings the number of derivations of a question may be less than this number</p> \ No newline at end of file |
From: Matt L. v. a. <we...@ma...> - 2007-09-13 00:35:11
|
Log Message: ----------- Modified Files: -------------- wwmoodle/wwquestion/moodle/question/type/webwork: edit_webwork_form.php Revision Data ------------- Index: edit_webwork_form.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwquestion/moodle/question/type/webwork/edit_webwork_form.php,v retrieving revision 1.1 retrieving revision 1.2 diff -Lwwquestion/moodle/question/type/webwork/edit_webwork_form.php -Lwwquestion/moodle/question/type/webwork/edit_webwork_form.php -u -r1.1 -r1.2 --- wwquestion/moodle/question/type/webwork/edit_webwork_form.php +++ wwquestion/moodle/question/type/webwork/edit_webwork_form.php @@ -25,7 +25,6 @@ //CODE HEADER $mform->addElement('header', 'codeheader', get_string("edit_codeheader", 'qtype_webwork')); - $mform->setHelpButton('codeheader',array('codeheader', get_string('edit_codeheader','qtype_webwork'),'webwork')); //CODE $mform->addElement('textarea', 'code', get_string('edit_code', 'qtype_webwork'), @@ -66,7 +65,7 @@ $mform->addElement('text', 'seed', get_string('edit_seed','qtype_webwork'), array('size' => 3)); $mform->setType('seed', PARAM_INT); - $mform->setHelpButton('seed', array('webwork', get_string('edit_seed', 'qtype_webwork'), 'webwork')); + $mform->setHelpButton('seed', array('seed', get_string('edit_seed', 'qtype_webwork'), 'webwork')); $mform->setDefault('seed', 0); $mform->addRule('seed', null, 'required', null, 'client'); @@ -74,7 +73,7 @@ $mform->addElement('text', 'trials', get_string('edit_trials','qtype_webwork'), array('size' => 3)); $mform->setType('trials', PARAM_INT); - $mform->setHelpButton('trials', array('webwork', get_string('edit_trials', 'qtype_webwork'), 'webwork')); + $mform->setHelpButton('trials', array('trials', get_string('edit_trials', 'qtype_webwork'), 'webwork')); $mform->setDefault('trials', 10); $mform->addRule('trials', null, 'required', null, 'client'); } |