--- loncom/interface/loncommon.pm 2024/08/17 23:31:37 1.1075.2.161.2.25
+++ loncom/interface/loncommon.pm 2013/12/30 01:56:41 1.1169
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1075.2.161.2.25 2024/08/17 23:31:37 raeburn Exp $
+# $Id: loncommon.pm,v 1.1169 2013/12/30 01:56:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -61,7 +61,7 @@ use POSIX qw(strftime mktime);
use Apache::lonmenu();
use Apache::lonenc();
use Apache::lonlocal;
-use Apache::lonnavmaps();
+use Apache::lonnet();
use HTML::Entities;
use Apache::lonhtmlcommon();
use Apache::loncoursedata();
@@ -69,23 +69,12 @@ use Apache::lontexconvert();
use Apache::lonclonecourse();
use Apache::lonuserutils();
use Apache::lonuserstate();
-use Apache::courseclassifier();
use LONCAPA qw(:DEFAULT :match);
-use LONCAPA::map();
-use HTTP::Request;
use DateTime::TimeZone;
-use DateTime::Locale;
-use Encode();
+use DateTime::Locale::Catalog;
+use Text::Aspell;
use Authen::Captcha;
use Captcha::reCAPTCHA;
-use JSON::DWIW;
-use LWP::UserAgent;
-use Crypt::DES;
-use DynaLoader; # for Crypt::DES version
-use File::Copy();
-use File::Path();
-use String::CRC32();
-use Short::URL();
# ---------------------------------------------- Designs
use vars qw(%defaultdesign);
@@ -170,6 +159,7 @@ sub ssi_with_retries {
# ----------------------------------------------- Filetypes/Languages/Copyright
my %language;
my %supported_language;
+my %supported_codes;
my %latex_language; # For choosing hyphenation in
my %latex_language_bykey; # for choosing hyphenation from metadata
my %cprtag;
@@ -200,18 +190,19 @@ BEGIN {
{
my $langtabfile = $Apache::lonnet::perlvar{'lonTabDir'}.
'/language.tab';
- if ( open(my $fh,'<',$langtabfile) ) {
+ if ( open(my $fh,"<$langtabfile") ) {
while (my $line = <$fh>) {
next if ($line=~/^\#/);
chomp($line);
- my ($key,$two,$country,$three,$enc,$val,$sup,$latex)=(split(/\t/,$line));
+ my ($key,$code,$country,$three,$enc,$val,$sup,$latex)=(split(/\t/,$line));
$language{$key}=$val.' - '.$enc;
if ($sup) {
$supported_language{$key}=$sup;
+ $supported_codes{$key} = $code;
}
if ($latex) {
$latex_language_bykey{$key} = $latex;
- $latex_language{$two} = $latex;
+ $latex_language{$code} = $latex;
}
}
close($fh);
@@ -221,7 +212,7 @@ BEGIN {
{
my $copyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}.
'/copyright.tab';
- if ( open (my $fh,'<',$copyrightfile) ) {
+ if ( open (my $fh,"<$copyrightfile") ) {
while (my $line = <$fh>) {
next if ($line=~/^\#/);
chomp($line);
@@ -235,7 +226,7 @@ BEGIN {
{
my $sourcecopyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}.
'/source_copyright.tab';
- if ( open (my $fh,'<',$sourcecopyrightfile) ) {
+ if ( open (my $fh,"<$sourcecopyrightfile") ) {
while (my $line = <$fh>) {
next if ($line =~ /^\#/);
chomp($line);
@@ -249,7 +240,7 @@ BEGIN {
# -------------------------------------------------------------- default domain designs
my $designdir=$Apache::lonnet::perlvar{'lonTabDir'}.'/lonDomColors';
my $designfile = $designdir.'/default.tab';
- if ( open (my $fh,'<',$designfile) ) {
+ if ( open (my $fh,"<$designfile") ) {
while (my $line = <$fh>) {
next if ($line =~ /^\#/);
chomp($line);
@@ -263,12 +254,12 @@ BEGIN {
{
my $categoryfile = $Apache::lonnet::perlvar{'lonTabDir'}.
'/filecategories.tab';
- if ( open (my $fh,'<',$categoryfile) ) {
+ if ( open (my $fh,"<$categoryfile") ) {
while (my $line = <$fh>) {
next if ($line =~ /^\#/);
chomp($line);
my ($extension,$category)=(split(/\s+/,$line,2));
- push(@{$category_extensions{lc($category)}},$extension);
+ push @{$category_extensions{lc($category)}},$extension;
}
close($fh);
}
@@ -278,7 +269,7 @@ BEGIN {
{
my $typesfile = $Apache::lonnet::perlvar{'lonTabDir'}.
'/filetypes.tab';
- if ( open (my $fh,'<',$typesfile) ) {
+ if ( open (my $fh,"<$typesfile") ) {
while (my $line = <$fh>) {
next if ($line =~ /^\#/);
chomp($line);
@@ -431,7 +422,7 @@ sub studentbrowser_javascript {
-COLORFULEDIT
-}
-
-sub xmleditor_js {
- return <
-
-XMLEDIT
-}
-
-sub insert_folding_button {
- my $curDepth = $Apache::lonxml::curdepth;
- my $lastresource = $env{'request.ambiguous'};
-
- return "";
-}
-
-=pod
-
-=item * &iframe_wrapper_headjs()
-
-emits javascript containing two global vars to facilitate handling of resizing
-by code in iframe_wrapper_resizejs() used when an iframe is present in a page
-with standard LON-CAPA menus.
-
-=cut
-
-#
-# Where iframe is in use, if window.onload() executes before the custom resize function
-# has been defined (jQuery), two global javascript vars (LCnotready and LCresizedef)
-# are used to ensure document.ready() triggers a call to resize, so the iframe contents
-# do not obscure the Functions menu.
-#
-
-sub iframe_wrapper_headjs {
- return <<"ENDJS";
-
-
-ENDJS
-
-}
-
-=pod
-
-=item * &iframe_wrapper_resizejs()
-
-emits javascript used to handle resizing for a page containing
-an iframe, to ensure that the iframe does not obscure any
-standard LON-CAPA menu items.
-
-=back
-
-=cut
-
-#
-# jQuery to use when iframe is in use and a page resize occurs.
-# This script will ensure that the iframe does not obscure any
-# standard LON-CAPA inline menus (primary, secondary, and/or
-# breadcrumbs and Functions menus. Expects javascript from
-# &iframe_wrapper_headjs() to be in head portion of the web page,
-# e.g., by inclusion in second arg passed to &start_page().
-#
-
-sub iframe_wrapper_resizejs {
- my $offset = 5;
- &get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
- if (($env{'form.inhibitmenu'} eq 'yes') || ($env{'form.only_body'})) {
- $offset = 0;
- }
- return &Apache::lonhtmlcommon::scripttag(<
-ENDJS
- }
$endbodytag=
- "$endbodyjs ".
+ " ".
&mt('Continue').''.
$endbodytag;
}
}
- if ((ref($args) eq 'HASH') && ($args->{'dashjs'})) {
- $endbodytag = &Apache::lonhtmlcommon::dash_to_minus_js().$endbodytag;
- }
return $endbodytag;
}
@@ -6757,14 +5417,6 @@ form, .inline {
display: inline;
}
-.LC_menus_content.shown{
- display: block;
-}
-
-.LC_menus_content.hidden {
- display: none;
-}
-
.LC_right {
text-align:right;
}
@@ -6785,12 +5437,6 @@ form, .inline {
width:400px;
}
-#LC_collapsible_separator {
- border: 1px solid black;
- width: 99.9%;
- height: 0px;
-}
-
.LC_iframecontainer {
width: 98%;
margin: 0;
@@ -6853,17 +5499,6 @@ div.LC_confirm_box .LC_success img {
vertical-align: middle;
}
-.LC_maxwidth {
- max-width: 100%;
- height: auto;
-}
-
-.LC_textsize_mobile {
- \@media only screen and (max-device-width: 480px) {
- -webkit-text-size-adjust:100%; -moz-text-size-adjust:100%; -ms-text-size-adjust:100%;
- }
-}
-
.LC_icon {
border: none;
vertical-align: middle;
@@ -6985,10 +5620,6 @@ table#LC_menubuttons img {
vertical-align: middle;
}
-.LC_breadcrumbs_hoverable {
- background: $sidebg;
-}
-
td.LC_table_cell_checkbox {
text-align: center;
}
@@ -7059,11 +5690,6 @@ td.LC_menubuttons_text {
background: $tabbg;
}
-td.LC_zero_height {
- line-height: 0;
- cellpadding: 0;
-}
-
table.LC_data_table {
border: 1px solid #000000;
border-collapse: separate;
@@ -7654,8 +6280,7 @@ table.LC_prior_tries td {
padding: 6px;
}
-.LC_answer_unknown,
-.LC_answer_warning {
+.LC_answer_unknown {
background: orange;
color: black;
padding: 6px;
@@ -7737,7 +6362,6 @@ table.LC_data_table tr > td.LC_docs_entr
color: #990000;
}
-.LC_domprefs_email,
.LC_docs_reinit_warn,
.LC_docs_ext_edit {
font-size: x-small;
@@ -7853,7 +6477,7 @@ div.LC_edit_problem_footer,
div.LC_edit_problem_footer div,
div.LC_edit_problem_editxml_header,
div.LC_edit_problem_editxml_header div {
- z-index: 100;
+ margin-top: 5px;
}
div.LC_edit_problem_header_title {
@@ -7869,17 +6493,14 @@ table.LC_edit_problem_header_title {
background: $tabbg;
}
-div.LC_edit_actionbar {
- background-color: $sidebg;
- margin: 0;
- padding: 0;
- line-height: 200%;
+div.LC_edit_problem_discards {
+ float: left;
+ padding-bottom: 5px;
}
-div.LC_edit_actionbar div{
- padding: 0;
- margin: 0;
- display: inline-block;
+div.LC_edit_problem_saves {
+ float: right;
+ padding-bottom: 5px;
}
.LC_edit_opt {
@@ -7895,10 +6516,6 @@ div.LC_edit_actionbar div{
margin-left: 40px;
}
-#LC_edit_problem_codemirror div{
- margin-left: 0px;
-}
-
img.stift {
border-width: 0;
vertical-align: middle;
@@ -7986,15 +6603,6 @@ fieldset {
/* overflow: hidden; */
}
-fieldset#LC_selectuser {
- margin: 0;
- padding: 0;
-}
-
-article.geogebraweb div {
- margin: 0;
-}
-
fieldset > legend {
font-weight: bold;
padding: 0 5px 0 5px;
@@ -8022,6 +6630,7 @@ fieldset > legend {
ol.LC_primary_menu {
margin: 0;
padding: 0;
+ background-color: $pgbg_or_bgcolor;
}
ol#LC_PathBreadcrumbs {
@@ -8033,48 +6642,23 @@ ol.LC_primary_menu li {
vertical-align: middle;
text-align: left;
list-style: none;
- position: relative;
float: left;
- z-index: 100; /* will be displayed above codemirror and underneath the help-layer */
- line-height: 1.5em;
}
-ol.LC_primary_menu li a,
-ol.LC_primary_menu li p {
+ol.LC_primary_menu li a {
display: block;
margin: 0;
padding: 0 5px 0 10px;
text-decoration: none;
}
-ol.LC_primary_menu li p span.LC_primary_menu_innertitle {
- display: inline-block;
- width: 95%;
- text-align: left;
-}
-
-ol.LC_primary_menu li p span.LC_primary_menu_innerarrow {
- display: inline-block;
- width: 5%;
- float: right;
- text-align: right;
- font-size: 70%;
-}
-
-ol.LC_primary_menu ul {
+ol.LC_primary_menu li ul {
display: none;
- width: 15em;
+ width: 10em;
background-color: $data_table_light;
- position: absolute;
- top: 100%;
-}
-
-ol.LC_primary_menu ul ul {
- left: 100%;
- top: 0;
}
-ol.LC_primary_menu li:hover > ul, ol.LC_primary_menu li.hover > ul {
+ol.LC_primary_menu li:hover ul, ol.LC_primary_menu li.hover ul {
display: block;
position: absolute;
margin: 0;
@@ -8083,21 +6667,15 @@ ol.LC_primary_menu li:hover > ul, ol.LC_
}
ol.LC_primary_menu li:hover li, ol.LC_primary_menu li.hover li {
-/* First Submenu -> size should be smaller than the menu title of the whole menu */
font-size: 90%;
vertical-align: top;
float: none;
border-left: 1px solid black;
border-right: 1px solid black;
-/* A dark bottom border to visualize different menu options;
-overwritten in the create_submenu routine for the last border-bottom of the menu */
- border-bottom: 1px solid $data_table_dark;
}
-ol.LC_primary_menu li li p:hover {
- color:$button_hover;
- text-decoration:none;
- background-color:$data_table_dark;
+ol.LC_primary_menu li:hover li a, ol.LC_primary_menu li.hover li a {
+ background-color:$data_table_light;
}
ol.LC_primary_menu li li a:hover {
@@ -8105,11 +6683,6 @@ ol.LC_primary_menu li li a:hover {
background-color:$data_table_dark;
}
-/* Font-size equal to the size of the predecessors*/
-ol.LC_primary_menu li:hover li li {
- font-size: 100%;
-}
-
ol.LC_primary_menu li img {
vertical-align: bottom;
height: 1.1em;
@@ -8534,10 +7107,6 @@ a#LC_content_toolbar_edittoplevel {
background-image:url(/res/adm/pages/edittoplevel.gif);
}
-a#LC_content_toolbar_printout {
- background-image:url(/res/adm/pages/printout.gif);
-}
-
ul#LC_toolbar li a:hover {
background-position: bottom center;
}
@@ -8655,36 +7224,6 @@ ul.LC_funclist li {
cursor:pointer;
}
-.LCisDisabled {
- cursor: not-allowed;
- opacity: 0.5;
-}
-
-a[aria-disabled="true"] {
- color: currentColor;
- display: inline-block; /* For IE11/ MS Edge bug */
- pointer-events: none;
- text-decoration: none;
-}
-
-pre.LC_wordwrap {
- white-space: pre-wrap;
- white-space: -moz-pre-wrap;
- white-space: -pre-wrap;
- white-space: -o-pre-wrap;
- word-wrap: break-word;
-}
-
-/*
- styles used for response display
-*/
-div.LC_radiofoil, div.LC_rankfoil {
- margin: .5em 0em .5em 0em;
-}
-table.LC_itemgroup {
- margin-top: 1em;
-}
-
/*
styles used by TTH when "Default set of options to pass to tth/m
when converting TeX" in course settings has been set
@@ -8706,120 +7245,6 @@ span.roman {font-family: serif; font-sty
span.overacc2 {position: relative; left: .8em; top: -1.2ex;}
span.overacc1 {position: relative; left: .6em; top: -1.2ex;}
-/*
- sections with roles, for content only
-*/
-section[class^="role-"] {
- padding-left: 10px;
- padding-right: 5px;
- margin-top: 8px;
- margin-bottom: 8px;
- border: 1px solid #2A4;
- border-radius: 5px;
- box-shadow: 0px 1px 1px #BBB;
-}
-section[class^="role-"]>h1 {
- position: relative;
- margin: 0px;
- padding-top: 10px;
- padding-left: 40px;
-}
-section[class^="role-"]>h1:before {
- position: absolute;
- left: -5px;
- top: 5px;
-}
-section.role-activity>h1:before {
- content:url('/adm/daxe/images/section_icons/activity.png');
-}
-section.role-advice>h1:before {
- content:url('/adm/daxe/images/section_icons/advice.png');
-}
-section.role-bibliography>h1:before {
- content:url('/adm/daxe/images/section_icons/bibliography.png');
-}
-section.role-citation>h1:before {
- content:url('/adm/daxe/images/section_icons/citation.png');
-}
-section.role-conclusion>h1:before {
- content:url('/adm/daxe/images/section_icons/conclusion.png');
-}
-section.role-definition>h1:before {
- content:url('/adm/daxe/images/section_icons/definition.png');
-}
-section.role-demonstration>h1:before {
- content:url('/adm/daxe/images/section_icons/demonstration.png');
-}
-section.role-example>h1:before {
- content:url('/adm/daxe/images/section_icons/example.png');
-}
-section.role-explanation>h1:before {
- content:url('/adm/daxe/images/section_icons/explanation.png');
-}
-section.role-introduction>h1:before {
- content:url('/adm/daxe/images/section_icons/introduction.png');
-}
-section.role-method>h1:before {
- content:url('/adm/daxe/images/section_icons/method.png');
-}
-section.role-more_information>h1:before {
- content:url('/adm/daxe/images/section_icons/more_information.png');
-}
-section.role-objectives>h1:before {
- content:url('/adm/daxe/images/section_icons/objectives.png');
-}
-section.role-prerequisites>h1:before {
- content:url('/adm/daxe/images/section_icons/prerequisites.png');
-}
-section.role-remark>h1:before {
- content:url('/adm/daxe/images/section_icons/remark.png');
-}
-section.role-reminder>h1:before {
- content:url('/adm/daxe/images/section_icons/reminder.png');
-}
-section.role-summary>h1:before {
- content:url('/adm/daxe/images/section_icons/summary.png');
-}
-section.role-syntax>h1:before {
- content:url('/adm/daxe/images/section_icons/syntax.png');
-}
-section.role-warning>h1:before {
- content:url('/adm/daxe/images/section_icons/warning.png');
-}
-
-#LC_minitab_header {
- float:left;
- width:100%;
- background:#DAE0D2 url("/res/adm/pages/minitabmenu_bg.gif") repeat-x bottom;
- font-size:93%;
- line-height:normal;
- margin: 0.5em 0 0.5em 0;
-}
-#LC_minitab_header ul {
- margin:0;
- padding:10px 10px 0;
- list-style:none;
-}
-#LC_minitab_header li {
- float:left;
- background:url("/res/adm/pages/minitabmenu_left.gif") no-repeat left top;
- margin:0;
- padding:0 0 0 9px;
-}
-#LC_minitab_header a {
- display:block;
- background:url("/res/adm/pages/minitabmenu_right.gif") no-repeat right top;
- padding:5px 15px 4px 6px;
-}
-#LC_minitab_header #LC_current_minitab {
- background-image:url("/res/adm/pages/minitabmenu_left_on.gif");
-}
-#LC_minitab_header #LC_current_minitab a {
- background-image:url("/res/adm/pages/minitabmenu_right_on.gif");
- padding-bottom:5px;
-}
-
-
END
}
@@ -8840,13 +7265,7 @@ Inputs: $title - optional title for the
3- whether the side effect should occur
(side effect of setting
$env{'internal.head.redirect'} to the url
- redirected to)
- 4- whether the redirect target should be
- the opener of the current (pop-up)
- window (side effect of setting
- $env{'internal.head.to_opener'} to
- 1, if true.
- 5- whether encrypt check should be skipped
+ redirected too)
domain -> force to color decorate a page for a specific
domain
function -> force usage of a specific rolish color scheme
@@ -8875,16 +7294,13 @@ sub headtag {
''.
&font_settings($args);
- my $inhibitprint;
- if ($args->{'print_suppress'}) {
- $inhibitprint = &print_suppression();
- }
+ my $inhibitprint = &print_suppression();
if (!$args->{'frameset'}) {
$result .= &Apache::lonhtmlcommon::htmlareaheaders();
}
- if ($args->{'force_register'}) {
- $result .= &Apache::lonmenu::registerurl(1);
+ if ($args->{'force_register'} && $env{'request.noversionuri'} !~ m{^/res/adm/pages/}) {
+ $result .= Apache::lonxml::display_title();
}
if (!$args->{'no_nav_bar'}
&& !$args->{'only_body'}
@@ -8909,205 +7325,33 @@ sub headtag {
}
}
if (ref($args->{'redirect'})) {
- my ($time,$url,$inhibit_continue,$to_opener,$skip_enc_check) = @{$args->{'redirect'}};
- if (!$skip_enc_check) {
- $url = &Apache::lonenc::check_encrypt($url);
- }
+ my ($time,$url,$inhibit_continue) = @{$args->{'redirect'}};
+ $url = &Apache::lonenc::check_encrypt($url);
if (!$inhibit_continue) {
$env{'internal.head.redirect'} = $url;
}
- $result.=<<"ADDMETA";
+ $result.=<
-ADDMETA
- if ($to_opener) {
- $env{'internal.head.to_opener'} = 1;
- my $dest = &js_escape($url);
- my $timeout = int($time * 1000);
- $result .=<<"ENDJS";
-
-ENDJS
- } else {
- $result.=<<"ADDMETA";
ADDMETA
- }
- } else {
- unless (($args->{'frameset'}) || ($args->{'js_ready'}) || ($args->{'only_body'}) || ($args->{'no_nav_bar'})) {
- my $requrl = $env{'request.uri'};
- if ($requrl eq '') {
- $requrl = $ENV{'REQUEST_URI'};
- $requrl =~ s/\?.+$//;
- }
- unless (($requrl =~ m{^/adm/(?:switchserver|login|authenticate|logout|groupsort|cleanup|helper|slotrequest|grades)(\?|$)}) ||
- (($requrl =~ m{^/res/}) && (($env{'form.submitted'} eq 'scantron') ||
- ($env{'form.grade_symb'}) || ($Apache::lonhomework::scantronmode)))) {
- my $dom_in_use = $Apache::lonnet::perlvar{'lonDefDomain'};
- unless (&Apache::lonnet::allowed('mau',$dom_in_use)) {
- my %domdefs = &Apache::lonnet::get_domain_defaults($dom_in_use);
- my $lonhost = $Apache::lonnet::perlvar{'lonHostID'};
- my ($offload,$offloadoth);
- if (ref($domdefs{'offloadnow'}) eq 'HASH') {
- if ($domdefs{'offloadnow'}{$lonhost}) {
- $offload = 1;
- if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne $dom_in_use) &&
- (!(($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')))) {
- unless (&Apache::lonnet::shared_institution($env{'user.domain'})) {
- $offloadoth = 1;
- $dom_in_use = $env{'user.domain'};
- }
- }
- }
- }
- unless ($offload) {
- if (ref($domdefs{'offloadoth'}) eq 'HASH') {
- if ($domdefs{'offloadoth'}{$lonhost}) {
- if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne $dom_in_use) &&
- (!(($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')))) {
- unless (&Apache::lonnet::shared_institution($env{'user.domain'})) {
- $offload = 1;
- $offloadoth = 1;
- $dom_in_use = $env{'user.domain'};
- }
- }
- }
- }
- }
- if ($offload) {
- my $newserver = &Apache::lonnet::spareserver(undef,30000,undef,1,$dom_in_use);
- if (($newserver eq '') && ($offloadoth)) {
- my @domains = &Apache::lonnet::current_machine_domains();
- if (($dom_in_use ne '') && (!grep(/^\Q$dom_in_use\E$/,@domains))) {
- ($newserver) = &Apache::lonnet::choose_server($dom_in_use);
- }
- }
- if (($newserver) && ($newserver ne $lonhost)) {
- my $numsec = 5;
- my $timeout = $numsec * 1000;
- my ($newurl,$locknum,%locks,$msg);
- if ($env{'request.role.adv'}) {
- ($locknum,%locks) = &Apache::lonnet::get_locks();
- }
- my $disable_submit = 0;
- if ($requrl =~ /$LONCAPA::assess_re/) {
- $disable_submit = 1;
- }
- if ($locknum) {
- my @lockinfo = sort(values(%locks));
- $msg = &mt('Once the following tasks are complete:')." \n".
- join(", ",sort(values(%locks)))."\n";
- if (&show_course()) {
- $msg .= &mt('your session will be transferred to a different server, after you click "Courses".');
- } else {
- $msg .= &mt('your session will be transferred to a different server, after you click "Roles".');
- }
- } else {
- if (($requrl =~ m{^/res/}) && ($env{'form.submitted'} =~ /^part_/)) {
- $msg = &mt('Your LON-CAPA submission has been recorded')."\n";
- }
- $msg .= &mt('Your current LON-CAPA session will be transferred to a different server in [quant,_1,second].',$numsec);
- $newurl = '/adm/switchserver?otherserver='.$newserver;
- if (($env{'request.role'}) && ($env{'request.role'} ne 'cm')) {
- $newurl .= '&role='.$env{'request.role'};
- }
- if ($env{'request.symb'}) {
- my $shownsymb = &Apache::lonenc::check_encrypt($env{'request.symb'});
- if ($shownsymb =~ m{^/enc/}) {
- my $reqdmajor = 2;
- my $reqdminor = 11;
- my $reqdsubminor = 3;
- my $newserverrev = &Apache::lonnet::get_server_loncaparev('',$newserver);
- my $remoterev = &Apache::lonnet::get_server_loncaparev(undef,$newserver);
- my ($major,$minor,$subminor) = ($remoterev =~ /^\'?(\d+)\.(\d+)\.(\d+|)[\w.\-]+\'?$/);
- if (($major eq '' && $minor eq '') ||
- (($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)) ||
- (($reqdmajor == $major) && ($reqdminor == $minor) && (($subminor eq '') ||
- ($reqdsubminor > $subminor))))) {
- undef($shownsymb);
- }
- }
- if ($shownsymb) {
- &js_escape(\$shownsymb);
- $newurl .= '&symb='.$shownsymb;
- }
- } else {
- my $shownurl = &Apache::lonenc::check_encrypt($requrl);
- &js_escape(\$shownurl);
- $newurl .= '&origurl='.$shownurl;
- }
- }
- &js_escape(\$msg);
- $result.=<
-
-OFFLOAD
- }
- }
- }
- }
- }
}
if (!defined($title)) {
$title = 'The LearningOnline Network with CAPA';
}
if (!$args->{'no_auto_mt_title'}) { $title = &mt($title); }
- if ($title =~ /^LON-CAPA\s+/) {
- $result .= ' '.$title.'';
- } else {
- $result .= ' LON-CAPA '.$title.'';
- }
- $result .= "\n".''
+ .'{'frameset'}) {
$result .= ' /';
}
- $result .= '>'
+ $result .= '>'
.$inhibitprint
.$head_extra;
- my $clientmobile;
- if (($env{'user.name'} eq '') && ($env{'user.domain'} eq '')) {
- (undef,undef,undef,undef,undef,undef,$clientmobile) = &decode_user_agent();
- } else {
- $clientmobile = $env{'browser.mobile'};
- }
- if ($clientmobile) {
+ if ($env{'browser.mobile'}) {
$result .= '
';
}
- $result .= ''."\n";
return $result.'';
}
@@ -9126,12 +7370,12 @@ sub font_settings {
my $headerstring='';
if ((!$env{'browser.mathml'} && $env{'browser.unicode'}) ||
((ref($args) eq 'HASH') && ($args->{'browser.unicode'}))) {
- $headerstring.=
- '{'frameset'}) {
- $headerstring.= ' /';
+ $headerstring.= ' /';
}
- $headerstring .= '>'."\n";
+ $headerstring .= '>'."\n";
}
return $headerstring;
}
@@ -9176,8 +7420,7 @@ sub print_suppression {
}
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $clientip = &Apache::lonnet::get_requestor_ip();
- my $blocked = &blocking_status('printout',$clientip,$cnum,$cdom,undef,1);
+ my $blocked = &blocking_status('printout',$cnum,$cdom);
if ($blocked) {
my $checkrole = "cm./$cdom/$cnum";
if ($env{'request.course.sec'} ne '') {
@@ -9285,23 +7528,14 @@ $args - additional optional args support
skip_phases -> hash ref of
head -> skip the generation
body -> skip all generation
- no_inline_link -> if true and in remote mode, don't show the
- 'Switch To Inline Menu' link
no_auto_mt_title -> prevent &mt()ing the title arg
+ inherit_jsmath -> when creating popup window in a page,
+ should it have jsmath forced on by the
+ current page
bread_crumbs -> Array containing breadcrumbs
bread_crumbs_component -> if exists show it as headline else show only the breadcrumbs
- bread_crumbs_nomenu -> if true will pass false as the value of $menulink
- to lonhtmlcommon::breadcrumbs
- group -> includes the current group, if page is for a
- specific group
- use_absolute -> for request for external resource or syllabus, this
- will contain https:// if server uses
- https (as per hosts.tab), but request is for http
- hostname -> hostname, originally from $r->hostname(), (optional).
- links_disabled -> Links in primary and secondary menus are disabled
- (Can enable them once page has loaded - see lonroles.pm
- for an example).
- links_target -> Target for links, e.g., _parent (optional).
+ group -> includes the current group, if page is for a
+ specific group
=back
@@ -9314,83 +7548,12 @@ sub start_page {
#&Apache::lonnet::logthis("start_page ".join(':',caller(0)));
$env{'internal.start_page'}++;
- my ($result,@advtools,$ltiscope,$ltiuri,%ltimenu,$menucoll,%menu);
+ my ($result,@advtools);
if (! exists($args->{'skip_phases'}{'head'}) ) {
$result .= &xml_begin($args->{'frameset'}) . &headtag($title, $head_extra, $args);
}
-
- if (($env{'request.course.id'}) && ($env{'request.lti.login'})) {
- if ($env{'course.'.$env{'request.course.id'}.'.lti.override'}) {
- unless ($env{'course.'.$env{'request.course.id'}.'.lti.topmenu'}) {
- $args->{'no_primary_menu'} = 1;
- }
- unless ($env{'course.'.$env{'request.course.id'}.'.lti.inlinemenu'}) {
- $args->{'no_inline_menu'} = 1;
- }
- if ($env{'course.'.$env{'request.course.id'}.'.lti.lcmenu'}) {
- map { $ltimenu{$_} = 1; } split(/,/,$env{'course.'.$env{'request.course.id'}.'.lti.lcmenu'});
- }
- } else {
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
- if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
- unless ($lti{$env{'request.lti.login'}}{'topmenu'}) {
- $args->{'no_primary_menu'} = 1;
- }
- unless ($lti{$env{'request.lti.login'}}{'inlinemenu'}) {
- $args->{'no_inline_menu'} = 1;
- }
- if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') {
- map { $ltimenu{$_} = 1; } @{$lti{$env{'request.lti.login'}}{'lcmenu'}};
- }
- }
- }
- ($ltiscope,$ltiuri) = &LONCAPA::ltiutils::lti_provider_scope($env{'request.lti.uri'},
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'});
- } elsif ($env{'request.course.id'}) {
- my $expiretime=600;
- if ((time-$env{'course.'.$env{'request.course.id'}.'.last_cache'}) > $expiretime) {
- &Apache::lonnet::coursedescription($env{'request.course.id'},{'freshen_cache' => 1});
- }
- my ($deeplinkmenu,$menuref);
- ($menucoll,$deeplinkmenu,$menuref) = &menucoll_in_effect();
- if ($menucoll) {
- if (ref($menuref) eq 'HASH') {
- %menu = %{$menuref};
- }
- if ($menu{'top'} eq 'n') {
- $args->{'no_primary_menu'} = 1;
- }
- if ($menu{'inline'} eq 'n') {
- unless (&Apache::lonnet::allowed('opa')) {
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $crstype = &course_type();
- my $now = time;
- my $ccrole;
- if ($crstype eq 'Community') {
- $ccrole = 'co';
- } else {
- $ccrole = 'cc';
- }
- if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
- my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
- if ((($start) && ($start<0)) ||
- (($end) && ($end<$now)) ||
- (($start) && ($now<$start))) {
- $args->{'no_inline_menu'} = 1;
- }
- } else {
- $args->{'no_inline_menu'} = 1;
- }
- }
- }
- }
- }
-
- my $showncrumbs;
+
if (! exists($args->{'skip_phases'}{'body'}) ) {
if ($args->{'frameset'}) {
my $attr_string = &make_attr_string($args->{'force_register'},
@@ -9402,9 +7565,8 @@ sub start_page {
$args->{'function'}, $args->{'add_entries'},
$args->{'only_body'}, $args->{'domain'},
$args->{'force_register'}, $args->{'no_nav_bar'},
- $args->{'bgcolor'}, $args->{'no_inline_link'},
- $args, \@advtools,
- $ltiscope,$ltiuri,\%ltimenu,$menucoll,\%menu,\$showncrumbs);
+ $args->{'bgcolor'}, $args,
+ \@advtools);
}
}
@@ -9426,7 +7588,6 @@ sub start_page {
#Breadcrumbs
if (exists($args->{'bread_crumbs'}) or exists($args->{'bread_crumbs_component'})) {
- unless ($showncrumbs) {
&Apache::lonhtmlcommon::clear_breadcrumbs();
#if any br links exists, add them to the breadcrumbs
if (exists($args->{'bread_crumbs'}) and ref($args->{'bread_crumbs'}) eq 'ARRAY') {
@@ -9438,33 +7599,13 @@ sub start_page {
if (@advtools > 0) {
&Apache::lonmenu::advtools_crumbs(@advtools);
}
- my $menulink;
- # if arg: bread_crumbs_nomenu is true pass 0 as $menulink item.
- if ((exists($args->{'bread_crumbs_nomenu'})) ||
- ($ltiscope eq 'map') || ($ltiscope eq 'resource')) {
- $menulink = 0;
- } else {
- undef($menulink);
- }
- my $linkprotout;
- if ($env{'request.deeplink.login'}) {
- my $linkprotout = &Apache::lonmenu::linkprot_exit();
- if ($linkprotout) {
- &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$linkprotout);
- }
- }
+
#if bread_crumbs_component exists show it as headline else show only the breadcrumbs
if(exists($args->{'bread_crumbs_component'})){
- $result .= &Apache::lonhtmlcommon::breadcrumbs($args->{'bread_crumbs_component'},'',$menulink);
- } else {
- $result .= &Apache::lonhtmlcommon::breadcrumbs('','',$menulink);
+ $result .= &Apache::lonhtmlcommon::breadcrumbs($args->{'bread_crumbs_component'});
+ }else{
+ $result .= &Apache::lonhtmlcommon::breadcrumbs();
}
- }
- } elsif (($env{'environment.remote'} eq 'on') &&
- ($env{'form.inhibitmenu'} ne 'yes') &&
- ($env{'request.noversionuri'} =~ m{^/res/}) &&
- ($env{'request.noversionuri'} !~ m{^/res/adm/pages/})) {
- $result .= '
';
}
return $result;
}
@@ -9501,147 +7642,6 @@ sub end_page {
return $result;
}
-sub menucoll_in_effect {
- my ($menucoll,$deeplinkmenu,%menu);
- if ($env{'request.course.id'}) {
- $menucoll = $env{'course.'.$env{'request.course.id'}.'.menudefault'};
- if ($env{'request.deeplink.login'}) {
- my ($deeplink_symb,$deeplink,$check_login_symb);
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- if ($env{'request.noversionuri'} =~ m{^/(res|uploaded)/}) {
- if ($env{'request.noversionuri'} =~ /\.(page|sequence)$/) {
- my $navmap = Apache::lonnavmaps::navmap->new();
- if (ref($navmap)) {
- $deeplink = $navmap->get_mapparam(undef,
- &Apache::lonnet::declutter($env{'request.noversionuri'}),
- '0.deeplink');
- } else {
- $check_login_symb = 1;
- }
- } else {
- my $symb=&Apache::lonnet::symbread();
- if ($symb) {
- $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$symb);
- } else {
- $check_login_symb = 1;
- }
- }
- } else {
- $check_login_symb = 1;
- }
- if ($check_login_symb) {
- $deeplink_symb = &deeplink_login_symb($cnum,$cdom);
- if ($deeplink_symb =~ /\.(page|sequence)$/) {
- my $mapname = &Apache::lonnet::deversion((&Apache::lonnet::decode_symb($deeplink_symb))[2]);
- my $navmap = Apache::lonnavmaps::navmap->new();
- if (ref($navmap)) {
- $deeplink = $navmap->get_mapparam(undef,$mapname,'0.deeplink');
- }
- } else {
- $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$deeplink_symb);
- }
- }
- if ($deeplink ne '') {
- my ($state,$others,$listed,$scope,$protect,$display,$target) = split(/,/,$deeplink);
- if ($display =~ /^\d+$/) {
- $deeplinkmenu = 1;
- $menucoll = $display;
- }
- }
- }
- if ($menucoll) {
- %menu = &page_menu($env{'course.'.$env{'request.course.id'}.'.menucollections'},$menucoll);
- }
- }
- return ($menucoll,$deeplinkmenu,\%menu);
-}
-
-sub deeplink_login_symb {
- my ($cnum,$cdom) = @_;
- my $login_symb;
- if ($env{'request.deeplink.login'}) {
- $login_symb = &symb_from_tinyurl($env{'request.deeplink.login'},$cnum,$cdom);
- }
- return $login_symb;
-}
-
-sub symb_from_tinyurl {
- my ($url,$cnum,$cdom) = @_;
- if ($url =~ m{^\Q/tiny/$cdom/\E(\w+)$}) {
- my $key = $1;
- my ($tinyurl,$login);
- my ($result,$cached)=&Apache::lonnet::is_cached_new('tiny',$cdom."\0".$key);
- if (defined($cached)) {
- $tinyurl = $result;
- } else {
- my $configuname = &Apache::lonnet::get_domainconfiguser($cdom);
- my %currtiny = &Apache::lonnet::get('tiny',[$key],$cdom,$configuname);
- if ($currtiny{$key} ne '') {
- $tinyurl = $currtiny{$key};
- &Apache::lonnet::do_cache_new('tiny',$cdom."\0".$key,$currtiny{$key},600);
- }
- }
- if ($tinyurl ne '') {
- my ($cnumreq,$symb) = split(/\&/,$tinyurl);
- if (wantarray) {
- return ($cnumreq,$symb);
- } elsif ($cnumreq eq $cnum) {
- return $symb;
- }
- }
- }
- if (wantarray) {
- return ();
- } else {
- return;
- }
-}
-
-sub usable_exttools {
- my %tooltypes;
- if ($env{'request.course.id'}) {
- if ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'}) {
- if ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'both') {
- %tooltypes = (
- crs => 1,
- dom => 1,
- );
- } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'crs') {
- $tooltypes{'crs'} = 1;
- } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'dom') {
- $tooltypes{'dom'} = 1;
- }
- } else {
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $crstype = lc($env{'course.'.$env{'request.course.id'}.'.type'});
- if ($crstype eq '') {
- $crstype = 'course';
- }
- if ($crstype eq 'course') {
- if ($env{'course.'.$env{'request.course.id'}.'internal.coursecode'}) {
- $crstype = 'official';
- } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.textbook'}) {
- $crstype = 'textbook';
- } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.lti'}) {
- $crstype = 'lti';
- } else {
- $crstype = 'unofficial';
- }
- }
- my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
- if ($domdefaults{$crstype.'domexttool'}) {
- $tooltypes{'dom'} = 1;
- }
- if ($domdefaults{$crstype.'exttool'}) {
- $tooltypes{'crs'} = 1;
- }
- }
- }
- return %tooltypes;
-}
-
sub wishlist_window {
return(<<'ENDWISHLIST');
@@ -9726,20 +7721,13 @@ sub modal_link {
$target_attr = 'target="'.$target.'"';
}
return <<"ENDLINK";
-$linktext
+
+ $linktext
ENDLINK
}
sub modal_adhoc_script {
- my ($funcname,$width,$height,$content,$possmathjax)=@_;
- my $mathjax;
- if ($possmathjax) {
- $mathjax = <<'ENDJAX';
- if (typeof MathJax == 'object') {
- MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
- }
-ENDJAX
- }
+ my ($funcname,$width,$height,$content)=@_;
return (<
//
@@ -9758,21 +7745,21 @@ ENDADHOC
}
sub modal_adhoc_inner {
- my ($funcname,$width,$height,$content,$possmathjax)=@_;
+ my ($funcname,$width,$height,$content)=@_;
my $innerwidth=$width-20;
$content=&js_ready(
- &start_page('Dialog',undef,{'only_body'=>1,'bgcolor'=>'#FFFFFF'}).
+ &start_page('Dialog',undef,{'only_body'=>1,'bgcolor'=>'#FFFFFF'}).
&start_scrollbox($width.'px',$innerwidth.'px',$height.'px','myModal','#FFFFFF',undef,1).
$content.
&end_scrollbox().
&end_page()
);
- return &modal_adhoc_script($funcname,$width,$height,$content,$possmathjax);
+ return &modal_adhoc_script($funcname,$width,$height,$content);
}
sub modal_adhoc_window {
- my ($funcname,$width,$height,$content,$linktext,$possmathjax)=@_;
- return &modal_adhoc_inner($funcname,$width,$height,$content,$possmathjax).
+ my ($funcname,$width,$height,$content,$linktext)=@_;
+ return &modal_adhoc_inner($funcname,$width,$height,$content).
"".$linktext."";
}
@@ -9838,9 +7825,8 @@ sub end_togglebox {
}
sub LCprogressbar_script {
- my ($id,$number_to_do)=@_;
- if ($number_to_do) {
- return(<
//
ENDPROGRESS
- } else {
- return(<
-//
-
-ENDPROGRESS
- }
}
sub LCprogressbarUpdate_script {
return(<
.ui-progressbar { position:relative; }
-.progress-label {position: absolute; width: 100%; text-align: center; top: 1px; font-weight: bold; text-shadow: 1px 1px 0 #fff;margin: 0; line-height: 200%; }
.pblabel { position: absolute; width: 100%; text-align: center; line-height: 1.9em; }
@@ -9901,54 +7865,37 @@ my $LCidcnt;
my $LCcurrentid;
sub LCprogressbar {
- my ($r,$number_to_do,$preamble)=@_;
+ my ($r)=(@_);
$LClastpercent=0;
$LCidcnt++;
$LCcurrentid=$$.'_'.$LCidcnt;
- my ($starting,$content);
- if ($number_to_do) {
- $starting=&mt('Starting');
- $content=(<$starting
ENDPROGBAR
- } else {
- $starting=&mt('Loading...');
- $LClastpercent='false';
- $content=(<
-
$starting
-
-ENDPROGBAR
- }
- &r_print($r,$content.&LCprogressbar_script($LCcurrentid,$number_to_do));
+ &r_print($r,$content.&LCprogressbar_script($LCcurrentid));
}
sub LCprogressbarUpdate {
- my ($r,$val,$text,$number_to_do)=@_;
- if ($number_to_do) {
- unless ($val) {
- if ($LClastpercent) {
- $val=$LClastpercent;
- } else {
- $val=0;
- }
- }
- if ($val<0) { $val=0; }
- if ($val>100) { $val=0; }
- $LClastpercent=$val;
- unless ($text) { $text=$val.'%'; }
- } else {
- $val = 'false';
+ my ($r,$val,$text)=@_;
+ unless ($val) {
+ if ($LClastpercent) {
+ $val=$LClastpercent;
+ } else {
+ $val=0;
+ }
}
+ if ($val<0) { $val=0; }
+ if ($val>100) { $val=0; }
+ $LClastpercent=$val;
+ unless ($text) { $text=$val.'%'; }
$text=&js_ready($text);
&r_print($r,<
//
ENDUPDATE
@@ -10133,21 +8080,14 @@ function expand_div(caller) {
sub simple_error_page {
my ($r,$title,$msg,$args) = @_;
- my %displayargs;
if (ref($args) eq 'HASH') {
if (!$args->{'no_auto_mt_msg'}) { $msg = &mt($msg); }
- if ($args->{'only_body'}) {
- $displayargs{'only_body'} = 1;
- }
- if ($args->{'no_nav_bar'}) {
- $displayargs{'no_nav_bar'} = 1;
- }
} else {
$msg = &mt($msg);
}
my $page =
- &Apache::loncommon::start_page($title,'',\%displayargs).
+ &Apache::loncommon::start_page($title).
'
'.$msg.'
'.
&Apache::loncommon::end_page();
if (ref($r)) {
@@ -10364,7 +8304,7 @@ role status: active, previous or future.
sub check_user_status {
my ($udom,$uname,$cdom,$crs,$role,$sec) = @_;
my %userinfo = &Apache::lonnet::dump('roles',$udom,$uname);
- my @uroles = keys(%userinfo);
+ my @uroles = keys %userinfo;
my $srchstr;
my $active_chk = 'none';
my $now = time;
@@ -10453,7 +8393,7 @@ sub get_sections {
}
}
- if ($check_students) {
+ if ($check_students) {
my ($classlist) = &Apache::loncoursedata::get_classlist($cdom,$cnum);
my $sec_index = &Apache::loncoursedata::CL_SECTION();
my $status_index = &Apache::loncoursedata::CL_STATUS();
@@ -10849,8 +8789,8 @@ sub get_user_quota {
if ($quota eq '' || wantarray) {
if ($quotaname eq 'course') {
my %domdefs = &Apache::lonnet::get_domain_defaults($udom);
- if (($crstype eq 'official') || ($crstype eq 'unofficial') ||
- ($crstype eq 'community') || ($crstype eq 'textbook')) {
+ if (($crstype eq 'official') || ($crstype eq 'unofficial') ||
+ ($crstype eq 'community') || ($crstype eq 'textbook')) {
$defquota = $domdefs{$crstype.'quota'};
}
if ($defquota eq '') {
@@ -11021,10 +8961,10 @@ sub excess_filesize_warning {
}
$disk_quota = int($disk_quota * 1000);
if (($current_disk_usage + $filesize) > $disk_quota) {
- return '
'.
+ return '
'.
&mt("Unable to $action [_1]. (size = [_2] kilobytes). Disk quota will be exceeded.",
- ''.$filename.'',$filesize).'
'.
- '
'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.',
+ ''.$filename.'',$filesize).''.
+ ' '.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.',
$disk_quota,$current_disk_usage).
'
';
}
@@ -11034,6 +8974,8 @@ sub excess_filesize_warning {
###############################################
+
+
sub get_secgrprole_info {
my ($cdom,$cnum,$needroles,$type) = @_;
my %sections_count = &get_sections($cdom,$cnum);
@@ -11072,24 +9014,8 @@ sub get_secgrprole_info {
}
sub user_picker {
- my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype,$context,$fixeddom,$noinstd) = @_;
+ my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype,$context) = @_;
my $currdom = $dom;
- my @alldoms = &Apache::lonnet::all_domains();
- if (@alldoms == 1) {
- my %domsrch = &Apache::lonnet::get_dom('configuration',
- ['directorysrch'],$alldoms[0]);
- my $domdesc = &Apache::lonnet::domain($alldoms[0],'description');
- my $showdom = $domdesc;
- if ($showdom eq '') {
- $showdom = $dom;
- }
- if (ref($domsrch{'directorysrch'}) eq 'HASH') {
- if ((!$domsrch{'directorysrch'}{'available'}) &&
- ($domsrch{'directorysrch'}{'lcavailable'} eq '0')) {
- return (&mt('LON-CAPA directory search is not available in domain: [_1]',$showdom),0);
- }
- }
- }
my %curr_selected = (
srchin => 'dom',
srchby => 'lastname',
@@ -11110,7 +9036,7 @@ sub user_picker {
}
$srchterm = $srch->{'srchterm'};
}
- my %html_lt=&Apache::lonlocal::texthash(
+ my %lt=&Apache::lonlocal::texthash(
'usr' => 'Search criteria',
'doma' => 'Domain/institution to search',
'uname' => 'username',
@@ -11123,8 +9049,6 @@ sub user_picker {
'exact' => 'is',
'contains' => 'contains',
'begins' => 'begins with',
- );
- my %js_lt=&Apache::lonlocal::texthash(
'youm' => "You must include some text to search for.",
'thte' => "The text you are searching for must contain at least two characters when using a 'begins' type search.",
'thet' => "The text you are searching for must contain at least three characters when using a 'contains' type search.",
@@ -11134,16 +9058,7 @@ sub user_picker {
'whse' => "When searching by last,first you must include at least one character in the first name.",
'thfo' => "The following need to be corrected before the search can be run:",
);
- &html_escape(\%html_lt);
- &js_escape(\%js_lt);
- my $domform;
- my $allow_blank = 1;
- if ($fixeddom) {
- $allow_blank = 0;
- $domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1,undef,[$currdom]);
- } else {
- $domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1);
- }
+ my $domform = &select_dom_form($currdom,'srchdomain',1,1);
my $srchinsel = ' \n";
@@ -11170,10 +9084,10 @@ sub user_picker {
foreach my $option ('lastname','lastfirst','uname') {
if ($curr_selected{'srchby'} eq $option) {
$srchbysel .= '
- ';
+ ';
} else {
$srchbysel .= '
- ';
+ ';
}
}
$srchbysel .= "\n \n";
@@ -11182,10 +9096,10 @@ sub user_picker {
foreach my $option ('begins','contains','exact') {
if ($curr_selected{'srchtype'} eq $option) {
$srchtypesel .= '
- ';
+ ';
} else {
$srchtypesel .= '
- ';
+ ';
}
}
$srchtypesel .= "\n \n";
@@ -11270,46 +9184,46 @@ function validateEntry(callingForm) {
if (srchterm == "") {
checkok = 0;
- msg += "$js_lt{'youm'}\\n";
+ msg += "$lt{'youm'}\\n";
}
if (srchtype== 'begins') {
if (srchterm.length < 2) {
checkok = 0;
- msg += "$js_lt{'thte'}\\n";
+ msg += "$lt{'thte'}\\n";
}
}
if (srchtype== 'contains') {
if (srchterm.length < 3) {
checkok = 0;
- msg += "$js_lt{'thet'}\\n";
+ msg += "$lt{'thet'}\\n";
}
}
if (srchin == 'instd') {
if (srchdomain == '') {
checkok = 0;
- msg += "$js_lt{'yomc'}\\n";
+ msg += "$lt{'yomc'}\\n";
}
}
if (srchin == 'dom') {
if (srchdomain == '') {
checkok = 0;
- msg += "$js_lt{'ymcd'}\\n";
+ msg += "$lt{'ymcd'}\\n";
}
}
if (srchby == 'lastfirst') {
if (srchterm.indexOf(",") == -1) {
checkok = 0;
- msg += "$js_lt{'whus'}\\n";
+ msg += "$lt{'whus'}\\n";
}
if (srchterm.indexOf(",") == srchterm.length -1) {
checkok = 0;
- msg += "$js_lt{'whse'}\\n";
+ msg += "$lt{'whse'}\\n";
}
}
if (checkok == 0) {
- alert("$js_lt{'thfo'}\\n"+msg);
+ alert("$lt{'thfo'}\\n"+msg);
return;
}
if (checkok == 1) {
@@ -11327,10 +9241,10 @@ $new_user_create
END_BLOCK
$output .= &Apache::lonhtmlcommon::start_pick_box().
- &Apache::lonhtmlcommon::row_title($html_lt{'doma'}).
+ &Apache::lonhtmlcommon::row_title($lt{'doma'}).
$domform.
&Apache::lonhtmlcommon::row_closure().
- &Apache::lonhtmlcommon::row_title($html_lt{'usr'}).
+ &Apache::lonhtmlcommon::row_title($lt{'usr'}).
$srchbysel.
$srchtypesel.
''.
@@ -11338,165 +9252,61 @@ END_BLOCK
&Apache::lonhtmlcommon::row_closure(1).
&Apache::lonhtmlcommon::end_pick_box().
' ';
- return ($output,1);
+ return $output;
}
sub user_rule_check {
my ($usershash,$checks,$alerts,$rulematch,$inst_results,$curr_rules,$got_rules) = @_;
- my ($response,%inst_response);
+ my $response;
if (ref($usershash) eq 'HASH') {
- if (keys(%{$usershash}) > 1) {
- my (%by_username,%by_id,%userdoms);
- my $checkid;
- if (ref($checks) eq 'HASH') {
- if ((!defined($checks->{'username'})) && (defined($checks->{'id'}))) {
- $checkid = 1;
- }
- }
- foreach my $user (keys(%{$usershash})) {
- my ($uname,$udom) = split(/:/,$user);
- if ($checkid) {
- if (ref($usershash->{$user}) eq 'HASH') {
- if ($usershash->{$user}->{'id'} ne '') {
- $by_id{$udom}{$usershash->{$user}->{'id'}} = $uname;
- $userdoms{$udom} = 1;
- if (ref($inst_results) eq 'HASH') {
- $inst_results->{$uname.':'.$udom} = {};
- }
- }
- }
- } else {
- $by_username{$udom}{$uname} = 1;
- $userdoms{$udom} = 1;
- if (ref($inst_results) eq 'HASH') {
- $inst_results->{$uname.':'.$udom} = {};
- }
- }
- }
- foreach my $udom (keys(%userdoms)) {
- if (!$got_rules->{$udom}) {
- my %domconfig = &Apache::lonnet::get_dom('configuration',
- ['usercreation'],$udom);
- if (ref($domconfig{'usercreation'}) eq 'HASH') {
- foreach my $item ('username','id') {
- if (ref($domconfig{'usercreation'}{$item.'_rule'}) eq 'ARRAY') {
- $$curr_rules{$udom}{$item} =
- $domconfig{'usercreation'}{$item.'_rule'};
- }
- }
- }
- $got_rules->{$udom} = 1;
- }
+ foreach my $user (keys(%{$usershash})) {
+ my ($uname,$udom) = split(/:/,$user);
+ next if ($udom eq '' || $uname eq '');
+ my ($id,$newuser);
+ if (ref($usershash->{$user}) eq 'HASH') {
+ $newuser = $usershash->{$user}->{'newuser'};
+ $id = $usershash->{$user}->{'id'};
}
- if ($checkid) {
- foreach my $udom (keys(%by_id)) {
- my ($outcome,$results) = &Apache::lonnet::get_multiple_instusers($udom,$by_id{$udom},'id');
- if ($outcome eq 'ok') {
- foreach my $id (keys(%{$by_id{$udom}})) {
- my $uname = $by_id{$udom}{$id};
- $inst_response{$uname.':'.$udom} = $outcome;
- }
- if (ref($results) eq 'HASH') {
- foreach my $uname (keys(%{$results})) {
- if (exists($inst_response{$uname.':'.$udom})) {
- $inst_response{$uname.':'.$udom} = $outcome;
- $inst_results->{$uname.':'.$udom} = $results->{$uname};
- }
- }
- }
- }
+ my $inst_response;
+ if (ref($checks) eq 'HASH') {
+ if (defined($checks->{'username'})) {
+ ($inst_response,%{$inst_results->{$user}}) =
+ &Apache::lonnet::get_instuser($udom,$uname);
+ } elsif (defined($checks->{'id'})) {
+ ($inst_response,%{$inst_results->{$user}}) =
+ &Apache::lonnet::get_instuser($udom,undef,$id);
}
} else {
- foreach my $udom (keys(%by_username)) {
- my ($outcome,$results) = &Apache::lonnet::get_multiple_instusers($udom,$by_username{$udom});
- if ($outcome eq 'ok') {
- foreach my $uname (keys(%{$by_username{$udom}})) {
- $inst_response{$uname.':'.$udom} = $outcome;
- }
- if (ref($results) eq 'HASH') {
- foreach my $uname (keys(%{$results})) {
- $inst_results->{$uname.':'.$udom} = $results->{$uname};
- }
- }
- }
- }
+ ($inst_response,%{$inst_results->{$user}}) =
+ &Apache::lonnet::get_instuser($udom,$uname);
+ return;
}
- } elsif (keys(%{$usershash}) == 1) {
- my $user = (keys(%{$usershash}))[0];
- my ($uname,$udom) = split(/:/,$user);
- if (($udom ne '') && ($uname ne '')) {
- if (ref($usershash->{$user}) eq 'HASH') {
- if (ref($checks) eq 'HASH') {
- if (defined($checks->{'username'})) {
- ($inst_response{$user},%{$inst_results->{$user}}) =
- &Apache::lonnet::get_instuser($udom,$uname);
- } elsif (defined($checks->{'id'})) {
- if ($usershash->{$user}->{'id'} ne '') {
- ($inst_response{$user},%{$inst_results->{$user}}) =
- &Apache::lonnet::get_instuser($udom,undef,
- $usershash->{$user}->{'id'});
- } else {
- ($inst_response{$user},%{$inst_results->{$user}}) =
- &Apache::lonnet::get_instuser($udom,$uname);
- }
- }
- } else {
- ($inst_response{$user},%{$inst_results->{$user}}) =
- &Apache::lonnet::get_instuser($udom,$uname);
- return;
- }
- if (!$got_rules->{$udom}) {
- my %domconfig = &Apache::lonnet::get_dom('configuration',
- ['usercreation'],$udom);
- if (ref($domconfig{'usercreation'}) eq 'HASH') {
- foreach my $item ('username','id') {
- if (ref($domconfig{'usercreation'}{$item.'_rule'}) eq 'ARRAY') {
- $$curr_rules{$udom}{$item} =
- $domconfig{'usercreation'}{$item.'_rule'};
- }
- }
+ if (!$got_rules->{$udom}) {
+ my %domconfig = &Apache::lonnet::get_dom('configuration',
+ ['usercreation'],$udom);
+ if (ref($domconfig{'usercreation'}) eq 'HASH') {
+ foreach my $item ('username','id') {
+ if (ref($domconfig{'usercreation'}{$item.'_rule'}) eq 'ARRAY') {
+ $$curr_rules{$udom}{$item} =
+ $domconfig{'usercreation'}{$item.'_rule'};
}
- $got_rules->{$udom} = 1;
}
}
- } else {
- return;
- }
- } else {
- return;
- }
- foreach my $user (keys(%{$usershash})) {
- my ($uname,$udom) = split(/:/,$user);
- next if (($udom eq '') || ($uname eq ''));
- my $id;
- if (ref($inst_results) eq 'HASH') {
- if (ref($inst_results->{$user}) eq 'HASH') {
- $id = $inst_results->{$user}->{'id'};
- }
- }
- if ($id eq '') {
- if (ref($usershash->{$user})) {
- $id = $usershash->{$user}->{'id'};
- }
+ $got_rules->{$udom} = 1;
}
foreach my $item (keys(%{$checks})) {
if (ref($$curr_rules{$udom}) eq 'HASH') {
if (ref($$curr_rules{$udom}{$item}) eq 'ARRAY') {
if (@{$$curr_rules{$udom}{$item}} > 0) {
- my %rule_check = &Apache::lonnet::inst_rulecheck($udom,$uname,$id,$item,
- $$curr_rules{$udom}{$item});
+ my %rule_check = &Apache::lonnet::inst_rulecheck($udom,$uname,$id,$item,$$curr_rules{$udom}{$item});
foreach my $rule (@{$$curr_rules{$udom}{$item}}) {
if ($rule_check{$rule}) {
$$rulematch{$user}{$item} = $rule;
- if ($inst_response{$user} eq 'ok') {
+ if ($inst_response eq 'ok') {
if (ref($inst_results) eq 'HASH') {
if (ref($inst_results->{$user}) eq 'HASH') {
if (keys(%{$inst_results->{$user}}) == 0) {
$$alerts{$item}{$udom}{$uname} = 1;
- } elsif ($item eq 'id') {
- if ($inst_results->{$user}->{'id'} eq '') {
- $$alerts{$item}{$udom}{$uname} = 1;
- }
}
}
}
@@ -11607,14 +9417,7 @@ sub personal_data_fieldtitles {
sub sorted_inst_types {
my ($dom) = @_;
- my ($usertypes,$order);
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- if (ref($domdefaults{'inststatus'}) eq 'HASH') {
- $usertypes = $domdefaults{'inststatus'}{'inststatustypes'};
- $order = $domdefaults{'inststatus'}{'inststatusorder'};
- } else {
- ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom);
- }
+ my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom);
my $othertitle = &mt('All users');
if ($env{'request.course.id'}) {
$othertitle = &mt('Any users');
@@ -11635,15 +9438,11 @@ sub sorted_inst_types {
}
sub get_institutional_codes {
- my ($cdom,$crs,$settings,$allcourses,$LC_code) = @_;
+ my ($settings,$allcourses,$LC_code) = @_;
# Get complete list of course sections to update
my @currsections = ();
my @currxlists = ();
- my (%unclutteredsec,%unclutteredlcsec);
my $coursecode = $$settings{'internal.coursecode'};
- my $crskey = $crs.':'.$coursecode;
- @{$unclutteredsec{$crskey}} = ();
- @{$unclutteredlcsec{$crskey}} = ();
if ($$settings{'internal.sectionnums'} ne '') {
@currsections = split(/,/,$$settings{'internal.sectionnums'});
@@ -11654,37 +9453,24 @@ sub get_institutional_codes {
}
if (@currxlists > 0) {
- foreach my $xl (@currxlists) {
- if ($xl =~ /^([^:]+):(\w*)$/) {
+ foreach (@currxlists) {
+ if (m/^([^:]+):(\w*)$/) {
unless (grep/^$1$/,@{$allcourses}) {
- push(@{$allcourses},$1);
+ push @{$allcourses},$1;
$$LC_code{$1} = $2;
}
}
}
}
-
+
if (@currsections > 0) {
- foreach my $sec (@currsections) {
- if ($sec =~ m/^(\w+):(\w*)$/ ) {
- my $instsec = $1;
+ foreach (@currsections) {
+ if (m/^(\w+):(\w*)$/) {
+ my $sec = $coursecode.$1;
my $lc_sec = $2;
- unless (grep/^\Q$instsec\E$/,@{$unclutteredsec{$crskey}}) {
- push(@{$unclutteredsec{$crskey}},$instsec);
- push(@{$unclutteredlcsec{$crskey}},$lc_sec);
- }
- }
- }
- }
-
- if (@{$unclutteredsec{$crskey}} > 0) {
- my %formattedsec = &Apache::lonnet::auto_instsec_reformat($cdom,'clutter',\%unclutteredsec);
- if ((ref($formattedsec{$crskey}) eq 'ARRAY') && (ref($unclutteredlcsec{$crskey}) eq 'ARRAY')) {
- for (my $i=0; $i<@{$formattedsec{$crskey}}; $i++) {
- my $sec = $coursecode.$formattedsec{$crskey}[$i];
- unless (grep/^\Q$sec\E$/,@{$allcourses}) {
- push(@{$allcourses},$sec);
- $$LC_code{$sec} = $unclutteredlcsec{$crskey}[$i];
+ unless (grep/^$sec$/,@{$allcourses}) {
+ push @{$allcourses},$sec;
+ $$LC_code{$sec} = $lc_sec;
}
}
}
@@ -11781,9 +9567,7 @@ reservable_now - ref to hash of student_
Keys in inner hash are:
(a) symb: either blank or symb to which slot use is restricted.
- (b) endreserve: end date of reservation period.
- (c) uniqueperiod: start,end dates when slot is to be uniquely
- selected.
+ (b) endreserve: end date of reservation period.
sorted_future - ref to array of student_schedulable slots reservable in
the future, ordered by start date of reservation period.
@@ -11794,8 +9578,6 @@ future_reservable - ref to hash of stude
Keys in inner hash are:
(a) symb: either blank or symb to which slot use is restricted.
(b) startreserve: start date of reservation period.
- (c) uniqueperiod: start,end dates when slot is to be uniquely
- selected.
=back
@@ -11849,10 +9631,6 @@ sub get_future_slots {
my $startreserve = $slots{$slot}->{'startreserve'};
my $endreserve = $slots{$slot}->{'endreserve'};
my $symb = $slots{$slot}->{'symb'};
- my $uniqueperiod;
- if (ref($slots{$slot}->{'uniqueperiod'}) eq 'ARRAY') {
- $uniqueperiod = join(',',@{$slots{$slot}->{'uniqueperiod'}});
- }
if (($startreserve < $now) &&
(!$endreserve || $endreserve > $now)) {
my $lastres = $endreserve;
@@ -11861,15 +9639,13 @@ sub get_future_slots {
}
$reservable_now{$slot} = {
symb => $symb,
- endreserve => $lastres,
- uniqueperiod => $uniqueperiod,
+ endreserve => $lastres
};
} elsif (($startreserve > $now) &&
(!$endreserve || $endreserve > $startreserve)) {
$future_reservable{$slot} = {
symb => $symb,
- startreserve => $startreserve,
- uniqueperiod => $uniqueperiod,
+ startreserve => $startreserve
};
}
}
@@ -12050,7 +9826,7 @@ sub ask_for_embedded_content {
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
}
- if (($actionurl eq '/adm/portfolio') ||
+ if (($actionurl eq '/adm/portfolio') ||
($actionurl eq '/adm/coursegrp_portfolio')) {
my $current_path='/';
if ($env{'form.currentpath'}) {
@@ -12082,18 +9858,18 @@ sub ask_for_embedded_content {
$toplevel = $url;
if ($args->{'context'} eq 'paste') {
($cdom,$cnum) = ($url =~ m{^\Q/uploaded/\E($match_domain)/($match_courseid)/});
- ($path) =
+ ($path) =
($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/});
$fileloc = &Apache::lonnet::filelocation('',$toplevel);
$fileloc =~ s{^/}{};
}
}
- } elsif ($actionurl eq '/adm/dependencies') {
+ } elsif ($actionurl eq '/adm/dependencies') {
if ($env{'request.course.id'} ne '') {
if (ref($args) eq 'HASH') {
$url = $args->{'docs_url'};
$title = $args->{'docs_title'};
- $toplevel = $url;
+ $toplevel = $url;
unless ($toplevel =~ m{^/}) {
$toplevel = "/$url";
}
@@ -12104,15 +9880,7 @@ sub ask_for_embedded_content {
($path) =
($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/});
}
- if ($toplevel=~/^\/*(uploaded|editupload)/) {
- $fileloc = $toplevel;
- $fileloc=~ s/^\s*(\S+)\s*$/$1/;
- my ($udom,$uname,$fname) =
- ($fileloc=~ m{^/+(?:uploaded|editupload)/+($match_domain)/+($match_name)/+(.*)$});
- $fileloc = propath($udom,$uname).'/userfiles/'.$fname;
- } else {
- $fileloc = &Apache::lonnet::filelocation('',$toplevel);
- }
+ $fileloc = &Apache::lonnet::filelocation('',$toplevel);
$fileloc =~ s{^/}{};
($filename) = ($fileloc =~ m{.+/([^/]+)$});
$heading = &mt('Status of dependencies in [_1]',"$title ($filename)");
@@ -12172,8 +9940,8 @@ sub ask_for_embedded_content {
my $dirptr = 16384;
foreach my $path (keys(%subdependencies)) {
$currsubfile{$path} = {};
- if (($actionurl eq '/adm/portfolio') ||
- ($actionurl eq '/adm/coursegrp_portfolio')) {
+ if (($actionurl eq '/adm/portfolio') ||
+ ($actionurl eq '/adm/coursegrp_portfolio')) {
my ($sublistref,$listerror) =
&Apache::lonnet::dirlist($url.$path,$udom,$uname,$getpropath);
if (ref($sublistref) eq 'ARRAY') {
@@ -12315,7 +10083,7 @@ sub ask_for_embedded_content {
$counter = scalar(keys(%existing));
$numpathchg = scalar(keys(%pathchanges));
return ($output,$counter,$numpathchg,\%existing);
- } elsif (($actionurl eq "/public/$cdom/$cnum/syllabus") &&
+ } elsif (($actionurl eq "/public/$cdom/$cnum/syllabus") &&
(ref($args) eq 'HASH') && ($args->{'context'} eq 'rewrites')) {
$counter = scalar(keys(%existing));
$numpathchg = scalar(keys(%pathchanges));
@@ -12544,7 +10312,7 @@ sub ask_for_embedded_content {
Performs clean-up of directories, subdirectories and filename in an
embedded object, referenced in an HTML file which is being uploaded
-to a course or portfolio, where
+to a course or portfolio, where
"Upload embedded images/multimedia files if HTML file" checkbox was
checked.
@@ -12563,7 +10331,7 @@ sub clean_path {
@contents = ($embed_file);
}
my $lastidx = scalar(@contents)-1;
- for (my $i=0; $i<=$lastidx; $i++) {
+ for (my $i=0; $i<=$lastidx; $i++) {
$contents[$i]=~s{\\}{/}g;
$contents[$i]=~s/\s+/\_/g;
$contents[$i]=~s{[^/\w\.\-]}{}g;
@@ -12902,7 +10670,7 @@ sub modify_html_refs {
}
my (%allfiles,%codebase,$output,$content);
my @changes = &get_env_multiple('form.namechange');
- unless ((@changes > 0) || ($context eq 'syllabus')) {
+ unless ((@changes > 0) || ($context eq 'syllabus')) {
if (wantarray) {
return ('',0,0);
} else {
@@ -12934,7 +10702,7 @@ sub modify_html_refs {
return;
}
}
- if (open(my $fh,'<',$container)) {
+ if (open(my $fh,"<$container")) {
$content = join('', <$fh>);
close($fh);
} else {
@@ -12999,7 +10767,7 @@ sub modify_html_refs {
}
}
} else {
- if (open(my $fh,'>',$container)) {
+ if (open(my $fh,">$container")) {
print $fh $content;
close($fh);
$output = '
'.&mt('Updated [quant,_1,reference] in [_2].',
@@ -13037,7 +10805,7 @@ sub modify_html_refs {
}
}
if ($rewrites) {
- my $saveresult;
+ my $saveresult;
my $url = &Apache::lonnet::store_edited_file($container,$content,$udom,$uname,\$saveresult);
if ($url eq $container) {
my ($fname) = ($container =~ m{/([^/]+)$});
@@ -13143,11 +10911,11 @@ sub check_for_upload {
if ($currsize < $filesize) {
my $extra = $filesize - $currsize;
if (($current_disk_usage + $extra) > $disk_quota) {
- my $msg = '
'.
+ my $msg = ''.
&mt('Unable to upload [_1]. (size = [_2] kilobytes). Disk quota will be exceeded if existing (smaller) file with same name (size = [_3] kilobytes) is replaced.',
- ''.$fname.'',$filesize,$currsize).'
'.
- '
'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.',
- $disk_quota,$current_disk_usage).'
';
+ ''.$fname.'',$filesize,$currsize).''.
+ ' '.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.',
+ $disk_quota,$current_disk_usage);
return ('will_exceed_quota',$msg);
}
}
@@ -13156,21 +10924,21 @@ sub check_for_upload {
}
}
if (($current_disk_usage + $filesize) > $disk_quota){
- my $msg = '
'.
- &mt('Unable to upload [_1]. (size = [_2] kilobytes). Disk quota will be exceeded.',''.$fname.'',$filesize).'
'.
- '
'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.',$disk_quota,$current_disk_usage).'
';
+ my $msg = ''.
+ &mt('Unable to upload [_1]. (size = [_2] kilobytes). Disk quota will be exceeded.',''.$fname.'',$filesize).''.
+ ' '.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.',$disk_quota,$current_disk_usage);
return ('will_exceed_quota',$msg);
} elsif ($found_file) {
if ($locked_file) {
- my $msg = '
';
+ my $msg = '';
$msg .= &mt('Unable to upload [_1]. A locked file by that name was found in [_2].',''.$fname.'',''.$port_path.$env{'form.currentpath'}.'');
- $msg .= '
';
+ $msg .= ' ';
$msg .= &mt('You will be able to rename or delete existing [_1] after a grade has been assigned.',''.$fname.'');
return ('file_locked',$msg);
} else {
- my $msg = '
';
+ my $msg = '';
$msg .= &mt(' A file by that name: [_1] was found in [_2].',''.$fname.'',$port_path.$env{'form.currentpath'});
- $msg .= '
';
$itemcount ++;
@@ -16121,15 +13609,12 @@ path - Array containing all categories b
currcategories - reference to array of current categories assigned to the course
-disabled - scalar (optional) contains disabled="disabled" if input elements are
- to be readonly (e.g., Domain Helpdesk role viewing course settings).
-
Returns: $output (markup to be displayed).
=cut
sub assign_category_rows {
- my ($itemcount,$cats,$depth,$parent,$path,$currcategories,$disabled) = @_;
+ my ($itemcount,$cats,$depth,$parent,$path,$currcategories) = @_;
my ($text,$name,$item,$chgstr);
if (ref($cats) eq 'ARRAY') {
my $maxdepth = scalar(@{$cats});
@@ -16152,12 +13637,12 @@ sub assign_category_rows {
}
$text .= '
';
@@ -16169,12 +13654,6 @@ sub assign_category_rows {
return $text;
}
-=pod
-
-=back
-
-=cut
-
############################################################
############################################################
@@ -16256,7 +13735,7 @@ sub commit_studentrole {
}
$oldsecurl = $uurl;
$expire_role_result =
- &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',$now,'','','',$context);
+ &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',$now,'','',$context);
if ($env{'request.course.sec'} ne '') {
if ($expire_role_result eq 'refused') {
my @roles = ('st');
@@ -16305,7 +13784,7 @@ sub commit_studentrole {
}
}
} else {
- if ($secchange) {
+ if ($secchange) {
$$logmsg .= &mt('Error when attempting section change for [_1] from old section "[_2]" to new section: "[_3]" in course [_4] -error:',$uname,$oldsec,$sec,$cid).' '.$modify_section_result.$linefeed;
} else {
$$logmsg .= &mt('Error when attempting to modify role for [_1] for section: "[_2]" in course [_3] -error:',$uname,$sec,$cid).' '.$modify_section_result.$linefeed;
@@ -16368,8 +13847,7 @@ sub check_clone {
my $cloneid='/'.$args->{'clonedomain'}.'/'.$args->{'clonecourse'};
my ($clonecrsudom,$clonecrsunum)= &LONCAPA::split_courseid($cloneid);
my $clonehome=&Apache::lonnet::homeserver($clonecrsunum,$clonecrsudom);
- my $clonetitle;
- my @clonemsg;
+ my $clonemsg;
my $can_clone = 0;
my $lctype = lc($args->{'crstype'});
if ($lctype ne 'community') {
@@ -16377,154 +13855,59 @@ sub check_clone {
}
if ($clonehome eq 'no_host') {
if ($args->{'crstype'} eq 'Community') {
- push(@clonemsg,({
- mt => 'No new community created.',
- args => [],
- },
- {
- mt => 'A new community could not be cloned from the specified original - [_1] - because it is a non-existent community.',
- args => [$args->{'clonedomain'}.':'.$args->{'clonedomain'}],
- }));
+ $clonemsg = &mt('No new community created.').$linefeed.&mt('A new community could not be cloned from the specified original - [_1] - because it is a non-existent community.',$args->{'clonecourse'}.':'.$args->{'clonedomain'});
} else {
- push(@clonemsg,({
- mt => 'No new course created.',
- args => [],
- },
- {
- mt => 'A new course could not be cloned from the specified original - [_1] - because it is a non-existent course.',
- args => [$args->{'clonecourse'}.':'.$args->{'clonedomain'}],
- }));
- }
+ $clonemsg = &mt('No new course created.').$linefeed.&mt('A new course could not be cloned from the specified original - [_1] - because it is a non-existent course.',$args->{'clonecourse'}.':'.$args->{'clonedomain'});
+ }
} else {
my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1});
- $clonetitle = $clonedesc{'description'};
if ($args->{'crstype'} eq 'Community') {
if ($clonedesc{'type'} ne 'Community') {
- push(@clonemsg,({
- mt => 'No new community created.',
- args => [],
- },
- {
- mt => 'A new community could not be cloned from the specified original - [_1] - because it is a course not a community.',
- args => [$args->{'clonecourse'}.':'.$args->{'clonedomain'}],
- }));
- return ($can_clone,\@clonemsg,$cloneid,$clonehome);
+ $clonemsg = &mt('No new community created.').$linefeed.&mt('A new community could not be cloned from the specified original - [_1] - because it is a course not a community.',$args->{'clonecourse'}.':'.$args->{'clonedomain'});
+ return ($can_clone, $clonemsg, $cloneid, $clonehome);
}
}
- if (($env{'request.role.domain'} eq $args->{'clonedomain'}) &&
+ if (($env{'request.role.domain'} eq $args->{'clonedomain'}) &&
(&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
$can_clone = 1;
} else {
- my %clonehash = &Apache::lonnet::get('environment',['cloners','internal.coursecode'],
+ my %clonehash = &Apache::lonnet::get('environment',['cloners'],
$args->{'clonedomain'},$args->{'clonecourse'});
- if ($clonehash{'cloners'} eq '') {
- my %domdefs = &Apache::lonnet::get_domain_defaults($args->{'course_domain'});
- if ($domdefs{'canclone'}) {
- unless ($domdefs{'canclone'} eq 'none') {
- if ($domdefs{'canclone'} eq 'domain') {
- if ($args->{'ccdomain'} eq $args->{'clonedomain'}) {
- $can_clone = 1;
- }
- } elsif (($clonehash{'internal.coursecode'}) && ($args->{'crscode'}) &&
- ($args->{'clonedomain'} eq $args->{'course_domain'})) {
- if (&Apache::lonnet::default_instcode_cloning($args->{'clonedomain'},$domdefs{'canclone'},
- $clonehash{'internal.coursecode'},$args->{'crscode'})) {
- $can_clone = 1;
- }
- }
- }
- }
+ my @cloners = split(/,/,$clonehash{'cloners'});
+ if (grep(/^\*$/,@cloners)) {
+ $can_clone = 1;
+ } elsif (grep(/^\*\:\Q$args->{'ccdomain'}\E$/,@cloners)) {
+ $can_clone = 1;
} else {
- my @cloners = split(/,/,$clonehash{'cloners'});
- if (grep(/^\*$/,@cloners)) {
- $can_clone = 1;
- } elsif (grep(/^\*\:\Q$args->{'ccdomain'}\E$/,@cloners)) {
- $can_clone = 1;
- } elsif (grep(/^\Q$args->{'ccuname'}\E:\Q$args->{'ccdomain'}\E$/,@cloners)) {
- $can_clone = 1;
- }
- unless ($can_clone) {
- if (($clonehash{'internal.coursecode'}) && ($args->{'crscode'}) &&
- ($args->{'clonedomain'} eq $args->{'course_domain'})) {
- my (%gotdomdefaults,%gotcodedefaults);
- foreach my $cloner (@cloners) {
- if (($cloner ne '*') && ($cloner !~ /^\*\:$match_domain$/) &&
- ($cloner !~ /^$match_username\:$match_domain$/) && ($cloner ne '')) {
- my (%codedefaults,@code_order);
- if (ref($gotcodedefaults{$args->{'clonedomain'}}) eq 'HASH') {
- if (ref($gotcodedefaults{$args->{'clonedomain'}}{'defaults'}) eq 'HASH') {
- %codedefaults = %{$gotcodedefaults{$args->{'clonedomain'}}{'defaults'}};
- }
- if (ref($gotcodedefaults{$args->{'clonedomain'}}{'order'}) eq 'ARRAY') {
- @code_order = @{$gotcodedefaults{$args->{'clonedomain'}}{'order'}};
- }
- } else {
- &Apache::lonnet::auto_instcode_defaults($args->{'clonedomain'},
- \%codedefaults,
- \@code_order);
- $gotcodedefaults{$args->{'clonedomain'}}{'defaults'} = \%codedefaults;
- $gotcodedefaults{$args->{'clonedomain'}}{'order'} = \@code_order;
- }
- if (@code_order > 0) {
- if (&Apache::lonnet::check_instcode_cloning(\%codedefaults,\@code_order,
- $cloner,$clonehash{'internal.coursecode'},
- $args->{'crscode'})) {
- $can_clone = 1;
- last;
- }
- }
- }
- }
- }
- }
- }
- unless ($can_clone) {
my $ccrole = 'cc';
if ($args->{'crstype'} eq 'Community') {
$ccrole = 'co';
}
- my %roleshash =
- &Apache::lonnet::get_my_roles($args->{'ccuname'},
- $args->{'ccdomain'},
- 'userroles',['active'],[$ccrole],
- [$args->{'clonedomain'}]);
- if ($roleshash{$args->{'clonecourse'}.':'.$args->{'clonedomain'}.':'.$ccrole}) {
+ my %roleshash =
+ &Apache::lonnet::get_my_roles($args->{'ccuname'},
+ $args->{'ccdomain'},
+ 'userroles',['active'],[$ccrole],
+ [$args->{'clonedomain'}]);
+ if (($roleshash{$args->{'clonecourse'}.':'.$args->{'clonedomain'}.':'.$ccrole}) || (grep(/^\Q$args->{'ccuname'}\E:\Q$args->{'ccdomain'}\E$/,@cloners))) {
$can_clone = 1;
- } elsif (&Apache::lonnet::is_course_owner($args->{'clonedomain'},$args->{'clonecourse'},
- $args->{'ccuname'},$args->{'ccdomain'})) {
+ } elsif (&Apache::lonnet::is_course_owner($args->{'clonedomain'},$args->{'clonecourse'},$args->{'ccuname'},$args->{'ccdomain'})) {
$can_clone = 1;
- }
- }
- unless ($can_clone) {
- if ($args->{'crstype'} eq 'Community') {
- push(@clonemsg,({
- mt => 'No new community created.',
- args => [],
- },
- {
- mt => 'The new community could not be cloned from the existing community because the new community owner ([_1]) does not have cloning rights in the existing community ([_2]).',
- args => [$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'}],
- }));
} else {
- push(@clonemsg,({
- mt => 'No new course created.',
- args => [],
- },
- {
- mt => 'The new course could not be cloned from the existing course because the new course owner ([_1]) does not have cloning rights in the existing course ([_2]).',
- args => [$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'}],
- }));
+ if ($args->{'crstype'} eq 'Community') {
+ $clonemsg = &mt('No new community created.').$linefeed.&mt('The new community could not be cloned from the existing community because the new community owner ([_1]) does not have cloning rights in the existing community ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'});
+ } else {
+ $clonemsg = &mt('No new course created.').$linefeed.&mt('The new course could not be cloned from the existing course because the new course owner ([_1]) does not have cloning rights in the existing course ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'});
+ }
}
}
}
}
- return ($can_clone,\@clonemsg,$cloneid,$clonehome,$clonetitle);
+ return ($can_clone, $clonemsg, $cloneid, $clonehome);
}
sub construct_course {
- my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context,
- $cnum,$category,$coderef,$callercontext,$user_lh) = @_;
- my ($outcome,$msgref,$clonemsgref);
+ my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context,$cnum,$category,$coderef) = @_;
+ my $outcome;
my $linefeed = ' '."\n";
if ($context eq 'auto') {
$linefeed = "\n";
@@ -16533,11 +13916,18 @@ sub construct_course {
#
# Are we cloning?
#
- my ($can_clone,$cloneid,$clonehome,$clonetitle);
+ my ($can_clone, $clonemsg, $cloneid, $clonehome);
if (($args->{'clonecourse'}) && ($args->{'clonedomain'})) {
- ($can_clone,$clonemsgref,$cloneid,$clonehome,$clonetitle) = &check_clone($args,$linefeed);
+ ($can_clone, $clonemsg, $cloneid, $clonehome) = &check_clone($args,$linefeed);
+ if ($context ne 'auto') {
+ if ($clonemsg ne '') {
+ $clonemsg = ''.$clonemsg.'';
+ }
+ }
+ $outcome .= $clonemsg.$linefeed;
+
if (!$can_clone) {
- return (0,$outcome,$clonemsgref);
+ return (0,$outcome);
}
}
@@ -16555,20 +13945,15 @@ sub construct_course {
$args->{'ccuname'}.':'.
$args->{'ccdomain'},
$args->{'crstype'},
- $cnum,$context,$category,
- $callercontext);
+ $cnum,$context,$category);
# Note: The testing routines depend on this being output; see
# Utils::Course. This needs to at least be output as a comment
# if anyone ever decides to not show this, and Utils::Course::new
# will need to be suitably modified.
- if (($callercontext eq 'auto') && ($user_lh ne '')) {
- $outcome .= &mt_user($user_lh,'New LON-CAPA [_1] ID: [_2]',$crstype,$$courseid).$linefeed;
- } else {
- $outcome .= &mt('New LON-CAPA [_1] ID: [_2]',$crstype,$$courseid).$linefeed;
- }
+ $outcome .= &mt('New LON-CAPA [_1] ID: [_2]',$crstype,$$courseid).$linefeed;
if ($$courseid =~ /^error:/) {
- return (0,$outcome,$clonemsgref);
+ return (0,$outcome);
}
#
@@ -16577,37 +13962,23 @@ sub construct_course {
($$crsudom,$$crsunum)= &LONCAPA::split_courseid($$courseid);
my $crsuhome=&Apache::lonnet::homeserver($$crsunum,$$crsudom);
if ($crsuhome eq 'no_host') {
- if (($callercontext eq 'auto') && ($user_lh ne '')) {
- $outcome .= &mt_user($user_lh,
- 'Course creation failed, unrecognized course home server.');
- } else {
- $outcome .= &mt('Course creation failed, unrecognized course home server.');
- }
- $outcome .= $linefeed;
- return (0,$outcome,$clonemsgref);
+ $outcome .= &mt('Course creation failed, unrecognized course home server.').$linefeed;
+ return (0,$outcome);
}
$outcome .= &mt('Created on').': '.$crsuhome.$linefeed;
#
# Do the cloning
-#
- my @clonemsg;
+#
if ($can_clone && $cloneid) {
- push(@clonemsg,
- {
- mt => 'Created [_1] by cloning from [_2]',
- args => [$crstype,$clonetitle],
- });
+ $clonemsg = &mt('Cloning [_1] from [_2]',$crstype,$clonehome);
+ if ($context ne 'auto') {
+ $clonemsg = ''.$clonemsg.'';
+ }
+ $outcome .= $clonemsg.$linefeed;
my %oldcenv=&Apache::lonnet::dump('environment',$$crsudom,$$crsunum);
# Copy all files
- my @info =
- &Apache::lonclonecourse::copycoursefiles($cloneid,$$courseid,$args->{'datemode'},
- $args->{'dateshift'},$args->{'crscode'},
- $args->{'ccuname'}.':'.$args->{'ccdomain'},
- $args->{'tinyurls'});
- if (@info) {
- push(@clonemsg,@info);
- }
+ &Apache::lonclonecourse::copycoursefiles($cloneid,$$courseid,$args->{'datemode'},$args->{'dateshift'});
# Restore URL
$cenv{'url'}=$oldcenv{'url'};
# Restore title
@@ -16632,11 +14003,9 @@ sub construct_course {
'plc.users.denied',
'hidefromcat',
'checkforpriv',
- 'categories'],
+ 'categories',
+ 'internal.uniquecode'],
$$crsudom,$$crsunum);
- if ($args->{'textbook'}) {
- $cenv{'internal.textbook'} = $args->{'textbook'};
- }
}
#
@@ -16647,9 +14016,6 @@ sub construct_course {
if ($args->{'crstype'}) {
$cenv{'type'}=$args->{'crstype'};
}
- if ($args->{'lti'}) {
- $cenv{'internal.lti'}=$args->{'lti'};
- }
if ($args->{'crsid'}) {
$cenv{'courseid'}=$args->{'crsid'};
}
@@ -16671,7 +14037,6 @@ sub construct_course {
$cenv{'internal.defaultcredits'} = $args->{'defaultcredits'};
}
my @badclasses = (); # Used to accumulate sections/crosslistings that did not pass classlist access check for course owner.
- my @oklcsecs = (); # Used to accumulate LON-CAPA sections for validated institutional sections.
if ($args->{'crssections'}) {
$cenv{'internal.sectionnums'} = '';
if ($args->{'crssections'} =~ m/,/) {
@@ -16685,12 +14050,8 @@ sub construct_course {
my $class = $args->{'crscode'}.$sec;
my $addcheck = &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$class,$cenv{'internal.courseowner'});
$cenv{'internal.sectionnums'} .= $item.',';
- if ($addcheck eq 'ok') {
- unless (grep(/^\Q$gp\E$/,@oklcsecs)) {
- push(@oklcsecs,$gp);
- }
- } else {
- push(@badclasses,$class);
+ unless ($addcheck eq 'ok') {
+ push @badclasses, $class;
}
}
$cenv{'internal.sectionnums'} =~ s/,$//;
@@ -16717,12 +14078,8 @@ sub construct_course {
my ($xl,$gp) = split/:/,$item;
my $addcheck = &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$xl,$cenv{'internal.courseowner'});
$cenv{'internal.crosslistings'} .= $item.',';
- if ($addcheck eq 'ok') {
- unless (grep(/^\Q$gp\E$/,@oklcsecs)) {
- push(@oklcsecs,$gp);
- }
- } else {
- push(@badclasses,$xl);
+ unless ($addcheck eq 'ok') {
+ push @badclasses, $xl;
}
}
$cenv{'internal.crosslistings'} =~ s/,$//;
@@ -16757,63 +14114,32 @@ sub construct_course {
}
if (@badclasses > 0) {
my %lt=&Apache::lonlocal::texthash(
- 'tclb' => 'The courses listed below were included as sections or crosslistings affiliated with your new LON-CAPA course.',
- 'howi' => 'However, if automated course roster updates are enabled for this class, these particular sections/crosslistings are not guaranteed to contribute towards enrollment.',
- 'itis' => 'It is possible that rights to access enrollment for these classes will be available through assignment of co-owners.',
+ 'tclb' => 'The courses listed below were included as sections or crosslistings affiliated with your new LON-CAPA course. However, if automated course roster updates are enabled for this class, these particular sections/crosslistings will not contribute towards enrollment, because the user identified as the course owner for this LON-CAPA course',
+ 'dnhr' => 'does not have rights to access enrollment in these classes',
+ 'adby' => 'as determined by the policies of your institution on access to official classlists'
);
- my $badclass_msg = $lt{'tclb'}.$linefeed.$lt{'howi'}.$linefeed.
- &mt('That is because the user identified as the course owner ([_1]) does not have rights to access enrollment in these classes, as determined by the policies of your institution on access to official classlists',$cenv{'internal.courseowner'}).$linefeed.$lt{'itis'};
+ my $badclass_msg = $cenv{'internal.courseowner'}.') - '.$lt{'dnhr'}.
+ ' ('.$lt{'adby'}.')';
if ($context eq 'auto') {
$outcome .= $badclass_msg.$linefeed;
- } else {
$outcome .= '