
/* ======================================================================
The Bodington System Software License, Version 1.0
  
Copyright (c) 2001 The University of Leeds.  All rights reserved.
  
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

1.  Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2.  Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3.  The end-user documentation included with the redistribution, if any,
must include the following acknowledgement:  "This product includes
software developed by the University of Leeds
(http://www.bodington.org/)."  Alternately, this acknowledgement may
appear in the software itself, if and wherever such third-party
acknowledgements normally appear.

4.  The names "Bodington", "Nathan Bodington", "Bodington System",
"Bodington Open Source Project", and "The University of Leeds" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
d.gardner@leeds.ac.uk.

5.  The name "Bodington" may not appear in the name of products derived
from this software without prior written permission of the University of
Leeds.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO,  TITLE,  THE IMPLIED WARRANTIES 
OF QUALITY  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO 
EVENT SHALL THE UNIVERSITY OF LEEDS OR ITS CONTRIBUTORS BE LIABLE FOR 
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
POSSIBILITY OF SUCH DAMAGE.
=========================================================

This software was originally created by the University of Leeds and may contain voluntary 
contributions from others.  For more information on the Bodington Open Source Project, please 
see http://bodington.org/

====================================================================== */

package org.bodington.assessment;

import java.math.BigDecimal;
import java.util.Enumeration;
import java.io.*;

import org.bodington.server.*;
import org.bodington.sqldatabase.*;
import org.bodington.database.*;
import org.bodington.text.BigString;

