--- rat/lonratedt.pm 2002/05/22 13:31:22 1.26
+++ rat/lonratedt.pm 2010/03/10 21:26:15 1.99
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Edit Handler for RAT Maps
#
-# $Id: lonratedt.pm,v 1.26 2002/05/22 13:31:22 www Exp $
+# $Id: lonratedt.pm,v 1.99 2010/03/10 21:26:15 droeschl Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,359 +25,240 @@
#
# http://www.lon-capa.org/
#
-# (TeX Content Handler
-#
-# 05/29/00,05/30 Gerd Kortemeyer)
-# 7/1,6/30 Gerd Kortemeyer
+
package Apache::lonratedt;
use strict;
use Apache::Constants qw(:common);
use Apache::lonnet;
-use Apache::lonratsrv;
-
-my @order;
-my @resources;
-
-
-# Mapread read maps into global arrays @links and @resources, determines status
-# sets @order - pointer to resources in right order
-# sets @resources - array with the resources with correct idx
-#
-sub mapread {
- my $fn=shift;
+use Apache::lonsequence();
+use Apache::loncommon();
+use Apache::lonlocal;
+use LONCAPA::map();
+use File::Copy;
+use LONCAPA;
+use HTML::Entities();
- my @links;
- undef @links;
- undef @resources;
- undef @order;
- @resources=('');
- @order=();
-
- my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,'');
- if ($errtext) { return ($errtext,2); }
-
-# -------------------------------------------------------------------- Read map
- foreach (split(/\<\&\>/,$outtext)) {
- my ($command,$number,$content)=split(/\<\:\>/,$_);
- if ($command eq 'objcont') {
- $resources[$number]=$content;
- }
- if ($command eq 'objlinks') {
- $links[$number]=$content;
- }
- }
-# ------------------------------------------------------- Is this a linear map?
- my @starters=();
- my @endings=();
- undef @starters;
- undef @endings;
-
- foreach (@links) {
- if (defined($_)) {
- my ($start,$end,$cond)=split(/\:/,$_);
- if ((defined($starters[$start])) || (defined($endings[$end]))) {
- return
- ('Map has branchings. Use advanced editor.',1);
- }
- $starters[$start]=1;
- $endings[$end]=1;
- if ($cond) {
- return
- ('Map has conditions. Use advanced editor.',1);
- }
- }
+# --------------------------------------------------------- Build up RAT screen
+sub ratedt {
+ my ($r,$url)=@_;
+ my %layout = ('border' => "0",
+ 'rows' => "1,250,*");
+ my $js ='
+';
- }
- for (my $i=1; $i<=$#resources; $i++) {
- if (defined($resources[$i])) {
- unless (($starters[$i]) || ($endings[$i])) {
- return
- ('Map has unconnected resources. Use advanced editor.',1);
- }
- }
- }
+ my $start_page =
+ &Apache::loncommon::start_page('Edit Sequence',$js,
+ {'frameset' => 1,
+ 'add_entries' => \%layout});
-# -------------------------------------------------- This is a linear map, sort
+ my $end_page =
+ &Apache::loncommon::end_page({'frameset' => 1});
- my $startidx=0;
- my $endidx=0;
- for (my $i=0; $i<=$#resources; $i++) {
- if (defined($resources[$i])) {
- my ($title,$url,$ext,$type)=split(/\:/,$resources[$i]);
- if ($type eq 'start') { $startidx=$i; }
- if ($type eq 'finish') { $endidx=$i; }
- }
- }
- my $k=0;
- my $currentidx=$startidx;
- $order[$k]=$currentidx;
- for (my $i=0; $i<=$#resources; $i++) {
- foreach (@links) {
- my ($start,$end)=split(/\:/,$_);
- if ($start==$currentidx) {
- $currentidx=$end;
- $k++;
- $order[$k]=$currentidx;
- last;
- }
- }
- if ($currentidx==$endidx) { last; }
- }
- return $errtext;
+ $r->print(<