diff --git a/.gitignore b/.gitignore index 2700983926..a925cc3c41 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ courses.dist library-directory-tree.json library-subject-tree.json textbook-tree.json -development.yml *~ <<<<<<< HEAD /webwork3/public/js/bower_components/* diff --git a/conf/defaults.config b/conf/defaults.config index cdcf029bdb..843c08dc22 100644 --- a/conf/defaults.config +++ b/conf/defaults.config @@ -1136,6 +1136,7 @@ $webservices = { # The items below can be placed in localOverrides.conf override the settings in this file # One can also use $showeditors{classlisteditor1}=0; to override a setting. %showeditors = ( + ww3 => 1, classlisteditor1 => 0, classlisteditor2 => 1, diff --git a/conf/localOverrides.conf.dist b/conf/localOverrides.conf.dist index e49af7290a..e00c6047a2 100644 --- a/conf/localOverrides.conf.dist +++ b/conf/localOverrides.conf.dist @@ -243,13 +243,13 @@ $problemDefaults{max_attempts} = -1; # These will disappear (or at least decrease in number) once the final editor verisons # are determined. %showeditors = ( + ww3 => 1, # classlisteditor1 => 1, classlisteditor2 => 1, - classlisteditor3 => 1, + # # homeworkseteditor1 => 1, homeworkseteditor2 => 1, - homeworkseteditor3 => 1, # # librarybrowsernojs => 1, librarybrowser1 => 1, diff --git a/conf/webwork.apache2-config.dist b/conf/webwork.apache2-config.dist index 828574d6ad..010b722542 100644 --- a/conf/webwork.apache2-config.dist +++ b/conf/webwork.apache2-config.dist @@ -35,9 +35,7 @@ # The "show source" button is most useful for webwork "courses" used to train new authors # It is not desirable to expose the code of regular homework questions to students -ScriptAliasMatch /webwork2_course_files/([^/]*)/show-source.cgi/(.*) /opt/webwork/courses/$1/html/show-source.cgi/$2 - - +#ScriptAliasMatch /webwork2_course_files/([^/]*)/show-source.cgi/(.*) /opt/webwork/courses/$1/html/show-source.cgi/$2 PerlModule mod_perl2 @@ -97,7 +95,6 @@ eval "use lib '$pg_dir/lib'"; die $@ if $@; require Apache::WeBWorK; # force compilation of pretty much everything - # At this point, the following configuration variables should be present for use # in wiring WeBWorK into Apache: # @@ -149,18 +146,37 @@ if ($webwork_url eq "") { $Location{$webwork_htdocs_url} = { SetHandler => "none" }; } - -#################################################################### -# The RESTful webservice is to be running on port 3000 and this allows -# proper connection to it. -#################################################################### +########################################################################## +# WeBWork 3 +# This sets up webwork 3 to be served via dancer via cgi +# If you want to serve webwork 3 directly through dancer comment +# out the following block, and then uncomment the proxy pass lines below +# You will need to start dancer manually, or set it up as service +########################################################################## + +my $webwork3_htdocs_dir = $webwork_dir."/webwork3/public"; +# Set up /webwork3 to point to the dispatch cgi +push @Alias, [ "/webwork3/js" => "$webwork3_htdocs_dir/js"]; +push @Alias, [ "/webwork3/css" => "$webwork3_htdocs_dir/css"]; +push @Alias, [ "/webwork3/images" => "$webwork3_htdocs_dir/images"]; +push @PerlConfig, "ScriptAlias /webwork3 $webwork3_htdocs_dir/dispatch.fcgi"; + +# Allow cgi to run in the webwork3 dir +$Directory{"$webwork3_htdocs_dir"} = { + AllowOverride => "None", + Options => "+ExecCGI -MultiViews +SymLinksIfOwnerMatch", + Order => "allow,deny", + Allow => "from all", + AddHandler => "fastcgi-script .fcgi", +}; + +# These lines are for service WeBWork 3 through dancer directly. #ProxyPass /webwork3 http://localhost:3000 #ProxyPassReverse /webwork3 http://localhost:3000 - #################################################################### # WebworkSOAP handlers (for integration with moodle) #################################################################### diff --git a/conf/webwork.apache2.4-config.dist b/conf/webwork.apache2.4-config.dist index 48418838a3..43bcb81dce 100644 --- a/conf/webwork.apache2.4-config.dist +++ b/conf/webwork.apache2.4-config.dist @@ -35,9 +35,7 @@ # The "show source" button is most useful for webwork "courses" used to train new authors # It is not desirable to expose the code of regular homework questions to students -ScriptAliasMatch /webwork2_course_files/([^/]*)/show-source.cgi/(.*) /opt/webwork/courses/$1/html/show-source.cgi/$2 - - +#ScriptAliasMatch /webwork2_course_files/([^/]*)/show-source.cgi/(.*) /opt/webwork/courses/$1/html/show-source.cgi/$2 PerlModule mod_perl2 @@ -145,8 +143,35 @@ if ($webwork_url eq "") { $Location{$webwork_htdocs_url} = { SetHandler => "none" }; } +########################################################################## +# WeBWork 3 +# This sets up webwork 3 to be served via dancer via cgi +# If you want to serve webwork 3 directly through dancer comment +# out the following block, and then uncomment the proxy pass lines below +# You will need to start dancer manually, or set it up as service +########################################################################## + +my $webwork3_htdocs_dir = $webwork_dir."/webwork3/public"; +# Set up /webwork3 to point to the dispatch cgi +push @Alias, [ "/webwork3/js" => "$webwork3_htdocs_dir/js"]; +push @Alias, [ "/webwork3/css" => "$webwork3_htdocs_dir/css"]; +push @Alias, [ "/webwork3/images" => "$webwork3_htdocs_dir/images"]; +push @PerlConfig, "ScriptAlias /webwork3 $webwork3_htdocs_dir/dispatch.fcgi"; + +# Allow cgi to run in the webwork3 dir +$Directory{"$webwork3_htdocs_dir"} = { + AllowOverride => "None", + Options => "+ExecCGI -MultiViews +SymLinksIfOwnerMatch", + Require => "all granted", + AddHandler => "fastcgi-script .fcgi", +}; + +# These lines are for service WeBWork 3 through dancer directly. +#ProxyPass /webwork3 http://localhost:3000 +#ProxyPassReverse /webwork3 http://localhost:3000 + #################################################################### # WebworkSOAP handlers (for integration with moodle) #################################################################### diff --git a/webwork3/environments/development.yml.dist b/conf/webwork3.conf.dist similarity index 73% rename from webwork3/environments/development.yml.dist rename to conf/webwork3.conf.dist index f0f49fa124..5a3b2775c7 100644 --- a/webwork3/environments/development.yml.dist +++ b/conf/webwork3.conf.dist @@ -1,14 +1,20 @@ -# configuration file for development environment - +# configuration file for WeBWorK 3. This is a YAML formatted file, not Perl +# formatted like the other configuration files. The webwork_dir, pg_dir, +# and database information needs to be set for WeBWorK 3 to work. # # The webwork directory needs to be set webwork_dir: "/opt/webwork/webwork2" +pg_dir: "/opt/webwork/pg" # the logger engine to use # console: log messages to STDOUT (your console where you started the # application server) -# file: log message to a file in log/ +# file: log message to a file in logs/ +# Note: If you are running through apache and not a stand alone server you +# wont be able to see the log information. To see the log information you +# need to change this to file and then make sure that webwork2/webwork3/logs +# is owned, readable and writable by the wwdata group. logger: "console" # the log level for this environment diff --git a/lib/WeBWorK/ContentGenerator.pm b/lib/WeBWorK/ContentGenerator.pm index 0b7f0f12b4..0df6105404 100644 --- a/lib/WeBWorK/ContentGenerator.pm +++ b/lib/WeBWorK/ContentGenerator.pm @@ -754,14 +754,21 @@ sub links { print CGI::end_li(); print CGI::start_li(); print CGI::start_ul(); + + # WW3 redirect + print CGI::li(&$makelink("${pfx}WW3", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args)) + if $ce->{showeditors}->{ww3}; + #class list editor print CGI::li(&$makelink("${pfx}UserList", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args)) if $ce->{showeditors}->{classlisteditor1}; print CGI::li(&$makelink("${pfx}UserList2", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args)) if $ce->{showeditors}->{classlisteditor2}; - print CGI::li(&$makelink("${pfx}UserList3", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args)) - if $ce->{showeditors}->{classlisteditor3}; + + # the following is WW3 page which is being included elsewhere + # print CGI::li(&$makelink("${pfx}UserList3", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args)) + # if $ce->{showeditors}->{classlisteditor3}; # Homework Set Editor @@ -770,8 +777,9 @@ sub links { print CGI::li(&$makelink("${pfx}ProblemSetList2", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args)) if $ce->{showeditors}->{homeworkseteditor2}; - print CGI::li(&$makelink("${pfx}ProblemSetList3", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args)) - if $ce->{showeditors}->{homeworkseteditor3}; + # the following is WW3 page which is being included elsewhere + # print CGI::li(&$makelink("${pfx}ProblemSetList3", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args)) + # if $ce->{showeditors}->{homeworkseteditor3}; ## only show editor link for non-versioned sets if (defined $setID && $setID !~ /,v\d+$/ ) { diff --git a/lib/WeBWorK/ContentGenerator/Instructor/WW3.pm b/lib/WeBWorK/ContentGenerator/Instructor/WW3.pm new file mode 100644 index 0000000000..809908c05a --- /dev/null +++ b/lib/WeBWorK/ContentGenerator/Instructor/WW3.pm @@ -0,0 +1,66 @@ +################################################################################ +# WeBWorK Online Homework Delivery System +# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# $CVSHeader: +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of either: (a) the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any later +# version, or (b) the "Artistic License" which comes with this package. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the +# Artistic License for more details. +################################################################################ + +package WeBWorK::ContentGenerator::Instructor::WW3; +use base qw(WeBWorK); +use base qw(WeBWorK::ContentGenerator::Instructor); +use JSON qw(to_json); + +=head1 NAME + +WeBWorK::ContentGenerator::Instructor::WW3 - provides redirect to WW3 tools + +=cut + + + + +use strict; +use warnings; +#use CGI qw(-nosticky ); +use WeBWorK::CGI qw/redirect/; +use WeBWorK::Debug; + +sub footer(){ + my $self = shift; + my $r = $self->r; + my $ce = $r->ce; + my $ww_version = $ce->{WW_VERSION}||"unknown -- set ww version VERSION"; + my $pg_version = $ce->{PG_VERSION}||"unknown -- set pg version PG_VERSION link to ../pg/VERSION"; + my $theme = $ce->{defaultTheme}||"unknown -- set defaultTheme in localOverides.conf"; + my $copyright_years = $ce->{WW_COPYRIGHT_YEARS}||"1996-2011"; + # print CGI::div({-id=>"last-modified"}, $r->maketext("Page generated at [_1]", timestamp($self))); + print CGI::div({-id=>"copyright",class=>"nav navbar-text"}, "WeBWorK © $copyright_years", "| theme: $theme | ww_version: $ww_version | pg_version: $pg_version|", CGI::a({-href=>"http://webwork.maa.org/"}, $r->maketext("The WeBWorK Project"), )); + return "" +} + + +sub pre_header_initialize { + my $self = shift; + my $r = $self->r; + my $urlpath = $r->urlpath; + print redirect("/webwork3/courses/". $urlpath->arg("courseID") . "/manager"); + +} + + + +1; +=head1 AUTHOR + +Written by Peter Staab at (pstaab at fitchburgstate.edu) + +=cut diff --git a/lib/WeBWorK/URLPath.pm b/lib/WeBWorK/URLPath.pm index ad5e32e3e0..ee5ee78409 100644 --- a/lib/WeBWorK/URLPath.pm +++ b/lib/WeBWorK/URLPath.pm @@ -356,7 +356,8 @@ our %pathTypes = ( instructor_tools => { name => 'Instructor Tools', parent => 'set_list', - kids => [ qw/instructor_user_list instructor_user_list2 instructor_user_list3 instructor_set_list instructor_set_list2 instructor_set_list3 + kids => [ qw/ww3_course_manager instructor_user_list instructor_user_list2 + instructor_set_list instructor_set_list2 instructor_add_users instructor_achievement_list instructor_set_assigner instructor_file_manager instructor_problem_editor instructor_problem_editor2 instructor_problem_editor3 instructor_simple_editor @@ -374,6 +375,23 @@ our %pathTypes = ( display => 'WeBWorK::ContentGenerator::Instructor::Index', }, + ################################################################################ + # + # Link to WW3 Course Manager + # + ################################################################################ + + ww3_course_manager => { + name => 'WeBWorK3', + parent => 'instructor_tools', + kids => [ qw// ], + match => qr|^ww3/|, + capture => [ qw// ], + produce => 'ww3', + display => 'WeBWorK::ContentGenerator::Instructor::WW3', + + }, + ################################################################################ instructor_user_list => { @@ -394,15 +412,16 @@ our %pathTypes = ( produce => 'users2/', display => 'WeBWorK::ContentGenerator::Instructor::UserList2', }, - instructor_user_list3 => { - name => 'Classlist Manager', - parent => 'instructor_tools', - kids => [ qw/instructor_user_detail/ ], - match => qr|^users3/|, - capture => [ qw// ], - produce => 'users3/', - display => 'WeBWorK::ContentGenerator::Instructor::UserList3', - }, + # This is a WW3 page that is being included else. + # instructor_user_list3 => { + # name => 'Classlist Manager', + # parent => 'instructor_tools', + # kids => [ qw/instructor_user_detail/ ], + # match => qr|^users3/|, + # capture => [ qw// ], + # produce => 'users3/', + # display => 'WeBWorK::ContentGenerator::Instructor::UserList3', + # }, instructor_user_detail => { name => 'Sets assigned to $userID', parent => 'instructor_user_list', @@ -442,16 +461,17 @@ our %pathTypes = ( produce => 'sets2/', display => 'WeBWorK::ContentGenerator::Instructor::ProblemSetList2', }, - - instructor_set_list3 => { - name => 'Homework Manager', - parent => 'instructor_tools', - kids => [ qw/instructor_set_detail/ ], - match => qr|^sets3/|, - capture => [ qw// ], - produce => 'sets3/', - display => 'WeBWorK::ContentGenerator::Instructor::ProblemSetList3', - }, + # This is a WW3 page that is being included elsewhere + # + # instructor_set_list3 => { + # name => 'Homework Manager', + # parent => 'instructor_tools', + # kids => [ qw/instructor_set_detail/ ], + # match => qr|^sets3/|, + # capture => [ qw// ], + # produce => 'sets3/', + # display => 'WeBWorK::ContentGenerator::Instructor::ProblemSetList3', + # }, instructor_set_detail => { diff --git a/webwork3/bin/app.pl b/webwork3/bin/app.pl index 499c4b8e99..80e4be3ed0 100755 --- a/webwork3/bin/app.pl +++ b/webwork3/bin/app.pl @@ -1,8 +1,13 @@ #!/usr/bin/env perl use Dancer; use Dancer::Plugin::Database; -use WeBWorK::DB; + +# link to WeBWorK code libraries +use lib config->{webwork_dir}.'/lib'; +use lib config->{pg_dir}.'/lib'; + use WeBWorK::CourseEnvironment; +use WeBWorK::DB; use WeBWorK::Authen; ## note: Routes::Authenication must be passed first @@ -14,10 +19,6 @@ use Routes::Settings; use Routes::PastAnswers; - - - - set serializer => 'JSON'; hook 'before' => sub { @@ -66,18 +67,17 @@ if($result){ my $key = $authen->create_session(params->{user}); - session->{user} = params->{user}; - session->{key} = $key; + session user => params->{user}; + session key => $key; + my $permission = vars->{db}->getPermissionLevel(session->{user}); - session->{permission} = $permission->{permission}; + session permission => $permission->{permission}; - debug session; return {session_key=>$key, user=>params->{user},logged_in=>1}; - } else { return {logged_in=>0}; - } + } }; @@ -97,7 +97,6 @@ session_name=>config->{session_name}, session_secure=>config->{session_secure}, session_is_http_only=>config->{session_is_http_only}, - }; }; diff --git a/webwork3/environments/development.yml b/webwork3/environments/development.yml new file mode 120000 index 0000000000..dcf0aa4953 --- /dev/null +++ b/webwork3/environments/development.yml @@ -0,0 +1 @@ +../../conf/webwork3.conf \ No newline at end of file diff --git a/webwork3/lib/Routes/Authentication.pm b/webwork3/lib/Routes/Authentication.pm index 3176abb563..6cb863c676 100644 --- a/webwork3/lib/Routes/Authentication.pm +++ b/webwork3/lib/Routes/Authentication.pm @@ -84,20 +84,22 @@ sub authenticate { if(! defined(session 'key')){ my $key = vars->{db}->getKey(session 'user'); - debug $key; - if ($key->{key} eq params->{session_key}) { session key => params->{session_key}; } + + } if(! defined(session 'key')){ send_error("The session key has not been defined or is not correct. You may need to authenticate again",401); } - # debug "Checking if session->{permission} is defined"; - # debug session->{permission}; + # update the timestamp in the database so the user isn't logged out prematurely. + my $key = vars->{db}->getKey(session 'user'); + $key->{timestamp} = time(); + vars->{db}->putKey($key); if (! defined(session 'permission')){ my $permission = vars->{db}->getPermissionLevel(session 'user'); diff --git a/webwork3/public/dispatch.cgi b/webwork3/public/dispatch.cgi index 3bb7f2a3d0..aed085fffd 100755 --- a/webwork3/public/dispatch.cgi +++ b/webwork3/public/dispatch.cgi @@ -7,7 +7,7 @@ use Plack::Runner; # correctly to the dispatchers, so forcing PSGI and env here # is safer. set apphandler => 'PSGI'; -set environment => 'production'; +set environment => 'development'; my $psgi = path($RealBin, '..', 'bin', 'app.pl'); die "Unable to read startup script: $psgi" unless -r $psgi; diff --git a/webwork3/public/dispatch.fcgi b/webwork3/public/dispatch.fcgi index 8c42e3a4c4..f493cbbd81 100755 --- a/webwork3/public/dispatch.fcgi +++ b/webwork3/public/dispatch.fcgi @@ -7,11 +7,11 @@ use Plack::Handler::FCGI; # correctly to the dispatchers, so forcing PSGI and env here # is safer. set apphandler => 'PSGI'; -set environment => 'production'; +set environment => 'development'; my $psgi = path($RealBin, '..', 'bin', 'app.pl'); my $app = do($psgi); die "Unable to read startup script: $@" if $@; -my $server = Plack::Handler::FCGI->new(nproc => 5, detach => 1); +my $server = Plack::Handler::FCGI->new(nproc => 1, detach => 1); $server->run($app); diff --git a/webwork3/public/js/apps/CourseManager/CourseManager.js b/webwork3/public/js/apps/CourseManager/CourseManager.js index 36ca37c7da..7b3255fa2a 100644 --- a/webwork3/public/js/apps/CourseManager/CourseManager.js +++ b/webwork3/public/js/apps/CourseManager/CourseManager.js @@ -141,6 +141,8 @@ var CourseManager = WebPage.extend({ }); }}); + $(".ww2-link").attr("href","/webwork2/"+config.courseSettings.course_id); // create a link back to ww2. + }, // can a lot of this be handled by the individual views? diff --git a/webwork3/views/layouts/manager.tt b/webwork3/views/layouts/manager.tt index 0506c283cb..8f85721fcf 100644 --- a/webwork3/views/layouts/manager.tt +++ b/webwork3/views/layouts/manager.tt @@ -56,6 +56,7 @@ Powered by Dancer [% dancer_versio
  • Classlist Manager
  • Import and Export HW sets
  • Settings
  • +
  • WeBWorK2