[ww-bugs] Bug 3454: New: includePGfile

bugzilla-daemon at webwork.maa.org bugzilla-daemon at webwork.maa.org
Fri Sep 18 19:29:10 EDT 2015


http://bugs.webwork.maa.org/show_bug.cgi?id=3454

           Summary: includePGfile
           Product: Problem libraries
           Version: unspecified
          Platform: PC
        OS/Version: Mac OS
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Library (OPL)
        AssignedTo: jj at asu.edu
        ReportedBy: gage at math.rochester.edu
        Web browser ---
           version:


First let me note that includePGproblem() and includePGfile() behave
differently.  

IncludePGproblem(full path from template directory) is used frequently for
redirection to a new problem within the library.  This redirection is pretty
robust since usually the path begins  "Library/...... " so as long as the
Library link in the course is correct this will find the targeted file.

Saving a local copy of this file will still work, although in order to edit the
targeted file you have to change the path used in you homework set to the
targeted file. (This seems best in any case.)

The PG problems with includePGproblem() also work when included in HTML pages.

-----------------------------------------------------------------------------------
In macros/unionInclude.pl we have a similar include macro with slightly
different behaviour
and purpose.

includePGfile( file_name assumed to be in the same folder as original .pg file)

Finding the full file path is  accomplished with the code: (in
macros/unionInclude.pl)

   my $PGfile = $main::envir{'fileName'};
   $PGfile =~ s![^/]+$!!; $PGfile .= $name;
   while ($PGfile =~ s![^/]*/../!!) {}
+  $PGfile =~ s!^tmpEdit/!!;
   my $problem = read_whole_problem_file($main::templateDirectory.$PGfile);


The purpose of includePGfile is to include common text in a group of problems
without rewriting it.  The targeted files in this case end in -text.pg by
convention. (They are almost all in either Union or CollegeOfIdaho library
directories. )

Here are the difficulties:

(1) If a problem using includePGfile is saved as a local problem then the link
to the included file is broken (it is no longer in the same directory).  You
can't copy and save the included file using the library browser because the
-text.pg files have library tags indicating that they should not be included in
the OPL database -- hence they are invisible to the library browser.

(2) These files also don't work when included in HTML pages (I'm still checking
the details as to why here.)

(3) They also wouldn't work in this situation   dir/included-text.pg,
dir/prob1.pg, dir /prob2/prob2.pg , dir/prob2/image.png  
Prob1 would find the included-text.pg but prob2.pg would not be able to find
the 
included text ( and using  includePGfile("../included-text.pg") wouldn't work
either.

references to incidences in the wild:

http://webwork.maa.org/moodle/mod/forum/search.php?search=includePGfile&id=3

One possible fix might be to insist that the full file path from the TMPL
directory be included as the input into includePGfile()  as it is in
includePGproblem().  

Are there comments about this fix?  Are there better or at least alternative
fixes?


One last thing.  unionIncludes.pl  occurs in both macros/Union and
macros/CollegeOfIdaho. 
It's unclear which of these files will be included by loadMacros() and they are
close, but not identical.  Should we remove one of them?

-- 
Configure bugmail: http://bugs.webwork.maa.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.


More information about the webwork-bugs mailing list