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

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
1.28    ! raeburn    52:          by going to the &quot;Modify parameter settings&quot; screen and clicking on the &quot;Course Configuration&quot; button.</p>
1.1       bowersj2   53: 
1.10      matthew    54:       <p>If you do not have experience coordinating LON-CAPA courses or if you
1.27      bisitz     55:          prefer the Helper interface, please click &quot;Next&quot;.</p>
1.1       bowersj2   56:       </message>
                     57:     </state>
                     58: 
1.22      biermanm   59:   <state name="COURSE_DESCRIPTION" title="Course Title">
1.12      matthew    60:     <message nextstate="FORBID_CHAT">
1.22      biermanm   61:       The &quot;Course Title&quot; is the name of the course that will be
1.10      matthew    62:       seen by the students.  You may now modify the description and hit 
1.27      bisitz     63:       &quot;Next&quot; to continue.<br />
1.3       bowersj2   64:       </message>
                     65:     <string variable='description' size='60' >
                     66:       <defaultvalue>
                     67:         return &{$helper->{DATA}->{GETVAL}}('description');
                     68:       </defaultvalue>
                     69:       <finalcode>
                     70:         if (&{$helper->{DATA}->{SETVAL}}('description', $element->getValue())) {
                     71:           return 'Course description changed to <b>' . $element->getValue() . 
                     72:                  '</b>.';
                     73:         }
                     74:         </finalcode>
                     75:       </string>
1.12      matthew    76:     </state>
                     77: 
1.24      hauer      78:   <state name="FORBID_CHAT" title="Chat Room Participation">
1.12      matthew    79:     <message nextstate="FORBID_DISCUSSION">
1.24      hauer      80:       <p>LON-CAPA has chat room functionality. This course will receive
                     81:          its own chat room. You may deny students, TAs, or instructors
1.12      matthew    82:          the right to access the chat room.</p>
                     83:       </message>
                     84:     <choices variable="BANNED_CHAT_ROLES" multichoice="1" allowempty='1'>
                     85:       <choice computer="st"><b>Students</b> - students will not be able to use or view the chat room.</choice>
                     86:       <choice computer="ta"><b>Teaching Assistants</b> - teaching assistants will not be able use or view the chat room</choice>
                     87:       <choice computer="in"><b>Instructor</b> - instructors will not be able to use or view the chat room</choice>
                     88:       <defaultvalue>
1.16      albertel   89:         my $denied = &{$helper->{DATA}->{GETVAL}}('plc.roles.denied');
1.12      matthew    90:         $denied =~ s/,/\|\|\|/g;
                     91:         return $denied;
                     92:       </defaultvalue>
                     93:       <finalcode>
                     94:         my $denied = $element->getValue();
                     95:         $denied =~ s/\|\|\|/,/g;
                     96:         if (&{$helper->{DATA}->{SETVAL}}('plc.roles.denied', $denied)) {
                     97:             $denied =~ s/st/ students/;
                     98:             $denied =~ s/in/ instructors/;
                     99:             $denied =~ s/ta/ teaching assistants/;
                    100:             $denied =~ s/ep/ exam proctors/;
                    101:             if ($denied =~ /^[^,]*,[^,]*$/) { # only one comma
                    102:                 $denied =~ s/,/ and/g;
                    103:             } else { # add "and" to last comma
                    104:                 $denied =~ s/,([^,]*)$/, and\1/;
                    105:             }
                    106:             if ($denied) {
1.25      hauer     107:                 $denied = substr($denied, 1) . ' not allowed to participate in chat room.';
1.12      matthew   108:                 $denied = ucfirst($denied);
                    109:             } else {
1.25      hauer     110:                 $denied = 'Everyone can participate in chat room.';
1.12      matthew   111:             }
                    112:             return $denied;
                    113:         } else {
                    114:             return '';
                    115:         }
                    116:       </finalcode>
                    117:       </choices>
1.3       bowersj2  118:     </state>
                    119: 
1.1       bowersj2  120:   <state name="FORBID_DISCUSSION" title="Discussion Participation">
                    121:     <message nextstate="DISCUSSION_HTML">
1.2       bowersj2  122:          LON-CAPA hosts discussions on all resources in a course. By default,
                    123:          all users are allowed to participate in these discussions.
