SlideShare a Scribd company logo
1 of 2
Download to read offline
EK	127	Homework	2:	Grading	Script	Parser	
Background	
In	most	every	lab	section,	you	have	some	problems	you	are	required	to	submit	on	Edge.	The	
code	you	submit	on	Edge	is	typically	a	script	that	accomplishes	some	desired	task,	and	the	
online	platform	automatically	grades	it	and	provides	feedback.		
	
The	embedded	MATLAB	on	Edge	works	in	a	fairly	unique	way.	MATLAB	is	by	no	means	built	into	
your	browser.	What	happens	is	your	code	is	sent	as	a	string	to	a	MathWorks	server	where	it	is	
evaluated	(as	in	the	eval	function	is	used),	and	the	results	are	sent	back	to	you	on	Edge.	
	
For	clarity,	we	will	refer	to	the	student	answer	(the	actual	code	you	type	into	Edge)	as	the	
“answer	code”.	Additionally,	the	code	that	automatically	grades	the	answer	code	will	be	
referred	to	as	the	“grading	code”.	
	
Immediately	after	the	answer	code,	the	grading	code	is	also	processed	by	a	MathWorks	server.	
Since	both	scripts	are	run	in	the	same	workspace,	any	variable	created	in	the	answer	code	are	
accessible	in	the	grading	code.	
	
Just	as	you	write	the	answer	code,	someone	had	to	have	written	the	grading	code,	right?	The	
grading	code	accomplishes	a	variety	of	tasks,	such	as	making	sure	a	certain	function	is	used,	
making	sure	the	answer	is	correct,	making	sure	a	loop	is	or	isn’t	used,	etc.	
	
Sometimes,	it	is	very	useful	to	process	the	answer	code	as	a	text	file.	If	the	answer	code	is	seen	
as	just	text,	we	can	use	our	string	manipulation	functions	on	it.	As	an	example,	one	common	
task	is	to	remove	all	comments	from	the	answer	code.	
Assignment	
Your	task	is	to	write	a	portion	of	the	grading	code	to	grade	Problem	3.4	from	Worksheet	3	
(which	was	to	write	the	diff	function).	Your	code	needs	to	do	the	following:	
	
• Read	the	answer	code	as	a	text	file	
• Delete	OR	ignore	all	comments	
• Check	to	see	if	the	answer	code	uses	the	subtraction	operator	(the	minus	sign)	
• If	the	answer	code	does	NOT	use	the	subtraction	operator,	assert	an	error	and	provide	
feedback	using	the	assert	function	
• Check	to	see	if	the	answer	code	uses	the	diff	function	
• If	the	answer	code	DOES	use	the	diff	function,	assert	an	error	and	provide	feedback	
using	the	assert	function
The	assert	function	is	a	built-in	function	that	generates	an	error	when	a	condition	is	violated.	
For	example:	
	
	
assert(isequal(myprod,myprod_test),'Check your expression for myprod')
Here,	myprod	is	the	student’s	answer	and	myprod_test	is	the	correct	answer	to	check	it	against.	
This	statement	checks	to	see	if	the	variables	myprod	and	myprod_test	hold	the	same	value.	If	
they	do	(so	the	condition	is	true),	nothing	happens.	If	the	values	are	different	(so	the	condition	
is	false),	it	asserts	an	error	and	provides	a	feedback	statement	of	“Check	your	expression	for	
myprod”.	
	
In	addition	to	the	assert	function,	you	will	need	to	use	some	string	functions.	Please	refer	to	
your	book,	notes,	and	online	resources	to	find	helpful	functions.	
Additional	Guidance	
To	understand	the	nature	of	the	problem	even	better,	you	should	play	around	with	this	
problem	on	Edge	(see:	Week	3,	WS3	Edge	Submit	Problems,	the	4th
	problem	titled	
“Difference”).		Try	to	make	intentional	mistakes	and	see	what	happens!	For	instance,	what	
happens	if	you	use	the	diff	function?	What	if	the	word	“diff”	is	used	in	a	comment?	Playing	
around	with	it	on	Edge	should	help	you	out	with	writing	your	solution.	
	
Some	sample	M-files	have	been	provided	as	well.	These	should	help	you	test	your	solution	(you	
can	find	these	on	Edge):	
1. correct_answer.m	-	A	perfect,	vectorized	solution	
2. uses_diff.m	-	A	correct	solution	that	uses	the	diff	function	
3. incorrect_answer.m		-	An	incorrect	solution	that	attempts	to	use	a	for	loop	
4. assert_sample.m	-	A	quick	example	of	how	the	assert	function	is	used	
	
