Validation 计算机可用性(UI表单验证)

Validation 计算机可用性(UI表单验证),validation,google-apps-script,tracking,google-sites,Validation,Google Apps Script,Tracking,Google Sites,我创建了一个表格,跟踪某一天注册计算机实验室的学生人数。我的问题是,我想让表单在个人开始注册并且学生人数超过可用计算机数量时生成一条消息,无论是由个人还是与特定日期已注册的人数相结合 我还想让它告诉他们,如果没有填充,实验室里还有多少斑点 我的问题是,我想知道当有太多人注册实验室时,我会添加什么代码来创建一条消息。我不知道从哪里开始,或者如何开始 现在我所做的就是追踪注册人数 //Create the GUI form function doGet() { var app = UiApp.

我创建了一个表格,跟踪某一天注册计算机实验室的学生人数。我的问题是,我想让表单在个人开始注册并且学生人数超过可用计算机数量时生成一条消息,无论是由个人还是与特定日期已注册的人数相结合

我还想让它告诉他们,如果没有填充,实验室里还有多少斑点

我的问题是,我想知道当有太多人注册实验室时,我会添加什么代码来创建一条消息。我不知道从哪里开始,或者如何开始

现在我所做的就是追踪注册人数

//Create the GUI form

function doGet() {
  var app = UiApp.createApplication().setTitle('DHS: Kurzweil Calendar');

  //Create a panel which holds all the form elelemnts
  var vertMainPanel = app.createVerticalPanel().setId('vertMainPanel');

  //Create the form elelemnts
  var lblTeacherName = app.createLabel('Teacher Name:');
  var txtTeacherName = app.createTextBox().setName('txtTeacherName');

  var lblExt = app.createLabel('Ext:');
  var txtExt = app.createTextBox().setName('txtExt');

  var lblDate = app.createLabel('Date:');
  var boxDate = app.createDateBox().setId('boxDate').setName('boxDate');

  var lbxSubject = app.createListBox().setId('lbxSubject').setName('lbxSubject');
        lbxSubject.setVisibleItemCount(5);
        lbxSubject.addItem('-- Select One --');
        lbxSubject.addItem('Algebra I (OCS)');
        lbxSubject.addItem('Algebra II');
        lbxSubject.addItem('Algebra II (Honors)');
        lbxSubject.addItem('Agriscience Applications');
        lbxSubject.addItem('Agriscience Applications (OCS)');
        lbxSubject.addItem('Anatomy and Physiology');
        lbxSubject.addItem('Anatomy and Physiology (Honors)');
        lbxSubject.addItem('Animal Science');
        lbxSubject.addItem('American Sign Language II');
        lbxSubject.addItem('Apparel I');
        lbxSubject.addItem('Art History (AP)');
        lbxSubject.addItem('Advanced Functions and Modeling');
        lbxSubject.addItem('Automotive Computer System Diagnostics');
        lbxSubject.addItem('Automotive Brakes');
        lbxSubject.addItem('Automotive Service');
        lbxSubject.addItem('Automotive Service (OCS)'); 
        lbxSubject.addItem('Benchmarks');
        lbxSubject.addItem('Bible History');
        lbxSubject.addItem('Biology');
        lbxSubject.addItem('Biology (AP)');
        lbxSubject.addItem('Biology (Honors)');
        lbxSubject.addItem('Biology (OCS)');
        lbxSubject.addItem('Biomedical Technology');
        lbxSubject.addItem('Biotechnology and Agriscience');
        lbxSubject.addItem('Calculus AB (AP)');
        lbxSubject.addItem('Calculus BC (AP)');
        lbxSubject.addItem('Carpentry I');
        lbxSubject.addItem('Carpentry I (OCS)');
        lbxSubject.addItem('Carpentry III');
        lbxSubject.addItem('Chemistry');
        lbxSubject.addItem('Chemistry (AP)');
        lbxSubject.addItem('Chemistry (Honors)');
        lbxSubject.addItem('Choral Arts (Beginning)');
        lbxSubject.addItem('Civics and Economics');
        lbxSubject.addItem('Civics and Economics (Honors)');
        lbxSubject.addItem('Computer Programming I');
        lbxSubject.addItem('Computer Science (AP)');
        lbxSubject.addItem('Computer Technology');
        lbxSubject.addItem('Concert Band II (Beginning)');        
        lbxSubject.addItem('Concert Band II (Proficient)');
        lbxSubject.addItem('Core and Sustainable Construction');
        lbxSubject.addItem('Core and Sustainable Construction (OCS)');
        lbxSubject.addItem('Digital Media I');
        lbxSubject.addItem('Digitial Media I (OCS)');
        lbxSubject.addItem('Digital Media II');
        lbxSubject.addItem('Discrete Mathematics');
        lbxSubject.addItem('Drafting I');
        lbxSubject.addItem('Drafting Architecture II (Honors)');
        lbxSubject.addItem('Drafting Architecture III (Honors)');
        lbxSubject.addItem('Earth and Environmental Science');
        lbxSubject.addItem('Earth and Environmental Sceince (AP)');
        lbxSubject.addItem('Earth and Environmental Science (Honors)');
        lbxSubject.addItem('Early Childhood Ed I');
        lbxSubject.addItem('eCommerce I (Honors)');
        lbxSubject.addItem('English I');
        lbxSubject.addItem('English I (Honors)');
        lbxSubject.addItem('English II');        
        lbxSubject.addItem('English II (Honors)');
        lbxSubject.addItem('English II (OCS)');
        lbxSubject.addItem('English III');
        lbxSubject.addItem('English III (Honors)');
        lbxSubject.addItem('English III (OCS)');
        lbxSubject.addItem('English IV');
        lbxSubject.addItem('English IV (Honors)');
        lbxSubject.addItem('English IV (OCS)');
        lbxSubject.addItem('English Lang and Comp (AP)');
        lbxSubject.addItem('English Language Arts II');
        lbxSubject.addItem('English Language Arts III');
        lbxSubject.addItem('Engish Literature (AP)');
        lbxSubject.addItem('European History (AP)');
        lbxSubject.addItem('Fashion Merchandising');
        lbxSubject.addItem('Financial Management (OCS)');
        lbxSubject.addItem('Foods I');
        lbxSubject.addItem('Foods I (OCS)');
        lbxSubject.addItem('Foods II - Enterprise');
        lbxSubject.addItem('Foods II - Advanced (OCS)');
        lbxSubject.addItem('French I');
        lbxSubject.addItem('French II');
        lbxSubject.addItem('French III (Honors)');
        lbxSubject.addItem('Functional Finances');
        lbxSubject.addItem('Geometry'); 
        lbxSubject.addItem('Geometry (Honors)');
        lbxSubject.addItem('German I');
        lbxSubject.addItem('German II');
        lbxSubject.addItem('German III (Honors)');
        lbxSubject.addItem('Health and Physical Education');
        lbxSubject.addItem('Health Sciences (Advanced Studies)');
        lbxSubject.addItem('Health Team Relations');
        lbxSubject.addItem('Human Geography (AP)');
        lbxSubject.addItem('Holocaust and Peace Studies');
        lbxSubject.addItem('Horticulture I');
        lbxSubject.addItem('Horticulture I (OCS)');
        lbxSubject.addItem('Horticulture II');
        lbxSubject.addItem('Horticulture II (OCS)');
        lbxSubject.addItem('Integrated Math I');
        lbxSubject.addItem('Interior Design I');
        lbxSubject.addItem('Introduction to Math');
        lbxSubject.addItem('Japanese I');
        lbxSubject.addItem('JROTC I');
        lbxSubject.addItem('JROTC II');
        lbxSubject.addItem('JROTC III');
        lbxSubject.addItem('JROTC IV');
        lbxSubject.addItem('Latin I');
        lbxSubject.addItem('Latim II');
        lbxSubject.addItem('Latin III (Honors)');
        lbxSubject.addItem('Leadership Development');
        lbxSubject.addItem('Marketing Management');
        lbxSubject.addItem('Masonry I');
        lbxSubject.addItem('Masonry I (OCS)');
        lbxSubject.addItem('Masonry III');
        lbxSubject.addItem('Microsoft Excel and Access');
        lbxSubject.addItem('Microsoft Word PowerPoint and Publisher');
        lbxSubject.addItem('Multimedia and Webpage Design');
        lbxSubject.addItem('Music Business and Recording (Beginning)');
        lbxSubject.addItem('Occupational Preparations I');
        lbxSubject.addItem('Occupational Preparations II');
        lbxSubject.addItem('Occupational Preparations III');
        lbxSubject.addItem('Occupational Preparations IV');
        lbxSubject.addItem('Parent and Child Development');        
        lbxSubject.addItem('Parent and Child Development (OCS)');
        lbxSubject.addItem('Personal Finance');        
        lbxSubject.addItem('Personal Finance (OCS)');
        lbxSubject.addItem('Physical Science');
        lbxSubject.addItem('Physics (Honors)');
        lbxSubject.addItem('Pre-Calculus (Honors)');
        lbxSubject.addItem('Professional Management and Leadership I');
        lbxSubject.addItem('Professional Management and Leadership II');
        lbxSubject.addItem('Psychology');
        lbxSubject.addItem('Physcology (AP)');
        lbxSubject.addItem('Psychology (Honors)');
        lbxSubject.addItem('SAT Preparation');
        lbxSubject.addItem('Science and Technical Visualization I');
        lbxSubject.addItem('Science and Technical Visualization II');
        lbxSubject.addItem('Social Studies (OCS)');
        lbxSubject.addItem('Spanish I');
        lbxSubject.addItem('Spanish II');
        lbxSubject.addItem('Spanish III (Honors)');
        lbxSubject.addItem('Spanish IV (Honors)');
        lbxSubject.addItem('Special Topics of Mathematics');
        lbxSubject.addItem('Symphonic Band II (Beginning)');
        lbxSubject.addItem('Symphonic Band II (Intermediate)');
        lbxSubject.addItem('Symphonic Band II (Proficient)');
        lbxSubject.addItem('Technology Engineering and Design');
        lbxSubject.addItem('Theatre Arts (Beginning)');
        lbxSubject.addItem('Theatre Arts (Intermediate)');
        lbxSubject.addItem('US History');
        lbxSubject.addItem('US History (AP)');
        lbxSubject.addItem('US History (Honors)');
        lbxSubject.addItem('Visual Arts (Beginning)');
        lbxSubject.addItem('Visual Arts (Intermediate)');
        lbxSubject.addItem('Visual Arts (Proficient)');
        lbxSubject.addItem('Visual Arts (Advanced)');
        lbxSubject.addItem('Visual Arts Specialization in Ceramics (Advanced)');
        lbxSubject.addItem('Vocal Ensemble (Intermediate)');
        lbxSubject.addItem('Vocal Ensemble (Proficient)');
        lbxSubject.addItem('Wind Ensemble II (Intermediate)');
        lbxSubject.addItem('Wind Ensemble II (Proficient)');
        lbxSubject.addItem('Wind Ensemble II (Advanced)');
        lbxSubject.addItem('World Geography');
        lbxSubject.addItem('World History');
        lbxSubject.addItem('World History');
        lbxSubject.addItem('World History (Honors)');

  var lbxPeriod = app.createListBox().setId('lbxPeriod').setName('lbxPeriod');
        lbxSubject.setVisibleItemCount(1);
        lbxPeriod.addItem('-- Select One --');
        lbxPeriod.addItem('1st Period');
        lbxPeriod.addItem('2nd Period');
        lbxPeriod.addItem('3rd Period');
        lbxPeriod.addItem('4th Period');

  var lblStudentNum = app.createLabel('Number of Students:');
  var txtStudentNum = app.createTextBox().setName('txtStudentNum');

  var radSource1 = app.createRadioButton('group1', 'Hard-Copy').setFormValue('Hard-Copy').setName('Hard-Copy').setId('Hard-Copy');
  var radSource2 = app.createRadioButton('group1', 'Electronic-Copy').setFormValue('Electronic-Copy').setName('Electronic-Copy').setId('Electronic-Copy');

  var radSource3 = app.createRadioButton('group2', 'Teacher-Made Exam').setFormValue('Teacher-Made Exam').setName('Teacher-Made').setId('Teacher-Made');
  var radSource4 = app.createRadioButton('group2', 'Elements Exam').setFormValue('Elements Exam').setName('Elements').setId('Elements');
  var radSource5 = app.createRadioButton('group2', 'Quia Exam').setFormValue('Quia Exam').setName('Quia').setId('Quia');

  var btnCreate = app.createButton('Create Event');

  //Create handler which will execute 'createEvents(e)' on clicking the button
  var evtHandler = app.createServerClickHandler('createEvents');
      evtHandler.addCallbackElement(vertMainPanel);
  //Add this handler to the button
      btnCreate.addClickHandler(evtHandler);

  //Add all the elemnts to the panel 
  vertMainPanel.add(lblTeacherName)
       .add(txtTeacherName)
       .add(lblExt)
       .add(txtExt)
       .add(lblDate)
       .add(boxDate)
       .add(lbxSubject)
       .add(lbxPeriod)
       .add(lblStudentNum)
       .add(txtStudentNum)
       .add(radSource1)
       .add(radSource2)
       .add(radSource3)
       .add(radSource4)
       .add(radSource5)
       .add(btnCreate);

  //Add this panel to the application
  app.add(vertMainPanel);

  //Return the application
  return app;
}

