/* ** Used by instructor to create a class session of a catalog ** Class: CreateClass ** Author: Yuping Zhu ** Date: 12-01-1999 */ package ascdb.courses; import oracle.html.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import ascdb.conf; import ascdb.users.UserValidation; public class CreateClass extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // Output HTML page header res.setContentType("text/html"); PrintWriter out = res.getWriter(); conf dbconf= new conf(req); String uid = req.getParameter("uid"); String cidStr = req.getParameter("cid"); int cid = (new Integer(cidStr)).intValue(); UserValidation UserV = new UserValidation(); try { // Create an HtmlBody Object HtmlBody bd = new HtmlBody(); // Sets various attributes of HtmlBody bd.setBackgroundColor("#fffff2"); Font f = new Font(Color.olive,"myfont","+5"); int TabRow = UserV.Validation(req); if (TabRow < 5) { out.println("You do not have this privilege!"); out.println(BackMainHome()); return; } HtmlStringBuffer HTMLBuf = new HtmlStringBuffer(); HTMLBuf.appendln(""); HTMLBuf.appendln(""); HTMLBuf.appendln("Create a new Class"); //Create a JavaScript Object Script js = new Script("JavaScript"); js.setCode("function Validation(form) {\n" + " if (form.copres[0].checked) {\n" + " var fg = 0\n" + " if (form.copresex.value.length == 0) \n" + " fg = 1 \n" + " var coName = form.copresex.value\n" + " while (coName.charCodeAt(0) == 32)\n" + " coName = coName.substring(1)\n" + " if (coName.length == 0) \n" + " fg = 1\n" + " if (fg == 0) return true\n" + " alert(\"You must give the names of your co-presentors.\")\n" + " return false\n" + " }\n" + "}\n"); HTMLBuf.append(js); HTMLBuf.appendln(""); HTMLBuf.appendln("
"); bd .addItem(new SimpleItem(f.toHTML())) .addItem(new SimpleItem("Create a new Class").setBold().setCenter()) .addItem(SimpleItem.Paragraph); Font bf = new Font(Color.black,null,"+1"); bd.addItem(new SimpleItem(bf.toHTML())); bd .addItem(new SimpleItem("All inputs are required...").setBold().setFontColor(Color.red)) .addItem(SimpleItem.HorizontalRule) .addItem(SimpleItem.LineBreak); bd .addItem(new SimpleItem("Will you require use of our system? ").setBold().setFontColor(Color.black)) .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem("Yes")) .addItem(new Radio("system","Y")) .addItem(new SimpleItem("No")) .addItem(new Radio("system","N",true)) .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem("Do you need materials handed out to students or files loaded into the student accounts for use during the class? ").setBold().setFontColor(Color.black)) .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem("Yes")) .addItem(new Radio("stuff","Y")) .addItem(new SimpleItem("No")) .addItem(new Radio("stuff","N",true)) .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem("Do we have your permission to video tape this class? ").setBold().setFontColor(Color.black)) .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem("Yes")) .addItem(new Radio("tape","Y")) .addItem(new SimpleItem("No")) .addItem(new Radio("tape","N",true)) .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem("Do we have your permission to use this class on our website? ").setBold().setFontColor(Color.black)) .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem("Yes")) .addItem(new Radio("web","Y")) .addItem(new SimpleItem("No")) .addItem(new Radio("web","N",true)) .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem("What is the beginning date of class? ").setBold().setFontColor(Color.black)) .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem("Day: ").setBold().setFontColor(Color.black)); Select day = new Select("dd"); for (int i=1; i<32; i++) day.addOption(new Option((new Integer(i)).toString())); Select mon = new Select("mm"); mon .addOption(new Option("Jan")) .addOption(new Option("Feb")) .addOption(new Option("Mar")) .addOption(new Option("Apr")) .addOption(new Option("May")) .addOption(new Option("Jun")) .addOption(new Option("Jul")) .addOption(new Option("Aug")) .addOption(new Option("Sep")) .addOption(new Option("Oct")) .addOption(new Option("Nov")) .addOption(new Option("Dec")); Select year = new Select("yy"); year .addOption(new Option("2000")) .addOption(new Option("2001")) .addOption(new Option("2002")); bd .addItem(day) .addItem(new SimpleItem("Month: ").setBold().setFontColor(Color.black)) .addItem(mon) .addItem(new SimpleItem("Year: ").setBold().setFontColor(Color.black)) .addItem(year) .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem("Do you have any co-presentors? ").setBold().setFontColor(Color.black)) .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem("Yes")) .addItem(new Radio("copres","Y")) .addItem(new SimpleItem("No")) .addItem(new Radio("copres","N",true)) .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem("Note: They will also have to register, but please provide their names: ").setBold().setFontColor(Color.black)) .addItem(SimpleItem.LineBreak) .addItem(new TextField("copresex",50,32,"")) .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem("Insturctor: ").setBold().setFontColor(Color.black)); // Load the Oracle JDBC driver Class.forName (dbconf.JdbcDriver); // Connect to the database Connection conn = DriverManager.getConnection (dbconf.ConnectStr,dbconf.DBName,dbconf.DBPassword); // Create a Statement Statement stmt = conn.createStatement (); ResultSet inst = stmt.executeQuery("select oracle_uid, last_nam, first_nam from users where purpose='Instructor' or purpose='Administraor'"); Select Teacher = new Select("instructor"); while (inst.next()) if ((inst.getString(1)).equals(uid)) Teacher.addOption(new Option(inst.getString(3) + " " + inst.getString(2), inst.getString(3) + " " + inst.getString(2),true)); else Teacher.addOption(new Option(inst.getString(3) + " " + inst.getString(2))); bd .addItem(Teacher) .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem("Do you prefer using the classroom or the Scientific Visualization Lab? (There is a maximum of 20 available workstations in the classroom and 7 in the Sci-Vis Lab) ").setBold().setFontColor(Color.black)); Select Croom = new Select("room"); Croom .addOption(new Option("Rm105")) .addOption(new Option("SciVis")); ResultSet courseInfo = stmt.executeQuery("select * from catalog where course_id = " + cid); if (! courseInfo.next()) { out.println("The course does not exist in DB!"); out.println(BackMainHome()); return; } bd .addItem(Croom) .addItem(SimpleItem.LineBreak) .addItem(new Hidden("uid",uid)) .addItem(new Hidden("cid",cidStr)) .addItem(new Hidden("size",courseInfo.getString("class_size"))) .addItem(new Submit("submit", "Submit!")) .addItem(new Reset("Reset")); bd.addItem(SimpleItem.HorizontalRule); bd .addItem(new SimpleItem("Course Information").setBold().setFontColor(Color.red)) .addItem(SimpleItem.Paragraph) .addItem(new SimpleItem("Course Number: ").setBold().setFontColor(Color.olive)) .addItem(new SimpleItem(courseInfo.getString("course_num"))) .addItem(SimpleItem.Paragraph) .addItem(new SimpleItem("Course Title: ").setBold().setFontColor(Color.olive)) .addItem(new SimpleItem(courseInfo.getString("title"))) .addItem(SimpleItem.Paragraph) .addItem(new SimpleItem("Course Description: ").setBold().setFontColor(Color.olive)) // .addItem(SimpleItem.LineBreak) .addItem(new SimpleItem(courseInfo.getString("overview"))) .addItem(SimpleItem.Paragraph) .addItem(new SimpleItem("Duration (in days): ").setBold().setFontColor(Color.olive)) .addItem(new SimpleItem(courseInfo.getString("duration"))) .addItem(SimpleItem.Paragraph) .addItem(new SimpleItem("Agenda: ").setBold().setFontColor(Color.olive)) //.addItem(SimpleItem.LineBreak) .addItem(new SimpleItem(courseInfo.getString("agenda"))) .addItem(SimpleItem.Paragraph) .addItem(new SimpleItem("Prerequisites Description: ").setBold().setFontColor(Color.olive)) //.addItem(SimpleItem.LineBreak) .addItem(new SimpleItem(courseInfo.getString("prerequisites"))) .addItem(SimpleItem.Paragraph) .addItem(new SimpleItem("The maximum number of students: ").setBold().setFontColor(Color.olive)) .addItem(new SimpleItem(courseInfo.getString("class_size"))); HTMLBuf.append(bd); out.println(HTMLBuf); } catch(ClassNotFoundException e) { out.println("Can not load JDBC driver!"); } catch(SQLException e) { out.println(e.getMessage()); } } private HtmlStringBuffer BackMainHome() { HtmlStringBuffer BackMain = new HtmlStringBuffer(); BackMain.appendln(""); BackMain.appendln(""); return BackMain; } }