File:  [LON-CAPA] / doc / homework / newtag.html
Revision 1.1: download - view: text, annotated - select for diffs
Thu Jun 6 08:43:24 2002 UTC (19 years, 11 months ago) by albertel
Branches: MAIN
CVS tags: version_2_9_X, version_2_9_99_0, version_2_9_1, version_2_9_0, version_2_8_X, version_2_8_99_1, version_2_8_99_0, version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_X, version_2_7_99_1, version_2_7_99_0, version_2_7_1, version_2_7_0, version_2_6_X, version_2_6_99_1, version_2_6_99_0, version_2_6_3, version_2_6_2, version_2_6_1, version_2_6_0, version_2_5_X, version_2_5_99_1, version_2_5_99_0, version_2_5_2, version_2_5_1, version_2_5_0, version_2_4_X, version_2_4_99_0, version_2_4_2, version_2_4_1, version_2_4_0, version_2_3_X, version_2_3_99_0, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_X, version_2_2_99_1, version_2_2_99_0, version_2_2_2, version_2_2_1, version_2_2_0, version_2_1_X, version_2_1_99_3, version_2_1_99_2, version_2_1_99_1, version_2_1_99_0, version_2_1_3, version_2_1_2, version_2_1_1, version_2_1_0, version_2_12_X, version_2_11_X, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, version_2_10_X, version_2_10_1, version_2_10_0_RC2, version_2_10_0_RC1, version_2_10_0, version_2_0_X, version_2_0_99_1, version_2_0_2, version_2_0_1, version_2_0_0, version_1_99_3, version_1_99_2, version_1_99_1_tmcc, version_1_99_1, version_1_99_0_tmcc, version_1_99_0, version_1_3_X, version_1_3_3, version_1_3_2, version_1_3_1, version_1_3_0, version_1_2_X, version_1_2_99_1, version_1_2_99_0, version_1_2_1, version_1_2_0, version_1_1_X, version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, version_1_1_99_0, version_1_1_3, version_1_1_2, version_1_1_1, version_1_1_0, version_1_0_99_3, version_1_0_99_2, version_1_0_99_1, version_1_0_99, version_1_0_3, version_1_0_2, version_1_0_1, version_1_0_0, version_0_99_5, version_0_99_4, version_0_99_3, version_0_99_2, version_0_99_1, version_0_99_0, version_0_6_2, version_0_6, version_0_5_1, version_0_5, version_0_4, stable_2002_july, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, conference_2003, bz6209-base, bz6209, STABLE, HEAD, GCI_3, GCI_2, GCI_1, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse, BZ4492-Support_horizontal_radioresponse
- most of a document outlining what needs to be done to add a basic tag

