Annotation of loncom/html/adm/helper/course.initialization.helper, revision 1.21

1.2       bowersj2    1: <helper title="Course Initialization Helper" requiredpriv='opa'>
                      2: 
                      3:   <exec>
1.15      albertel    4:     my $courseid = $env{'request.course.id'};
                      5:     my $crsdom = $env{'course.'.$courseid.'.domain'};
                      6:     my $crsnum = $env{'course.'.$courseid.'.num'};
1.5       bowersj2    7:     $helper->{DATA}->{DOM} = $crsdom;
                      8:     $helper->{DATA}->{CRS} = $crsnum;
                      9: 
1.15      albertel   10:     $helper->{DATA}->{FIRST_RUN} = $env{'course.'.$crsnum.
1.5       bowersj2   11:                                         '.course.intialization.not.run'};
                     12:     # Delete the 'course.initialization.not.run' course environment
                     13:     Apache::lonnet::put('environment', {'course.helper.not.run' => 0}, 
                     14:                         $crsdom, $crsnum);
1.15      albertel   15:     Apache::lonnet::coursedescription($env{'request.course.id'});
1.2       bowersj2   16: 
                     17:     $helper->{DATA}->{GETVAL} = sub {
                     18:         my @resultlist = &Apache::lonnet::get('environment', [shift()], 
                     19:                                               $helper->{DATA}->{DOM},
                     20:                                               $helper->{DATA}->{CRS}); 
                     21:         return $resultlist[1]; };
                     22:     $helper->{DATA}->{SETVAL} = sub {
                     23:         my $name = shift;
                     24:         my $val = shift;
                     25:         if (&{$helper->{DATA}->{GETVAL}}($name) ne $val) {
                     26:             &Apache::lonnet::put('environment', {$name=>$val}, 
                     27:                                  $helper->{DATA}->{DOM},
1.6       bowersj2   28:                                  $helper->{DATA}->{CRS});
                     29:             # Try to fix bug 1757
1.15      albertel   30:             Apache::lonnet::coursedescription($env{'request.course.id'});
1.2       bowersj2   31:             return 1;
                     32:         } else {
                     33:             return 0;
                     34:         }
                     35:     }
                     36:   </exec>
1.1       bowersj2   37: 
                     38:   <state name="START" title="Welcome to Your New LON-CAPA Course">
1.5       bowersj2   39:     <eval>
1.14      sakharuk   40:       return $helper->{DATA}->{FIRST_RUN} ? 
1.10      matthew    41:         'This Helper will set up your new LON-CAPA course and choose '.
                     42:         'which features will be active. You can '.
1.5       bowersj2   43:         're-visit it later to change settings in your course.' .
                     44: 
                     45:         '<p>If you have previous experience with coordinating LON-CAPA courses and '.
1.10      matthew    46:         'prefer not to use the helper, <a href="/adm/menu">click here</a> to leave.'
1.5       bowersj2   47:         :
1.14      sakharuk   48:         &mt('This helper will set up your LON-CAPA course and choose which features will be active.');
1.5       bowersj2   49:       </eval>
1.3       bowersj2   50:     <message nextstate="COURSE_DESCRIPTION">
1.5       bowersj2   51:       <p>All settings which you can change with this Helper can also be changed
                     52:          by going to the PARM screen and clicking on the &quot;Set
1.1       bowersj2   53:          course environment&quot; button.</p>
                     54: 
1.10      matthew    55:       <p>If you do not have experience coordinating LON-CAPA courses or if you
1.2       bowersj2   56:          prefer the Helper interface, please click <nobr><b>Next -&gt;</b></nobr>.</p>
1.1       bowersj2   57:       </message>
                     58:     </state>
                     59: 
