File:  [LON-CAPA] / loncom / html / adm / helper / course.initialization.helper
Revision 1.30: download - view: text, annotated - select for diffs
Sun Mar 14 15:25:47 2010 UTC (14 years, 3 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
Bug 5984.
 - Update entry in nohist_courseids.db when course initialization helper is used to update course description.

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

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