kapacitor tickscript won't work after adjustment - influxdb

I adjust tickscript(kapacitor) for my calculation.
However, no alerts work after few changes.
Before adjustment, it worked without problem.
I wonder why it does not work after adjustment.
To be more specific, I need to get "MACD" of my stock price.
Measurements contain the price of each items.
Anyone knows why?
before it was:
var db = 'telegraf'
var rp = 'autogen'
var measurement = 'exec'
var groupBy = ['symbol']
var whereFilter = lambda: TRUE
var name = 'coin'
var idVar = name + '-{{.Group}}'
var message = ' {{.ID}} {{.Level}} {{.Time}}'
var idTag = 'alertID'
var levelTag = 'level'
var messageField = 'message'
var durationField = 'duration'
var outputDB = 'chronograf'
var outputRP = 'autogen'
var outputMeasurement = 'alerts'
var triggerType = 'threshold'
var crit = 50000000000
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|eval(lambda: "lastPrice")
.as('value')
var trigger = data
|alert()
.crit(lambda: "value" > crit)
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.stateChangesOnly()
.telegram()
.chatId('####')
.parseMode('Markdown')
trigger
|eval(lambda: float("value"))
.as('value')
.keep()
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag('alertName', name)
.tag('triggerType', triggerType)
trigger
|httpOut('output')
Now it became:
var db = 'telegraf'
var rp = 'autogen'
var measurement = 'exec'
var groupBy = ['symbol']
var whereFilter = lambda: TRUE
var name = 'coin'
var idVar = name + '-{{.Group}}'
var message = ' {{.ID}} {{.Level}} {{.Time}}'
var idTag = 'alertID'
var levelTag = 'level'
var messageField = 'message'
var durationField = 'duration'
var outputDB = 'chronograf'
var outputRP = 'autogen'
var outputMeasurement = 'alerts'
var triggerType = 'threshold'
var crit = 0
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|eval(lambda: "lastPrice")
.as('v')
var avg12 = data
|window()
.period(3m)
.every(1m)
|mean('x1')
.as('x1a')
var avg26 = data
|window()
.period(5m)
.every(1m)
|mean('x2')
.as('x2a')
var macd = avg12
|join(avg26)
.as('x1a', 'x2a')
|eval(lambda: float('x1a.value' - 'x2a.value'))
.keep()
.as('value')
var trigger = macd
|alert()
.crit(lambda: "value" > crit)
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.stateChangesOnly()
.telegram()
.chatId('###')
.parseMode('Markdown')
trigger
|eval(lambda: float("value"))
.as('value')
.keep()
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag('alertName', name)
.tag('triggerType', triggerType)
trigger
|httpOut('output')

Related

SyntaxError: Unexpected token - Google Sheets Script Editor

