@@ -17,47 +17,71 @@ <h3>{{=message}}</h3>
1717 function validateForm ( ) {
1818 var x = document . forms [ "mainform" ] [ "projectname" ] . value ;
1919 var basecourse = document . forms [ "mainform" ] [ "coursetype" ] . value ;
20-
21- if ( x == "" || x . indexOf ( " " ) !== - 1 || x . indexOf ( "/" ) > - 1 ) {
22- alert ( 'Error: Your Project Name may not contain spaces or /' )
23- return false ;
24- }
25-
26- if ( ! / ^ ( [ \x30 - \x39 ] | [ \x41 - \x5A ] | [ \x61 - \x7A ] | [ _ - ] ) * $ / . test ( x ) ) {
27- alert ( "Error: Your project name can only contain ASCII letters digits and - or _" ) ;
28- return false ;
29- }
20+ let instid = document . forms [ "mainform" ] [ "institution" ] . value ;
21+ let level = document . forms [ "mainform" ] [ "courselevel" ] . value ;
22+
3023
3124 if ( basecourse == "" ) {
3225 alert ( 'Error: You must select a book for your course' )
3326 return false ;
3427 }
3528
29+ if ( instid == "" ) {
30+ alert ( 'Error: You must provide the name of your Institution. This is used for help your students find the correct course' )
31+ return false ;
32+ }
33+
34+ if ( level == "unknown" ) {
35+ alert ( "Please tell us approximately what level your course is at this is important for recommending questions as well as educational research." )
36+ return false ;
37+ }
38+
39+ if ( x == "" || x . indexOf ( " " ) !== - 1 || x . indexOf ( "/" ) > - 1 ) {
40+ alert ( 'Error: Your Project Name may not contain spaces or /' )
41+ return false ;
42+ }
43+
44+ if ( ! / ^ ( [ \x30 - \x39 ] | [ \x41 - \x5A ] | [ \x61 - \x7A ] | [ _ - ] ) * $ / . test ( x ) ) {
45+ alert ( "Error: Your project name can only contain ASCII letters digits and - or _" ) ;
46+ return false ;
47+ }
48+
49+
3650 unhide_img ( 'spinner' ) ;
3751 return true
3852 }
53+
54+ function suggested_course_name ( ) {
55+ let d = new Date ( ) ;
56+ const getSeason = d => Math . floor ( ( ( d . getMonth ( ) + 1 ) / 12 * 4 ) ) % 4
57+ let season = [ 'winter' , 'spring' , 'summer' , 'fall' ] [ getSeason ( d ) ]
58+
59+ var basecourse = document . forms [ "mainform" ] [ "coursetype" ] . value ;
60+ let instid = document . forms [ "mainform" ] [ "institution" ] . value ;
61+ let suggestedCourse = ""
62+
63+ if ( instid ) {
64+ suggestedCourse += instid . toLowerCase ( ) ;
65+ }
66+ if ( basecourse ) {
67+ suggestedCourse += "_" + basecourse . toLowerCase ( ) ;
68+ }
69+ suggestedCourse += "_" + season + ( d . getYear ( ) - 100 )
70+
71+ document . forms [ "mainform" ] [ "projectname" ] . value = suggestedCourse ;
72+
73+ }
74+
75+
3976</ script >
4077< div class ="col-md-7 ">
4178 < form name ="mainform " action ="/{{=request.application}}/{{=request.controller}}/build " method ="get " onsubmit ="return validateForm(); ">
42- < div class ="form-group row ">
43- < div class ="col-md-4 ">
44- < label for ="projectname "> Course Name</ label >
45- < input type ="text " class ="form-control " placeholder ="myproject " name ="projectname " id ="projectname " />
46- </ div >
47- </ div >
48- < p > This will be the name your students use when they register. Make it one word, short (no spaces)</ p >
49- < div class ="form-group row ">
50- < div class ="col-md-6 ">
51- < label for ="projectdescription "> Description</ label >
52- < input type ="text " class ="form-control " placeholder ="Enter a short description " name ="projectdescription " id ="projectdescription " />
53- </ div >
54- </ div >
5579
5680 < div class ="form-group row ">
5781 < div class ="col-md-6 ">
58- < label for ="institution "> Institution</ label >
59- < input type ="text " class ="form-control " placeholder ="Your school " name ="institution " id ="institution " />
60- < label for ="courselevel "> Course Level</ label >
82+ < label for ="institution "> Institution (required) </ label >
83+ < input type ="text " class ="form-control " placeholder ="Your school " name ="institution " id ="institution " onchange =" suggested_course_name() " />
84+ < label for ="courselevel "> Course Level (required) </ label >
6185 < select id ="courselevel " class ="form-control " name ="courselevel ">
6286 < option value ="unknown " disabled selected > Please Select</ option >
6387 < option value ="grad "> Graduate</ option >
@@ -346,9 +370,31 @@ <h3>Math Books</h3>
346370 </label>
347371 </div> -->
348372 </ div >
373+ < script >
374+ var rad = document . forms . mainform . coursetype ;
375+ var prev = null ;
376+ for ( var i = 0 ; i < rad . length ; i ++ ) {
377+ rad [ i ] . addEventListener ( 'change' , suggested_course_name ) ;
378+ }
379+ </ script >
349380
350381 < br />
351382
383+ < p > This is our < strong > suggestion</ strong > for your course name it will be the name your students use when they register. Feel free to change it if it does not work for you.</ p >
384+ < div class ="form-group row ">
385+ < div class ="col-md-6 ">
386+ < label for ="projectname "> Course Name</ label >
387+ < input type ="text " class ="form-control " placeholder ="myproject " name ="projectname " id ="projectname " size ="50 " />
388+ </ div >
389+ </ div >
390+
391+ < div class ="form-group row ">
392+ < div class ="col-md-6 ">
393+ < label for ="projectdescription "> Description</ label >
394+ < input type ="text " class ="form-control " placeholder ="Enter a short description " name ="projectdescription " id ="projectdescription " />
395+ </ div >
396+ </ div >
397+
352398 < div class ="form-group ">
353399 < div class ="checkbox ">
354400 < label >
0 commit comments