1.1       bowersj2  124: 
1.8       bowersj2  125:       <p>If you do not wish certain types of users to be able to use the 
                    126:          discussion features, select those types below. Note your class
1.2       bowersj2  127:          may not have all of these roles; you may safely ignore roles you
                    128:          do not intend to use. (For instance, &quot;Exam Proctor&quot; is
                    129:          generally useful only for large courses.)</p>
1.1       bowersj2  130: 
1.8       bowersj2  131:       <p>Types of users not allowed to participate in discussion can
1.9       bowersj2  132:          still view any discussion that other users post.</p>
1.8       bowersj2  133: 
1.1       bowersj2  134:       </message>
1.2       bowersj2  135:     <choices variable="BANNED_DISCUSSION_ROLES" multichoice="1" allowempty='1'>
1.1       bowersj2  136:       <choice computer="st"><b>Students</b> - students will not be able to participate in discussions</choice>
                    137:       <choice computer="ta"><b>Teaching Assistants</b> - teaching assistants will not be able to participate in discussions</choice>
                    138:       <choice computer="in"><b>Instructor</b> - instructors will not be able to participate in discussions</choice>
1.2       bowersj2  139:       <defaultvalue>
                    140:         my $denied = &{$helper->{DATA}->{GETVAL}}('pch.roles.denied');
                    141:         $denied =~ s/,/\|\|\|/g;
                    142:         return $denied;
                    143:       </defaultvalue>
                    144:       <finalcode>
                    145:         my $denied = $element->getValue();
                    146:         $denied =~ s/\|\|\|/,/g;
                    147:         if (&{$helper->{DATA}->{SETVAL}}('pch.roles.denied', $denied)) {
                    148:             $denied =~ s/st/ students/;
                    149:             $denied =~ s/in/ instructors/;
                    150:             $denied =~ s/ta/ teaching assistants/;
                    151:             $denied =~ s/ep/ exam proctors/;
                    152:             if ($denied =~ /^[^,]*,[^,]*$/) { # only one comma
                    153:                 $denied =~ s/,/ and/g;
                    154:             } else { # add "and" to last comma
                    155:                 $denied =~ s/,([^,]*)$/, and\1/;
                    156:             }
                    157:             if ($denied) {
                    158:                 $denied = substr($denied, 1) . ' not allowed to participate in discussion.';
                    159:                 $denied = ucfirst($denied);
                    160:             } else {
                    161:                 $denied = 'Everyone can participate in discussion.';
                    162:             }
                    163:             return $denied;
                    164:         } else {
                    165:             return '';
                    166:         }
                    167:       </finalcode>
1.1       bowersj2  168:       </choices>
                    169:     </state>
                    170: 
                    171:   <state name="DISCUSSION_HTML" title="HTML in Discussions">
1.3       bowersj2  172:     <message nextstate="FEEDBACK_ADDRESSES">
1.10      matthew   173:       <p>HTML can be allowed or banned inside of course discussion.</p>
1.1       bowersj2  174:       </message>
                    175:     <choices variable="HTML_ALLOWED">
                    176:       <choice computer=""><b>HTML banned</b>: HTML will not be allowed in discussion postings.</choice>
                    177:       <choice computer="yes"><b>HTML allowed</b>: Discussion participants can use limited HTML in their postings.</choice>
1.3       bowersj2  178:       <defaultvalue>
                    179:         return &{$helper->{DATA}->{GETVAL}}('allow_limited_html_in_feedback');
                    180:       </defaultvalue>
                    181:       <finalcode>
                    182:         if (&{$helper->{DATA}->{SETVAL}}('allow_limited_html_in_feedback', $element->getValue())) {
                    183:           if ($element->getValue() eq 'yes') {
                    184:             return 'Limited HTML allowed in feedback.';
                    185:           } else {
                    186:             return 'HTML not allowed in feedback.';
                    187:           }
                    188:         }
                    189:         </finalcode>
1.1       bowersj2  190:       </choices>
1.2       bowersj2  191:     </state>
                    192: 
1.3       bowersj2  193:   <state name="FEEDBACK_ADDRESSES" title="Feedback Addresses for Course Content">
1.18      raeburn   194:     <message nextstate="USERS_ALLOWED_TO_CLONE">
1.10      matthew   195:       Course members can provide feedback about the course. You can choose
                    196:       who will receive the feedback, such as a different instructor or a
                    197:       TA. Please enter their LON-CAPA address below, in the