function createEvents(e){

  //Get the active application
  var app = UiApp.getActiveApplication();

  try{
    //Get the entries
    var ssTeacher = e.parameter.txtTeacherName;
    var ssExt = e.parameter.txtExt;
    var ssSubject = e.parameter.lbxSubject;
    var ssPeriod = e.parameter.lbxPeriod;
    var ssStudentNum = e.parameter.txtStudentNum;
    var ssSource = "";
    var ssType = "";
    var eventDate = e.parameter.boxDate;
    var eventCalSubject = ssPeriod + ": " + ssTeacher + " (" + ssStudentNum + ")";
    var eventCalDetails = "Extension: " + ssExt + "\n" +
          "Subject: " + ssSubject + "\n\n" +
          "Source: " + ssSource + "\n" +
          "Type: " + ssType + "\n";

    //Get the calendar
    var cal = CalendarApp.getCalendarById('davie.k12.nc.us_d2mv2eb8aspuant1vb5j6r3sis@group.calendar.google.com');//Change the calendar id
    //Create the events
    cal.createAllDayEvent(eventCalSubject, Utilities.formatDate(eventDate, 'EST', 'MM/DD/YYYY'), {description:eventCalDetails});

    //Log the entries in a spreadsheet
    var ss = SpreadsheetApp.openById('0Aur3owCpuUY-dGJIOGZ1LXhqT2FNMGVXSGNJazFnUmc#gid=0');//Change the spreadhseet key to yours
    var sheet = ss.getSheets()[0];
    sheet.getRange(sheet.getLastRow()+1, 1, 1, 10).setValues([[new Date(), eventDate, ssTeacher, ssExt, ssSubject, ssPeriod, ssSource, ssType, ssStudentNum, 'Event created']]);

    //Show the confirmation message
    app.add(app.createLabel('Kurzweil Calendar Event created successfully...'));
    //Make the form panel invisible
    app.getElementById('vertMainPanel').setVisible(false);
    return app;
  }

  //If an error occurs, show it on the panel
  catch(e){
    app.add(app.createLabel('Error occured: '+ e));
    return app;
  }
}