1.5       bowersj2   60:   <state name="COURSE_DESCRIPTION" title="Course Description">
1.12      matthew    61:     <message nextstate="FORBID_CHAT">
1.3       bowersj2   62:       The &quot;Course Description&quot; is the name of the course that will be
1.10      matthew    63:       seen by the students.  You may now modify the description and hit 
                     64:       <nobr>&quot;<b>Next -&gt;</b>&quot;</nobr> to continue.<br />
1.3       bowersj2   65:       </message>
                     66:     <string variable='description' size='60' >
                     67:       <defaultvalue>
                     68:         return &{$helper->{DATA}->{GETVAL}}('description');
                     69:       </defaultvalue>
                     70:       <finalcode>
                     71:         if (&{$helper->{DATA}->{SETVAL}}('description', $element->getValue())) {
                     72:           return 'Course description changed to <b>' . $element->getValue() . 
                     73:                  '</b>.';
                     74:         }
                     75:         </finalcode>
                     76:       </string>
1.12      matthew    77:     </state>
                     78: 
                     79:   <state name="FORBID_CHAT" title="Chat Participation">
                     80:     <message nextstate="FORBID_DISCUSSION">
                     81:       <p>LON-CAPA has live chat functionality.  This course will receive
                     82:          its own chat room.  You may deny students, TAs, or instructors
                     83:          the right to access the chat room.</p>
                     84:       </message>
                     85:     <choices variable="BANNED_CHAT_ROLES" multichoice="1" allowempty='1'>
                     86:       <choice computer="st"><b>Students</b> - students will not be able to use or view the chat room.</choice>
                     87:       <choice computer="ta"><b>Teaching Assistants</b> - teaching assistants will not be able use or view the chat room</choice>
                     88:       <choice computer="in"><b>Instructor</b> - instructors will not be able to use or view the chat room</choice>
                     89:       <defaultvalue>
1.16      albertel   90:         my $denied = &{$helper->{DATA}->{GETVAL}}('plc.roles.denied');
1.12      matthew    91:         $denied =~ s/,/\|\|\|/g;
                     92:         return $denied;
                     93:       </defaultvalue>
                     94:       <finalcode>
                     95:         my $denied = $element->getValue();
                     96:         $denied =~ s/\|\|\|/,/g;
                     97:         if (&{$helper->{DATA}->{SETVAL}}('plc.roles.denied', $denied)) {
                     98:             $denied =~ s/st/ students/;
                     99:             $denied =~ s/in/ instructors/;
                    100:             $denied =~ s/ta/ teaching assistants/;
                    101:             $denied =~ s/ep/ exam proctors/;
                    102:             if ($denied =~ /^[^,]*,[^,]*$/) { # only one comma
                    103:                 $denied =~ s/,/ and/g;
                    104:             } else { # add "and" to last comma
                    105:                 $denied =~ s/,([^,]*)$/, and\1/;
                    106:             }
                    107:             if ($denied) {
1.17      albertel  108:                 $denied = substr($denied, 1) . ' not allowed to participate in live chatroom.';
1.12      matthew   109:                 $denied = ucfirst($denied);
                    110:             } else {
1.17      albertel  111:                 $denied = 'Everyone can participate in live chatroom.';
1.12      matthew   112:             }
                    113:             return $denied;
                    114:         } else {
                    115:             return '';
                    116:         }
                    117:       </finalcode>
                    118:       </choices>
1.3       bowersj2  119:     </state>
                    120: 
1.1       bowersj2  121:   <state name="FORBID_DISCUSSION" title="Discussion Participation">
                    122:     <message nextstate="DISCUSSION_HTML">
1.2       bowersj2  123:          LON-CAPA hosts discussions on all resources in a course. By default,
                    124:          all users are allowed to participate in these discussions.
1.1       bowersj2  125: 
1.8       bowersj2  126:       <p>If you do not wish certain types of users to be able to use the 
                    127:          discussion features, select those types below. Note your class
1.2       bowersj2  128:          may not have all of these roles; you may safely ignore roles you
                    129:          do not intend to use. (For instance, &quot;Exam Proctor&quot; is
                    130:          generally useful only for large courses.)</p>
