| … | |
… | |
| 35 | require WeBWorK::Utils::ListingDB; |
35 | require WeBWorK::Utils::ListingDB; |
| 36 | |
36 | |
| 37 | |
37 | |
| 38 | use constant MAX_SHOW => 20; |
38 | use constant MAX_SHOW => 20; |
| 39 | |
39 | |
|
|
40 | ## This is for searching the disk for directories containing pg files. |
| 40 | ## to make the recursion work, this returns an array where the first |
41 | ## to make the recursion work, this returns an array where the first |
| 41 | ## item is 1 or 0 depending on whether or not the current |
42 | ## item is 1 or 0 depending on whether or not the current |
| 42 | ## directory has any pg files. The second is a list of directories |
43 | ## directory has any pg files. The second is a list of directories |
| 43 | ## which contain pg files. |
44 | ## which contain pg files. |
| 44 | sub get_library_sets { |
45 | sub get_library_sets { |
| … | |
… | |
| 117 | $self->assignProblemToAllSetUsers($problemRecord); |
118 | $self->assignProblemToAllSetUsers($problemRecord); |
| 118 | } |
119 | } |
| 119 | } |
120 | } |
| 120 | |
121 | |
| 121 | |
122 | |
| 122 | ############# List of library sets |
123 | ############# List of sets of problems in templates directory |
| 123 | |
124 | |
| 124 | sub getalllibsets { |
125 | sub getalllibsets { |
| 125 | my $ce = shift; |
126 | my $ce = shift; |
| 126 | my @all_library_sets = get_library_sets(1, $ce->{courseDirs}->{templates}); |
127 | my @all_library_sets = get_library_sets(1, $ce->{courseDirs}->{templates}); |
| 127 | my $includetop = shift @all_library_sets; |
128 | my $includetop = shift @all_library_sets; |
| … | |
… | |
| 195 | # |
196 | # |
| 196 | # Incoming data - current chapter, current section |
197 | # Incoming data - current chapter, current section |
| 197 | sub browse_library_panel { |
198 | sub browse_library_panel { |
| 198 | my $self = shift; |
199 | my $self = shift; |
| 199 | my $r = $self->r; |
200 | my $r = $self->r; |
|
|
201 | my $ce = $r->ce; |
| 200 | |
202 | |
| 201 | my $libraryRoot = $r->{ce}->{webworkDirs}->{libraryRoot}; |
203 | my $libraryRoot = $r->{ce}->{webworkDirs}->{libraryRoot}; |
| 202 | |
204 | |
| 203 | unless($libraryRoot) { |
205 | unless($libraryRoot) { |
| 204 | print CGI::Tr(CGI::td(CGI::div({class=>'ResultsWithError', align=>"center"}, |
206 | print CGI::Tr(CGI::td(CGI::div({class=>'ResultsWithError', align=>"center"}, |
| 205 | "The problem library has not been installed."))); |
207 | "The problem library has not been installed."))); |
| 206 | return; |
208 | return; |
|
|
209 | } |
|
|
210 | # Test if the Library directory exists. If not, try to make it |
|
|
211 | unless(-d "$ce->{courseDirs}->{templates}/Library") { |
|
|
212 | unless(symlink($libraryRoot, "$ce->{courseDirs}->{templates}/Library")) { |
|
|
213 | $self->{libmsg} .= <<"HERE"; |
|
|
214 | You are missing the directory <code>templates/Library</code>, which is needed |
|
|
215 | for the Problem Library to function. It should be a link pointing to |
|
|
216 | <code>$libraryRoot</code>, which you set in <code>conf/global.conf</code>. |
|
|
217 | I tried to make the link for you, but that failed. Check the permissions |
|
|
218 | in your <code>templates</code> directory. |
|
|
219 | HERE |
|
|
220 | } |
| 207 | } |
221 | } |
| 208 | |
222 | |
| 209 | my $default_chap = "All Chapters"; |
223 | my $default_chap = "All Chapters"; |
| 210 | my $default_sect = "All Sections"; |
224 | my $default_sect = "All Sections"; |
| 211 | |
225 | |
| … | |
… | |
| 355 | : CGI::div({class=>"RenderSolo"}, $pg->{body_text}); |
369 | : CGI::div({class=>"RenderSolo"}, $pg->{body_text}); |
| 356 | |
370 | |
| 357 | |
371 | |
| 358 | my $edit_link = ''; |
372 | my $edit_link = ''; |
| 359 | if($self->{r}->param('browse_which') ne 'browse_library') { |
373 | if($self->{r}->param('browse_which') ne 'browse_library') { |
| 360 | $edit_link = CGI::a({href=>$self->systemLink( |
374 | $edit_link = CGI::a({href=>$self->systemLink($urlpath->newFromModule("WeBWorK::ContentGenerator::Instructor::PGProblemEditor", |
| 361 | $urlpath->new(type=>'instructor_problem_editor_withset_withproblem', |
|
|
| 362 | args=>{courseID =>$urlpath->arg("courseID"), |
375 | courseID =>$urlpath->arg("courseID"), |
| 363 | setID=>"Undefined_Set", problemID=>"1" } |
376 | setID=>"Undefined_Set", |
|
|
377 | problemID=>"1"), |
| 364 | ), params=>{sourceFilePath => "$sourceFileName"} |
378 | params=>{sourceFilePath => "$sourceFileName"} |
| 365 | )}, "Edit it" ); |
379 | )}, "Edit it" ); |
| 366 | } |
380 | } |
| 367 | |
381 | |
| 368 | my $try_link = CGI::a({href=>$self->systemLink( $urlpath->new(type=>'problem_detail', |
382 | my $try_link = CGI::a({href=>$self->systemLink($urlpath->newFromModule("WeBWorK::ContentGenerator::Problem", |
| 369 | args=>{courseID =>$urlpath->arg("courseID"), |
383 | courseID =>$urlpath->arg("courseID"), |
| 370 | setID=>"Undefined_Set", problemID=>"1"} |
384 | setID=>"Undefined_Set", |
| 371 | ), |
385 | problemID=>"1"), |
| 372 | params =>{effectiveUser => $self->r->param('user'), |
386 | params =>{effectiveUser => $self->r->param('user'), |
| 373 | editMode => "SetMaker", |
387 | editMode => "SetMaker", |
| 374 | sourceFilePath => "$sourceFileName"} )}, "Try it"); |
388 | sourceFilePath => "$sourceFileName"} )}, "Try it"); |
| 375 | |
389 | |
| 376 | |
390 | |