--- loncom/xml/lonxml.pm 2007/10/08 09:20:22 1.462 +++ loncom/xml/lonxml.pm 2007/10/22 09:27:50 1.466 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.462 2007/10/08 09:20:22 foxr Exp $ +# $Id: lonxml.pm,v 1.466 2007/10/22 09:27:50 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -631,6 +631,24 @@ sub callsub { return $currentstring; } +{ + my %state; + + sub init_state { + undef(%state); + } + + sub set_state { + my ($key,$value) = @_; + $state{$key} = $value; + return $value; + } + sub get_state { + my ($key) = @_; + return $state{$key}; + } +} + sub setup_globals { my ($request,$target)=@_; $Apache::lonxml::request=$request; @@ -640,6 +658,7 @@ sub setup_globals { $Apache::lonxml::usestyle=1; &init_counter(); &clear_bubble_lines_for_part(); + &init_state(); @Apache::lonxml::pwd=(); @Apache::lonxml::extlinks=(); @script_var_displays=(); @@ -1047,28 +1066,28 @@ Increments the internal counter environm Optional Arguments: $increment - amount to increment by (defaults to 1) Also 1 if the value is negative or zero. - $part_id - optional part id.. during analysis, this - indicates whic part of a problem is being + $response_id - The id of the response to record. This + indicates whicn part of which problem is being counted. =cut sub increment_counter { - my ($increment, $part_id) = @_; + my ($increment, $response_id) = @_; if (!defined($increment) || $increment le 0) { $increment = 1; } $Apache::lonxml::counter += $increment; - # If the caller supplied the part_id parameter, + # If the caller supplied the response_id parameter, # Maintain its counter.. creating if necessary. - if(defined($part_id)) { - if (!defined($Apache::lonxml::counters_per_part{$part_id})) { - $Apache::lonxml::counters_per_part{$part_id} = 0; + if(defined($response_id)) { + if (!defined($Apache::lonxml::counters_per_part{$response_id})) { + $Apache::lonxml::counters_per_part{$response_id} = 0; } - $Apache::lonxml::counters_per_part{$part_id} += $increment; - my $new_value = $Apache::lonxml::counters_per_part{$part_id}; + $Apache::lonxml::counters_per_part{$response_id} += $increment; + my $new_value = $Apache::lonxml::counters_per_part{$response_id}; } $Apache::lonxml::counter_changed=1; @@ -1129,20 +1148,20 @@ sub store_counter { =pod -=item bubble_lines_for_part(part_id) +=item bubble_lines_for_part(response_id) Returns the number of lines required to get a response for -$part_id (this is just $Apache::lonxml::counters_per_part{$part_id} +$response_id (this is just $Apache::lonxml::counters_per_part{$response_id} =cut sub bubble_lines_for_part { - my ($part_id) = @_; + my ($response_id) = @_; - if (!defined($Apache::lonxml::counters_per_part{$part_id})) { + if (!defined($Apache::lonxml::counters_per_part{$response_id})) { return 0; } else { - return $Apache::lonxml::counters_per_part{$part_id}; + return $Apache::lonxml::counters_per_part{$response_id}; } } @@ -1163,7 +1182,7 @@ sub clear_bubble_lines_for_part { =pod -=item set_bubble_lines(part_id, value) +=item set_bubble_lines(response_id, value) If there is a problem part, that for whatever reason requires bubble lines that are not @@ -1173,9 +1192,9 @@ analysis to set its hash value explicitl =cut sub set_bubble_lines { - my ($part_id, $value) = @_; + my ($response_id, $value) = @_; - $Apache::lonxml::counters_per_part{$part_id} = $value; + $Apache::lonxml::counters_per_part{$response_id} = $value; } =pod @@ -1464,36 +1483,37 @@ sub inserteditinfo { my $initialize=''; my $textarea_id = 'filecont'; my ($add_to_onload, $add_to_onresize); - my $addbuttons=&Apache::lonhtmlcommon::htmlareaaddbuttons(); $initialize=&Apache::lonhtmlcommon::spellheader(); if ($filetype eq 'html' && (!&Apache::lonhtmlcommon::htmlareablocked() && &Apache::lonhtmlcommon::htmlareabrowser())) { - $textarea_id .= '_htmlarea'; + $textarea_id .= '___Frame'; + my $lang = &Apache::lonhtmlcommon::htmlarea_lang(); $initialize.=(< -$addbuttons - - HTMLArea.loadPlugin("FullPage"); - +lonca function initDocument() { - var editor=new HTMLArea("filecont",config); - editor.registerPlugin(FullPage); - editor.generate(); - setTimeout( - function () { - HTMLArea._addEvents(editor._doc, - ["keypress","mousedown"], unClean); - editor._iframe.id = '$textarea_id'; - resize_textarea('$textarea_id','LC_aftertextarea'); - },300); + var oFCKeditor = new FCKeditor('filecont'); + oFCKeditor.Config['CustomConfigurationsPath'] = '/fckeditor/loncapaconfig.js' ; + oFCKeditor.Config['FullPage'] = true + oFCKeditor.Config['AutoDetectLanguage'] = false; + oFCKeditor.Config['DefaultLanguage'] = "$lang"; + oFCKeditor.ReplaceTextarea(); + } + function check_if_dirty(editor) { + if (editor.IsDirty()) { + unClean(); + } + } + function FCKeditor_OnComplete(editor) { + editor.Events.AttachEvent("OnSelectionChange",check_if_dirty); + resize_textarea('$textarea_id','LC_aftertextarea'); } FULLPAGE } else { $initialize.=(< -$addbuttons function initDocument() { resize_textarea('$textarea_id','LC_aftertextarea'); }