I want to create a master tab that takes data from other tabs. Once the data is in the master tab I want to be able to filter the information.
I've done this previously using the code that I am having issues with. I learned how to do this here: https://www.youtube.com/watch?v=rpITkG40rQs
Also the previous project I used this code for still works.
The code I am having trouble with is below. I'm getting the following error now:
Exception: The starting column of the range is too small.
getColumnValue # Copy 2 of Code.gs:59
getCombinedColumnValues # Copy 2 of Code.gs:39
(anonymous) # Copy 2 of Code.gs:16
combineData # Copy 2 of Code.gs:15
previously i got this error:
Syntax error: SyntaxError: Unexpected token ')' line: 14 file: Copy of Code.gs
line 14 is under the "labels" var and above the loop starting with lables.foreach...
function combineData() {
var masterSheet = "Master";
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(masterSheet);
var lc = ss.getLastColumn();
var lr = ss.getLastRow();
ss.getRange(2, 1, lr-1, lc).clearContent();
ss.getRange(1, 49, lr-1, lc).clearContent();
var labels = ss.getRange(1, 1, 1, lc).getValues()[0];
labels.forEach(function(label,i){
var colValues = getCombinedColumnValues(label);
ss.getRange(2, i+1, colValues.length, 1).setValues(colValues);
Logger.log(colValues);
});
}
/// note to self - the problem I was having with the document below was the 'if' statement. The tutorial only has one exclusion. I have several tables to include and exclude.
function getCombinedColumnValues(label) {
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets()
var colValues = [];
for(k in sheets){
var sheetName = sheets[k].getSheetName();
// grabs the tabs I want.
if ((sheetName == "CBDIO Data")||(sheetName == "CCA Data")||(sheetName == "CHW Data")||(sheetName == "Mujeres en Accion Data")||(sheetName == "Padres Unidos Data")||(sheetName == "CBDIO - Form")){
var tempValue = getColumnValue(label, sheetName)
colValues = colValues.concat(tempValue);
}
};
return colValues;
}
function getColumnValue(label, sheetName) {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
var colIndex = getColumnIndex(label, sheetName);
var numRow = ss.getLastRow() - 1;
var colValues = ss.getRange(2, colIndex, numRow, 1).getValues();
return colValues;
}
function getColumnIndex(label, sheetName) {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
var lc = ss.getLastColumn();
var lookupRangeValues = ss.getRange(1, 1, 1, lc).getValues()[0];
var index = lookupRangeValues.indexOf(label) + 1;
return index;
}
'''

Create Kapacitor alert error

I get following error while creating an Kapacitor alert. Alert is created but not triggered.
ts=2018-08-21T15:01:05.329Z lvl=error msg="failed to create database" service=kapacitor task_master=main task=chronograf-v1-2004f027-091f-4af9-b5c8-a636ab28fcc8 node=influxdb_out8 err="retention policy conflicts with an existing policy" database=chronograf cluster=
Retention policy defined on influxdb database is defined as following.
show retention policies on chronograf
name duration shardGroupDuration replicaN default
---- -------- ------------------ -------- -------
autogen 1440h0m0s 168h0m0s 1 true
Tickscript used
var db = 'telemetrics'
var rp = 'two_months'
var measurement = 'system'
var groupBy = []
var whereFilter = lambda: ("host" == 'hostname.domain.xxxx')
var period = 1m
0s
var name = 'Redis Deadman'
var idVar = name + ':{{.Group}}'
var message = 'DEADMAN Alert REDIS.'
var idTag = 'alertID'
var levelTag = 'level'
var messageField = 'message'
var durationField = 'duration'
var outputDB = 'chronograf'
var outputRP = 'autogen'
var outputMeasurement = 'alerts'
var triggerType = 'deadman'
var threshold = 0.0
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
var trigger = data
|deadman(threshold, period)
.stateChangesOnly()
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.telegram()
.chatId('-232933442')
.log('/var/log/kapacitor/alerts.log')
trigger
|eval(lambda: "emitted")
.as('value')
.keep('value', messageField, durationField)
|eval(lambda: float("value"))
.as('value')
.keep()
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag('alertName', name)
.tag('triggerType', triggerType)
trigger
|httpOut('output')
Any suggestions?
The conflict i guess is that you are trying to create the same db.
"retention policy conflicts with an existing policy" you may need another rp.

Binding row value to odata model SAP UI5

I have a table with 2 columns - one where user can input a value to return and other column is a checkbox. If a user enters a value in the item row, I make the checkbox checked. If value is greater than 0 then only the checkbox is selected. My issue is with the below code, if I input a value on the 3 rd row, that checkbox is selected but alongside even the first row's checkbox is selected. I think the issue is in the stmt: tableModel.setProperty("/ItemSet/results/0/ReturnItemFlag", "X"); Because I am giving "0" the first row is also getting the value. How to I point to the correct result number.
Controller.js
qtyChange: function(oEvent) {
var a = oEvent.getSource();
var input = a.getValue()
var row = oEvent.getSource().getParent().getParent();
var index = row.getIndex();
var oTable = vc.getView().byId("takeStockHistoryDetailTable");
var selectedRowPath = oTable.getContextByIndex(index).getPath();
var tableModel = vc.getView().getModel(TAKE_STOCK_ORDER_DETAIL);
var selectedPart = tableModel.getObject(selectedRowPath);
var QtyOnHand = selectedPart.QtyOnHand;
var UnitP = selectedPart.UnitPrice;
var f = parseInt(input);
var g = parseInt(QtyOnHand);
var h = parseFloat(UnitP);
if (f > g) {
sap.m.MessageToast.show("Return quantity is more than available quantity");
a.setValue("");
} else if (f === 0 || input === "") {
selectedPart.ReturnItemFlag = 'Y';
tableModel.setProperty("/ItemSet/results/0/ReturnItemFlag", "Y");
} else {
selectedPart.ReturnItemFlag = 'X';
selectedPart.QtyToReturn = input;
var sub = input * h;
// debugger;
var sub1 = sub.toString();
selectedPart.Subtotal = sub1;
tableModel.setProperty("/ItemSet/results/0/ReturnItemFlag", "X");
tableModel.setProperty("/ItemSet/results/0/Subtotal", sub1);
}
},
This is possibly a very complicated way of working with table items.
Here is how you should work with bindingContexts.
on listItemPress Event of the table(list)
qtyChange: function(oEvent){
var oColumnListItem = oEvent.getSource().getParent();
var sPath = oColumnListItem.getBindingContextPath("yourModelName");
OR
var sPath = oColumnListItem.getBindingContext("yourModelName").getPath();
var sReturnItemFlagPath = sPath + "/ReturnItemFlag";
tableModel.setProperty(sReturnItemFlagPath,"newValue");
}
Let me know if this helps!

Combine/merge multiple maps into 1 map

How can I combine/merge 2 or more maps in dart into 1 map?
for example I have something like:
var firstMap = {"1":"2"};
var secondMap = {"1":"2"};
var thirdMap = {"1":"2"};
I want:
var finalMap = {"1":"2", "1":"2", "1":"2"};
you can use addAll method of Map object
var firstMap = {"1":"2"};
var secondMap = {"2":"3"};
var thirdMap = {};
thirdMap.addAll(firstMap);
thirdMap.addAll(secondMap);
print(thirdMap);
Or
var thirdMap = {}..addAll(firstMap)..addAll(secondMap);
Update
Since dart sdk 2.3
You can use spread operator ...
final firstMap = {"1":"2"};
final secondMap = {"2":"3"};
final thirdMap = {
...firstMap,
...secondMap,
};
alternate syntax using Map.addAll, Iterable.reduce and cascading operator, for combining a lot of maps:
var combinedMap = mapList.reduce( (map1, map2) => map1..addAll(map2) );
live dartpad example
https://dartpad.dartlang.org/9cd116d07d2f45a9b890b4b1186dcc5e
Another option is using CombinedMapView from package:collection:
new CombinedMapView([firstMap, secondMap])
It doesn't create a merged map, but creates a Map that is a view of both.
I came up with a "single line" solution for an Iterable of Maps:
var finalMap = Map.fromEntries(mapList.expand((map) => map.entries));
var firstMap = {"1":"5"};
var secondMap = {"1":"6"};
var thirdMap = {"2":"7"};
var finalMap = {...firstMap, ...secondMap, ...thirdMap};
// finalMap: {"1":"6", "2":"7"};
Notice that key "1" with value "5" will be overwritten with "6".

Show/hide TextBox based on status of RadioButton

I would like to show "txtElementID" when the radSource4 button is clicked and "txtQuiaLink" and "txtQuiaPass" when the radSource5 button is clicked. How do I go about doing that... I am a little new to Google Apps Script and trying to learn some basics. Thanks
//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').setFormat(UiApp.DateTimeFormat.DATE_SHORT);
var lbxSubject = app.createListBox().setId('lbxSubject').setName('lbxSubject');
var lstSubjItems = ['-- Select One --','Algebra I (OCS)','Algebra II','Algebra II (Honors)','Agriscience Applications','Agriscience Applications (OCS)','Anatomy and Physiology','Anatomy and Physiology (Honors)','Animal Science','American Sign Language II','Apparel I','Art History (AP)','Advanced Functions and Modeling','Automotive Computer System Diagnostics','Automotive Brakes','Automotive Service','Automotive Service (OCS)', 'Benchmarks','Bible History','Biology','Biology (AP)','Biology (Honors)','Biology (OCS)','Biomedical Technology','Biotechnology and Agriscience','Calculus AB (AP)','Calculus BC (AP)','Carpentry I','Carpentry I (OCS)','Carpentry III','Chemistry','Chemistry (AP)','Chemistry (Honors)','Choral Arts (Beginning)','Civics and Economics','Civics and Economics (Honors)','Computer Programming I','Computer Science (AP)','Computer Technology','Concert Band II (Beginning)', 'Concert Band II (Proficient)','Core and Sustainable Construction','Core and Sustainable Construction (OCS)','Digital Media I','Digitial Media I (OCS)','Digital Media II','Discrete Mathematics','Drafting I','Drafting Architecture II (Honors)','Drafting Architecture III (Honors)','Earth and Environmental Science','Earth and Environmental Sceince (AP)','Earth and Environmental Science (Honors)','Early Childhood Ed I','eCommerce I (Honors)','English I','English I (Honors)','English II','English II (Honors)','English II (OCS)','English III','English III (Honors)','English III (OCS)','English IV','English IV (Honors)','English IV (OCS)','English Lang and Comp (AP)','English Language Arts II','English Language Arts III','Engish Literature (AP)','European History (AP)','Fashion Merchandising','Financial Management (OCS)','Foods I','Foods I (OCS)','Foods II - Enterprise','Foods II - Advanced (OCS)','French I','French II','French III (Honors)','Functional Finances','Geometry', 'Geometry (Honors)','German I','German II','German III (Honors)','Health and Physical Education','Health Sciences (Advanced Studies)','Health Team Relations','Human Geography (AP)','Holocaust and Peace Studies','Horticulture I','Horticulture I (OCS)','Horticulture II','Horticulture II (OCS)','Integrated Math I','Interior Design I','Introduction to Math','Japanese I','JROTC I','JROTC II','JROTC III','JROTC IV','Latin I','Latim II','Latin III (Honors)','Leadership Development','Marketing Management','Masonry I','Masonry I (OCS)','Masonry III','Microsoft Excel and Access','Microsoft Word PowerPoint and Publisher','Multimedia and Webpage Design','Music Business and Recording (Beginning)','Occupational Preparations I','Occupational Preparations II','Occupational Preparations III','Occupational Preparations IV','Parent and Child Development', 'Parent and Child Development (OCS)','Personal Finance', 'Personal Finance (OCS)','Physical Science','Physics (Honors)','Pre-Calculus (Honors)','Professional Management and Leadership I','Professional Management and Leadership II','Psychology','Physcology (AP)','Psychology (Honors)','SAT Preparation','Science and Technical Visualization I','Science and Technical Visualization II','Social Studies (OCS)','Spanish I','Spanish II','Spanish III (Honors)','Spanish IV (Honors)','Special Topics of Mathematics','Symphonic Band II (Beginning)','Symphonic Band II (Intermediate)','Symphonic Band II (Proficient)','Technology Engineering and Design','Theatre Arts (Beginning)','Theatre Arts (Intermediate)','US History','US History (AP)','US History (Honors)','Visual Arts (Beginning)','Visual Arts (Intermediate)','Visual Arts (Proficient)','Visual Arts (Advanced)','Visual Arts Specialization in Ceramics (Advanced)','Vocal Ensemble (Intermediate)','Vocal Ensemble (Proficient)','Wind Ensemble II (Intermediate)','Wind Ensemble II (Proficient)','Wind Ensemble II (Advanced)','World Geography','World History','World History','World History (Honors)'];
lstSubjItems.sort();
for (var l = 0; l < lstSubjItems.length; l++) {
lbxSubject.addItem(lstSubjItems[l]);
}
var lbxPeriod = app.createListBox().setId('lbxPeriod').setName('lbxPeriod');
var lstPrdItems = ['-- Select One --','1st Period','2nd Period','3rd Period','4th Period'];
lstPrdItems.sort();
for (var l = 0; l < lstPrdItems.length; l++) {
lbxPeriod.addItem(lstPrdItems[l]);
}
var lblStudentNum = app.createLabel('Number of Students:');
var txtStudentNum = app.createTextBox().setName('txtStudentNum');
var txtRadioGrp1 = app.createTextBox().setName('txtRadioGrp1').setVisible(false);
var txtRadioGrp2 = app.createTextBox().setName('txtRadioGrp2').setVisible(false);
var txtElementsID = app.createTextBox().setName('txtElementsID').setVisible(false);
var txtQuiaLink = app.createTextBox().setName('txtQuiaLink').setVisible(false);
var txtQuiaPass = app.createTextBox().setName('txtQuiaPass').setVisible(false);
//Create Source Radio Button Group
var radSource1 = app.createRadioButton('group1', 'Hard-Copy').setFormValue('Hard-Copy').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp1).setText('Hard-Copy'));
var radSource2 = app.createRadioButton('group1', 'Electronic-Copy').setFormValue('Electronic-Copy').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp1).setText('Electronic-Copy'));
//Create Type Radio Button Group
var radSource3 = app.createRadioButton('group2', 'Teacher-Made Exam').setFormValue('Teacher-Made Exam').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp2).setText('Teacher-Made Exam'));
var radSource4 = app.createRadioButton('group2', 'Elements Exam').setFormValue('Elements Exam').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp1).setText('Elements Exam'));
if (radSource4 == true) {
txtElementsID.setVisible(true);
} else {
txtElementsID.setVisible(false);
}
var radSource5 = app.createRadioButton('group2', 'Quia Exam').setFormValue('Quia Exam').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp1).setText('Quia Exam'));
if (radSource5 == true) {
txtQuiaLink.setVisible(true);
txtQuiaPass.setVisible(true);
} else {
txtQuiaLink.setVisible(false);
txtQuiaPass.setVisible(false);
}
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(txtRadioGrp1)
.add(radSource3)
.add(radSource4)
.add(txtElementsID)
.add(radSource5)
.add(txtQuiaLink)
.add(txtQuiaPass)
.add(txtRadioGrp2)
.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 = e.parameter.txtRadioGrp1;
var ssType = e.parameter.txtRadioGrp2;
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, eventDate, {description:eventCalDetails});
//Log the entries in a spreadsheet
var sheet = SpreadsheetApp.openById('0Aur3owCpuUY-dGJIOGZ1LXhqT2FNMGVXSGNJazFnUmc#gid=0').getActiveSheet();//Change the spreadhseet key to yours
var lastRow = sheet.getLastRow();
var targetRange = sheet.getRange(lastRow+1, 1, 1, 10).setValues([[new Date(),eventDate,ssTeacher,ssExt,ssSubject,ssPeriod,ssSource,ssType,ssStudentNum,'Event created']]);
return app;
//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;
}
}
Use ClientHandlers that toggle visibility...
A short example is better than a long explanation, I guess it's clear enough, just insert the following code after you have created all the radioButtons and textBoxes.
DEMO app and full code here
//Client Handlers for textBoxes
var showTxtElementHandler = app.createClientHandler().forTargets(txtElementsID).setVisible(true);
var hideTxtElementHandler = app.createClientHandler().forTargets(txtElementsID).setVisible(false);
radSource4.addClickHandler(showTxtElementHandler);// show when click on radio4
radSource3.addClickHandler(hideTxtElementHandler);// hide if click other
radSource5.addClickHandler(hideTxtElementHandler);
var showtxtQuiaLinkHandler = app.createClientHandler().forTargets(txtQuiaLink).setVisible(true);
var hidetxtQuiaLinkHandler = app.createClientHandler().forTargets(txtQuiaLink).setVisible(false);
radSource5.addClickHandler(showtxtQuiaLinkHandler);// show when clicked on radio5
radSource3.addClickHandler(hidetxtQuiaLinkHandler);// hide in other cases
radSource4.addClickHandler(hidetxtQuiaLinkHandler);
EDIT : did you mean something like this ? :
in this case I did it with an horizontal panel like below (demo updated)
var txtRadioGrp1 = app.createTextBox().setName('txtRadioGrp1').setVisible(false);
var txtRadioGrp2 = app.createTextBox().setName('txtRadioGrp2').setVisible(false);
var txtElementsID = app.createTextBox().setName('txtElementsID');
var txtQuiaLink = app.createTextBox().setName('txtQuiaLink');
var txtElementsIDP = app.createHorizontalPanel().add(app.createLabel('enter a value')).add(txtElementsID).setVisible(false);
var txtQuiaLinkP = app.createHorizontalPanel().add(app.createLabel('enter a value')).add(txtQuiaLink).setVisible(false);
var txtQuiaPass = app.createTextBox().setName('txtQuiaPass').setVisible(false);
//Create Source Radio Button Group
var radSource1 = app.createRadioButton('group1', 'Hard-Copy').setFormValue('Hard-Copy').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp1).setText('Hard-Copy'));
var radSource2 = app.createRadioButton('group1', 'Electronic-Copy').setFormValue('Electronic-Copy').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp1).setText('Electronic-Copy'));
//Create Type Radio Button Group
var radSource3 = app.createRadioButton('group2', 'Teacher-Made Exam').setFormValue('Teacher-Made Exam').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp2).setText('Teacher-Made Exam'));
var radSource4 = app.createRadioButton('group2', 'Elements Exam').setFormValue('Elements Exam').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp1).setText('Elements Exam'));
var radSource5 = app.createRadioButton('group2', 'Quia Exam').setFormValue('Quia Exam').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp1).setText('Quia Exam'));
var btnCreate = app.createButton('Create Event');
//Client Handlers for textBoxes
var showTxtElementHandler = app.createClientHandler().forTargets(txtElementsIDP).setVisible(true);
var hideTxtElementHandler = app.createClientHandler().forTargets(txtElementsIDP).setVisible(false);
radSource4.addClickHandler(showTxtElementHandler);
radSource3.addClickHandler(hideTxtElementHandler);
radSource5.addClickHandler(hideTxtElementHandler);
var showtxtQuiaLinkHandler = app.createClientHandler().forTargets(txtQuiaLinkP).setVisible(true);
var hidetxtQuiaLinkHandler = app.createClientHandler().forTargets(txtQuiaLinkP).setVisible(false);
radSource5.addClickHandler(showtxtQuiaLinkHandler);
radSource3.addClickHandler(hidetxtQuiaLinkHandler);
radSource4.addClickHandler(hidetxtQuiaLinkHandler);
EDIT 2 : GRID version
//Add all the elemnts to the panel
var grid = app.createGrid(12,2).setCellPadding(5);
vertMainPanel.add(grid);
grid.setWidget(0,0,lblTeacherName)
.setWidget(0,1,txtTeacherName)
.setWidget(1,0,lblExt)
.setWidget(1,1,txtExt)
.setWidget(2,0,lblDate)
.setWidget(2,1,boxDate)
.setWidget(3,1,lbxSubject)
.setWidget(3,0,lbxPeriod)
.setWidget(4,0,lblStudentNum)
.setWidget(4,1,txtStudentNum)
.setWidget(5,0,radSource1)
.setWidget(5,1,radSource2)
.setWidget(6,0,txtRadioGrp1)
.setWidget(7,0,radSource3)
.setWidget(8,0,radSource4)
.setWidget(8,1,txtElementsIDP)
.setWidget(9,0,radSource5)
.setWidget(9,1,txtQuiaLinkP)
.setWidget(10,0,txtQuiaPass)
.setWidget(10,1,txtRadioGrp2)
.setWidget(11,0,btnCreate);

Resources