这应该不会太难得到。。。您只需将订阅数存储在处理程序函数中的某个位置(例如,在scriptProperties中),如果订阅数达到最大值,则只需禁用submit按钮,以便不再验证表单

在doGet函数中,可以根据您定义的相关scriptProperty轻松地
设置启用(布尔)
提交按钮,并显示解释订阅关闭原因的标签


如果将限制设置为20,则最多可获得21台(考虑到有1台计算机/预订),但如果将限制设置为19,则最多可获得20台。

您的问题是什么?你能分享一下你已经拥有的代码,它显示了你在实现上述要求时遇到的问题吗?我已经在上面添加了我的代码,并试图澄清我的问题……你在这项任务中到底有什么问题或困难?您是否尝试了一些工作不正常的方法?我不知道如何才能使这种类型的验证正确地编码,并且找不到代码资源。我实际上已经重新编码了页面并更新了上面的源代码。。。我想知道如何将验证编码到表单中,使我无法安排超过20台计算机。你能给我举个例子吗。。。根据表格提交的时间,这听起来似乎是可行的。然而,有没有一种方法可以根据某一天电子表格中列出的学生总数来实现这一目标?学生每天会被不同的班级列出,因此需要有一个截止日期。如果不知道你的数据,就很难给出一个工作示例。。。我想你很清楚你是如何组织你的活动的,但我不清楚……:)学生可以订阅每一个不同的科目吗?那个时期呢?你需要如何计算它们?标准是什么?该表格由教师填写以安排计算机实验室。教师输入特定信息,特别是日期、周期和学生人数。一旦他们点击“提交”,它就会创建一个日历事件,让我可以查看每个课时有多少学生注册了实验室,并将数据提交到谷歌电子表格(目前无法正常工作)。我的问题是如何从数据库中获得基于日期和时段的学生总数,这样我就不会让老师超额预订我的实验室了?是的。。。根据你周末与我分享的内容,我想我可能会有更好的想法。我们将看到事情的进展,希望很快能找到解决办法。