Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ RUN apt-get update \
libjson-xs-perl \
libjson-maybexs-perl \
libcpanel-json-xs-perl \
libmoox-options-perl \
make \
netpbm \
preview-latex-style \
Expand Down
91 changes: 8 additions & 83 deletions bin/OPL-update
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ use lib "$ENV{WEBWORK_ROOT}/lib";
use lib "$ENV{WEBWORK_ROOT}/bin";
use WeBWorK::CourseEnvironment;
use WeBWorK::Utils::Tags;
use OPLUtils qw/build_library_directory_tree build_library_subject_tree build_library_textbook_tree/;
use OPLUtils qw/build_library_directory_tree build_library_subject_tree build_library_textbook_tree writeJSONtoFile/;

my $ce = new WeBWorK::CourseEnvironment({webwork_dir=>$ENV{WEBWORK_ROOT}});

Expand Down Expand Up @@ -527,13 +527,13 @@ if($canopenfile) {
}
#### End of taxonomy/taxonomy2

use JSON;

#### Save the official taxonomy in json format
my $webwork_htdocs = $ce->{webwork_dir}."/htdocs";
my $file = "$webwork_htdocs/DATA/tagging-taxonomy.json";
open(OUTF, ">$file") or die "Cannot open $file";
binmode(OUTF,':encoding(UTF-8)');
print OUTF to_json($tagtaxo,{pretty=>1}) or die "Cannot write to $file";
close(OUTF);

writeJSONtoFile($tagtaxo,$file);
print "Saved taxonomy to $file.\n";

#### Now deal with cross-listed sections
Expand Down Expand Up @@ -901,84 +901,9 @@ for my $chap (@{$dbchaps}) {
}
}

# Now run the script build-library-tree
# This is used to create the file library-tree.json which can be used to
# load in subject-chapter-section information for the OPL

use strict;
use warnings;
use JSON;


my $tree; # the library subject tree will be stored as arrays of objects.

my $sth = $dbh->prepare("select * from OPL_DBsubject");
$sth->execute;

my @subjects = ();
my @subject_names = ();
while ( my @row = $sth->fetchrow_array ) {
push(@subjects,$row[0]);
push(@subject_names,$row[1]);
}


my @subject_tree; # array to store the individual library tree for each subject

foreach my $i (0..$#subjects){

my $subject_row = $subjects[$i];
my $subject_name = $subject_names[$i];

my $sth = $dbh->prepare("select * from OPL_DBchapter where DBsubject_id = $subject_row;");
$sth->execute;

my @chapters = ();
my @chapter_names = ();
while ( my @row = $sth->fetchrow_array ) {
push(@chapters,$row[0]);
push(@chapter_names,$row[1]);
}


my @chapter_tree; # array to store the individual library tree for each chapter

foreach my $j (0..$#chapters) {
my $chapter_row = $chapters[$j];
my $chapter_name = $chapter_names[$j];
my $sth = $dbh->prepare("SELECT * FROM `$tables{dbsection}` WHERE DBchapter_id=$chapter_row");
$sth->execute;

my @subfields = ();
while ( my @row = $sth->fetchrow_array ) {
my $section_name;
$section_name->{name} = $row[1];
my $clone = { %{ $section_name } }; # need to clone it before pushing into the @subfields array.
push(@subfields,$clone);
}

my $chapter_tree;
$chapter_tree->{name} = $chapter_name;
$chapter_tree->{subfields} = \@subfields;

my $clone = { %{ $chapter_tree } }; # need to clone it before pushing into the @chapter_tree array.
push(@chapter_tree,$clone);



}

my $subject_tree;
$subject_tree->{name} = $subject_name;
$subject_tree->{subfields} = \@chapter_tree;

my $clone = { % {$subject_tree}};
push (@subject_tree, $clone);
}

build_library_directory_tree($ce);
build_library_subject_tree($ce,$dbh);
build_library_textbook_tree($ce,$dbh);
# Note: this used to build some JSON versions of the textbooks, subjects and directory trees
# that could be used in the library browswer. It's functionality is now
# in the updateOPLextras.pl script.

$dbh->disconnect;

Expand Down
Loading