You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(53) |
Feb
(56) |
Mar
|
Apr
|
May
(30) |
Jun
(78) |
Jul
(121) |
Aug
(155) |
Sep
(77) |
Oct
(61) |
Nov
(45) |
Dec
(94) |
2006 |
Jan
(116) |
Feb
(33) |
Mar
(11) |
Apr
(23) |
May
(60) |
Jun
(89) |
Jul
(130) |
Aug
(109) |
Sep
(124) |
Oct
(63) |
Nov
(82) |
Dec
(45) |
2007 |
Jan
(31) |
Feb
(35) |
Mar
(123) |
Apr
(36) |
May
(18) |
Jun
(134) |
Jul
(133) |
Aug
(241) |
Sep
(126) |
Oct
(31) |
Nov
(15) |
Dec
(5) |
2008 |
Jan
(11) |
Feb
(6) |
Mar
(16) |
Apr
(29) |
May
(43) |
Jun
(149) |
Jul
(27) |
Aug
(29) |
Sep
(37) |
Oct
(20) |
Nov
(4) |
Dec
(6) |
2009 |
Jan
(34) |
Feb
(30) |
Mar
(16) |
Apr
(6) |
May
(1) |
Jun
(32) |
Jul
(22) |
Aug
(7) |
Sep
(18) |
Oct
(50) |
Nov
(22) |
Dec
(8) |
2010 |
Jan
(17) |
Feb
(15) |
Mar
(10) |
Apr
(9) |
May
(67) |
Jun
(30) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
|
From: Mike G. v. a. <we...@ma...> - 2010-11-10 19:48:30
|
Log Message: ----------- Quote value in $set[value] to avoid warning messages Modified Files: -------------- wwmoodle/wwassignment4/moodle/mod/wwassignment: locallib.php Revision Data ------------- Index: locallib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/mod/wwassignment/locallib.php,v retrieving revision 1.16 retrieving revision 1.17 diff -Lwwassignment4/moodle/mod/wwassignment/locallib.php -Lwwassignment4/moodle/mod/wwassignment/locallib.php -u -r1.16 -r1.17 --- wwassignment4/moodle/mod/wwassignment/locallib.php +++ wwassignment4/moodle/mod/wwassignment/locallib.php @@ -532,7 +532,7 @@ $totalpoints =0; if(isset($record)) { foreach ($record as $set) { - $totalpoints = $totalpoints + $set[value]; + $totalpoints = $totalpoints + $set['value']; } return $totalpoints; |
From: Mike G. v. a. <we...@ma...> - 2010-09-28 00:11:47
|
Log Message: ----------- Added a line that prevents errors when one of the moodle courses is no longer available. The grade transfer process is skipped in this case. Modified Files: -------------- wwmoodle/wwassignment4/moodle/mod/wwassignment: lib.php Revision Data ------------- Index: lib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/mod/wwassignment/lib.php,v retrieving revision 1.16 retrieving revision 1.17 diff -Lwwassignment4/moodle/mod/wwassignment/lib.php -Lwwassignment4/moodle/mod/wwassignment/lib.php -u -r1.16 -r1.17 --- wwassignment4/moodle/mod/wwassignment/lib.php +++ wwassignment4/moodle/mod/wwassignment/lib.php @@ -191,7 +191,13 @@ $courseid = $wwassignment->course; $wwclient = new wwassignment_client(); $wwcoursename = _wwassignment_mapped_course($courseid,false); + if ($wwcoursename == -1 ) { // possibly the course connection to webwork has disappeared + return(array()); + } $wwsetname = $wwassignment->webwork_set; + if ($wwsetname == -1) {// possibly the set in webwork has disappeared + return(array()); + } $usernamearray = array(); $students = array(); $studentgrades = array(); @@ -518,7 +524,10 @@ // $modinfo = get_fast_modinfo($course); // -function wwassignment_update_dirty_sets() { // update grades for all instances which have been modified since last cronjob +function wwassignment_update_dirty_sets() { + // update grades for all instances which have been touched since last cronjob + // we don't want to be checking courses from previous semesters which are dormant. + // we look at the log records to see if this course has been active global $CFG; $timenow = time(); $lastcron = get_field("modules","lastcron","name","wwassignment"); @@ -544,7 +553,7 @@ $idValues= "( ".implode(",", array_keys($wwmodtimes) ). " )"; error_log("values string $idValues"); - //error_log("last modification times".print_r($wwmodtimes,true)); + error_log("last modification times".print_r($wwmodtimes,true)); $sql = "SELECT a.*, cm.idnumber as cmidnumber, a.course as courseid, cm.id as wwinstanceid FROM {$CFG->prefix}wwassignment a, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m @@ -565,8 +574,10 @@ ", lastcron $lastcron, course id ".$wwassignment->course.", wwassignment id ".$wwassignment->id. ", set name ".$wwassignment->name.", cm.id ".$wwassignment->wwinstanceid); if ($wwassignment->grade != 0) { + debugLog("call wwassignment_update_grades"); wwassignment_update_grades($wwassignment); } else { + debugLog("call wwassignment_grade_item_update"); wwassignment_grade_item_update($wwassignment); } // refresh events for this assignment |
From: Mike G. v. a. <we...@ma...> - 2010-09-27 05:16:07
|
Log Message: ----------- modifications that allow links to gateway quizzes Modified Files: -------------- wwmoodle/wwassignment4/moodle/mod/wwassignment: locallib.php Revision Data ------------- Index: locallib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/mod/wwassignment/locallib.php,v retrieving revision 1.15 retrieving revision 1.16 diff -Lwwassignment4/moodle/mod/wwassignment/locallib.php -Lwwassignment4/moodle/mod/wwassignment/locallib.php -u -r1.15 -r1.16 --- wwassignment4/moodle/mod/wwassignment/locallib.php +++ wwassignment4/moodle/mod/wwassignment/locallib.php @@ -152,7 +152,7 @@ $wwcoursename = _wwassignment_mapped_course($cid,false); if ( $wwcoursename== -1) { error_log("Can't connect course $cid to webwork"); - return false; + return(false); } $wwclient = new wwassignment_client(); $wwsetname = $wwassignment->webwork_set; @@ -165,7 +165,7 @@ // update event _wwassignment_delete_events($wwassignment->id); _wwassignment_create_events($wwassignment,$wwsetdata); - return true; + return( true); } @@ -325,7 +325,11 @@ * @return URL. */ function _wwassignment_link_to_set($webworkcourse,$webworkset) { - return _wwassignment_link_to_course($webworkcourse) . "$webworkset/"; + if (preg_match('/quiz/',$webworkset ) ) { + return _wwassignment_link_to_course($webworkcourse) . "quiz_mode/$webworkset/"; + } else { + return _wwassignment_link_to_course($webworkcourse) . "$webworkset/"; + } } /** |
From: Mike G. v. a. <we...@ma...> - 2010-06-27 23:52:58
|
Log Message: ----------- Enabled extra warning messages Modified Files: -------------- webwork2/lib/WeBWorK/PG: Local.pm Revision Data ------------- Index: Local.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/PG/Local.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -Llib/WeBWorK/PG/Local.pm -Llib/WeBWorK/PG/Local.pm -u -r1.31 -r1.32 --- lib/WeBWorK/PG/Local.pm +++ lib/WeBWorK/PG/Local.pm @@ -95,9 +95,9 @@ # "user=".$user->user_id.",problem=".$ce->{courseName}."/".$set->set_id."/".$problem->problem_id.",mode=".$translationOptions->{displayMode}, # "begin"); - # install a local warn handler to collect warnings + # install a local warn handler to collect warnings FIXME -- figure out what I meant to do here. my $warnings = ""; - local $SIG{__WARN__} = sub { $warnings .= shift()."<br/>\n"}; + #local $SIG{__WARN__} = sub { $warnings .= shift()."<br/>\n"}; #if $ce->{pg}->{options}->{catchWarnings}; # create a Translator |
From: Mike G. v. a. <we...@ma...> - 2010-06-15 03:42:48
|
Log Message: ----------- removed warning statement Modified Files: -------------- webwork2/lib/WeBWorK/Utils: CourseIntegrityCheck.pm Revision Data ------------- Index: CourseIntegrityCheck.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/Utils/CourseIntegrityCheck.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -Llib/WeBWorK/Utils/CourseIntegrityCheck.pm -Llib/WeBWorK/Utils/CourseIntegrityCheck.pm -u -r1.8 -r1.9 --- lib/WeBWorK/Utils/CourseIntegrityCheck.pm +++ lib/WeBWorK/Utils/CourseIntegrityCheck.pm @@ -96,7 +96,6 @@ sub checkCourseTables { my ($self, $courseName) = @_; - warn "Course name is not defined".caller(2), unless defined($courseName) and $courseName =~/\S/; my $str=''; my $tables_ok = 1; my %dbStatus = (); |
From: Mike G. v. a. <we...@ma...> - 2010-06-15 03:41:49
|
Log Message: ----------- changed to version to 2.4.9+ Modified Files: -------------- webwork2: LICENSE Revision Data ------------- Index: LICENSE =================================================================== RCS file: /webwork/cvs/system/webwork2/LICENSE,v retrieving revision 1.8 retrieving revision 1.9 diff -LLICENSE -LLICENSE -u -r1.8 -r1.9 --- LICENSE +++ LICENSE @@ -1,7 +1,7 @@ WeBWorK Online Homework Delivery System - Version 2.4.x + Version 2.4.9+ Copyright 2000-2009, The WeBWorK Project All rights reserved. |
From: Mike G. v. a. <we...@ma...> - 2010-06-13 02:51:19
|
Log Message: ----------- Added Walter Zorn's tool tip package to the js directory. Modified Files: -------------- webwork2/htdocs/js: ww_applet_support.js Added Files: ----------- webwork2/htdocs/js: wz_tooltip.js Revision Data ------------- Index: ww_applet_support.js =================================================================== RCS file: /webwork/cvs/system/webwork2/htdocs/js/ww_applet_support.js,v retrieving revision 1.13 retrieving revision 1.14 diff -Lhtdocs/js/ww_applet_support.js -Lhtdocs/js/ww_applet_support.js -u -r1.13 -r1.14 --- htdocs/js/ww_applet_support.js +++ htdocs/js/ww_applet_support.js @@ -127,9 +127,13 @@ } function getQE(name1) { // get Question Element in problemMainForm by name - var isIE = navigator.appName.indexOf("Microsoft") != -1; - var obj = (isIE) ? document.getElementById(name1) - :document.problemMainForm[name1]; + //var isIE = navigator.appName.indexOf("Microsoft") != -1; + //var obj = (isIE) ? document.getElementById(name1) + // :document.problemMainForm[name1]; + + var obj = document.getElementById(name1); + if (!obj) {document.problemMainForm[name1]} + // needed for IE -- searches id and name space so it can be unreliable if names are not unique if (!obj || obj.name != name1) { var msg = "Can't find element " + name1; --- /dev/null +++ htdocs/js/wz_tooltip.js @@ -0,0 +1,1149 @@ +/* This notice must be untouched at all times. + +wz_tooltip.js v. 4.12 + +The latest version is available at +http://www.walterzorn.com +or http://www.devira.com +or http://www.walterzorn.de + +Copyright (c) 2002-2007 Walter Zorn. All rights reserved. +Created 1.12.2002 by Walter Zorn (Web: http://www.walterzorn.com ) +Last modified: 13.7.2007 + +Easy-to-use cross-browser tooltips. +Just include the script at the beginning of the <body> section, and invoke +Tip('Tooltip text') from within the desired HTML onmouseover eventhandlers. +No container DIV, no onmouseouts required. +By default, width of tooltips is automatically adapted to content. +Is even capable of dynamically converting arbitrary HTML elements to tooltips +by calling TagToTip('ID_of_HTML_element_to_be_converted') instead of Tip(), +which means you can put important, search-engine-relevant stuff into tooltips. +Appearance of tooltips can be individually configured +via commands passed to Tip() or TagToTip(). + +Tab Width: 4 +LICENSE: LGPL + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License (LGPL) as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +For more details on the GNU Lesser General Public License, +see http://www.gnu.org/copyleft/lesser.html +*/ + +var config = new Object(); + + +//=================== GLOBAL TOOPTIP CONFIGURATION =========================// +var tt_Debug = true // false or true - recommended: false once you release your page to the public +var tt_Enabled = true // Allows to (temporarily) suppress tooltips, e.g. by providing the user with a button that sets this global variable to false +var TagsToTip = true // false or true - if true, the script is capable of converting HTML elements to tooltips + +// For each of the following config variables there exists a command, which is +// just the variablename in uppercase, to be passed to Tip() or TagToTip() to +// configure tooltips individually. Individual commands override global +// configuration. Order of commands is arbitrary. +// Example: onmouseover="Tip('Tooltip text', LEFT, true, BGCOLOR, '#FF9900', FADEIN, 400)" + +config. Above = false // false or true - tooltip above mousepointer? +config. BgColor = '#E4E7FF' // Background color +config. BgImg = '' // Path to background image, none if empty string '' +config. BorderColor = '#002299' +config. BorderStyle = 'solid' // Any permitted CSS value, but I recommend 'solid', 'dotted' or 'dashed' +config. BorderWidth = 1 +config. CenterMouse = false // false or true - center the tip horizontally below (or above) the mousepointer +config. ClickClose = false // false or true - close tooltip if the user clicks somewhere +config. CloseBtn = false // false or true - closebutton in titlebar +config. CloseBtnColors = ['#990000', '#FFFFFF', '#DD3333', '#FFFFFF'] // [Background, text, hovered background, hovered text] - use empty strings '' to inherit title colors +config. CloseBtnText = ' X ' // Close button text (may also be an image tag) +config. CopyContent = true // When converting a HTML element to a tooltip, copy only the element's content, rather than converting the element by its own +config. Delay = 400 // Time span in ms until tooltip shows up +config. Duration = 0 // Time span in ms after which the tooltip disappears; 0 for infinite duration +config. FadeIn = 0 // Fade-in duration in ms, e.g. 400; 0 for no animation +config. FadeOut = 0 +config. FadeInterval = 30 // Duration of each fade step in ms (recommended: 30) - shorter is smoother but causes more CPU-load +config. Fix = null // Fixated position - x- an y-oordinates in brackets, e.g. [210, 480], or null for no fixation +config. FollowMouse = true // false or true - tooltip follows the mouse +config. FontColor = '#000044' +config. FontFace = 'Verdana,Geneva,sans-serif' +config. FontSize = '8pt' // E.g. '9pt' or '12px' - unit is mandatory +config. FontWeight = 'normal' // 'normal' or 'bold'; +config. Left = false // false or true - tooltip on the left of the mouse +config. OffsetX = 14 // Horizontal offset of left-top corner from mousepointer +config. OffsetY = 8 // Vertical offset +config. Opacity = 100 // Integer between 0 and 100 - opacity of tooltip in percent +config. Padding = 3 // Spacing between border and content +config. Shadow = false // false or true +config. ShadowColor = '#C0C0C0' +config. ShadowWidth = 5 +config. Sticky = false // Do NOT hide tooltip on mouseout? false or true +config. TextAlign = 'left' // 'left', 'right' or 'justify' +config. Title = '' // Default title text applied to all tips (no default title: empty string '') +config. TitleAlign = 'left' // 'left' or 'right' - text alignment inside the title bar +config. TitleBgColor = '' // If empty string '', BorderColor will be used +config. TitleFontColor = '#ffffff' // Color of title text - if '', BgColor (of tooltip body) will be used +config. TitleFontFace = '' // If '' use FontFace (boldified) +config. TitleFontSize = '' // If '' use FontSize +config. Width = 0 // Tooltip width; 0 for automatic adaption to tooltip content +//======= END OF TOOLTIP CONFIG, DO NOT CHANGE ANYTHING BELOW ==============// + + + + +//====================== PUBLIC ============================================// +function Tip() +{ + tt_Tip(arguments, null); +} +function TagToTip() +{ + if(TagsToTip) + { + var t2t = tt_GetElt(arguments[0]); + if(t2t) + tt_Tip(arguments, t2t); + } +} + +//================== PUBLIC EXTENSION API ==================================// +// Extension eventhandlers currently supported: +// OnLoadConfig, OnCreateContentString, OnSubDivsCreated, OnShow, OnMoveBefore, +// OnMoveAfter, OnHideInit, OnHide, OnKill + +var tt_aElt = new Array(10), // Container DIV, outer title & body DIVs, inner title & body TDs, closebutton SPAN, shadow DIVs, and IFRAME to cover windowed elements in IE +tt_aV = new Array(), // Caches and enumerates config data for currently active tooltip +tt_sContent, // Inner tooltip text or HTML +tt_scrlX = 0, tt_scrlY = 0, +tt_musX, tt_musY, +tt_over, +tt_x, tt_y, tt_w, tt_h; // Position, width and height of currently displayed tooltip + +function tt_Extension() +{ + tt_ExtCmdEnum(); + tt_aExt[tt_aExt.length] = this; + return this; +} +function tt_SetTipPos(x, y) +{ + var css = tt_aElt[0].style; + + tt_x = x; + tt_y = y; + css.left = x + "px"; + css.top = y + "px"; + if(tt_ie56) + { + var ifrm = tt_aElt[tt_aElt.length - 1]; + if(ifrm) + { + ifrm.style.left = css.left; + ifrm.style.top = css.top; + } + } +} +function tt_Hide() +{ + if(tt_db && tt_iState) + { + if(tt_iState & 0x2) + { + tt_aElt[0].style.visibility = "hidden"; + tt_ExtCallFncs(0, "Hide"); + } + tt_tShow.EndTimer(); + tt_tHide.EndTimer(); + tt_tDurt.EndTimer(); + tt_tFade.EndTimer(); + if(!tt_op && !tt_ie) + { + tt_tWaitMov.EndTimer(); + tt_bWait = false; + } + if(tt_aV[CLICKCLOSE]) + tt_RemEvtFnc(document, "mouseup", tt_HideInit); + tt_AddRemOutFnc(false); + tt_ExtCallFncs(0, "Kill"); + // In case of a TagToTip tooltip, hide converted DOM node and + // re-insert it into document + if(tt_t2t && !tt_aV[COPYCONTENT]) + { + tt_t2t.style.display = "none"; + tt_MovDomNode(tt_t2t, tt_aElt[6], tt_t2tDad); + } + tt_iState = 0; + tt_over = null; + tt_ResetMainDiv(); + if(tt_aElt[tt_aElt.length - 1]) + tt_aElt[tt_aElt.length - 1].style.display = "none"; + } +} +function tt_GetElt(id) +{ + return(document.getElementById ? document.getElementById(id) + : document.all ? document.all[id] + : null); +} +function tt_GetDivW(el) +{ + return(el ? (el.offsetWidth || el.style.pixelWidth || 0) : 0); +} +function tt_GetDivH(el) +{ + return(el ? (el.offsetHeight || el.style.pixelHeight || 0) : 0); +} +function tt_GetScrollX() +{ + return(window.pageXOffset || (tt_db ? (tt_db.scrollLeft || 0) : 0)); +} +function tt_GetScrollY() +{ + return(window.pageYOffset || (tt_db ? (tt_db.scrollTop || 0) : 0)); +} +function tt_GetClientW() +{ + return(document.body && (typeof(document.body.clientWidth) != tt_u) ? document.body.clientWidth + : (typeof(window.innerWidth) != tt_u) ? window.innerWidth + : tt_db ? (tt_db.clientWidth || 0) + : 0); +} +function tt_GetClientH() +{ + // Exactly this order seems to yield correct values in all major browsers + return(document.body && (typeof(document.body.clientHeight) != tt_u) ? document.body.clientHeight + : (typeof(window.innerHeight) != tt_u) ? window.innerHeight + : tt_db ? (tt_db.clientHeight || 0) + : 0); +} +function tt_GetEvtX(e) +{ + return (e ? ((typeof(e.pageX) != tt_u) ? e.pageX : (e.clientX + tt_scrlX)) : 0); +} +function tt_GetEvtY(e) +{ + return (e ? ((typeof(e.pageY) != tt_u) ? e.pageY : (e.clientY + tt_scrlY)) : 0); +} +function tt_AddEvtFnc(el, sEvt, PFnc) +{ + if(el) + { + if(el.addEventListener) + el.addEventListener(sEvt, PFnc, false); + else + el.attachEvent("on" + sEvt, PFnc); + } +} +function tt_RemEvtFnc(el, sEvt, PFnc) +{ + if(el) + { + if(el.removeEventListener) + el.removeEventListener(sEvt, PFnc, false); + else + el.detachEvent("on" + sEvt, PFnc); + } +} + +//====================== PRIVATE ===========================================// +var tt_aExt = new Array(), // Array of extension objects + +tt_db, tt_op, tt_ie, tt_ie56, tt_bBoxOld, // Browser flags +tt_body, +tt_flagOpa, // Opacity support: 1=IE, 2=Khtml, 3=KHTML, 4=Moz, 5=W3C +tt_maxPosX, tt_maxPosY, +tt_iState = 0, // Tooltip active |= 1, shown |= 2, move with mouse |= 4 +tt_opa, // Currently applied opacity +tt_bJmpVert, // Tip above mouse (or ABOVE tip below mouse) +tt_t2t, tt_t2tDad, // Tag converted to tip, and its parent element in the document +tt_elDeHref, // The tag from which Opera has removed the href attribute +// Timer +tt_tShow = new Number(0), tt_tHide = new Number(0), tt_tDurt = new Number(0), +tt_tFade = new Number(0), tt_tWaitMov = new Number(0), +tt_bWait = false, +tt_u = "undefined"; + + +function tt_Init() +{ + tt_MkCmdEnum(); + // Send old browsers instantly to hell + if(!tt_Browser() || !tt_MkMainDiv()) + return; + tt_IsW3cBox(); + tt_OpaSupport(); + tt_AddEvtFnc(document, "mousemove", tt_Move); + // In Debug mode we search for TagToTip() calls in order to notify + // the user if they've forgotten to set the TagsToTip config flag + if(TagsToTip || tt_Debug) + tt_SetOnloadFnc(); + tt_AddEvtFnc(window, "scroll", + function() + { + tt_scrlX = tt_GetScrollX(); + tt_scrlY = tt_GetScrollY(); + if(tt_iState && !(tt_aV[STICKY] && (tt_iState & 2))) + tt_HideInit(); + } ); + // Ensure the tip be hidden when the page unloads + tt_AddEvtFnc(window, "unload", tt_Hide); + tt_Hide(); +} +// Creates command names by translating config variable names to upper case +function tt_MkCmdEnum() +{ + var n = 0; + for(var i in config) + eval("window." + i.toString().toUpperCase() + " = " + n++); + tt_aV.length = n; +} +function tt_Browser() +{ + var n, nv, n6, w3c; + + n = navigator.userAgent.toLowerCase(), + nv = navigator.appVersion; + tt_op = (document.defaultView && typeof(eval("w" + "indow" + "." + "o" + "p" + "er" + "a")) != tt_u); + tt_ie = n.indexOf("msie") != -1 && document.all && !tt_op; + if(tt_ie) + { + var ieOld = (!document.compatMode || document.compatMode == "BackCompat"); + tt_db = !ieOld ? document.documentElement : (document.body || null); + if(tt_db) + tt_ie56 = parseFloat(nv.substring(nv.indexOf("MSIE") + 5)) >= 5.5 + && typeof document.body.style.maxHeight == tt_u; + } + else + { + tt_db = document.documentElement || document.body || + (document.getElementsByTagName ? document.getElementsByTagName("body")[0] + : null); + if(!tt_op) + { + n6 = document.defaultView && typeof document.defaultView.getComputedStyle != tt_u; + w3c = !n6 && document.getElementById; + } + } + tt_body = (document.getElementsByTagName ? document.getElementsByTagName("body")[0] + : (document.body || null)); + if(tt_ie || n6 || tt_op || w3c) + { + if(tt_body && tt_db) + { + if(document.attachEvent || document.addEventListener) + return true; + } + else + tt_Err("wz_tooltip.js must be included INSIDE the body section," + + " immediately after the opening <body> tag."); + } + tt_db = null; + return false; +} +function tt_MkMainDiv() +{ + // Create the tooltip DIV + if(tt_body.insertAdjacentHTML) + tt_body.insertAdjacentHTML("afterBegin", tt_MkMainDivHtm()); + else if(typeof tt_body.innerHTML != tt_u && document.createElement && tt_body.appendChild) + tt_body.appendChild(tt_MkMainDivDom()); + // FireFox Alzheimer bug + if(window.tt_GetMainDivRefs && tt_GetMainDivRefs()) + return true; + tt_db = null; + return false; +} +function tt_MkMainDivHtm() +{ + return('<div id="WzTtDiV"></div>' + + (tt_ie56 ? ('<iframe id="WzTtIfRm" src="javascript:false" scrolling="no" frameborder="0" style="filter:Alpha(opacity=0);position:absolute;top:0px;left:0px;display:none;"></iframe>') + : '')); +} +function tt_MkMainDivDom() +{ + var el = document.createElement("div"); + if(el) + el.id = "WzTtDiV"; + return el; +} +function tt_GetMainDivRefs() +{ + tt_aElt[0] = tt_GetElt("WzTtDiV"); + if(tt_ie56 && tt_aElt[0]) + { + tt_aElt[tt_aElt.length - 1] = tt_GetElt("WzTtIfRm"); + if(!tt_aElt[tt_aElt.length - 1]) + tt_aElt[0] = null; + } + if(tt_aElt[0]) + { + var css = tt_aElt[0].style; + + css.visibility = "hidden"; + css.position = "absolute"; + css.overflow = "hidden"; + return true; + } + return false; +} +function tt_ResetMainDiv() +{ + var w = (window.screen && screen.width) ? screen.width : 10000; + + tt_SetTipPos(-w, 0); + tt_aElt[0].innerHTML = ""; + tt_aElt[0].style.width = (w - 1) + "px"; +} +function tt_IsW3cBox() +{ + var css = tt_aElt[0].style; + + css.padding = "10px"; + css.width = "40px"; + tt_bBoxOld = (tt_GetDivW(tt_aElt[0]) == 40); + css.padding = "0px"; + tt_ResetMainDiv(); +} +function tt_OpaSupport() +{ + var css = tt_body.style; + + tt_flagOpa = (typeof(css.filter) != tt_u) ? 1 + : (typeof(css.KhtmlOpacity) != tt_u) ? 2 + : (typeof(css.KHTMLOpacity) != tt_u) ? 3 + : (typeof(css.MozOpacity) != tt_u) ? 4 + : (typeof(css.opacity) != tt_u) ? 5 + : 0; +} +// Ported from http://dean.edwards.name/weblog/2006/06/again/ +// (Dean Edwards et al.) +function tt_SetOnloadFnc() +{ + tt_AddEvtFnc(document, "DOMContentLoaded", tt_HideSrcTags); + tt_AddEvtFnc(window, "load", tt_HideSrcTags); + if(tt_body.attachEvent) + tt_body.attachEvent("onreadystatechange", + function() { + if(tt_body.readyState == "complete") + tt_HideSrcTags(); + } ); + if(/WebKit|KHTML/i.test(navigator.userAgent)) + { + var t = setInterval(function() { + if(/loaded|complete/.test(document.readyState)) + { + clearInterval(t); + tt_HideSrcTags(); + } + }, 10); + } +} +function tt_HideSrcTags() +{ + if(!window.tt_HideSrcTags || window.tt_HideSrcTags.done) + return; + window.tt_HideSrcTags.done = true; + if(!tt_HideSrcTagsRecurs(tt_body)) + tt_Err("To enable the capability to convert HTML elements to tooltips," + + " you must set TagsToTip in the global tooltip configuration" + + " to true."); +} +function tt_HideSrcTagsRecurs(dad) +{ + var a, ovr, asT2t; + + // Walk the DOM tree for tags that have an onmouseover attribute + // containing a TagToTip('...') call. + // (.childNodes first since .children is bugous in Safari) + a = dad.childNodes || dad.children || null; + for(var i = a ? a.length : 0; i;) + {--i; + if(!tt_HideSrcTagsRecurs(a[i])) + return false; + ovr = a[i].getAttribute ? a[i].getAttribute("onmouseover") + : (typeof a[i].onmouseover == "function") ? a[i].onmouseover + : null; + if(ovr) + { + asT2t = ovr.toString().match(/TagToTip\s*\(\s*'[^'.]+'\s*[\),]/); + if(asT2t && asT2t.length) + { + if(!tt_HideSrcTag(asT2t[0])) + return false; + } + } + } + return true; +} +function tt_HideSrcTag(sT2t) +{ + var id, el; + + // The ID passed to the found TagToTip() call identifies an HTML element + // to be converted to a tooltip, so hide that element + id = sT2t.replace(/.+'([^'.]+)'.+/, "$1"); + el = tt_GetElt(id); + if(el) + { + if(tt_Debug && !TagsToTip) + return false; + else + el.style.display = "none"; + } + else + tt_Err("Invalid ID\n'" + id + "'\npassed to TagToTip()." + + " There exists no HTML element with that ID."); + return true; +} +function tt_Tip(arg, t2t) +{ + if(!tt_db) + return; + if(tt_iState) + tt_Hide(); + if(!tt_Enabled) + return; + tt_t2t = t2t; + if(!tt_ReadCmds(arg)) + return; + tt_iState = 0x1 | 0x4; + tt_AdaptConfig1(); + tt_MkTipContent(arg); + tt_MkTipSubDivs(); + tt_FormatTip(); + tt_bJmpVert = false; + tt_maxPosX = tt_GetClientW() + tt_scrlX - tt_w - 1; + tt_maxPosY = tt_GetClientH() + tt_scrlY - tt_h - 1; + tt_AdaptConfig2(); + // We must fake the first mousemove in order to ensure the tip + // be immediately shown and positioned + tt_Move(); + tt_ShowInit(); +} +function tt_ReadCmds(a) +{ + var i; + + // First load the global config values, to initialize also values + // for which no command has been passed + i = 0; + for(var j in config) + tt_aV[i++] = config[j]; + // Then replace each cached config value for which a command has been + // passed (ensure the # of command args plus value args be even) + if(a.length & 1) + { + for(i = a.length - 1; i > 0; i -= 2) + tt_aV[a[i - 1]] = a[i]; + return true; + } + tt_Err("Incorrect call of Tip() or TagToTip().\n" + + "Each command must be followed by a value."); + return false; +} +function tt_AdaptConfig1() +{ + tt_ExtCallFncs(0, "LoadConfig"); + // Inherit unspecified title formattings from body + if(!tt_aV[TITLEBGCOLOR].length) + tt_aV[TITLEBGCOLOR] = tt_aV[BORDERCOLOR]; + if(!tt_aV[TITLEFONTCOLOR].length) + tt_aV[TITLEFONTCOLOR] = tt_aV[BGCOLOR]; + if(!tt_aV[TITLEFONTFACE].length) + tt_aV[TITLEFONTFACE] = tt_aV[FONTFACE]; + if(!tt_aV[TITLEFONTSIZE].length) + tt_aV[TITLEFONTSIZE] = tt_aV[FONTSIZE]; + if(tt_aV[CLOSEBTN]) + { + // Use title colors for non-specified closebutton colors + if(!tt_aV[CLOSEBTNCOLORS]) + tt_aV[CLOSEBTNCOLORS] = new Array("", "", "", ""); + for(var i = 4; i;) + {--i; + if(!tt_aV[CLOSEBTNCOLORS][i].length) + tt_aV[CLOSEBTNCOLORS][i] = (i & 1) ? tt_aV[TITLEFONTCOLOR] : tt_aV[TITLEBGCOLOR]; + } + // Enforce titlebar be shown + if(!tt_aV[TITLE].length) + tt_aV[TITLE] = " "; + } + // Circumvents broken display of images and fade-in flicker in Geckos < 1.8 + if(tt_aV[OPACITY] == 100 && typeof tt_aElt[0].style.MozOpacity != tt_u && !Array.every) + tt_aV[OPACITY] = 99; + // Smartly shorten the delay for fade-in tooltips + if(tt_aV[FADEIN] && tt_flagOpa && tt_aV[DELAY] > 100) + tt_aV[DELAY] = Math.max(tt_aV[DELAY] - tt_aV[FADEIN], 100); +} +function tt_AdaptConfig2() +{ + if(tt_aV[CENTERMOUSE]) + tt_aV[OFFSETX] -= ((tt_w - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0)) >> 1); +} +// Expose content globally so extensions can modify it +function tt_MkTipContent(a) +{ + if(tt_t2t) + { + if(tt_aV[COPYCONTENT]) + tt_sContent = tt_t2t.innerHTML; + else + tt_sContent = ""; + } + else + tt_sContent = a[0]; + tt_ExtCallFncs(0, "CreateContentString"); +} +function tt_MkTipSubDivs() +{ + var sCss = 'position:relative;margin:0px;padding:0px;border-width:0px;left:0px;top:0px;line-height:normal;width:auto;', + sTbTrTd = ' cellspacing=0 cellpadding=0 border=0 style="' + sCss + '"><tbody style="' + sCss + '"><tr><td '; + + tt_aElt[0].innerHTML = + ('' + + (tt_aV[TITLE].length ? + ('<div id="WzTiTl" style="position:relative;z-index:1;">' + + '<table id="WzTiTlTb"' + sTbTrTd + 'id="WzTiTlI" style="' + sCss + '">' + + tt_aV[TITLE] + + '</td>' + + (tt_aV[CLOSEBTN] ? + ('<td align="right" style="' + sCss + + 'text-align:right;">' + + '<span id="WzClOsE" style="padding-left:2px;padding-right:2px;' + + 'cursor:' + (tt_ie ? 'hand' : 'pointer') + + ';" onmouseover="tt_OnCloseBtnOver(1)" onmouseout="tt_OnCloseBtnOver(0)" onclick="tt_HideInit()">' + + tt_aV[CLOSEBTNTEXT] + + '</span></td>') + : '') + + '</tr></tbody></table></div>') + : '') + + '<div id="WzBoDy" style="position:relative;z-index:0;">' + + '<table' + sTbTrTd + 'id="WzBoDyI" style="' + sCss + '">' + + tt_sContent + + '</td></tr></tbody></table></div>' + + (tt_aV[SHADOW] + ? ('<div id="WzTtShDwR" style="position:absolute;overflow:hidden;"></div>' + + '<div id="WzTtShDwB" style="position:relative;overflow:hidden;"></div>') + : '') + ); + tt_GetSubDivRefs(); + // Convert DOM node to tip + if(tt_t2t && !tt_aV[COPYCONTENT]) + { + // Store the tag's parent element so we can restore that DOM branch + // once the tooltip is hidden + tt_t2tDad = tt_t2t.parentNode || tt_t2t.parentElement || tt_t2t.offsetParent || null; + if(tt_t2tDad) + { + tt_MovDomNode(tt_t2t, tt_t2tDad, tt_aElt[6]); + tt_t2t.style.display = "block"; + } + } + tt_ExtCallFncs(0, "SubDivsCreated"); +} +function tt_GetSubDivRefs() +{ + var aId = new Array("WzTiTl", "WzTiTlTb", "WzTiTlI", "WzClOsE", "WzBoDy", "WzBoDyI", "WzTtShDwB", "WzTtShDwR"); + + for(var i = aId.length; i; --i) + tt_aElt[i] = tt_GetElt(aId[i - 1]); +} +function tt_FormatTip() +{ + var css, w, iOffY, iOffSh; + + //--------- Title DIV ---------- + if(tt_aV[TITLE].length) + { + css = tt_aElt[1].style; + css.background = tt_aV[TITLEBGCOLOR]; + css.paddingTop = (tt_aV[CLOSEBTN] ? 2 : 0) + "px"; + css.paddingBottom = "1px"; + css.paddingLeft = css.paddingRight = tt_aV[PADDING] + "px"; + css = tt_aElt[3].style; + css.color = tt_aV[TITLEFONTCOLOR]; + css.fontFamily = tt_aV[TITLEFONTFACE]; + css.fontSize = tt_aV[TITLEFONTSIZE]; + css.fontWeight = "bold"; + css.textAlign = tt_aV[TITLEALIGN]; + // Close button DIV + if(tt_aElt[4]) + { + css.paddingRight = (tt_aV[PADDING] << 1) + "px"; + css = tt_aElt[4].style; + css.background = tt_aV[CLOSEBTNCOLORS][0]; + css.color = tt_aV[CLOSEBTNCOLORS][1]; + css.fontFamily = tt_aV[TITLEFONTFACE]; + css.fontSize = tt_aV[TITLEFONTSIZE]; + css.fontWeight = "bold"; + } + if(tt_aV[WIDTH] > 0) + tt_w = tt_aV[WIDTH] + ((tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1); + else + { + tt_w = tt_GetDivW(tt_aElt[3]) + tt_GetDivW(tt_aElt[4]); + // Some spacing between title DIV and closebutton + if(tt_aElt[4]) + tt_w += tt_aV[PADDING]; + } + // Ensure the top border of the body DIV be covered by the title DIV + iOffY = -tt_aV[BORDERWIDTH]; + } + else + { + tt_w = 0; + iOffY = 0; + } + + //-------- Body DIV ------------ + css = tt_aElt[5].style; + css.top = iOffY + "px"; + if(tt_aV[BORDERWIDTH]) + { + css.borderColor = tt_aV[BORDERCOLOR]; + css.borderStyle = tt_aV[BORDERSTYLE]; + css.borderWidth = tt_aV[BORDERWIDTH] + "px"; + } + if(tt_aV[BGCOLOR].length) + css.background = tt_aV[BGCOLOR]; + if(tt_aV[BGIMG].length) + css.backgroundImage = "url(" + tt_aV[BGIMG] + ")"; + css.padding = tt_aV[PADDING] + "px"; + css.textAlign = tt_aV[TEXTALIGN]; + // TD inside body DIV + css = tt_aElt[6].style; + css.color = tt_aV[FONTCOLOR]; + css.fontFamily = tt_aV[FONTFACE]; + css.fontSize = tt_aV[FONTSIZE]; + css.fontWeight = tt_aV[FONTWEIGHT]; + css.background = ""; + css.textAlign = tt_aV[TEXTALIGN]; + if(tt_aV[WIDTH] > 0) + w = tt_aV[WIDTH] + ((tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1); + else + // We measure the width of the body's inner TD, because some browsers + // expand the width of the container and outer body DIV to 100% + w = tt_GetDivW(tt_aElt[6]) + ((tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1); + if(w > tt_w) + tt_w = w; + + //--------- Shadow DIVs ------------ + if(tt_aV[SHADOW]) + { + tt_w += tt_aV[SHADOWWIDTH]; + iOffSh = Math.floor((tt_aV[SHADOWWIDTH] * 4) / 3); + // Bottom shadow + css = tt_aElt[7].style; + css.top = iOffY + "px"; + css.left = iOffSh + "px"; + css.width = (tt_w - iOffSh - tt_aV[SHADOWWIDTH]) + "px"; + css.height = tt_aV[SHADOWWIDTH] + "px"; + css.background = tt_aV[SHADOWCOLOR]; + // Right shadow + css = tt_aElt[8].style; + css.top = iOffSh + "px"; + css.left = (tt_w - tt_aV[SHADOWWIDTH]) + "px"; + css.width = tt_aV[SHADOWWIDTH] + "px"; + css.background = tt_aV[SHADOWCOLOR]; + } + else + iOffSh = 0; + + //-------- Container DIV ------- + tt_SetTipOpa(tt_aV[FADEIN] ? 0 : tt_aV[OPACITY]); + tt_FixSize(iOffY, iOffSh); +} +// Fixate the size so it can't dynamically change while the tooltip is moving. +function tt_FixSize(iOffY, iOffSh) +{ + var wIn, wOut, i; + + tt_aElt[0].style.width = tt_w + "px"; + tt_aElt[0].style.pixelWidth = tt_w; + wOut = tt_w - ((tt_aV[SHADOW]) ? tt_aV[SHADOWWIDTH] : 0); + // Body + wIn = wOut; + if(!tt_bBoxOld) + wIn -= ((tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1); + tt_aElt[5].style.width = wIn + "px"; + // Title + if(tt_aElt[1]) + { + wIn = wOut - (tt_aV[PADDING] << 1); + if(!tt_bBoxOld) + wOut = wIn; + tt_aElt[1].style.width = wOut + "px"; + tt_aElt[2].style.width = wIn + "px"; + } + tt_h = tt_GetDivH(tt_aElt[0]) + iOffY; + // Right shadow + if(tt_aElt[8]) + tt_aElt[8].style.height = (tt_h - iOffSh) + "px"; + i = tt_aElt.length - 1; + if(tt_aElt[i]) + { + tt_aElt[i].style.width = tt_w + "px"; + tt_aElt[i].style.height = tt_h + "px"; + } +} +function tt_DeAlt(el) +{ + var aKid; + + if(el.alt) + el.alt = ""; + if(el.title) + el.title = ""; + aKid = el.childNodes || el.children || null; + if(aKid) + { + for(var i = aKid.length; i;) + tt_DeAlt(aKid[--i]); + } +} +// This hack removes the annoying native tooltips over links in Opera +function tt_OpDeHref(el) +{ + if(!tt_op) + return; + if(tt_elDeHref) + tt_OpReHref(); + while(el) + { + if(el.hasAttribute("href")) + { + el.t_href = el.getAttribute("href"); + el.t_stats = window.status; + el.removeAttribute("href"); + el.style.cursor = "hand"; + tt_AddEvtFnc(el, "mousedown", tt_OpReHref); + window.status = el.t_href; + tt_elDeHref = el; + break; + } + el = el.parentElement; + } +} +function tt_ShowInit() +{ + tt_tShow.Timer("tt_Show()", tt_aV[DELAY], true); + if(tt_aV[CLICKCLOSE]) + tt_AddEvtFnc(document, "mouseup", tt_HideInit); +} +function tt_OverInit(e) +{ + tt_over = e.target || e.srcElement; + tt_DeAlt(tt_over); + tt_OpDeHref(tt_over); + tt_AddRemOutFnc(true); +} +function tt_Show() +{ + var css = tt_aElt[0].style; + + // Override the z-index of the topmost wz_dragdrop.js D&D item + css.zIndex = Math.max((window.dd && dd.z) ? (dd.z + 2) : 0, 1010); + if(tt_aV[STICKY] || !tt_aV[FOLLOWMOUSE]) + tt_iState &= ~0x4; + if(tt_aV[DURATION] > 0) + tt_tDurt.Timer("tt_HideInit()", tt_aV[DURATION], true); + tt_ExtCallFncs(0, "Show") + css.visibility = "visible"; + tt_iState |= 0x2; + if(tt_aV[FADEIN]) + tt_Fade(0, 0, tt_aV[OPACITY], Math.round(tt_aV[FADEIN] / tt_aV[FADEINTERVAL])); + tt_ShowIfrm(); +} +function tt_ShowIfrm() +{ + if(tt_ie56) + { + var ifrm = tt_aElt[tt_aElt.length - 1]; + if(ifrm) + { + var css = ifrm.style; + css.zIndex = tt_aElt[0].style.zIndex - 1; + css.display = "block"; + } + } +} +function tt_Move(e) +{ + e = window.event || e; + if(e) + { + tt_musX = tt_GetEvtX(e); + tt_musY = tt_GetEvtY(e); + } + if(tt_iState) + { + if(!tt_over && e) + tt_OverInit(e); + if(tt_iState & 0x4) + { + // Protect some browsers against jam of mousemove events + if(!tt_op && !tt_ie) + { + if(tt_bWait) + return; + tt_bWait = true; + tt_tWaitMov.Timer("tt_bWait = false;", 1, true); + } + if(tt_aV[FIX]) + { + tt_iState &= ~0x4; + tt_SetTipPos(tt_aV[FIX][0], tt_aV[FIX][1]); + } + else if(!tt_ExtCallFncs(e, "MoveBefore")) + tt_SetTipPos(tt_PosX(), tt_PosY()); + tt_ExtCallFncs([tt_musX, tt_musY], "MoveAfter") + } + } +} +function tt_PosX() +{ + var x; + + x = tt_musX; + if(tt_aV[LEFT]) + x -= tt_w + tt_aV[OFFSETX] - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0); + else + x += tt_aV[OFFSETX]; + // Prevent tip from extending past right/left clientarea boundary + if(x > tt_maxPosX) + x = tt_maxPosX; + return((x < tt_scrlX) ? tt_scrlX : x); +} +function tt_PosY() +{ + var y; + + // Apply some hysteresis after the tip has snapped to the other side of the + // mouse. In case of insufficient space above and below the mouse, we place + // the tip below. + if(tt_aV[ABOVE] && (!tt_bJmpVert || tt_CalcPosYAbove() >= tt_scrlY + 16)) + y = tt_DoPosYAbove(); + else if(!tt_aV[ABOVE] && tt_bJmpVert && tt_CalcPosYBelow() > tt_maxPosY - 16) + y = tt_DoPosYAbove(); + else + y = tt_DoPosYBelow(); + // Snap to other side of mouse if tip would extend past window boundary + if(y > tt_maxPosY) + y = tt_DoPosYAbove(); + if(y < tt_scrlY) + y = tt_DoPosYBelow(); + return y; +} +function tt_DoPosYBelow() +{ + tt_bJmpVert = tt_aV[ABOVE]; + return tt_CalcPosYBelow(); +} +function tt_DoPosYAbove() +{ + tt_bJmpVert = !tt_aV[ABOVE]; + return tt_CalcPosYAbove(); +} +function tt_CalcPosYBelow() +{ + return(tt_musY + tt_aV[OFFSETY]); +} +function tt_CalcPosYAbove() +{ + var dy = tt_aV[OFFSETY] - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0); + if(tt_aV[OFFSETY] > 0 && dy <= 0) + dy = 1; + return(tt_musY - tt_h - dy); +} +function tt_OnOut() +{ + tt_AddRemOutFnc(false); + if(!(tt_aV[STICKY] && (tt_iState & 0x2))) + tt_HideInit(); +} +function tt_HideInit() +{ + tt_ExtCallFncs(0, "HideInit"); + tt_iState &= ~0x4; + if(tt_flagOpa && tt_aV[FADEOUT]) + { + tt_tFade.EndTimer(); + if(tt_opa) + { + var n = Math.round(tt_aV[FADEOUT] / (tt_aV[FADEINTERVAL] * (tt_aV[OPACITY] / tt_opa))); + tt_Fade(tt_opa, tt_opa, 0, n); + return; + } + } + tt_tHide.Timer("tt_Hide();", 1, false); +} +function tt_OpReHref() +{ + if(tt_elDeHref) + { + tt_elDeHref.setAttribute("href", tt_elDeHref.t_href); + tt_RemEvtFnc(tt_elDeHref, "mousedown", tt_OpReHref); + window.status = tt_elDeHref.t_stats; + tt_elDeHref = null; + } +} +function tt_Fade(a, now, z, n) +{ + if(n) + { + now += Math.round((z - now) / n); + if((z > a) ? (now >= z) : (now <= z)) + now = z; + else + tt_tFade.Timer("tt_Fade(" + + a + "," + now + "," + z + "," + (n - 1) + + ")", + tt_aV[FADEINTERVAL], + true); + } + now ? tt_SetTipOpa(now) : tt_Hide(); +} +// To circumvent the opacity nesting flaws of IE, we set the opacity +// for each sub-DIV separately, rather than for the container DIV. +function tt_SetTipOpa(opa) +{ + tt_SetOpa(tt_aElt[5].style, opa); + if(tt_aElt[1]) + tt_SetOpa(tt_aElt[1].style, opa); + if(tt_aV[SHADOW]) + { + opa = Math.round(opa * 0.8); + tt_SetOpa(tt_aElt[7].style, opa); + tt_SetOpa(tt_aElt[8].style, opa); + } +} +function tt_OnCloseBtnOver(iOver) +{ + var css = tt_aElt[4].style; + + iOver <<= 1; + css.background = tt_aV[CLOSEBTNCOLORS][iOver]; + css.color = tt_aV[CLOSEBTNCOLORS][iOver + 1]; +} +function tt_Int(x) +{ + var y; + + return(isNaN(y = parseInt(x)) ? 0 : y); +} +// Adds or removes the document.mousemove or HoveredElem.mouseout handler +// conveniently. Keeps track of those handlers to prevent them from being +// set or removed redundantly. +function tt_AddRemOutFnc(bAdd) +{ + var PSet = bAdd ? tt_AddEvtFnc : tt_RemEvtFnc; + + if(bAdd != tt_AddRemOutFnc.bOn) + { + PSet(tt_over, "mouseout", tt_OnOut); + tt_AddRemOutFnc.bOn = bAdd; + if(!bAdd) + tt_OpReHref(); + } +} +tt_AddRemOutFnc.bOn = false; +Number.prototype.Timer = function(s, iT, bUrge) +{ + if(!this.value || bUrge) + this.value = window.setTimeout(s, iT); +} +Number.prototype.EndTimer = function() +{ + if(this.value) + { + window.clearTimeout(this.value); + this.value = 0; + } +} +function tt_SetOpa(css, opa) +{ + tt_opa = opa; + if(tt_flagOpa == 1) + { + // Hack for bugs of IE: + // A DIV cannot be made visible in a single step if an opacity < 100 + // has been applied while the DIV was hidden. + // Moreover, in IE6, applying an opacity < 100 has no effect if the + // concerned element has no layout (position, size, zoom, ...). + if(opa < 100) + { + var bVis = css.visibility != "hidden"; + css.zoom = "100%"; + if(!bVis) + css.visibility = "visible"; + css.filter = "alpha(opacity=" + opa + ")"; + if(!bVis) + css.visibility = "hidden"; + } + else + css.filter = ""; + } + else + { + opa /= 100.0; + switch(tt_flagOpa) + { + case 2: + css.KhtmlOpacity = opa; break; + case 3: + css.KHTMLOpacity = opa; break; + case 4: + css.MozOpacity = opa; break; + case 5: + css.opacity = opa; break; + } + } +} +function tt_MovDomNode(el, dadFrom, dadTo) +{ + if(dadFrom) + dadFrom.removeChild(el); + if(dadTo) + dadTo.appendChild(el); +} +function tt_Err(sErr) +{ + if(tt_Debug) + alert("Tooltip Script Error Message:\n\n" + sErr); +} + +//=========== DEALING WITH EXTENSIONS ==============// +function tt_ExtCmdEnum() +{ + var s; + + // Add new command(s) to the commands enum + for(var i in config) + { + s = "window." + i.toString().toUpperCase(); + if(eval("typeof(" + s + ") == tt_u")) + { + eval(s + " = " + tt_aV.length); + tt_aV[tt_aV.length] = null; + } + } +} +function tt_ExtCallFncs(arg, sFnc) +{ + var b = false; + for(var i = tt_aExt.length; i;) + {--i; + var fnc = tt_aExt[i]["On" + sFnc]; + // Call the method the extension has defined for this event + if(fnc && fnc(arg)) + b = true; + } + return b; +} + +tt_Init(); |
From: Mike G. v. a. <we...@ma...> - 2010-06-13 02:50:25
|
Log Message: ----------- CourseAdmin has minor changes in format for presenting the results of upgrading courses. Problem.pm adds tool tips to the answer preview and to the correct answer preview using Walter Zorn's tooltip package. Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator: CourseAdmin.pm Problem.pm Revision Data ------------- Index: Problem.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm,v retrieving revision 1.226 retrieving revision 1.227 diff -Llib/WeBWorK/ContentGenerator/Problem.pm -Llib/WeBWorK/ContentGenerator/Problem.pm -u -r1.226 -r1.227 --- lib/WeBWorK/ContentGenerator/Problem.pm +++ lib/WeBWorK/ContentGenerator/Problem.pm @@ -261,8 +261,14 @@ my $row; #$row .= CGI::td($name); $row .= $showAttemptAnswers ? CGI::td($self->nbsp($studentAnswer)) : ""; - $row .= $showAttemptPreview ? CGI::td({title=>"$studentAnswer"}, $self->nbsp($preview)) : ""; - $row .= $showCorrectAnswers ? CGI::td({title=> "$correctAnswerPreview"}, $self->nbsp($correctAnswer)) : ""; + $row .= $showAttemptPreview ? CGI::td({onmouseover=>qq!Tip('$studentAnswer',SHADOW, true, + DELAY, 1000, FADEIN, 300, FADEOUT, 300, STICKY, 1, OFFSETX, -20, CLOSEBTN, true, CLICKCLOSE, false, + BGCOLOR, '#F4FF91', TITLE, 'Entered:',TITLEBGCOLOR, '#F4FF91', TITLEFONTCOLOR, '#000000')!}, + $self->nbsp($preview)) : ""; + $row .= $showCorrectAnswers ? CGI::td({onmouseover=> qq!Tip('$correctAnswer',SHADOW, true, + DELAY, 1000, FADEIN, 300, FADEOUT, 300, STICKY, 1, OFFSETX, -20, CLOSEBTN, true, CLICKCLOSE, false, + BGCOLOR, '#F4FF91', TITLE, 'Entered:',TITLEBGCOLOR, '#F4FF91', TITLEFONTCOLOR, '#000000')!}, + $self->nbsp($correctAnswerPreview)) : ""; $row .= $showAttemptResults ? CGI::td($self->nbsp($resultString)) : ""; $row .= $showMessages ? CGI::td({-class=>"Message"},$self->nbsp($answerMessage)) : ""; push @tableRows, $row; @@ -321,7 +327,9 @@ # duplication that can be dealt with later by abstracting out tth/dvipng/etc. my $tex = $answerResult->{preview_latex_string}; - + my $student_ans = $answerResult->{student_ans}; + my $mouseover = qq!Tip('$student_ans')!; + return "" unless defined $tex and $tex ne ""; if ($displayMode eq "plainText") { @@ -365,6 +373,7 @@ } } elsif ($displayMode eq "images") { + $imgGen->{mouseover} = $answerResult->{student_ans}; $imgGen->add($tex); } elsif ($displayMode eq "jsMath") { $tex =~ s/</</g; $tex =~ s/>/>/g; @@ -388,6 +397,8 @@ my $tex = $answerResult->{correct_value}->TeX; + my $correct_ans = $answerResult->{correct_ans}; + my $mouseover = qq!Tip('$correct_ans')!; return "" unless defined $tex and $tex ne ""; if ($displayMode eq "plainText") { @@ -431,6 +442,7 @@ } } elsif ($displayMode eq "images") { + $imgGen->{mouseover} = $mouseover; $imgGen->add($tex); } elsif ($displayMode eq "jsMath") { $tex =~ s/</</g; $tex =~ s/>/>/g; @@ -1023,6 +1035,10 @@ } debug("end answer processing"); + ##### javaScripts ############# + my $site_url = $ce->{webworkURLs}->{htdocs}; + print qq!<script type="text/javascript" src="$site_url/js/wz_tooltip.js"></script>!; + ##### output ##### # custom message for editor Index: CourseAdmin.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/CourseAdmin.pm,v retrieving revision 1.90 retrieving revision 1.91 diff -Llib/WeBWorK/ContentGenerator/CourseAdmin.pm -Llib/WeBWorK/ContentGenerator/CourseAdmin.pm -u -r1.90 -r1.91 --- lib/WeBWorK/ContentGenerator/CourseAdmin.pm +++ lib/WeBWorK/ContentGenerator/CourseAdmin.pm @@ -2578,7 +2578,7 @@ foreach my $table_name (@tables_to_alter) { #warn "do_upgrade_course: adding new fields to table $table_name in course $upgrade_courseID"; $update_error_msg{$upgrade_courseID} .= $CIchecker->updateTableFields($upgrade_courseID, $table_name); } - print CGI::p({-style=>'color:green; font-weight:bold'}, $update_error_msg{$upgrade_courseID}); + ### $update_error_msg{$upgrade_courseID} is printed below ############################################################################# # Add missing directories when it can be done safely ############################################################################# #warn "do_upgrade_course: updating course directories for $upgrade_courseID"; @@ -2588,8 +2588,6 @@ ############################################################################# # Analyze database status and prepare status report ############################################################################# - print CGI::checkbox({name=>"upgrade_courseIDs", label=>'upgrade', selected=>1,value=>$upgrade_courseID}). - "Report for course $upgrade_courseID:".CGI::br(); ($tables_ok,$dbStatus) = $CIchecker->checkCourseTables($upgrade_courseID); @@ -2628,7 +2626,9 @@ ############################################################################# # Print status ############################################################################# - + print " Report for course $upgrade_courseID:".CGI::br(); + print CGI::p({-style=>'color:green; font-weight:bold'}, $update_error_msg{$upgrade_courseID}); + print CGI::p($str); # print message about tables print CGI::p($dir_msg); # message about directories |
From: Mike G. v. a. <we...@ma...> - 2010-06-12 19:46:55
|
Log Message: ----------- added buttons that select all or select non via javaScript made some style changes in the presentation of the reports. VS: ---------------------------------------------------------------------- Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator: CourseAdmin.pm Revision Data ------------- Index: CourseAdmin.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/CourseAdmin.pm,v retrieving revision 1.89 retrieving revision 1.90 diff -Llib/WeBWorK/ContentGenerator/CourseAdmin.pm -Llib/WeBWorK/ContentGenerator/CourseAdmin.pm -u -r1.89 -r1.90 --- lib/WeBWorK/ContentGenerator/CourseAdmin.pm +++ lib/WeBWorK/ContentGenerator/CourseAdmin.pm @@ -2357,6 +2357,19 @@ #my $urlpath = $r->urlpath; + my $selectAll =CGI::input({-type=>'button', -name=>'check_all', -value=>'Select all eligible courses', + onClick => "for (i in document.courselist.elements) { + if (document.courselist.elements[i].name =='upgrade_courseIDs') { + document.courselist.elements[i].checked = true + } + }" }); + my $selectNone =CGI::input({-type=>'button', -name=>'check_none', -value=>'Unselect all courses', + onClick => "for (i in document.courselist.elements) { + if (document.courselist.elements[i].name =='upgrade_courseIDs') { + document.courselist.elements[i].checked = false + } + }" }); + my @courseIDs = listCourses($ce); @courseIDs = sort {lc($a) cmp lc ($b) } @courseIDs; #make sort case insensitive @@ -2366,7 +2379,8 @@ "Update the checked directories?" ); - print CGI::start_form(-method=>"POST", -action=>$r->uri); + print CGI::start_form(-method=>"POST", -action=>$r->uri, -id=>"courselist", -name=>"courselist"), + CGI::p($selectAll, $selectNone); print $self->hidden_authen_fields; print $self->hidden_fields("subDisplay"); @@ -2574,14 +2588,15 @@ ############################################################################# # Analyze database status and prepare status report ############################################################################# + print CGI::checkbox({name=>"upgrade_courseIDs", label=>'upgrade', selected=>1,value=>$upgrade_courseID}). + "Report for course $upgrade_courseID:".CGI::br(); ($tables_ok,$dbStatus) = $CIchecker->checkCourseTables($upgrade_courseID); - + my ($all_tables_ok, $extra_database_tables, $extra_database_fields, $str) = formatReportOnDatabaseTables($tables_ok, $dbStatus); # prepend course name - $str = CGI::checkbox({name=>"upgrade_courseIDs", label=>'upgrade', selected=>1,value=>$upgrade_courseID}). - "Report for course $upgrade_courseID:".CGI::br()."Database:".CGI::br(). $str; + $str = CGI::br()."Database:".CGI::br(). $str; ############################################################################# # Report on databases and report summary @@ -2603,7 +2618,7 @@ my ($directories_ok, $str2) = $CIchecker->checkCourseDirectories(); my $style = ($directories_ok)?"color:green" : "color:red"; my $dir_msg = join ('', - CGI::h2("Directory structure"), + "Directory structure",CGI::br(), CGI::p($str2), ($directories_ok)? CGI::p({style=>$style},"Directory structure is ok") : CGI::p({style=>$style},"Directory structure is missing directories |
From: Mike G. v. a. <we...@ma...> - 2010-06-12 19:45:19
|
Log Message: ----------- remove ? typo at beginning of file Modified Files: -------------- webwork2/lib/WeBWorK: PG.pm Revision Data ------------- Index: PG.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/PG.pm,v retrieving revision 1.79 retrieving revision 1.80 diff -Llib/WeBWorK/PG.pm -Llib/WeBWorK/PG.pm -u -r1.79 -r1.80 --- lib/WeBWorK/PG.pm +++ lib/WeBWorK/PG.pm @@ -1,4 +1,4 @@ -?################################################################################ +################################################################################ # WeBWorK Online Homework Delivery System # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader$ |
From: dpvc v. a. <we...@ma...> - 2010-06-12 11:13:00
|
Log Message: ----------- Clear all previous anwer data when the problem is reset Modified Files: -------------- pg/macros: problemRandomize.pl Revision Data ------------- Index: problemRandomize.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/problemRandomize.pl,v retrieving revision 1.13 retrieving revision 1.14 diff -Lmacros/problemRandomize.pl -Lmacros/problemRandomize.pl -u -r1.13 -r1.14 --- macros/problemRandomize.pl +++ macros/problemRandomize.pl @@ -233,6 +233,8 @@ foreach my $id (split(/;/,$status->{answers})) {delete $main::inputs_ref->{$id}} foreach my $id (1..$status->{ans_rule_count}) {delete $main::inputs_ref->{"${main::QUIZ_PREFIX}${main::ANSWER_PREFIX}$id"}} + foreach my $id (keys %{$main::inputs_ref}) + {if ($id =~ m/^previous_(.*)$/) {delete $main::inputs_ref->{$1}; delete $main::inputs_ref->{$id}}} $main::inputs_ref->{_status} = $self->encode(\%defaultStatus); $status->{seed} = ($main::inputs_ref->{_reseed} || seed()); } |
From: Mike G. v. a. <we...@ma...> - 2010-06-12 02:11:23
|
Log Message: ----------- Added a "upgrade course" set of forms and handlers. The main page will no longer check the course directory and database structures (and will therefore load faster). the "upgrade" page will allow you to upgrade the structures, where possible, of all courses with a single button push command. Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator: CourseAdmin.pm Revision Data ------------- Index: CourseAdmin.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/CourseAdmin.pm,v retrieving revision 1.88 retrieving revision 1.89 diff -Llib/WeBWorK/ContentGenerator/CourseAdmin.pm -Llib/WeBWorK/ContentGenerator/CourseAdmin.pm -u -r1.88 -r1.89 --- lib/WeBWorK/ContentGenerator/CourseAdmin.pm +++ lib/WeBWorK/ContentGenerator/CourseAdmin.pm @@ -188,15 +188,22 @@ elsif ($subDisplay eq "archive_course") { if (defined $r->param("archive_course")) { - # validate or confirm + # validate -- if invalid, start over. + # if form is valid a page indicating the status of + # database tables and directories is presented. + # If they are ok, then you can push archive button, otherwise + # you can quit or choose to upgrade the tables @errors = $self->archive_course_validate; if (@errors) { $method_to_call = "archive_course_form"; } else { - $method_to_call = "archive_course_confirm"; + $method_to_call = "archive_course_confirm"; #check tables & directories } } elsif (defined $r->param("confirm_archive_course")) { # validate and archive + # the "archive it" button has been pushed and the + # course will be archived + # a report on success or failure will be generated @errors = $self->archive_course_validate; if (@errors) { $method_to_call = "archive_course_form"; @@ -205,11 +212,14 @@ } } elsif (defined $r->param("upgrade_course_tables") ){ # upgrade and revalidate + # the "upgrade course" button has been pushed + # after the course has been upgraded you are returned + # to the confirm page. @errors = $self->archive_course_validate; if (@errors) { $method_to_call = "archive_course_form"; } else { - $method_to_call = "archive_course_confirm"; + $method_to_call = "archive_course_confirm"; # upgrade and recheck tables & directories. } } else { # form only @@ -235,9 +245,35 @@ } } else { # form only + # start at the beginning -- get drop down list of courses to unarchive $method_to_call = "unarchive_course_form"; } } + elsif ($subDisplay eq "upgrade_course") { + if (defined $r->param("upgrade_course")) { + # validate or confirm + # if form is valid present details of analysis of the course structure + @errors = $self->upgrade_course_validate; + if (@errors) { + $method_to_call = "upgrade_course_form"; + } else { + $method_to_call = "upgrade_course_confirm"; + } + } elsif (defined $r->param("confirm_upgrade_course")) { + # validate and upgrade + # if form is valid upgrade the courses and present results + @errors = $self->upgrade_course_validate; + if (@errors) { + $method_to_call = "upgrade_course_form"; + } else { + $method_to_call = "do_upgrade_course"; + } + } else { + # form only + # start at the beginning -- get list of courses and their status + $method_to_call = "upgrade_course_form"; + } + } elsif ($subDisplay eq "manage_locations") { if (defined ($r->param("manage_location_action"))) { $method_to_call = @@ -346,6 +382,8 @@ "|", CGI::a({href=>$self->systemLink($urlpath, params=>{subDisplay=>"unarchive_course"})}, "Unarchive Course"), "|", + CGI::a({href=>$self->systemLink($urlpath, params=>{subDisplay=>"upgrade_course"})}, "Upgrade courses"), + "|", CGI::a({href=>$self->systemLink($urlpath, params=>{subDisplay=>"manage_locations"})}, "Manage Locations"), CGI::hr(), $methodMessage, @@ -377,22 +415,22 @@ foreach my $courseID (sort {lc($a) cmp lc($b) } @courseIDs) { next if $courseID eq "admin"; # done already above next if $courseID eq "modelCourse"; # modelCourse isn't a real course so don't create missing directories, etc - my $urlpath = $r->urlpath->newFromModule("WeBWorK::ContentGenerator::ProblemSets", courseID => $courseID); - my $tempCE = new WeBWorK::CourseEnvironment({ - %WeBWorK::SeedCE, - courseName => $courseID, - }); - - my $CIchecker = new WeBWorK::Utils::CourseIntegrityCheck(ce=>$tempCE); - my ($tables_ok,$dbStatus) = $CIchecker->checkCourseTables($courseID); - $CIchecker->updateCourseDirectories(); #creates missing html_temp, mailmerge tmpEditFileDir directories; - my ($directories_ok, $str2) = $CIchecker->checkCourseDirectories(); +# my $urlpath = $r->urlpath->newFromModule("WeBWorK::ContentGenerator::ProblemSets", courseID => $courseID); +# my $tempCE = new WeBWorK::CourseEnvironment({ +# %WeBWorK::SeedCE, +# courseName => $courseID, +# }); +# +# my $CIchecker = new WeBWorK::Utils::CourseIntegrityCheck(ce=>$tempCE); +# my ($tables_ok,$dbStatus) = $CIchecker->checkCourseTables($courseID); +# $CIchecker->updateCourseDirectories(); #creates missing html_temp, mailmerge tmpEditFileDir directories; +# my ($directories_ok, $str2) = $CIchecker->checkCourseDirectories(); print CGI::li(CGI::a({href=>$self->systemLink($urlpath, authen => 0)}, $courseID), - CGI::code( - $tempCE->{dbLayoutName}, - ), - $directories_ok ? "" : CGI::span({style=>"color:red"},"Directory structure or permissions need to be repaired. "), - $tables_ok ? CGI::span({style=>"color:green"},"Database tables ok") : CGI::span({style=>"color:red"},"Database tables need updating."), +# CGI::code( +# $tempCE->{dbLayoutName}, +# ), +# $directories_ok ? "" : CGI::span({style=>"color:red"},"Directory structure or permissions need to be repaired. "), +# $tables_ok ? CGI::span({style=>"color:green"},"Database tables ok") : CGI::span({style=>"color:red"},"Database tables need updating."), ); @@ -1941,7 +1979,7 @@ ); } ############################################################################# -# Check directories +# Check directories and report ############################################################################# @@ -2308,6 +2346,291 @@ } } +########################################################################## + +sub upgrade_course_form { + my ($self) = @_; + my $r = $self->r; + my $ce = $r->ce; + #my $db = $r->db; + #my $authz = $r->authz; + #my $urlpath = $r->urlpath; + + + my @courseIDs = listCourses($ce); + @courseIDs = sort {lc($a) cmp lc ($b) } @courseIDs; #make sort case insensitive + + print CGI::h2("Upgrade Courses"); + + print CGI::p( + "Update the checked directories?" + ); + + print CGI::start_form(-method=>"POST", -action=>$r->uri); + print $self->hidden_authen_fields; + print $self->hidden_fields("subDisplay"); + + foreach my $courseID ( @courseIDs) { + next if $courseID eq "admin"; # done already above + next if $courseID eq "modelCourse"; # modelCourse isn't a real course so don't create missing directories, etc + next unless $courseID =~/\S/; # skip empty courseIDs (there shouldn't be any + my $urlpath = $r->urlpath->newFromModule("WeBWorK::ContentGenerator::ProblemSets", courseID => $courseID); + my $tempCE; + eval{ $tempCE = new WeBWorK::CourseEnvironment({ + %WeBWorK::SeedCE, + courseName => $courseID, + })}; + print "Can't create course environment for $courseID because $@" if $@; + my $CIchecker = new WeBWorK::Utils::CourseIntegrityCheck(ce=>$tempCE); + $CIchecker->updateCourseDirectories(); #creates missing html_temp, mailmerge tmpEditFileDir directories; + my ($tables_ok,$dbStatus) = $CIchecker->checkCourseTables($courseID); + my ($directories_ok, $str2) = $CIchecker->checkCourseDirectories(); + my $checked = ($tables_ok && $directories_ok)?0:1; # don't check if everything is ok + my $checkbox_spot = ""; + if ($checked) { # only show checkbox if the course is not up-to-date + $checkbox_spot = CGI::checkbox({name=>"upgrade_courseIDs", label=>'upgrade', selected=>$checked,value=>$courseID}); + } + print CGI::li( + $checkbox_spot," ", + CGI::a({href=>$self->systemLink($urlpath, authen => 0)}, $courseID), + CGI::code( + $tempCE->{dbLayoutName}, + ), + $directories_ok ? "" : CGI::span({style=>"color:red"},"Directory structure or permissions need to be repaired. "), + $tables_ok ? CGI::span({style=>"color:green"},"Database tables ok") : CGI::span({style=>"color:red"},"Database tables need updating."), + + ); + + } + + + + print CGI::p({style=>"text-align: center"}, CGI::submit(-name=>"upgrade_course", -value=>"Upgrade Courses")); + + print CGI::end_form(); +} + +sub upgrade_course_validate { + my ($self) = @_; + my $r = $self->r; + my $ce = $r->ce; + #my $db = $r->db; + #my $authz = $r->authz; + my $urlpath = $r->urlpath; + + my @upgrade_courseIDs = $r->param("upgrade_courseIDs") ; + @upgrade_courseIDs = () unless @upgrade_courseIDs; + #warn "validate: upgrade ids ", join("|",@upgrade_courseIDs); + my @errors; + foreach my $upgrade_courseID (@upgrade_courseIDs) { + if ($upgrade_courseID eq "") { + push @errors, "You must specify a course name."; + } + } + + + return @errors; +} + +sub upgrade_course_confirm { + my ($self) = @_; + my $r = $self->r; + my $ce = $r->ce; + my $db = $r->db; + + + my @upgrade_courseIDs = $r->param("upgrade_courseIDs"); + @upgrade_courseIDs = () unless @upgrade_courseIDs; + #my $upgrade_courseID = $upgrade_courseIDs[0]; + my %update_error_msg = (); + print CGI::start_form(-method=>"POST", -action=>$r->uri); + foreach my $upgrade_courseID (@upgrade_courseIDs) { + next unless $upgrade_courseID =~/\S/; # skip empty values + ########################## + # analyze one course + ########################## + my $ce2 = new WeBWorK::CourseEnvironment({ + %WeBWorK::SeedCE, + courseName => $upgrade_courseID, + }); + #warn "upgrade_course_confirm: updating |$upgrade_courseID| from course list: " , join("|",@upgrade_courseIDs); + + ############################################################################# + # Create integrity checker + ############################################################################# + + my $CIchecker = new WeBWorK::Utils::CourseIntegrityCheck(ce=>$ce2); + + ############################################################################# + # Report on database status + ############################################################################# + + my ($tables_ok,$dbStatus) = $CIchecker->checkCourseTables($upgrade_courseID); + my ($all_tables_ok, $extra_database_tables, $extra_database_fields, $str) = formatReportOnDatabaseTables($tables_ok, $dbStatus); + # prepend course name + $str = CGI::checkbox({name=>"upgrade_courseIDs", label=>'upgrade', selected=>1,value=>$upgrade_courseID}). + "Report for course $upgrade_courseID:".CGI::br()."Database:".CGI::br(). $str; + + ############################################################################# + # Report on databases + ############################################################################# + + print CGI::p($str); + if ($extra_database_tables) { + print CGI::p({-style=>'color:red; font-weight:bold'},"There are extra database tables which are not defined in the schema. + They can only be removed manually from the database."); + } + if ($extra_database_fields) { + print CGI::p({-style=>'color:red; font-weight:bold'},"There are extra database fields which are not defined in the schema for at least one table. + They can only be removed manually from the database."); + } + + + ############################################################################# + # Report on directory status + ############################################################################# + my ($directories_ok, $str2) = $CIchecker->checkCourseDirectories(); + my $style = ($directories_ok)?"color:green" : "color:red"; + print "Directory structure".CGI::br(), CGI::p($str2), + ($directories_ok)? CGI::p({style=>$style},"Directory structure is ok") : + CGI::p({style=>$style},"Directory structure is missing directories + or the webserver lacks sufficient privileges."); + } + #warn "upgrade_course_confirm: now print form"; + ############################################################################# + # Print form for choosing next action. + ############################################################################# + print CGI::h3("No course id defined") unless @upgrade_courseIDs; + + + print $self->hidden_authen_fields; + print $self->hidden_fields("subDisplay"); + #print CGI::hidden('upgrade_courseIDs',@upgrade_courseIDs); + + #################################################################### + # Submit buttons + # After presenting a detailed summary of status of selected courses the choice is made to + # upgrade the selected courses (confirm_upgrade_course is set + # or return to the beginning (decline_upgrade_course is set + + #################################################################### + print CGI::p({style=>"text-align: center"}, + CGI::submit(-name =>"decline_upgrade_course", -value => "Don't upgrade"), + CGI::submit(-name=>"confirm_upgrade_course", -value=>"Upgrade") ); + + print CGI::h3("upgrade_course_confirm subroutine"); + + print CGI::end_form(); + +} + +sub do_upgrade_course { + my ($self) = @_; + my $r = $self->r; + my $ce = $r->ce; + my $db = $r->db; + + + my @upgrade_courseIDs = $r->param("upgrade_courseIDs"); + @upgrade_courseIDs = () unless @upgrade_courseIDs; + my %update_error_msg = (); + #warn "do_upgrade_course: upgrade_courseIDs = ", join(" ", @upgrade_courseIDs); + foreach my $upgrade_courseID (@upgrade_courseIDs) { + next unless $upgrade_courseID =~ /\S/; # omit blank course IDs + + ########################## + # update one course + ########################## + my $ce2 = new WeBWorK::CourseEnvironment({ + %WeBWorK::SeedCE, + courseName => $upgrade_courseID, + }); + #warn "do_upgrade_course: updating |$upgrade_courseID| from" , join("|",@upgrade_courseIDs); + ############################################################################# + # Create integrity checker + ############################################################################# + + my $CIchecker = new WeBWorK::Utils::CourseIntegrityCheck(ce=>$ce2); + + ############################################################################# + # Add missing tables and missing fields to existing tables + ############################################################################# + + my ($tables_ok,$dbStatus) = $CIchecker->checkCourseTables($upgrade_courseID); + my @schema_table_names = keys %$dbStatus; # update tables missing from database; + my @tables_to_create = grep {$dbStatus->{$_}->[0] == WeBWorK::Utils::CourseIntegrityCheck::ONLY_IN_A} @schema_table_names; + my @tables_to_alter = grep {$dbStatus->{$_}->[0] == WeBWorK::Utils::CourseIntegrityCheck::DIFFER_IN_A_AND_B} @schema_table_names; + $update_error_msg{$upgrade_courseID} = $CIchecker->updateCourseTables($upgrade_courseID, [@tables_to_create]); + foreach my $table_name (@tables_to_alter) { #warn "do_upgrade_course: adding new fields to table $table_name in course $upgrade_courseID"; + $update_error_msg{$upgrade_courseID} .= $CIchecker->updateTableFields($upgrade_courseID, $table_name); + } + print CGI::p({-style=>'color:green; font-weight:bold'}, $update_error_msg{$upgrade_courseID}); + ############################################################################# + # Add missing directories when it can be done safely + ############################################################################# #warn "do_upgrade_course: updating course directories for $upgrade_courseID"; + $CIchecker -> updateCourseDirectories(); # needs more error messages + + + ############################################################################# + # Analyze database status and prepare status report + ############################################################################# + + ($tables_ok,$dbStatus) = $CIchecker->checkCourseTables($upgrade_courseID); + + my ($all_tables_ok, $extra_database_tables, $extra_database_fields, $str) + = formatReportOnDatabaseTables($tables_ok, $dbStatus); + # prepend course name + $str = CGI::checkbox({name=>"upgrade_courseIDs", label=>'upgrade', selected=>1,value=>$upgrade_courseID}). + "Report for course $upgrade_courseID:".CGI::br()."Database:".CGI::br(). $str; + + ############################################################################# + # Report on databases and report summary + ############################################################################# + + + if ($extra_database_tables) { + $str .= CGI::p({-style=>'color:red; font-weight:bold'},"There are extra database tables which are not defined in the schema. + They can only be removed manually from the database."); + } + if ($extra_database_fields) { + $str .= CGI::p({-style=>'color:red; font-weight:bold'},"There are extra database fields which are not defined in the schema for at least one table. + They can only be removed manually from the database."); + } + + ############################################################################# + # Prepare report on directory status + ############################################################################# + my ($directories_ok, $str2) = $CIchecker->checkCourseDirectories(); + my $style = ($directories_ok)?"color:green" : "color:red"; + my $dir_msg = join ('', + CGI::h2("Directory structure"), + CGI::p($str2), + ($directories_ok)? CGI::p({style=>$style},"Directory structure is ok") : + CGI::p({style=>$style},"Directory structure is missing directories + or the webserver lacks sufficient privileges.") + ); + + ############################################################################# + # Print status + ############################################################################# + + print CGI::p($str); # print message about tables + print CGI::p($dir_msg); # message about directories + + } + ############################################################################# + # Submit buttons -- return to beginning + ############################################################################# + print CGI::h3("do_upgrade_course subroutine"); + print CGI::start_form(-method=>"POST", -action=>$r->uri); #send back to this script + print $self->hidden_authen_fields; + print $self->hidden_fields("subDisplay"); + print CGI::p({style=>"text-align: center"}, CGI::submit(-name=>"decline_upgrade_course", -value=>"Continue") ); + print CGI::end_form(); +} + + + ################################################################################ ## location management routines; added by DG [Danny Ginn] 20070215 ## revised by glarose @@ -2901,4 +3224,70 @@ } ################################################################################ +# Utilities +################################################################################ +sub formatReportOnDatabaseTables { + my ($tables_ok,$dbStatus) = @_; + + # print db status + + my %msg =( WeBWorK::Utils::CourseIntegrityCheck::ONLY_IN_A => CGI::span({style=>"color:red"}," Table defined in schema but missing in database"), + WeBWorK::Utils::CourseIntegrityCheck::ONLY_IN_B => CGI::span({style=>"color:red"}," Table defined in database but missing in schema"), + WeBWorK::Utils::CourseIntegrityCheck::SAME_IN_A_AND_B => CGI::span({style=>"color:green"}," Table is ok "), + WeBWorK::Utils::CourseIntegrityCheck::DIFFER_IN_A_AND_B => CGI::span({style=>"color:red"}," Schema and database table definitions do not agree "), + ); + my %msg2 =( WeBWorK::Utils::CourseIntegrityCheck::ONLY_IN_A => CGI::span({style=>"color:red"}," missing in database"), + WeBWorK::Utils::CourseIntegrityCheck::ONLY_IN_B => CGI::span({style=>"color:red"}," missing in schema"), + WeBWorK::Utils::CourseIntegrityCheck::SAME_IN_A_AND_B => CGI::span({style=>"color:green"}," is ok "), + WeBWorK::Utils::CourseIntegrityCheck::DIFFER_IN_A_AND_B => CGI::span({style=>"color:red"}," Schema and database field definitions do not agree "), + ); + my $all_tables_ok=1; + my $extra_database_tables=0; + my $extra_database_fields=0; + my $str =''; + $str .= CGI::start_ul(); + foreach my $table (sort keys %$dbStatus) { + my $table_status = $dbStatus->{$table}->[0]; + $str .= CGI::li( CGI::b($table) . $msg{ $table_status } ); + + CASE: { + $table_status == WeBWorK::Utils::CourseIntegrityCheck::SAME_IN_A_AND_B + && do{ last CASE; + }; + $table_status == WeBWorK::Utils::CourseIntegrityCheck::ONLY_IN_A + && do{ + $all_tables_ok = 0; last CASE; + }; + $table_status == WeBWorK::Utils::CourseIntegrityCheck::ONLY_IN_B + && do{ + $extra_database_tables = 1; last CASE; + }; + $table_status == WeBWorK::Utils::CourseIntegrityCheck::DIFFER_IN_A_AND_B + && do{ + my %fieldInfo = %{ $dbStatus->{$table}->[1] }; + $str .=CGI::start_ul(); + foreach my $key (keys %fieldInfo) { + my $field_status = $fieldInfo{$key}->[0]; + CASE2: { + $field_status == WeBWorK::Utils::CourseIntegrityCheck::ONLY_IN_B + && do{ + $extra_database_fields = 1; last CASE2; + }; + $field_status == WeBWorK::Utils::CourseIntegrityCheck::ONLY_IN_A + && do{ + $all_tables_ok=0; last CASE2; + }; + } + $str .= CGI::li("Field $key => ". $msg2{$field_status }); + } + $str .= CGI::end_ul(); + }; + } + + + } + $str.=CGI::end_ul(); + $str .= ($all_tables_ok)?CGI::p("Database tables are ok") : ""; + return ($all_tables_ok, $extra_database_tables, $extra_database_fields, $str); +} 1; |
From: Mike G. v. a. <we...@ma...> - 2010-06-12 02:09:04
|
Log Message: ----------- added some UI niceties Modified Files: -------------- webwork2/lib/WeBWorK/Utils: CourseIntegrityCheck.pm Revision Data ------------- Index: CourseIntegrityCheck.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/Utils/CourseIntegrityCheck.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -Llib/WeBWorK/Utils/CourseIntegrityCheck.pm -Llib/WeBWorK/Utils/CourseIntegrityCheck.pm -u -r1.7 -r1.8 --- lib/WeBWorK/Utils/CourseIntegrityCheck.pm +++ lib/WeBWorK/Utils/CourseIntegrityCheck.pm @@ -96,6 +96,7 @@ sub checkCourseTables { my ($self, $courseName) = @_; + warn "Course name is not defined".caller(2), unless defined($courseName) and $courseName =~/\S/; my $str=''; my $tables_ok = 1; my %dbStatus = (); @@ -321,9 +322,9 @@ $style = "color:red"; } - push @results, CGI::span({style=>$style},"$dir => $path $status <br/>\n"); + push @results, CGI::li( "$dir =>".CGI::span({style=>$style}," $path $status <br/>\n") ); } - $str = join(" ",@results); + $str = CGI::start_ul(). join(" ",@results) . CGI::end_ul(); return ( $directories_ok, $str); } @@ -335,7 +336,7 @@ =cut sub updateCourseDirectories { - my ($self) = @_; + my $self = shift; my $ce = $self->{ce}; my @webworkDirectories = keys %{$ce->{webworkDirs}}; my @courseDirectories = keys %{$ce->{courseDirs}}; |
From: Mike G. v. a. <we...@ma...> - 2010-06-12 02:08:10
|
Log Message: ----------- got rid of a foobar Modified Files: -------------- webwork2/lib/WeBWorK: PG.pm Revision Data ------------- Index: PG.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/PG.pm,v retrieving revision 1.78 retrieving revision 1.79 diff -Llib/WeBWorK/PG.pm -Llib/WeBWorK/PG.pm -u -r1.78 -r1.79 --- lib/WeBWorK/PG.pm +++ lib/WeBWorK/PG.pm @@ -1,4 +1,4 @@ -################################################################################ +?################################################################################ # WeBWorK Online Homework Delivery System # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader$ @@ -167,7 +167,7 @@ $envir{jsMathURL} = $ce->{webworkURLs}->{jsMath}; $envir{asciimathURL} = $ce->{webworkURLs}->{asciimath}; $envir{LaTeXMathMLURL} = $ce->{webworkURLs}->{LaTeXMathML}; - $envir{server_root_url} = $ce->{apache_root_url}|| 'foo_bar'; + $envir{server_root_url} = $ce->{apache_root_url}|| ''; # Information for sending mail |
From: Mike G. v. a. <we...@ma...> - 2010-06-08 12:40:14
|
Log Message: ----------- refactored much ofof the code in renderProblem.pl. This now uses the module webwork2/lib/WebworkClient.pm which also contains code from renderViaXMLRPC Modified Files: -------------- webwork2/clients: checkProblem.pl renderProblem.pl webwork_xmlrpc_inc.pl Revision Data ------------- Index: renderProblem.pl =================================================================== RCS file: /webwork/cvs/system/webwork2/clients/renderProblem.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -Lclients/renderProblem.pl -Lclients/renderProblem.pl -u -r1.6 -r1.7 --- clients/renderProblem.pl +++ clients/renderProblem.pl @@ -34,10 +34,9 @@ use strict; use warnings; -package WeBWorK::ContentGenerator::renderViaXMLRPC_client; -use Crypt::SSLeay; # needed for https -use XMLRPC::Lite; -use MIME::Base64 qw( encode_base64 decode_base64); +use lib '/opt/webwork/webwork2/lib'; +#use Crypt::SSLeay; # needed for https +use WebworkClient; ################################################## # configuration section for client @@ -45,7 +44,10 @@ # configure the local output file and display command !!!!!!!! use constant TEMPOUTPUTFILE => '/Users/gage/Desktop/renderProblemOutput.html'; # client only -use constant DISPLAY_COMMAND => 'open -a firefox '; # mac client only opens tempoutputfile above +#use constant DISPLAY_COMMAND => 'open -a firefox '; # mac client only opens tempoutputfile above + use constant DISPLAY_COMMAND => "open -a 'Google Chrome' "; + + # other command lines for opening the html file gnome-open or firefox file.html # the rest can be configured later to use a different server @@ -57,30 +59,22 @@ $PROTOCOL = 'http'; $HOSTNAME = 'localhost'; $HOSTPORT = 80; - $FULL_URL = "$PROTOCOL://$HOSTNAME:$HOSTPORT"; - $FORM_ACTION_URL = "$FULL_URL/webwork2/html2xml"; $XML_PASSWORD = 'xmlwebwork'; $XML_COURSE = 'daemon_course'; } else { $PROTOCOL = 'https'; # or 'https'; $HOSTNAME = "hosted2.webwork.rochester.edu"; # 'localhost'; $HOSTPORT = 443; #( for secure https) # 80 or 443; - $FULL_URL = "$PROTOCOL://$HOSTNAME:$HOSTPORT"; - $FORM_ACTION_URL = "$FULL_URL/webwork2/html2xml"; # server parameter $XML_PASSWORD = 'xmlwebwork'; $XML_COURSE = 'daemon_course'; } -use constant TRANSPORT_METHOD => 'XMLRPC::Lite'; -use constant REQUEST_CLASS => 'WebworkXMLRPC'; # WebworkXMLRPC is used for soap also!! -use constant REQUEST_URI => 'mod_xmlrpc'; - - + $FULL_URL = "$PROTOCOL://$HOSTNAME:$HOSTPORT"; -use constant DISPLAYMODE => 'images'; # tex and jsMath are other possibilities. +use constant DISPLAYMODE => 'images'; # jsMath is another possibilities. our @COMMANDS = qw( listLibraries renderProblem ); #listLib readFile tex2pdf @@ -90,20 +84,9 @@ # end configuration section ################################################## -sub new { - my $self = { - output => '', - encodedSource => '', - self => '', - inputs_ref => { AnSwEr0001 => '', - AnSwEr0002 => '', - AnSwEr0003 => '', - },, - }; - bless $self; -} -our $xmlrpc_client = new WeBWorK::ContentGenerator::renderViaXMLRPC_client; + +our $xmlrpc_client = new WebworkClient; ################################################## # input/output section @@ -116,15 +99,29 @@ undef $/; $source = <>; #slurp input -$xmlrpc_client->{encodedSource} = encodeSource($source); $/ =1; +$xmlrpc_client->encodeSource($source); +$xmlrpc_client->url($FULL_URL); +$xmlrpc_client->{displayMode} = DISPLAYMODE(); +$xmlrpc_client->{user} = 'xmluser'; +$xmlrpc_client->{password} = $XML_PASSWORD; +$xmlrpc_client->{course} = $XML_COURSE; + #xmlrpcCall('renderProblem'); -$xmlrpc_client->xmlrpcCall('renderProblem'); +our $output; +if ( $xmlrpc_client->xmlrpcCall('renderProblem') ) { + + $output = $xmlrpc_client->formatRenderedProblem; +} else { + $output = $xmlrpc_client->{output}; # error report +} + + local(*FH); open(FH, '>'.TEMPOUTPUTFILE) or die "Can't open file ".TEMPOUTPUTFILE()." for writing"; -print FH $xmlrpc_client->{output} ; +print FH $output; close(FH); system(DISPLAY_COMMAND().TEMPOUTPUTFILE()); @@ -134,316 +131,358 @@ ################################################## -our $result; - ################################################## -# Utilities -- -# this code is identical between renderProblem.pl and renderViaXMLRPC.pm +# XMLRPC client -- +# the code below is identical between renderProblem.pl and renderViaXMLRPC.pm???? +# and has been included in WebworkClient.pm ################################################## -sub xmlrpcCall { - my $self = shift; - my $command = shift; - $command = 'listLibraries' unless $command; - - my $requestResult = TRANSPORT_METHOD - -> proxy($FULL_URL.'/'.REQUEST_URI); - - my $input = $self->setInputTable(); - local( $result); - # use eval to catch errors - eval { $result = $requestResult->call(REQUEST_CLASS.'.'.$command,$input) }; - print STDERR "There were a lot of errors\n" if $@; - print STDERR "Errors: \n $@\n End Errors\n" if $@; - - - - - unless (ref($result) and $result->fault) { - my $rh_result = $result->result(); - #print STDERR pretty_print_rh($rh_result); - $self->{output} = $self->formatRenderedProblem($rh_result); - - } else { - $self->{output} = 'Error from server: '. join( ",\n ", - $result->faultcode, - $result->faultstring); - } -} - -sub encodeSource { - my $source = shift; - encode_base64($source); -} - -sub pretty_print { # provides html output -- NOT a method - my $r_input = shift; - my $level = shift; - $level = 4 unless defined($level); - $level--; - return '' unless $level > 0; # only print three levels of hashes (safety feature) - my $out = ''; - if ( not ref($r_input) ) { - $out = $r_input if defined $r_input; # not a reference - $out =~ s/</</g ; # protect for HTML output - } elsif ("$r_input" =~/hash/i) { # this will pick up objects whose '$self' is hash and so works better than ref($r_iput). - local($^W) = 0; - - $out .= "$r_input " ."<TABLE border = \"2\" cellpadding = \"3\" BGCOLOR = \"#FFFFFF\">"; - - - foreach my $key ( sort ( keys %$r_input )) { - $out .= "<tr><TD> $key</TD><TD>=></td><td> ".pretty_print($r_input->{$key}) . "</td></tr>"; - } - $out .="</table>"; - } elsif (ref($r_input) eq 'ARRAY' ) { - my @array = @$r_input; - $out .= "( " ; - while (@array) { - $out .= pretty_print(shift @array, $level) . " , "; - } - $out .= " )"; - } elsif (ref($r_input) eq 'CODE') { - $out = "$r_input"; - } else { - $out = $r_input; - $out =~ s/</</g; # protect for HTML output - } - - return $out." "; -} - -sub setInputTable_for_listLib { - my $self = shift; - my $out = { - pw => $XML_PASSWORD, - set => 'set0', - library_name => 'Library', - command => 'all', - }; - - $out; -} -sub setInputTable { - my $self = shift; - my $out = { - pw => $XML_PASSWORD, - library_name => 'Library', - command => 'renderProblem', - answer_form_submitted => 1, - course => $XML_COURSE, - extra_packages_to_load => [qw( AlgParserWithImplicitExpand Expr - ExprWithImplicitExpand AnswerEvaluator - AnswerEvaluatorMaker - )], - mode => DISPLAYMODE(), - modules_to_evaluate => [ qw( -Exporter -DynaLoader -GD -WWPlot -Fun -Circle -Label -PGrandom -Units -Hermite -List -Match -Multiple -Select -AlgParser -AnswerHash -Fraction -VectorField -Complex1 -Complex -MatrixReal1 Matrix -Distributions -Regression - - )], - envir => $self->environment(), - problem_state => { - - num_of_correct_ans => 0, - num_of_incorrect_ans => 4, - recorded_score => 1.0, - }, - source => $self->{encodedSource}, #base64 encoded - - - - }; - - $out; -} - -sub environment { - my $self = shift; - my $envir = { - answerDate => '4014438528', - CAPA_Graphics_URL=>"not defined", - CAPA_GraphicsDirectory =>"not defined", - CAPA_MCTools=>"not defined", - CAPA_Tools=>'not defined', - cgiDirectory=>'Not defined', - cgiURL => 'Not defined', - classDirectory=> 'Not defined', - courseName=>'Not defined', - courseScriptsDirectory=>'not defined', - displayMode=>DISPLAYMODE, - dueDate=> '4014438528', - effectivePermissionLevel => 10, - externalGif2EpsPath=>'not defined', - externalPng2EpsPath=>'not defined', - externalTTHPath=>'/usr/local/bin/tth', - fileName=>'set0/prob1a.pg', - formattedAnswerDate=>'6/19/00', - formattedDueDate=>'6/19/00', - formattedOpenDate=>'6/19/00', - functAbsTolDefault=> 0.0000001, - functLLimitDefault=>0, - functMaxConstantOfIntegration=> 1000000000000.0, - functNumOfPoints=> 5, - functRelPercentTolDefault=> 0.000001, - functULimitDefault=>1, - functVarDefault=> 'x', - functZeroLevelDefault=> 0.000001, - functZeroLevelTolDefault=>0.000001, - htmlDirectory =>'not defined', - htmlURL =>'not defined', - inputs_ref => $self->{inputs_ref}, - macroDirectory=>'not defined', - numAbsTolDefault=>0.0000001, - numFormatDefault=>'%0.13g', - numOfAttempts=> 0, - numRelPercentTolDefault => 0.0001, - numZeroLevelDefault =>0.000001, - numZeroLevelTolDefault =>0.000001, - openDate=> '3014438528', - permissionLevel =>10, - PRINT_FILE_NAMES_FOR => [ 'gage'], - probFileName => 'set0/prob1a.pg', - problemSeed => 1234, - problemValue =>1, - probNum => 13, - psvn => 54321, - psvnNumber=> 54321, - questionNumber => 1, - scriptDirectory => 'Not defined', - sectionName => 'Gage', - sectionNumber => 1, - sessionKey=> 'Not defined', - setNumber =>'not defined', - studentLogin =>'gage', - studentName => 'Mike Gage', - tempDirectory => 'not defined', - templateDirectory=>'not defined', - tempURL=>'not defined', - webworkDocsURL => 'not defined', - - showHints => 1, # extra options -- usually passed from the input form - showSolutions => 1, - - }; - $envir; -}; - -sub formatAnswerRow { - my $self = shift; - my $rh_answer = shift; - my $problemNumber = shift; - my $answerString = $rh_answer->{original_student_ans}||' '; - my $correctAnswer = $rh_answer->{correct_ans}||''; - my $ans_message = $rh_answer->{ans_message}||''; - my $score = ($rh_answer->{score}) ? 'Correct' : 'Incorrect'; - my $row = qq{ - <tr> - <td> - Prob: $problemNumber - </td> - <td> - $answerString - </td> - <td> - $score - </td> - <td> - Correct answer is $correctAnswer - </td> - <td> - <i>$ans_message</i> - </td> - </tr>\n - }; - $row; -} - -sub formatRenderedProblem { - my $self = shift; - my $rh_result = shift; # wrap problem in formats - my $problemText = decode_base64($rh_result->{text}); - my $rh_answers = $rh_result->{answers}; - my $encodedSource = $self->{encodedSource}||'foobar'; - my $warnings = ''; - if ( defined ($rh_result->{WARNINGS}) and $rh_result->{WARNINGS} ){ - $warnings = "<div style=\"background-color:pink\"> - <p >WARNINGS</p><p>".decode_base64($rh_result->{WARNINGS})."</p></div>"; - } - #warn "keys: ", join(" | ", sort keys %{$rh_result }); - my $debug_messages = $rh_result->{flags}->{DEBUG_messages} || []; - $debug_messages = join("<br/>\n", @{ $debug_messages } ); - my $internal_debug_messages = $rh_result->{internal_debug_messages} || []; - $internal_debug_messages = join("<br/>\n", @{ $internal_debug_messages } ); - # collect answers - my $answerTemplate = q{<hr>ANSWERS <table border="3" align="center">}; - my $problemNumber = 1; - foreach my $key (sort keys %{$rh_answers}) { - $answerTemplate .= $self->formatAnswerRow($rh_answers->{$key}, $problemNumber++); - } - $answerTemplate .= q{</table> <hr>}; - - - - my $problemTemplate = <<ENDPROBLEMTEMPLATE; -<html> -<head> -<base href="$FULL_URL"> -<title>WeBWorK Editor</title> -</head> -<body> - $answerTemplate - <form action="$FORM_ACTION_URL" method="post"> - $problemText - <input type="hidden" name="answersSubmitted" value="1"> - <input type="hidden" name="problemAddress" value="probSource"> - <input type="hidden" name="problemSource" value="$encodedSource"> - <input type="hidden" name="problemSeed" value="1234"> - <input type="hidden" name="pathToProblemFile" value="foobar"> - <p><input type="submit" name="submit" value="submit answers"></p> - </form> -<HR> -<h3> Warning section </h3> -$warnings -<h3> -Debug message section -</h3> -$debug_messages -<h3> -internal errors -</h3> -$internal_debug_messages - -</body> -</html> - -ENDPROBLEMTEMPLATE - - - - $problemTemplate; -} - +# package WeBWorK::ContentGenerator::renderViaXMLRPC_client; +# +# use Crypt::SSLeay; # needed for https +# use XMLRPC::Lite; +# use MIME::Base64 qw( encode_base64 decode_base64); +# +# use constant TRANSPORT_METHOD => 'XMLRPC::Lite'; +# use constant REQUEST_CLASS => 'WebworkXMLRPC'; # WebworkXMLRPC is used for soap also!! +# use constant REQUEST_URI => 'mod_xmlrpc'; +# +# sub new { +# my $self = { +# output => '', +# encodedSource => '', +# url => '', +# password => '', +# course => '', +# displayMode => '', +# inputs_ref => { AnSwEr0001 => '', +# AnSwEr0002 => '', +# AnSwEr0003 => '', +# }, +# }; +# +# bless $self; +# } +# +# +# our $result; +# +# ################################################## +# # Utilities -- +# # this code is identical between renderProblem.pl and renderViaXMLRPC.pm +# ################################################## +# +# sub xmlrpcCall { +# my $self = shift; +# my $command = shift; +# $command = 'listLibraries' unless $command; +# +# my $requestResult = TRANSPORT_METHOD +# -> proxy($self->{url}.'/'.REQUEST_URI); +# +# my $input = $self->setInputTable(); +# local( $result); +# # use eval to catch errors +# eval { $result = $requestResult->call(REQUEST_CLASS.'.'.$command,$input) }; +# if ($@) { +# print STDERR "There were a lot of errors for $command\n" ; +# print STDERR "Errors: \n $@\n End Errors\n" ; +# return 0 #failure +# } +# +# unless (ref($result) and $result->fault) { +# my $rh_result = $result->result(); +# #print STDERR pretty_print_rh($rh_result); +# $self->{output} = $rh_result; #$self->formatRenderedProblem($rh_result); +# return 1; # success +# +# } else { +# $self->{output} = 'Error from server: '. join( ",\n ", +# $result->faultcode, +# $result->faultstring); +# return 0; #failure +# } +# } +# +# sub encodeSource { +# my $self = shift; +# my $source = shift; +# $self->{encodedSource} =encode_base64($source); +# } +# sub url { +# my $self = shift; +# my $new_url = shift; +# $self->{url} = $new_url if defined($new_url) and $new_url =~ /\S/; +# $self->{url}; +# } +# sub pretty_print { # provides html output -- NOT a method +# my $r_input = shift; +# my $level = shift; +# $level = 4 unless defined($level); +# $level--; +# return '' unless $level > 0; # only print three levels of hashes (safety feature) +# my $out = ''; +# if ( not ref($r_input) ) { +# $out = $r_input if defined $r_input; # not a reference +# $out =~ s/</</g ; # protect for HTML output +# } elsif ("$r_input" =~/hash/i) { # this will pick up objects whose '$self' is hash and so works better than ref($r_iput). +# local($^W) = 0; +# +# $out .= "$r_input " ."<TABLE border = \"2\" cellpadding = \"3\" BGCOLOR = \"#FFFFFF\">"; +# +# +# foreach my $key ( sort ( keys %$r_input )) { +# $out .= "<tr><TD> $key</TD><TD>=></td><td> ".pretty_print($r_input->{$key}) . "</td></tr>"; +# } +# $out .="</table>"; +# } elsif (ref($r_input) eq 'ARRAY' ) { +# my @array = @$r_input; +# $out .= "( " ; +# while (@array) { +# $out .= pretty_print(shift @array, $level) . " , "; +# } +# $out .= " )"; +# } elsif (ref($r_input) eq 'CODE') { +# $out = "$r_input"; +# } else { +# $out = $r_input; +# $out =~ s/</</g; # protect for HTML output +# } +# +# return $out." "; +# } +# +# sub setInputTable_for_listLib { +# my $self = shift; +# my $out = { +# pw => $self->{password}, +# set => 'set0', +# library_name => 'Library', +# command => 'all', +# }; +# +# $out; +# } +# sub setInputTable { +# my $self = shift; +# my $out = { +# pw => $self->{password}, +# library_name => 'Library', +# command => 'renderProblem', +# answer_form_submitted => 1, +# course => $self->{course}, +# extra_packages_to_load => [qw( AlgParserWithImplicitExpand Expr +# ExprWithImplicitExpand AnswerEvaluator +# AnswerEvaluatorMaker +# )], +# mode => $self->{displayMode}, +# modules_to_evaluate => [ qw( +# Exporter +# DynaLoader +# GD +# WWPlot +# Fun +# Circle +# Label +# PGrandom +# Units +# Hermite +# List +# Match +# Multiple +# Select +# AlgParser +# AnswerHash +# Fraction +# VectorField +# Complex1 +# Complex +# MatrixReal1 Matrix +# Distributions +# Regression +# +# )], +# envir => $self->environment(), +# problem_state => { +# +# num_of_correct_ans => 0, +# num_of_incorrect_ans => 4, +# recorded_score => 1.0, +# }, +# source => $self->{encodedSource}, #base64 encoded +# +# +# +# }; +# +# $out; +# } +# +# sub environment { +# my $self = shift; +# my $envir = { +# answerDate => '4014438528', +# CAPA_Graphics_URL=>'http://webwork-db.math.rochester.edu/capa_graphics/', +# CAPA_GraphicsDirectory =>'/ww/webwork/CAPA/CAPA_Graphics/', +# CAPA_MCTools=>'/ww/webwork/CAPA/CAPA_MCTools/', +# CAPA_Tools=>'/ww/webwork/CAPA/CAPA_Tools/', +# cgiDirectory=>'Not defined', +# cgiURL => 'Not defined', +# classDirectory=> 'Not defined', +# courseName=>'Not defined', +# courseScriptsDirectory=>'not defined', +# displayMode=>$self->{displayMode}, +# dueDate=> '4014438528', +# effectivePermissionLevel => 10, +# externalGif2EpsPath=>'not defined', +# externalPng2EpsPath=>'not defined', +# externalTTHPath=>'/usr/local/bin/tth', +# fileName=>'set0/prob1a.pg', +# formattedAnswerDate=>'6/19/00', +# formattedDueDate=>'6/19/00', +# formattedOpenDate=>'6/19/00', +# functAbsTolDefault=> 0.0000001, +# functLLimitDefault=>0, +# functMaxConstantOfIntegration=> 1000000000000.0, +# functNumOfPoints=> 5, +# functRelPercentTolDefault=> 0.000001, +# functULimitDefault=>1, +# functVarDefault=> 'x', +# functZeroLevelDefault=> 0.000001, +# functZeroLevelTolDefault=>0.000001, +# htmlDirectory =>'not defined', +# htmlURL =>'not defined', +# inputs_ref => $self->{inputs_ref}, +# macroDirectory=>'not defined', +# numAbsTolDefault=>0.0000001, +# numFormatDefault=>'%0.13g', +# numOfAttempts=> 0, +# numRelPercentTolDefault => 0.0001, +# numZeroLevelDefault =>0.000001, +# numZeroLevelTolDefault =>0.000001, +# openDate=> '3014438528', +# permissionLevel =>10, +# PRINT_FILE_NAMES_FOR => [ 'gage'], +# probFileName => 'set0/prob1a.pg', +# problemSeed => 1234, +# problemValue =>1, +# probNum => 13, +# psvn => 54321, +# psvnNumber=> 54321, +# questionNumber => 1, +# scriptDirectory => 'Not defined', +# sectionName => 'Gage', +# sectionNumber => 1, +# sessionKey=> 'Not defined', +# setNumber =>'not defined', +# studentLogin =>'gage', +# studentName => 'Mike Gage', +# tempDirectory => 'not defined', +# templateDirectory=>'not defined', +# tempURL=>'not defined', +# webworkDocsURL => 'not defined', +# +# showHints => 1, # extra options -- usually passed from the input form +# showSolutions => 1, +# +# }; +# $envir; +# }; +# +# sub formatAnswerRow { +# my $self = shift; +# my $rh_answer = shift; +# my $problemNumber = shift; +# my $answerString = $rh_answer->{original_student_ans}||' '; +# my $correctAnswer = $rh_answer->{correct_ans}||''; +# my $ans_message = $rh_answer->{ans_message}||''; +# my $score = ($rh_answer->{score}) ? 'Correct' : 'Incorrect'; +# my $row = qq{ +# <tr> +# <td> +# Prob: $problemNumber +# </td> +# <td> +# $answerString +# </td> +# <td> +# $score +# </td> +# <td> +# Correct answer is $correctAnswer +# </td> +# <td> +# <i>$ans_message</i> +# </td> +# </tr>\n +# }; +# $row; +# } +# +# sub formatRenderedProblem { +# my $self = shift; +# my $rh_result = $self->{output}; # wrap problem in formats +# my $problemText = decode_base64($rh_result->{text}); +# my $rh_answers = $rh_result->{answers}; +# my $encodedSource = $self->{encodedSource}||'foobar'; +# my $warnings = ''; +# if ( defined ($rh_result->{WARNINGS}) and $rh_result->{WARNINGS} ){ +# $warnings = "<div style=\"background-color:pink\"> +# <p >WARNINGS</p><p>".decode_base64($rh_result->{WARNINGS})."</p></div>"; +# } +# #warn "keys: ", join(" | ", sort keys %{$rh_result }); +# my $debug_messages = $rh_result->{flags}->{DEBUG_messages} || []; +# $debug_messages = join("<br/>\n", @{ $debug_messages } ); +# my $internal_debug_messages = $rh_result->{internal_debug_messages} || []; +# $internal_debug_messages = join("<br/>\n", @{ $internal_debug_messages } ); +# # collect answers +# my $answerTemplate = q{<hr>ANSWERS <table border="3" align="center">}; +# my $problemNumber = 1; +# foreach my $key (sort keys %{$rh_answers}) { +# $answerTemplate .= $self->formatAnswerRow($rh_answers->{$key}, $problemNumber++); +# } +# $answerTemplate .= q{</table> <hr>}; +# +# my $FULL_URL = $self->url; +# my $FORM_ACTION_URL = "$FULL_URL/webwork2/html2xml"; +# my $problemTemplate = <<ENDPROBLEMTEMPLATE; +# <html> +# <head> +# <base href="$FULL_URL"> +# <title>WeBWorK Editor using host $HOSTNAME</title> +# </head> +# <body> +# $answerTemplate +# <form action="$FORM_ACTION_URL" method="post"> +# $problemText +# <input type="hidden" name="answersSubmitted" value="1"> +# <input type="hidden" name="problemAddress" value="probSource"> +# <input type="hidden" name="problemSource" value="$encodedSource"> +# <input type="hidden" name="problemSeed" value="1234"> +# <input type="hidden" name="pathToProblemFile" value="foobar"> +# <p><input type="submit" name="submit" value="submit answers"></p> +# </form> +# <HR> +# <h3> Warning section </h3> +# $warnings +# <h3> +# Debug message section +# </h3> +# $debug_messages +# <h3> +# internal errors +# </h3> +# $internal_debug_messages +# +# </body> +# </html> +# +# ENDPROBLEMTEMPLATE +# +# +# +# $problemTemplate; +# } +# 1; Index: checkProblem.pl =================================================================== RCS file: /webwork/cvs/system/webwork2/clients/checkProblem.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -Lclients/checkProblem.pl -Lclients/checkProblem.pl -u -r1.3 -r1.4 --- clients/checkProblem.pl +++ clients/checkProblem.pl @@ -13,7 +13,7 @@ =cut -use constant LOG_FILE => '/Volumes/Riemann/webwork/problemLibraries/bad_problems.txt'; +use constant LOG_FILE => '/Users/gage/Desktop//bad_problems.txt'; use XMLRPC::Lite; use MIME::Base64 qw( encode_base64 decode_base64); require "webwork_xmlrpc_inc.pl"; # must be in the same directory Index: webwork_xmlrpc_inc.pl =================================================================== RCS file: /webwork/cvs/system/webwork2/clients/webwork_xmlrpc_inc.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -Lclients/webwork_xmlrpc_inc.pl -Lclients/webwork_xmlrpc_inc.pl -u -r1.3 -r1.4 --- clients/webwork_xmlrpc_inc.pl +++ clients/webwork_xmlrpc_inc.pl @@ -1,131 +1,170 @@ #!/usr/bin/perl -w -=pod +################################################################################ +# WeBWorK Online Homework Delivery System +# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# $CVSHeader$ +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of either: (a) the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any later +# version, or (b) the "Artistic License" which comes with this package. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the +# Artistic License for more details. +################################################################################ + +=head1 NAME + +webwork2/clients/WebworkClient.pm + +This script will take a file and send it to a WeBWorK daemon webservice +to have it rendered. The result is split into the basic HTML rendering +and evaluation of answers and then passed to a browser for printing. -This script will take a command and an input -file. +The formatting allows the browser presentation to be interactive with the +daemon running the script webwork2/lib/renderViaXMLRPC.pm -It will list available libraries, list the contents of libraries -or render the input file. +Rembember to configure the local output file and display command !!!!!!!! -All of this is done by contacting the webservice. +=cut +use strict; +use warnings; -=cut -use XMLRPC::Lite; -use MIME::Base64 qw( encode_base64 decode_base64); -# configuration section -use constant PROTOCOL => 'http'; # or 'http'; -use constant HOSTURL => 'localhost'; -use constant HOSTPORT => 80; -use constant TRANSPORT_METHOD => 'XMLRPC::Lite'; -use constant REQUEST_CLASS => 'WebworkXMLRPC'; # WebworkXMLRPC is used for soap also!! -use constant REQUEST_URI => 'mod_xmlrpc'; -use constant TEMPOUTPUTFILE => '/Users/gage/Desktop/renderProblemOutput.html'; -use constant COURSE => 'daemon2_course'; +our @COMMANDS = qw( listLibraries renderProblem ); #listLib readFile tex2pdf -# $pg{displayModes} = [ -# "plainText", # display raw TeX for math expressions -# "formattedText", # format math expressions using TtH -# "images", # display math expressions as images generated by dvipng -# "jsMath", # render TeX math expressions on the client side using jsMath -# "asciimath", # render TeX math expressions on the client side using ASCIIMathML -# ]; -use constant DISPLAYMODE => 'images'; # tex and jsMath are other possibilities. +################################################## +# XMLRPC client -- +# this code is identical between renderProblem.pl and renderViaXMLRPC.pm???? +################################################## +package WeBWorK::ContentGenerator::WebworkClient; -my @COMMANDS = qw( listLibraries renderProblem ); #listLib readFile tex2pdf +use Crypt::SSLeay; # needed for https +use XMLRPC::Lite; +use MIME::Base64 qw( encode_base64 decode_base64); -# end configuration section +use constant TRANSPORT_METHOD => 'XMLRPC::Lite'; +use constant REQUEST_CLASS => 'WebworkXMLRPC'; # WebworkXMLRPC is used for soap also!! +use constant REQUEST_URI => 'mod_xmlrpc'; +sub new { + my $self = { + output => '', + encodedSource => '', + url => '', + password => '', + course => '', + displayMode => '', + inputs_ref => { AnSwEr0001 => '', + AnSwEr0002 => '', + AnSwEr0003 => '', + }, + }; + bless $self; +} +our $result; +################################################## +# Utilities -- +# this code is identical between renderProblem.pl and renderViaXMLRPC.pm +################################################## sub xmlrpcCall { + my $self = shift; my $command = shift; - my $source = shift; $command = 'listLibraries' unless $command; my $requestResult = TRANSPORT_METHOD - #->uri('http://'.HOSTURL.':'.HOSTPORT.'/'.REQUEST_CLASS) - -> proxy(PROTOCOL.'://'.HOSTURL.':'.HOSTPORT.'/'.REQUEST_URI); + -> proxy($self->{url}.'/'.REQUEST_URI); - my $test = [3,4,5,6]; - my $input = setInputTable($source); - #print "displayMode=",$input->{envir}->{displayMode},"\n"; + my $input = $self->setInputTable(); local( $result); # use eval to catch errors eval { $result = $requestResult->call(REQUEST_CLASS.'.'.$command,$input) }; - print STDERR "There were a lot of errors\n" if $@; - print "Errors: \n $@\n End Errors\n" if $@; - - #print "result is|", ref($result),"|"; + if ($@) { + print STDERR "There were a lot of errors for $command\n" ; + print STDERR "Errors: \n $@\n End Errors\n" ; + return 0 #failure + } unless (ref($result) and $result->fault) { - return $result->result(); # returns result hash + my $rh_result = $result->result(); + #print STDERR pretty_print_rh($rh_result); + $self->{output} = $rh_result; #$self->formatRenderedProblem($rh_result); + return 1; # success + } else { - print 'oops ', join ', ', + $self->{output} = 'Error from server: '. join( ",\n ", $result->faultcode, - $result->faultstring; - return 0; + $result->faultstring); + return 0; #failure } } -sub source { - encode_base64($source); +sub encodeSource { + my $self = shift; + my $source = shift; + $self->{encodedSource} =encode_base64($source); } -sub pretty_print_rh { - shift if UNIVERSAL::isa($_[0] => __PACKAGE__); - my $rh = shift; - my $indent = shift || 0; - my $out = ""; - my $type = ref($rh); - - if (defined($type) and $type) { - $out .= " type = $type; "; - } elsif (! defined($rh )) { - $out .= " type = UNDEFINED; "; - } - return $out." " unless defined($rh); - - if ( ref($rh) =~/HASH/ or "$rh" =~/HASH/ ) { - $out .= "{\n"; - $indent++; - foreach my $key (sort keys %{$rh}) { - $out .= " "x$indent."$key => " . pretty_print_rh( $rh->{$key}, $indent ) . "\n"; - } - $indent--; - $out .= "\n"." "x$indent."}\n"; - - } elsif (ref($rh) =~ /ARRAY/ or "$rh" =~/ARRAY/) { - $out .= " ( "; - foreach my $elem ( @{$rh} ) { - $out .= pretty_print_rh($elem, $indent); - - } - $out .= " ) \n"; - } elsif ( ref($rh) =~ /SCALAR/ ) { - $out .= "scalar reference ". ${$rh}; - } elsif ( ref($rh) =~/Base64/ ) { - $out .= "base64 reference " .$$rh; +sub url { + my $self = shift; + my $new_url = shift; + $self->{url} = $new_url if defined($new_url) and $new_url =~ /\S/; + $self->{url}; +} +sub pretty_print { # provides html output -- NOT a method + my $r_input = shift; + my $level = shift; + $level = 4 unless defined($level); + $level--; + return '' unless $level > 0; # only print three levels of hashes (safety feature) + my $out = ''; + if ( not ref($r_input) ) { + $out = $r_input if defined $r_input; # not a reference + $out =~ s/</</g ; # protect for HTML output + } elsif ("$r_input" =~/hash/i) { # this will pick up objects whose '$self' is hash and so works better than ref($r_iput). + local($^W) = 0; + + $out .= "$r_input " ."<TABLE border = \"2\" cellpadding = \"3\" BGCOLOR = \"#FFFFFF\">"; + + + foreach my $key ( sort ( keys %$r_input )) { + $out .= "<tr><TD> $key</TD><TD>=></td><td> ".pretty_print($r_input->{$key}) . "</td></tr>"; + } + $out .="</table>"; + } elsif (ref($r_input) eq 'ARRAY' ) { + my @array = @$r_input; + $out .= "( " ; + while (@array) { + $out .= pretty_print(shift @array, $level) . " , "; + } + $out .= " )"; + } elsif (ref($r_input) eq 'CODE') { + $out = "$r_input"; } else { - $out .= $rh; + $out = $r_input; + $out =~ s/</</g; # protect for HTML output } return $out." "; } sub setInputTable_for_listLib { - $out = { - #password => 'geometry', - pw => 'geometry', + my $self = shift; + my $out = { + pw => $self->{password}, set => 'set0', library_name => 'Library', command => 'all', @@ -134,20 +173,18 @@ $out; } sub setInputTable { - my $source = shift; - $out = { - #password => 'geometry', - pw => 'geometry', - set => 'set0', + my $self = shift; + my $out = { + pw => $self->{password}, library_name => 'Library', - command => 'all', + command => 'renderProblem', answer_form_submitted => 1, - course => COURSE(), + course => $self->{course}, extra_packages_to_load => [qw( AlgParserWithImplicitExpand Expr ExprWithImplicitExpand AnswerEvaluator AnswerEvaluatorMaker )], - mode => DISPLAYMODE(), + mode => $self->{displayMode}, modules_to_evaluate => [ qw( Exporter DynaLoader @@ -174,14 +211,14 @@ Regression )], - envir => environment(), + envir => $self->environment(), problem_state => { - num_of_correct_ans => 2, + num_of_correct_ans => 0, num_of_incorrect_ans => 4, recorded_score => 1.0, }, - source => source($source), #base64 encoded + source => $self->{encodedSource}, #base64 encoded @@ -191,6 +228,7 @@ } sub environment { + my $self = shift; my $envir = { answerDate => '4014438528', CAPA_Graphics_URL=>'http://webwork-db.math.rochester.edu/capa_graphics/', @@ -201,9 +239,10 @@ cgiURL => 'Not defined', classDirectory=> 'Not defined', courseName=>'Not defined', - courseScriptsDirectory=>'/ww/webwork/system/courseScripts/', - displayMode=>DISPLAYMODE, + courseScriptsDirectory=>'not defined', + displayMode=>$self->{displayMode}, dueDate=> '4014438528', + effectivePermissionLevel => 10, externalGif2EpsPath=>'not defined', externalPng2EpsPath=>'not defined', externalTTHPath=>'/usr/local/bin/tth', @@ -220,14 +259,10 @@ functVarDefault=> 'x', functZeroLevelDefault=> 0.000001, functZeroLevelTolDefault=>0.000001, - htmlDirectory =>'/ww/webwork/courses/gage_course/html/', - htmlURL =>'http://webwork-db.math.rochester.edu/gage_course/', - inputs_ref => { - AnSwEr1 => '', - AnSwEr2 => '', - AnSwEr3 => '', - }, - macroDirectory=>'/ww/webwork/courses/gage_course/templates/macros/', + htmlDirectory =>'not defined', + htmlURL =>'not defined', + inputs_ref => $self->{inputs_ref}, + macroDirectory=>'not defined', numAbsTolDefault=>0.0000001, numFormatDefault=>'%0.13g', numOfAttempts=> 0, @@ -235,6 +270,7 @@ numZeroLevelDefault =>0.000001, numZeroLevelTolDefault =>0.000001, openDate=> '3014438528', + permissionLevel =>10, PRINT_FILE_NAMES_FOR => [ 'gage'], probFileName => 'set0/prob1a.pg', problemSeed => 1234, @@ -247,15 +283,115 @@ sectionName => 'Gage', sectionNumber => 1, sessionKey=> 'Not defined', - setNumber =>'MAAtutorial', + setNumber =>'not defined', studentLogin =>'gage', studentName => 'Mike Gage', - tempDirectory => '/ww/htdocs/tmp/gage_course/', - templateDirectory=>'/ww/webwork/courses/gage_course/templates/', - tempURL=>'http://webwork-db.math.rochester.edu/tmp/gage_course/', - webworkDocsURL => 'http://webwork.math.rochester.edu/webwork_gage_system_html', + tempDirectory => 'not defined', + templateDirectory=>'not defined', + tempURL=>'not defined', + webworkDocsURL => 'not defined', + + showHints => 1, # extra options -- usually passed from the input form + showSolutions => 1, + }; $envir; }; -1; \ No newline at end of file +sub formatAnswerRow { + my $self = shift; + my $rh_answer = shift; + my $problemNumber = shift; + my $answerString = $rh_answer->{original_student_ans}||' '; + my $correctAnswer = $rh_answer->{correct_ans}||''; + my $ans_message = $rh_answer->{ans_message}||''; + my $score = ($rh_answer->{score}) ? 'Correct' : 'Incorrect'; + my $row = qq{ + <tr> + <td> + Prob: $problemNumber + </td> + <td> + $answerString + </td> + <td> + $score + </td> + <td> + Correct answer is $correctAnswer + </td> + <td> + <i>$ans_message</i> + </td> + </tr>\n + }; + $row; +} + +sub formatRenderedProblem { + my $self = shift; + my $rh_result = $self->{output}; # wrap problem in formats + my $problemText = decode_base64($rh_result->{text}); + my $rh_answers = $rh_result->{answers}; + my $encodedSource = $self->{encodedSource}||'foobar'; + my $warnings = ''; + if ( defined ($rh_result->{WARNINGS}) and $rh_result->{WARNINGS} ){ + $warnings = "<div style=\"background-color:pink\"> + <p >WARNINGS</p><p>".decode_base64($rh_result->{WARNINGS})."</p></div>"; + } + #warn "keys: ", join(" | ", sort keys %{$rh_result }); + my $debug_messages = $rh_result->{flags}->{DEBUG_messages} || []; + $debug_messages = join("<br/>\n", @{ $debug_messages } ); + my $internal_debug_messages = $rh_result->{internal_debug_messages} || []; + $internal_debug_messages = join("<br/>\n", @{ $internal_debug_messages } ); + # collect answers + my $answerTemplate = q{<hr>ANSWERS <table border="3" align="center">}; + my $problemNumber = 1; + foreach my $key (sort keys %{$rh_answers}) { + $answerTemplate .= $self->formatAnswerRow($rh_answers->{$key}, $problemNumber++); + } + $answerTemplate .= q{</table> <hr>}; + + my $FULL_URL = $self->url; + my $FORM_ACTION_URL = "$FULL_URL/webwork2/html2xml"; + my $problemTemplate = <<ENDPROBLEMTEMPLATE; +<html> +<head> +<base href="$FULL_URL"> +<title>WeBWorK Editor using host $HOSTNAME</title> +</head> +<body> + $answerTemplate + <form action="$FORM_ACTION_URL" method="post"> + $problemText + <input type="hidden" name="answersSubmitted" value="1"> + <input type="hidden" name="problemAddress" value="probSource"> + <input type="hidden" name="problemSource" value="$encodedSource"> + <input type="hidden" name="problemSeed" value="1234"> + <input type="hidden" name="pathToProblemFile" value="foobar"> + <p><input type="submit" name="submit" value="submit answers"></p> + </form> +<HR> +<h3> Warning section </h3> +$warnings +<h3> +Debug message section +</h3> +$debug_messages +<h3> +internal errors +</h3> +$internal_debug_messages + +</body> +</html> + +ENDPROBLEMTEMPLATE + + + + $problemTemplate; +} + + +1; |
From: Mike G. v. a. <we...@ma...> - 2010-06-08 12:35:14
|
Log Message: ----------- backporting Gavin's fix to HEAD version Tags: ---- rel-2-4-patches Modified Files: -------------- webwork2/bin: NPL-update Revision Data ------------- Index: NPL-update =================================================================== RCS file: /webwork/cvs/system/webwork2/bin/NPL-update,v retrieving revision 1.1.2.5.2.1 retrieving revision 1.1.2.5.2.2 diff -Lbin/NPL-update -Lbin/NPL-update -u -r1.1.2.5.2.1 -r1.1.2.5.2.2 --- bin/NPL-update +++ bin/NPL-update @@ -368,42 +368,42 @@ $tagged = 0; while (<IN>) { SWITCH: { - if (/KEYWORDS\((.*)\)/i) { + if (/\bKEYWORDS\((.*)\)/i) { @keyword = keywordcleaner($1); last SWITCH; } - if (/DBsubject\(\s*'(.*?)'\s*\)/) { + if (/\bDBsubject\(\s*'(.*?)'\s*\)/) { $subject = $1; $subject =~ s/'/\'/g; last SWITCH; } - if (/DBchapter\(\s*'(.*?)'\s*\)/) { + if (/\bDBchapter\(\s*'(.*?)'\s*\)/) { $chapter = $1; $chapter =~ s/'/\'/g; $tagged = 1; last SWITCH; } - if (/DBsection\(\s*'(.*?)'\s*\)/) { + if (/\bDBsection\(\s*'(.*?)'\s*\)/) { $section = $1; $section =~ s/'/\'/g; last SWITCH; } - if (/Date\(\s*'(.*?)'\s*\)/) { + if (/\bDate\(\s*'(.*?)'\s*\)/) { $date = $1; $date =~ s/'/\'/g; last SWITCH; } - if (/Institution\(\s*'(.*?)'\s*\)/) { + if (/\bInstitution\(\s*'(.*?)'\s*\)/) { $institution = $1; $institution =~ s/'/\'/g; last SWITCH; } - if (/Author\(\s*'(.*?)'\s*\)/) { + if (/\bAuthor\(\s*'(.*?)'\s*\)/) { $author = $1; $author =~ s/'/\'/g; last SWITCH; } - if (/TitleText(\d+)\(\s*'(.*?)'\s*\)/) { + if (/\bTitleText(\d+)\(\s*'(.*?)'\s*\)/) { $textno = $1; $text = $2; $text =~ s/'/\'/g; @@ -413,7 +413,7 @@ } last SWITCH; } - if (/EditionText(\d+)\(\s*'(.*?)'\s*\)/) { + if (/\bEditionText(\d+)\(\s*'(.*?)'\s*\)/) { $textno = $1; $edition = $2; $edition =~ s/'/\'/g; @@ -423,7 +423,7 @@ } last SWITCH; } - if (/AuthorText(\d+)\(\s*'(.*?)'\s*\)/) { + if (/\bAuthorText(\d+)\(\s*'(.*?)'\s*\)/) { $textno = $1; $textauthor = $2; $textauthor =~ s/'/\'/g; @@ -433,7 +433,7 @@ } last SWITCH; } - if (/Section(\d+)\(\s*'(.*?)'\s*\)/) { + if (/\bSection(\d+)\(\s*'(.*?)'\s*\)/) { $textno = $1; $textsection = $2; $textsection =~ s/'/\'/g; @@ -450,7 +450,7 @@ } last SWITCH; } - if (/Problem(\d+)\(\s*(.*?)\s*\)/) { + if (/\bProblem(\d+)\(\s*(.*?)\s*\)/) { $textno = $1; $textproblem = $2; $textproblem =~ s/\D/ /g; |
From: Mike G. v. a. <we...@ma...> - 2010-06-08 12:11:02
|
Log Message: ----------- factored code from renderProblem.pl and renderViaXMLRPC.pm into this file Added Files: ----------- webwork2/lib: WebworkClient.pm Revision Data ------------- --- /dev/null +++ lib/WebworkClient.pm @@ -0,0 +1,399 @@ +#!/usr/bin/perl -w + +################################################################################ +# WeBWorK Online Homework Delivery System +# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# $CVSHeader: webwork2/lib/WebworkClient.pm,v 1.1 2010/06/08 11:46:38 gage Exp $ +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of either: (a) the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any later +# version, or (b) the "Artistic License" which comes with this package. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the +# Artistic License for more details. +################################################################################ + +=head1 NAME + +webwork2/clients/WebworkClient.pm + +This script will take a file and send it to a WeBWorK daemon webservice +to have it rendered. The result is split into the basic HTML rendering +and evaluation of answers and then passed to a browser for printing. + +The formatting allows the browser presentation to be interactive with the +daemon running the script webwork2/lib/renderViaXMLRPC.pm + +Rembember to configure the local output file and display command !!!!!!!! + +=cut + +use strict; +use warnings; + + + + +our @COMMANDS = qw( listLibraries renderProblem ); #listLib readFile tex2pdf + + + +################################################## +# XMLRPC client -- +# this code is identical between renderProblem.pl and renderViaXMLRPC.pm???? +################################################## + +package WebworkClient; + +#use Crypt::SSLeay; # needed for https +use XMLRPC::Lite; +use MIME::Base64 qw( encode_base64 decode_base64); + +use constant TRANSPORT_METHOD => 'XMLRPC::Lite'; +use constant REQUEST_CLASS => 'WebworkXMLRPC'; # WebworkXMLRPC is used for soap also!! +use constant REQUEST_URI => 'mod_xmlrpc'; + +sub new { + my $self = { + output => '', + encodedSource => '', + url => '', + password => '', + course => '', + displayMode => '', + inputs_ref => { AnSwEr0001 => '', + AnSwEr0002 => '', + AnSwEr0003 => '', + }, + }; + + bless $self; +} + + +our $result; + +################################################## +# Utilities -- +# this code is identical between renderProblem.pl and renderViaXMLRPC.pm +################################################## + +sub xmlrpcCall { + my $self = shift; + my $command = shift; + $command = 'listLibraries' unless $command; + + my $requestResult = TRANSPORT_METHOD + -> proxy($self->{url}.'/'.REQUEST_URI); + + my $input = $self->setInputTable(); + local( $result); + # use eval to catch errors + eval { $result = $requestResult->call(REQUEST_CLASS.'.'.$command,$input) }; + if ($@) { + print STDERR "There were a lot of errors for $command\n" ; + print STDERR "Errors: \n $@\n End Errors\n" ; + return 0 #failure + } + + unless (ref($result) and $result->fault) { + my $rh_result = $result->result(); + #print STDERR pretty_print_rh($rh_result); + $self->{output} = $rh_result; #$self->formatRenderedProblem($rh_result); + return 1; # success + + } else { + $self->{output} = 'Error from server: '. join( ",\n ", + $result->faultcode, + $result->faultstring); + return 0; #failure + } +} + +sub encodeSource { + my $self = shift; + my $source = shift; + $self->{encodedSource} =encode_base64($source); +} +sub url { + my $self = shift; + my $new_url = shift; + $self->{url} = $new_url if defined($new_url) and $new_url =~ /\S/; + $self->{url}; +} +sub pretty_print { # provides html output -- NOT a method + my $r_input = shift; + my $level = shift; + $level = 4 unless defined($level); + $level--; + return '' unless $level > 0; # only print three levels of hashes (safety feature) + my $out = ''; + if ( not ref($r_input) ) { + $out = $r_input if defined $r_input; # not a reference + $out =~ s/</</g ; # protect for HTML output + } elsif ("$r_input" =~/hash/i) { # this will pick up objects whose '$self' is hash and so works better than ref($r_iput). + local($^W) = 0; + + $out .= "$r_input " ."<TABLE border = \"2\" cellpadding = \"3\" BGCOLOR = \"#FFFFFF\">"; + + + foreach my $key ( sort ( keys %$r_input )) { + $out .= "<tr><TD> $key</TD><TD>=></td><td> ".pretty_print($r_input->{$key}) . "</td></tr>"; + } + $out .="</table>"; + } elsif (ref($r_input) eq 'ARRAY' ) { + my @array = @$r_input; + $out .= "( " ; + while (@array) { + $out .= pretty_print(shift @array, $level) . " , "; + } + $out .= " )"; + } elsif (ref($r_input) eq 'CODE') { + $out = "$r_input"; + } else { + $out = $r_input; + $out =~ s/</</g; # protect for HTML output + } + + return $out." "; +} + +sub setInputTable_for_listLib { + my $self = shift; + my $out = { + pw => $self->{password}, + set => 'set0', + library_name => 'Library', + command => 'all', + }; + + $out; +} +sub setInputTable { + my $self = shift; + my $out = { + pw => $self->{password}, + library_name => 'Library', + command => 'renderProblem', + answer_form_submitted => 1, + course => $self->{course}, + extra_packages_to_load => [qw( AlgParserWithImplicitExpand Expr + ExprWithImplicitExpand AnswerEvaluator + AnswerEvaluatorMaker + )], + mode => $self->{displayMode}, + modules_to_evaluate => [ qw( +Exporter +DynaLoader +GD +WWPlot +Fun +Circle +Label +PGrandom +Units +Hermite +List +Match +Multiple +Select +AlgParser +AnswerHash +Fraction +VectorField +Complex1 +Complex +MatrixReal1 Matrix +Distributions +Regression + + )], + envir => $self->environment(), + problem_state => { + + num_of_correct_ans => 0, + num_of_incorrect_ans => 4, + recorded_score => 1.0, + }, + source => $self->{encodedSource}, #base64 encoded + + + + }; + + $out; +} + +sub environment { + my $self = shift; + my $envir = { + answerDate => '4014438528', + CAPA_Graphics_URL=>'http://webwork-db.math.rochester.edu/capa_graphics/', + CAPA_GraphicsDirectory =>'/ww/webwork/CAPA/CAPA_Graphics/', + CAPA_MCTools=>'/ww/webwork/CAPA/CAPA_MCTools/', + CAPA_Tools=>'/ww/webwork/CAPA/CAPA_Tools/', + cgiDirectory=>'Not defined', + cgiURL => 'foobarNot defined', + classDirectory=> 'Not defined', + courseName=>'Not defined', + courseScriptsDirectory=>'not defined', + displayMode=>$self->{displayMode}, + dueDate=> '4014438528', + effectivePermissionLevel => 10, + externalGif2EpsPath=>'not defined', + externalPng2EpsPath=>'not defined', + externalTTHPath=>'/usr/local/bin/tth', + fileName=>'set0/prob1a.pg', + formattedAnswerDate=>'6/19/00', + formattedDueDate=>'6/19/00', + formattedOpenDate=>'6/19/00', + functAbsTolDefault=> 0.0000001, + functLLimitDefault=>0, + functMaxConstantOfIntegration=> 1000000000000.0, + functNumOfPoints=> 5, + functRelPercentTolDefault=> 0.000001, + functULimitDefault=>1, + functVarDefault=> 'x', + functZeroLevelDefault=> 0.000001, + functZeroLevelTolDefault=>0.000001, + htmlDirectory =>'not defined', + htmlURL =>'not defined', + inputs_ref => $self->{inputs_ref}, + macroDirectory=>'not defined', + numAbsTolDefault=>0.0000001, + numFormatDefault=>'%0.13g', + numOfAttempts=> 0, + numRelPercentTolDefault => 0.0001, + numZeroLevelDefault =>0.000001, + numZeroLevelTolDefault =>0.000001, + openDate=> '3014438528', + permissionLevel =>10, + PRINT_FILE_NAMES_FOR => [ 'gage'], + probFileName => 'set0/prob1a.pg', + problemSeed => 1234, + problemValue =>1, + probNum => 13, + psvn => 54321, + psvnNumber=> 54321, + questionNumber => 1, + scriptDirectory => 'Not defined', + sectionName => 'Gage', + sectionNumber => 1, + server_root_url =>"foobarfoobar", + sessionKey=> 'Not defined', + setNumber =>'not defined', + studentLogin =>'gage', + studentName => 'Mike Gage', + tempDirectory => 'not defined', + templateDirectory=>'not defined', + tempURL=>'not defined', + webworkDocsURL => 'not defined', + + showHints => 1, # extra options -- usually passed from the input form + showSolutions => 1, + + }; + $envir; +}; + +sub formatAnswerRow { + my $self = shift; + my $rh_answer = shift; + my $problemNumber = shift; + my $answerString = $rh_answer->{original_student_ans}||' '; + my $correctAnswer = $rh_answer->{correct_ans}||''; + my $ans_message = $rh_answer->{ans_message}||''; + my $score = ($rh_answer->{score}) ? 'Correct' : 'Incorrect'; + my $row = qq{ + <tr> + <td> + Prob: $problemNumber + </td> + <td> + $answerString + </td> + <td> + $score + </td> + <td> + Correct answer is $correctAnswer + </td> + <td> + <i>$ans_message</i> + </td> + </tr>\n + }; + $row; +} + +sub formatRenderedProblem { + my $self = shift; + my $rh_result = $self->{output}; # wrap problem in formats + my $problemText = decode_base64($rh_result->{text}); + my $rh_answers = $rh_result->{answers}; + my $encodedSource = $self->{encodedSource}||'foobar'; + my $warnings = ''; + if ( defined ($rh_result->{WARNINGS}) and $rh_result->{WARNINGS} ){ + $warnings = "<div style=\"background-color:pink\"> + <p >WARNINGS</p><p>".decode_base64($rh_result->{WARNINGS})."</p></div>"; + } + #warn "keys: ", join(" | ", sort keys %{$rh_result }); + my $debug_messages = $rh_result->{flags}->{DEBUG_messages} || []; + $debug_messages = join("<br/>\n", @{ $debug_messages } ); + my $internal_debug_messages = $rh_result->{internal_debug_messages} || []; + $internal_debug_messages = join("<br/>\n", @{ $internal_debug_messages } ); + # collect answers + my $answerTemplate = q{<hr>ANSWERS <table border="3" align="center">}; + my $problemNumber = 1; + foreach my $key (sort keys %{$rh_answers}) { + $answerTemplate .= $self->formatAnswerRow($rh_answers->{$key}, $problemNumber++); + } + $answerTemplate .= q{</table> <hr>}; + + my $FULL_URL = $self->url; + my $FORM_ACTION_URL = "$FULL_URL/webwork2/html2xml"; + my $problemTemplate = <<ENDPROBLEMTEMPLATE; +<html> +<head> +<base href="$FULL_URL"> +<title>$FULL_URL WeBWorK Editor using host $FULL_URL</title> +</head> +<body> +<h2> WeBWorK Editor using host $FULL_URL</h2> + $answerTemplate + <form action="$FORM_ACTION_URL" method="post"> + $problemText + <input type="hidden" name="answersSubmitted" value="1"> + <input type="hidden" name="problemAddress" value="probSource"> + <input type="hidden" name="problemSource" value="$encodedSource"> + <input type="hidden" name="problemSeed" value="1234"> + <input type="hidden" name="pathToProblemFile" value="foobar"> + <p><input type="submit" name="submit" value="submit answers"></p> + </form> +<HR> +<h3> Warning section </h3> +$warnings +<h3> +Debug message section +</h3> +$debug_messages +<h3> +internal errors +</h3> +$internal_debug_messages + +</body> +</html> + +ENDPROBLEMTEMPLATE + + + + $problemTemplate; +} + + +1; |
From: Mike G. v. a. <we...@ma...> - 2010-06-08 11:53:50
|
Log Message: ----------- modifications to help find apache_root_url More needs to be done to duplicate the functionality in WeBWorK.pm and in Apache/WeBWorK.pm Modified Files: -------------- webwork2/lib: WebworkWebservice.pm Revision Data ------------- Index: WebworkWebservice.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WebworkWebservice.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -Llib/WebworkWebservice.pm -Llib/WebworkWebservice.pm -u -r1.6 -r1.7 --- lib/WebworkWebservice.pm +++ lib/WebworkWebservice.pm @@ -23,7 +23,9 @@ ############################################################################### my $webwork_directory = $WeBWorK::Constants::WEBWORK_DIRECTORY; #'/opt/webwork/webwork2'; - + + #FIXME -- this has to be modified to reflect local host. + $WebworkWebservice::PROTOCOL = 'http'; $WebworkWebservice::HOST_NAME = 'localhost'; # Apache->server->server_hostname; $WebworkWebservice::HOST_PORT = '80'; # Apache->server->port; |
From: Mike G. v. a. <we...@ma...> - 2010-06-08 11:52:30
|
Log Message: ----------- factoring code into WebworkClient.pm Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator: renderViaXMLRPC.pm Revision Data ------------- Index: renderViaXMLRPC.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/renderViaXMLRPC.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -Llib/WeBWorK/ContentGenerator/renderViaXMLRPC.pm -Llib/WeBWorK/ContentGenerator/renderViaXMLRPC.pm -u -r1.2 -r1.3 --- lib/WeBWorK/ContentGenerator/renderViaXMLRPC.pm +++ lib/WeBWorK/ContentGenerator/renderViaXMLRPC.pm @@ -23,42 +23,49 @@ use strict; use warnings; - package WeBWorK::ContentGenerator::renderViaXMLRPC; use base qw(WeBWorK::ContentGenerator); #use Crypt::SSLeay; -use XMLRPC::Lite; -use MIME::Base64 qw( encode_base64 decode_base64); +#use XMLRPC::Lite; +#use MIME::Base64 qw( encode_base64 decode_base64); + + +use strict; +use warnings; +use WebworkClient; ################################################## # configuration section -- point back to the current server to process answers ################################################## -use constant PROTOCOL => 'http'; -use constant HOSTNAME => 'localhost'; -use constant HOSTPORT => 80; -our $FULL_URL = PROTOCOL."://".HOSTNAME; # .":".HOSTPORT; -our $FORM_ACTION_URL = "/webwork2/html2xml"; # points back to current server - - -# use constant PROTOCOL => 'https'; # or 'http'; -# use constant HOSTNAME => 'hosted2.webwork.rochester.edu'; # 'localhost'; -# use constant HOSTPORT => 443; #( for secure https) # 80; -# our $FULL_URL = PROTOCOL."://".HOSTNAME; # .":".HOSTPORT; -# our $FORM_ACTION_URL = "/webwork2/html2xml"; # points back to current server - -use constant TRANSPORT_METHOD => 'XMLRPC::Lite'; -use constant REQUEST_CLASS => 'WebworkXMLRPC'; # WebworkXMLRPC is used for soap also!! -use constant REQUEST_URI => 'mod_xmlrpc'; -use constant TEMPOUTPUTFILE => '/Users/gage/Desktop/renderProblemOutput.html'; # client only -use constant DISPLAY_COMMAND => 'open -a firefox '; # client only +# configure the local output file and display command !!!!!!!! + +# the rest can be configured later to use a different server + +my $use_local = 1; +our ($PROTOCOL,$HOSTNAME, $HOSTPORT, $FULL_URL,$FORM_ACTION_URL, $XML_PASSWORD, $XML_COURSE); +if ($use_local) { + # the rest can work!! + $PROTOCOL = 'http'; + $HOSTNAME = 'localhost'; + $HOSTPORT = 80; + $XML_PASSWORD = 'xmlwebwork'; + $XML_COURSE = 'daemon_course'; +} else { + $PROTOCOL = 'https'; # or 'https'; + $HOSTNAME = "hosted2.webwork.rochester.edu"; # 'localhost'; + $HOSTPORT = 443; #( for secure https) # 80 or 443; + $XML_PASSWORD = 'xmlwebwork'; + $XML_COURSE = 'daemon_course'; + +} -use constant XML_PASSWORD => 'xmlwebwork'; -use constant XML_COURSE => 'daemon_course'; +$FULL_URL = "$PROTOCOL://$HOSTNAME:$HOSTPORT"; -use constant DISPLAYMODE => 'images'; # tex and jsMath are other possibilities. + +use constant DISPLAYMODE => 'images'; # jsMath is another possibilities. our @COMMANDS = qw( listLibraries renderProblem ); #listLib readFile tex2pdf @@ -68,29 +75,35 @@ # end configuration section ################################################## -################################################## -# input/output section -################################################## - sub pre_header_initialize { my ($self) = @_; my $r = $self->r; my $db = new WeBWorK::DB($r->ce->{dbLayout}); - $self->{encodedSource} = $r->param('problemSource'); + my $xmlrpc_client = new WebworkClient; + + $xmlrpc_client->{encodedSource} = $r->param('problemSource') ; # this source has already been encoded + $xmlrpc_client->url($FULL_URL); + $xmlrpc_client->{displayMode} = DISPLAYMODE(); + $xmlrpc_client->{user} = 'xmluser'; + $xmlrpc_client->{password} = $XML_PASSWORD; + $xmlrpc_client->{course} = $XML_COURSE; my %inputs_ref; foreach my $key ( keys %{ $r->{paramcache} } ) { $inputs_ref{$key} = $r->param("$key"); } - $self->{inputs_ref} = \%inputs_ref; - print STDERR pretty_print_rh($r->{paramcache}); - $self->xmlrpcCall('renderProblem'); # takes from {encodedSource}; result in {output} - + $xmlrpc_client->{inputs_ref} = \%inputs_ref; + # print STDERR WebworkClient::pretty_print($r->{paramcache}); + if ( $xmlrpc_client->xmlrpcCall('renderProblem') ) { + $self->{output} = $xmlrpc_client->formatRenderedProblem; + } else { + $self->{output} = $xmlrpc_client->{output}; # error report + } } sub content { - my ($self) = @_; - print $self->{output}; + my $self = shift; + print $self->{output}; } ################################################## @@ -98,301 +111,301 @@ ################################################## -our $result; - -################################################## -# Utilities -- -# this code is identical between renderProblem.pl and renderViaXMLRPC.pm -################################################## - -sub xmlrpcCall { - my $self = shift; - my $command = shift; - $command = 'listLibraries' unless $command; - - my $requestResult = TRANSPORT_METHOD - #->uri('http://'.HOSTNAME.':'.HOSTPORT.'/'.REQUEST_CLASS) - -> proxy($FULL_URL.'/'.REQUEST_URI); - - my $input = $self->setInputTable(); - local( $result); - # use eval to catch errors - eval { $result = $requestResult->call(REQUEST_CLASS.'.'.$command,$input) }; - print STDERR "There were a lot of errors\n" if $@; - print STDERR "Errors: \n $@\n End Errors\n" if $@; - - - - - unless (ref($result) and $result->fault) { - my $rh_result = $result->result(); - #print STDERR pretty_print_rh($rh_result); - $self->{output} = $self->formatRenderedProblem($rh_result); - - } else { - $self->{output} = 'Error from server: ', join( ",\n ", - $result->faultcode, - $result->faultstring); - } -} - -sub encodeSource { - my $source = shift; - encode_base64($source); -} - - -sub pretty_print_rh { - shift if UNIVERSAL::isa($_[0] => __PACKAGE__); - my $rh = shift; - my $indent = shift || 0; - my $out = ""; - my $type = ref($rh); - - if (defined($type) and $type) { - $out .= " type = $type; "; - } elsif (! defined($rh )) { - $out .= " type = UNDEFINED; "; - } - return $out." " unless defined($rh); - - if ( ref($rh) =~/HASH/ or "$rh" =~/HASH/ ) { - $out .= "{\n"; - $indent++; - foreach my $key (sort keys %{$rh}) { - $out .= " "x$indent."$key => " . pretty_print_rh( $rh->{$key}, $indent ) . "\n"; - } - $indent--; - $out .= "\n"." "x$indent."}\n"; - - } elsif (ref($rh) =~ /ARRAY/ or "$rh" =~/ARRAY/) { - $out .= " ( "; - foreach my $elem ( @{$rh} ) { - $out .= pretty_print_rh($elem, $indent); - - } - $out .= " ) \n"; - } elsif ( ref($rh) =~ /SCALAR/ ) { - $out .= "scalar reference ". ${$rh}; - } elsif ( ref($rh) =~/Base64/ ) { - $out .= "base64 reference " .$$rh; - } else { - $out .= $rh; - } - - return $out." "; -} - -sub setInputTable_for_listLib { - my $self = shift; - my $out = { - pw => XML_PASSWORD, - set => 'set0', - library_name => 'Library', - command => 'all', - }; - - $out; -} -sub setInputTable { - my $self = shift; - my $out = { - pw => XML_PASSWORD, - library_name => 'Library', - command => 'renderProblem', - answer_form_submitted => 1, - course => XML_COURSE(), - extra_packages_to_load => [qw( AlgParserWithImplicitExpand Expr - ExprWithImplicitExpand AnswerEvaluator - AnswerEvaluatorMaker - )], - mode => DISPLAYMODE(), - modules_to_evaluate => [ qw( -Exporter -DynaLoader -GD -WWPlot -Fun -Circle -Label -PGrandom -Units -Hermite -List -Match -Multiple -Select -AlgParser -AnswerHash -Fraction -VectorField -Complex1 -Complex -MatrixReal1 Matrix -Distributions -Regression - - )], - envir => $self->environment(), - problem_state => { - - num_of_correct_ans => 2, - num_of_incorrect_ans => 4, - recorded_score => 1.0, - }, - source => $self->{encodedSource}, #base64 encoded - - - - }; - - $out; -} - -sub environment { - my $self = shift; - my $envir = { - answerDate => '4014438528', - CAPA_Graphics_URL=>"not defined", - CAPA_GraphicsDirectory =>"not defined", - CAPA_MCTools=>"not defined", - CAPA_Tools=>'not defined', - cgiDirectory=>'Not defined', - cgiURL => 'Not defined', - classDirectory=> 'Not defined', - courseName=>'Not defined', - courseScriptsDirectory=>'not defined', - displayMode=>DISPLAYMODE, - dueDate=> '4014438528', - externalGif2EpsPath=>'not defined', - externalPng2EpsPath=>'not defined', - externalTTHPath=>'/usr/local/bin/tth', - fileName=>'set0/prob1a.pg', - formattedAnswerDate=>'6/19/00', - formattedDueDate=>'6/19/00', - formattedOpenDate=>'6/19/00', - functAbsTolDefault=> 0.0000001, - functLLimitDefault=>0, - functMaxConstantOfIntegration=> 1000000000000.0, - functNumOfPoints=> 5, - functRelPercentTolDefault=> 0.000001, - functULimitDefault=>1, - functVarDefault=> 'x', - functZeroLevelDefault=> 0.000001, - functZeroLevelTolDefault=>0.000001, - htmlDirectory =>'not defined', - htmlURL =>'not defined', - inputs_ref => $self->{inputs_ref}, - macroDirectory=>'not defined', - numAbsTolDefault=>0.0000001, - numFormatDefault=>'%0.13g', - numOfAttempts=> 0, - numRelPercentTolDefault => 0.0001, - numZeroLevelDefault =>0.000001, - numZeroLevelTolDefault =>0.000001, - openDate=> '3014438528', - PRINT_FILE_NAMES_FOR => [ 'gage'], - probFileName => 'set0/prob1a.pg', - problemSeed => 1234, - problemValue =>1, - probNum => 13, - psvn => 54321, - psvnNumber=> 54321, - questionNumber => 1, - scriptDirectory => 'Not defined', - sectionName => 'Gage', - sectionNumber => 1, - sessionKey=> 'Not defined', - setNumber =>'not defined', - studentLogin =>'gage', - studentName => 'Mike Gage', - tempDirectory => 'not defined', - templateDirectory=>'not defined', - tempURL=>'not defined', - webworkDocsURL => 'not defined', - }; - $envir; -}; - -sub formatAnswerRow { - my $self = shift; - my $rh_answer = shift; - my $problemNumber = shift; - my $answerString = $rh_answer->{original_student_ans}||' '; - my $correctAnswer = $rh_answer->{correct_ans}||''; - my $ans_message = $rh_answer->{ans_message}; - my $score = ($rh_answer->{score}) ? 'Correct' : 'Incorrect'; - my $row = qq{ - <tr> - <td> - Prob: $problemNumber - </td> - <td> - $answerString - </td> - <td> - $score - </td> - <td> - Correct answer is $correctAnswer - </td> - <td> - <i>$ans_message</i> - </td> - </tr>\n - }; - $row; -} - -sub formatRenderedProblem { - my $self = shift; - my $rh_result = shift; # wrap problem in formats - my $problemText = decode_base64($rh_result->{text}); - my $rh_answers = $rh_result->{answers}; - my $encodedSource = $self->{encodedSource}||'foobar'; - my $warnings = ''; - if ( defined ($rh_result->{WARNINGS}) and $rh_result->{WARNINGS} ){ - $warnings = "<div style=\"background-color:pink\"> - <p >WARNINGS</p><p>".decode_base64($rh_result->{WARNINGS})."</p></div>"; - } - - ; - # collect answers - my $answerTemplate = q{<hr>ANSWERS <table border="3" align="center">}; - my $problemNumber = 1; - foreach my $key (sort keys %{$rh_answers}) { - $answerTemplate .= $self->formatAnswerRow($rh_answers->{$key}, $problemNumber++); - } - $answerTemplate .= q{</table> <hr>}; - - - - my $problemTemplate = <<ENDPROBLEMTEMPLATE; -<html> -<head> -<title>WeBWorK Editor</title> -</head> -<body> - $answerTemplate - $warnings - <form action="$FORM_ACTION_URL" method="post"> - $problemText - <input type="hidden" name="answersSubmitted" value="1"> - <input type="hidden" name="problemAddress" value="probSource"> - <input type="hidden" name="problemSource" value="$encodedSource"> - <input type="hidden" name="problemSeed" value="1234"> - <input type="hidden" name="pathToProblemFile" value="foobar"> - <p><input type="submit" name="submit" value="submit answers"></p> - </form> -</body> -</html> - -ENDPROBLEMTEMPLATE - - - - $problemTemplate; -} - +# our $result; +# +# ################################################## +# # Utilities -- +# # this code is identical between renderProblem.pl and renderViaXMLRPC.pm +# ################################################## +# +# sub xmlrpcCall { +# my $self = shift; +# my $command = shift; +# $command = 'listLibraries' unless $command; +# +# my $requestResult = TRANSPORT_METHOD +# #->uri('http://'.HOSTNAME.':'.HOSTPORT.'/'.REQUEST_CLASS) +# -> proxy($FULL_URL.'/'.REQUEST_URI); +# +# my $input = $self->setInputTable(); +# local( $result); +# # use eval to catch errors +# eval { $result = $requestResult->call(REQUEST_CLASS.'.'.$command,$input) }; +# print STDERR "There were a lot of errors\n" if $@; +# print STDERR "Errors: \n $@\n End Errors\n" if $@; +# +# +# +# +# unless (ref($result) and $result->fault) { +# my $rh_result = $result->result(); +# #print STDERR pretty_print($rh_result); +# $self->{output} = $self->formatRenderedProblem($rh_result); +# +# } else { +# $self->{output} = 'Error from server: ', join( ",\n ", +# $result->faultcode, +# $result->faultstring); +# } +# } +# +# sub encodeSource { +# my $source = shift; +# encode_base64($source); +# } +# +# +# sub pretty_print_rh { +# shift if UNIVERSAL::isa($_[0] => __PACKAGE__); +# my $rh = shift; +# my $indent = shift || 0; +# my $out = ""; +# my $type = ref($rh); +# +# if (defined($type) and $type) { +# $out .= " type = $type; "; +# } elsif (! defined($rh )) { +# $out .= " type = UNDEFINED; "; +# } +# return $out." " unless defined($rh); +# +# if ( ref($rh) =~/HASH/ or "$rh" =~/HASH/ ) { +# $out .= "{\n"; +# $indent++; +# foreach my $key (sort keys %{$rh}) { +# $out .= " "x$indent."$key => " . pretty_print_rh( $rh->{$key}, $indent ) . "\n"; +# } +# $indent--; +# $out .= "\n"." "x$indent."}\n"; +# +# } elsif (ref($rh) =~ /ARRAY/ or "$rh" =~/ARRAY/) { +# $out .= " ( "; +# foreach my $elem ( @{$rh} ) { +# $out .= pretty_print_rh($elem, $indent); +# +# } +# $out .= " ) \n"; +# } elsif ( ref($rh) =~ /SCALAR/ ) { +# $out .= "scalar reference ". ${$rh}; +# } elsif ( ref($rh) =~/Base64/ ) { +# $out .= "base64 reference " .$$rh; +# } else { +# $out .= $rh; +# } +# +# return $out." "; +# } +# +# sub setInputTable_for_listLib { +# my $self = shift; +# my $out = { +# pw => XML_PASSWORD, +# set => 'set0', +# library_name => 'Library', +# command => 'all', +# }; +# +# $out; +# } +# sub setInputTable { +# my $self = shift; +# my $out = { +# pw => XML_PASSWORD, +# library_name => 'Library', +# command => 'renderProblem', +# answer_form_submitted => 1, +# course => XML_COURSE(), +# extra_packages_to_load => [qw( AlgParserWithImplicitExpand Expr +# ExprWithImplicitExpand AnswerEvaluator +# AnswerEvaluatorMaker +# )], +# mode => DISPLAYMODE(), +# modules_to_evaluate => [ qw( +# Exporter +# DynaLoader +# GD +# WWPlot +# Fun +# Circle +# Label +# PGrandom +# Units +# Hermite +# List +# Match +# Multiple +# Select +# AlgParser +# AnswerHash +# Fraction +# VectorField +# Complex1 +# Complex +# MatrixReal1 Matrix +# Distributions +# Regression +# +# )], +# envir => $self->environment(), +# problem_state => { +# +# num_of_correct_ans => 2, +# num_of_incorrect_ans => 4, +# recorded_score => 1.0, +# }, +# source => $self->{encodedSource}, #base64 encoded +# +# +# +# }; +# +# $out; +# } +# +# sub environment { +# my $self = shift; +# my $envir = { +# answerDate => '4014438528', +# CAPA_Graphics_URL=>"not defined", +# CAPA_GraphicsDirectory =>"not defined", +# CAPA_MCTools=>"not defined", +# CAPA_Tools=>'not defined', +# cgiDirectory=>'Not defined', +# cgiURL => 'Not defined', +# classDirectory=> 'Not defined', +# courseName=>'Not defined', +# courseScriptsDirectory=>'not defined', +# displayMode=>DISPLAYMODE, +# dueDate=> '4014438528', +# externalGif2EpsPath=>'not defined', +# externalPng2EpsPath=>'not defined', +# externalTTHPath=>'/usr/local/bin/tth', +# fileName=>'set0/prob1a.pg', +# formattedAnswerDate=>'6/19/00', +# formattedDueDate=>'6/19/00', +# formattedOpenDate=>'6/19/00', +# functAbsTolDefault=> 0.0000001, +# functLLimitDefault=>0, +# functMaxConstantOfIntegration=> 1000000000000.0, +# functNumOfPoints=> 5, +# functRelPercentTolDefault=> 0.000001, +# functULimitDefault=>1, +# functVarDefault=> 'x', +# functZeroLevelDefault=> 0.000001, +# functZeroLevelTolDefault=>0.000001, +# htmlDirectory =>'not defined', +# htmlURL =>'not defined', +# inputs_ref => $self->{inputs_ref}, +# macroDirectory=>'not defined', +# numAbsTolDefault=>0.0000001, +# numFormatDefault=>'%0.13g', +# numOfAttempts=> 0, +# numRelPercentTolDefault => 0.0001, +# numZeroLevelDefault =>0.000001, +# numZeroLevelTolDefault =>0.000001, +# openDate=> '3014438528', +# PRINT_FILE_NAMES_FOR => [ 'gage'], +# probFileName => 'set0/prob1a.pg', +# problemSeed => 1234, +# problemValue =>1, +# probNum => 13, +# psvn => 54321, +# psvnNumber=> 54321, +# questionNumber => 1, +# scriptDirectory => 'Not defined', +# sectionName => 'Gage', +# sectionNumber => 1, +# sessionKey=> 'Not defined', +# setNumber =>'not defined', +# studentLogin =>'gage', +# studentName => 'Mike Gage', +# tempDirectory => 'not defined', +# templateDirectory=>'not defined', +# tempURL=>'not defined', +# webworkDocsURL => 'not defined', +# }; +# $envir; +# }; +# +# sub formatAnswerRow { +# my $self = shift; +# my $rh_answer = shift; +# my $problemNumber = shift; +# my $answerString = $rh_answer->{original_student_ans}||' '; +# my $correctAnswer = $rh_answer->{correct_ans}||''; +# my $ans_message = $rh_answer->{ans_message}; +# my $score = ($rh_answer->{score}) ? 'Correct' : 'Incorrect'; +# my $row = qq{ +# <tr> +# <td> +# Prob: $problemNumber +# </td> +# <td> +# $answerString +# </td> +# <td> +# $score +# </td> +# <td> +# Correct answer is $correctAnswer +# </td> +# <td> +# <i>$ans_message</i> +# </td> +# </tr>\n +# }; +# $row; +# } +# +# sub formatRenderedProblem { +# my $self = shift; +# my $rh_result = shift; # wrap problem in formats +# my $problemText = decode_base64($rh_result->{text}); +# my $rh_answers = $rh_result->{answers}; +# my $encodedSource = $self->{encodedSource}||'foobar'; +# my $warnings = ''; +# if ( defined ($rh_result->{WARNINGS}) and $rh_result->{WARNINGS} ){ +# $warnings = "<div style=\"background-color:pink\"> +# <p >WARNINGS</p><p>".decode_base64($rh_result->{WARNINGS})."</p></div>"; +# } +# +# ; +# # collect answers +# my $answerTemplate = q{<hr>ANSWERS <table border="3" align="center">}; +# my $problemNumber = 1; +# foreach my $key (sort keys %{$rh_answers}) { +# $answerTemplate .= $self->formatAnswerRow($rh_answers->{$key}, $problemNumber++); +# } +# $answerTemplate .= q{</table> <hr>}; +# +# +# +# my $problemTemplate = <<ENDPROBLEMTEMPLATE; +# <html> +# <head> +# <title>WeBWorK Editor</title> +# </head> +# <body> +# $answerTemplate +# $warnings +# <form action="$FORM_ACTION_URL" method="post"> +# $problemText +# <input type="hidden" name="answersSubmitted" value="1"> +# <input type="hidden" name="problemAddress" value="probSource"> +# <input type="hidden" name="problemSource" value="$encodedSource"> +# <input type="hidden" name="problemSeed" value="1234"> +# <input type="hidden" name="pathToProblemFile" value="foobar"> +# <p><input type="submit" name="submit" value="submit answers"></p> +# </form> +# </body> +# </html> +# +# ENDPROBLEMTEMPLATE +# +# +# +# $problemTemplate; +# } +# 1; |
From: Mike G. v. a. <we...@ma...> - 2010-06-08 11:51:31
|
Log Message: ----------- minor change toward finding the apache root url Modified Files: -------------- webwork2/lib/WeBWorK: PG.pm Revision Data ------------- Index: PG.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/PG.pm,v retrieving revision 1.77 retrieving revision 1.78 diff -Llib/WeBWorK/PG.pm -Llib/WeBWorK/PG.pm -u -r1.77 -r1.78 --- lib/WeBWorK/PG.pm +++ lib/WeBWorK/PG.pm @@ -167,7 +167,7 @@ $envir{jsMathURL} = $ce->{webworkURLs}->{jsMath}; $envir{asciimathURL} = $ce->{webworkURLs}->{asciimath}; $envir{LaTeXMathMLURL} = $ce->{webworkURLs}->{LaTeXMathML}; - $envir{server_root_url} = $ce->{apache_root_url}; + $envir{server_root_url} = $ce->{apache_root_url}|| 'foo_bar'; # Information for sending mail |
From: Mike G. v. a. <we...@ma...> - 2010-06-08 11:50:20
|
Log Message: ----------- minor change to warnings format Modified Files: -------------- webwork2/lib/WeBWorK/PG: Local.pm Revision Data ------------- Index: Local.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/PG/Local.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -Llib/WeBWorK/PG/Local.pm -Llib/WeBWorK/PG/Local.pm -u -r1.30 -r1.31 --- lib/WeBWorK/PG/Local.pm +++ lib/WeBWorK/PG/Local.pm @@ -97,7 +97,7 @@ # install a local warn handler to collect warnings my $warnings = ""; - local $SIG{__WARN__} = sub { $warnings .= shift }; + local $SIG{__WARN__} = sub { $warnings .= shift()."<br/>\n"}; #if $ce->{pg}->{options}->{catchWarnings}; # create a Translator |
From: Mike G. v. a. <we...@ma...> - 2010-06-08 11:47:10
|
Log Message: ----------- removing unused code. Factoring code Modified Files: -------------- webwork2/lib/WebworkWebservice: RenderProblem.pm Revision Data ------------- Index: RenderProblem.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WebworkWebservice/RenderProblem.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -Llib/WebworkWebservice/RenderProblem.pm -Llib/WebworkWebservice/RenderProblem.pm -u -r1.10 -r1.11 --- lib/WebworkWebservice/RenderProblem.pm +++ lib/WebworkWebservice/RenderProblem.pm @@ -1,6 +1,20 @@ #!/usr/local/bin/perl -w -# Copyright (C) 2001 Michael Gage +################################################################################ +# WeBWorK Online Homework Delivery System +# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# $CVSHeader$ +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of either: (a) the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any later +# version, or (b) the "Artistic License" which comes with this package. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the +# Artistic License for more details. +################################################################################ @@ -41,30 +55,36 @@ our $WW_DIRECTORY = $WebworkWebservice::WW_DIRECTORY; our $PG_DIRECTORY = $WebworkWebservice::PG_DIRECTORY; our $COURSENAME = $WebworkWebservice::COURSENAME; +our $PROTOCOL = $WebworkWebservice::PROTOCOL; our $HOST_NAME = $WebworkWebservice::HOST_NAME; -our $HOSTURL ="http://$HOST_NAME:80"; -our $ce =$WebworkWebservice::SeedCE; -# create a local course environment for some course - $ce = WeBWorK::CourseEnvironment->new($WW_DIRECTORY, "", "", $COURSENAME); -#print "\$ce = \n", WeBWorK::Utils::pretty_print_rh($ce); - - -#other services -# File variables -#our $WARNINGS=''; - - -# imported constants - -my $COURSE_TEMP_DIRECTORY = $ce->{courseDirs}->{html_tmp}; -my $COURSE_TEMP_URL = $HOSTURL.$ce->{courseURLs}->{html_tmp}; - -my $pgMacrosDirectory = $ce->{pg_dir}.'/macros/'; -my $macroDirectory = $ce->{courseDirs}->{macros}.'/'; -my $templateDirectory = $ce->{courseDirs}->{templates}; - -my %PG_environment = $ce->{pg}->{specialPGEnvironmentVars}; - +our $PORT = $WebworkWebservice::HOST_PORT; +our $HOSTURL = "$PROTOCOL://$HOST_NAME:$PORT"; +# +# #our $ce = $WebworkWebservice::SeedCE; +# # create a local course environment for some course +# our $ce = WeBWorK::CourseEnvironment->new( +# {webwork_dir=> $WW_DIRECTORY, courseName=>$COURSENAME} +# ); +# $ce->{apache_root_url} = $HOSTURL; +# #print "\$ce = \n", WeBWorK::Utils::pretty_print_rh($ce); +# +# +# #other services +# # File variables +# #our $WARNINGS=''; +# +# +# # imported constants +# +# my $COURSE_TEMP_DIRECTORY = $ce->{courseDirs}->{html_tmp}; +# my $COURSE_TEMP_URL = $HOSTURL.$ce->{courseURLs}->{html_tmp}; +# +# my $pgMacrosDirectory = $ce->{pg_dir}.'/macros/'; +# my $macroDirectory = $ce->{courseDirs}->{macros}.'/'; +# my $templateDirectory = $ce->{courseDirs}->{templates}; +# +# my %PG_environment = $ce->{pg}->{specialPGEnvironmentVars}; +# use constant DISPLAY_MODES => { # display name # mode name @@ -118,19 +138,17 @@ } #FIXME put in check to make sure the course exists. eval { - $ce = WeBWorK::CourseEnvironment->new($WW_DIRECTORY, "", "", $courseName); + $ce = WeBWorK::CourseEnvironment->new({webwork_dir=>$WW_DIRECTORY, courseName=> $courseName}); + $ce->{apache_root_url}= $HOSTURL; # Create database object for this course $db = WeBWorK::DB->new($ce->{dbLayout}); }; # $ce->{pg}->{options}->{catchWarnings}=1; #FIXME warnings aren't automatically caught # when using xmlrpc -- turn this on in the daemon2_course. #^FIXME need better way of determining whether the course actually exists. - if ($@) { - $ce = WeBWorK::CourseEnvironment->new($WW_DIRECTORY, "", "", $COURSENAME); - $db = WeBWorK::DB->new($ce->{dbLayout}); - } + warn "Unable to create course $courseName. Error: $@" if $@; my $user = $rh->{user}; - $user = 'gage' unless defined $user and $user =~/\S/; + $user = 'practice1' unless defined $user and $user =~/\S/; ########################################### # Authenticate this request @@ -296,8 +314,7 @@ r_source => $r_problem_source, # reference to a source file string. # if reference is not defined then the path is obtained # from the problem object. - permissionLevel => 10, # $rh->{envir}->{permissionLevel}; - r_envirOverrides => $rh, + permissionLevel => $rh->{envir}->{permissionLevel} || 0, }; my $formFields = $rh->{envir}->{inputs_ref}; @@ -346,11 +363,13 @@ $formFields, # translation options $translationOptions, +# { # extras +# overrides => $rh->{overrides}}, +# } ); - # new version of output: my $out2 = { text => encode_base64( $pg->{body_text} ), |
From: Mike G. v. a. <we...@ma...> - 2010-06-08 01:02:08
|
Log Message: ----------- defining server_root_url from environment Modified Files: -------------- pg/lib: PGalias.pm Revision Data ------------- Index: PGalias.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGalias.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -Llib/PGalias.pm -Llib/PGalias.pm -u -r1.8 -r1.9 --- lib/PGalias.pm +++ lib/PGalias.pm @@ -759,6 +759,7 @@ sub findAppletCodebase { my $self = shift; my $fileName = shift; # probably the name of a jar file + $server_root_url=$self->envir("server_root_url"); #check cache first if (defined($appletCodebaseLocations{$fileName}) and $appletCodebaseLocations{$fileName} =~/\S/ ){ |
From: Mike G. v. a. <we...@ma...> - 2010-06-08 00:57:20
|
Log Message: ----------- removed unnecessary warning Modified Files: -------------- pg/lib: PGcore.pm Revision Data ------------- Index: PGcore.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGcore.pm,v retrieving revision 1.9 retrieving revision 1.10 diff -Llib/PGcore.pm -Llib/PGcore.pm -u -r1.9 -r1.10 --- lib/PGcore.pm +++ lib/PGcore.pm @@ -310,9 +310,9 @@ my $in_key = shift; if ( not_null($in_key) ) { if (defined ($self->{envir}->{$in_key} ) ) { - warn "result is", $self->{envir}->{$in_key}; + $self->{envir}->{$in_key}; } else { - warn "\$envir{$in_key} is not defined"; + warn "\$envir{$in_key} is not defined\n"; return ''; } } else { |
From: Mike G. v. a. <we...@ma...> - 2010-06-07 20:13:13
|
Log Message: ----------- added envir method for exporting the envir (read only) simplified code in PGalias.pm Modified Files: -------------- pg/lib: PGalias.pm PGcore.pm Revision Data ------------- Index: PGcore.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGcore.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -Llib/PGcore.pm -Llib/PGcore.pm -u -r1.8 -r1.9 --- lib/PGcore.pm +++ lib/PGcore.pm @@ -37,7 +37,10 @@ =head2 Utility Macros - not_null(item) returns 1 or 0 + +=head4 not_null + + not_null(item) returns 1 or 0 empty arrays, empty hashes, strings containing only whitespace are all NULL and return 0 all undefined quantities are null and return 0 @@ -57,6 +60,19 @@ } } +=head4 pretty_print + + Usage: warn pretty_print( $rh_hash_input) + TEXT(pretty_print($ans_hash)); + TEXT(pretty_print(~~%envir )); + +This can be very useful for printing out HTML messages about objects while debugging + +=cut + +# ^function pretty_print +# ^uses lex_sort +# ^uses pretty_print sub pretty_print { # provides html output -- NOT a method my $r_input = shift; my $level = shift; @@ -289,7 +305,22 @@ $self->{OUTPUT_ARRAY}; } +sub envir { + my $self = shift; + my $in_key = shift; + if ( not_null($in_key) ) { + if (defined ($self->{envir}->{$in_key} ) ) { + warn "result is", $self->{envir}->{$in_key}; + } else { + warn "\$envir{$in_key} is not defined"; + return ''; + } + } else { + warn "<h3> Environment</h3>".pretty_print($self->{envir}); + return ''; + } +} =item LABELED_ANS() TEXT(labeled_ans_rule("name1"), labeled_ans_rule("name2")); Index: PGalias.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGalias.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -Llib/PGalias.pm -Llib/PGalias.pm -u -r1.7 -r1.8 --- lib/PGalias.pm +++ lib/PGalias.pm @@ -760,17 +760,17 @@ my $self = shift; my $fileName = shift; # probably the name of a jar file #check cache first - return $appletCodebaseLocations{$fileName} - if defined($appletCodebaseLocations{$fileName}) - and $appletCodebaseLocations{$fileName} =~/\S/; + if (defined($appletCodebaseLocations{$fileName}) + and $appletCodebaseLocations{$fileName} =~/\S/ ){ + $appletCodebaseLocations{$fileName} + + + } my $appletPath = $self->{appletPath}; foreach my $appletLocation (@{$appletPath}) { if ($appletLocation =~ m|^/|) { $appletLocation = "$server_root_url$appletLocation"; } - return $appletLocation; # --hack workaround -- just pick the first location and use that -- no checks -# hack to workaround conflict between lwp-request and apache2 -# comment out the check_url block my $url = "$appletLocation/$fileName"; if ($self->check_url($url)) { $appletCodebaseLocations{$fileName} = $appletLocation; #update cache |