1.1       bowersj2  131: 
1.8       bowersj2  132:       <p>Types of users not allowed to participate in discussion can
1.9       bowersj2  133:          still view any discussion that other users post.</p>
1.8       bowersj2  134: 
1.1       bowersj2  135:       </message>
1.2       bowersj2  136:     <choices variable="BANNED_DISCUSSION_ROLES" multichoice="1" allowempty='1'>
1.1       bowersj2  137:       <choice computer="st"><b>Students</b> - students will not be able to participate in discussions</choice>
                    138:       <choice computer="ta"><b>Teaching Assistants</b> - teaching assistants will not be able to participate in discussions</choice>
                    139:       <choice computer="in"><b>Instructor</b> - instructors will not be able to participate in discussions</choice>
1.2       bowersj2  140:       <defaultvalue>
                    141:         my $denied = &{$helper->{DATA}->{GETVAL}}('pch.roles.denied');
                    142:         $denied =~ s/,/\|\|\|/g;
                    143:         return $denied;
                    144:       </defaultvalue>
                    145:       <finalcode>
                    146:         my $denied = $element->getValue();
                    147:         $denied =~ s/\|\|\|/,/g;
                    148:         if (&{$helper->{DATA}->{SETVAL}}('pch.roles.denied', $denied)) {
                    149:             $denied =~ s/st/ students/;
                    150:             $denied =~ s/in/ instructors/;
                    151:             $denied =~ s/ta/ teaching assistants/;
                    152:             $denied =~ s/ep/ exam proctors/;
                    153:             if ($denied =~ /^[^,]*,[^,]*$/) { # only one comma
                    154:                 $denied =~ s/,/ and/g;
                    155:             } else { # add "and" to last comma
                    156:                 $denied =~ s/,([^,]*)$/, and\1/;
                    157:             }
                    158:             if ($denied) {
                    159:                 $denied = substr($denied, 1) . ' not allowed to participate in discussion.';
                    160:                 $denied = ucfirst($denied);
                    161:             } else {
                    162:                 $denied = 'Everyone can participate in discussion.';
                    163:             }
                    164:             return $denied;
                    165:         } else {
                    166:             return '';
                    167:         }
                    168:       </finalcode>
1.1       bowersj2  169:       </choices>
                    170:     </state>
                    171: 
                    172:   <state name="DISCUSSION_HTML" title="HTML in Discussions">
1.3       bowersj2  173:     <message nextstate="FEEDBACK_ADDRESSES">
1.10      matthew   174:       <p>HTML can be allowed or banned inside of course discussion.</p>
1.1       bowersj2  175:       </message>
                    176:     <choices variable="HTML_ALLOWED">
                    177:       <choice computer=""><b>HTML banned</b>: HTML will not be allowed in discussion postings.</choice>
                    178:       <choice computer="yes"><b>HTML allowed</b>: Discussion participants can use limited HTML in their postings.</choice>
1.3       bowersj2  179:       <defaultvalue>
                    180:         return &{$helper->{DATA}->{GETVAL}}('allow_limited_html_in_feedback');
                    181:       </defaultvalue>
                    182:       <finalcode>
                    183:         if (&{$helper->{DATA}->{SETVAL}}('allow_limited_html_in_feedback', $element->getValue())) {
                    184:           if ($element->getValue() eq 'yes') {
                    185:             return 'Limited HTML allowed in feedback.';
                    186:           } else {
                    187:             return 'HTML not allowed in feedback.';
                    188:           }
                    189:         }
                    190:         </finalcode>
1.1       bowersj2  191:       </choices>
1.2       bowersj2  192:     </state>
                    193: 