-still missing
       - useful helper function descriptions
       - edit mode
            - insertlist.tab
       - analyze mode

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>Making a New Tag Handler</title>
  </head>

  <body>
    <h1>Making a New Tag Handler</h1>

    <h2>Required Actions</h2>
    <ul>
      <li>
	you will need to call <i>&amp;Apache::lonxml::register()</i>
	to register the tag name and the namespace it is in, most of
	the time this is in the BEGIN block of the handler
      </li>
      <li>
	you will need to create both <i>&amp;start_newtag()</i> and
	<i>&amp;end_newtag()</i> functions.
      </li>
      <li>
	these function will need to do one of: 
	<ol>
	  <li>
	    return a non-null string
	  </li>
	  <li>
	    return a null string (and expect that for some targets a
	    default output may be generated for it)
	  </li>
	  <li>
	    return a list containing a null string for the first
	    element and the string 'no' for the second element., this
	    will make sure that the result is a null string and any
	    default action normally taken will be skipped
	  </li>
	</ol>
      <li>
	These functions will have six arguments passed to them
	<ol>
	  <li>
	    <i>$target</i> a scalar cotaing the string of the target
	    that is being parsed for. The current possibilities
	    include web, tex, grade, answer, modified, edit, meta,
	    analyze. Although more may be added in the future, you
	    must guarentee that you return a blank string for any
	    target you don't specifically handle.
	  </li>
	  <li>
	    <i>$token</i> a HTML::LCParser token object,You probably
	    want to avoid using the parameter information inside of
	    this, you most likely want to use <i>$paramstack</i> and
	    <i>&amp;Apache::lonxml::get_param()</i>
	  </li>
	  <li>
	    <i>$tagstack</i> a stack pointer of the names of the tags
	    that are currently open, don't modify
	  </li>
	  <li>
	    <i>$paramstack</i> a stack pointer of the parameters
	    passed to the currently open tags, don't modify, and you
	    probably should use this only as a parameter to
	    <i>&amp;Apache::lonxml::get_param</i>
	  </li>
	  <li>
	    <i>$parser</i> a stack pointer of the current stack of
	    HTML::LCParser objects. You probably only want to use the
	    top one. Also your functions may manipulate this object
	    and grab more tokens from it but be carefule about
	    unbalancing it, also avoid calling the ->get_text()
	    routine unless you really not what you are doing
	    (<i>&amp;Apache::lonxml::get_all_text()</i> is probably
	    what you want to use.
	  </li>
	  <li>
	    <i>$safeeval</i> a pointer to the safe space interpreter,
	    You probably don't what to do anything with this directly,
	    <i>&amp;Apache::run::run</i> and other functions need this
	    argument and will use it correctly.
	  </li>
	  <li>
	    <i>$style</i> a Hash reference, it contains mappings
	    between tags and style file definitions. Few functions
	    will need to use this.
	  </li>
	</ol>
      </li>
      <li>
	if it is a new response tag it needs to
	<ul>
	  <li>
	    call <i>&amp;Apache::response::start_response()</i> in the
	    start_newtag function and
	    <i>&amp;Apache::response::end_response()</i> at the end of
	    the end_newtag function
	  </li>
	  <li>
	    set the required data for a responseid from the
	    datastorage document
	  </li>
	  <li>
	    use the functions
	    <i>&amp;Apache::response::check_for_previous()</i> and
	    <i>&amp;Apache::response::handle_previous()</i> to check
	    if a student's reponse has been submitted before.
	  </li>
	  <li>
	    call <i>&amp;Apache::response::setup_params()</i> if it is
	    expecting external parameters to be set for it.
	  </li>
	</ul>
      </li>
    </ul>
    <h2>Things to not do</h2>
    <ul>
      <li>
	there is no direct access to the Apache Request object. It is
	<b>very</b> unlikely that you need it, any data you want is
	either in %ENV, a global variable listed below or in the xml
	documentation, or should be gotten through an Apache::lonnet
	function
      </li>
      <li>
	print, either return it in the result, or use the
	debug/warning/error facility of Apache::lonxml
      </li>
      <li>
	use the <i>get_text()</i> procedure of the $parser
	HTML::LCParser object
      </li>
      <li>
	access the paramater attributes of the $token HTML::LCParser
	object
      </li>
    </ul>
    <h2>Interesting Globals</h2>
    <ul>
      <li> lonhomework globals 
	<ul>
	  <li>
	    <i>%Apache::lonhomework::history</i> the data from a restore
	    call for the current symb
	  </li>
	  <li>
	    <i>%Apache::lonhomework::results</i> the hash that will be
	    cstored at the end of the current execution
	  </li>
	  <li>
	    <i>$Apache::lonhomework::browse</i> the result of an allowed
	    request for the bre priviledge on the current file
	  </li>
	  <li>
	    <i>$Apache::lonhomework::viewgrades</i> the result of an
	    allowed request on the vgr priviledge for the current course
	  </li>
	  <li>
	    <i>$Apache::lonhomework::type</i> the current type of the
	    resource, either '', exam, homework, quiz, form, or survey
	  </li>
	  <li>
	    <i>%Apache::lonhomework::analyze</i> in analyze mode all data
	    to be returned is sotred in here.
	  </li>
	</ul>
      </li>
      <li>
	inputtag globals
	<ul>
	  <li>
	    <i>@Apache::inputtags::input</i> list of current input ids
	  </li>
	  <li>
	    <i>@Apache::inputtags::inputlist</i> list of all input ids
	    seen in this problem
	  </li>
	  <li>
	    <i>@Apache::inputtags::response</i> list of all current
	    response ids
	  </li>
	  <li>
	    <i>@Apache::inputtags::responselist</i> list of all
	    response ids seen in this problem
	  </li>
	  <li>
	    <i>@Apache::inputtags::previous</i> list of whether or not
	    a specific response was previously used
	  </li>
	  <li>
	    <i>$Apache::inputtags::part</i> id of current part, 0
	    means that no part is current (inside &lt;problem&gt;
	    only)
	  </li>
	  <li>
	    <i>@Apache::inputtags::status</i> list of problem date
	    statuses, the first element is for &lt;problem&gt; if
	    there is a second element it is for the current
	    &lt;part&gt; possible values are CLOSED, CAN_ANSWER,
	    SHOW_ANSWER, UNCHECKEDOUT
	  </li>
	  <li>
	    <i>%Apache::inputtags::params</i> hash of defined params
	    for the current response
	  </li>
	  <li>
	    <i>@Apache::inputtags::import</i> list of all ids, from
	    &lt;import&gt;s, these get join()ed and prepended to the
	    ids in the @Apache::inputtags::response and
	    @Apache::inputtags::responselist variables
	  </li>
	</ul>
      </li>
    </ul>
    <h2>Interesting Function</h2>
    
      
    <hr>
    <address><a href="mailto:albertel@msu.edu"></a></address>
<!-- Created: Thu Jun  6 03:47:04 EDT 2002 -->
<!-- hhmts start -->
Last modified: Thu Jun  6 04:46:00 EDT 2002
<!-- hhmts end -->
  </body>
</html>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>