public class QuestionnaireQuestion extends org.bodington.sqldatabase.SqlPersistentObject
	{
	private static final byte Q_FLAG_CAN_COMMENT	= 1;
	private static final byte Q_FLAG_STANDARD		= 2;
	
	
	private PrimaryKey questionnaire_question_id;
	private PrimaryKey resource_id;
	private PrimaryKey introduction_big_string_id;
	private PrimaryKey statement_a_big_string_id;
	private PrimaryKey statement_b_big_string_id;
	private PrimaryKey statement_c_big_string_id;
	private PrimaryKey statement_d_big_string_id;
	private PrimaryKey statement_e_big_string_id;
	private PrimaryKey statement_f_big_string_id;
	private PrimaryKey statement_g_big_string_id;
	private PrimaryKey statement_h_big_string_id;
	private PrimaryKey statement_i_big_string_id;
	private PrimaryKey statement_j_big_string_id;
	private int ordinal;
	private byte flags;
	private int statements=-1;
	

   	public static QuestionnaireQuestion findQuestionnaireQuestion( PrimaryKey key )
		throws BuildingServerException
		{
		return (QuestionnaireQuestion)findPersistentObject( key, "org.bodington.assessment.QuestionnaireQuestion" );
		}
	public static Enumeration findQuestionnaireQuestions( String where )
	    throws BuildingServerException
	    {
	    return findPersistentObjects( where, "org.bodington.assessment.QuestionnaireQuestion" );
	    }
	public static Enumeration findQuestionnaireQuestions( String where, String order )
	    throws BuildingServerException
	    {
	    return findPersistentObjects( where, order, "org.bodington.assessment.QuestionnaireQuestion" );
	    }


    public PrimaryKey getPrimaryKey()
    	{
        return getQuestionnaireQuestionId();
    	}

    public void setPrimaryKey(PrimaryKey key)
    	{
    	setQuestionnaireQuestionId( key );
    	}

	
	public PrimaryKey getQuestionnaireQuestionId()
		{
		return questionnaire_question_id;
		}
		
	public void setQuestionnaireQuestionId( PrimaryKey id )
		{
		questionnaire_question_id = id;
		}

		
	public PrimaryKey getResourceId()
		{
		return resource_id;
		}
		
	public void setResourceId( PrimaryKey id )
		{
		resource_id = id;
		setUnsaved();
		}


		
		
	public PrimaryKey getIntroductionBigStringId()
		{
		return introduction_big_string_id;
		}

	public void setIntroductionBigStringId( PrimaryKey id )
		{
		introduction_big_string_id = id;
		setUnsaved();
		}
		
	public String getIntroduction()
		throws BuildingServerException
		{
		if ( introduction_big_string_id == null )
			return null;
		BigString bstr = BigString.findBigString( introduction_big_string_id );
		if ( bstr == null )
			return null;
		return bstr.getString();
		}
		
	public void setIntroduction( String s )
		throws BuildingServerException
		{
		BigString bstr=null;
		if ( introduction_big_string_id != null )
			bstr = BigString.findBigString( introduction_big_string_id );
		if ( bstr == null )
			{
			bstr = new BigString();
			bstr.setString( s );
			bstr.save();
			introduction_big_string_id = bstr.getBigStringId();
			setUnsaved();
			return;
			}

		bstr.setString( s );
		bstr.save();
		}
	
		
	public PrimaryKey getStatementABigStringId()
		{
		return statement_a_big_string_id;
		}

	public void setStatementABigStringId( PrimaryKey id )
		{
		statement_a_big_string_id = id;
		setUnsaved();
		}
		
		
		
	public PrimaryKey getStatementBBigStringId()
		{
		return statement_b_big_string_id;
		}

	public void setStatementBBigStringId( PrimaryKey id )
		{
		statement_b_big_string_id = id;
		setUnsaved();
		}
		
		
		
	public PrimaryKey getStatementCBigStringId()
		{
		return statement_c_big_string_id;
		}

	public void setStatementCBigStringId( PrimaryKey id )
		{
		statement_c_big_string_id = id;
		setUnsaved();
		}
		
		
		
	public PrimaryKey getStatementDBigStringId()
		{
		return statement_d_big_string_id;
		}

	public void setStatementDBigStringId( PrimaryKey id )
		{
		statement_d_big_string_id = id;
		setUnsaved();
		}
		
		
		
	public PrimaryKey getStatementEBigStringId()
		{
		return statement_e_big_string_id;
		}

	public void setStatementEBigStringId( PrimaryKey id )
		{
		statement_e_big_string_id = id;
		setUnsaved();
		}
		
		
		
	public PrimaryKey getStatementFBigStringId()
		{
		return statement_f_big_string_id;
		}

	public void setStatementFBigStringId( PrimaryKey id )
		{
		statement_f_big_string_id = id;
		setUnsaved();
		}
		
		
		
	public PrimaryKey getStatementGBigStringId()
		{
		return statement_g_big_string_id;
		}

	public void setStatementGBigStringId( PrimaryKey id )
		{
		statement_g_big_string_id = id;
		setUnsaved();
		}
		
		
		
	public PrimaryKey getStatementHBigStringId()
		{
		return statement_h_big_string_id;
		}

	public void setStatementHBigStringId( PrimaryKey id )
		{
		statement_h_big_string_id = id;
		setUnsaved();
		}
		
		
		
	public PrimaryKey getStatementIBigStringId()
		{
		return statement_i_big_string_id;
		}

	public void setStatementIBigStringId( PrimaryKey id )
		{
		statement_i_big_string_id = id;
		setUnsaved();
		}
		
		
		
	public PrimaryKey getStatementJBigStringId()
		{
		return statement_j_big_string_id;
		}

	public void setStatementJBigStringId( PrimaryKey id )
		{
		statement_j_big_string_id = id;
		setUnsaved();
		}
		
		
	public PrimaryKey getStatementBigStringId( int n )
		throws BuildingServerException
		{
		switch ( n )
			{
			case 0:
				return getStatementABigStringId();
			case 1:
				return getStatementBBigStringId();
			case 2:
				return getStatementCBigStringId();
			case 3:
				return getStatementDBigStringId();
			case 4:
				return getStatementEBigStringId();
			case 5:
				return getStatementFBigStringId();
			case 6:
				return getStatementGBigStringId();
			case 7:
				return getStatementHBigStringId();
			case 8:
				return getStatementIBigStringId();
			case 9:
				return getStatementJBigStringId();
			}
			
		return null;
		}
		
		

		
	public String getStatement( int n )
		throws BuildingServerException
		{
		if ( n<0 || n>9 )
			return null;
			
		if ( isStandardQuestion() )
			{
			switch ( n )
				{
				case 0:
					return "I strongly agree.";
				case 1:
					return "I agree.";
				case 2:
					return "I partly agree and partly disagree.";
				case 3:
					return "I disagree.";
				case 4:
					return "I strongly disagree.";
				}
			return null;
			}
		
		PrimaryKey big_string_id = null;
		switch ( n )
			{
			case 0:
				big_string_id = getStatementABigStringId();
				break;
			case 1:
				big_string_id = getStatementBBigStringId();
				break;
			case 2:
				big_string_id = getStatementCBigStringId();
				break;
			case 3:
				big_string_id = getStatementDBigStringId();
				break;
			case 4:
				big_string_id = getStatementEBigStringId();
				break;
			case 5:
				big_string_id = getStatementFBigStringId();
				break;
			case 6:
				big_string_id = getStatementGBigStringId();
				break;
			case 7:
				big_string_id = getStatementHBigStringId();
				break;
			case 8:
				big_string_id = getStatementIBigStringId();
				break;
			case 9:
				big_string_id = getStatementJBigStringId();
				break;
			}
			
		if ( big_string_id == null )
			return null;
			
		BigString bs = BigString.findBigString( big_string_id );
		
		
		return bs.toString();
		}
		
	public void setStatement( int n, String s )
		throws BuildingServerException
		{
		if ( n<0 || n>9 )
			return;

		PrimaryKey big_string_id = null;
		switch ( n )
			{
			case 0:
				big_string_id = getStatementABigStringId();
				break;
			case 1:
				big_string_id = getStatementBBigStringId();
				break;
			case 2:
				big_string_id = getStatementCBigStringId();
				break;
			case 3:
				big_string_id = getStatementDBigStringId();
				break;
			case 4:
				big_string_id = getStatementEBigStringId();
				break;
			case 5:
				big_string_id = getStatementFBigStringId();
				break;
			case 6:
				big_string_id = getStatementGBigStringId();
				break;
			case 7:
				big_string_id = getStatementHBigStringId();
				break;
			case 8:
				big_string_id = getStatementIBigStringId();
				break;
			case 9:
				big_string_id = getStatementJBigStringId();
				break;
			}
			
		BigString bs;
		
		if ( big_string_id == null )
			{
			bs = new BigString();
			bs.setString( s );
			bs.save();
			big_string_id = bs.getBigStringId();
			switch ( n )
				{
				case 0:
					setStatementABigStringId( big_string_id );
					break;
				case 1:
					setStatementBBigStringId( big_string_id );
					break;
				case 2:
					setStatementCBigStringId( big_string_id );
					break;
				case 3:
					setStatementDBigStringId( big_string_id );
					break;
				case 4:
					setStatementEBigStringId( big_string_id );
					break;
				case 5:
					setStatementFBigStringId( big_string_id );
					break;
				case 6:
					setStatementGBigStringId( big_string_id );
					break;
				case 7:
					setStatementHBigStringId( big_string_id );
					break;
				case 8:
					setStatementIBigStringId( big_string_id );
					break;
				case 9:
					setStatementJBigStringId( big_string_id );
					break;
				}
			setUnsaved();
			return;
			}

		bs = BigString.findBigString( big_string_id );
		
		if ( bs==null )
			return;

		bs.setString( s );
		bs.save();
		}
	

		
	public int getOrdinal()
		{
		return ordinal;
		}
		
	public void setOrdinal( int o )
		{
		if ( o==ordinal )
			return;
		ordinal = o;
		setUnsaved();
		}
		
		
	public byte getFlags()
		{
		return flags;
		}
		
	public void setFlags( byte b )
		{
		if ( b==flags )
			return;
		flags = b;
		setUnsaved();
		}


	public boolean canComment()
		{
		return (flags & Q_FLAG_CAN_COMMENT) != 0;
		}
	public void setCanComment( boolean b )
		{
		if ( canComment() == b )
			return;
		setFlags( (byte)(getFlags() ^ Q_FLAG_CAN_COMMENT) );
		}

	public boolean isStandardQuestion()
		{
		return (flags & Q_FLAG_STANDARD) != 0;
		}
	public void setStandardQuestion( boolean b )
		throws BuildingServerException
		{
		if ( isStandardQuestion() == b )
			return;


		setFlags( (byte)(getFlags() ^ Q_FLAG_STANDARD) );

		
		if ( isStandardQuestion() )
			for ( int i=0; i<10; i++ )
				setStatement( i, "" );
		}


	public int getStatementCount()
		throws BuildingServerException
		{
		String s;
		
		if ( !isUnsaved() && statements>=0 )
			return statements;
			
		if ( isStandardQuestion() )
			{
			statements = 5;
			return 5;
			}
		
		statements=0;
		for ( int i=0; i<10; i++ )
			{
			s = getStatement( i );
			if ( s!=null && s.trim().length()>0 )
				statements = (i+1);
			}
			
		return statements;
		}

	public void setUnsaved()
		{
		statements=-1;
		super.setUnsaved();
		}
		
		
		
	public void exportXml( PrintWriter xml_out )
	    throws IOException, BuildingServerException
	    {
	    exportXml( xml_out, true );
	    }
	    
	public void exportXml( PrintWriter xml_out, boolean allow_composite )
	    throws IOException, BuildingServerException
	    {
	    if ( canComment() )
	        {
	        if ( getStatementCount() > 0 )
	            {
	            if ( allow_composite )
	                exportXmlComposite( xml_out, "pk_" + getPrimaryKey() + "_composite"  );
	            else
	                {
	                exportXmlChoice( xml_out, "pk_" + getPrimaryKey() + "_choice", true  );
	                exportXmlComment( xml_out, "pk_" + getPrimaryKey() + "_comment", true  );
	                }
	            }
	        else
	            {
                exportXmlComment( xml_out, "pk_" + getPrimaryKey() + "_comment", false );
                }
	        }
	    else
	        {
	        if ( getStatementCount() > 0 )
                exportXmlChoice( xml_out, "pk_" + getPrimaryKey() + "_choice", false );
            else
                exportXmlExplanation( xml_out, "pk_" + getPrimaryKey() + "_explanation"  );
	        }
	    }

	    
	    
	private void exportXmlExplanation( PrintWriter xmlout, String ident )
	    throws IOException, BuildingServerException
	    {
        xmlout.print( "\t<item ident=\"" );
        xmlout.print( ident );
        xmlout.print( "\">" );
        xmlout.println();

        xmlout.println( "\t\t<itemmetadata>" );
        xmlout.println( "\t\t\t<qmd_computerscored>No</qmd_computerscored>" );
        xmlout.println( "\t\t\t<qmd_feedbackpermitted>No</qmd_feedbackpermitted>" );
        xmlout.println( "\t\t\t<qmd_hintspermitted>No</qmd_hintspermitted>" );
        xmlout.println( "\t\t\t<qmd_itemtype>Explanation</qmd_itemtype>" );
        xmlout.println( "\t\t\t<qmd_maximumscore>0</qmd_maximumscore>" );
        xmlout.println( "\t\t\t<qmd_renderingtype>None</qmd_renderingtype>" );
        xmlout.println( "\t\t\t<qmd_responsetype>None</qmd_responsetype>" );
        xmlout.println( "\t\t\t<qmd_scoringpermitted>No</qmd_scoringpermitted>" );
        xmlout.println( "\t\t\t<qmd_toolvendor>Bodington System</qmd_toolvendor>" );
        xmlout.println( "\t\t</itemmetadata>" );

        xmlout.println( "\t\t<presentation>" );
            xmlout.println( "\t\t\t<material>" );
                xmlout.print( "\t\t\t\t<mattext texttype=\"text/html\"><![CDATA[" );
                xmlout.print( getIntroduction() );
                xmlout.print( "]]></mattext>" );
                xmlout.println();
            xmlout.println( "\t\t\t</material>" );

            xmlout.println( "<response_extension/>" );
        xmlout.println( "\t\t</presentation>" );
        xmlout.print( "\t</item>" );
        xmlout.println();
        }
	    
	private void exportXmlComment( PrintWriter xmlout, String ident, boolean broken_composite )
	    throws IOException, BuildingServerException
	    {
        xmlout.print( "\t<item ident=\"" );
        xmlout.print( ident );
        xmlout.print( "\">" );
        xmlout.println();

        xmlout.println( "\t\t<itemmetadata>" );
        xmlout.println( "\t\t\t<qmd_computerscored>No</qmd_computerscored>" );
        xmlout.println( "\t\t\t<qmd_feedbackpermitted>No</qmd_feedbackpermitted>" );
        xmlout.println( "\t\t\t<qmd_hintspermitted>No</qmd_hintspermitted>" );
        xmlout.println( "\t\t\t<qmd_itemtype>String</qmd_itemtype>" );
        xmlout.println( "\t\t\t<qmd_maximumscore>0</qmd_maximumscore>" );
        xmlout.println( "\t\t\t<qmd_renderingtype>String</qmd_renderingtype>" );
        xmlout.println( "\t\t\t<qmd_responsetype>Single</qmd_responsetype>" );
        xmlout.println( "\t\t\t<qmd_scoringpermitted>No</qmd_scoringpermitted>" );
        xmlout.println( "\t\t\t<qmd_toolvendor>Bodington System</qmd_toolvendor>" );
        xmlout.println( "\t\t</itemmetadata>" );

        xmlout.println( "\t\t<presentation>" );
            xmlout.println( "\t\t\t<material>" );
                xmlout.print( "\t\t\t\t<mattext texttype=\"text/html\"><![CDATA[" );
                if ( broken_composite )
                    {
                    xmlout.println();
                    xmlout.println( "<P>This is the comment box for the previous question.</P>" );
                    }
                else
                    xmlout.print( getIntroduction() );
                xmlout.print( "]]></mattext>" );
                xmlout.println();
            xmlout.println( "\t\t\t</material>" );

            xmlout.println( "<response_str ident=\"1\" rcardinality=\"Single\">" );
            xmlout.println( "<render_fib fibtype=\"String\" prompt=\"Box\" rows=\"5\" columns=\"30\" />" );
            xmlout.println( "</response_str>" );

        xmlout.println( "\t\t</presentation>" );
        xmlout.print( "\t</item>" );
        xmlout.println();
        }
	    

	private void exportXmlChoice( PrintWriter xmlout, String ident, boolean broken_composite )
	    throws IOException, BuildingServerException
	    {
	    int i, j, n;

        xmlout.print( "\t<item ident=\"" );
        xmlout.print( ident );
        xmlout.print( "\">" );
        xmlout.println();

        xmlout.println( "\t\t<itemmetadata>" );
        xmlout.println( "\t\t\t<qmd_computerscored>No</qmd_computerscored>" );
        xmlout.println( "\t\t\t<qmd_feedbackpermitted>No</qmd_feedbackpermitted>" );
        xmlout.println( "\t\t\t<qmd_hintspermitted>No</qmd_hintspermitted>" );
        xmlout.println( "\t\t\t<qmd_itemtype>Logical Identifier</qmd_itemtype>" );
        xmlout.println( "\t\t\t<qmd_maximumscore>0</qmd_maximumscore>" );
        xmlout.println( "\t\t\t<qmd_renderingtype>Choice</qmd_renderingtype>" );
        xmlout.println( "\t\t\t<qmd_responsetype>Single</qmd_responsetype>" );
        xmlout.println( "\t\t\t<qmd_scoringpermitted>No</qmd_scoringpermitted>" );
        xmlout.println( "\t\t\t<qmd_toolvendor>Bodington System</qmd_toolvendor>" );
        xmlout.println( "\t\t</itemmetadata>" );
                
        xmlout.println( "\t\t<presentation>" );
            xmlout.println( "\t\t\t<material>" );
                xmlout.print( "\t\t\t\t<mattext texttype=\"text/html\"><![CDATA[" );
                xmlout.print( getIntroduction() );
                //if ( broken_composite )
                //    {
                //    xmlout.println();
                //    xmlout.println( "<P>(The next question contains the comment box for this question.)</P>" );
                //    }
                xmlout.print( "]]></mattext>" );
                xmlout.println();
            xmlout.println( "\t\t\t</material>" );
            xmlout.println( "\t\t\t<response_lid ident=\"1\" rcardinality=\"Single\">" );

                xmlout.println( "\t\t\t\t<render_choice shuffle=\"No\">" );
                        
        n=getStatementCount();
        for ( j=0; j<n; j++ )
            {
            xmlout.print( "\t\t\t\t\t<response_label ident=\"" );
            xmlout.print( (char)('A'+j) );
            xmlout.print( "\">" );
            xmlout.println();
                        
            xmlout.println( "\t\t\t\t\t\t<material>" );

                xmlout.print( "\t\t\t\t\t\t\t<mattext texttype=\"text/html\"><![CDATA[" );
                xmlout.print( getStatement( j ) );
                xmlout.print( "]]></mattext>" );
                xmlout.println();

            xmlout.println( "\t\t\t\t\t\t</material>" );
            xmlout.println( "\t\t\t\t\t</response_label>" );
            }

                xmlout.println( "\t\t\t\t</render_choice>" );
            xmlout.println( "\t\t\t</response_lid>" );
        xmlout.println( "\t\t</presentation>" );
        xmlout.print( "\t</item>" );
        xmlout.println();
        }
	    	    
	private void exportXmlComposite( PrintWriter xmlout, String ident )
	    throws IOException, BuildingServerException
	    {
	    int i, j, n;
	        
        xmlout.print( "\t<item ident=\"" );
        xmlout.print( ident );
        xmlout.print( "\">" );
        xmlout.println();

        xmlout.println( "\t\t<itemmetadata>" );
        xmlout.println( "\t\t\t<qmd_computerscored>No</qmd_computerscored>" );
        xmlout.println( "\t\t\t<qmd_feedbackpermitted>No</qmd_feedbackpermitted>" );
        xmlout.println( "\t\t\t<qmd_hintspermitted>No</qmd_hintspermitted>" );
        xmlout.println( "\t\t\t<qmd_itemtype>Composite</qmd_itemtype>" );
        xmlout.println( "\t\t\t<qmd_maximumscore>0</qmd_maximumscore>" );
        //xmlout.println( "\t\t\t<qmd_renderingtype>Choice</qmd_renderingtype>" );
        xmlout.println( "\t\t\t<qmd_responsetype>Multiple</qmd_responsetype>" );
        xmlout.println( "\t\t\t<qmd_scoringpermitted>No</qmd_scoringpermitted>" );
        xmlout.println( "\t\t\t<qmd_toolvendor>Bodington System</qmd_toolvendor>" );
        xmlout.println( "\t\t</itemmetadata>" );
                
        xmlout.println( "\t\t<presentation>" );
            xmlout.println( "\t\t\t<material>" );
                xmlout.print( "\t\t\t\t<mattext texttype=\"text/html\"><![CDATA[" );
                xmlout.print( getIntroduction() );
                xmlout.print( "]]></mattext>" );
                xmlout.println();
            xmlout.println( "\t\t\t</material>" );
            xmlout.println( "\t\t\t<response_lid ident=\"1\" rcardinality=\"Single\">" );

                xmlout.println( "\t\t\t\t<render_choice shuffle=\"No\">" );
                        
        n=getStatementCount();
        for ( j=0; j<n; j++ )
            {
            xmlout.print( "\t\t\t\t\t<response_label ident=\"" );
            xmlout.print( (char)('A'+j) );
            xmlout.print( "\">" );
            xmlout.println();
                        
            xmlout.println( "\t\t\t\t\t\t<material>" );

                xmlout.print( "\t\t\t\t\t\t\t<mattext texttype=\"text/html\"><![CDATA[" );
                xmlout.print( getStatement( j ) );
                xmlout.print( "]]></mattext>" );
                xmlout.println();

            xmlout.println( "\t\t\t\t\t\t</material>" );
            xmlout.println( "\t\t\t\t\t</response_label>" );
            }

                xmlout.println( "\t\t\t\t</render_choice>" );
            xmlout.println( "\t\t\t</response_lid>" );

            xmlout.println( "<response_str ident=\"2\" rcardinality=\"Single\">" );
            xmlout.println( "<render_fib fibtype=\"String\" prompt=\"Box\" rows=\"5\" columns=\"30\" />" );
            xmlout.println( "</response_str>" );

        xmlout.println( "\t\t</presentation>" );
        xmlout.print( "\t</item>" );
        xmlout.println();
        }
    }