1.3       bowersj2  194:   <state name="FEEDBACK_ADDRESSES" title="Feedback Addresses for Course Content">
1.18      raeburn   195:     <message nextstate="USERS_ALLOWED_TO_CLONE">
1.10      matthew   196:       Course members can provide feedback about the course. You can choose
                    197:       who will receive the feedback, such as a different instructor or a
                    198:       TA. Please enter their LON-CAPA address below, in the
1.3       bowersj2  199:       form <b>user:domain</b>, where &quot;user&quot; and &quot;domain&quot;
                    200:       are both the LON-CAPA username and LON-CAPA domain, not an email
                    201:       address.</p> 
                    202:       </message>
1.14      sakharuk  203:     <eval>return &mt('<p>Your current LON-CAPA domain is &quot;<b>[_1]</b>&quot;.</p>',"$helper->{DATA}->{DOM}"); 
1.3       bowersj2  204:       </eval>
                    205:     <string variable='feedback_addresses' size='60' >
                    206:       <defaultvalue>
                    207:         return &{$helper->{DATA}->{GETVAL}}('comment.email');
                    208:       </defaultvalue>
                    209:       <finalcode>
                    210:         if (&{$helper->{DATA}->{SETVAL}}('comment.email', $element->getValue())) {
                    211:           return 'Comment address(es) updated to <b>' . $element->getValue() . 
                    212:                  '</b>.';
                    213:         }
                    214:         </finalcode>
                    215:       </string>
                    216:     <message>
1.10      matthew   217:       <p><b>Advanced</b>: You can send the feedback from different sections
                    218:          to different people, by doing the following:</p>
1.3       bowersj2  219: 
1.11      bowersj2  220:       <ul><li>Separate each entry with a comma.</li>
1.3       bowersj2  221:           <li>To send feedback to a certain address for different sections,
1.11      bowersj2  222:               append the section name or names (separated by semi-colons)
1.3       bowersj2  223:               in a parenthesized list after the <b>user:domain</b>.</li></ul>
                    224: 
                    225:       <p>For example,</p>
                    226: 
                    227:       <p><b>john102:msu(001;002;003),bob293:msu(004;005;006),madeupname:here(007;008;009)</b></p>
                    228: 
                    229:       <p>will route course feedback to &quot;john102&quot; for sections 1, 2, and 3, to
                    230:          &quot;bob293&quot; for 4, 5, and 6, and to &quot;madeupname:here&quot; for
                    231:          7, 8, and 9. Note there is no requirement that the addresses be in any
                    232:          particular domain.</p>
                    233:       </message>
                    234:     </state>
