From: Simon H. <sim...@us...> - 2010-09-30 16:56:56
|
Update of /cvsroot/stack/stack-dev/lib/ui In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv28438/lib/ui Modified Files: questionTest.php authorTest.php questionBank.php AuthorDisplay.php questionReview.php questionExporter.php OptionsEdit.php questionDeploy.php DisplayItem.php questionImporter.php report.php GhostWriter.php frontend.php Added Files: report.js report.css Log Message: Merging 2.2 branch (with some additional fixes to ensure seamless updating for version lines) Index: questionImporter.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/ui/questionImporter.php,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** questionImporter.php 28 Jul 2009 15:39:26 -0000 1.17 --- questionImporter.php 30 Sep 2010 16:56:15 -0000 1.18 *************** *** 21,28 **** --- 21,40 ---- */ + session_start(); + require_once('../../config.php'); $config = new stackConfig(); global $config; + $url = $config->get('weburl'); + $diemessage = "Please <a href='$url'>login</a>."; + if (array_key_exists('loggedin',$_SESSION)) { + $loggedin = $_SESSION['loggedin']; + if (!$loggedin) { die($diemessage); } + } else { + die($diemessage); + } + + $root = $config->get('docroot'); $webroot = $config->get('webroot'); Index: questionDeploy.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/ui/questionDeploy.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** questionDeploy.php 2 Nov 2009 17:55:08 -0000 1.9 --- questionDeploy.php 30 Sep 2010 16:56:15 -0000 1.10 *************** *** 23,26 **** --- 23,36 ---- global $config; + $url = $config->get('weburl'); + $diemessage = "Please <a href='$url'>login</a>."; + if (array_key_exists('loggedin',$_SESSION)) { + $loggedin = $_SESSION['loggedin']; + if (!$loggedin) { die($diemessage); } + } else { + die($diemessage); + } + + $root = $config->get('docroot'); require_once('DisplayItem.php'); *************** *** 31,81 **** require_once $root.'/lib/deployment/Deployment.php'; $cache = new StackDBCache(); $cache->connect(); ! echo html_head(get_string('FE_deployQuestion', 'stack'),'../../',"@import \"../../styles.css\";\n"); ! $qid = $_GET['id']; // TODO: needs sanitization ?> - <body> ! <h1><?php echo get_string('FE_deployQuestion', 'stack').' '.$qid; ?></h1> <p><a href="../../index.php"><?php echo get_string('FE_index_main','stack','') ?></a> ! <a href="authorTest.php?id=<?php echo $qid ?>"><?php echo get_string('stackQuestion_filterLinkEdit','stack'); ?></a></p> <div class="section80"> ! <h3 class="section"><?php echo get_string('FE_deployQuestion_instancesOfQuestion', 'stack').' '.$qid; ?></h3> <p> <?php - $deployment = new Deployment($qid); // will auto-deploy as necessary - $request = $_POST + $_GET; // POST from this page with possible GET via Opaque if(!$deployment->isSingleton()) { // multiple versions - $result = $deployment->processOperations($request); if(!empty($result)) echo "<div class='warning'>".$result."</div>"; ! echo "<form method='POST' action='?id=".$qid."'>".$deployment->formXHTML()."</form"; } else { // single version echo "<div class='warning'>"; ! echo $deployment->processOperations($request); if($deployment->autoDeployed) { echo get_string('FE_deployQuestion_auto', 'stack'); } echo "</div>"; } ! //echo $deployment->listXHTML(); ! if($deployment->getInstances() == NULL) { echo '<i>'.get_string('FE_deployQuestion_noi', 'stack').'</i>'; } else { ! if (1 == count($deployment->getInstances())) { ! echo '<p>'.get_string('FE_deployQuestion_version', 'stack').'</p>'; } else { ! echo '<p>'.count($deployment->getInstances()).get_string('FE_deployQuestion_versions', 'stack').'</p>'; } echo '<table class="deploymentTable" border="1">'; echo '<tr><th>'; ! echo '</th><th>'; echo get_string('stackQuestion_questionStem', 'stack'); echo '</th><th>'; --- 41,121 ---- require_once $root.'/lib/deployment/Deployment.php'; + $id = $_GET['id']; // TODO: needs sanitization + + $itemDB = new StackDBItem(); + $itemDB->connect(); + $latestVersion = $itemDB->getLatestVersion($id); + $cache = new StackDBCache(); $cache->connect(); ! $deployment = new Deployment($id); // will auto-deploy as necessary ! $request = $_POST + $_GET; // POST from this page with possible GET via Opaque ! $result = $deployment->processOperations($request); + echo html_head(get_string('FE_deployVersion', 'stack'),'../../',"@import \"../../styles.css\";\n"); ?> <body> ! <h1><?php echo get_string('FE_deployVersion', 'stack').' '.$id; ?></h1> <p><a href="../../index.php"><?php echo get_string('FE_index_main','stack','') ?></a> ! <a href="authorTest.php?id=<?php echo $id ?>"><?php echo get_string('stackQuestion_filterLinkEdit','stack'); ?></a></p> <div class="section80"> ! <h3 class="section"> ! <?php ! if(isset($_GET['dropall'])) { ! $undeployment = new Deployment($_GET['dropall']); ! $undeployment->drop(); ! } ! ! echo get_string('FE_deployQuestion_instancesOfVersion', 'stack').' '.$id; ! ?></h3> <p> <?php + $earliest = $deployment->earliestDeployedVersion(); // any stale deployments? if(!$deployment->isSingleton()) { // multiple versions if(!empty($result)) echo "<div class='warning'>".$result."</div>"; ! if($latestVersion == $deployment->getVersion()) { // this is latest version ! if($latestVersion == $earliest || false == $earliest) { ! echo "<form method='POST' action='?id=".$id."'>".$deployment->formXHTML()."</form>"; ! } else { ! echo get_string('FE_deployQuestion_oldVersionDeployed', 'stack'); ! $deployment = new Deployment($earliest); ! echo '<p><a href="?id='.$id.'&dropall='.$earliest.'">'.get_string('FE_deployQuestion_undeployAll', 'stack').'</a>'; ! } ! } else { // this is an old version ! echo get_string('FE_deployQuestion_newerVersionCannotDeploy', 'stack', $latestVersion); ! echo '<a href="?id='.$latestVersion.'">deploy latest</a>'; ! } } else { // single version echo "<div class='warning'>"; ! echo $result;//$deployment->processOperations($request); if($deployment->autoDeployed) { echo get_string('FE_deployQuestion_auto', 'stack'); + } else { + echo get_string('FE_deployQuestion_oldVersionDeployed', 'stack'); + $deployment = new Deployment($earliest); } echo "</div>"; } ! $instances = $deployment->getInstances(); ! ! if($instances == NULL) { echo '<i>'.get_string('FE_deployQuestion_noi', 'stack').'</i>'; } else { ! if (1 == count($instances)) { ! echo '<p>'.get_string('FE_deployQuestion_instanceDeployed', 'stack').'</p>'; } else { ! echo '<p>'.get_string('FE_deployQuestion_xInstances', 'stack', $deployment->size()); } + echo get_string('FE_deployQuestion_ofVersionXdeployed', 'stack', $deployment->getVersion()).'</p>'; echo '<table class="deploymentTable" border="1">'; echo '<tr><th>'; ! //echo 'v';//get_string('stackQuestion_id.revision', 'stack'); ! //echo '</th><th>'; echo get_string('stackQuestion_questionStem', 'stack'); echo '</th><th>'; *************** *** 84,91 **** echo '</th></tr>'; ! foreach($deployment->getInstances() as $instance) { $item = $cache->getDisplayItem($instance['id']); echo '<tr>'; ! echo '<td>'. $instance['id'] .'</td>'; echo '<td>'. $instance['xhtml'] .'</td>'; echo '<td>'.$item->getQuestionNote().'</td>'; --- 124,132 ---- echo '</th></tr>'; ! foreach($instances as $instance) { ! //print_r($instance); $item = $cache->getDisplayItem($instance['id']); echo '<tr>'; ! //echo "<td>$instance[version]</td>"; echo '<td>'. $instance['xhtml'] .'</td>'; echo '<td>'.$item->getQuestionNote().'</td>'; *************** *** 99,113 **** ?> </div> - <div class="section80"> - <h3 class="section"><?php echo get_string('FE_deployQuestion_primedResponses', 'stack')?></h3> - Pregenerated from the question tests, they can include correct answers as well as common mistakes. The cache can be primed to include their straightforward submission to save the work at quiz time. - <form method="POST" action="questionDeploy.php?id=<?php echo $qid ?>"> - <input type="submit" value="Regenerate"> - </form> <?php $responses = $deployment->primeResponses(); if($responses === NULL) echo "No question tests defined!"; else echo sizeof($responses)." new responses primed."; // should output responses defined (counted) and their test result ?> </div> \ No newline at end of file --- 140,155 ---- ?> </div> <?php + if($earliest == $latestVersion) { + echo '<div class="section80">'; + echo '<h3 class="section">'.get_string('FE_deployQuestion_primedResponses', 'stack').'</h3>'; + echo get_string('FE_deployQuestion_primedResponsesBlurb', 'stack'); + echo '<form method="POST" action="questionDeploy.php?id='.$id.'"><input type="submit" value="Regenerate"></form>'; + $responses = $deployment->primeResponses(); if($responses === NULL) echo "No question tests defined!"; else echo sizeof($responses)." new responses primed."; // should output responses defined (counted) and their test result + } ?> </div> \ No newline at end of file Index: OptionsEdit.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/ui/OptionsEdit.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** OptionsEdit.php 4 Oct 2007 12:58:48 -0000 1.5 --- OptionsEdit.php 30 Sep 2010 16:56:15 -0000 1.6 *************** *** 19,23 **** $config = new stackConfig(); global $config; ! require_once('OptionsEditor.php'); $editor = new OptionsEditor(); --- 19,33 ---- $config = new stackConfig(); global $config; ! ! $url = $config->get('weburl'); ! $diemessage = "Please <a href='$url'>login</a>."; ! if (array_key_exists('loggedin',$_SESSION)) { ! $loggedin = $_SESSION['loggedin']; ! if (!$loggedin) { die($diemessage); } ! } else { ! die($diemessage); ! } ! ! require_once('OptionsEditor.php'); $editor = new OptionsEditor(); *************** *** 25,29 **** ?> ! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> --- 35,39 ---- ?> ! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> *************** *** 41,51 **** var optionsContainer; var copyContainer; ! window.onload = function() { optionsContainer = new fx.Height('options', {duration: 400}); copyContainer = new fx.Height('copy', {duration: 400}); ! //copyContainer.hide(); ! //optionsContainer.hide(); ! <?php //display last edited page. if(!empty($_POST['edit_new']) || !empty($_POST['edit_overwrite'])) --- 51,61 ---- var optionsContainer; var copyContainer; ! window.onload = function() { optionsContainer = new fx.Height('options', {duration: 400}); copyContainer = new fx.Height('copy', {duration: 400}); ! //copyContainer.hide(); ! //optionsContainer.hide(); ! <?php //display last edited page. if(!empty($_POST['edit_new']) || !empty($_POST['edit_overwrite'])) *************** *** 59,63 **** ?> } ! function toggleBoth() { --- 69,73 ---- ?> } ! function toggleBoth() { *************** *** 66,72 **** optionsContainer.toggle('optIcon', iconPath); } ! ! </script> ! <title>Question test</title> </head> --- 76,82 ---- optionsContainer.toggle('optIcon', iconPath); } ! ! </script> ! <title>Question test</title> </head> Index: authorTest.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/ui/authorTest.php,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** authorTest.php 11 Jan 2010 17:23:36 -0000 1.16 --- authorTest.php 30 Sep 2010 16:56:15 -0000 1.17 *************** *** 17,26 **** --- 17,39 ---- */ session_start(); + require_once('../../config.php'); $config = new stackConfig(); global $config; + $url = $config->get('weburl'); + $diemessage = "Please <a href='$url'>login</a>."; + if (array_key_exists('loggedin',$_SESSION)) { + $loggedin = $_SESSION['loggedin']; + if (!$loggedin) { die($diemessage); } + } else { + die($diemessage); + } + + require_once('AuthorDisplay.php'); + require_once $config->get('docroot').'/lib/ui/frontend.php'; + if(empty($_SESSION['authorItem']) || ($_POST == NULL)) { *************** *** 48,104 **** //unset($_SESSION['authorItem']); $_SESSION['authorItem'] = serialize($author); - ?> - - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - <html> - <head> - <style type="text/css" media="all"> - @import "../../styles.css"; - </style> - <script type="text/javascript" src="../../other/moo.fx/prototype.lite.js"></script> - <script type="text/javascript" src="../../other/moo.fx/moo.fx.js"></script> - <script type="text/javascript" src="../../other/jquery.js"></script> - <script type="text/javascript"> - // Initialise the effects - var metaContainer; - var optionsContainer; - var moodleContainer; - var prtContainer; - var qpContainer; - - - window.onload = function() { - metaContainer = new fx.Height('meta', {duration: 400}); - metaContainer.hide(); - optionsContainer = new fx.Height('options', {duration: 400}); - optionsContainer.hide(); - moodleContainer = new fx.Height('moptions', {duration: 400}); - moodleContainer.hide(); - prtContainer = new fx.Height('prtContainer', {duration: 400}); - qpContainer = new fx.Height('qpContainer', {duration: 400}); - - } ! </script> ! <script type="text/javascript"> ! function swapper(container, icon) ! { ! var iconPath = '<?php echo $config->get('weburl'); ?>/pix/'; ! container.toggle(icon, iconPath); ! } ! ! function toggleIcon(container) { ! var iconPath = '<?php echo $config->get('weburl'); ?>/pix/'; ! alert($(container).child()); ! } ! </script> ! <title>Question test</title> ! </head> <body> <form action="authorTest.php" method="POST"> <div id="authoringControls"> ! <h2><?php echo get_string('stackAuthor_title'.$key,'stack').' #'.$_GET['id'] ?></h2> ! <p><a href="../../index.php"><?php echo get_string('FE_index_main','stack','') ?></a></p> <input type="submit" name="submit" value="<?php echo get_string('stackAuthor_button_update','stack'); ?>" /> <input type="submit" name="submit" value="<?php echo get_string('stackAuthor_button_save','stack'); ?>" /> --- 61,71 ---- //unset($_SESSION['authorItem']); $_SESSION['authorItem'] = serialize($author); ! echo html_head(get_string('stackQuestion_authorEditQuestion', 'stack'),'../../',"@import \"../../styles.css\";\n", 'LaTeX', true); ! ?> <body> <form action="authorTest.php" method="POST"> <div id="authoringControls"> ! <a href="../../index.php"><?php echo get_string('FE_index_main','stack','') ?></a><p /> <input type="submit" name="submit" value="<?php echo get_string('stackAuthor_button_update','stack'); ?>" /> <input type="submit" name="submit" value="<?php echo get_string('stackAuthor_button_save','stack'); ?>" /> *************** *** 107,116 **** <input type="submit" name="submit" value="<?php echo get_string('stackAuthor_button_exportAsXml','stack'); ?>" /> <p> ! <a href="#stem">Stem</a> ! <br /><a href="#parts" onClick="$('#partContainer').slideDown();">Interactions</a> ! <br /><a href="#prts" onClick="$('#prtContainer').slideDown();">Responses</a> ! <br /><a href="#options" onClick="$('#optionContainer').slideDown();">Options</a> ! <br /><a href="#tests" onClick="$('#testContainer').slideDown();">Tests</a> ! <br /><a href="#meta" onClick="$('#metaContainer').slideDown();">Meta</a> </div> <?php --- 74,90 ---- <input type="submit" name="submit" value="<?php echo get_string('stackAuthor_button_exportAsXml','stack'); ?>" /> <p> ! <ul> ! <li><a href="#stem">Stem</a></li> ! <li><a href="#parts" onClick="$('#partContainer').slideDown();">Interactions</a></li> ! <li><a href="#prts" onClick="$('#prtContainer').slideDown();">Responses</a></li> ! <li><a href="#options" onClick="$('#optionContainer').slideDown();">Options</a></li> ! <li><a href="#tests" onClick="$('#testContainer').slideDown();">Tests</a></li> ! <li><a href="#meta" onClick="$('#metaContainer').slideDown();">Meta</a></li> ! </ul> ! <?php ! // line history ! //echo $author->displayVersionHistory(); ! ?> ! </div> <?php *************** *** 118,122 **** ?> </form> ! <?php --- 92,100 ---- ?> </form> ! <script language="JavaScript" type="text/javascript"> ! $(document).ready(function() { ! $('#authoringControls').append($('#versionHistory').detach().html()); ! }); ! </script> <?php Index: DisplayItem.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/ui/DisplayItem.php,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** DisplayItem.php 13 May 2010 16:09:53 -0000 1.99 --- DisplayItem.php 30 Sep 2010 16:56:15 -0000 1.100 *************** *** 309,313 **** /** Processes the question inserting in the students answer, answerboxes and feedback as needed. * Returns the XHTML representation of the question. ! * No caching; that logic is handled higher up. * * @param array $posted values --- 309,313 ---- /** Processes the question inserting in the students answer, answerboxes and feedback as needed. * Returns the XHTML representation of the question. ! * No display caching; that logic is handled higher up. * * @param array $posted values *************** *** 385,388 **** --- 385,389 ---- //check status, $status = $IE->getStatus(); + $hideFeedback = 'true' == $this->item->questionPart[$label]->getHideFeedback()->getSelected(); switch($status) *************** *** 403,406 **** --- 404,410 ---- //$full .= '<span class="solutionButton"> '.get_string('stackQuestionDisplay_viewSolution','stack','').'<input type="checkbox" value="true" name="'."SR__$label".'" />'; + if($hideFeedback) { + $full = ''; + } $xhtml = str_replace("<IEfeedback>$label</IEfeedback>", $full, $xhtml); break; *************** *** 423,426 **** --- 427,433 ---- $full .= "</div>\n\n"; + if($hideFeedback) { + $full = ''; + } $xhtml = str_replace("<IEfeedback>$label</IEfeedback>", $full, $xhtml); break; *************** *** 436,439 **** --- 443,449 ---- } $full .= "</div>\n\n"; + if($hideFeedback) { + $full = ''; + } $xhtml = str_replace("<IEfeedback>$label</IEfeedback>", $full, $xhtml); break; *************** *** 452,455 **** --- 462,468 ---- $full .= '<br />'.get_string('stackQuestionDisplay_ThisCanDisplay','stack','').' <span class="SyntaxExample2">'.$this->cachedTAnsValue[$label].'</span> '; $full .= "</div>\n\n"; + if($hideFeedback) { + $full = ''; + } $xhtml = str_replace("<IEfeedback>$label</IEfeedback>", $full, $xhtml); *************** *** 769,772 **** --- 782,786 ---- //var_dump($implicitForbid); $this->studentAnswers->syntaxCheck($this->itemOpts, $this->item->getQuestionPartsByStudentAnsKey(), $implicitForbid); + $this->studentAnswers->scoreIfValid($this->item->getQuestionPartsByStudentAnsKey()); $this->studentAnswers->casValidate($this->itemOpts, $this->item->getSeed(), $this->item->getQuestionPartsByStudentAnsKey(), $this->cachedTAnsValue); *************** *** 1306,1309 **** --- 1320,1324 ---- } + public function getTestInput($test) { *************** *** 1362,1369 **** } ! //echo "<pre>"; print_r($test); echo "</pre>"; ! foreach ($test as $key => $val) { ! $test_post[$key] = $postcalc[$key]; ! } return $test_post; --- 1377,1396 ---- } ! ! //echo "<pre>.."; print_r($testIE); echo "..</pre>"; ! $questionParts = $this->item->getQuestionPartsByStudentAnsKey(); ! $test_post=array(); ! if(!empty($questionParts)) ! { ! foreach($questionParts as $SA => $QP) ! { ! $type = $QP->getInputType(); ! $inputType = new InputTypeController($type,$SA); ! $result = $inputType->getTestPostData($postcalc[$SA]); ! foreach($result as $key => $val) { ! $test_post['sAns__'.$key] = $val; ! } ! } ! } return $test_post; *************** *** 1559,1570 **** foreach($qpNames as $name) { if (array_key_exists('IE_'.$name,$QT)) { ! $tests[$key]['IE']['sAns__'.$name] = $QT['IE_'.$name]; } } ! foreach($PRTs as $name =>$PRT) { ! if (array_key_exists('PRT_'.$name,$QT)) { ! $tests[$key]['PRT'][$name] = $QT['PRT_'.$name]; ! } } } --- 1586,1599 ---- foreach($qpNames as $name) { if (array_key_exists('IE_'.$name,$QT)) { ! $tests[$key]['IE'][$name] = $QT['IE_'.$name]; } } ! if (!empty($PRTs)) { ! foreach($PRTs as $name =>$PRT) { ! if (array_key_exists('PRT_'.$name,$QT)) { ! $tests[$key]['PRT'][$name] = $QT['PRT_'.$name]; ! } ! } } } *************** *** 1610,1618 **** // If a PRT is not traversed then the answernote should not exist. // This is different from an answernote existing with the value "NONE", so unset where necessary. ! foreach($test['PRT'] as $key=>$val){ ! if ('NONE'==trim($val)) ! { ! unset($test['PRT'][$key]); ! } } --- 1639,1649 ---- // If a PRT is not traversed then the answernote should not exist. // This is different from an answernote existing with the value "NONE", so unset where necessary. ! if (array_key_exists('PRT',$test)) { ! foreach($test['PRT'] as $key=>$val){ ! if ('NONE'==trim($val)) ! { ! unset($test['PRT'][$key]); ! } ! } } Index: AuthorDisplay.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/ui/AuthorDisplay.php,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** AuthorDisplay.php 11 Jan 2010 17:23:36 -0000 1.67 --- AuthorDisplay.php 30 Sep 2010 16:56:15 -0000 1.68 *************** *** 26,33 **** --- 26,35 ---- require_once $root.'/lib/ui/DisplayItem.php'; require_once $root.'/lib/translator.php'; + require_once $root.'/lib/stringUtil.php'; require_once $root.'/lib/XML/ExportStackTwoItem.php'; require_once $root.'/lib/ui/inputTypes/InputTypeController.php'; require_once($root.'/lib/database/MoodleDB.php'); require_once($root.'/lib/database/StackDBCache.php'); + require_once($root.'/lib/database/StackDBItem.php'); /** *************** *** 109,113 **** else { ! //load a question from the database, if it exists. (loads the itemOptions form the database too. $this->item = new Item(NULL, $questionId); } --- 111,115 ---- else { ! //load a question from the database, if it exists (loads the itemOptions form the database too). $this->item = new Item(NULL, $questionId); } *************** *** 138,141 **** --- 140,146 ---- $display = ''; } + + $display .= $this->displayJS(); + $display .= $this->displayStem(); *************** *** 152,155 **** --- 157,161 ---- $display .= $this->displayMeta(); $display .= $this->displayMoodleAuthor($engineID); + $display .= $this->displayVersionHistory($engineID); return $display; *************** *** 166,182 **** private function displayStem() { $stem = '<div id="stem" class="section">'; ! // var_dump($this); ! ! if($this->item->getQuestionId() != NULL) ! { ! $stem .= '<div class="row"><span class="label">'.get_string('stackAuthor_qid', 'stack','').' </span><span class="formw">'.$this->item->getQuestionId().'</span></div>'; ! } ! $stem .= '<div class="row"><span class="label">'.get_string('stackAuthor_name', 'stack','').' </span><span class="formw">'.$this->item->questionName->editWidget('questionName', 64).'</span></div>'; $stem .= '<div class="row"><span class="label">'.get_string('stackAuthor_description', 'stack','').' </span><span class="formw"> '.$this->item->questionDescription->editWidget('questionDescription', 65,2,12).'</span></div>'; $stem .= '<div class="row"><span class="label">'.get_string('stackAuthor_keywords', 'stack','').' </span><span class="formw"> '.$this->item->questionKeywords->editWidget('questionKeywords', 64).'</span></div>'; ! $stem .= '<div class="row"><span class="label">'.get_string('stackAuthor_qvariables', 'stack','').' </span><span class="formw"> '.$this->item->questionVariables->editWidget('questionVariables', 65, 4, 12).'</span></div>'; if(!empty($this->authoringErrors['questionVariables']) && ($this->refreshCycle > 0)) --- 172,184 ---- private function displayStem() { + global $config; $stem = '<div id="stem" class="section">'; + // <h3>'.get_string('stackAuthor_stem', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack').'" href="http://stack.bham.ac.uk/wiki/index.php/Stem"><img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" /></a></h3>'; ! $stem .= '<div id="authoringVersionID">v.'.$this->item->getQuestionId().'</div>'; $stem .= '<div class="row"><span class="label">'.get_string('stackAuthor_name', 'stack','').' </span><span class="formw">'.$this->item->questionName->editWidget('questionName', 64).'</span></div>'; $stem .= '<div class="row"><span class="label">'.get_string('stackAuthor_description', 'stack','').' </span><span class="formw"> '.$this->item->questionDescription->editWidget('questionDescription', 65,2,12).'</span></div>'; $stem .= '<div class="row"><span class="label">'.get_string('stackAuthor_keywords', 'stack','').' </span><span class="formw"> '.$this->item->questionKeywords->editWidget('questionKeywords', 64).'</span></div>'; ! $stem .= '<div class="row"><span class="label">'.get_string('stackAuthor_qvariables', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack').'"href="http://stack.bham.ac.uk/wiki/index.php/KeyVals#Question_variables"><img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" /></a> </span> <span class="formw"> '.$this->item->questionVariables->editWidget('questionVariables', 65, 4, 12).'</span></div>'; if(!empty($this->authoringErrors['questionVariables']) && ($this->refreshCycle > 0)) *************** *** 188,192 **** //the question stem itself ! $stem .= '<br /><br /><div class="row"><span class="label"><strong>'.get_string('stackAuthor_stem', 'stack','').'</strong> <br /><br /><code>'.get_string('stackAuthor_stemInfo', 'stack','').'</code></span><span class="formw"> '.$this->item->questionStem->editWidget('questionStem', 65, 15, 30).'</span></div>'; $stem .= '<div class="clearer"> </div>'; --- 190,199 ---- //the question stem itself ! $stem .= '<br /><br /><div class="row"><span class="label"><strong>'.get_string('stackAuthor_questionStem', 'stack','') ! .'</strong> <br /><br /><code>'.get_string('stackAuthor_stemInfo', 'stack','').'</code>' ! .'<p />Preview<input onclick="$(\'#stemPreview\').slideToggle(\'fast\')" type="checkbox" name="previewstem"></span>'; ! $stem .= '<span class="formw" onkeyup="authorPreview(\'questionStem\',\'#stemPreview\')">'.$this->item->questionStem->editWidget('questionStem', 65, 15, 30).'</span></div>'; ! $stem .= '<div class="row"><span class="label"> </span><span class="formw"><div id="stemPreview" class="authorMath"></div></div></span>'; ! $stem .= '<script>authorPreview(\'questionStem\',\'#stemPreview\')</script>'; $stem .= '<div class="clearer"> </div>'; *************** *** 197,201 **** } ! $stem .= '<div class="row"><span class="label">'.get_string('stackAuthor_workedSolution', 'stack','').'</span><span class="formw"> '.$this->item->workedSolution->editWidget('workedSolution', 65, 2, 10).'</span></div>'; $stem .= '<div class="clearer"> </div>'; if(!empty($this->authoringErrors['workedSolution']) && ($this->refreshCycle > 0)) --- 204,211 ---- } ! $stem .= '<div class="row"><span class="label">'.get_string('stackAuthor_workedSolution', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack').'"href="http://stack.bham.ac.uk/wiki/index.php/CASText#Worked_solution"><img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" /></a>'; ! $stem .= '<p />Preview<input onclick="$(\'#workedSolutionPreview\').slideToggle(\'fast\')" type="checkbox" name="previewstem"></span></span><span class="formw" onkeyup="authorPreview(\'workedSolution\',\'#workedSolutionPreview\')" class="formw"> '.$this->item->workedSolution->editWidget('workedSolution', 65, 2, 10).'</span></div>'; ! $stem .= '<div class="row"><span class="label"> </span><span class="formw"><div id="workedSolutionPreview" class="authorMath"></div></div></span>'; ! $stem .= '<script>authorPreview(\'workedSolution\',\'#workedSolutionPreview\')</script>'; $stem .= '<div class="clearer"> </div>'; if(!empty($this->authoringErrors['workedSolution']) && ($this->refreshCycle > 0)) *************** *** 204,208 **** } ! $stem .= '<div class="row"><span class="label">'.get_string('stackAuthor_qnote', 'stack','').' </span><span class="formw"> '.$this->item->questionNote->editWidget('questionNote', 65, 2, 10).'</span></div>'; $stem .= '<div class="clearer"> </div>'; --- 214,218 ---- } ! $stem .= '<div class="row"><span class="label">'.get_string('stackAuthor_qnote', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack').'"href="http://stack.bham.ac.uk/wiki/index.php/Question_note"><img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" /></a></span><span class="formw"> '.$this->item->questionNote->editWidget('questionNote', 65, 2, 10).'</span></div>'; $stem .= '<div class="clearer"> </div>'; *************** *** 215,218 **** --- 225,229 ---- //$stem .= '<div class="row"><span class="label"><input type="submit" name="submit" value="'.get_string('stackAuthor_button_update','stack').'" /></span></div>'; + $stem .= '<div class="clearer"> </div><br /> </div>'; return $stem; *************** *** 228,232 **** { global $config; ! $form = '<div id="prts" class="section"><h3><a onclick="$(\'#prtContainer\').slideToggle();swapper(prtContainer, \'prtIcon\');"><img src="'.$config->get('weburl').'/pix/triangleDown.gif" name="prtIcon" />'.get_string('stackAuthor_potentialResponseTrees', 'stack','').'</a></h3>'; //$form = '<div class="section"><h3><a onclick="prtContainer.toggle();"> '.get_string('stackAuthor_potentialResponseTrees', 'stack','').'</a></h3>'; $form .= '<div id="prtContainer">'; --- 239,249 ---- { global $config; ! $form = '<div id="prts" class="section"> ! <h3><a onclick="$(\'#prtContainer\').slideToggle();swapper(prtContainer, \'prtIcon\');"> ! <img src="'.$config->get('weburl').'/pix/triangleDown.gif" name="prtIcon" /> '. ! get_string('stackAuthor_potentialResponseTrees', 'stack','').'</a> ! <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Potential_response_trees"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></h3>'; //$form = '<div class="section"><h3><a onclick="prtContainer.toggle();"> '.get_string('stackAuthor_potentialResponseTrees', 'stack','').'</a></h3>'; $form .= '<div id="prtContainer">'; *************** *** 245,253 **** } - $PRTs = $this->item->getPRTs(); if($PRTs != NULL) { - foreach($PRTs as $name => $PRT) { --- 262,268 ---- *************** *** 272,276 **** $widget = $PRT->feedbackVariables->editWidget($prefix.'-feedbackVariables', 65, 2, 6); ! $form .= '<div class="row"><span class="label">'.get_string('stackAuthor_feedbackVariables', 'stack','').' <br /><br /></span><span class="formw">'.$widget.'</span></div>'; $form .= '<div style="clear: both"> </div>'; --- 287,291 ---- $widget = $PRT->feedbackVariables->editWidget($prefix.'-feedbackVariables', 65, 2, 6); ! $form .= '<div class="row"><span class="label">'.get_string('stackAuthor_feedbackVariables', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack').'"href="http://stack.bham.ac.uk/wiki/index.php/KeyVals#Feedback_variables"><img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" /></a><br /><br /></span><span class="formw">'.$widget.'</span></div>'; $form .= '<div style="clear: both"> </div>'; *************** *** 325,329 **** { global $config; ! $xhtml = '<div id="parts" class="section"><h3><a onclick="$(\'#partContainer\').slideToggle();swapper(qpContainer, \'qpIcon\');"><img src="'.$config->get('weburl').'/pix/triangleDown.gif" name="qpIcon" />'.get_string('stackAuthor_interactionElements', 'stack','').'</a></h3>'; //$xhtml = '<div class="section"><h3><a onclick="qpContainer.toggle();">'.get_string('stackAuthor_interactionElements', 'stack','').'</a></h3>'; $xhtml .= '<div id="partContainer">'; --- 340,346 ---- { global $config; ! $xhtml = '<div id="parts" class="section"><h3><a onclick="$(\'#partContainer\').slideToggle();swapper(qpContainer, \'qpIcon\');"><img src="'.$config->get('weburl').'/pix/triangleDown.gif" name="qpIcon" />'.get_string('stackAuthor_interactionElements', 'stack','').'</a> <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></h3>'; //$xhtml = '<div class="section"><h3><a onclick="qpContainer.toggle();">'.get_string('stackAuthor_interactionElements', 'stack','').'</a></h3>'; $xhtml .= '<div id="partContainer">'; *************** *** 335,340 **** $xhtml .= '<table class="interactionElementsTable" border="1" cellpadding="2" cellspacing="0"> <tbody> ! <tr> ! <td class="tableTitle">'.get_string('stackAuthor_studentAnsKey', 'stack','').'</td>'; foreach($qpNames as $name) --- 352,359 ---- $xhtml .= '<table class="interactionElementsTable" border="1" cellpadding="2" cellspacing="0"> <tbody> ! <tr><td class="IElabel"> </td> ! <td colspan="'.$noQPs.'">'.get_string('stackAuthor_studentAnsKey', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements#Students.27s_Answer_Key"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td></tr><tr><td class="IElabel"> </td>'; foreach($qpNames as $name) *************** *** 342,346 **** $xhtml .= '<td class="tableTitle">'.$name.'</td>'; } ! $xhtml .= "</tr><tr><td>".get_string('stackAuthor_inputType', 'stack','')."</td>"; //inputtypes --- 361,367 ---- $xhtml .= '<td class="tableTitle">'.$name.'</td>'; } ! $xhtml .= '</tr><tr><td class="IElabel">'.get_string('stackAuthor_inputType', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements#Input_Type"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td>'; //inputtypes *************** *** 354,358 **** } ! $xhtml .= '</tr><tr><td>'.get_string('stackAuthor_teachersAns', 'stack','').'</td>'; //teachers answer foreach($qpNames as $name) --- 375,381 ---- } ! $xhtml .= '</tr><tr><td class="IElabel">'.get_string('stackAuthor_teachersAns', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements#Teacher.27s_Answer"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td>'; //teachers answer foreach($qpNames as $name) *************** *** 366,370 **** //box size ! $xhtml .= '</tr><tr><td>'.get_string('stackAuthor_boxsize', 'stack','').'</td>'; foreach($qpNames as $name) { --- 389,395 ---- //box size ! $xhtml .= '</tr><tr><td class="IElabel">'.get_string('stackAuthor_boxsize', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements#Box_Size"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td>'; foreach($qpNames as $name) { *************** *** 374,378 **** } //allow informal syntax ! $xhtml .='</tr><tr><td>'.get_string('stackAuthor_strictsyntax', 'stack','').'</td>'; foreach($qpNames as $name) --- 399,405 ---- } //allow informal syntax ! $xhtml .='</tr><tr><td class="IElabel">'.get_string('stackAuthor_strictsyntax', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements#Strict_Syntax"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td>'; foreach($qpNames as $name) *************** *** 385,389 **** //allow informal syntax ! $xhtml .='</tr><tr><td>'.get_string('stackAuthor_insertStars', 'stack','').'</td>'; foreach($qpNames as $name) --- 412,418 ---- //allow informal syntax ! $xhtml .='</tr><tr><td class="IElabel">'.get_string('stackAuthor_insertStars', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements#Insert_Stars"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td>'; foreach($qpNames as $name) *************** *** 397,401 **** //syntax hint ! $xhtml .= '</tr><td>'.get_string('stackAuthor_syntaxHint', 'stack','').'</td>'; foreach($qpNames as $name) --- 426,432 ---- //syntax hint ! $xhtml .= '</tr><td class="IElabel">'.get_string('stackAuthor_syntaxHint', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements#Syntax_Hint"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td>'; foreach($qpNames as $name) *************** *** 408,412 **** //forbidden words, comma separated. ! $xhtml .= '</tr><td>'.get_string('stackAuthor_forbiddenWords', 'stack','').'</td>'; foreach($qpNames as $name) --- 439,445 ---- //forbidden words, comma separated. ! $xhtml .= '</tr><td class="IElabel">'.get_string('stackAuthor_forbiddenWords', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements#Forbidden_words"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td>'; foreach($qpNames as $name) *************** *** 430,434 **** //allowed words, same as forbidden words ! $xhtml .= '</tr><td>'.get_string('stackAuthor_allowedWords', 'stack','').'</td>'; foreach($qpNames as $name) --- 463,469 ---- //allowed words, same as forbidden words ! $xhtml .= '</tr><td class="IElabel">'.get_string('stackAuthor_allowedWords', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements#Allowed_words"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td>'; foreach($qpNames as $name) *************** *** 452,456 **** //forbid floats ! $xhtml .= '</tr><td>'.get_string('stackAuthor_forbidFloats', 'stack','').'</td>'; foreach($qpNames as $name) --- 487,493 ---- //forbid floats ! $xhtml .= '</tr><td class="IElabel">'.get_string('stackAuthor_forbidFloats', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements#Forbid_Floats"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td>'; foreach($qpNames as $name) *************** *** 463,467 **** //Require in lowest terms ! $xhtml .= '</tr><td>'.get_string('stackAuthor_LowestTerms', 'stack','').'</td>'; foreach($qpNames as $name) --- 500,506 ---- //Require in lowest terms ! $xhtml .= '</tr><td class="IElabel">'.get_string('stackAuthor_LowestTerms', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements#Require_lowest_terms"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td>'; foreach($qpNames as $name) *************** *** 474,478 **** //SameType ! $xhtml .= '</tr><td>'.get_string('stackAuthor_sameType', 'stack','').'</td>'; foreach($qpNames as $name) --- 513,519 ---- //SameType ! $xhtml .= '</tr><td class="IElabel">'.get_string('stackAuthor_sameType', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements#Check_Students_answer.27s_type"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td>'; foreach($qpNames as $name) *************** *** 487,493 **** } //finally add in any input type options ! $xhtml .= '</tr><td>'.get_string('stackAuthor_inputTypeOpt', 'stack').'</td>'; foreach($qpNames as $name) --- 528,568 ---- } + //StudentVerify + $xhtml .= '</tr><td class="IElabel">'.get_string('stackAuthor_studentVerify', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). + '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements#Student_must_verify"> + <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td>'; + + foreach($qpNames as $name) + { + $prefix = 'qp-'.$name.'-studentVerify'; + $studentVerify = $this->item->questionPart[$name]->getStudentVerify(); + if($studentVerify !== NULL) + { + $widget = $studentVerify->editWidget($prefix); + $xhtml .= '<td>'.$widget.'</td>'; + } + } + + //HideFeedback + $xhtml .= '</tr><td class="IElabel">'.get_string('stackAuthor_hideFeedback', 'stack','').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). + '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements#Hide_feedback"> + <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td>'; + + foreach($qpNames as $name) + { + $prefix = 'qp-'.$name.'-hideFeedback'; + $hideFeedback = $this->item->questionPart[$name]->getHideFeedback(); + if($hideFeedback !== NULL) + { + $widget = $hideFeedback->editWidget($prefix); + $xhtml .= '<td>'.$widget.'</td>'; + } + } + //finally add in any input type options ! $xhtml .= '</tr><td class="IElabel">'.get_string('stackAuthor_inputTypeOpt', 'stack').' <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Interaction_elements"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></td>'; foreach($qpNames as $name) *************** *** 561,565 **** { global $config; ! $meta = '<div id="meta" class="section"><h3><a onclick="$(\'#metaContainer\').slideToggle();swapper(metaContainer, \'metaIcon\');"><img src="'.$config->get('weburl').'/pix/triangleUp.gif" name="metaIcon" />'.get_string('stackAuthor_metadata', 'stack','').'</a></h3>'; //$meta = '<div class="section"><h3><a onclick="metaContainer.toggle();">'.get_string('stackAuthor_metadata','stack','').'</a></h3>'; $meta .= '<div id="metaContainer">'; --- 636,643 ---- { global $config; ! $meta = '<div id="meta" class="section"><h3><a onclick="$(\'#metaContainer\').slideToggle();swapper(metaContainer, \'metaIcon\');"><img src="'.$config->get('weburl').'/pix/triangleUp.gif" name="metaIcon" />'.get_string('stackAuthor_metadata', 'stack','').'</a> <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Metadata"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></h3>'; ! //$meta = '<div class="section"><h3><a onclick="metaContainer.toggle();">'.get_string('stackAuthor_metadata','stack','').'</a></h3>'; $meta .= '<div id="metaContainer">'; *************** *** 589,593 **** { global $config; ! $opt = '<div id="options" class="section"><h3><a onclick="$(\'#optionContainer\').slideToggle();swapper(optionsContainer, \'optIcon\');"><img src="'.$config->get('weburl').'/pix/triangleUp.gif" name="optIcon" />'.get_string('stackAuthor_options', 'stack','').'</a></h3>'; //$opt = '<div class="section"><h3><a onclick="optionsContainer.toggle();">'.get_string('stackAuthor_options','stack','').'</a></h3>'; $opt .= '<div id="optionContainer">'; --- 667,673 ---- { global $config; ! $opt = '<div id="options" class="section"><h3><a onclick="$(\'#optionContainer\').slideToggle();swapper(optionsContainer, \'optIcon\');"><img src="'.$config->get('weburl').'/pix/triangleUp.gif" name="optIcon" />'.get_string('stackAuthor_options', 'stack','').'</a> <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Options"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></h3>'; //$opt = '<div class="section"><h3><a onclick="optionsContainer.toggle();">'.get_string('stackAuthor_options','stack','').'</a></h3>'; $opt .= '<div id="optionContainer">'; *************** *** 615,619 **** { global $config; ! $tests = '<div id="tests" class="section"><h3><a name="tests" onclick="$(\'#testContainer\').slideToggle();swapper(testsContainer, \'optIcon\');"><img src="'.$config->get('weburl').'/pix/triangleDown.gif" name="optIcon" />'.get_string('stackAuthor_questionTests', 'stack','').'</a></h3>'; $tests .= '<div id="testContainer">'; if(!empty($this->item->questionPart)) { --- 695,701 ---- { global $config; ! $tests = '<div id="tests" class="section"><h3><a name="tests" onclick="$(\'#testContainer\').slideToggle();swapper(testsContainer, \'optIcon\');"><img src="'.$config->get('weburl').'/pix/triangleDown.gif" name="optIcon" />'.get_string('stackAuthor_questionTests', 'stack','').'</a> <a target="_blank" alt="'.get_string('stackAuthor_onlineGuide','stack'). ! '" href="http://stack.bham.ac.uk/wiki/index.php/Testing"> ! <img title="'.get_string('stackAuthor_onlineGuide','stack').'" src="'.$config->get('weburl').'/pix/help.png" name="help" /></a></h3>'; $tests .= '<div id="testContainer">'; if(!empty($this->item->questionPart)) { *************** *** 815,819 **** $valid = $this->gWriter->validate(); $this->item->store(); - if($this->item->valid == true) { --- 897,900 ---- *************** *** 836,840 **** } ! //if in Moodle, update if(!empty($engineID)) { --- 917,921 ---- } ! //if in Moodle, update via add if(!empty($engineID)) { *************** *** 846,850 **** //update Moodle's database. $qid = $this->item->getQuestionId(); ! $result = $db->addQuestion($qid, $this->authorId, $engineID, $post['category']); if($result == false) { --- 927,931 ---- //update Moodle's database. $qid = $this->item->getQuestionId(); ! $result = $db->addQuestion($qid, $this->item->getLine(), $this->authorId, $engineID, $post['category']); if($result == false) { *************** *** 873,877 **** case get_string('stackAuthor_button_exportAsXml','stack'): - //echo 'Would be exporting as XML now'; $valid = $this->gWriter->validate(); $this->item->store(); --- 954,957 ---- *************** *** 894,898 **** break; ! case 'Add to Moodle': $valid = $this->gWriter->validate(); --- 974,978 ---- break; ! case get_string('stackAuthor_addToMoodle','stack'): $valid = $this->gWriter->validate(); *************** *** 904,908 **** $db = new MoodleDB(); $db->connect(); ! $result = $db->addQuestion($qid, $this->authorId, $engineID, $post['category']); $db->disconnect(); unset($db); --- 984,988 ---- $db = new MoodleDB(); $db->connect(); ! $result = $db->addQuestion($qid, $this->item->getLine(), $this->authorId, $engineID, $post['category']); $db->disconnect(); unset($db); *************** *** 932,935 **** --- 1012,1096 ---- return $valid;*/ } + + public function displayVersionHistory($engineID = NULL) { + global $config; + // get itemdb connection + $db = new StackDBItem(); + $db->connect(); + // get array of versions time->id + + $versions = $db->getVersions($this->item->getLine()); + + if(!empty($versions)) { + $output = '<div class="section" id="versionHistory">'; + $output .= "<h3>".get_string('stackAuthor_savedVersions','stack','')."</h3>"; + foreach($versions as $date=>$id) { + if($engineID != NULL) { // for Moodle authoring + //if($this->item->getQuestionId() == $id) $output .= '<img src="'.$config->get('webroot').'/pix/transparent16x16.gif" /> <a href="questionTest.php?id='.$id.'"><img src="'.$config->get('webroot').'/pix/eye.png" alt="'.get_string('stackIcon_try','stack').'" /></a> <b>'.stringUtil::prettifyDate($date).'</b>'; + if($this->item->getQuestionId() == $id) $output .= '<img src="'.$config->get('webroot').'/pix/arrow_right.png" /> <a href="questionTest.php?id='.$id.'"><img src="'.$config->get('webroot').'/pix/eye.png" alt="'.get_string('stackIcon_try','stack').'" /></a> <b>'.stringUtil::prettifyDate($date).'</b>'; + else $output .= '<a href="stackAuthor.php?id='.$id.'"><img src="'.$config->get('webroot').'/pix/pencil.png" alt="'.get_string('stackIcon_edit','stack').'" /> <a href="stackSessionPage.php?page=try&id='.$id.'"> <img src="'.$config->get('webroot').'/pix/eye.png" alt="'.get_string('stackIcon_try','stack').'" /></a> '.stringUtil::prettifyDate($date); + + } else { // for standalone STACK authoring + if($this->item->getQuestionId() == $id) $output .= '<img src="'.$config->get('webroot').'/pix/transparent16x16.gif" /> <a href="questionTest.php?id='.$id.'"><img src="'.$config->get('webroot').'/pix/eye.png" alt="'.get_string('stackIcon_try','stack').'" /></a> <b>'.stringUtil::prettifyDate($date).'</b>'; + else $output .= '<a href="authorTest.php?id='.$id.'"><img src="'.$config->get('webroot').'/pix/pencil.png" alt="'.get_string('stackIcon_edit','stack').'" /> <a href="questionTest.php?id='.$id.'"> <img src="'.$config->get('webroot').'/pix/eye.png" alt="'.get_string('stackIcon_try','stack').'" /></a> '.stringUtil::prettifyDate($date); + } + $output .= '<br />'; + } + $output .= "</div>"; + } + + $db->disconnect(); + + return $output; + } + + public function displayJS() { + // get options required from each input type + $inputCont = new InputTypeController(); + + $output = "<script>"; + + $usedOptions = str_replace('\n','',json_encode(InputTypeController::getOptionsUsed())); + $optionDefaults = str_replace('\n','',json_encode(InputTypeController::getOptionDefaults())); + $output .= 'usedOptions = eval('.$usedOptions.');'; + $output .= 'optionDefaults = eval('.$optionDefaults.');'; + + $output .= "function updateOptions(name) { + key = name.match(/-(.*)-/)[1]; // gives answer key + type = $(\"*[name='\"+name+\"']\").val(); // e.g. True/False + shown = usedOptions[type]; + + $(\"*[name^='qp-\"+key+\"']\").each(function() { // for each option for this ans + optionName = $(this).attr('name'); // e.g. qp-a-syntaxHint + option = optionName.match(/-.+?-(.*)$/)[1]; // gives option name, e.g. syntaxHint + //console.log(option); + $(this).hide(); // assume hidden by default + + //$(this).css('border','1px solid red'); // for testing only + for(i = 0; i < shown.length; i++) { // search for option + if(shown[i] == option) { + $(this).show(); + //$(this).css('border','1px solid green');// for testing only + } + } + if(optionDefaults[type] && optionDefaults[type][option]) { + $(this).val(optionDefaults[type][option]); + } + }); + $(\"*[name*='inputTypeParam']\").show(); // always show IT params! + //$(\"input:hidden\").after(\"n/a\"); + } + + $(document).ready(function() { + // handle changes in input type + $(\"select[name$='inputType']\").change(function() { + updateOptions($(this).attr('name'))}); + // initial option hiding (can prolly be chained to above) + $(\"select[name$='inputType']\").each(function() { + updateOptions($(this).attr('name'))}); + }); + </script>"; + return $output; + } } Index: questionBank.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/ui/questionBank.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d ... [truncated message content] |