Note:	Both	examples	1	and	2	contain	“diff”	in	a	comment.	
	
You	may	also	find	the	following	useful:	
1. fileread()		-	a	function	useful	for	reading	the	entire	file	as	a	string	
2. char(10)	-	the	newline	character	that	separates	each	line	in	the	file.	Comments	will	
always	be	on	separate	lines	from	actual	code	to	making	parsing	out/ignoring	comments	
easier.

More Related Content

What's hot

Acceptance Testing With Selenium
Acceptance Testing With SeleniumAcceptance Testing With Selenium
Acceptance Testing With Selenium
elliando dias
 

What's hot (20)

Java Custom Annotations- Part1
Java Custom Annotations- Part1Java Custom Annotations- Part1
Java Custom Annotations- Part1
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 
Keyword Driven Testing using TestComplete
Keyword Driven Testing using TestCompleteKeyword Driven Testing using TestComplete
Keyword Driven Testing using TestComplete
 
Web App Security - A Developers Perspective: Part 1 - SQL Injection
Web App Security - A Developers Perspective: Part 1 - SQL InjectionWeb App Security - A Developers Perspective: Part 1 - SQL Injection
Web App Security - A Developers Perspective: Part 1 - SQL Injection
 
Crafting high quality code
Crafting high quality code Crafting high quality code
Crafting high quality code
 
How to build quality software
How to build quality softwareHow to build quality software
How to build quality software
 
Behaviour driven development aka bdd
Behaviour driven development aka bddBehaviour driven development aka bdd
Behaviour driven development aka bdd
 
Automation Testing of Shadow DOM Elements with Katalon Studio
Automation Testing of Shadow DOM Elements with Katalon StudioAutomation Testing of Shadow DOM Elements with Katalon Studio
Automation Testing of Shadow DOM Elements with Katalon Studio
 
Compiling and linking of a c code
Compiling and linking of a c codeCompiling and linking of a c code
Compiling and linking of a c code
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 
Hybrid Automation Framework Development introduction
Hybrid Automation Framework Development introductionHybrid Automation Framework Development introduction
Hybrid Automation Framework Development introduction
 
Test Complete
Test CompleteTest Complete
Test Complete
 
Spring REST Request Validation
Spring REST Request ValidationSpring REST Request Validation
Spring REST Request Validation
 
Client side unit tests - using jasmine & karma
Client side unit tests - using jasmine & karmaClient side unit tests - using jasmine & karma
Client side unit tests - using jasmine & karma
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 
Unit-testing and E2E testing in JS
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JS
 
Acceptance Testing With Selenium
Acceptance Testing With SeleniumAcceptance Testing With Selenium
Acceptance Testing With Selenium
 
Amazon CodeGuru - Automate Code review and Code performance monitoring
Amazon CodeGuru - Automate Code review and Code performance monitoringAmazon CodeGuru - Automate Code review and Code performance monitoring
Amazon CodeGuru - Automate Code review and Code performance monitoring
 
Cucumber ppt
Cucumber pptCucumber ppt
Cucumber ppt
 
Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018
 

Viewers also liked

Joy Burress Resume 11.2013
Joy Burress Resume 11.2013Joy Burress Resume 11.2013
Joy Burress Resume 11.2013
Joy Burress
 
LOTS FOR SALE CAMP WARRINER COVE
LOTS FOR SALE CAMP WARRINER COVELOTS FOR SALE CAMP WARRINER COVE
LOTS FOR SALE CAMP WARRINER COVE
Alan Dodd
 
Reporte de entrevista tics
Reporte de entrevista ticsReporte de entrevista tics
Reporte de entrevista tics
Yadira Orozco
 

Viewers also liked (14)

Fazekas borászat-magyar
Fazekas borászat-magyarFazekas borászat-magyar
Fazekas borászat-magyar
 
Joy Burress Resume 11.2013
Joy Burress Resume 11.2013Joy Burress Resume 11.2013
Joy Burress Resume 11.2013
 