1.2       bowersj2  235: 
1.18      raeburn   236:   <state name="USERS_ALLOWED_TO_CLONE" title="Granting permission to clone course">
                    237:    <message nextstate="FINAL"> 
                    238:       Existing courses can be cloned when creating new courses.<br />Cloning will copy the course structure, contents, and most parameters (automatically advancing any date parameters by six months).<br /><br />
                    239:       Names of owners of other courses permitted to clone this course:<br />
                    240:    </message>
                    241:    <string variable='can_clone' size='60' >
                    242:     <defaultvalue>
                    243:      return &{$helper->{DATA}->{GETVAL}}('cloners');
                    244:     </defaultvalue>
                    245:     <validator>
                    246:       my ($output,@cloners,%disallowed);
                    247:       my $match_dom = $LONCAPA::match_domain;
                    248:       my $match_uname = $LONCAPA::match_username; 
                    249:       if ($val =~ /,/) {
                    250:           @cloners = split(/,/,$val);
                    251:       } else {
                    252:           $cloners[0] = $val;
                    253:       }
                    254:       foreach my $item (@cloners) {
1.21    ! albertel  255: 	  next if ($item =~ /^\s*$/);
        !           256: 	  next if ($item eq '*');
        !           257:        
        !           258: 	  my ($clname,$cldom) = split(/:/,$item);
        !           259: 	  if ($clname eq '*') {
        !           260: 	      if ($cldom =~ /^$match_dom$/) {
        !           261: 		  if (!&Apache::lonnet::domain($cldom)) {
        !           262: 		      $disallowed{'domain'} .= $item.',';
        !           263: 		  }
        !           264: 	      } else {
        !           265: 		  $disallowed{'format'} .= $item.',';
        !           266: 	      }
        !           267: 	  } elsif ($item !~/^($match_uname)\:($match_dom)$/) {
        !           268: 	      $disallowed{'format'} .= $item.',';
        !           269: 	  } else {
        !           270: 	      if (!&Apache::lonnet::domain($cldom)) {
        !           271: 		  $disallowed{'domain'} .= $item.','; 
        !           272: 	      } elsif (&Apache::lonnet::homeserver($clname,$cldom) eq 'no_host') {
        !           273: 		  $disallowed{'newuser'} .= $item.',';
        !           274: 	      }
        !           275: 	  }
1.18      raeburn   276:       }
                    277:       foreach my $key (keys(%disallowed)) {
                    278:           $disallowed{$key} =~ s/,$//;
                    279:       }
                    280:       if (keys(%disallowed) > 0) {
                    281:           $output.= 'Your input contained the following errors:<ul>';
                    282:           if (defined($disallowed{'format'})) {
                    283:               $output  .= '<li>Invalid format: '.
                    284:                           '<b>'.$disallowed{'format'}.'</b></li>';
                    285:           }
                    286:           if (defined($disallowed{'domain'})) {
                    287:               $output .= '<li>Domain(s) do(es) not exist: '.
                    288:                           '<b>'.$disallowed{'domain'}.'</b></li>';
                    289:           }
                    290:           if (defined($disallowed{'newuser'})) {
                    291:               $output .= '<li>LON-CAPA user(s) do(es) not exist: '.
                    292:                          '<b>'.$disallowed{'newuser'}.'</b></li>';
                    293:           }
1.21    ! albertel  294:           $output .= '</ul>';
1.18      raeburn   295:       }
                    296:       return $output;
                    297:     </validator>
                    298:     <finalcode>
                    299:      if (&{$helper->{DATA}->{SETVAL}}('cloners', $element->getValue())) {
                    300: 
                    301: 
                    302:        return 'Users allowed to clone course updated to <b>' . $element->getValue() .
                    303:                  '</b>.';
                    304:      }
                    305:     </finalcode>
                    306:    </string>
                    307:    <message>
                    308:     <br />(Course Coordinators automatically have the right to clone their own courses.)
                    309:     <ul>
                    310:      <li>Format: <b>user:domain</b>, where &quot;user&quot; and &quot;domain&quot;
                    311:       are the LON-CAPA username and domain of the user.</li><li>Separate different users with a comma.</li><li>Use *:domain to allow course to be cloned by any course owner in the specified domain.</li><li>Use * to allow unrestricted cloning by all course owners in all domains.</li></ul>
                    312:    </message>
                    313:   </state>
1.2       bowersj2  314:   <state name="FINAL" title="Completed">
1.3       bowersj2  315:     <message>Your course is now set up. Please select the <b>Finish Course 
                    316:       Initialization</b> button to re-intialize the course with your chosen
1.7       bowersj2  317:       settings.
1.3       bowersj2  318: 
                    319:       <p>Remember that all of these settings can be modified in the <b>PARMS</b>
                    320:          screen, by pushing the <b>Course Environment</b> button.</p>
                    321:       </message>
1.13      bowersj2  322:     <condition>
1.15      albertel  323:       <clause>$env{'course.'.$env{'request.course.id'}.'.clonedfrom'}</clause>
1.13      bowersj2  324:       <message>After you select <b>Finish Course Initialization</b>,
                    325:                you will be taken to the Parameter Overview screen to
                    326:                update the dates for this cloned course.</message>
                    327:     </condition>
1.3       bowersj2  328:     <final restartCourse='1' />
1.1       bowersj2  329:     </state>
                    330:   </helper>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>