Skip to content

Commit

Permalink
add an update category submit button to update the display of shareab…
Browse files Browse the repository at this point in the history
…le wild cards
  • Loading branch information
pichetp committed Apr 19, 2007
1 parent 85fbf88 commit 0dd3e11
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
28 changes: 25 additions & 3 deletions question/type/calculated/edit_calculated_form.php
Expand Up @@ -64,8 +64,14 @@ function definition_inner(&$mform) {
$this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', 1, get_string('addmoreanswerblanks', 'qtype_calculated'));*/
//------------------------------------------------------------------------------------------
$label = get_string("sharedwildcards", "qtype_datasetdependent");
$mform->addElement('hidden', 'initialcategory', 1);
$html2 = $this->qtypeobj->print_dataset_definitions_category($this->question);
$mform->insertElementBefore($mform->createElement('static','list',$label,$html2),'questiontext');
$mform->insertElementBefore($mform->createElement('static','listcategory',$label,$html2),'name');
$addfieldsname='updatecategory';
$addstring='Update the category';
$mform->registerNoSubmitButton($addfieldsname);

$mform->insertElementBefore( $mform->createElement('submit', $addfieldsname, $addstring),'listcategory');

$mform->addElement('header', 'answerhdr', get_string('answerhdr', 'qtype_calculated'));

Expand Down Expand Up @@ -158,8 +164,24 @@ function set_data($question) {
}
$default_values['submitbutton'] = get_string('nextpage', 'qtype_calculated');
$default_values['makecopy'] = get_string('makecopynextpage', 'qtype_calculated');
$question = (object)((array)$question + $default_values);

/* set the wild cards category display given that on loading the category element is
unselected when processing this function but have a valid value when processing the
update category button. The value can be obtain by
$qu->category =$this->_form->_elements[$this->_form->_elementIndex['category']]->_values[0];
but is coded using existing functions
*/
$qu = new stdClass;
$el = new stdClass;
/* no need to call elementExists() here */
$el=$this->_form->getElement('category');
if($value =$el->getSelected()) {
$qu->category =$value[0];
}else {
$qu->category=$question->category;// on load $question->category is set by question.php
}
$html2 = $this->qtypeobj->print_dataset_definitions_category($qu);
$this->_form->_elements[$this->_form->_elementIndex['listcategory']]->_text = $html2 ;
$question = (object)((array)$question + $default_values);

parent::set_data($question);
}
Expand Down
2 changes: 1 addition & 1 deletion question/type/calculated/questiontype.php
Expand Up @@ -917,7 +917,7 @@ function print_dataset_definitions_category($form) {
}
$text .="</table>";
}else{
$text .=get_string('no shareable wild card', 'qtype_calculated'); //"<b>NO SHAREABLE DATASETS IN THIS CATEGORY</b>";
$text .=get_string('nosharedwildcard', 'qtype_calculated');
}
return $text ;
}
Expand Down

0 comments on commit 0dd3e11

Please sign in to comment.