NDP 02 : EXPERTOS SENTARÁN LAS BASES DEL FUTURO DE LA MINERÍA EN EL PERÚ
NDP 02 : EXPERTOS SENTARÁN LAS BASES DEL FUTURO DE LA MINERÍA EN EL PERÚNDP 02 : EXPERTOS SENTARÁN LAS BASES DEL FUTURO DE LA MINERÍA EN EL PERÚ
NDP 02 : EXPERTOS SENTARÁN LAS BASES DEL FUTURO DE LA MINERÍA EN EL PERÚ
 
LOTS FOR SALE CAMP WARRINER COVE
LOTS FOR SALE CAMP WARRINER COVELOTS FOR SALE CAMP WARRINER COVE
LOTS FOR SALE CAMP WARRINER COVE
 
Hagel Resume
Hagel ResumeHagel Resume
Hagel Resume
 
Reporte de entrevista tics
Reporte de entrevista ticsReporte de entrevista tics
Reporte de entrevista tics
 
Snapcode Low Down
Snapcode Low DownSnapcode Low Down
Snapcode Low Down
 
PRESSEMITTEILUNG: MRB präsentiert sich mit neuer Optik und frischem Design
PRESSEMITTEILUNG: MRB präsentiert sich mit neuer Optik und frischem DesignPRESSEMITTEILUNG: MRB präsentiert sich mit neuer Optik und frischem Design
PRESSEMITTEILUNG: MRB präsentiert sich mit neuer Optik und frischem Design
 
Anacronismo
AnacronismoAnacronismo
Anacronismo
 
NDEAM 15 poster
NDEAM 15 posterNDEAM 15 poster
NDEAM 15 poster
 
Pro_Tools_Tier_1
Pro_Tools_Tier_1Pro_Tools_Tier_1
Pro_Tools_Tier_1
 
Publicación4
Publicación4Publicación4
Publicación4
 
Id me giant summer camp labels giveaway
Id me giant summer camp labels giveawayId me giant summer camp labels giveaway
Id me giant summer camp labels giveaway
 
השבוע בטבעון - עדלאידע, OPEN RAKU, גינה קהילתית סרטים והופעות
השבוע בטבעון - עדלאידע, OPEN RAKU, גינה קהילתית סרטים והופעותהשבוע בטבעון - עדלאידע, OPEN RAKU, גינה קהילתית סרטים והופעות
השבוע בטבעון - עדלאידע, OPEN RAKU, גינה קהילתית סרטים והופעות
 

Similar to EK127S15HW2

Similar to EK127S15HW2 (20)

The Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingThe Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and Everything
 
The Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingThe Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and Everything
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.js
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJS
 
MATLAB Coder Example Research Ideas
MATLAB Coder Example Research IdeasMATLAB Coder Example Research Ideas
MATLAB Coder Example Research Ideas
 
Looking for Bugs in MonoDevelop
Looking for Bugs in MonoDevelopLooking for Bugs in MonoDevelop
Looking for Bugs in MonoDevelop
 
AspectMock
AspectMockAspectMock
AspectMock
 
learn mvc project in 7 day
learn mvc project in 7 daylearn mvc project in 7 day
learn mvc project in 7 day
 
Managing the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS LambdaManaging the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS Lambda
 
Continuous Delivery with AWS Lambda - AWS April 2016 Webinar Series
Continuous Delivery with AWS Lambda - AWS April 2016 Webinar SeriesContinuous Delivery with AWS Lambda - AWS April 2016 Webinar Series
Continuous Delivery with AWS Lambda - AWS April 2016 Webinar Series
 
Thinkful - Intro to JavaScript
Thinkful - Intro to JavaScriptThinkful - Intro to JavaScript
Thinkful - Intro to JavaScript
 
Mi0041 java and web design
Mi0041 java and web designMi0041 java and web design
Mi0041 java and web design
 
The Little Unicorn That Could
The Little Unicorn That CouldThe Little Unicorn That Could
The Little Unicorn That Could
 
HoloLens Unity Build Pipelines on Azure DevOps
HoloLens Unity Build Pipelines on Azure DevOpsHoloLens Unity Build Pipelines on Azure DevOps
HoloLens Unity Build Pipelines on Azure DevOps
 
Meteor
MeteorMeteor
Meteor
 
We continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShellWe continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShell
 
How I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptHow I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScript
 
Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8
 
Coding Naked
Coding NakedCoding Naked
Coding Naked
 
Managing the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS LambdaManaging the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS Lambda
 

EK127S15HW2