From: Simon H. <sim...@us...> - 2010-07-23 12:35:36
|
Update of /cvsroot/stack/stack-dev/lib/ui In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv19338/lib/ui Modified Files: Tag: STACK2_2 AuthorDisplay.php Log Message: Code for hiding IE options. Needs completing for all input types. Index: AuthorDisplay.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/ui/AuthorDisplay.php,v retrieving revision 1.67.2.12 retrieving revision 1.67.2.13 diff -C2 -d -r1.67.2.12 -r1.67.2.13 *** AuthorDisplay.php 21 Jul 2010 07:30:33 -0000 1.67.2.12 --- AuthorDisplay.php 23 Jul 2010 12:35:27 -0000 1.67.2.13 *************** *** 141,145 **** } ! //$display .= $this->displaySys(); $display .= $this->displayStem(); --- 141,145 ---- } ! $display .= $this->displayJS(); $display .= $this->displayStem(); *************** *** 163,187 **** } - - /** - * Displays the system-assigned question info - * @access private - * @return string xhtml - */ - private function displaySys() - { - if($this->item->getQuestionId() != NULL) - { - return '<div class="section">'.get_string('stackAuthor_editingQuestion', 'stack'). - ' '.$this->item->questionName->getSelection().'</div>'; - /* return '<div class="section"><div class="row"><span class="label">'. - get_string('stackAuthor_authoring', 'stack',''). - ' </span><span class="formw">'.$this->item->questionName->getSelection(). - ' (last '.$this->item->getVersion().' saved '. - stringUtil::prettifyDate($this->item->questionDateLastEdited->getSelection()).')</span></div></div>'; - */ - } - } - /** * Displays the parts of the question that can be displayed before the questionStem has been filled in. --- 163,166 ---- *************** *** 198,202 **** '" href="http://stack.bham.ac.uk/wiki/index.php/%3F: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>'; --- 177,181 ---- '" href="http://stack.bham.ac.uk/wiki/index.php/%3F: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>'; *************** *** 618,622 **** '" href="http://stack.bham.ac.uk/wiki/index.php/%3F:Meta_Data"> <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">'; --- 597,601 ---- '" href="http://stack.bham.ac.uk/wiki/index.php/%3F:Meta_Data"> <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">'; *************** *** 934,938 **** case get_string('stackAuthor_button_exportAsXml','stack'): - //echo 'Would be exporting as XML now'; $valid = $this->gWriter->validate(); $this->item->store(); --- 913,916 ---- *************** *** 1024,1027 **** --- 1002,1069 ---- return $output; } + + public function displayJS() { + echo "<script> + /* + All options: + teacherAns + boxSize + informalSyntax + insertStars + syntaxHint + forbid + allow + floats + lowest + sameType + studentVerify + */ + hiddenOptions = [ + 'Algebraic Input', + [], + 'True/False', + ['boxSize','informalSyntax','insertStars','syntaxHint','forbid','allow','floats','lowest','sameType','studentVerify'], + 'Single Character', + [], + 'DropDownList', + [], + 'Matrix', + [], + 'List', + [], + 'Textarea', + [], + 'Slider', + [] + ]; + + function hideOptions(name) { + key = name.match(/-(.*)-/)[1]; // gives answer key + type = $(\"*[name='\"+name+\"']\").val(); // e.g. True/False + hiddenTypeOptions = []; // find type options + for(i = 0; i < hiddenOptions.length; i+=2) { + if(hiddenOptions[i] == type) hiddenTypeOptions = hiddenOptions[i+1]; + } + $(\"*[name^='qp-\"+key+\"']\").each(function() { // go down each option + optionName = $(this).attr('name'); // e.g. qp-a-syntaxHint + $(this).show(); // assume shown by default - failsafe! + for(i = 0; i < hiddenTypeOptions.length; i++) { // search for option + if('qp-' + key + '-' + hiddenTypeOptions[i] == optionName) { + $(this).hide(); + } + } + }); + } + + $(document).ready(function() { + // handle changes in input type + $(\"select[name$='inputType']\").change(function() { + hideOptions($(this).attr('name'))}); + // initial option hiding (can prolly be chained to above) + $(\"select[name$='inputType']\").each(function() { + hideOptions($(this).attr('name'))}); + }); + </script>"; + } } |