[system] / trunk / webwork-modperl / lib / WeBWorK / ContentGenerator / Instructor / PGProblemEditor.pm Repository:
ViewVC logotype

View of /trunk/webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 889 - (download) (as text) (annotate)
Thu May 22 21:40:23 2003 UTC (10 years ago) by gage
File size: 5368 byte(s)
Stub for PGProblemEditor which edits a .pg file

-- Mike

    1 package WeBWorK::ContentGenerator::Instructor::PGProblemEditor;
    2 use base qw(WeBWorK::ContentGenerator::Instructor);
    3 
    4 
    5 =head1 NAME
    6 
    7 WeBWorK::ContentGenerator::Instructor::ProblemSetEditor - Edit a set definition list
    8 
    9 =cut
   10 
   11 use strict;
   12 use warnings;
   13 use CGI qw();
   14 use WeBWorK::Utils qw(readFile);
   15 
   16 our $libraryName;
   17 our $rowheight;
   18 
   19 sub title {
   20   my $self = shift;
   21   return "Instructor Tools - PG Problem Editor for ?????";
   22 }
   23 
   24 sub body {
   25   my $self = shift;
   26 
   27   # test area
   28   my $r = $self->{r};
   29   my $db = $self->{db};
   30 
   31   my $user = $r->param('user');
   32   my $key = $db->getKey($user)->key();
   33 
   34 
   35   ################
   36   # Gathering info
   37   # What is needed
   38   #     $problemPath  --
   39   #     $formURL -- the action URL for the form
   40   #     $tmpProblemPath
   41   my ($problemPath,$formURL,$tmpProblemPath) = $self->initialize();
   42 
   43 
   44 
   45 
   46 
   47   my $header = 'Problem Editor';
   48 
   49 
   50   #########################################################################
   51   # Define the popup strings used for selecting the library set directory, and the problem from that directory
   52   #fix me
   53   # he problem of multiple selections needs to be handled properly.
   54   #########################################################################
   55 # my $popUpSetDirectoryString = $self->fetchSetDirectories($setDirectory);  #pass default choice as current directory
   56 # my $popUpPGProblemString = $self->fetchPGproblems($setDirectory);
   57 
   58 
   59   #########################################################################
   60   # Define a link to view the problem
   61   #fix me:
   62   # Currently this link used the webwork problem library, which might be out of
   63   # sync with the local library
   64   #########################################################################
   65 
   66 
   67 
   68   #########################################################################
   69   # Format the page
   70   #########################################################################
   71 
   72   return CGI::p($header),
   73 
   74     "<p> the parameters passed are "  #fix me -- debugging code
   75     . join("<BR>", %{$r->param()}) .
   76     "</p> and the gatheredInfo is ",
   77     join("<br>",$self->initialize() ),
   78   ;
   79 
   80 }
   81 
   82 sub initialize {
   83   #fix me.  This is very much hacked together.  In particular can we pass the key inside the post?
   84   my ($self, @path_components) = @_;
   85   my $ce        =   $self->{ce};
   86   my $r       = $self->{r};
   87   my $path_info     = $r->path_info || "";
   88 
   89   ## Determine the set name
   90   my $remaining_path  = $path_info;
   91   $remaining_path =~ s/^.*pgProblemEditor//;
   92   my($junk,  @components) = split "/", $remaining_path;
   93   my $problemPath = $remaining_path;
   94   # Find the URL for the form
   95   $path_info =~s|pgProblemEditor.*$|pgProblemEditor/|;   # remove trailing info, if any, from the path
   96   my $formURL = "/webwork$path_info";
   97 
   98   my $tmpProblemPath = "unknown";
   99 
  100   ($problemPath,$formURL,$tmpProblemPath);
  101 }
  102 
  103 # sub gatherProblemList {   #workaround for obtaining the definition of a problem set (awaiting implementation of db function)
  104 #   my $self = shift;
  105 #   my $setName = shift;
  106 #   my $output = "";
  107 #   if ( defined($setName) and $setName ne "" ) {
  108 #     my $templateDirectory = $self->{ce}->{courseDirs}->{templates};
  109 #     my $fileName = "$templateDirectory/$setName.def";
  110 #     my @output =  split("\n",WeBWorK::Utils::readFile($fileName) );
  111 #     @output = grep  /\.pg/,   @output;     # only get the .pg files
  112 #     @output = grep  !/Header/, @output;   # eliminate header files
  113 #     $output = join("\n",@output);
  114 #   } else {
  115 #     $output = "No set name |$setName| is defined";
  116 #   }
  117 #
  118 #
  119 #   return  $output
  120 #
  121 #
  122 #
  123 #
  124 # }
  125 # sub fetchSetDirectories {
  126 #
  127 #   my $self = shift;
  128 #   my $defaultChoice = shift;
  129 #   my $templateDirectory = $self->{ce}->{courseDirs}->{templates};
  130 #   opendir SETDEFDIR, $templateDirectory
  131 #     or return "Can't open directory $templateDirectory";
  132 #
  133 #   my @allFiles = grep !/^\./, readdir SETDEFDIR;
  134 #   closedir  SETDEFDIR;
  135 #
  136 #   ## filter to find only the set directories
  137 #   ## -- it is assumed that these directories don't contain a period in their names
  138 #   ## and that all other files do.  Directories names must also begin with "set".
  139 #   ## A better plan would be to read only the names of directories, not files.
  140 #
  141 #   ## sort the directories
  142 #   my @setDefFiles = grep /^set[^\.]*$/, @allFiles;
  143 #   my @sortedNames = sort @setDefFiles;
  144 #
  145 #   return "$libraryName/" . CGI::br(). CGI::popup_menu(-name=>'setDirectory', -size=>$rowheight,
  146 #    -values=>\@sortedNames, -default=>$defaultChoice ) .CGI::br() ;
  147 # }
  148 #
  149 # sub fetchPGproblems {
  150 #
  151 #   my $self = shift;
  152 #   my $setDirectory = shift;
  153 #
  154 #   # Handle default for setDirectory
  155 #   # fix me -- this is not bullet proof
  156 #   $setDirectory = "set0" unless defined($setDirectory);
  157 #   my $templateDirectory = $self->{ce}->{courseDirs}->{templates};
  158 #
  159 #   ##
  160 #   opendir SETDEFDIR, "$templateDirectory/$setDirectory"
  161 #     or return "Can't open directory $templateDirectory/$setDirectory";
  162 #
  163 #   my @allFiles = grep !/^\./, readdir SETDEFDIR;
  164 #   closedir  SETDEFDIR;
  165 #
  166 #   ## filter to find only pg problems
  167 #   ## Some problems are themselves in directories (if they have auxiliary
  168 #   ## .png's for example.  This eventuallity needs to be handled.
  169 #
  170 #   ## sort the directories
  171 #   my @pgFiles = grep /\.pg$/, @allFiles;
  172 #   my @sortedNames = sort @pgFiles;
  173 #
  174 #   return "$setDirectory ". CGI::br() .
  175 #   CGI::popup_menu(-name=>'pgProblem', -size=>$rowheight, -multiple=>undef, -values=>\@sortedNames,  ) .
  176 #   CGI::br() ;
  177 # }
  178 
  179 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9