From: pkiddie <pk...@us...> - 2005-09-12 09:24:33
|
Update of /cvsroot/stack/stack-1-0/scripts/rqp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11501/scripts/rqp Modified Files: RQPv1p0Server.php stackRQP.php Log Message: Slight alterations to functioning of RQP server. Index: RQPv1p0Server.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/rqp/RQPv1p0Server.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** RQPv1p0Server.php 9 Sep 2005 10:59:21 -0000 1.9 --- RQPv1p0Server.php 12 Sep 2005 09:24:24 -0000 1.10 *************** *** 117,121 **** 'timeDependent' => FALSE , 'canComputerScore' => TRUE , ! 'maxScore' => 0, 'valid' => FALSE ); --- 117,121 ---- 'timeDependent' => FALSE , 'canComputerScore' => TRUE , ! 'maxScore' => 1, //assumed default of 1 'valid' => FALSE ); *************** *** 135,139 **** $itemProperties['maxScore']=$quOptions['QuVal']; //This isnt being returned?? is it in latest spec?? ! $itemInfo['title'] = $question['questionName']; } --- 135,139 ---- $itemProperties['maxScore']=$quOptions['QuVal']; //This isnt being returned?? is it in latest spec?? ! $itemInfo['name'] = $question['questionName']; } *************** *** 204,215 **** if (empty($source)) { ! //Is this a new NEW question, or are we in an existing authoring session if (empty($inputData)) { // if empty input array - we are starting afresh ! $question = stack_question_new('Paul Kiddie'); //Create question with mim fields. Todo, how do we get admin name from Moodle } else { $question = stack_rqp_question_get($inputData); // parse input fields stack_question_validate($question,$errors); // validate question and add potential reponse fields //Where there are no errors in the users input and the user has requested to save the question --- 204,221 ---- if (empty($source)) { ! //First time through authoring session if (empty($inputData)) { // if empty input array - we are starting afresh ! $question = stack_question_new('Remote User'); //Create question with mim fields. Todo, how do we get admin name from Moodle ! ! $output['body'] = stack_question_edit_form_substance($question,$errors,$namePrefix, $remoteCaller = TRUE); } + //Successive edits in new authoring session else { $question = stack_rqp_question_get($inputData); // parse input fields stack_question_validate($question,$errors); // validate question and add potential reponse fields + + $output['title'] = $question['questionName']; + $output['body'] = stack_question_edit_form_substance($question,$errors,$namePrefix, $remoteCaller = TRUE); //Where there are no errors in the users input and the user has requested to save the question *************** *** 218,221 **** --- 224,230 ---- $outcomeVars['completion'] = 'complete'; $outcomeVars['source'] = stack_rqp_source_write($question); + + //Disable all input fields + $output['body'] = stack_rqp_input_fields_disable($output['body']); } *************** *** 225,231 **** } } - - $output['title'] = $question['questionName']; - $output['body'] = stack_question_edit_form_substance($question,$errors,$namePrefix, $remoteCaller = TRUE); } --- 234,237 ---- *************** *** 237,248 **** switch($source) { case('adminOptions'): { $options_headings = array(get_string('stackOptions_edit_out','stack'),''); $options_list = array('Display','Language'); ! ! $fieldname = 'quiz'.'[quizOptions]'; $output = array('title' => '', //initially question will have no title //remoteCaller = true ! 'body' => stack_options_edit_form($options_headings,$options_list,$optval,$fieldname,$namePrefix, TRUE), 'stem' => '', 'feedback' => '', --- 243,263 ---- switch($source) { case('adminOptions'): { + if (!$options = stack_rqp_keyval_field_get($inputData,'questionOptions')) { // options set in input fields + $question_options = array(); + } + + else { + $question_options = unserialize(html_entity_decode($options)); + } + + $optval = stack_options_formvals_set($question_options); + $options_headings = array(get_string('stackOptions_edit_out','stack'),''); $options_list = array('Display','Language'); ! $output = array('title' => '', //initially question will have no title //remoteCaller = true ! 'body' => stack_options_edit_form($options_headings,$options_list,$optval,'questionOptions',$namePrefix, TRUE), 'stem' => '', 'feedback' => '', *************** *** 250,253 **** --- 265,271 ---- 'answer' => '', 'solution' => ''); + + $outcomeVars['completion'] = 'complete'; + $outcomeVars['options'] = stack_rqp_keyval_field_get($inputData,'questionOptions'); //Return options as serialised string contained by [questionOptions] break; } *************** *** 256,265 **** $options_headings = array(get_string('stackOptions_edit_out','stack'),''); $options_list = array('Display','Language'); - - $fieldname = 'quiz'.'[quizOptions]'; $output = array('title' => '', //initially question will have no title //remoteCaller = true ! 'body' => stack_options_edit_form($options_headings,$options_list,$optval,$fieldname,$namePrefix, TRUE), 'stem' => '', 'feedback' => '', --- 274,281 ---- $options_headings = array(get_string('stackOptions_edit_out','stack'),''); $options_list = array('Display','Language'); $output = array('title' => '', //initially question will have no title //remoteCaller = true ! 'body' => stack_options_edit_form($options_headings,$options_list,$optval,'questionOptions',$namePrefix, TRUE), 'stem' => '', 'feedback' => '', *************** *** 273,282 **** $options_headings = array(get_string('stackOptions_edit_out','stack'),''); $options_list = array('Display','Language'); - - $fieldname = 'quiz'.'[quizOptions]'; $output = array('title' => '', //initially question will have no title //remoteCaller = true ! 'body' => stack_options_edit_form($options_headings,$options_list,$optval,$fieldname,$namePrefix, TRUE), 'stem' => '', 'feedback' => '', --- 289,296 ---- $options_headings = array(get_string('stackOptions_edit_out','stack'),''); $options_list = array('Display','Language'); $output = array('title' => '', //initially question will have no title //remoteCaller = true ! 'body' => stack_options_edit_form($options_headings,$options_list,$optval,'questionOptions',$namePrefix, TRUE), 'stem' => '', 'feedback' => '', *************** *** 290,294 **** //This could only be STACK question source XML default: { ! if (empty($inputData)) { //On initial entry of editing an existing qu. $question = stack_rqp_parse_xml_string($source, &$errors); // Retrieve the question from source --- 304,309 ---- //This could only be STACK question source XML default: { ! //On initial entry of editing an existing qu. ! if (empty($inputData)) { $question = stack_rqp_parse_xml_string($source, &$errors); // Retrieve the question from source *************** *** 309,312 **** --- 324,330 ---- $outcomeVars['completion'] = 'complete'; $outcomeVars['source'] = stack_rqp_source_write($question); + + //Disable all input fields + $output['body'] = stack_rqp_input_fields_disable($output['body']); } *************** *** 474,541 **** $stem .= trim($questionInst['questionStemInst']); ! //9.2 Construct last answer ! $answer = ''; if ('' !==trim($last_attempt['RawAns'])) { //if there is an attempt made ! $answer .= 'Your last submitted answer was: <code>'; ! $answer .= htmlspecialchars(trim($last_attempt['RawAns'])); ! $answer .= '<code><br />'; ! $answer .= 'This was interpreted as:'; ! $answer .= trim($last_attempt['AnsDisp']); } ! //9.3 Construct 'validation'. is this response? ! $response = ''; ! if (array_key_exists('Valid',$this_attempt) && 'true' === $this_attempt['Valid']) { ! $response .= '<code>'; ! $response .= htmlspecialchars(trim($this_attempt['RawAns'])); ! $response .= '</code> was interpreted as:<br />'; ! $response .= trim($this_attempt['AnsDisp']); } - else { - $validation = trim($this_attempt['Feedback']); - } ! //9.4 Construct interactions - ??? $AnsFieldName; $body =''; - $feedback=''; $body .= stack_question_inst_try_formfrag($RawAns, $AnsFieldName); ! //9.5 Construct feedback if (array_key_exists('Valid',$this_attempt) && 'true' === $this_attempt['Valid']) { $feedback = trim($this_attempt['FeedBack']); } ! ! $correct = ''; if (array_key_exists('questionSolInst',$questionInst)) { if (array_key_exists('display', $questionInst['questionSolInst'])) { ! $correct= trim($questionInst['questionSolInst']['display']); } } ! //What if there is no worked solution - display correct response ! if ('' === $correct) { if (array_key_exists('questionAnsInst',$questionInst)) { if (array_key_exists('display', $questionInst['questionAnsInst'])) { ! $correct .= 'A correct answer is:<br />'; ! $correct .= trim($questionInst['questionAnsInst']['display']); } if (array_key_exists('value', $questionInst['questionAnsInst'])) { if (array_key_exists('display', $questionInst['questionAnsInst'])) { ! $correct .= '<br />which can be entered as:'; } else { ! $correct .= 'A correct answer can be entered as:'; } ! $correct .= trim($questionInst['questionAnsInst']['value']); } } } - $solution =''; - $solution .= $correct; //10. Construct Render params --- 492,567 ---- $stem .= trim($questionInst['questionStemInst']); ! //9.2 Construct last response made by student ! $response = ''; if ('' !==trim($last_attempt['RawAns'])) { //if there is an attempt made ! $response .= 'Your last submitted answer was: <code>'; ! $response .= htmlspecialchars(trim($last_attempt['RawAns'])); ! $response .= '</code><br />'; ! $response .= 'This was interpreted as:'; ! $response .= trim($last_attempt['AnsDisp']); } ! //9.3 Construct answer where required ! $answer = ''; ! if (array_key_exists('questionAnsInst',$questionInst)) { ! if (array_key_exists('display', $questionInst['questionAnsInst'])) { ! $answer .= 'A correct answer is:<br />'; ! $answer .= trim($questionInst['questionAnsInst']['display']); ! } ! ! if (array_key_exists('value', $questionInst['questionAnsInst'])) { ! if (array_key_exists('display', $questionInst['questionAnsInst'])) { ! $answer .= '<br />which can be entered as:'; ! } ! ! else { ! $answer .= 'A correct answer can be entered as:'; ! } ! ! $answer .= trim($questionInst['questionAnsInst']['value']); ! } } ! //9.4 Construct student attempt interactions $body =''; $body .= stack_question_inst_try_formfrag($RawAns, $AnsFieldName); ! //9.5 Construct feedback, e.g. at potential response level ! $feedback=''; if (array_key_exists('Valid',$this_attempt) && 'true' === $this_attempt['Valid']) { $feedback = trim($this_attempt['FeedBack']); } ! ! //9.6 Construct solution to question ! $solution = ''; if (array_key_exists('questionSolInst',$questionInst)) { if (array_key_exists('display', $questionInst['questionSolInst'])) { ! $solution= trim($questionInst['questionSolInst']['display']); } } ! //What if there is no worked solution available, just display correct response ! if ('' === $solution) { if (array_key_exists('questionAnsInst',$questionInst)) { if (array_key_exists('display', $questionInst['questionAnsInst'])) { ! $solution .= 'A correct answer is:<br />'; ! $solution .= trim($questionInst['questionAnsInst']['display']); } if (array_key_exists('value', $questionInst['questionAnsInst'])) { if (array_key_exists('display', $questionInst['questionAnsInst'])) { ! $solution .= '<br />which can be entered as:'; } else { ! $solution .= 'A correct answer can be entered as:'; } ! $solution .= trim($questionInst['questionAnsInst']['value']); } } } //10. Construct Render params *************** *** 568,572 **** //Construct RenderType ! $render = array('persistentData' => serialize($persistence), 'outcomeVars' => $outcomeVars, 'onSubmit' => $onSubmit, --- 594,598 ---- //Construct RenderType ! $render = array('persistentData' => serialize($persistence), //else '', 'outcomeVars' => $outcomeVars, 'onSubmit' => $onSubmit, Index: stackRQP.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/rqp/stackRQP.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** stackRQP.php 8 Sep 2005 22:07:25 -0000 1.4 --- stackRQP.php 12 Sep 2005 09:24:24 -0000 1.5 *************** *** 149,152 **** --- 149,175 ---- return false; } + + function stack_rqp_serialize_options() + { + } + + /** + * + * This takes the HTML output from the creation of the authoring form fragment, and simply disables + * each input field + * + */ + function stack_rqp_input_fields_disable($formFields) + { + $disabledForm = ''; + + $disabledForm = str_replace('<input', '<input disabled', $formFields); + $disabledForm = str_replace('<button', '<button disabled', $disabledForm); + $disabledForm = str_replace('<textarea', '<textarea disabled', $disabledForm); + $disabledForm = str_replace('<option', '<option disabled', $disabledForm); + $disabledForm = str_replace('<select', '<select disabled', $disabledForm); + + return $disabledForm; + } /** |