1.3       bowersj2  198:       form <b>user:domain</b>, where &quot;user&quot; and &quot;domain&quot;
1.23      schafran  199:       are both the LON-CAPA username and LON-CAPA domain, not an e-mail
1.3       bowersj2  200:       address.</p> 
                    201:       </message>
1.27      bisitz    202:     <eval>return '<p>'.&mt('Your current LON-CAPA domain is [_1].','&quot;<b>'.$helper->{DATA}->{DOM}.'</b>&quot;').'</p>'; 
1.3       bowersj2  203:       </eval>
                    204:     <string variable='feedback_addresses' size='60' >
                    205:       <defaultvalue>
                    206:         return &{$helper->{DATA}->{GETVAL}}('comment.email');
                    207:       </defaultvalue>
                    208:       <finalcode>
                    209:         if (&{$helper->{DATA}->{SETVAL}}('comment.email', $element->getValue())) {
                    210:           return 'Comment address(es) updated to <b>' . $element->getValue() . 
                    211:                  '</b>.';
                    212:         }
                    213:         </finalcode>
                    214:       </string>
                    215:     <message>
1.10      matthew   216:       <p><b>Advanced</b>: You can send the feedback from different sections
                    217:          to different people, by doing the following:</p>
1.3       bowersj2  218: 
1.11      bowersj2  219:       <ul><li>Separate each entry with a comma.</li>
1.3       bowersj2  220:           <li>To send feedback to a certain address for different sections,
1.11      bowersj2  221:               append the section name or names (separated by semi-colons)
1.3       bowersj2  222:               in a parenthesized list after the <b>user:domain</b>.</li></ul>
                    223: 
                    224:       <p>For example,</p>
                    225: 
                    226:       <p><b>john102:msu(001;002;003),bob293:msu(004;005;006),madeupname:here(007;008;009)</b></p>
                    227: 
                    228:       <p>will route course feedback to &quot;john102&quot; for sections 1, 2, and 3, to
                    229:          &quot;bob293&quot; for 4, 5, and 6, and to &quot;madeupname:here&quot; for
                    230:          7, 8, and 9. Note there is no requirement that the addresses be in any
                    231:          particular domain.</p>
                    232:       </message>
                    233:     </state>
1.2       bowersj2  234: 
1.18      raeburn   235:   <state name="USERS_ALLOWED_TO_CLONE" title="Granting permission to clone course">
                    236:    <message nextstate="FINAL"> 
1.27      bisitz    237:       Existing courses can be cloned when creating new courses.<br />
                    238:       Cloning will copy the course structure, contents, and most parameters (automatically advancing any date parameters by six months).<br /><br />
                    239:       Usernames of owners of other courses permitted to clone this course:<br />
1.18      raeburn   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;
1.27      bisitz    311:       are the LON-CAPA username and domain of the user.</li>
                    312:      <li>Separate different users with a comma.</li>
                    313:      <li>Use *:domain to allow course to be cloned by any course owner in the specified domain.</li>
                    314:      <li>Use * to allow unrestricted cloning by all course owners in all domains.</li>
                    315:     </ul>
1.18      raeburn   316:    </message>
                    317:   </state>
1.2       bowersj2  318:   <state name="FINAL" title="Completed">
1.26      bisitz    319:     <message>Your course is now set up. Please select the <b>Save</b>
                    320:       button to re-intialize the course with your chosen
1.7       bowersj2  321:       settings.
1.3       bowersj2  322: 
1.28    ! raeburn   323:       <p>Remember that all of these settings can be modified in the <b>Modify parameter settings</b>
1.26      bisitz    324:          screen (<b>Course Configuration</b>).</p>
1.3       bowersj2  325:       </message>
1.13      bowersj2  326:     <condition>
1.15      albertel  327:       <clause>$env{'course.'.$env{'request.course.id'}.'.clonedfrom'}</clause>
1.13      bowersj2  328:       <message>After you select <b>Finish Course Initialization</b>,
                    329:                you will be taken to the Parameter Overview screen to
                    330:                update the dates for this cloned course.</message>
                    331:     </condition>
1.3       bowersj2  332:     <final restartCourse='1' />
1.1       bowersj2  333:     </state>
                    334:   </helper>

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