From 49fcceffdd301e7727bfd1623a8ca418c4992a5e Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Thu, 17 May 2012 22:54:13 -0400
Subject: [PATCH 01/60] First version of QTI parser
---
lib/QTI_parser.rb | 58 ++++++++++++++++++++++++++++++++++++
lib/learning_parser.rb | 37 +++++++++++++++++++++++
lib/sample_QTI_questions.xml | 24 +++++++++++++++
3 files changed, 119 insertions(+)
create mode 100644 lib/QTI_parser.rb
create mode 100644 lib/learning_parser.rb
create mode 100644 lib/sample_QTI_questions.xml
diff --git a/lib/QTI_parser.rb b/lib/QTI_parser.rb
new file mode 100644
index 0000000..9ac9427
--- /dev/null
+++ b/lib/QTI_parser.rb
@@ -0,0 +1,58 @@
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
+require 'parslet'
+require 'parslet/convenience'
+
+class Question < Parslet::Parser
+ #Single character rules
+ rule(:leftbracket) { str('[') }
+ rule(:rightbracket) { str(']') }
+ rule(:exclamation) { str('!').repeat(1) }
+ rule(:lessthan) { str('<').repeat(1) >> space? }
+ rule(:greaterthan) { str('>').repeat(1) >> space? }
+ rule(:colon) { str(':') >> space? }
+ rule(:equal) { str('=') >> space? }
+ rule(:semicolon) { str(';') >> space? }
+ rule(:lparen) { str('(') >> space? }
+ rule(:rparen) { str(')') >> space? }
+ rule(:qmark) { str('?') >> space? }
+ rule(:underscore) { str('_') >> space? }
+
+ rule(:space) { match('\s').repeat(1) }
+ rule(:space?) { space.maybe }
+
+ #Things
+ rule(:letters) { match['A-Za-z'].repeat(1) >> space? }
+ rule(:numbers) { match['0-9'].repeat(1) >> space? }
+ rule(:period) { match('\.') >> space? }
+ rule(:star) { match('\*') >> space? }
+ rule(:fslash) { match('\/') >> space? }
+
+ #Grammar parts
+ rule(:punc) { colon | greaterthan | lessthan | equal |
+ semicolon | lparen | rparen | period | star | fslash |
+ qmark | underscore }
+ rule(:begin_ques) { lessthan >> exclamation >> leftbracket >>
+ letters >> leftbracket }
+ rule(:ques) { (letters | numbers | punc | end_ques ) >> ques.repeat }
+ rule(:end_ques) { rightbracket >> rightbracket >> greaterthan }
+
+ rule(:expression) { begin_ques >> ques }
+ root :expression
+end
+
+def parse(str)
+ question = Question.new
+ p question.parse(str)
+
+rescue Parslet::ParseFailed => error
+ puts error, question.root.error_tree
+
+end
+
+
+parse "
fs = 11025;
tt = (0:round(0.25*fs
+ ))/fs;
Which MATLAB code would you use to gene
+rate the appropriate DTMF signal to represent telephone key number
+ 5? And this is another way.]]>"
diff --git a/lib/learning_parser.rb b/lib/learning_parser.rb
new file mode 100644
index 0000000..7947835
--- /dev/null
+++ b/lib/learning_parser.rb
@@ -0,0 +1,37 @@
+require 'parslet'
+
+class Mini < Parslet::Parser
+ #Single character rules
+ rule(:lparen) { str('(') >> space? }
+ rule(:rparen) { str(')') >> space? }
+ rule(:comma) { str(',') >> space? }
+
+ rule(:space) { match('\s').repeat(1) }
+ rule(:space?) { space.maybe }
+
+ #Things
+ rule(:integer) { match('[0-9]').repeat(1).as(:int) >> space?}
+ rule(:identifier) { match['a-z'].repeat(1) }
+ rule(:operator) { match('[+]') >> space? }
+
+ #Grammar parts
+ rule(:sum) { integer.as(:left) >> operator.as(:op) >> expression.as(:right) }
+ rule(:arglist) { expression >> (comma >> expression).repeat }
+ rule(:funcall) { identifier.as(:funcall) >> lparen >> arglist.as(:arglist) >> rparen }
+
+ rule(:expression) { funcall | sum | integer }
+ root :expression
+end
+
+def parse(str)
+ mini = Mini.new
+ print "Parsing #{str}: "
+
+ p mini.parse(str)
+rescue Parslet::ParseFailed => error
+ puts error, mini.root.error_tree
+end
+
+parse "puts(1 + 2 + 3, 45)"
+
+
diff --git a/lib/sample_QTI_questions.xml b/lib/sample_QTI_questions.xml
new file mode 100644
index 0000000..70d9bef
--- /dev/null
+++ b/lib/sample_QTI_questions.xml
@@ -0,0 +1,24 @@
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
+
fs = 11025;
tt = (0:round(0.25*fs
+ ))/fs;
Which MATLAB code would you use to gene
+rate the appropriate DTMF signal to represent telephone key number
+ 5? And this is another way.]]>
+
+
+
+ φ) for the followi
+ ng sinusoid where x(t) = cos(ωt + φ);
+
]]>
+
+ function tone=note(keynum,dur)
% Returns a single sinusoid with the key and duration specified
fs = 11025;
tt = 0:1/fs:dur;
f0 = 440*2^((keynum-49)/12);
tone = cos(2*pi*f0*tt);A student wants to modify the function so that the tone created by this function has TWO frequency components. The new tone should be the sum of two sinusoids, one of which is the fundamental and the other of which has a frequency 2 times higher. The amplitudes (and phases) can be the same. Which one of the following is a correct modification that will accomplish this task?
+]]>
+
+x(t) = e2cos(5πt)cos(2πfct)Determine fc.]]>
+
+ƒ0 = 13.4 Hz. Determine the smallest integer value of the sampling rate ƒs so that no aliasing occurs. The units of ƒs are samples per second. You must justify your response by citing a theorem or property about sampling.]]>
+
+Folded Alias: Set the input frequency to ƒ0 = 13 Hz, the input phase to φ = -1.3 rads, and ƒs = 20 Hz. Write down the formula for the output signal, and then write a justification consisting of three steps:
- calculating the values of
for the blue spectral lines in the spectrum of the discrete-time signal x[n] shown in the middle plots, - aliasing
(blue to red), and - transforming x[n] into y(t) using an equation that describes the ideal D-to-C converter and uses the principal aias.
]]>
\ No newline at end of file
From c337b1b2216e5391392e24f9b370022de906b2be Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Fri, 18 May 2012 01:12:41 -0400
Subject: [PATCH 02/60] New unit test for QTI parser
---
test/unit/QTI_parser_test.rb | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 test/unit/QTI_parser_test.rb
diff --git a/test/unit/QTI_parser_test.rb b/test/unit/QTI_parser_test.rb
new file mode 100644
index 0000000..6574346
--- /dev/null
+++ b/test/unit/QTI_parser_test.rb
@@ -0,0 +1,28 @@
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
+require 'test_helper'
+require 'parslet/convenience'
+
+class QTIParserTest < ActiveSupport::TestCase
+ def setup
+ @parser = QuestionParser.new
+ end
+
+ test "leftbracket" do
+ parser = QuestionParser.new
+ assert_equal parser.leftbracket.parse("[").to_s, "["
+ end
+
+
+ test "space" do
+ parser = QuestionParser.new
+ assert_equal parser.space.parse(" ").to_s, " "
+ end
+
+ test "space?" do
+ parser = QuestionParser.new
+ assert_equal parser.space?.parse(" ").to_s, " "
+ assert_equal parser.space?.parse("").to_s, ""
+ end
+end
\ No newline at end of file
From 5dd839c9ecaf428c7e23d639a66c2b5289ffdadd Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Fri, 18 May 2012 01:13:23 -0400
Subject: [PATCH 03/60] Added exceptions to the QTI parser
---
lib/QTI_parser.rb | 44 +++++++++++++++++++++---------------------
lib/learning_parser.rb | 11 ++++++-----
2 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/lib/QTI_parser.rb b/lib/QTI_parser.rb
index 9ac9427..06a6ebd 100644
--- a/lib/QTI_parser.rb
+++ b/lib/QTI_parser.rb
@@ -4,13 +4,20 @@
require 'parslet'
require 'parslet/convenience'
-class Question < Parslet::Parser
+class QuestionParser < Parslet::Parser
+ def parse(str)
+ #p question.parse(str)
+
+ rescue Parslet::ParseFailed
+ puts "Sorry, but " + str + " contains unknown characters."
+ end
+
#Single character rules
rule(:leftbracket) { str('[') }
rule(:rightbracket) { str(']') }
- rule(:exclamation) { str('!').repeat(1) }
- rule(:lessthan) { str('<').repeat(1) >> space? }
- rule(:greaterthan) { str('>').repeat(1) >> space? }
+ rule(:exclamation) { str('!') }
+ rule(:lessthan) { str('<') >> space? }
+ rule(:greaterthan) { str('>') >> space? }
rule(:colon) { str(':') >> space? }
rule(:equal) { str('=') >> space? }
rule(:semicolon) { str(';') >> space? }
@@ -18,7 +25,13 @@ class Question < Parslet::Parser
rule(:rparen) { str(')') >> space? }
rule(:qmark) { str('?') >> space? }
rule(:underscore) { str('_') >> space? }
-
+ rule(:doublequote) { str('"') >> space? }
+ rule(:ampersand) { str('&') >> space? }
+ rule(:comma) { str(',') >> space? }
+ rule(:percent) { str('%') >> space? }
+ rule(:caret) { str('^') >> space? }
+ rule(:dash) { str('-') >> space? }
+
rule(:space) { match('\s').repeat(1) }
rule(:space?) { space.maybe }
@@ -28,31 +41,18 @@ class Question < Parslet::Parser
rule(:period) { match('\.') >> space? }
rule(:star) { match('\*') >> space? }
rule(:fslash) { match('\/') >> space? }
+ rule(:bslash) { match('\\') >> space? }
#Grammar parts
rule(:punc) { colon | greaterthan | lessthan | equal |
semicolon | lparen | rparen | period | star | fslash |
- qmark | underscore }
+ qmark | underscore | doublequote | ampersand | comma |
+ percent | caret | dash | bslash }
rule(:begin_ques) { lessthan >> exclamation >> leftbracket >>
letters >> leftbracket }
rule(:ques) { (letters | numbers | punc | end_ques ) >> ques.repeat }
rule(:end_ques) { rightbracket >> rightbracket >> greaterthan }
- rule(:expression) { begin_ques >> ques }
+ rule(:expression) { (begin_ques >> ques) | ques }
root :expression
end
-
-def parse(str)
- question = Question.new
- p question.parse(str)
-
-rescue Parslet::ParseFailed => error
- puts error, question.root.error_tree
-
-end
-
-
-parse "
fs = 11025;
tt = (0:round(0.25*fs
- ))/fs;
Which MATLAB code would you use to gene
-rate the appropriate DTMF signal to represent telephone key number
- 5? And this is another way.]]>"
diff --git a/lib/learning_parser.rb b/lib/learning_parser.rb
index 7947835..41b6e82 100644
--- a/lib/learning_parser.rb
+++ b/lib/learning_parser.rb
@@ -1,3 +1,4 @@
+# encoding: utf-8
require 'parslet'
class Mini < Parslet::Parser
@@ -23,15 +24,15 @@ class Mini < Parslet::Parser
root :expression
end
+
def parse(str)
mini = Mini.new
print "Parsing #{str}: "
p mini.parse(str)
-rescue Parslet::ParseFailed => error
- puts error, mini.root.error_tree
-end
-
-parse "puts(1 + 2 + 3, 45)"
+ rescue Exception
+ puts "Sorry, but " + str + " contains non-ASCII characters. Please replace with the correct formatting."
+end
+parse 'puts(1 + 2 + 3, ω)'
From 9770932466e86dd14631d3e853d31b96ee3a13a0 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Mon, 21 May 2012 14:38:28 -0400
Subject: [PATCH 04/60] Made the parser more flexible in terms of how it
accepts inputs, and added a unit test for individual characters, as well as
actual questions. The parser also identifies strings with non-ASCII
characters and raises an exception.
---
lib/QTI_parser.rb | 33 +------
test/unit/QTI_parser_test.rb | 186 ++++++++++++++++++++++++++++++++++-
2 files changed, 186 insertions(+), 33 deletions(-)
diff --git a/lib/QTI_parser.rb b/lib/QTI_parser.rb
index 06a6ebd..7a4d42c 100644
--- a/lib/QTI_parser.rb
+++ b/lib/QTI_parser.rb
@@ -13,25 +13,6 @@ def parse(str)
end
#Single character rules
- rule(:leftbracket) { str('[') }
- rule(:rightbracket) { str(']') }
- rule(:exclamation) { str('!') }
- rule(:lessthan) { str('<') >> space? }
- rule(:greaterthan) { str('>') >> space? }
- rule(:colon) { str(':') >> space? }
- rule(:equal) { str('=') >> space? }
- rule(:semicolon) { str(';') >> space? }
- rule(:lparen) { str('(') >> space? }
- rule(:rparen) { str(')') >> space? }
- rule(:qmark) { str('?') >> space? }
- rule(:underscore) { str('_') >> space? }
- rule(:doublequote) { str('"') >> space? }
- rule(:ampersand) { str('&') >> space? }
- rule(:comma) { str(',') >> space? }
- rule(:percent) { str('%') >> space? }
- rule(:caret) { str('^') >> space? }
- rule(:dash) { str('-') >> space? }
-
rule(:space) { match('\s').repeat(1) }
rule(:space?) { space.maybe }
@@ -42,17 +23,13 @@ def parse(str)
rule(:star) { match('\*') >> space? }
rule(:fslash) { match('\/') >> space? }
rule(:bslash) { match('\\') >> space? }
+ rule(:any) { match('.') >> space? }
#Grammar parts
- rule(:punc) { colon | greaterthan | lessthan | equal |
- semicolon | lparen | rparen | period | star | fslash |
- qmark | underscore | doublequote | ampersand | comma |
- percent | caret | dash | bslash }
- rule(:begin_ques) { lessthan >> exclamation >> leftbracket >>
- letters >> leftbracket }
- rule(:ques) { (letters | numbers | punc | end_ques ) >> ques.repeat }
- rule(:end_ques) { rightbracket >> rightbracket >> greaterthan }
+ rule(:punc) { period | star | fslash | bslash }
+ rule(:ques) { (letters | numbers | punc | any ) >> ques.repeat }
+
- rule(:expression) { (begin_ques >> ques) | ques }
+ rule(:expression) { ques }
root :expression
end
diff --git a/test/unit/QTI_parser_test.rb b/test/unit/QTI_parser_test.rb
index 6574346..2155f1b 100644
--- a/test/unit/QTI_parser_test.rb
+++ b/test/unit/QTI_parser_test.rb
@@ -1,28 +1,204 @@
+#encoding: utf-8
+
# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
# License version 3 or later. See the COPYRIGHT file for details.
require 'test_helper'
require 'parslet/convenience'
+#Sample questions used in test
+samples = Array.new
+samples[0] = '
fs = 11025;
tt = (0:round(0.25*fs
+ ))/fs;
Which MATLAB code would you use to gene
+rate the appropriate DTMF signal to represent telephone key number
+ 5? And this is another way.]]>'
+
+ samples[1] = ''
+
+ samples[2] = 'function tone=note(keynum,dur)
% Returns
+ a single sinusoid with the key and duration specified
fs = 11025;
+
tt = 0:1/fs:dur;
f0 = 440*2^((keynum-49)/12);
+ tone = cos(2*pi*f0*tt);A student wants to modify the function so
+ that the tone created by this function has TWO frequency components. The new tone
+ should be the sum of two sinusoids, one of which is the fundamental and the
+ other of which has a frequency 2 times higher. The amplitudes (and phases) can
+ be the same. Which one of the following is a correct modification that will
+ accomplish this task?]]>'
+
+samples[3] = 'x(t) = e2cos(5πt)cos(2πf
+ ct)Determine fc.]]>'
+
+samples[4] = 'ƒ0 = 13.4
+Hz. Determine the smallest integer value of the sampling
+rate ƒs so that no aliasing occurs. The units of ƒs
+ are samples per second. You must justify your response by citing a theorem or
+property about sampling.]]>'
+
+samples[5] = 'Folded Alias: Set the input frequency to ƒ0
+ = 13 Hz, the input phase to φ = -1.3 rads, and ƒs =
+ 20 Hz. Write down the formula for the output signal, and then write a justification
+ consisting of three steps:
- calculating the values of
for the blue spectral lines in the spectrum of the discrete-time signal x
+ [n] shown in the middle plots, - aliasing
+ (blue to red), and - transforming x[n] into y(t) using an equation that
+ describes the ideal D-to-C converter and uses the principal aias.
]]>'
+
+samples[6] = ' φ) for the following sinusoid
+where x(t) = cos(ωt + φ);
]]>'
+
+
class QTIParserTest < ActiveSupport::TestCase
def setup
@parser = QuestionParser.new
end
+ test "space" do
+ parser = QuestionParser.new
+ assert_equal parser.space.parse(" ").to_s, " "
+ end
+
+ test "space?" do
+ parser = QuestionParser.new
+ assert_equal parser.space?.parse(" ").to_s, " "
+ assert_equal parser.space?.parse("").to_s, ""
+ end
+
+ test "fslash" do
+ parser = QuestionParser.new
+ assert_equal parser.fslash.parse("/ ").to_s, "/ "
+ assert_equal parser.fslash.parse("/").to_s, "/"
+ end
+
+ test "lessthan" do
+ parser = QuestionParser.new
+ assert_equal parser.lessthan.parse("< ").to_s, "< "
+ assert_equal parser.lessthan.parse("<").to_s, "<"
+ end
+
+ test "greaterthan" do
+ parser = QuestionParser.new
+ assert_equal parser.greaterthan.parse("> ").to_s, "> "
+ assert_equal parser.greaterthan.parse(">").to_s,">"
+ end
+
+ test "equal" do
+ parser = QuestionParser.new
+ assert_equal parser.equal.parse("= ").to_s, "= "
+ assert_equal parser.equal.parse("=").to_s, "= "
+ end
+
+ test "underscore" do
+ parser = QuestionParser.new
+ assert_equal parser.underscore.parse("_ ").to_s,"_ "
+ assert_equal parser.underscore.parse("_").to_s,"_"
+ end
+
+ test "exclamation" do
+ parser = QuestionParser.new
+ assert_equal parser.exclamation.parse("! ").to_s, "! "
+ assert_equal parser.exclamation.parse("!").to_s, "!"
+ end
+
test "leftbracket" do
parser = QuestionParser.new
+ assert_equal parser.leftbracket.parse("[ ").to_s, "[ "
assert_equal parser.leftbracket.parse("[").to_s, "["
end
+ test "colon" do
+ parser = QuestionParser.new
+ assert_equal parser.colon.parse(": ").to_s, ": "
+ assert_equal parser.colon.parse(":").to_s, ":"
+ end
- test "space" do
+ test "semicolon" do
parser = QuestionParser.new
- assert_equal parser.space.parse(" ").to_s, " "
+ assert_equal parser.semicolon.parse("; ").to_s, "; "
+ assert_equal parser.semicolon.parse(";").to_s, ";"
end
- test "space?" do
+ test "lparen" do
parser = QuestionParser.new
- assert_equal parser.space?.parse(" ").to_s, " "
- assert_equal parser.space?.parse("").to_s, ""
+ assert_equal parser.lparen.parse("( ").to_s, "( "
+ assert_equal parser.lparen.parse("(").to_s, "("
+ end
+
+ test "rparen" do
+ parser = QuestionParser.new
+ assert_equal parser.rparen.parse(") ").to_s, ") "
+ assert_equal parser.rparen.parse(")").to_s, ")"
+ end
+
+ test "period" do
+ parser = QuestionParser.new
+ assert_equal parser.period.parse(". ").to_s, ". "
+ assert_equal parser.period.parse(".").to_s, "."
+ end
+
+ test "star" do
+ parser = QuestionParser.new
+ assert_equal parser.star.parse("* ").to_s, "* "
+ assert_equal parser.star.parse("*").to_s, "*"
+ end
+
+ test "qmark" do
+ parser = QuestionParser.new
+ assert_equal parser.qmark.parse("? ").to_s, "? "
+ assert_equal parser.qmark.parse("?").to_s, "?"
+ end
+
+ test "quote" do
+ parser = QuestionParser.new
+ assert_equal parser.quote.parse('" ').to_s, '" '
+ assert_equal parser.quote.parse('"').to_s, '"'
+ end
+
+ test "ampersand" do
+ parser = QuestionParser.new
+ assert_equal parser.ampersand.parse("& ").to_s, "& "
+ assert_equal parser.ampersand.parse("&").to_s, "&"
+ end
+
+ test "comma" do
+ parser = QuestionParser.new
+ assert_equal parser.comma.parse(", ").to_s, ", "
+ assert_equal parser.comma.parse(",").to_s, ","
+ end
+
+ test "percent" do
+ parser = QuestionParser.new
+ assert_equal parser.percent.parse("% ").to_s, "% "
+ assert_equal parser.percent.parse("%").to_s, "%"
+ end
+
+ test "caret" do
+ parser = QuestionParser.new
+ assert_equal parser.caret.parse("^ ").to_s, "^ "
+ assert_equal parser.caret.parse("^").to_s, "^"
+ end
+
+ test "hyphen" do
+ parser = QuestionParser.new
+ assert_equal parser.hyphen.parse("- ").to_s, "- "
+ assert_equal parser.hyphen.parse("-").to_s, "-"
+ end
+
+ test "bslash" do
+ parser = QuestionParser.new
+ assert_equal parser.bslash.parse("\\ ").to_s, "\\ "
+ assert_equal parser.bslash.parse("\\").to_s, "\\"
+ end
+
+ test "samples" do
+ for i in 0..(samples.length - 2) do
+ parser = QuestionParser.new
+ assert_equal parser.samples.parse(samples[i]).to_s, samples[i]
+ end
+
+ parser = QuestionParser.new
+ assert_raise(Parslet::ParseFailed) {parser.samples.parse(samples[6])}
end
end
\ No newline at end of file
From f44b892fb0813a755a976e9a20f8e47f73b80868 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Wed, 23 May 2012 00:39:09 -0400
Subject: [PATCH 05/60] Changed the parser so that it accepts almost any
character that comes through, and can deal with text written on more than one
line. All of the tests in qti_parser_test run successfully.
---
lib/qti_parser.rb | 49 ++++++++++
test/unit/qti_parser_test.rb | 182 +++++++++++++++++++++++++++++++++++
2 files changed, 231 insertions(+)
create mode 100644 lib/qti_parser.rb
create mode 100644 test/unit/qti_parser_test.rb
diff --git a/lib/qti_parser.rb b/lib/qti_parser.rb
new file mode 100644
index 0000000..8a265f5
--- /dev/null
+++ b/lib/qti_parser.rb
@@ -0,0 +1,49 @@
+#encoding: utf-8
+
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
+require 'parslet'
+require 'parslet/convenience'
+
+class QTIParser < Parslet::Parser
+ def parse(str)
+
+ rescue image_start_tag.absent?
+ puts "You need to attach " + filename + " ."
+ rescue Parslet::ParseFailed
+ puts "Sorry, but " + str + " contains unknown characters."
+ end
+
+ #Check for accompanying images
+ rule(:filename) { match['a-zA-z0-9_\.-\()\/?\\ '].repeat(1) }
+ rule(:image_start_tag) { str("
")).as(:image) }
+
+ #Check for formatting
+ rule(:italic_tag) { match("" | "").as(:italic) }
+ rule(:bold_tag) { match("" | "").as(:bold) }
+
+ #Single character rules
+ rule(:space) { match("\s").repeat(1) }
+ rule(:space?) { space.maybe }
+
+ #Things
+ rule(:letters) { (match(/\w/) >> space?).repeat(1) }
+ rule(:any) { match(/./) >> space? }
+ rule(:crlf) { match("\r\n") >> space? }
+ rule(:lf) { match("\n") >> space? }
+ rule(:eol) { crlf | lf }
+
+ #Grammar parts
+ rule(:text) { (letters | eol | any ) >> text.repeat }
+ rule(:ques) { text.repeat(1) }
+
+ rule(:expression) { ques }
+ root :expression
+end
+
+class Question_Transform < Parslet::Transform
+ rule(:italic) {"'"}
+ rule(:bold) {"!!"}
+end
\ No newline at end of file
diff --git a/test/unit/qti_parser_test.rb b/test/unit/qti_parser_test.rb
new file mode 100644
index 0000000..26447ac
--- /dev/null
+++ b/test/unit/qti_parser_test.rb
@@ -0,0 +1,182 @@
+#encoding: utf-8
+
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
+require 'test_helper'
+require 'parslet/convenience'
+
+class QTIParserTest < ActiveSupport::TestCase
+
+ def setup
+ @parser = QTIParser.new
+ end
+
+ test "space" do
+ parser = QTIParser.new
+ assert_equal parser.space.parse(" ").to_s, " "
+ end
+
+ test "space?" do
+ parser = QTIParser.new
+ assert_equal parser.space?.parse(" ").to_s, " "
+ assert_equal parser.space?.parse("").to_s, ""
+ end
+
+ test "letters" do
+ parser = QTIParser.new
+ assert_equal parser.letters.parse("aifjeovj").to_s, "aifjeovj"
+ assert_equal parser.letters.parse("ei ief ").to_s, "ei ief "
+ end
+
+ test "numbers" do
+ parser = QTIParser.new
+ assert_equal parser.letters.parse("4846473").to_s, "4846473"
+ assert_equal parser.letters.parse("38 28 482 ").to_s, "38 28 482 "
+ end
+
+ test "fslash" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("/ ").to_s, "/ "
+ assert_equal parser.any.parse("/").to_s, "/"
+ end
+
+ test "bslash" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("\\ ").to_s, "\\ "
+ assert_equal parser.any.parse("\\").to_s, "\\"
+ end
+
+ test "lparen" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("( ").to_s, "( "
+ assert_equal parser.any.parse("(").to_s, "("
+ end
+
+ test "rparen" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse(") ").to_s, ") "
+ assert_equal parser.any.parse(")").to_s, ")"
+ end
+
+ test "lbracket" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("[ ").to_s, "[ "
+ assert_equal parser.any.parse("[").to_s, "["
+ end
+
+ test "rbracket" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("] ").to_s, "] "
+ assert_equal parser.any.parse("]").to_s, "]"
+ end
+
+ test "lthan" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("< ").to_s, "< "
+ assert_equal parser.any.parse("<").to_s, "<"
+ end
+
+ test "greaterthan" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("> ").to_s, "> "
+ assert_equal parser.any.parse(">").to_s, ">"
+ end
+
+ test "equal" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("= ").to_s, "= "
+ assert_equal parser.any.parse("=").to_s, "="
+ end
+
+ test "hyphen" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("- ").to_s, "- "
+ assert_equal parser.any.parse("-").to_s, "-"
+ end
+
+ test "underscore" do
+ parser = QTIParser.new
+ assert_equal parser.letters.parse("_ ").to_s, "_ "
+ assert_equal parser.letters.parse("_").to_s, "_"
+ end
+
+ test "semicolon" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("; ").to_s, "; "
+ assert_equal parser.any.parse(";").to_s, ";"
+ end
+
+ test "colon" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse(": ").to_s, ": "
+ assert_equal parser.any.parse(":").to_s, ":"
+ end
+
+ test "comma" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse(", ").to_s, ", "
+ assert_equal parser.any.parse(",").to_s, ","
+ end
+
+ test "period" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse(". ").to_s, ". "
+ assert_equal parser.any.parse(".").to_s, "."
+ end
+
+ test "qmark" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("? ").to_s, "? "
+ assert_equal parser.any.parse("?").to_s, "?"
+ end
+
+ test "exclamation" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("! ").to_s, "! "
+ assert_equal parser.any.parse("!").to_s, "!"
+ end
+
+ test "ampersand" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("& ").to_s, "& "
+ assert_equal parser.any.parse("&").to_s, "&"
+ end
+
+ test "percent" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("% ").to_s, "% "
+ assert_equal parser.any.parse("%").to_s, "%"
+ end
+
+ test "star" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("* ").to_s, "* "
+ assert_equal parser.any.parse("*").to_s, "*"
+ end
+
+ test "caret" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse("^ ").to_s, "^ "
+ assert_equal parser.any.parse("^").to_s, "^"
+ end
+
+ test "quote" do
+ parser = QTIParser.new
+ assert_equal parser.any.parse('" ').to_s, '" '
+ assert_equal parser.any.parse('"').to_s, '"'
+ end
+
+ test "samples" do
+ parser = QTIParser.new
+ samples = Array.new
+ samples [0] = ''
+ samples [1] = 'φ) for the followi
+ ng sinusoid where x(t) = cos(ωt + φ);
+
]]>'
+ assert_nothing_raised(Parslet::ParseFailed) {parser.expression.parse(samples[0])}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.expression.parse(samples[1])}
+ end
+
+end
\ No newline at end of file
From 72af70ba7420fe60d4704778f1b7e2744fa88841 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Wed, 23 May 2012 03:17:09 -0400
Subject: [PATCH 06/60] Attempting to write an execption for images within
questions.
---
config/environment.rb | 1 +
lib/learning_parser.rb | 5 ++++-
lib/qti_parser.rb | 11 +++--------
test/unit/qti_transform_test.rb | 20 ++++++++++++++++++++
4 files changed, 28 insertions(+), 9 deletions(-)
create mode 100644 test/unit/qti_transform_test.rb
diff --git a/config/environment.rb b/config/environment.rb
index 5a88fed..6b70d82 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -13,6 +13,7 @@
require 'vote_methods'
require 'form_builder_extensions'
require 'acts_as_numberable'
+require 'qti_parser'
ActionMailer::Base.delivery_method = :sendmail
diff --git a/lib/learning_parser.rb b/lib/learning_parser.rb
index 41b6e82..86d0255 100644
--- a/lib/learning_parser.rb
+++ b/lib/learning_parser.rb
@@ -20,6 +20,7 @@ class Mini < Parslet::Parser
rule(:arglist) { expression >> (comma >> expression).repeat }
rule(:funcall) { identifier.as(:funcall) >> lparen >> arglist.as(:arglist) >> rparen }
+
rule(:expression) { funcall | sum | integer }
root :expression
end
@@ -35,4 +36,6 @@ def parse(str)
puts "Sorry, but " + str + " contains non-ASCII characters. Please replace with the correct formatting."
end
-parse 'puts(1 + 2 + 3, ω)'
+parse 'puts(1 + 2 + 3)'
+
+
diff --git a/lib/qti_parser.rb b/lib/qti_parser.rb
index 8a265f5..e673772 100644
--- a/lib/qti_parser.rb
+++ b/lib/qti_parser.rb
@@ -8,16 +8,11 @@
class QTIParser < Parslet::Parser
def parse(str)
-
- rescue image_start_tag.absent?
- puts "You need to attach " + filename + " ."
- rescue Parslet::ParseFailed
- puts "Sorry, but " + str + " contains unknown characters."
end
#Check for accompanying images
rule(:filename) { match['a-zA-z0-9_\.-\()\/?\\ '].repeat(1) }
- rule(:image_start_tag) { str("
> filename.as(:filename) >> str("\">")).as(:image) }
#Check for formatting
@@ -36,7 +31,7 @@ def parse(str)
rule(:eol) { crlf | lf }
#Grammar parts
- rule(:text) { (letters | eol | any ) >> text.repeat }
+ rule(:text) { ( image_start_tag.absent? | letters | eol | any ) >> text.repeat }
rule(:ques) { text.repeat(1) }
rule(:expression) { ques }
@@ -46,4 +41,4 @@ def parse(str)
class Question_Transform < Parslet::Transform
rule(:italic) {"'"}
rule(:bold) {"!!"}
-end
\ No newline at end of file
+end
diff --git a/test/unit/qti_transform_test.rb b/test/unit/qti_transform_test.rb
new file mode 100644
index 0000000..3bcef20
--- /dev/null
+++ b/test/unit/qti_transform_test.rb
@@ -0,0 +1,20 @@
+#encoding: utf-8
+
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
+require 'test_helper'
+require 'parslet/convenience'
+
+class QTITransfromTest < ActiveSupport::TestCase
+ #This array contains sample questions used for testing.
+ samples = Array.new
+ samples [0] = '
(blue to red), '
+
+ test "images" do
+ parser = QTIParser.new
+ assert_raise(Parslet::ParseFailed) {parser.parse(samples[0])}
+ end
+
+end
\ No newline at end of file
From 8ad5b4cfb1a2d2c6653ad2b1f865c867ee899a6d Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Fri, 25 May 2012 15:17:29 -0400
Subject: [PATCH 07/60] Fixed the parser(again). Now, the transformer will
replace HTML italic tags with the correct format. Had to change the parser
unit test to adjust for changes in output.
---
lib/qti_parser.rb | 21 +++--
test/unit/qti_parser_test.rb | 149 +++++++++++++++++++++-----------
test/unit/qti_transform_test.rb | 12 ++-
3 files changed, 121 insertions(+), 61 deletions(-)
diff --git a/lib/qti_parser.rb b/lib/qti_parser.rb
index e673772..f707999 100644
--- a/lib/qti_parser.rb
+++ b/lib/qti_parser.rb
@@ -8,6 +8,7 @@
class QTIParser < Parslet::Parser
def parse(str)
+ super(str)
end
#Check for accompanying images
@@ -16,7 +17,7 @@ def parse(str)
rule(:image) { (image_start_tag >> filename.as(:filename) >> str("\">")).as(:image) }
#Check for formatting
- rule(:italic_tag) { match("" | "").as(:italic) }
+ rule(:italic_tag) { (str("") | str("")).as(:italic) }
rule(:bold_tag) { match("" | "").as(:bold) }
#Single character rules
@@ -24,21 +25,23 @@ def parse(str)
rule(:space?) { space.maybe }
#Things
- rule(:letters) { (match(/\w/) >> space?).repeat(1) }
- rule(:any) { match(/./) >> space? }
+ rule(:letters) { (match(/\w/) >> space?).repeat(1).as(:letters) }
rule(:crlf) { match("\r\n") >> space? }
rule(:lf) { match("\n") >> space? }
- rule(:eol) { crlf | lf }
+ rule(:eol) { (crlf | lf).as(:eol) }
#Grammar parts
- rule(:text) { ( image_start_tag.absent? | letters | eol | any ) >> text.repeat }
- rule(:ques) { text.repeat(1) }
+ rule(:format) { italic_tag }
+ rule(:text) { ( format | letters | eol | (any.as(:any)) ).repeat(1) }
+ rule(:ques) { text.repeat(1).as(:text) }
rule(:expression) { ques }
root :expression
end
-class Question_Transform < Parslet::Transform
- rule(:italic) {"'"}
- rule(:bold) {"!!"}
+class QTITransform < Parslet::Transform
+ rule(:italic => simple(:italic)) {"'"}
+ rule(:letters => simple(:letters)) { letters }
+ rule(:any => simple(:any)) { any }
+ rule(:text => sequence(:entries)) { entries.join}
end
diff --git a/test/unit/qti_parser_test.rb b/test/unit/qti_parser_test.rb
index 26447ac..52cc62f 100644
--- a/test/unit/qti_parser_test.rb
+++ b/test/unit/qti_parser_test.rb
@@ -25,146 +25,193 @@ def setup
test "letters" do
parser = QTIParser.new
- assert_equal parser.letters.parse("aifjeovj").to_s, "aifjeovj"
- assert_equal parser.letters.parse("ei ief ").to_s, "ei ief "
+ a = parser.parse("aifjeovj")
+ assert_equal "aifjeovj", QTITransform.new.apply(a)
+ b = parser.parse("ei ief ")
+ assert_equal "ei ief ", QTITransform.new.apply(b)
end
test "numbers" do
parser = QTIParser.new
- assert_equal parser.letters.parse("4846473").to_s, "4846473"
- assert_equal parser.letters.parse("38 28 482 ").to_s, "38 28 482 "
+ a = parser.parse("4846473")
+ assert_equal "4846473", QTITransform.new.apply(a)
+ b = parser.parse("38 28 482 ")
+ assert_equal "38 28 482 ", QTITransform.new.apply(b)
end
test "fslash" do
parser = QTIParser.new
- assert_equal parser.any.parse("/ ").to_s, "/ "
- assert_equal parser.any.parse("/").to_s, "/"
+ a = parser.parse("/ ")
+ assert_equal "/ ", QTITransform.new.apply(a)
+ b = parser.parse("/")
+ assert_equal "/", QTITransform.new.apply(b)
end
test "bslash" do
parser = QTIParser.new
- assert_equal parser.any.parse("\\ ").to_s, "\\ "
- assert_equal parser.any.parse("\\").to_s, "\\"
+ a = parser.parse("\\ ")
+ assert_equal "\\ ", QTITransform.new.apply(a)
+ b = parser.parse("\\")
+ assert_equal "\\", QTITransform.new.apply(b)
end
-
test "lparen" do
parser = QTIParser.new
- assert_equal parser.any.parse("( ").to_s, "( "
- assert_equal parser.any.parse("(").to_s, "("
+ a = parser.parse("( ")
+ assert_equal "( ", QTITransform.new.apply(a)
+ b = parser.parse("(")
+ assert_equal "(", QTITransform.new.apply(b)
end
test "rparen" do
parser = QTIParser.new
- assert_equal parser.any.parse(") ").to_s, ") "
- assert_equal parser.any.parse(")").to_s, ")"
+ a = parser.parse(") ")
+ assert_equal ") ", QTITransform.new.apply(a)
+ b = parser.parse(")")
+ assert_equal ")", QTITransform.new.apply(b)
end
test "lbracket" do
parser = QTIParser.new
- assert_equal parser.any.parse("[ ").to_s, "[ "
- assert_equal parser.any.parse("[").to_s, "["
+ a = parser.parse("[ ")
+ assert_equal "[ ", QTITransform.new.apply(a)
+ b = parser.parse("[")
+ assert_equal "[", QTITransform.new.apply(b)
end
test "rbracket" do
parser = QTIParser.new
- assert_equal parser.any.parse("] ").to_s, "] "
- assert_equal parser.any.parse("]").to_s, "]"
+ a = parser.parse("] ")
+ assert_equal "] ", QTITransform.new.apply(a)
+ b = parser.parse("]")
+ assert_equal "]", QTITransform.new.apply(b)
end
test "lthan" do
parser = QTIParser.new
- assert_equal parser.any.parse("< ").to_s, "< "
- assert_equal parser.any.parse("<").to_s, "<"
+ a = parser.parse("< ")
+ assert_equal "< ", QTITransform.new.apply(a)
+ b = parser.parse("<")
+ assert_equal "<", QTITransform.new.apply(b)
end
test "greaterthan" do
parser = QTIParser.new
- assert_equal parser.any.parse("> ").to_s, "> "
- assert_equal parser.any.parse(">").to_s, ">"
+ a = parser.parse("> ")
+ assert_equal "> ", QTITransform.new.apply(a)
+ b = parser.parse(">")
+ assert_equal ">", QTITransform.new.apply(b)
end
test "equal" do
parser = QTIParser.new
- assert_equal parser.any.parse("= ").to_s, "= "
- assert_equal parser.any.parse("=").to_s, "="
+ a = parser.parse("= ")
+ assert_equal "= ", QTITransform.new.apply(a)
+ b = parser.parse("=")
+ assert_equal "=", QTITransform.new.apply(b)
end
test "hyphen" do
parser = QTIParser.new
- assert_equal parser.any.parse("- ").to_s, "- "
- assert_equal parser.any.parse("-").to_s, "-"
+ a = parser.parse("- ")
+ assert_equal "- ", QTITransform.new.apply(a)
+ b = parser.parse("-")
+ assert_equal "-", QTITransform.new.apply(b)
end
test "underscore" do
parser = QTIParser.new
- assert_equal parser.letters.parse("_ ").to_s, "_ "
- assert_equal parser.letters.parse("_").to_s, "_"
+ a = parser.parse("_ ")
+ assert_equal "_ ", QTITransform.new.apply(a)
+ b = parser.parse("_")
+ assert_equal "_", QTITransform.new.apply(b)
end
test "semicolon" do
parser = QTIParser.new
- assert_equal parser.any.parse("; ").to_s, "; "
- assert_equal parser.any.parse(";").to_s, ";"
+ a = parser.parse("; ")
+ assert_equal "; ", QTITransform.new.apply(a)
+ b = parser.parse(";")
+ assert_equal ";", QTITransform.new.apply(b)
end
test "colon" do
parser = QTIParser.new
- assert_equal parser.any.parse(": ").to_s, ": "
- assert_equal parser.any.parse(":").to_s, ":"
+ a = parser.parse(": ")
+ assert_equal ": ", QTITransform.new.apply(a)
+ b = parser.parse(":")
+ assert_equal ":", QTITransform.new.apply(b)
end
test "comma" do
parser = QTIParser.new
- assert_equal parser.any.parse(", ").to_s, ", "
- assert_equal parser.any.parse(",").to_s, ","
+ a = parser.parse(", ")
+ assert_equal ", ", QTITransform.new.apply(a)
+ b = parser.parse(",")
+ assert_equal ",", QTITransform.new.apply(b)
end
test "period" do
parser = QTIParser.new
- assert_equal parser.any.parse(". ").to_s, ". "
- assert_equal parser.any.parse(".").to_s, "."
+ a = parser.parse(". ")
+ assert_equal ". ", QTITransform.new.apply(a)
+ b = parser.parse(".")
+ assert_equal ".", QTITransform.new.apply(b)
end
test "qmark" do
parser = QTIParser.new
- assert_equal parser.any.parse("? ").to_s, "? "
- assert_equal parser.any.parse("?").to_s, "?"
+ a = parser.parse("? ")
+ assert_equal "? ", QTITransform.new.apply(a)
+ b = parser.parse("?")
+ assert_equal "?", QTITransform.new.apply(b)
end
test "exclamation" do
parser = QTIParser.new
- assert_equal parser.any.parse("! ").to_s, "! "
- assert_equal parser.any.parse("!").to_s, "!"
+ a = parser.parse("! ")
+ assert_equal "! ", QTITransform.new.apply(a)
+ b = parser.parse("!")
+ assert_equal "!", QTITransform.new.apply(b)
end
test "ampersand" do
parser = QTIParser.new
- assert_equal parser.any.parse("& ").to_s, "& "
- assert_equal parser.any.parse("&").to_s, "&"
+ a = parser.parse("& ")
+ assert_equal "& ", QTITransform.new.apply(a)
+ b = parser.parse("&")
+ assert_equal "&", QTITransform.new.apply(b)
end
test "percent" do
parser = QTIParser.new
- assert_equal parser.any.parse("% ").to_s, "% "
- assert_equal parser.any.parse("%").to_s, "%"
+ a = parser.parse("% ")
+ assert_equal "% ", QTITransform.new.apply(a)
+ b = parser.parse("%")
+ assert_equal "%", QTITransform.new.apply(b)
end
test "star" do
parser = QTIParser.new
- assert_equal parser.any.parse("* ").to_s, "* "
- assert_equal parser.any.parse("*").to_s, "*"
+ a = parser.parse("* ")
+ assert_equal "* ", QTITransform.new.apply(a)
+ b = parser.parse("*")
+ assert_equal "*", QTITransform.new.apply(b)
end
test "caret" do
parser = QTIParser.new
- assert_equal parser.any.parse("^ ").to_s, "^ "
- assert_equal parser.any.parse("^").to_s, "^"
+ a = parser.parse("^ ")
+ assert_equal "^ ", QTITransform.new.apply(a)
+ b = parser.parse("^")
+ assert_equal "^", QTITransform.new.apply(b)
end
test "quote" do
parser = QTIParser.new
- assert_equal parser.any.parse('" ').to_s, '" '
- assert_equal parser.any.parse('"').to_s, '"'
+ a = parser.parse('" ')
+ assert_equal '" ', QTITransform.new.apply(a)
+ b = parser.parse('"')
+ assert_equal '"', QTITransform.new.apply(b)
end
test "samples" do
@@ -175,8 +222,8 @@ def setup
samples [1] = 'φ) for the followi
ng sinusoid where x(t) = cos(ωt + φ);
]]>'
- assert_nothing_raised(Parslet::ParseFailed) {parser.expression.parse(samples[0])}
- assert_nothing_raised(Parslet::ParseFailed) {parser.expression.parse(samples[1])}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse(samples[0])}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse(samples[1])}
end
end
\ No newline at end of file
diff --git a/test/unit/qti_transform_test.rb b/test/unit/qti_transform_test.rb
index 3bcef20..4791fb5 100644
--- a/test/unit/qti_transform_test.rb
+++ b/test/unit/qti_transform_test.rb
@@ -14,7 +14,17 @@ class QTITransfromTest < ActiveSupport::TestCase
test "images" do
parser = QTIParser.new
- assert_raise(Parslet::ParseFailed) {parser.parse(samples[0])}
+ #p parser.expression.parse('if')
+ #assert_raise(Parslet::ParseFailed) {parser.parse(samples[0])}
end
+
+ test "italics" do
+ parser = QTIParser.new
+ a = parser.expression.parse('This is italics.')
+ expected = "'This is italics.'"
+ output1 = QTITransform.new.apply(a)
+ assert_equal expected, output1
+ end
+
end
\ No newline at end of file
From 3f1c8f1dce738cd256f3349b2e262cf43f9f0590 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Fri, 25 May 2012 15:19:07 -0400
Subject: [PATCH 08/60] Deleting old files
---
lib/QTI_parser.rb | 35 ------
test/unit/QTI_parser_test.rb | 204 -----------------------------------
2 files changed, 239 deletions(-)
delete mode 100644 lib/QTI_parser.rb
delete mode 100644 test/unit/QTI_parser_test.rb
diff --git a/lib/QTI_parser.rb b/lib/QTI_parser.rb
deleted file mode 100644
index 7a4d42c..0000000
--- a/lib/QTI_parser.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
-# License version 3 or later. See the COPYRIGHT file for details.
-
-require 'parslet'
-require 'parslet/convenience'
-
-class QuestionParser < Parslet::Parser
- def parse(str)
- #p question.parse(str)
-
- rescue Parslet::ParseFailed
- puts "Sorry, but " + str + " contains unknown characters."
- end
-
- #Single character rules
- rule(:space) { match('\s').repeat(1) }
- rule(:space?) { space.maybe }
-
- #Things
- rule(:letters) { match['A-Za-z'].repeat(1) >> space? }
- rule(:numbers) { match['0-9'].repeat(1) >> space? }
- rule(:period) { match('\.') >> space? }
- rule(:star) { match('\*') >> space? }
- rule(:fslash) { match('\/') >> space? }
- rule(:bslash) { match('\\') >> space? }
- rule(:any) { match('.') >> space? }
-
- #Grammar parts
- rule(:punc) { period | star | fslash | bslash }
- rule(:ques) { (letters | numbers | punc | any ) >> ques.repeat }
-
-
- rule(:expression) { ques }
- root :expression
-end
diff --git a/test/unit/QTI_parser_test.rb b/test/unit/QTI_parser_test.rb
deleted file mode 100644
index 2155f1b..0000000
--- a/test/unit/QTI_parser_test.rb
+++ /dev/null
@@ -1,204 +0,0 @@
-#encoding: utf-8
-
-# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
-# License version 3 or later. See the COPYRIGHT file for details.
-
-require 'test_helper'
-require 'parslet/convenience'
-
-#Sample questions used in test
-samples = Array.new
-samples[0] = '
fs = 11025;
tt = (0:round(0.25*fs
- ))/fs;
Which MATLAB code would you use to gene
-rate the appropriate DTMF signal to represent telephone key number
- 5? And this is another way.]]>'
-
- samples[1] = ''
-
- samples[2] = 'function tone=note(keynum,dur)
% Returns
- a single sinusoid with the key and duration specified
fs = 11025;
-
tt = 0:1/fs:dur;
f0 = 440*2^((keynum-49)/12);
- tone = cos(2*pi*f0*tt);A student wants to modify the function so
- that the tone created by this function has TWO frequency components. The new tone
- should be the sum of two sinusoids, one of which is the fundamental and the
- other of which has a frequency 2 times higher. The amplitudes (and phases) can
- be the same. Which one of the following is a correct modification that will
- accomplish this task?]]>'
-
-samples[3] = 'x(t) = e2cos(5πt)cos(2πf
- ct)Determine fc.]]>'
-
-samples[4] = 'ƒ0 = 13.4
-Hz. Determine the smallest integer value of the sampling
-rate ƒs so that no aliasing occurs. The units of ƒs
- are samples per second. You must justify your response by citing a theorem or
-property about sampling.]]>'
-
-samples[5] = 'Folded Alias: Set the input frequency to ƒ0
- = 13 Hz, the input phase to φ = -1.3 rads, and ƒs =
- 20 Hz. Write down the formula for the output signal, and then write a justification
- consisting of three steps:
- calculating the values of
for the blue spectral lines in the spectrum of the discrete-time signal x
- [n] shown in the middle plots, - aliasing
- (blue to red), and - transforming x[n] into y(t) using an equation that
- describes the ideal D-to-C converter and uses the principal aias.
]]>'
-
-samples[6] = ' φ) for the following sinusoid
-where x(t) = cos(ωt + φ);
]]>'
-
-
-class QTIParserTest < ActiveSupport::TestCase
- def setup
- @parser = QuestionParser.new
- end
-
- test "space" do
- parser = QuestionParser.new
- assert_equal parser.space.parse(" ").to_s, " "
- end
-
- test "space?" do
- parser = QuestionParser.new
- assert_equal parser.space?.parse(" ").to_s, " "
- assert_equal parser.space?.parse("").to_s, ""
- end
-
- test "fslash" do
- parser = QuestionParser.new
- assert_equal parser.fslash.parse("/ ").to_s, "/ "
- assert_equal parser.fslash.parse("/").to_s, "/"
- end
-
- test "lessthan" do
- parser = QuestionParser.new
- assert_equal parser.lessthan.parse("< ").to_s, "< "
- assert_equal parser.lessthan.parse("<").to_s, "<"
- end
-
- test "greaterthan" do
- parser = QuestionParser.new
- assert_equal parser.greaterthan.parse("> ").to_s, "> "
- assert_equal parser.greaterthan.parse(">").to_s,">"
- end
-
- test "equal" do
- parser = QuestionParser.new
- assert_equal parser.equal.parse("= ").to_s, "= "
- assert_equal parser.equal.parse("=").to_s, "= "
- end
-
- test "underscore" do
- parser = QuestionParser.new
- assert_equal parser.underscore.parse("_ ").to_s,"_ "
- assert_equal parser.underscore.parse("_").to_s,"_"
- end
-
- test "exclamation" do
- parser = QuestionParser.new
- assert_equal parser.exclamation.parse("! ").to_s, "! "
- assert_equal parser.exclamation.parse("!").to_s, "!"
- end
-
- test "leftbracket" do
- parser = QuestionParser.new
- assert_equal parser.leftbracket.parse("[ ").to_s, "[ "
- assert_equal parser.leftbracket.parse("[").to_s, "["
- end
-
- test "colon" do
- parser = QuestionParser.new
- assert_equal parser.colon.parse(": ").to_s, ": "
- assert_equal parser.colon.parse(":").to_s, ":"
- end
-
- test "semicolon" do
- parser = QuestionParser.new
- assert_equal parser.semicolon.parse("; ").to_s, "; "
- assert_equal parser.semicolon.parse(";").to_s, ";"
- end
-
- test "lparen" do
- parser = QuestionParser.new
- assert_equal parser.lparen.parse("( ").to_s, "( "
- assert_equal parser.lparen.parse("(").to_s, "("
- end
-
- test "rparen" do
- parser = QuestionParser.new
- assert_equal parser.rparen.parse(") ").to_s, ") "
- assert_equal parser.rparen.parse(")").to_s, ")"
- end
-
- test "period" do
- parser = QuestionParser.new
- assert_equal parser.period.parse(". ").to_s, ". "
- assert_equal parser.period.parse(".").to_s, "."
- end
-
- test "star" do
- parser = QuestionParser.new
- assert_equal parser.star.parse("* ").to_s, "* "
- assert_equal parser.star.parse("*").to_s, "*"
- end
-
- test "qmark" do
- parser = QuestionParser.new
- assert_equal parser.qmark.parse("? ").to_s, "? "
- assert_equal parser.qmark.parse("?").to_s, "?"
- end
-
- test "quote" do
- parser = QuestionParser.new
- assert_equal parser.quote.parse('" ').to_s, '" '
- assert_equal parser.quote.parse('"').to_s, '"'
- end
-
- test "ampersand" do
- parser = QuestionParser.new
- assert_equal parser.ampersand.parse("& ").to_s, "& "
- assert_equal parser.ampersand.parse("&").to_s, "&"
- end
-
- test "comma" do
- parser = QuestionParser.new
- assert_equal parser.comma.parse(", ").to_s, ", "
- assert_equal parser.comma.parse(",").to_s, ","
- end
-
- test "percent" do
- parser = QuestionParser.new
- assert_equal parser.percent.parse("% ").to_s, "% "
- assert_equal parser.percent.parse("%").to_s, "%"
- end
-
- test "caret" do
- parser = QuestionParser.new
- assert_equal parser.caret.parse("^ ").to_s, "^ "
- assert_equal parser.caret.parse("^").to_s, "^"
- end
-
- test "hyphen" do
- parser = QuestionParser.new
- assert_equal parser.hyphen.parse("- ").to_s, "- "
- assert_equal parser.hyphen.parse("-").to_s, "-"
- end
-
- test "bslash" do
- parser = QuestionParser.new
- assert_equal parser.bslash.parse("\\ ").to_s, "\\ "
- assert_equal parser.bslash.parse("\\").to_s, "\\"
- end
-
- test "samples" do
- for i in 0..(samples.length - 2) do
- parser = QuestionParser.new
- assert_equal parser.samples.parse(samples[i]).to_s, samples[i]
- end
-
- parser = QuestionParser.new
- assert_raise(Parslet::ParseFailed) {parser.samples.parse(samples[6])}
- end
-end
\ No newline at end of file
From 1300e7b487b083e40e63d56acf47eca2d69fe6d9 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Fri, 25 May 2012 17:50:38 -0400
Subject: [PATCH 09/60] Parser can now identify images inline in questions.
---
lib/qti_parser.rb | 11 ++++++-----
test/unit/qti_transform_test.rb | 23 ++++++++++++++++++++---
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/lib/qti_parser.rb b/lib/qti_parser.rb
index f707999..5c91476 100644
--- a/lib/qti_parser.rb
+++ b/lib/qti_parser.rb
@@ -10,11 +10,12 @@ class QTIParser < Parslet::Parser
def parse(str)
super(str)
end
-
+# [a-z]*[0-9]*\/*-*\.*\?*\\*
#Check for accompanying images
- rule(:filename) { match['a-zA-z0-9_\.-\()\/?\\ '].repeat(1) }
- rule(:image_start_tag) { match('
> filename.as(:filename) >> str("\">")).as(:image) }
+ rule(:filename) { match(/[a-z|0-9|\/|\-|\.|\?|\\]/).repeat(1).as(:filename) }
+ rule(:image_start_tag) { str('
').as(:image_end_tag) }
+ rule(:image) { (image_start_tag.as(:image_start_tag) >> ( filename | image_end_tag ).repeat).as(:image) }
#Check for formatting
rule(:italic_tag) { (str("") | str("")).as(:italic) }
@@ -32,7 +33,7 @@ def parse(str)
#Grammar parts
rule(:format) { italic_tag }
- rule(:text) { ( format | letters | eol | (any.as(:any)) ).repeat(1) }
+ rule(:text) { ( image.as(:image) | format | letters | eol | (any.as(:any)) ).repeat(1) }
rule(:ques) { text.repeat(1).as(:text) }
rule(:expression) { ques }
diff --git a/test/unit/qti_transform_test.rb b/test/unit/qti_transform_test.rb
index 4791fb5..7e34324 100644
--- a/test/unit/qti_transform_test.rb
+++ b/test/unit/qti_transform_test.rb
@@ -12,16 +12,33 @@ class QTITransfromTest < ActiveSupport::TestCase
samples [0] = '
(blue to red), '
+ test "img_filename" do
+ parser = QTIParser.new
+ a = parser.filename.parse('/ece2025/cgi-bin/mimetex.exe?\hat\om')
+ expected = "{:filename=>\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\om\"@0}"
+ assert_equal expected, a.to_s()
+ end
+
+ test "image_start_tag" do
+ parser = QTIParser.new
+ a = parser.image_start_tag.parse('
')
+ expected1 = "{:image=>[{:image_start_tag=>\"
\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\omega\"@10}, {:image_end_tag=>\"\\\">\"@49}]}"
+ assert_equal expected1,a.to_s()
#assert_raise(Parslet::ParseFailed) {parser.parse(samples[0])}
end
test "italics" do
parser = QTIParser.new
- a = parser.expression.parse('This is italics.')
- expected = "'This is italics.'"
+ a = parser.parse('aThis is italics.')
+ expected = "a'This is italics.'"
output1 = QTITransform.new.apply(a)
assert_equal expected, output1
end
From 9219a81b3f29f2fd0c38a35df7523da8f3d4da46 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Fri, 25 May 2012 21:06:01 -0400
Subject: [PATCH 10/60] Still having problems with getting the parser to
recognize images and raise an exception. But, now it replaces italic tags,
as well as bold and line break tags, with the correct formatting, regardless
of the case.
---
lib/qti_parser.rb | 17 ++++++++------
lib/quadbase_markup.rb | 2 ++
test/unit/qti_transform_test.rb | 41 +++++++++++++++++++++++++++++----
3 files changed, 48 insertions(+), 12 deletions(-)
diff --git a/lib/qti_parser.rb b/lib/qti_parser.rb
index 5c91476..37f1e2b 100644
--- a/lib/qti_parser.rb
+++ b/lib/qti_parser.rb
@@ -12,14 +12,15 @@ def parse(str)
end
# [a-z]*[0-9]*\/*-*\.*\?*\\*
#Check for accompanying images
- rule(:filename) { match(/[a-z|0-9|\/|\-|\.|\?|\\]/).repeat(1).as(:filename) }
+ rule(:filename) { match(/[a-z|0-9|\/|\-|\.|\?|\\\n\t\s]/).repeat(1).as(:filename) }
rule(:image_start_tag) { str('
').as(:image_end_tag) }
- rule(:image) { (image_start_tag.as(:image_start_tag) >> ( filename | image_end_tag ).repeat).as(:image) }
+ rule(:image) { (image_start_tag.as(:image_start_tag) >> ( filename | image_end_tag ).repeat(1)).as(:image) }
#Check for formatting
- rule(:italic_tag) { (str("") | str("")).as(:italic) }
- rule(:bold_tag) { match("" | "").as(:bold) }
+ rule(:italic_tag) { (str("") | str("") | str("") | str("")).as(:italic) }
+ rule(:bold_tag) { (str("") | str("") | str("") | str("")).as(:bold) }
+ rule(:line_break) { (str("
") | str("
")).as(:line_break)}
#Single character rules
rule(:space) { match("\s").repeat(1) }
@@ -32,8 +33,8 @@ def parse(str)
rule(:eol) { (crlf | lf).as(:eol) }
#Grammar parts
- rule(:format) { italic_tag }
- rule(:text) { ( image.as(:image) | format | letters | eol | (any.as(:any)) ).repeat(1) }
+ rule(:format) { italic_tag | bold_tag | line_break }
+ rule(:text) { ( image | format | letters | eol | (any.as(:any)) ).repeat(1) }
rule(:ques) { text.repeat(1).as(:text) }
rule(:expression) { ques }
@@ -42,7 +43,9 @@ def parse(str)
class QTITransform < Parslet::Transform
rule(:italic => simple(:italic)) {"'"}
+ rule(:bold => simple(:bold)) {"!!"}
+ rule(:line_break => simple(:break)) {"\n"}
rule(:letters => simple(:letters)) { letters }
rule(:any => simple(:any)) { any }
- rule(:text => sequence(:entries)) { entries.join}
+ rule(:text => sequence(:entries)) { entries.join }
end
diff --git a/lib/quadbase_markup.rb b/lib/quadbase_markup.rb
index 69a3783..32d2117 100644
--- a/lib/quadbase_markup.rb
+++ b/lib/quadbase_markup.rb
@@ -9,6 +9,8 @@ class QuadbaseParser < Parslet::Parser
def parse(str)
# Always make sure we have one 'paragraph'
super(str.strip + "\n\n")
+
+
end
# TODO add \# and \* as allowed in text
diff --git a/test/unit/qti_transform_test.rb b/test/unit/qti_transform_test.rb
index 7e34324..4e0aa09 100644
--- a/test/unit/qti_transform_test.rb
+++ b/test/unit/qti_transform_test.rb
@@ -9,7 +9,7 @@
class QTITransfromTest < ActiveSupport::TestCase
#This array contains sample questions used for testing.
samples = Array.new
- samples [0] = '
(blue to red), '
test "img_filename" do
@@ -35,13 +35,44 @@ class QTITransfromTest < ActiveSupport::TestCase
#assert_raise(Parslet::ParseFailed) {parser.parse(samples[0])}
end
+ test "text_w_images" do
+ parser = QTIParser.new
+ a = parser.parse(samples[0])
+ end
+
test "italics" do
parser = QTIParser.new
- a = parser.parse('aThis is italics.')
- expected = "a'This is italics.'"
+ a = parser.parse('aThis is italics.')
+ expected1 = "a'This is italics.'"
+ output1 = QTITransform.new.apply(a)
+ assert_equal expected1, output1
+ b = parser.parse('aThis is italics.')
+ expected2 = "a'This is italics.'"
+ output2 = QTITransform.new.apply(b)
+ assert_equal expected2, output2
+ end
+
+ test "bold" do
+ parser = QTIParser.new
+ a = parser.parse('aThis is bold text.')
+ expected1 = "a!!This is bold text.!!"
output1 = QTITransform.new.apply(a)
- assert_equal expected, output1
+ assert_equal expected1, output1
+ b = parser.parse('aThis is bold text.')
+ expected2 = "a!!This is bold text.!!"
+ output2 = QTITransform.new.apply(b)
+ assert_equal expected2, output2
end
-
+ test "line_break" do
+ parser = QTIParser.new
+ a = parser.parse('aThat was
unexpected.')
+ expected1 = "aThat was \nunexpected."
+ output1 = QTITransform.new.apply(a)
+ assert_equal expected1, output1
+ b = parser.parse('aThat was
unexpected.')
+ expected2 = "aThat was \nunexpected."
+ output2 = QTITransform.new.apply(b)
+ assert_equal expected2, output2
+ end
end
\ No newline at end of file
From 354d020cf6da6ec16ae238829911bc595ea37bfb Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Fri, 25 May 2012 22:17:24 -0400
Subject: [PATCH 11/60] Finally got it to recognize and raise exceptions.
---
lib/qti_parser.rb | 8 ++++++--
test/unit/qti_transform_test.rb | 8 +++++---
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/lib/qti_parser.rb b/lib/qti_parser.rb
index 37f1e2b..4e33193 100644
--- a/lib/qti_parser.rb
+++ b/lib/qti_parser.rb
@@ -14,8 +14,8 @@ def parse(str)
#Check for accompanying images
rule(:filename) { match(/[a-z|0-9|\/|\-|\.|\?|\\\n\t\s]/).repeat(1).as(:filename) }
rule(:image_start_tag) { str('
').as(:image_end_tag) }
- rule(:image) { (image_start_tag.as(:image_start_tag) >> ( filename | image_end_tag ).repeat(1)).as(:image) }
+ rule(:image_end_tag) { str('">') }
+ rule(:image) { (image_start_tag >> ( filename >> image_end_tag ).repeat(1)).as(:image) }
#Check for formatting
rule(:italic_tag) { (str("") | str("") | str("") | str("")).as(:italic) }
@@ -41,11 +41,15 @@ def parse(str)
root :expression
end
+class UnavailableImage < StandardError; end
+
class QTITransform < Parslet::Transform
rule(:italic => simple(:italic)) {"'"}
rule(:bold => simple(:bold)) {"!!"}
rule(:line_break => simple(:break)) {"\n"}
rule(:letters => simple(:letters)) { letters }
rule(:any => simple(:any)) { any }
+ rule(:image => sequence(:parts)) { raise UnavailableImage, "Image #{parts[0].to_s} must be uploaded"}
+ rule(:filename => simple(:filename)) {filename.str.gsub(/[\n\t]/, "").strip}
rule(:text => sequence(:entries)) { entries.join }
end
diff --git a/test/unit/qti_transform_test.rb b/test/unit/qti_transform_test.rb
index 4e0aa09..35faa2c 100644
--- a/test/unit/qti_transform_test.rb
+++ b/test/unit/qti_transform_test.rb
@@ -10,7 +10,7 @@ class QTITransfromTest < ActiveSupport::TestCase
#This array contains sample questions used for testing.
samples = Array.new
samples [0] = 'iejfei
(blue to red), '
+ ega"> (blue to red), '
test "img_filename" do
parser = QTIParser.new
@@ -30,14 +30,16 @@ class QTITransfromTest < ActiveSupport::TestCase
test "images" do
parser = QTIParser.new
a = parser.image.parse('
')
- expected1 = "{:image=>[{:image_start_tag=>\"
\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\omega\"@10}, {:image_end_tag=>\"\\\">\"@49}]}"
+ expected1 = "{:image=>[{:filename=>\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\omega\"@10}]}"
assert_equal expected1,a.to_s()
#assert_raise(Parslet::ParseFailed) {parser.parse(samples[0])}
end
test "text_w_images" do
parser = QTIParser.new
- a = parser.parse(samples[0])
+ a = parser.parse(samples[0])
+ #p QTITransform.new.apply(a)
+ assert_raise(UnavailableImage) {QTITransform.new.apply(a)}
end
test "italics" do
From 5d5462b7b65ab05b76cbd58036eeb36d0e5191d9 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Fri, 25 May 2012 22:34:57 -0400
Subject: [PATCH 12/60] Now replaces teletype tags with inline LaTex tags.
---
lib/qti_parser.rb | 22 +++++++++++---------
test/unit/qti_transform_test.rb | 36 +++++++++++++++++++--------------
2 files changed, 33 insertions(+), 25 deletions(-)
diff --git a/lib/qti_parser.rb b/lib/qti_parser.rb
index 4e33193..657084b 100644
--- a/lib/qti_parser.rb
+++ b/lib/qti_parser.rb
@@ -20,7 +20,8 @@ def parse(str)
#Check for formatting
rule(:italic_tag) { (str("") | str("") | str("") | str("")).as(:italic) }
rule(:bold_tag) { (str("") | str("") | str("") | str("")).as(:bold) }
- rule(:line_break) { (str("
") | str("
")).as(:line_break)}
+ rule(:line_break) { (str("
") | str("
")).as(:line_break) }
+ rule(:tt_tag) { (str("") | str("") | str("") | str("")).as(:ttype)}
#Single character rules
rule(:space) { match("\s").repeat(1) }
@@ -33,7 +34,7 @@ def parse(str)
rule(:eol) { (crlf | lf).as(:eol) }
#Grammar parts
- rule(:format) { italic_tag | bold_tag | line_break }
+ rule(:format) { italic_tag | bold_tag | line_break | tt_tag}
rule(:text) { ( image | format | letters | eol | (any.as(:any)) ).repeat(1) }
rule(:ques) { text.repeat(1).as(:text) }
@@ -44,12 +45,13 @@ def parse(str)
class UnavailableImage < StandardError; end
class QTITransform < Parslet::Transform
- rule(:italic => simple(:italic)) {"'"}
- rule(:bold => simple(:bold)) {"!!"}
- rule(:line_break => simple(:break)) {"\n"}
- rule(:letters => simple(:letters)) { letters }
- rule(:any => simple(:any)) { any }
- rule(:image => sequence(:parts)) { raise UnavailableImage, "Image #{parts[0].to_s} must be uploaded"}
- rule(:filename => simple(:filename)) {filename.str.gsub(/[\n\t]/, "").strip}
- rule(:text => sequence(:entries)) { entries.join }
+ rule(:italic => simple(:italic)) {"'"}
+ rule(:bold => simple(:bold)) {"!!"}
+ rule(:line_break => simple(:break)) {"\n"}
+ rule(:ttype => simple(:ttype)) {"$"}
+ rule(:letters => simple(:letters)) { letters }
+ rule(:any => simple(:any)) { any }
+ rule(:image => sequence(:parts)) { raise UnavailableImage, "Image #{parts[0].to_s} must be uploaded"}
+ rule(:filename => simple(:filename)) { filename.str.gsub(/[\n\t]/, "").strip }
+ rule(:text => sequence(:entries)) { entries.join }
end
diff --git a/test/unit/qti_transform_test.rb b/test/unit/qti_transform_test.rb
index 35faa2c..b6cfac2 100644
--- a/test/unit/qti_transform_test.rb
+++ b/test/unit/qti_transform_test.rb
@@ -31,50 +31,56 @@ class QTITransfromTest < ActiveSupport::TestCase
parser = QTIParser.new
a = parser.image.parse('
')
expected1 = "{:image=>[{:filename=>\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\omega\"@10}]}"
- assert_equal expected1,a.to_s()
- #assert_raise(Parslet::ParseFailed) {parser.parse(samples[0])}
+ assert_equal expected1,a.to_s()
end
test "text_w_images" do
parser = QTIParser.new
a = parser.parse(samples[0])
- #p QTITransform.new.apply(a)
assert_raise(UnavailableImage) {QTITransform.new.apply(a)}
end
test "italics" do
parser = QTIParser.new
a = parser.parse('aThis is italics.')
- expected1 = "a'This is italics.'"
+ expected = "a'This is italics.'"
output1 = QTITransform.new.apply(a)
- assert_equal expected1, output1
+ assert_equal expected, output1
b = parser.parse('aThis is italics.')
- expected2 = "a'This is italics.'"
output2 = QTITransform.new.apply(b)
- assert_equal expected2, output2
+ assert_equal expected, output2
end
test "bold" do
parser = QTIParser.new
a = parser.parse('aThis is bold text.')
- expected1 = "a!!This is bold text.!!"
+ expected = "a!!This is bold text.!!"
output1 = QTITransform.new.apply(a)
- assert_equal expected1, output1
+ assert_equal expected, output1
b = parser.parse('aThis is bold text.')
- expected2 = "a!!This is bold text.!!"
output2 = QTITransform.new.apply(b)
- assert_equal expected2, output2
+ assert_equal expected, output2
end
test "line_break" do
parser = QTIParser.new
a = parser.parse('aThat was
unexpected.')
- expected1 = "aThat was \nunexpected."
+ expected = "aThat was \nunexpected."
output1 = QTITransform.new.apply(a)
- assert_equal expected1, output1
+ assert_equal expected, output1
b = parser.parse('aThat was
unexpected.')
- expected2 = "aThat was \nunexpected."
output2 = QTITransform.new.apply(b)
- assert_equal expected2, output2
+ assert_equal expected, output2
+ end
+
+ test "teletype" do
+ parser = QTIParser.new
+ a = parser.parse('aMATH111')
+ expected = "a$MATH111$"
+ output1 = QTITransform.new.apply(a)
+ assert_equal expected, output1
+ b = parser.parse('aMATH111')
+ output2 = QTITransform.new.apply(b)
+ assert_equal expected, output2
end
end
\ No newline at end of file
From 37d9a8e2a30fc8ea8fd446c11403ad425e317828 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Fri, 25 May 2012 23:09:12 -0400
Subject: [PATCH 13/60] Recognizes and replaces paragraph tags with correct
formatting.
---
lib/qti_parser.rb | 4 +++-
test/unit/qti_transform_test.rb | 17 ++++++++++++++---
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/lib/qti_parser.rb b/lib/qti_parser.rb
index 657084b..061ad7c 100644
--- a/lib/qti_parser.rb
+++ b/lib/qti_parser.rb
@@ -22,6 +22,7 @@ def parse(str)
rule(:bold_tag) { (str("") | str("") | str("") | str("")).as(:bold) }
rule(:line_break) { (str("
") | str("
")).as(:line_break) }
rule(:tt_tag) { (str("") | str("") | str("") | str("")).as(:ttype)}
+ rule(:new_p) { (str("") | str("
") | str("") | str("
")).as(:para)}
#Single character rules
rule(:space) { match("\s").repeat(1) }
@@ -35,7 +36,7 @@ def parse(str)
#Grammar parts
rule(:format) { italic_tag | bold_tag | line_break | tt_tag}
- rule(:text) { ( image | format | letters | eol | (any.as(:any)) ).repeat(1) }
+ rule(:text) { ( image | format | letters | eol | new_p | (any.as(:any)) ).repeat(1) }
rule(:ques) { text.repeat(1).as(:text) }
rule(:expression) { ques }
@@ -49,6 +50,7 @@ class QTITransform < Parslet::Transform
rule(:bold => simple(:bold)) {"!!"}
rule(:line_break => simple(:break)) {"\n"}
rule(:ttype => simple(:ttype)) {"$"}
+ rule(:para => simple(:para)) {"\n\n"}
rule(:letters => simple(:letters)) { letters }
rule(:any => simple(:any)) { any }
rule(:image => sequence(:parts)) { raise UnavailableImage, "Image #{parts[0].to_s} must be uploaded"}
diff --git a/test/unit/qti_transform_test.rb b/test/unit/qti_transform_test.rb
index b6cfac2..2857cad 100644
--- a/test/unit/qti_transform_test.rb
+++ b/test/unit/qti_transform_test.rb
@@ -64,11 +64,11 @@ class QTITransfromTest < ActiveSupport::TestCase
test "line_break" do
parser = QTIParser.new
- a = parser.parse('aThat was
unexpected.')
- expected = "aThat was \nunexpected."
+ a = parser.parse('That was
unexpected.')
+ expected = "That was \nunexpected."
output1 = QTITransform.new.apply(a)
assert_equal expected, output1
- b = parser.parse('aThat was
unexpected.')
+ b = parser.parse('That was
unexpected.')
output2 = QTITransform.new.apply(b)
assert_equal expected, output2
end
@@ -83,4 +83,15 @@ class QTITransfromTest < ActiveSupport::TestCase
output2 = QTITransform.new.apply(b)
assert_equal expected, output2
end
+
+ test "new_paragraph" do
+ parser = QTIParser.new
+ a = parser.parse('That was unexpected
.')
+ expected = "That was \n\nunexpected\n\n."
+ output1 = QTITransform.new.apply(a)
+ assert_equal expected, output1
+ b = parser.parse('That was unexpected
.')
+ output2 = QTITransform.new.apply(b)
+ assert_equal expected, output2
+ end
end
\ No newline at end of file
From 1334f137324cf0bd734d5f6b2e9aee1ae090df03 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sat, 26 May 2012 01:57:51 -0400
Subject: [PATCH 14/60] Parser now detects for font changes and makes the
content for those changes bolded.
---
lib/qti_parser.rb | 42 ++++++++++++++++++++++-----------
test/unit/qti_transform_test.rb | 26 ++++++++++++++++++++
2 files changed, 54 insertions(+), 14 deletions(-)
diff --git a/lib/qti_parser.rb b/lib/qti_parser.rb
index 061ad7c..2f1c420 100644
--- a/lib/qti_parser.rb
+++ b/lib/qti_parser.rb
@@ -7,10 +7,11 @@
require 'parslet/convenience'
class QTIParser < Parslet::Parser
- def parse(str)
+ def parse(str)
+
super(str)
+
end
-# [a-z]*[0-9]*\/*-*\.*\?*\\*
#Check for accompanying images
rule(:filename) { match(/[a-z|0-9|\/|\-|\.|\?|\\\n\t\s]/).repeat(1).as(:filename) }
rule(:image_start_tag) { str('
") | str("") | str("") | str("")).as(:ttype)}
rule(:new_p) { (str("") | str("
") | str("") | str("
")).as(:para)}
+ #Check for any font changes
+ rule(:font1) { str("")}
+ rule(:font_open) { (font1 >> (extra_f >> font2).repeat(1)) }
+ rule(:content_f) { match(/[a-z|A-Z|0-9|\/|\-|\.|\?|\s|\\|\n|\t|\"|=]/).repeat(1).as(:content_f) }
+ rule(:font_close) { str("") }
+ rule(:font) { ( font_open >> (content_f >> font_close).repeat(1) ).as(:font) }
+
#Single character rules
rule(:space) { match("\s").repeat(1) }
rule(:space?) { space.maybe }
@@ -32,10 +42,11 @@ def parse(str)
rule(:letters) { (match(/\w/) >> space?).repeat(1).as(:letters) }
rule(:crlf) { match("\r\n") >> space? }
rule(:lf) { match("\n") >> space? }
- rule(:eol) { (crlf | lf).as(:eol) }
+ rule(:tab) { match("\t") >> space? }
+ rule(:eol) { (crlf | lf | tab).as(:eol) }
#Grammar parts
- rule(:format) { italic_tag | bold_tag | line_break | tt_tag}
+ rule(:format) { italic_tag | bold_tag | line_break | tt_tag | font }
rule(:text) { ( image | format | letters | eol | new_p | (any.as(:any)) ).repeat(1) }
rule(:ques) { text.repeat(1).as(:text) }
@@ -46,14 +57,17 @@ def parse(str)
class UnavailableImage < StandardError; end
class QTITransform < Parslet::Transform
- rule(:italic => simple(:italic)) {"'"}
- rule(:bold => simple(:bold)) {"!!"}
- rule(:line_break => simple(:break)) {"\n"}
- rule(:ttype => simple(:ttype)) {"$"}
- rule(:para => simple(:para)) {"\n\n"}
- rule(:letters => simple(:letters)) { letters }
- rule(:any => simple(:any)) { any }
- rule(:image => sequence(:parts)) { raise UnavailableImage, "Image #{parts[0].to_s} must be uploaded"}
- rule(:filename => simple(:filename)) { filename.str.gsub(/[\n\t]/, "").strip }
- rule(:text => sequence(:entries)) { entries.join }
+ rule(:italic => simple(:italic)) {"'"}
+ rule(:bold => simple(:bold)) {"!!"}
+ rule(:line_break => simple(:break)) {"\n"}
+ rule(:ttype => simple(:ttype)) {"$"}
+ rule(:para => simple(:para)) {"\n\n"}
+ rule(:eol => simple(:eol)) { eol }
+ rule(:content_f => simple(:content_f)) {"!!" + content_f + "!!"}
+ rule(:font => sequence(:font)) {"#{font[0].to_s}"}
+ rule(:letters => simple(:letters)) { letters }
+ rule(:any => simple(:any)) { any }
+ rule(:image => sequence(:parts)) { raise UnavailableImage, "Image #{parts[0].to_s} must be uploaded"}
+ rule(:filename => simple(:filename)) { filename.str.gsub(/[\n\t]/, "").strip }
+ rule(:text => sequence(:entries)) { entries.join }
end
diff --git a/test/unit/qti_transform_test.rb b/test/unit/qti_transform_test.rb
index 2857cad..c6cb174 100644
--- a/test/unit/qti_transform_test.rb
+++ b/test/unit/qti_transform_test.rb
@@ -11,6 +11,9 @@ class QTITransfromTest < ActiveSupport::TestCase
samples = Array.new
samples [0] = 'iejfei
(blue to red), '
+ samples [1] = 'Determine the smallest integer
+ value of the sampling rate'
+
test "img_filename" do
parser = QTIParser.new
@@ -94,4 +97,27 @@ class QTITransfromTest < ActiveSupport::TestCase
output2 = QTITransform.new.apply(b)
assert_equal expected, output2
end
+
+ test "font_open" do
+ parser = QTIParser.new
+ a = parser.font_open.parse('')
+ expected = ""
+ assert_equal expected, a.to_s
+ end
+
+ test "font_change" do
+ parser = QTIParser.new
+ a = parser.font.parse('blah')
+ expected = "{:font=>[{:content_f=>\"blah\"@19}]}"
+ assert_equal expected, a.to_s
+ end
+
+ test "font" do
+ parser = QTIParser.new
+ a = parser.parse(samples[1])
+ output1 = QTITransform.new.apply(a)
+ expected = "Determine the smallest !!integer!! \n\tvalue of the sampling rate"
+ assert_equal expected, output1
+ end
+
end
\ No newline at end of file
From 404f959fe299ed18dcafe498dae63c819ab041c6 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sat, 26 May 2012 05:26:45 -0400
Subject: [PATCH 15/60] Renames some files. Finished the first parser.
---
config/environment.rb | 2 +-
lib/spqr_parser.rb | 73 ++++++++++
test/unit/spqr_parser_test.rb | 229 +++++++++++++++++++++++++++++++
test/unit/spqr_transform_test.rb | 123 +++++++++++++++++
4 files changed, 426 insertions(+), 1 deletion(-)
create mode 100644 lib/spqr_parser.rb
create mode 100644 test/unit/spqr_parser_test.rb
create mode 100644 test/unit/spqr_transform_test.rb
diff --git a/config/environment.rb b/config/environment.rb
index 6b70d82..883ed9b 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -13,7 +13,7 @@
require 'vote_methods'
require 'form_builder_extensions'
require 'acts_as_numberable'
-require 'qti_parser'
+require 'spqr_parser'
ActionMailer::Base.delivery_method = :sendmail
diff --git a/lib/spqr_parser.rb b/lib/spqr_parser.rb
new file mode 100644
index 0000000..d7957b1
--- /dev/null
+++ b/lib/spqr_parser.rb
@@ -0,0 +1,73 @@
+#encoding: utf-8
+
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
+require 'parslet'
+require 'parslet/convenience'
+
+class SPQRParser < Parslet::Parser
+ def parse(str)
+
+ super(str)
+
+ end
+ #Check for accompanying images
+ rule(:filename) { match(/[a-z|0-9|\/|\-|\.|\?|\\\n\t\s]/).repeat(1).as(:filename) }
+ rule(:image_start_tag) { str('
') }
+ rule(:image) { (image_start_tag >> ( filename >> image_end_tag ).repeat(1)).as(:image) }
+
+ #Check for formatting
+ rule(:italic_tag) { (str("") | str("") | str("") | str("")).as(:italic) }
+ rule(:bold_tag) { (str("") | str("") | str("") | str("")).as(:bold) }
+ rule(:line_break) { (str("
") | str("
")).as(:line_break) }
+ rule(:tt_tag) { (str("") | str("") | str("") | str("")).as(:ttype)}
+ rule(:new_p) { (str("") | str("
") | str("") | str("
")).as(:para)}
+
+ #Check for any font changes
+ rule(:font1) { str("")}
+ rule(:font_open) { (font1 >> (extra_f >> font2).repeat(1)) }
+ rule(:content_f) { match(/[a-z|A-Z|0-9|\/|\-|\.|\?|\s|\\|\n|\t|\"|=]/).repeat(1).as(:content_f) }
+ rule(:font_close) { str("") }
+ rule(:font) { ( font_open >> (content_f >> font_close).repeat(1) ).as(:font) }
+
+ #Single character rules
+ rule(:space) { match("\s").repeat(1) }
+ rule(:space?) { space.maybe }
+
+ #Things
+ rule(:letters) { (match(/\w/) >> space?).repeat(1).as(:letters) }
+ rule(:crlf) { match("\r\n") >> space? }
+ rule(:lf) { match("\n") >> space? }
+ rule(:tab) { match("\t") >> space? }
+ rule(:eol) { (crlf | lf | tab).as(:eol) }
+
+ #Grammar parts
+ rule(:format) { italic_tag | bold_tag | line_break | tt_tag | font }
+ rule(:text) { ( image | format | letters | eol | new_p | (any.as(:any)) ).repeat(1) }
+ rule(:ques) { text.repeat(1).as(:text) }
+
+ rule(:expression) { ques }
+ root :expression
+end
+
+class UnavailableImage < StandardError; end
+
+class SPQRTransform < Parslet::Transform
+ rule(:italic => simple(:italic)) {"'"}
+ rule(:bold => simple(:bold)) {"!!"}
+ rule(:line_break => simple(:break)) {"\n"}
+ rule(:ttype => simple(:ttype)) {"$"}
+ rule(:para => simple(:para)) {"\n\n"}
+ rule(:eol => simple(:eol)) { eol }
+ rule(:content_f => simple(:content_f)) {"!!" + content_f + "!!"}
+ rule(:font => sequence(:font)) {"#{font[0].to_s}"}
+ rule(:letters => simple(:letters)) { letters }
+ rule(:any => simple(:any)) { any }
+ rule(:image => sequence(:parts)) { raise UnavailableImage, "Image #{parts[0].to_s} must be uploaded"}
+ rule(:filename => simple(:filename)) { filename.str.gsub(/[\n\t]/, "").strip }
+ rule(:text => sequence(:entries)) { entries.join }
+end
diff --git a/test/unit/spqr_parser_test.rb b/test/unit/spqr_parser_test.rb
new file mode 100644
index 0000000..d235461
--- /dev/null
+++ b/test/unit/spqr_parser_test.rb
@@ -0,0 +1,229 @@
+#encoding: utf-8
+
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
+require 'test_helper'
+require 'parslet/convenience'
+
+class SPQRParserTest < ActiveSupport::TestCase
+
+ def setup
+ @parser = SPQRParser.new
+ end
+
+ test "space" do
+ parser = SPQRParser.new
+ assert_equal parser.space.parse(" ").to_s, " "
+ end
+
+ test "space?" do
+ parser = SPQRParser.new
+ assert_equal parser.space?.parse(" ").to_s, " "
+ assert_equal parser.space?.parse("").to_s, ""
+ end
+
+ test "letters" do
+ parser = SPQRParser.new
+ a = parser.parse("aifjeovj")
+ assert_equal "aifjeovj", SPQRTransform.new.apply(a)
+ b = parser.parse("ei ief ")
+ assert_equal "ei ief ", SPQRTransform.new.apply(b)
+ end
+
+ test "numbers" do
+ parser = SPQRParser.new
+ a = parser.parse("4846473")
+ assert_equal "4846473", SPQRTransform.new.apply(a)
+ b = parser.parse("38 28 482 ")
+ assert_equal "38 28 482 ", SPQRTransform.new.apply(b)
+ end
+
+ test "fslash" do
+ parser = SPQRParser.new
+ a = parser.parse("/ ")
+ assert_equal "/ ", SPQRTransform.new.apply(a)
+ b = parser.parse("/")
+ assert_equal "/", SPQRTransform.new.apply(b)
+ end
+
+ test "bslash" do
+ parser = SPQRParser.new
+ a = parser.parse("\\ ")
+ assert_equal "\\ ", SPQRTransform.new.apply(a)
+ b = parser.parse("\\")
+ assert_equal "\\", SPQRTransform.new.apply(b)
+ end
+ test "lparen" do
+ parser = SPQRParser.new
+ a = parser.parse("( ")
+ assert_equal "( ", SPQRTransform.new.apply(a)
+ b = parser.parse("(")
+ assert_equal "(", SPQRTransform.new.apply(b)
+ end
+
+ test "rparen" do
+ parser = SPQRParser.new
+ a = parser.parse(") ")
+ assert_equal ") ", SPQRTransform.new.apply(a)
+ b = parser.parse(")")
+ assert_equal ")", SPQRTransform.new.apply(b)
+ end
+
+ test "lbracket" do
+ parser = SPQRParser.new
+ a = parser.parse("[ ")
+ assert_equal "[ ", SPQRTransform.new.apply(a)
+ b = parser.parse("[")
+ assert_equal "[", SPQRTransform.new.apply(b)
+ end
+
+ test "rbracket" do
+ parser = SPQRParser.new
+ a = parser.parse("] ")
+ assert_equal "] ", SPQRTransform.new.apply(a)
+ b = parser.parse("]")
+ assert_equal "]", SPQRTransform.new.apply(b)
+ end
+
+ test "lthan" do
+ parser = SPQRParser.new
+ a = parser.parse("< ")
+ assert_equal "< ", SPQRTransform.new.apply(a)
+ b = parser.parse("<")
+ assert_equal "<", SPQRTransform.new.apply(b)
+ end
+
+ test "greaterthan" do
+ parser = SPQRParser.new
+ a = parser.parse("> ")
+ assert_equal "> ", SPQRTransform.new.apply(a)
+ b = parser.parse(">")
+ assert_equal ">", SPQRTransform.new.apply(b)
+ end
+
+ test "equal" do
+ parser = SPQRParser.new
+ a = parser.parse("= ")
+ assert_equal "= ", SPQRTransform.new.apply(a)
+ b = parser.parse("=")
+ assert_equal "=", SPQRTransform.new.apply(b)
+ end
+
+ test "hyphen" do
+ parser = SPQRParser.new
+ a = parser.parse("- ")
+ assert_equal "- ", SPQRTransform.new.apply(a)
+ b = parser.parse("-")
+ assert_equal "-", SPQRTransform.new.apply(b)
+ end
+
+ test "underscore" do
+ parser = SPQRParser.new
+ a = parser.parse("_ ")
+ assert_equal "_ ", SPQRTransform.new.apply(a)
+ b = parser.parse("_")
+ assert_equal "_", SPQRTransform.new.apply(b)
+ end
+
+ test "semicolon" do
+ parser = SPQRParser.new
+ a = parser.parse("; ")
+ assert_equal "; ", SPQRTransform.new.apply(a)
+ b = parser.parse(";")
+ assert_equal ";", SPQRTransform.new.apply(b)
+ end
+
+ test "colon" do
+ parser = SPQRParser.new
+ a = parser.parse(": ")
+ assert_equal ": ", SPQRTransform.new.apply(a)
+ b = parser.parse(":")
+ assert_equal ":", SPQRTransform.new.apply(b)
+ end
+
+ test "comma" do
+ parser = SPQRParser.new
+ a = parser.parse(", ")
+ assert_equal ", ", SPQRTransform.new.apply(a)
+ b = parser.parse(",")
+ assert_equal ",", SPQRTransform.new.apply(b)
+ end
+
+ test "period" do
+ parser = SPQRParser.new
+ a = parser.parse(". ")
+ assert_equal ". ", SPQRTransform.new.apply(a)
+ b = parser.parse(".")
+ assert_equal ".", SPQRTransform.new.apply(b)
+ end
+
+ test "qmark" do
+ parser = SPQRParser.new
+ a = parser.parse("? ")
+ assert_equal "? ", SPQRTransform.new.apply(a)
+ b = parser.parse("?")
+ assert_equal "?", SPQRTransform.new.apply(b)
+ end
+
+ test "exclamation" do
+ parser = SPQRParser.new
+ a = parser.parse("! ")
+ assert_equal "! ", SPQRTransform.new.apply(a)
+ b = parser.parse("!")
+ assert_equal "!", SPQRTransform.new.apply(b)
+ end
+
+ test "ampersand" do
+ parser = SPQRParser.new
+ a = parser.parse("& ")
+ assert_equal "& ", SPQRTransform.new.apply(a)
+ b = parser.parse("&")
+ assert_equal "&", SPQRTransform.new.apply(b)
+ end
+
+ test "percent" do
+ parser = SPQRParser.new
+ a = parser.parse("% ")
+ assert_equal "% ", SPQRTransform.new.apply(a)
+ b = parser.parse("%")
+ assert_equal "%", SPQRTransform.new.apply(b)
+ end
+
+ test "star" do
+ parser = SPQRParser.new
+ a = parser.parse("* ")
+ assert_equal "* ", SPQRTransform.new.apply(a)
+ b = parser.parse("*")
+ assert_equal "*", SPQRTransform.new.apply(b)
+ end
+
+ test "caret" do
+ parser = SPQRParser.new
+ a = parser.parse("^ ")
+ assert_equal "^ ", SPQRTransform.new.apply(a)
+ b = parser.parse("^")
+ assert_equal "^", SPQRTransform.new.apply(b)
+ end
+
+ test "quote" do
+ parser = SPQRParser.new
+ a = parser.parse('" ')
+ assert_equal '" ', SPQRTransform.new.apply(a)
+ b = parser.parse('"')
+ assert_equal '"', SPQRTransform.new.apply(b)
+ end
+
+ test "samples" do
+ parser = SPQRParser.new
+ samples = Array.new
+ samples [0] = ''
+ samples [1] = 'φ) for the followi
+ ng sinusoid where x(t) = cos(ωt + φ);
+
]]>'
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse(samples[0])}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse(samples[1])}
+ end
+
+end
\ No newline at end of file
diff --git a/test/unit/spqr_transform_test.rb b/test/unit/spqr_transform_test.rb
new file mode 100644
index 0000000..288a025
--- /dev/null
+++ b/test/unit/spqr_transform_test.rb
@@ -0,0 +1,123 @@
+#encoding: utf-8
+
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
+require 'test_helper'
+require 'parslet/convenience'
+
+class SPQRTransfromTest < ActiveSupport::TestCase
+ #This array contains sample questions used for testing.
+ samples = Array.new
+ samples [0] = 'iejfei
(blue to red), '
+ samples [1] = 'Determine the smallest integer
+ value of the sampling rate'
+
+
+ test "img_filename" do
+ parser = SPQRParser.new
+ a = parser.filename.parse('/ece2025/cgi-bin/mimetex.exe?\hat\om')
+ expected = "{:filename=>\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\om\"@0}"
+ assert_equal expected, a.to_s()
+ end
+
+ test "image_start_tag" do
+ parser = SPQRParser.new
+ a = parser.image_start_tag.parse('
')
+ expected1 = "{:image=>[{:filename=>\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\omega\"@10}]}"
+ assert_equal expected1,a.to_s()
+ end
+
+ test "text_w_images" do
+ parser = SPQRParser.new
+ a = parser.parse(samples[0])
+ assert_raise(UnavailableImage) {SPQRTransform.new.apply(a)}
+ end
+
+ test "italics" do
+ parser = SPQRParser.new
+ a = parser.parse('aThis is italics.')
+ expected = "a'This is italics.'"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ b = parser.parse('aThis is italics.')
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected, output2
+ end
+
+ test "bold" do
+ parser = SPQRParser.new
+ a = parser.parse('aThis is bold text.')
+ expected = "a!!This is bold text.!!"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ b = parser.parse('aThis is bold text.')
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected, output2
+ end
+
+ test "line_break" do
+ parser = SPQRParser.new
+ a = parser.parse('That was
unexpected.')
+ expected = "That was \nunexpected."
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ b = parser.parse('That was
unexpected.')
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected, output2
+ end
+
+ test "teletype" do
+ parser = SPQRParser.new
+ a = parser.parse('aMATH111')
+ expected = "a$MATH111$"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ b = parser.parse('aMATH111')
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected, output2
+ end
+
+ test "new_paragraph" do
+ parser = SPQRParser.new
+ a = parser.parse('That was unexpected
.')
+ expected = "That was \n\nunexpected\n\n."
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ b = parser.parse('That was unexpected
.')
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected, output2
+ end
+
+ test "font_open" do
+ parser = SPQRParser.new
+ a = parser.font_open.parse('')
+ expected = ""
+ assert_equal expected, a.to_s
+ end
+
+ test "font_change" do
+ parser = SPQRParser.new
+ a = parser.font.parse('blah')
+ expected = "{:font=>[{:content_f=>\"blah\"@19}]}"
+ assert_equal expected, a.to_s
+ end
+
+ test "font" do
+ parser = SPQRParser.new
+ a = parser.parse(samples[1])
+ output1 = SPQRTransform.new.apply(a)
+ expected = "Determine the smallest !!integer!! \n\tvalue of the sampling rate"
+ assert_equal expected, output1
+ end
+
+end
\ No newline at end of file
From c8d12a423ebcbe484c9264a2482c44aa167c1b4a Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sat, 26 May 2012 12:29:25 -0400
Subject: [PATCH 16/60] Added replacements for greek letters, subscripts,
superscripts, and curly fs to parser. Changed error message for image to
just text stating that an image is missing.
---
config/environment.rb | 1 +
lib/spqr_parser.rb | 36 +++++++++++++++----
test/unit/spqr_transform_test.rb | 60 +++++++++++++++++++++++++++++++-
3 files changed, 89 insertions(+), 8 deletions(-)
diff --git a/config/environment.rb b/config/environment.rb
index 883ed9b..131a703 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -14,6 +14,7 @@
require 'form_builder_extensions'
require 'acts_as_numberable'
require 'spqr_parser'
+require 'smart_spqr_parser'
ActionMailer::Base.delivery_method = :sendmail
diff --git a/lib/spqr_parser.rb b/lib/spqr_parser.rb
index d7957b1..a9aad8e 100644
--- a/lib/spqr_parser.rb
+++ b/lib/spqr_parser.rb
@@ -7,10 +7,8 @@
require 'parslet/convenience'
class SPQRParser < Parslet::Parser
- def parse(str)
-
+ def parse(str)
super(str)
-
end
#Check for accompanying images
rule(:filename) { match(/[a-z|0-9|\/|\-|\.|\?|\\\n\t\s]/).repeat(1).as(:filename) }
@@ -34,6 +32,22 @@ def parse(str)
rule(:font_close) { str("") }
rule(:font) { ( font_open >> (content_f >> font_close).repeat(1) ).as(:font) }
+ #Greek letters
+ rule(:phi) { str("φ").as(:phi) }
+ rule(:pi) { str("π").as(:pi) }
+ rule(:omega) { str("ω").as(:omega) }
+ rule(:greek) { phi | pi | omega }
+
+ #Superscripts and Subscripts
+ rule(:sub1) { str("") | str("") }
+ rule(:con) { match(/[a-z|A-Z|0-9]/).repeat(1).as(:con) }
+ rule(:sub2) { str("") | str("") }
+ rule(:sub) { sub1 >> (con | greek).as(:sub) >> sub2 }
+ rule(:sup1) { str("") | str("") }
+ rule(:sup2) { str("") | str("") }
+ rule(:sup) { sup1 >> (con | greek).as(:sup) >> sup2 }
+
+
#Single character rules
rule(:space) { match("\s").repeat(1) }
rule(:space?) { space.maybe }
@@ -44,17 +58,18 @@ def parse(str)
rule(:lf) { match("\n") >> space? }
rule(:tab) { match("\t") >> space? }
rule(:eol) { (crlf | lf | tab).as(:eol) }
+ rule(:fnof) { str("ƒ").as(:fnof) }
#Grammar parts
- rule(:format) { italic_tag | bold_tag | line_break | tt_tag | font }
- rule(:text) { ( image | format | letters | eol | new_p | (any.as(:any)) ).repeat(1) }
+ rule(:format) { italic_tag | bold_tag | line_break | tt_tag | font | fnof | sub | sup }
+ rule(:text) { ( image | format | letters | eol | new_p | greek | (any.as(:any)) ).repeat(1) }
rule(:ques) { text.repeat(1).as(:text) }
rule(:expression) { ques }
root :expression
end
-class UnavailableImage < StandardError; end
+#class UnavailableImage < StandardError; end
class SPQRTransform < Parslet::Transform
rule(:italic => simple(:italic)) {"'"}
@@ -65,9 +80,16 @@ class SPQRTransform < Parslet::Transform
rule(:eol => simple(:eol)) { eol }
rule(:content_f => simple(:content_f)) {"!!" + content_f + "!!"}
rule(:font => sequence(:font)) {"#{font[0].to_s}"}
+ rule(:phi => simple(:phi)) {"\phi"}
+ rule(:pi => simple(:pi)) {"\pi"}
+ rule(:omega => simple(:omega)) {"\omega"}
+ rule(:fnof => simple(:fnof)) {"f"}
+ rule(:con => simple(:con)) { con }
+ rule(:sub => simple(:sub)) {"_{" + sub + "}"}
+ rule(:sup => simple(:sup)) {"^{" + sup + "}"}
rule(:letters => simple(:letters)) { letters }
rule(:any => simple(:any)) { any }
- rule(:image => sequence(:parts)) { raise UnavailableImage, "Image #{parts[0].to_s} must be uploaded"}
+ rule(:image => sequence(:image)) { "MISSING IMAGE: #{image[0].to_s}"}
rule(:filename => simple(:filename)) { filename.str.gsub(/[\n\t]/, "").strip }
rule(:text => sequence(:entries)) { entries.join }
end
diff --git a/test/unit/spqr_transform_test.rb b/test/unit/spqr_transform_test.rb
index 288a025..323a14a 100644
--- a/test/unit/spqr_transform_test.rb
+++ b/test/unit/spqr_transform_test.rb
@@ -40,7 +40,9 @@ class SPQRTransfromTest < ActiveSupport::TestCase
test "text_w_images" do
parser = SPQRParser.new
a = parser.parse(samples[0])
- assert_raise(UnavailableImage) {SPQRTransform.new.apply(a)}
+ expected = "iejfeiMISSING IMAGE: /ece2025/cgi-bin/mimetex.exe?\\hat\\omega (blue to red), "
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
end
test "italics" do
@@ -120,4 +122,60 @@ class SPQRTransfromTest < ActiveSupport::TestCase
assert_equal expected, output1
end
+ test "phi" do
+ parser = SPQRParser.new
+ a = parser.parse('φ')
+ expected = "\phi"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
+
+ test "pi" do
+ parser = SPQRParser.new
+ a = parser.parse('aπ')
+ expected = "a\pi"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
+
+ test "omega" do
+ parser = SPQRParser.new
+ a = parser.parse('aω')
+ expected = "a\omega"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
+
+ test "curly_f" do
+ parser = SPQRParser.new
+ a = parser.parse('ƒs')
+ expected = "fs"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
+
+ test "sub" do
+ parser = SPQRParser.new
+ a = parser.parse('aφ')
+ expected1 = "a_{phi}"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected1, output1
+ b = parser.parse('aeiew')
+ expected2 = "a_{eie}w"
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected2, output2
+ end
+
+ test "sup" do
+ parser = SPQRParser.new
+ a = parser.parse('aπ')
+ expected1 = "a^{\pi}"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected1, output1
+ b = parser.parse('biefie')
+ expected2 = "b^{iefie}"
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected2, output2
+ end
+
end
\ No newline at end of file
From e41465e9dd60c2dad30e543f5aa652d92fb92803 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sat, 26 May 2012 13:54:58 -0400
Subject: [PATCH 17/60] Created an import file that takes as inputs the
filename and the type of QTI content. It opens the files and creates a new
project titled Import.
---
Gemfile | 2 ++
Gemfile.lock | 2 ++
lib/qti_import.rb | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+)
create mode 100644 lib/qti_import.rb
diff --git a/Gemfile b/Gemfile
index 79eec6d..1526cda 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,6 +6,8 @@ gem 'rake', '0.8.7'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
+gem 'nokogiri'
+
# Deploy with Capistrano
gem 'capistrano'
diff --git a/Gemfile.lock b/Gemfile.lock
index 27e7f80..4f78d0d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -94,6 +94,7 @@ GEM
net-ssh (2.1.4)
net-ssh-gateway (1.0.1)
net-ssh (>= 1.99.1)
+ nokogiri (1.5.3)
orm_adapter (0.0.4)
paperclip (2.3.11)
activerecord (>= 2.3.0)
@@ -176,6 +177,7 @@ DEPENDENCIES
meta_where
mime-types
mysql2
+ nokogiri
paperclip (~> 2.3)
parslet (~> 1.2)
rack-ssl-enforcer
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
new file mode 100644
index 0000000..b8ada08
--- /dev/null
+++ b/lib/qti_import.rb
@@ -0,0 +1,37 @@
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
+require 'open-uri'
+require '/home/railsoer/Documents/quadbase/app/models/project.rb'
+require '/home/railsoer/Documents/quadbase/lib/spqr_parser.rb'
+
+module ImportQuestions
+ def openfile(filename)
+ f = File.open(filename)
+ doc = Nokogiri::XML(f)
+ end
+
+ def savefile(document)
+ a = File.open("/home/railsoer/Documents/values.txt",'w') {|f| f.write(document)}
+ end
+
+ def createproject
+ a = Project.create(:name => 'Import')
+ end
+end
+
+class QTImport
+ include ImportQuestions
+
+ attr_reader :filename, :content_type
+
+ def initialize(filename, content_type)
+ @filename = filename
+ @content_type = content_type
+ content = openfile(filename)
+ savefile(content)
+ import_project = createproject
+ end
+end
+
+try = QTImport.new("/home/railsoer/Documents/QTI_original.xml",'SPQR')
From c1987ff61082af46cd7a5f6c1696b2db3a052c94 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sat, 26 May 2012 14:36:05 -0400
Subject: [PATCH 18/60] Now, the import class will also decided which parser
and transformer to use based on the content type specified by the user.
---
config/environment.rb | 1 -
lib/qti_import.rb | 19 +++++++++++++++++--
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/config/environment.rb b/config/environment.rb
index 131a703..883ed9b 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -14,7 +14,6 @@
require 'form_builder_extensions'
require 'acts_as_numberable'
require 'spqr_parser'
-require 'smart_spqr_parser'
ActionMailer::Base.delivery_method = :sendmail
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index b8ada08..fc06495 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -20,17 +20,32 @@ def createproject
end
end
+# module find_parser
+# def choose_parser(content_type)
+# if
+# end
+
class QTImport
include ImportQuestions
+ # include
- attr_reader :filename, :content_type
+ attr_reader :filename, :content_type, :parser, :transformer
def initialize(filename, content_type)
@filename = filename
@content_type = content_type
content = openfile(filename)
- savefile(content)
+ #savefile(content)
import_project = createproject
+ parser, transformer = choose_import(content_type)
+ end
+
+ def choose_import(content_type)
+ if (content_type == 'SPQR')
+ a = SPQRParser.new
+ b = SPQRTransform.new
+ end
+ return a, b
end
end
From 3b917eb250e0290cd81d03a41f3a6d38db73ba9c Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sat, 26 May 2012 16:56:31 -0400
Subject: [PATCH 19/60] Import class can now grab just the relevant content,
and can pick out the question ids for each question (or will be able to).
---
lib/qti_import.rb | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index fc06495..1bf8a63 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -3,6 +3,7 @@
require 'open-uri'
require '/home/railsoer/Documents/quadbase/app/models/project.rb'
+require '/home/railsoer/Documents/quadbase/app/models/question.rb'
require '/home/railsoer/Documents/quadbase/lib/spqr_parser.rb'
module ImportQuestions
@@ -20,24 +21,44 @@ def createproject
end
end
-# module find_parser
-# def choose_parser(content_type)
-# if
-# end
+#For the SPQR content, it seems that a series of questions are embedded
+#within each tag. As such, we search and save only
+#content within each tag and "discard" the rest.
+module GetContent
+ def iterate_items(document)
+ items = document.xpath('//item').to_a
+ end
+
+ def get_questions(content)
+ a = content[0]
+ inter = a.attributes["ident"]
+ ques_name = inter.value
+ number = get_q_id(ques_name)
+ p ques_name
+ p number
+ end
+
+ def get_q_id(str)
+ value = (str.gsub("QUE_","")).to_i
+ end
+
+
+end
class QTImport
include ImportQuestions
- # include
+ include GetContent
attr_reader :filename, :content_type, :parser, :transformer
def initialize(filename, content_type)
@filename = filename
@content_type = content_type
- content = openfile(filename)
- #savefile(content)
+ document = openfile(filename)
import_project = createproject
parser, transformer = choose_import(content_type)
+ content = iterate_items(document)
+ get_questions(content)
end
def choose_import(content_type)
From 703575f9e9d2678a3822854f4c5fbb3f1f7c9e76 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sun, 27 May 2012 02:19:40 -0400
Subject: [PATCH 20/60] Ok, so this is the import class. It determines what
parser and transformer to use. It then creates one project, looks for the
first question, and grabs the first answer choice to that question. Then, it
looks for the points assigned to each answer choice and normalizes them.
Then, it assigns the correct amount of points to the first answer choice.
I'll work on iterating through answer choices next.
---
lib/qti_import.rb | 91 +++++++++++++++++++++++++++++++++++++++--------
1 file changed, 77 insertions(+), 14 deletions(-)
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index 1bf8a63..c6791ab 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -2,9 +2,10 @@
# License version 3 or later. See the COPYRIGHT file for details.
require 'open-uri'
-require '/home/railsoer/Documents/quadbase/app/models/project.rb'
-require '/home/railsoer/Documents/quadbase/app/models/question.rb'
-require '/home/railsoer/Documents/quadbase/lib/spqr_parser.rb'
+require 'project.rb'
+require 'question.rb'
+require 'spqr_parser.rb'
+require 'answer_choice.rb'
module ImportQuestions
def openfile(filename)
@@ -26,28 +27,89 @@ def createproject
#content within each tag and "discard" the rest.
module GetContent
def iterate_items(document)
- items = document.xpath('//item').to_a
+ items = document.xpath('//item')
end
- def get_questions(content)
+ def get_questions(content,parser,transformer)
a = content[0]
- inter = a.attributes["ident"]
- ques_name = inter.value
- number = get_q_id(ques_name)
- p ques_name
- p number
+ ques_num = a.attributes["ident"]
+
+ #Why is this such a roundabout way of getting the question? Well, the
+ #questions and answer choices have the same tag, with the answer choices
+ #nested more deeply. I can do a specific search for the path the answer
+ #choices are on and get those back. But, I can't do a more general
+ #search and get only questions back. Each time it returns the questions
+ #and answer choices, in sequence, but this is a problem, especially since
+ #the number of answer choices per question varies widely. Hence the
+ #roundabout method.
+ b = a.xpath('//presentation')
+ c = b[0].children.children.children
+ text = c[0].content
+ b1 = parser.parse(text)
+ ques = transformer.apply(b1)
+
+ answers = get_answers(a,parser,transformer)
+ fake_ans = AnswerChoice.new(:content => "fake", :credit => 1)
+
+ q = SimpleQuestion.new(:content => ques )
+ q.answer_choices << answers
+ q.answer_choices << fake_ans
+
+ q.save!
+ return q
+ end
+
+ def get_answers(content,parser,transformer)
+ a = content.xpath('//presentation//response_lid//mattext')
+ b = a[0]
+ text = (b.children[0]).content
+ b1 = parser.parse(text)
+ ans = transformer.apply(b1)
+ credit = get_credit(content)
+
+ choice = AnswerChoice.new(:content => ans, :credit => credit[0])
+ end
+
+ def get_credit(content)
+ a = content.xpath('//resprocessing')
+ b = a[0].children.children.children
+ b.remove_attr("respident")
+ b.children.remove
+ len = b.length
+ points = Array.new
+ for z in 0..(len-1)
+ y = b[z].element?()
+ if y == false
+ x = b[z].content
+ w = x.match(/\D/)
+ if w == nil
+ points << x.to_f
+ end
+ end
+ end
+ credits = normalize(points)
end
- def get_q_id(str)
- value = (str.gsub("QUE_","")).to_i
+ def normalize(array)
+ a = array.max
+ for z in 0..(array.length-1)
+ array[z] = array[z]/a
+ end
+ return array
end
end
+module AddQuestions
+ def add_questions(project,questions)
+ end
+end
+
class QTImport
include ImportQuestions
include GetContent
+ include AddQuestions
attr_reader :filename, :content_type, :parser, :transformer
@@ -58,9 +120,10 @@ def initialize(filename, content_type)
import_project = createproject
parser, transformer = choose_import(content_type)
content = iterate_items(document)
- get_questions(content)
+ questions = get_questions(content,parser,transformer)
+ add_questions(import_project,questions)
end
-
+private
def choose_import(content_type)
if (content_type == 'SPQR')
a = SPQRParser.new
From 0c0d9c3282f9b09b327099f859e7b768ec7361a0 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sun, 27 May 2012 03:28:35 -0400
Subject: [PATCH 21/60] Ok, so now the import class can also go through the
list of answer choices and select only those for the question being imported.
---
lib/qti_import.rb | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index c6791ab..092fade 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -32,7 +32,7 @@ def iterate_items(document)
def get_questions(content,parser,transformer)
a = content[0]
- ques_num = a.attributes["ident"]
+ ques_num = a.attributes["ident"].value
#Why is this such a roundabout way of getting the question? Well, the
#questions and answer choices have the same tag, with the answer choices
@@ -48,7 +48,7 @@ def get_questions(content,parser,transformer)
b1 = parser.parse(text)
ques = transformer.apply(b1)
- answers = get_answers(a,parser,transformer)
+ answers = get_answers(a,parser,transformer,ques_num)
fake_ans = AnswerChoice.new(:content => "fake", :credit => 1)
q = SimpleQuestion.new(:content => ques )
@@ -59,10 +59,19 @@ def get_questions(content,parser,transformer)
return q
end
- def get_answers(content,parser,transformer)
- a = content.xpath('//presentation//response_lid//mattext')
- b = a[0]
- text = (b.children[0]).content
+ def get_answers(content,parser,transformer,id_num)
+ #Find only the relevant answer choices, using the question id number
+ answers = Array.new
+ z = content.xpath('//presentation//response_lid//response_label')
+ for y in 0..(z.length-1)
+ label = z[y].attributes["ident"].value
+ x = label.match(id_num + "_A")
+ if x != nil
+ answers << z[y]
+ end
+ end
+ b = answers[0].children.children.children
+ text = b[0].content
b1 = parser.parse(text)
ans = transformer.apply(b1)
credit = get_credit(content)
From f10961aef7ea95e8c9ba1a237440af5384c610e4 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sun, 27 May 2012 03:30:41 -0400
Subject: [PATCH 22/60] Now the import class can go through the list of
relevant answer choices, parse and transform them, and add them to the
question.
---
lib/qti_import.rb | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index 092fade..0f3f433 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -52,7 +52,7 @@ def get_questions(content,parser,transformer)
fake_ans = AnswerChoice.new(:content => "fake", :credit => 1)
q = SimpleQuestion.new(:content => ques )
- q.answer_choices << answers
+ q.answer_choices << answers[0]
q.answer_choices << fake_ans
q.save!
@@ -69,14 +69,18 @@ def get_answers(content,parser,transformer,id_num)
if x != nil
answers << z[y]
end
- end
- b = answers[0].children.children.children
- text = b[0].content
- b1 = parser.parse(text)
- ans = transformer.apply(b1)
- credit = get_credit(content)
-
- choice = AnswerChoice.new(:content => ans, :credit => credit[0])
+ end
+ choices = Array.new
+ for a in 0..(answers.length-1)
+ b = answers[a].children.children.children
+ text = b[0].content
+ b1 = parser.parse(text)
+ ans = transformer.apply(b1)
+ credit = get_credit(content)
+ choice = AnswerChoice.new(:content => ans, :credit =>0)
+ choices << choice
+ end
+ return choices
end
def get_credit(content)
From d58f9b64e8cbb24f3b162f45aecb9e2a52f06512 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sun, 27 May 2012 06:07:36 -0400
Subject: [PATCH 23/60] Redid the function for finding the points for each
answer choice to search based on the question id, just like the original
function that finds the answer choices. This way, there shouldn't be any
worries of answer choices and the corresponding points value not matching.
---
lib/qti_import.rb | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index 0f3f433..c3cf1f5 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -49,6 +49,7 @@ def get_questions(content,parser,transformer)
ques = transformer.apply(b1)
answers = get_answers(a,parser,transformer,ques_num)
+ p answers
fake_ans = AnswerChoice.new(:content => "fake", :credit => 1)
q = SimpleQuestion.new(:content => ques )
@@ -71,35 +72,35 @@ def get_answers(content,parser,transformer,id_num)
end
end
choices = Array.new
+ credit = get_credit(content,id_num)
for a in 0..(answers.length-1)
b = answers[a].children.children.children
text = b[0].content
b1 = parser.parse(text)
ans = transformer.apply(b1)
- credit = get_credit(content)
- choice = AnswerChoice.new(:content => ans, :credit =>0)
+ choice = AnswerChoice.new(:content => ans, :credit => credit[a])
choices << choice
end
return choices
end
- def get_credit(content)
- a = content.xpath('//resprocessing')
- b = a[0].children.children.children
- b.remove_attr("respident")
- b.children.remove
- len = b.length
+ def get_credit(content,id_num)
+ numbers = Array.new
points = Array.new
- for z in 0..(len-1)
- y = b[z].element?()
- if y == false
- x = b[z].content
- w = x.match(/\D/)
- if w == nil
- points << x.to_f
- end
+ a = content.xpath('//resprocessing//respcondition')
+ for b in 0..(a.length-1)
+ c = a[b].children.children[1].children[0]
+ label = c.content
+ d = label.match(id_num + "_A")
+ if d != nil
+ numbers << a[b]
end
end
+ for i in 0..(numbers.length-1)
+ j = numbers[i].children.children.last
+ k = (j.content).to_f
+ points << k
+ end
credits = normalize(points)
end
From 42db9073c49842dbf47c3baa7334d28696c14901 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sun, 27 May 2012 09:18:44 -0400
Subject: [PATCH 24/60] Finished making the whole import class capable of
handling any number of questions with any number of answer choices. Also
wrote a unit test, that I will run shortly.
---
lib/qti_import.rb | 68 ++++++++++++++++++++----------------
test/unit/qti_import_test.rb | 31 ++++++++++++++++
2 files changed, 69 insertions(+), 30 deletions(-)
create mode 100644 test/unit/qti_import_test.rb
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index c3cf1f5..6ffd714 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -19,6 +19,7 @@ def savefile(document)
def createproject
a = Project.create(:name => 'Import')
+ a.add_member!(current_user)
end
end
@@ -29,35 +30,41 @@ module GetContent
def iterate_items(document)
items = document.xpath('//item')
end
-
+#Why is this such a roundabout way of getting the question? Well, the
+#questions and answer choices have the same tag, with the answer choices
+#nested more deeply. I can do a specific search for the path the answer
+#choices are on and get those back. But, I can't do a more general
+#search and get only questions back. Each time it returns the questions
+#and answer choices, in sequence, but this is a problem, especially since
+#the number of answer choices per question varies widely. Hence the
+#roundabout method.
def get_questions(content,parser,transformer)
- a = content[0]
- ques_num = a.attributes["ident"].value
-
- #Why is this such a roundabout way of getting the question? Well, the
- #questions and answer choices have the same tag, with the answer choices
- #nested more deeply. I can do a specific search for the path the answer
- #choices are on and get those back. But, I can't do a more general
- #search and get only questions back. Each time it returns the questions
- #and answer choices, in sequence, but this is a problem, especially since
- #the number of answer choices per question varies widely. Hence the
- #roundabout method.
- b = a.xpath('//presentation')
- c = b[0].children.children.children
- text = c[0].content
- b1 = parser.parse(text)
- ques = transformer.apply(b1)
-
- answers = get_answers(a,parser,transformer,ques_num)
- p answers
- fake_ans = AnswerChoice.new(:content => "fake", :credit => 1)
-
- q = SimpleQuestion.new(:content => ques )
- q.answer_choices << answers[0]
- q.answer_choices << fake_ans
-
- q.save!
- return q
+ ques = Array.new
+ ques_id = Array.new
+ questions = Array.new
+ for z in 0..(content.length-1)
+ y = content[z]
+ ques_num = y.attributes["ident"].value
+ ques_id << ques_num
+ x = y.xpath('//presentation')
+ w = x[0].children.children.children
+ text = w[0].content
+ v = parser.parse(text)
+ ques1 = transformer.apply(v)
+ ques << ques1
+ end
+ answers = get_answers(content,parser,transformer,ques_num)
+ for a in 0..(ques.length-1)
+ b = Comment.new(:message => ques_id[a])
+ q = SimpleQuestion.new(:content => ques[a])
+ q.comment_thread = b.comment_thread
+ for i in 0..(answers.length-1)
+ q.answer_choices << answers[i]
+ end
+ q.save!
+ questions << q
+ end
+ return questions
end
def get_answers(content,parser,transformer,id_num)
@@ -111,12 +118,13 @@ def normalize(array)
end
return array
end
-
-
end
module AddQuestions
def add_questions(project,questions)
+ for a in 0..(questions.length-1)
+ project.add_question!(questions[a])
+ end
end
end
diff --git a/test/unit/qti_import_test.rb b/test/unit/qti_import_test.rb
new file mode 100644
index 0000000..4281306
--- /dev/null
+++ b/test/unit/qti_import_test.rb
@@ -0,0 +1,31 @@
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
+require 'test_helper'
+
+class QTImportTest < ActiveSupport::TestCase
+ test "1_question" do
+ import = QTImport.new('/home/railsoer/Documents/spqr1.xml','SPQR')
+ assert_nothing_raised(import)
+ end
+
+ test "2_question" do
+ import = QTImport.new('home/railsoer/Documents/spqr2.xml','SPQR')
+ assert_nothing_raised(import)
+ end
+
+ test "5_question" do
+ import = QTImport.new('home/railsoer/Documents/spqr3.xml','SPQR')
+ assert_nothing_raised(import)
+ end
+
+ test "25_question" do
+ import = QTImport.new('home/railsoer/Documents/spqr4.xml','SPQR')
+ assert_nothing_raised(import)
+ end
+
+ test "all_question" do
+ import = QTImport.new('home/railsoer/Documents/spqr_original.xml','SPQR')
+ assert_nothing_raised(import)
+ end
+end
From 96203043c5d19388a2e33b139c1b4beb8563a8fa Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sun, 27 May 2012 10:28:15 -0400
Subject: [PATCH 25/60] All of the unit test for the importer work.
---
config/environment.rb | 1 +
lib/qti_import.rb | 9 +-
test/fixtures/files/spqr1.xml | 102 +
test/fixtures/files/spqr2.xml | 171 +
test/fixtures/files/spqr3.xml | 457 +
test/fixtures/files/spqr4.xml | 2482 ++
test/fixtures/files/spqr_original.xml | 51146 ++++++++++++++++++++++++
test/unit/qti_import_test.rb | 29 +-
8 files changed, 54378 insertions(+), 19 deletions(-)
create mode 100644 test/fixtures/files/spqr1.xml
create mode 100644 test/fixtures/files/spqr2.xml
create mode 100644 test/fixtures/files/spqr3.xml
create mode 100644 test/fixtures/files/spqr4.xml
create mode 100644 test/fixtures/files/spqr_original.xml
diff --git a/config/environment.rb b/config/environment.rb
index 883ed9b..6215787 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -14,6 +14,7 @@
require 'form_builder_extensions'
require 'acts_as_numberable'
require 'spqr_parser'
+require 'qti_import'
ActionMailer::Base.delivery_method = :sendmail
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index 6ffd714..8a46519 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -2,10 +2,7 @@
# License version 3 or later. See the COPYRIGHT file for details.
require 'open-uri'
-require 'project.rb'
-require 'question.rb'
require 'spqr_parser.rb'
-require 'answer_choice.rb'
module ImportQuestions
def openfile(filename)
@@ -19,7 +16,7 @@ def savefile(document)
def createproject
a = Project.create(:name => 'Import')
- a.add_member!(current_user)
+ # a.add_member!(current_user)
end
end
@@ -153,6 +150,4 @@ def choose_import(content_type)
end
return a, b
end
-end
-
-try = QTImport.new("/home/railsoer/Documents/QTI_original.xml",'SPQR')
+end
\ No newline at end of file
diff --git a/test/fixtures/files/spqr1.xml b/test/fixtures/files/spqr1.xml
new file mode 100644
index 0000000..f540637
--- /dev/null
+++ b/test/fixtures/files/spqr1.xml
@@ -0,0 +1,102 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/fixtures/files/spqr2.xml b/test/fixtures/files/spqr2.xml
new file mode 100644
index 0000000..d8c34e3
--- /dev/null
+++ b/test/fixtures/files/spqr2.xml
@@ -0,0 +1,171 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/fixtures/files/spqr3.xml b/test/fixtures/files/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/test/fixtures/files/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/fixtures/files/spqr4.xml b/test/fixtures/files/spqr4.xml
new file mode 100644
index 0000000..9185d3d
--- /dev/null
+++ b/test/fixtures/files/spqr4.xml
@@ -0,0 +1,2482 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+-
+
+
+Definition:
+
+A lowpass filter with magnitude response that supresses high frequencies of the input.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_10_A1
+
+100
+
+
+
+
+-
+
+
+z-domain is to transform time-domain signals (x[n])
into another domain where signals can be representd by polynomials and systems can be
represented by rational functions. This transformation greatly simplifies signal manipulation
and filter design. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_13_A1
+
+100
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
Assuming that the filter was designed via the Hamming-sinc formula, which one of the following can display the values of all the passband frequencies? The passband is defined as same as Bandpass Filters lab. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_15_A1
+
+0
+
+
+
+QUE_15_A2
+
+0
+
+
+
+QUE_15_A3
+
+0
+
+
+
+QUE_15_A4
+
+0
+
+
+
+QUE_15_A5
+
+0
+
+
+
+QUE_15_A6
+
+0
+
+
+
+QUE_15_A7
+
+0
+
+
+
+QUE_15_A8
+
+0
+
+
+
+QUE_15_A9
+
+0
+
+
+
+QUE_15_A10
+
+0
+
+
+
+QUE_15_A11
+
+0
+
+
+
+QUE_15_A12
+
+0
+
+
+
+QUE_15_A13
+
+0
+
+
+
+QUE_15_A14
+
+100
+
+
+
+QUE_15_A15
+
+50
+
+
+
+QUE_15_A16
+
+50
+
+
+
+QUE_15_A17
+
+20
+
+
+
+QUE_15_A18
+
+0
+
+
+
+QUE_15_A19
+
+20
+
+
+
+QUE_15_A20
+
+10
+
+
+
+
+-
+
+
+
Which coefficient is equal to -1? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_16_A1
+
+0
+
+
+
+QUE_16_A2
+
+0
+
+
+
+QUE_16_A3
+
+100
+
+
+
+QUE_16_A4
+
+0
+
+
+
+QUE_16_A5
+
+0
+
+
+
+
+-
+
+
+ For this problem you need to watch the movie and then determine the spectrum of x[n] in the movie called "Aliasing" which is the FIRST movie in this set (screen shot shown below).
+
Since x[n] is a discrete-time sinusoid, its spectrum will contain an infinite number of lines in the omega-hat domain. Select the location of two of these omega-hat frequencies (in radians).
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_18_A1
+
+0
+
+
+
+QUE_18_A2
+
+0
+
+
+
+QUE_18_A3
+
+0
+
+
+
+QUE_18_A4
+
+100
+
+
+
+QUE_18_A5
+
+0
+
+
+
+
+-
+
+
+h[n] = δ[n] + 2δ[n-1]
+
Find H(ejω) where ω is the normalized frequency called "omega-hat" in the text.
]]>
+
+
+
+
+
+jω) = 1 + 2(-1)]]>
+
+
+
+
+jω) = 1 + 2e-jω]]>
+
+
+
+
+jω) = e-jω - 2jω]]>
+
+
+
+
+jω) = e -jω + e -2jω ]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_19_A1
+
+0
+
+
+
+QUE_19_A2
+
+100
+
+
+
+QUE_19_A3
+
+0
+
+
+
+QUE_19_A4
+
+0
+
+
+
+
+-
+
+
+ pre,
+the message bits in string row vector tt,
+and termination bits in string row vector mm.
+
+
Each string row vector is an array of characters ('0' or '1') in MATLAB, e.g., '0010110101110'.
+
+
Which of the following is the correct way
+to form the bit string sent out from modem?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_21_A1
+
+0
+
+
+
+QUE_21_A2
+
+0
+
+
+
+QUE_21_A3
+
+100
+
+
+
+QUE_21_A4
+
+0
+
+
+
+QUE_21_A5
+
+0
+
+
+
+QUE_21_A6
+
+0
+
+
+
+QUE_21_A7
+
+0
+
+
+
+QUE_21_A8
+
+0
+
+
+
+
+-
+
+
+seventy-one fours?
+
Mark ALL the correct solutions.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_22_A1
+
+-30
+
+
+
+QUE_22_A2
+
+30
+
+
+
+QUE_22_A3
+
+35
+
+
+
+QUE_22_A4
+
+-30
+
+
+
+QUE_22_A5
+
+35
+
+
+
+
+-
+
+
+ -1 + z -3, what is the frequency response of this system? ]]>
+
+
+
+
+
+jω) = 1 + e -2jω]]>
+
+
+
+
+jω) = 1 - e-jω+ e-3jω]]>
+
+
+
+
+jω)=1-e-ω+3e-jω]]>
+
+
+
+
+jω) = e-jω - e-2jω + e-3jω]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_23_A1
+
+0
+
+
+
+QUE_23_A2
+
+100
+
+
+
+QUE_23_A3
+
+0
+
+
+
+QUE_23_A4
+
+0
+
+
+
+
+-
+
+
+z = -3 + j4, determine its angle in radians. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_25_A1
+
+0
+
+
+
+QUE_25_A2
+
+0
+
+
+
+QUE_25_A3
+
+100
+
+
+
+QUE_25_A4
+
+0
+
+
+
+QUE_25_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_26_A1
+
+100
+
+
+
+
+-
+
+
+magnitude of the frequency
+response of a digital bandpass filter
+H(z) when given the filter's impulse response,
+hh. Which of the following procedures will
+achieve the desired plot. Pick the BEST answer.
+
+
+
+]]>
+
+
+
+
+
+ww=-pi:pi/100:pi;
HH=freqz(hh,1,ww);
plot(ww,abs(HH)) ]]>
+
+
+
+
+ww=-pi:pi/100:pi;
HH=freqz(ww,hh);
plot(ww,abs(HH))]]>
+
+
+
+
+ww=-pi:pi/100:pi;
HH=freqz(hh,1,ww);
plot(ww,HH) ]]>
+
+
+
+
+ww=-pi:pi/100:pi;
HH=freqz(hh,ww);
plot(ww,abs(HH))]]>
+
+
+
+
+ww=-pi:pi;
HH=freqz(hh,1,ww);
plot(ww,abs(HH))]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_27_A1
+
+100
+
+
+
+QUE_27_A2
+
+0
+
+
+
+QUE_27_A3
+
+50
+
+
+
+QUE_27_A4
+
+0
+
+
+
+QUE_27_A5
+
+50
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
Which one of the following can display the MATLAB indices where the impulse response is equal to zero? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_28_A1
+
+0
+
+
+
+QUE_28_A2
+
+0
+
+
+
+QUE_28_A3
+
+0
+
+
+
+QUE_28_A4
+
+0
+
+
+
+QUE_28_A5
+
+0
+
+
+
+QUE_28_A6
+
+100
+
+
+
+QUE_28_A7
+
+50
+
+
+
+QUE_28_A8
+
+0
+
+
+
+QUE_28_A9
+
+0
+
+
+
+QUE_28_A10
+
+0
+
+
+
+QUE_28_A11
+
+0
+
+
+
+QUE_28_A12
+
+0
+
+
+
+QUE_28_A13
+
+0
+
+
+
+QUE_28_A14
+
+0
+
+
+
+QUE_28_A15
+
+0
+
+
+
+QUE_28_A16
+
+0
+
+
+
+QUE_28_A17
+
+0
+
+
+
+QUE_28_A18
+
+0
+
+
+
+QUE_28_A19
+
+0
+
+
+
+QUE_28_A20
+
+0
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
Which one of the following can display the DC value of the Frequency Reponse? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_29_A1
+
+0
+
+
+
+QUE_29_A2
+
+0
+
+
+
+QUE_29_A3
+
+0
+
+
+
+QUE_29_A4
+
+0
+
+
+
+QUE_29_A5
+
+0
+
+
+
+QUE_29_A6
+
+0
+
+
+
+QUE_29_A7
+
+0
+
+
+
+QUE_29_A8
+
+100
+
+
+
+QUE_29_A9
+
+20
+
+
+
+QUE_29_A10
+
+0
+
+
+
+QUE_29_A11
+
+0
+
+
+
+QUE_29_A12
+
+0
+
+
+
+QUE_29_A13
+
+0
+
+
+
+QUE_29_A14
+
+0
+
+
+
+QUE_29_A15
+
+0
+
+
+
+QUE_29_A16
+
+0
+
+
+
+QUE_29_A17
+
+0
+
+
+
+QUE_29_A18
+
+0
+
+
+
+QUE_29_A19
+
+0
+
+
+
+QUE_29_A20
+
+0
+
+
+
+
+-
+
+
+ HIGHPASS IIR filter, pick the correct (or BEST) one:
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_41_A1
+
+0
+
+
+
+QUE_41_A2
+
+0
+
+
+
+QUE_41_A3
+
+100
+
+
+
+QUE_41_A4
+
+0
+
+
+
+QUE_41_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_42_A1
+
+100
+
+
+
+
+-
+
+
+Highpass filter?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_43_A1
+
+0
+
+
+
+QUE_43_A2
+
+0
+
+
+
+QUE_43_A3
+
+0
+
+
+
+QUE_43_A4
+
+0
+
+
+
+QUE_43_A5
+
+0
+
+
+
+QUE_43_A6
+
+0
+
+
+
+QUE_43_A7
+
+0
+
+
+
+QUE_43_A8
+
+100
+
+
+
+
+-
+
+
+
+You have a hard time limit for this on-Line Exercise. After the time expires, you will NOT BE ABLE TO SAVE ANY MORE ANSWERS.
+Whenever you complete an answer, hit the "Save Answer" button to update your answer in the WebCT record.
+When you are finished with all the questions, hit the "FINISH" button.
+
+Check the button below to confirm that you understand these instructions
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_49_A1
+
+100
+
+
+
+
+-
+
+
+NOT allowed to discuss it with anyone else while answering these questions.
+
+
+Check the button below to confirm that you understand these instructions
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_51_A1
+
+100
+
+
+
+
+-
+
+
+(vector) argument and return the result. Only one of the functions works correctly, which one is it?
+]]>
+
+
+
+
+
+y = sqr(x)
y = x * x;
+]]>
+
+
+
+
+function sqr(x)
y = x * x;
+]]>
+
+
+
+
+function sqr(x)
y = x .* x;
+]]>
+
+
+
+
+function y=sqr(x)
x = x .* x;
+]]>
+
+
+
+
+function y=sqr(x)
y = x .* x;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_52_A1
+
+0
+
+
+
+QUE_52_A2
+
+0
+
+
+
+QUE_52_A3
+
+40
+
+
+
+QUE_52_A4
+
+40
+
+
+
+QUE_52_A5
+
+100
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/fixtures/files/spqr_original.xml b/test/fixtures/files/spqr_original.xml
new file mode 100644
index 0000000..166e652
--- /dev/null
+++ b/test/fixtures/files/spqr_original.xml
@@ -0,0 +1,51146 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+-
+
+
+Definition:
+
+A lowpass filter with magnitude response that supresses high frequencies of the input.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_10_A1
+
+100
+
+
+
+
+-
+
+
+z-domain is to transform time-domain signals (x[n])
into another domain where signals can be representd by polynomials and systems can be
represented by rational functions. This transformation greatly simplifies signal manipulation
and filter design. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_13_A1
+
+100
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
Assuming that the filter was designed via the Hamming-sinc formula, which one of the following can display the values of all the passband frequencies? The passband is defined as same as Bandpass Filters lab. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_15_A1
+
+0
+
+
+
+QUE_15_A2
+
+0
+
+
+
+QUE_15_A3
+
+0
+
+
+
+QUE_15_A4
+
+0
+
+
+
+QUE_15_A5
+
+0
+
+
+
+QUE_15_A6
+
+0
+
+
+
+QUE_15_A7
+
+0
+
+
+
+QUE_15_A8
+
+0
+
+
+
+QUE_15_A9
+
+0
+
+
+
+QUE_15_A10
+
+0
+
+
+
+QUE_15_A11
+
+0
+
+
+
+QUE_15_A12
+
+0
+
+
+
+QUE_15_A13
+
+0
+
+
+
+QUE_15_A14
+
+100
+
+
+
+QUE_15_A15
+
+50
+
+
+
+QUE_15_A16
+
+50
+
+
+
+QUE_15_A17
+
+20
+
+
+
+QUE_15_A18
+
+0
+
+
+
+QUE_15_A19
+
+20
+
+
+
+QUE_15_A20
+
+10
+
+
+
+
+-
+
+
+
Which coefficient is equal to -1? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_16_A1
+
+0
+
+
+
+QUE_16_A2
+
+0
+
+
+
+QUE_16_A3
+
+100
+
+
+
+QUE_16_A4
+
+0
+
+
+
+QUE_16_A5
+
+0
+
+
+
+
+-
+
+
+ For this problem you need to watch the movie and then determine the spectrum of x[n] in the movie called "Aliasing" which is the FIRST movie in this set (screen shot shown below).
+
Since x[n] is a discrete-time sinusoid, its spectrum will contain an infinite number of lines in the omega-hat domain. Select the location of two of these omega-hat frequencies (in radians).
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_18_A1
+
+0
+
+
+
+QUE_18_A2
+
+0
+
+
+
+QUE_18_A3
+
+0
+
+
+
+QUE_18_A4
+
+100
+
+
+
+QUE_18_A5
+
+0
+
+
+
+
+-
+
+
+h[n] = δ[n] + 2δ[n-1]
+
Find H(ejω) where ω is the normalized frequency called "omega-hat" in the text.
]]>
+
+
+
+
+
+jω) = 1 + 2(-1)]]>
+
+
+
+
+jω) = 1 + 2e-jω]]>
+
+
+
+
+jω) = e-jω - 2jω]]>
+
+
+
+
+jω) = e -jω + e -2jω ]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_19_A1
+
+0
+
+
+
+QUE_19_A2
+
+100
+
+
+
+QUE_19_A3
+
+0
+
+
+
+QUE_19_A4
+
+0
+
+
+
+
+-
+
+
+ pre,
+the message bits in string row vector tt,
+and termination bits in string row vector mm.
+
+
Each string row vector is an array of characters ('0' or '1') in MATLAB, e.g., '0010110101110'.
+
+
Which of the following is the correct way
+to form the bit string sent out from modem?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_21_A1
+
+0
+
+
+
+QUE_21_A2
+
+0
+
+
+
+QUE_21_A3
+
+100
+
+
+
+QUE_21_A4
+
+0
+
+
+
+QUE_21_A5
+
+0
+
+
+
+QUE_21_A6
+
+0
+
+
+
+QUE_21_A7
+
+0
+
+
+
+QUE_21_A8
+
+0
+
+
+
+
+-
+
+
+seventy-one fours?
+
Mark ALL the correct solutions.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_22_A1
+
+-30
+
+
+
+QUE_22_A2
+
+30
+
+
+
+QUE_22_A3
+
+35
+
+
+
+QUE_22_A4
+
+-30
+
+
+
+QUE_22_A5
+
+35
+
+
+
+
+-
+
+
+ -1 + z -3, what is the frequency response of this system? ]]>
+
+
+
+
+
+jω) = 1 + e -2jω]]>
+
+
+
+
+jω) = 1 - e-jω+ e-3jω]]>
+
+
+
+
+jω)=1-e-ω+3e-jω]]>
+
+
+
+
+jω) = e-jω - e-2jω + e-3jω]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_23_A1
+
+0
+
+
+
+QUE_23_A2
+
+100
+
+
+
+QUE_23_A3
+
+0
+
+
+
+QUE_23_A4
+
+0
+
+
+
+
+-
+
+
+z = -3 + j4, determine its angle in radians. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_25_A1
+
+0
+
+
+
+QUE_25_A2
+
+0
+
+
+
+QUE_25_A3
+
+100
+
+
+
+QUE_25_A4
+
+0
+
+
+
+QUE_25_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_26_A1
+
+100
+
+
+
+
+-
+
+
+magnitude of the frequency
+response of a digital bandpass filter
+H(z) when given the filter's impulse response,
+hh. Which of the following procedures will
+achieve the desired plot. Pick the BEST answer.
+
+
+
+]]>
+
+
+
+
+
+ww=-pi:pi/100:pi;
HH=freqz(hh,1,ww);
plot(ww,abs(HH)) ]]>
+
+
+
+
+ww=-pi:pi/100:pi;
HH=freqz(ww,hh);
plot(ww,abs(HH))]]>
+
+
+
+
+ww=-pi:pi/100:pi;
HH=freqz(hh,1,ww);
plot(ww,HH) ]]>
+
+
+
+
+ww=-pi:pi/100:pi;
HH=freqz(hh,ww);
plot(ww,abs(HH))]]>
+
+
+
+
+ww=-pi:pi;
HH=freqz(hh,1,ww);
plot(ww,abs(HH))]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_27_A1
+
+100
+
+
+
+QUE_27_A2
+
+0
+
+
+
+QUE_27_A3
+
+50
+
+
+
+QUE_27_A4
+
+0
+
+
+
+QUE_27_A5
+
+50
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
Which one of the following can display the MATLAB indices where the impulse response is equal to zero? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_28_A1
+
+0
+
+
+
+QUE_28_A2
+
+0
+
+
+
+QUE_28_A3
+
+0
+
+
+
+QUE_28_A4
+
+0
+
+
+
+QUE_28_A5
+
+0
+
+
+
+QUE_28_A6
+
+100
+
+
+
+QUE_28_A7
+
+50
+
+
+
+QUE_28_A8
+
+0
+
+
+
+QUE_28_A9
+
+0
+
+
+
+QUE_28_A10
+
+0
+
+
+
+QUE_28_A11
+
+0
+
+
+
+QUE_28_A12
+
+0
+
+
+
+QUE_28_A13
+
+0
+
+
+
+QUE_28_A14
+
+0
+
+
+
+QUE_28_A15
+
+0
+
+
+
+QUE_28_A16
+
+0
+
+
+
+QUE_28_A17
+
+0
+
+
+
+QUE_28_A18
+
+0
+
+
+
+QUE_28_A19
+
+0
+
+
+
+QUE_28_A20
+
+0
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
Which one of the following can display the DC value of the Frequency Reponse? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_29_A1
+
+0
+
+
+
+QUE_29_A2
+
+0
+
+
+
+QUE_29_A3
+
+0
+
+
+
+QUE_29_A4
+
+0
+
+
+
+QUE_29_A5
+
+0
+
+
+
+QUE_29_A6
+
+0
+
+
+
+QUE_29_A7
+
+0
+
+
+
+QUE_29_A8
+
+100
+
+
+
+QUE_29_A9
+
+20
+
+
+
+QUE_29_A10
+
+0
+
+
+
+QUE_29_A11
+
+0
+
+
+
+QUE_29_A12
+
+0
+
+
+
+QUE_29_A13
+
+0
+
+
+
+QUE_29_A14
+
+0
+
+
+
+QUE_29_A15
+
+0
+
+
+
+QUE_29_A16
+
+0
+
+
+
+QUE_29_A17
+
+0
+
+
+
+QUE_29_A18
+
+0
+
+
+
+QUE_29_A19
+
+0
+
+
+
+QUE_29_A20
+
+0
+
+
+
+
+-
+
+
+ HIGHPASS IIR filter, pick the correct (or BEST) one:
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_41_A1
+
+0
+
+
+
+QUE_41_A2
+
+0
+
+
+
+QUE_41_A3
+
+100
+
+
+
+QUE_41_A4
+
+0
+
+
+
+QUE_41_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_42_A1
+
+100
+
+
+
+
+-
+
+
+Highpass filter?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_43_A1
+
+0
+
+
+
+QUE_43_A2
+
+0
+
+
+
+QUE_43_A3
+
+0
+
+
+
+QUE_43_A4
+
+0
+
+
+
+QUE_43_A5
+
+0
+
+
+
+QUE_43_A6
+
+0
+
+
+
+QUE_43_A7
+
+0
+
+
+
+QUE_43_A8
+
+100
+
+
+
+
+-
+
+
+
+You have a hard time limit for this on-Line Exercise. After the time expires, you will NOT BE ABLE TO SAVE ANY MORE ANSWERS.
+Whenever you complete an answer, hit the "Save Answer" button to update your answer in the WebCT record.
+When you are finished with all the questions, hit the "FINISH" button.
+
+Check the button below to confirm that you understand these instructions
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_49_A1
+
+100
+
+
+
+
+-
+
+
+NOT allowed to discuss it with anyone else while answering these questions.
+
+
+Check the button below to confirm that you understand these instructions
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_51_A1
+
+100
+
+
+
+
+-
+
+
+(vector) argument and return the result. Only one of the functions works correctly, which one is it?
+]]>
+
+
+
+
+
+y = sqr(x)
y = x * x;
+]]>
+
+
+
+
+function sqr(x)
y = x * x;
+]]>
+
+
+
+
+function sqr(x)
y = x .* x;
+]]>
+
+
+
+
+function y=sqr(x)
x = x .* x;
+]]>
+
+
+
+
+function y=sqr(x)
y = x .* x;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_52_A1
+
+0
+
+
+
+QUE_52_A2
+
+0
+
+
+
+QUE_52_A3
+
+40
+
+
+
+QUE_52_A4
+
+40
+
+
+
+QUE_52_A5
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_55_A1
+
+0
+
+
+
+QUE_55_A2
+
+0
+
+
+
+QUE_55_A3
+
+0
+
+
+
+QUE_55_A4
+
+0
+
+
+
+QUE_55_A5
+
+0
+
+
+
+QUE_55_A6
+
+0
+
+
+
+QUE_55_A7
+
+0
+
+
+
+QUE_55_A8
+
+100
+
+
+
+
+-
+
+
+N = 100;
for k=1:N
x(k) = k/10;
y(k) = exp(-j*pi*x(k));
end
plot(x,abs(y));You are asked to replace this block of code by another one that has NO for loop in it. Which of the following is the correct code to make the same plot?
+]]>
+
+
+
+
+
+N = 100;
y = exp(-j*pi*x);
plot(x, abs(y)); ]]>
+
+
+
+
+N = 100;
y(k) = exp(-j*pi*(1:N)/10);
plot(k/10, abs(y));]]>
+
+
+
+
+N = 100;
y = exp(-j*pi*(1:N)/10);
plot(x, abs(y)); ]]>
+
+
+
+
+N = 100;
y = exp(-j*pi*(1:N)/10);
plot((1:N)/10, abs(y)); ]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_57_A1
+
+0
+
+
+
+QUE_57_A2
+
+0
+
+
+
+QUE_57_A3
+
+0
+
+
+
+QUE_57_A4
+
+100
+
+
+
+
+-
+
+
+NOT attend during the semester was:
+
(Note: there are 26 lectures; attendance means stayed for more than 45 minutes.)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_58_A1
+
+0
+
+
+
+QUE_58_A2
+
+0
+
+
+
+QUE_58_A3
+
+0
+
+
+
+QUE_58_A4
+
+0
+
+
+
+QUE_58_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_67_A1
+
+0
+
+
+
+QUE_67_A2
+
+0
+
+
+
+QUE_67_A3
+
+0
+
+
+
+QUE_67_A4
+
+100
+
+
+
+QUE_67_A5
+
+0
+
+
+
+
+-
+
+
+xx we want to count number of elements that are negative. Which one of the following MATLAB statements will perform that task?
+]]>
+
+
+
+
+
+count_neg(xx)
+]]>
+
+
+
+
+count(xx<0)
+]]>
+
+
+
+
+sum(xx<0)
+]]>
+
+
+
+
+for kk=1:end
if(xx<0), count=count+1, end
end]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_68_A1
+
+0
+
+
+
+QUE_68_A2
+
+0
+
+
+
+QUE_68_A3
+
+100
+
+
+
+QUE_68_A4
+
+0
+
+
+
+QUE_68_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_71_A1
+
+0
+
+
+
+QUE_71_A2
+
+100
+
+
+
+QUE_71_A3
+
+0
+
+
+
+QUE_71_A4
+
+0
+
+
+
+QUE_71_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_76_A1
+
+0
+
+
+
+QUE_76_A2
+
+0
+
+
+
+QUE_76_A3
+
+100
+
+
+
+QUE_76_A4
+
+0
+
+
+
+QUE_76_A5
+
+0
+
+
+
+
+-
+
+
+passband of a filter is a frequency region where
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_77_A1
+
+0
+
+
+
+QUE_77_A2
+
+100
+
+
+
+QUE_77_A3
+
+0
+
+
+
+QUE_77_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*pi*440*tt);
+xx2 = cos(2*pi*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being HIGHER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_78_A1
+
+0
+
+
+
+QUE_78_A2
+
+0
+
+
+
+QUE_78_A3
+
+25
+
+
+
+QUE_78_A4
+
+100
+
+
+
+QUE_78_A5
+
+0
+
+
+
+
+-
+
+
+
+ak = (pi*cos(pi*k/2))./(pi.^2 - (pi*k).^2)
+ak(ceil(length(ak)/2)+1)=0.25
+ak(ceil(length(ak)/2)-1)=0.25
+
+using the ak2sig function in MATLAB.
+
+If the FUNDAMENTAL period is defined to be To = 12, which of the following signals is synthesized (approximately) as N becomes large (>20)?
+
NOTE: The Fourier Series coefficients for |k| < N are used in the synthesis.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_80_A1
+
+50
+
+
+
+QUE_80_A2
+
+0
+
+
+
+QUE_80_A3
+
+100
+
+
+
+QUE_80_A4
+
+0
+
+
+
+QUE_80_A5
+
+0
+
+
+
+QUE_80_A6
+
+0
+
+
+
+
+-
+
+
+freqz.m function during this lab. However, this function has a STRANGE behavior if you use it to evaluate the frequency response at ONE frequency only. The work around is to invoke freqz.m with two frequencies, even if you only want one. For example, you could repeat the frequency of interest to make a two-element vector of frequencies.
+
+** TIME LIMIT **
+
+Here is the usual warning: You have a hard time limit for this on-Line Exercise. After the time expires, you will NOT BE ABLE TO SAVE ANY MORE ANSWERS.
+Whenever you complete an answer, hit the "Save Answer" button, and that will update the timer. Hit the "FINISH" button when you finish all the questions,
+
+Check the button below to confirm that you understand these instructions.
+]]>
+
+
+
+
+
+freqz.m
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_81_A1
+
+100
+
+
+
+
+-
+
+
+Netscape Issue With WebCT Quizes:
+
+If you wish to resize your quiz window when taking a quiz using a Netscape web browser, you MUST resize it and then press "CTRL-R" to reload the screen BEFORE you enter any answers.
+
+
+Check the button below to confirm that you understand these instructions
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_84_A1
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_91_A1
+
+0
+
+
+
+QUE_91_A2
+
+0
+
+
+
+QUE_91_A3
+
+0
+
+
+
+QUE_91_A4
+
+0
+
+
+
+QUE_91_A5
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_92_A1
+
+100
+
+
+
+QUE_92_A2
+
+0
+
+
+
+QUE_92_A3
+
+0
+
+
+
+QUE_92_A4
+
+0
+
+
+
+QUE_92_A5
+
+0
+
+
+
+
+-
+
+
+stopband of a filter is a frequency region where
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_93_A1
+
+0
+
+
+
+QUE_93_A2
+
+0
+
+
+
+QUE_93_A3
+
+0
+
+
+
+QUE_93_A4
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_94_A1
+
+100
+
+
+
+QUE_94_A2
+
+0
+
+
+
+QUE_94_A3
+
+0
+
+
+
+QUE_94_A4
+
+0
+
+
+
+QUE_94_A5
+
+0
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
Which one of the following can display the length of the impulse response? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_95_A1
+
+0
+
+
+
+QUE_95_A2
+
+0
+
+
+
+QUE_95_A3
+
+100
+
+
+
+QUE_95_A4
+
+0
+
+
+
+QUE_95_A5
+
+0
+
+
+
+QUE_95_A6
+
+0
+
+
+
+QUE_95_A7
+
+0
+
+
+
+QUE_95_A8
+
+0
+
+
+
+QUE_95_A9
+
+0
+
+
+
+QUE_95_A10
+
+0
+
+
+
+QUE_95_A11
+
+0
+
+
+
+QUE_95_A12
+
+0
+
+
+
+QUE_95_A13
+
+0
+
+
+
+QUE_95_A14
+
+0
+
+
+
+QUE_95_A15
+
+0
+
+
+
+QUE_95_A16
+
+0
+
+
+
+QUE_95_A17
+
+0
+
+
+
+QUE_95_A18
+
+0
+
+
+
+QUE_95_A19
+
+0
+
+
+
+QUE_95_A20
+
+0
+
+
+
+
+-
+
+
+decaying sinusoidal signal for the impulse response?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_96_A1
+
+25
+
+
+
+QUE_96_A2
+
+0
+
+
+
+QUE_96_A3
+
+100
+
+
+
+QUE_96_A4
+
+0
+
+
+
+QUE_96_A5
+
+25
+
+
+
+QUE_96_A6
+
+0
+
+
+
+QUE_96_A7
+
+0
+
+
+
+QUE_96_A8
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_97_A1
+
+0
+
+
+
+QUE_97_A2
+
+0
+
+
+
+QUE_97_A3
+
+0
+
+
+
+QUE_97_A4
+
+0
+
+
+
+QUE_97_A5
+
+0
+
+
+
+QUE_97_A6
+
+0
+
+
+
+QUE_97_A7
+
+0
+
+
+
+QUE_97_A8
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_98_A1
+
+0
+
+
+
+QUE_98_A2
+
+0
+
+
+
+QUE_98_A3
+
+0
+
+
+
+QUE_98_A4
+
+0
+
+
+
+QUE_98_A5
+
+0
+
+
+
+QUE_98_A6
+
+0
+
+
+
+QUE_98_A7
+
+0
+
+
+
+QUE_98_A8
+
+0
+
+
+
+
+-
+
+
+before going to lab.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_99_A1
+
+0
+
+
+
+QUE_99_A2
+
+0
+
+
+
+QUE_99_A3
+
+0
+
+
+
+QUE_99_A4
+
+0
+
+
+
+QUE_99_A5
+
+0
+
+
+
+
+-
+
+
+ mm,
+the message bits in string row vector pp,
+and termination bits in string row vector term.
+
+
Each string row vector is an array of characters ('0' or '1') in MATLAB, e.g., '0010110101110'.
+
+
Which of the following is the correct way
+to form the bit string sent out from modem?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_102_A1
+
+100
+
+
+
+QUE_102_A2
+
+0
+
+
+
+QUE_102_A3
+
+0
+
+
+
+QUE_102_A4
+
+0
+
+
+
+QUE_102_A5
+
+0
+
+
+
+QUE_102_A6
+
+0
+
+
+
+QUE_102_A7
+
+0
+
+
+
+QUE_102_A8
+
+0
+
+
+
+
+-
+
+
+ {+j, -j, -1},
+describe the type of filter in terms of its frequency response.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_108_A1
+
+0
+
+
+
+QUE_108_A2
+
+25
+
+
+
+QUE_108_A3
+
+0
+
+
+
+QUE_108_A4
+
+100
+
+
+
+QUE_108_A5
+
+25
+
+
+
+QUE_108_A6
+
+25
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_109_A1
+
+0
+
+
+
+QUE_109_A2
+
+0
+
+
+
+QUE_109_A3
+
+0
+
+
+
+QUE_109_A4
+
+0
+
+
+
+QUE_109_A5
+
+0
+
+
+
+
+-
+
+
+SS ?
+
+SS = struct('A',7,'f',440,'fs',8000,'dur',2);
+
+
Assume the standard interpretation for the parameter names of the sinusoid.
+]]>
+
+
+
+
+
+ A*cos(2*pi*f*t);
+]]>
+
+
+
+
+ SS.A*cos(2*pi*SS.f*(0:1/SS.fs:SS.dur));
+]]>
+
+
+
+
+ SS.A*cos(2*pi*SS.f*SS.t);
+]]>
+
+
+
+
+ A*cos(2*pi*f*(0:1/fs:dur));
+]]>
+
+
+
+
+ real( SS.A*exp(j*2*pi*SS.f/SS.fs*tt) );
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_114_A1
+
+0
+
+
+
+QUE_114_A2
+
+100
+
+
+
+QUE_114_A3
+
+0
+
+
+
+QUE_114_A4
+
+0
+
+
+
+QUE_114_A5
+
+100
+
+
+
+
+-
+
+
+growing sinusoidal signal for the impulse response?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_118_A1
+
+25
+
+
+
+QUE_118_A2
+
+0
+
+
+
+QUE_118_A3
+
+25
+
+
+
+QUE_118_A4
+
+0
+
+
+
+QUE_118_A5
+
+100
+
+
+
+QUE_118_A6
+
+0
+
+
+
+QUE_118_A7
+
+0
+
+
+
+QUE_118_A8
+
+0
+
+
+
+
+-
+
+
+
+One in WebCT, the other two for Georgia Tech.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_120_A1
+
+100
+
+
+
+QUE_120_A2
+
+100
+
+
+
+
+-
+
+
+xx = [9 2 7 5 1 4 2 6 4];
xx(4:6)]]>
+
+
+
+
+
+5 4 6 4
+
+]]>
+
+
+
+
+5 4
+
+]]>
+
+
+
+
+4 2 6
+
+]]>
+
+
+
+
+5 1 4
+
+]]>
+
+
+
+
+4 5 6
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_122_A1
+
+0
+
+
+
+QUE_122_A2
+
+0
+
+
+
+QUE_122_A3
+
+0
+
+
+
+QUE_122_A4
+
+100
+
+
+
+QUE_122_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_124_A1
+
+100
+
+
+
+
+-
+
+
+(funny.m), which of the following codes plots the function correctly over the period [0,10].
+
+function prelab = funny(waw)
+
prelab = waw.*(waw>=0 & waw<2) + (waw.^2).*(waw>=3 & waw<=5) + 4*waw.*(waw>=6 & waw<=10);
+
+
+]]>
+
+
+
+
+
+ fplot('prelab','waw', [0,10])
+]]>
+
+
+
+
+ fplot('prelab', [0,10])
+]]>
+
+
+
+
+ fplot('funny', 0, 10)
+]]>
+
+
+
+
+ fplot('funny', [0, 10])
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_129_A1
+
+0
+
+
+
+QUE_129_A2
+
+0
+
+
+
+QUE_129_A3
+
+0
+
+
+
+QUE_129_A4
+
+100
+
+
+
+
+-
+
+
+
+f(t) =
+
t, when (0<= t <2)
+
t^2 when (3<= t <=5)
+
4*t when (6<= t <=10)
+
zero, otherwise
+
+
+which of the following codes DOES NOT compute correctly the integral of the function defined above over the period [2, 5] using quad8() and inline()?
+]]>
+
+
+
+
+
+quad8(inline('t.*(t>=0 & t<2 )+ t.^2.*(t>=3 & t<=5) + 4*t.*(t>=6 & t<=10) ') , 2,5)
+]]>
+
+
+
+
+quad8(inline('t.*(t>=0 & t<2 )+ t.^2.*(t>=3 & t<=5) + 4*t.*(t>=6 & t<=10)','t') , 2,5)
+]]>
+
+
+
+
+quad8(inline('t.*(t>=0 & t<2 )+ t.^2.*(t>=3 & t<=5) + 4*t.*(t>=6 & t<=10)','t') , 2,5,[ ], [ ])
+]]>
+
+
+
+
+quad8(inline('t.*(t>=0 & t<2 )+ t.^2.*(t>=3 & t<=5) + 4*t.*(t>=6 & t<=10)','t') , [2,5])
+]]>
+
+
+
+
+quad8(inline('t.*(t>=0 & t<2 )+ t.^2.*(t>=3 & t<=5) + 4*t.*(t>=6 & t<=10)','t') , 2,5, [ ])
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_130_A1
+
+0
+
+
+
+QUE_130_A2
+
+0
+
+
+
+QUE_130_A3
+
+0
+
+
+
+QUE_130_A4
+
+100
+
+
+
+QUE_130_A5
+
+0
+
+
+
+
+-
+
+
+
+ak = (1/pi)*(k.^2-2).*sin(pi*k)./(k.*(k.^2-1));
+ak(ceil(length(ak)/2))=2;
+ak(ceil(length(ak)/2)+1)=0.5;
+ak(ceil(length(ak)/2)-1)=0.5;
+
+using the ak2sig function in MATLAB.
+
+If the FUNDAMENTAL period is defined to be To = 12, which of the following signals is synthesized (approximately) as N becomes large (>20)?
+
NOTE: The Fourier Series coefficients for |k| < N are used in the synthesis.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_132_A1
+
+25
+
+
+
+QUE_132_A2
+
+0
+
+
+
+QUE_132_A3
+
+75
+
+
+
+QUE_132_A4
+
+100
+
+
+
+QUE_132_A5
+
+0
+
+
+
+QUE_132_A6
+
+0
+
+
+
+
+-
+
+
+1 kHz tone in Matlab and listen to it. The following lines of code have already been written:
nn = 0:10000;
+xx = 11*sin(2*pi*0.2*nn);
Which one of the following will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(xx, 5000)
+]]>
+
+
+
+
+ soundsc(xx, 8000)
+]]>
+
+
+
+
+ soundsc(xx, 10000)
+]]>
+
+
+
+
+ soundsc(xx, 11025)
+]]>
+
+
+
+
+ soundsc(xx, 20000)
+]]>
+
+
+
+
+ soundsc(xx, nn)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_133_A1
+
+100
+
+
+
+QUE_133_A2
+
+0
+
+
+
+QUE_133_A3
+
+0
+
+
+
+QUE_133_A4
+
+0
+
+
+
+QUE_133_A5
+
+0
+
+
+
+QUE_133_A6
+
+0
+
+
+
+
+-
+
+
+unit step signal?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_134_A1
+
+0
+
+
+
+QUE_134_A2
+
+0
+
+
+
+QUE_134_A3
+
+0
+
+
+
+QUE_134_A4
+
+0
+
+
+
+QUE_134_A5
+
+0
+
+
+
+QUE_134_A6
+
+0
+
+
+
+QUE_134_A7
+
+100
+
+
+
+QUE_134_A8
+
+0
+
+
+
+
+-
+
+
+
+You have a hard time limit for this on-Line Exercise. After the time expires, you will NOT BE ABLE TO SAVE ANY MORE ANSWERS.
+Whenever you complete an answer, hit the
+"Save Answer" button to update your answer in the WebCT record.
+When you are finished with all the questions, hit the "FINISH" button.
+
+You can have MATLAB running while you answer these questions.
+This is an open book and open notes test. But, it must be your own work. You are NOT allowed to discuss it with anyone else while answering these questions.
+
+
+Check the button below to confirm that you understand these instructions
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_137_A1
+
+100
+
+
+
+
+-
+
+
+ pre,
+the message bits in string row vector tt,
+and termination bits in string row vector mm.
+
+
Each string row vector is an array of characters ('0' or '1') in MATLAB, e.g., '0010110101110'.
+
+
Which of the following is the correct way
+to form the bit string sent out from modem?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_139_A1
+
+0
+
+
+
+QUE_139_A2
+
+0
+
+
+
+QUE_139_A3
+
+0
+
+
+
+QUE_139_A4
+
+100
+
+
+
+QUE_139_A5
+
+0
+
+
+
+QUE_139_A6
+
+0
+
+
+
+QUE_139_A7
+
+0
+
+
+
+QUE_139_A8
+
+0
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
Assuming that the filter was designed via the Hamming-sinc formula, which one of the following can display the values of all the stopband frequencies? The stopband is defined as same as Bandpass Filters lab. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_141_A1
+
+0
+
+
+
+QUE_141_A2
+
+0
+
+
+
+QUE_141_A3
+
+0
+
+
+
+QUE_141_A4
+
+0
+
+
+
+QUE_141_A5
+
+0
+
+
+
+QUE_141_A6
+
+0
+
+
+
+QUE_141_A7
+
+0
+
+
+
+QUE_141_A8
+
+0
+
+
+
+QUE_141_A9
+
+0
+
+
+
+QUE_141_A10
+
+0
+
+
+
+QUE_141_A11
+
+0
+
+
+
+QUE_141_A12
+
+100
+
+
+
+QUE_141_A13
+
+50
+
+
+
+QUE_141_A14
+
+0
+
+
+
+QUE_141_A15
+
+0
+
+
+
+QUE_141_A16
+
+0
+
+
+
+QUE_141_A17
+
+0
+
+
+
+QUE_141_A18
+
+20
+
+
+
+QUE_141_A19
+
+0
+
+
+
+QUE_141_A20
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_142_A1
+
+100
+
+
+
+QUE_142_A2
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:0.2;
xx = cos(2*pi*tt*(800+df)) + cos(2*pi*tt*(800-df));
plot(tt,xx)
+Determine the value of df.
]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_145_A1
+
+0
+
+
+
+QUE_145_A2
+
+0
+
+
+
+QUE_145_A3
+
+0
+
+
+
+QUE_145_A4
+
+0
+
+
+
+QUE_145_A5
+
+100
+
+
+
+
+-
+
+
+ much shorter than this practice quiz.
+The rules for the real Pre/Post Lab quiz are:
+
+* Start the quiz at the beginning of your lab time (within the first 10 minutes)
+
* Do the online quiz in the lab room (BH-216) with a TA proctoring.
+
+* The real Pre/Post Lab quiz is open book, open notes, and open MATLAB.
+
+* Obey the GT Honor Code: do NOT discuss the questions with anyone else during the lab time.
+* Furthermore, since the on-line questions are used throughout the week in other sections, do not tell students in other sections about the contents.
+
+The score of this practice quiz will NOT count into your final grade.
+
+Check the button below to confirm that you understand these instructions
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_148_A1
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Information icon of the ECE2025 WebCT homepage.
+]]>
+
+
+
+
+Lab Assignments icon of the ECE2025 WebCT homepage.
+]]>
+
+
+
+
+Bulletin Board icon of the ECE2025 WebCT homepage.
+]]>
+
+
+
+
+"WORD" icon of the ECE2025 WebCT homepage.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_154_A1
+
+0
+
+
+
+QUE_154_A2
+
+0
+
+
+
+QUE_154_A3
+
+0
+
+
+
+QUE_154_A4
+
+0
+
+
+
+QUE_154_A5
+
+0
+
+
+
+QUE_154_A6
+
+0
+
+
+
+QUE_154_A7
+
+100
+
+
+
+
+-
+
+
+A = exp(j*pi*2); B = sin(100);
+tan(90);
+z = 8 + 7j; w = -5-9j;
+conj(z+w);
+pp = cos(5*pi); gg = sqrt(99+pp);(Note: it is possible to cut and paste from WebCT to MATLAB.)
At the end of these commands, what is the variable ans equal to? ]]>
+
+
+
+
+
+A
+]]>
+
+
+
+
+B
+]]>
+
+
+
+
+tan(90)
+]]>
+
+
+
+
+z
+]]>
+
+
+
+
+w
+]]>
+
+
+
+
+conj(z+w)
+]]>
+
+
+
+
+pp
+]]>
+
+
+
+
+gg
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_155_A1
+
+0
+
+
+
+QUE_155_A2
+
+0
+
+
+
+QUE_155_A3
+
+0
+
+
+
+QUE_155_A4
+
+0
+
+
+
+QUE_155_A5
+
+0
+
+
+
+QUE_155_A6
+
+100
+
+
+
+QUE_155_A7
+
+0
+
+
+
+QUE_155_A8
+
+0
+
+
+
+
+-
+
+
+apostrophe, ', in MATLAB. Which of the following commands would help him/her find the answer?
+]]>
+
+
+
+
+
+help '
+]]>
+
+
+
+
+help apostrophe
+]]>
+
+
+
+
+help ops
+]]>
+
+
+
+
+find '
+]]>
+
+
+
+
+lookfor '
+]]>
+
+
+
+
+'
+]]>
+
+
+
+
+whos '
+]]>
+
+
+
+
+tell me '
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_156_A1
+
+0
+
+
+
+QUE_156_A2
+
+0
+
+
+
+QUE_156_A3
+
+100
+
+
+
+QUE_156_A4
+
+0
+
+
+
+QUE_156_A5
+
+0
+
+
+
+QUE_156_A6
+
+0
+
+
+
+QUE_156_A7
+
+0
+
+
+
+QUE_156_A8
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_157_A1
+
+0
+
+
+
+QUE_157_A2
+
+0
+
+
+
+QUE_157_A3
+
+0
+
+
+
+QUE_157_A4
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_158_A1
+
+100
+
+
+
+QUE_158_A2
+
+0
+
+
+
+QUE_158_A3
+
+0
+
+
+
+QUE_158_A4
+
+0
+
+
+
+
+-
+
+
+ ** WARNING **
+
+There seems to be a software/hardware limitation with the BH-216 lab machines. You should run only one Web browser and one instance of MATLAB while taking the PreLab quiz, and NO other applications. Using other applications during the PreLab will be at YOUR OWN RISK.
+
+
+There have been random reports that opening PDF files while taking a WebCT quiz might slow down or freeze Windows on these computers. If you expect to use lecture notes or any PDF file during the quiz, the safest way is to have a hard copy of them printed before coming to lab.
+
+
Check the button below to confirm that you understand these instructions.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_164_A1
+
+100
+
+
+
+
+-
+
+
+M = 50;
+nn = 0:M;
+hamm = (0.54-0.46*cos(2*pi*nn/M));
+wc = 0.2*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2));
+sincwc(M/2 + 1) = wc/pi;
+bb = hamm.*sincwc;
+Choose all correct answers from followings, which will generate a bandpass filter. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_165_A1
+
+-25
+
+
+
+QUE_165_A2
+
+-25
+
+
+
+QUE_165_A3
+
+100
+
+
+
+QUE_165_A4
+
+-25
+
+
+
+QUE_165_A5
+
+-25
+
+
+
+QUE_165_A6
+
+-25
+
+
+
+QUE_165_A7
+
+-25
+
+
+
+QUE_165_A8
+
+-25
+
+
+
+QUE_165_A9
+
+-25
+
+
+
+QUE_165_A10
+
+-25
+
+
+
+
+-
+
+
+
+x.A = 10;
+x.t = [0:1/10000:2];
+x.mu = 200;
+x.freq = 100;You are asked to write ONE line of MATLAB code that constructs a chirp signal ''y" that has the above parameters. Mark all possible solutions from the following: ]]>
+
+
+
+
+
+ y = x.A * cos(2*pi*(x.mu*x.t + x.freq).*x.t));
+]]>
+
+
+
+
+ y = A*cos(2*pi*(mu*tt + freq).*tt);
+]]>
+
+
+
+
+ y = real(x.A * exp(j*2*pi*(x.mu*tt + x.freq).*tt))
+]]>
+
+
+
+
+ y = abs(x.A * exp(j*2*pi*(x.mu*x.t + x.freq).*x.t))
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_166_A1
+
+100
+
+
+
+QUE_166_A2
+
+-33
+
+
+
+QUE_166_A3
+
+-33
+
+
+
+QUE_166_A4
+
+-34
+
+
+
+
+-
+
+
+M = 50;
+nn = 0:M;
+hamm = (0.54-0.46*cos(2*pi*nn/M));
+wc = 0.2*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2));
+sincwc(M/2 + 1) = wc/pi;
+bb = hamm.*sincwc;
+
+
+Choose all correct answers from followings, which will generate a lowpass filter.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_167_A1
+
+50
+
+
+
+QUE_167_A2
+
+-25
+
+
+
+QUE_167_A3
+
+-25
+
+
+
+QUE_167_A4
+
+-25
+
+
+
+QUE_167_A5
+
+-25
+
+
+
+QUE_167_A6
+
+-25
+
+
+
+QUE_167_A7
+
+50
+
+
+
+QUE_167_A8
+
+-25
+
+
+
+QUE_167_A9
+
+-25
+
+
+
+QUE_167_A10
+
+-25
+
+
+
+
+-
+
+
+M = 50;
+nn = 0:M;
+hamm = (0.54-0.46*cos(2*pi*nn/M));
+wc = 0.2*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2));
+sincwc(M/2 + 1) = wc/pi;
+bb = hamm.*sincwc;
+
+
+Choose all correct answers from followings, which will generate a highpass filter.
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_171_A1
+
+-25
+
+
+
+QUE_171_A2
+
+-25
+
+
+
+QUE_171_A3
+
+-25
+
+
+
+QUE_171_A4
+
+-25
+
+
+
+QUE_171_A5
+
+50
+
+
+
+QUE_171_A6
+
+-25
+
+
+
+QUE_171_A7
+
+-25
+
+
+
+QUE_171_A8
+
+-25
+
+
+
+QUE_171_A9
+
+50
+
+
+
+QUE_171_A10
+
+-25
+
+
+
+
+-
+
+
+M = 50;
+nn = 0:M;
+hamm = (0.54-0.46*cos(2*pi*nn/M));
+wc = 0.2*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2));
+sincwc(M/2 + 1) = wc/pi;
+bb = hamm.*sincwc;
+
+
+Choose all correct answers from followings, which will evaluate the frequency response of bb at frequency 0.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_172_A1
+
+-25
+
+
+
+QUE_172_A2
+
+50
+
+
+
+QUE_172_A3
+
+-25
+
+
+
+QUE_172_A4
+
+-25
+
+
+
+QUE_172_A5
+
+-25
+
+
+
+QUE_172_A6
+
+-25
+
+
+
+QUE_172_A7
+
+-25
+
+
+
+QUE_172_A8
+
+50
+
+
+
+QUE_172_A9
+
+-25
+
+
+
+QUE_172_A10
+
+-25
+
+
+
+
+-
+
+
+M = 50;
+nn = 0:M;
+hamm = (0.54-0.46*cos(2*pi*nn/M));
+wc = 0.2*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2));
+sincwc(M/2 + 1) = wc/pi;
+bb = hamm.*sincwc;
+
+
+Choose all correct answers from followings, which will evaluate the frequency response of bb at frequency π.
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_173_A1
+
+-25
+
+
+
+QUE_173_A2
+
+-25
+
+
+
+QUE_173_A3
+
+-25
+
+
+
+QUE_173_A4
+
+-25
+
+
+
+QUE_173_A5
+
+-25
+
+
+
+QUE_173_A6
+
+50
+
+
+
+QUE_173_A7
+
+-25
+
+
+
+QUE_173_A8
+
+-25
+
+
+
+QUE_173_A9
+
+-25
+
+
+
+QUE_173_A10
+
+50
+
+
+
+
+-
+
+
+M = 50;
+nn = 0:M;
+hamm = (0.54-0.46*cos(2*pi*nn/M));
+wc = 0.2*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2));
+sincwc(M/2 + 1) = wc/pi;
+bb = hamm.*sincwc;
+
+
+Choose all correct answers from followings, which will evaluate the frequency response of bb at frequency 0.
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_177_A1
+
+-25
+
+
+
+QUE_177_A2
+
+50
+
+
+
+QUE_177_A3
+
+50
+
+
+
+QUE_177_A4
+
+-25
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
Which one of the following can display the length of the impulse response? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_179_A1
+
+0
+
+
+
+QUE_179_A2
+
+0
+
+
+
+QUE_179_A3
+
+100
+
+
+
+QUE_179_A4
+
+0
+
+
+
+QUE_179_A5
+
+0
+
+
+
+QUE_179_A6
+
+0
+
+
+
+QUE_179_A7
+
+0
+
+
+
+QUE_179_A8
+
+0
+
+
+
+QUE_179_A9
+
+0
+
+
+
+QUE_179_A10
+
+0
+
+
+
+QUE_179_A11
+
+0
+
+
+
+QUE_179_A12
+
+0
+
+
+
+QUE_179_A13
+
+0
+
+
+
+QUE_179_A14
+
+0
+
+
+
+QUE_179_A15
+
+0
+
+
+
+QUE_179_A16
+
+0
+
+
+
+QUE_179_A17
+
+0
+
+
+
+QUE_179_A18
+
+0
+
+
+
+QUE_179_A19
+
+0
+
+
+
+QUE_179_A20
+
+0
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
Which one of the following can display the values of all the stopband frequencies? The stopband is defined as same as Bandpass Filters lab. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_184_A1
+
+0
+
+
+
+QUE_184_A2
+
+0
+
+
+
+QUE_184_A3
+
+0
+
+
+
+QUE_184_A4
+
+0
+
+
+
+QUE_184_A5
+
+0
+
+
+
+QUE_184_A6
+
+0
+
+
+
+QUE_184_A7
+
+0
+
+
+
+QUE_184_A8
+
+0
+
+
+
+QUE_184_A9
+
+0
+
+
+
+QUE_184_A10
+
+0
+
+
+
+QUE_184_A11
+
+0
+
+
+
+QUE_184_A12
+
+100
+
+
+
+QUE_184_A13
+
+50
+
+
+
+QUE_184_A14
+
+0
+
+
+
+QUE_184_A15
+
+0
+
+
+
+QUE_184_A16
+
+0
+
+
+
+QUE_184_A17
+
+0
+
+
+
+QUE_184_A18
+
+20
+
+
+
+QUE_184_A19
+
+0
+
+
+
+QUE_184_A20
+
+0
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
+
+Which one of the following can display the values of all the passband frequencies? The passband is defined as same as Bandpass Filters lab.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_185_A1
+
+0
+
+
+
+QUE_185_A2
+
+0
+
+
+
+QUE_185_A3
+
+0
+
+
+
+QUE_185_A4
+
+0
+
+
+
+QUE_185_A5
+
+0
+
+
+
+QUE_185_A6
+
+0
+
+
+
+QUE_185_A7
+
+0
+
+
+
+QUE_185_A8
+
+0
+
+
+
+QUE_185_A9
+
+0
+
+
+
+QUE_185_A10
+
+0
+
+
+
+QUE_185_A11
+
+0
+
+
+
+QUE_185_A12
+
+0
+
+
+
+QUE_185_A13
+
+0
+
+
+
+QUE_185_A14
+
+100
+
+
+
+QUE_185_A15
+
+50
+
+
+
+QUE_185_A16
+
+50
+
+
+
+QUE_185_A17
+
+20
+
+
+
+QUE_185_A18
+
+0
+
+
+
+QUE_185_A19
+
+20
+
+
+
+QUE_185_A20
+
+10
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
Which one of the following can display the length of the impulse response? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_186_A1
+
+0
+
+
+
+QUE_186_A2
+
+0
+
+
+
+QUE_186_A3
+
+100
+
+
+
+QUE_186_A4
+
+0
+
+
+
+QUE_186_A5
+
+0
+
+
+
+QUE_186_A6
+
+0
+
+
+
+QUE_186_A7
+
+0
+
+
+
+QUE_186_A8
+
+0
+
+
+
+QUE_186_A9
+
+0
+
+
+
+QUE_186_A10
+
+0
+
+
+
+QUE_186_A11
+
+0
+
+
+
+QUE_186_A12
+
+0
+
+
+
+QUE_186_A13
+
+0
+
+
+
+QUE_186_A14
+
+0
+
+
+
+QUE_186_A15
+
+0
+
+
+
+QUE_186_A16
+
+0
+
+
+
+QUE_186_A17
+
+0
+
+
+
+QUE_186_A18
+
+0
+
+
+
+QUE_186_A19
+
+0
+
+
+
+QUE_186_A20
+
+0
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
Which one of the following can display the values of all the stopband frequencies? The stopband is defined as same as Bandpass Filters lab. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_187_A1
+
+0
+
+
+
+QUE_187_A2
+
+0
+
+
+
+QUE_187_A3
+
+0
+
+
+
+QUE_187_A4
+
+0
+
+
+
+QUE_187_A5
+
+0
+
+
+
+QUE_187_A6
+
+0
+
+
+
+QUE_187_A7
+
+0
+
+
+
+QUE_187_A8
+
+0
+
+
+
+QUE_187_A9
+
+0
+
+
+
+QUE_187_A10
+
+0
+
+
+
+QUE_187_A11
+
+0
+
+
+
+QUE_187_A12
+
+100
+
+
+
+QUE_187_A13
+
+50
+
+
+
+QUE_187_A14
+
+0
+
+
+
+QUE_187_A15
+
+0
+
+
+
+QUE_187_A16
+
+0
+
+
+
+QUE_187_A17
+
+0
+
+
+
+QUE_187_A18
+
+20
+
+
+
+QUE_187_A19
+
+0
+
+
+
+QUE_187_A20
+
+0
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
Which one of the following can display the MATLAB indices where the impulse response is equal to zero? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_188_A1
+
+0
+
+
+
+QUE_188_A2
+
+0
+
+
+
+QUE_188_A3
+
+0
+
+
+
+QUE_188_A4
+
+0
+
+
+
+QUE_188_A5
+
+0
+
+
+
+QUE_188_A6
+
+100
+
+
+
+QUE_188_A7
+
+50
+
+
+
+QUE_188_A8
+
+0
+
+
+
+QUE_188_A9
+
+0
+
+
+
+QUE_188_A10
+
+0
+
+
+
+QUE_188_A11
+
+0
+
+
+
+QUE_188_A12
+
+0
+
+
+
+QUE_188_A13
+
+0
+
+
+
+QUE_188_A14
+
+0
+
+
+
+QUE_188_A15
+
+0
+
+
+
+QUE_188_A16
+
+0
+
+
+
+QUE_188_A17
+
+0
+
+
+
+QUE_188_A18
+
+0
+
+
+
+QUE_188_A19
+
+0
+
+
+
+QUE_188_A20
+
+0
+
+
+
+
+-
+
+
+bb, which is processed by following MATLAB codes.
ww = pi*(-1000:1000)/1000;
+HH = freqz(bb,1,ww);
+
Which one of the following can display the DC value of the Frequency Reponse? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_189_A1
+
+0
+
+
+
+QUE_189_A2
+
+0
+
+
+
+QUE_189_A3
+
+0
+
+
+
+QUE_189_A4
+
+0
+
+
+
+QUE_189_A5
+
+0
+
+
+
+QUE_189_A6
+
+0
+
+
+
+QUE_189_A7
+
+0
+
+
+
+QUE_189_A8
+
+100
+
+
+
+QUE_189_A9
+
+20
+
+
+
+QUE_189_A10
+
+0
+
+
+
+QUE_189_A11
+
+0
+
+
+
+QUE_189_A12
+
+0
+
+
+
+QUE_189_A13
+
+0
+
+
+
+QUE_189_A14
+
+0
+
+
+
+QUE_189_A15
+
+0
+
+
+
+QUE_189_A16
+
+0
+
+
+
+QUE_189_A17
+
+0
+
+
+
+QUE_189_A18
+
+0
+
+
+
+QUE_189_A19
+
+0
+
+
+
+QUE_189_A20
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_211_A1
+
+0
+
+
+
+QUE_211_A2
+
+50
+
+
+
+QUE_211_A3
+
+0
+
+
+
+QUE_211_A4
+
+100
+
+
+
+QUE_211_A5
+
+0
+
+
+
+
+-
+
+
+Nulling filter?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_222_A1
+
+0
+
+
+
+QUE_222_A2
+
+100
+
+
+
+QUE_222_A3
+
+0
+
+
+
+QUE_222_A4
+
+0
+
+
+
+QUE_222_A5
+
+0
+
+
+
+QUE_222_A6
+
+0
+
+
+
+QUE_222_A7
+
+0
+
+
+
+QUE_222_A8
+
+0
+
+
+
+
+-
+
+
+xx alias?
f = 10000;
fs = 32000;
tt = 0:(1/fs):3;
xx = cos(2*pi*f*tt);
soundsc(xx,fs)
]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_226_A1
+
+0
+
+
+
+QUE_226_A2
+
+100
+
+
+
+
+-
+
+
+ {+1, +j, -j},
+describe the type of filter in terms of its frequency response.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_227_A1
+
+0
+
+
+
+QUE_227_A2
+
+0
+
+
+
+QUE_227_A3
+
+0
+
+
+
+QUE_227_A4
+
+25
+
+
+
+QUE_227_A5
+
+100
+
+
+
+QUE_227_A6
+
+25
+
+
+
+
+-
+
+
+ office hours
+on (you may have multiple answers)
+]]>
+
+
+
+
+
+ Tuesday morning between 8-12
+]]>
+
+
+
+
+ Tuesday afternoon between 12-6
+]]>
+
+
+
+
+ Tuesday evening between 6-10
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_228_A1
+
+100
+
+
+
+QUE_228_A2
+
+100
+
+
+
+QUE_228_A3
+
+100
+
+
+
+QUE_228_A4
+
+100
+
+
+
+
+-
+
+
+Buzz. The matrix encodes a digital image of the Georgia Tech Mascot
+
Which of the following commands will properly display the image of Buzz? Pick ONE.
+]]>
+
+
+
+
+
+ figure(Buzz)
+]]>
+
+
+
+
+ display(Buzz)
+]]>
+
+
+
+
+ plot(Buzz)
+]]>
+
+
+
+
+ print(Buzz)
+]]>
+
+
+
+
+ colormap(Buzz)
+]]>
+
+
+
+
+ show_img(Buzz)
+]]>
+
+
+
+
+ show_img(buzz)
+]]>
+
+
+
+
+ show_img('GT Mascot Buzz')
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_230_A1
+
+0
+
+
+
+QUE_230_A2
+
+0
+
+
+
+QUE_230_A3
+
+0
+
+
+
+QUE_230_A4
+
+0
+
+
+
+QUE_230_A5
+
+0
+
+
+
+QUE_230_A6
+
+100
+
+
+
+QUE_230_A7
+
+60
+
+
+
+QUE_230_A8
+
+20
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_232_A1
+
+0
+
+
+
+QUE_232_A2
+
+0
+
+
+
+QUE_232_A3
+
+0
+
+
+
+QUE_232_A4
+
+0
+
+
+
+QUE_232_A5
+
+0
+
+
+
+
+-
+
+
+TOTAL time per week I spent on this course (labs, HW, classes, studying) was on average:
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_235_A1
+
+0
+
+
+
+QUE_235_A2
+
+0
+
+
+
+QUE_235_A3
+
+0
+
+
+
+QUE_235_A4
+
+0
+
+
+
+QUE_235_A5
+
+0
+
+
+
+QUE_235_A6
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_237_A1
+
+0
+
+
+
+QUE_237_A2
+
+0
+
+
+
+QUE_237_A3
+
+100
+
+
+
+QUE_237_A4
+
+0
+
+
+
+QUE_237_A5
+
+0
+
+
+
+
+-
+
+
+xx ?
+]]>
+
+
+
+
+
+
sumx = xx(1:length(xx));
+
+]]>
+
+
+
+
+sumx = xx * transpose(xx);
+
+]]>
+
+
+
+
+sumx = xx * transpose(ones(1,length(xx)));
+
+]]>
+
+
+
+
+sumx = transpose(xx) * ones(1,length(xx));
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_238_A1
+
+0
+
+
+
+QUE_238_A2
+
+0
+
+
+
+QUE_238_A3
+
+100
+
+
+
+QUE_238_A4
+
+0
+
+
+
+
+-
+
+
+ xc=cos(2*pi*2000*t) with the following chirp signal:
+
x1 = cos(2*pi*400*t + 35*cos(2*pi*10*t))
+
+Which of the following most accurately describes the shape of the spectrogram
+of the modulated signal?
+
NOTE: like the AM Lab Warm-up, the spectrogram will exhibit sinusoidal shapes.
+
+(Assume a sampling rate of 44.1kHz, and a spectrogram display that only shows positive frequencies)
+
+]]>
+
+
+
+
+
+ 2000 Hz that varies plus or
+minus 350 Hz, i.e., between 1650 Hz and 2350 Hz.
+]]>
+
+
+
+
+ 2400 Hz varying plus or
+minus 35 Hz; the other centered at 1600 Hz varying plus or
+minus 35 Hz.
+]]>
+
+
+
+
+ 2400 Hz varying plus or
+minus 350 Hz; the other centered at 1600 Hz varying plus or
+minus 350 Hz.
+]]>
+
+
+
+
+ 400 Hz that varies between 365 Hz and
+ 435 Hz.
+]]>
+
+
+
+
+ plus two sinusoidal shapes: one centered at
+ 2750 Hz varying plus or
+minus 10 Hz; the other centered at 1250 Hz varying plus or
+minus 10 Hz.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_241_A1
+
+0
+
+
+
+QUE_241_A2
+
+50
+
+
+
+QUE_241_A3
+
+100
+
+
+
+QUE_241_A4
+
+0
+
+
+
+QUE_241_A5
+
+0
+
+
+
+
+-
+
+
+These next two questions are of interest to the ECE school...
I intend/desire to remain in Georgia after graduation from Georgia Tech.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_243_A1
+
+0
+
+
+
+QUE_243_A2
+
+0
+
+
+
+QUE_243_A3
+
+0
+
+
+
+QUE_243_A4
+
+0
+
+
+
+QUE_243_A5
+
+0
+
+
+
+
+-
+
+
+zz = signal(3,7);
+
+calls a user-written function named signal to generate a sinusoid. Which of the following is a correctly written function M-file for signal ?
+]]>
+
+
+
+
+
+
yy = signal(t1,t2)
+times = t1:1/10000:t2;
+yy = cos(2*pi*times);
+
+]]>
+
+
+
+
+function yy = signal(t1,t2)
+times = t1:1/10000:t2;
+yy = cos(2*pi*times);
+
+]]>
+
+
+
+
+mfile yy = signal(t1,t2)
+times = t1:1/10000:t2;
+yy = cos(2*pi*times);
+
+]]>
+
+
+
+
+function yy = signal(times)
+times = t1:1/10000:t2;
+yy = cos(2*pi*times);
+
+]]>
+
+
+
+
+function xx = signal(t1,t2)
+times = 3:1/10000:7;
+yy = cos(2*pi*times);
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_245_A1
+
+0
+
+
+
+QUE_245_A2
+
+100
+
+
+
+QUE_245_A3
+
+0
+
+
+
+QUE_245_A4
+
+0
+
+
+
+QUE_245_A5
+
+0
+
+
+
+
+-
+
+
+specgram function in MATLAB. What can you say
+about the signal being represented?
+]]>
+
+
+
+
+
+
+added together.
+]]>
+
+
+
+
+addition of two sinusoids.
+]]>
+
+
+
+
+concatenated, and the frequency of the first one is higher.
+]]>
+
+
+
+
+
+
+
+
+
+concatenation of two sinusoids, and
+the total length is 2 seconds (or longer).
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_248_A1
+
+25
+
+
+
+QUE_248_A2
+
+0
+
+
+
+QUE_248_A3
+
+25
+
+
+
+QUE_248_A4
+
+0
+
+
+
+QUE_248_A5
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_249_A1
+
+100
+
+
+
+
+-
+
+
+2 kHz tone in Matlab and listen to it. The following lines of code have already been written:
+
nn = 0:10000;
+xx = 15*sin(2*pi*0.1*nn);
+Which one of the following will correctly play the sound?
+]]>
+
+
+
+
+
+ soundsc(xx, 5000)
+]]>
+
+
+
+
+ soundsc(xx, 8000)
+]]>
+
+
+
+
+ soundsc(xx, 10000)
+]]>
+
+
+
+
+ soundsc(xx, 11025)
+]]>
+
+
+
+
+ soundsc(xx, 20000)
+]]>
+
+
+
+
+ soundsc(xx, nn)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_250_A1
+
+0
+
+
+
+QUE_250_A2
+
+0
+
+
+
+QUE_250_A3
+
+0
+
+
+
+QUE_250_A4
+
+0
+
+
+
+QUE_250_A5
+
+100
+
+
+
+QUE_250_A6
+
+0
+
+
+
+
+-
+
+
+xx = A*cos(2*pi*fc*t + I*cos(2*pi*fm*t - pi/2) - pi/2)
+
+
+
+If the ratio fc:fm is 5:7 (example 250:350), then fc is a harmonic frequency in the spectrum of xx. Which harmonic is fc, the carrier frequency ? Assume I = A = 1.
+
+NOTE: In general, if the fundamental frequency is 10Hz then 30Hz is the 3rd harmonic.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_251_A1
+
+0
+
+
+
+QUE_251_A2
+
+0
+
+
+
+QUE_251_A3
+
+100
+
+
+
+QUE_251_A4
+
+25
+
+
+
+QUE_251_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_252_A1
+
+0
+
+
+
+QUE_252_A2
+
+0
+
+
+
+QUE_252_A3
+
+0
+
+
+
+QUE_252_A4
+
+0
+
+
+
+QUE_252_A5
+
+0
+
+
+
+
+-
+
+
+xx = A*cos(2*pi*fc*t + I*cos(2*pi*fm*t - pi/2) - pi/2)
+
+
+
+If the ratio fc:fm is 1:2 (example 110:220), then fm is a harmonic frequency in the spectrum of xx. Which harmonic is fm, the modulation frequency ? Assume I = A = 1.
+
+NOTE: In general, if the fundamental frequency is 10Hz then 30Hz is the 3rd harmonic.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_253_A1
+
+20
+
+
+
+QUE_253_A2
+
+100
+
+
+
+QUE_253_A3
+
+0
+
+
+
+QUE_253_A4
+
+0
+
+
+
+QUE_253_A5
+
+0
+
+
+
+
+-
+
+
+z = 0.5 to z = 0.999
What happens to the impulse response and the frequency response
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_255_A1
+
+0
+
+
+
+QUE_255_A2
+
+0
+
+
+
+QUE_255_A3
+
+25
+
+
+
+QUE_255_A4
+
+100
+
+
+
+
+-
+
+
+script file which has been saved as prob1.m ?
+]]>
+
+
+
+
+
+prob1
+]]>
+
+
+
+
+prob1.m
+]]>
+
+
+
+
+do prob1.m
+]]>
+
+
+
+
+run prob1
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_256_A1
+
+100
+
+
+
+QUE_256_A2
+
+0
+
+
+
+QUE_256_A3
+
+0
+
+
+
+QUE_256_A4
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_261_A1
+
+0
+
+
+
+QUE_261_A2
+
+0
+
+
+
+QUE_261_A3
+
+0
+
+
+
+QUE_261_A4
+
+0
+
+
+
+QUE_261_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_262_A1
+
+0
+
+
+
+QUE_262_A2
+
+0
+
+
+
+QUE_262_A3
+
+0
+
+
+
+QUE_262_A4
+
+0
+
+
+
+QUE_262_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_267_A1
+
+0
+
+
+
+QUE_267_A2
+
+0
+
+
+
+QUE_267_A3
+
+0
+
+
+
+QUE_267_A4
+
+0
+
+
+
+QUE_267_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_272_A1
+
+100
+
+
+
+QUE_272_A2
+
+20
+
+
+
+QUE_272_A3
+
+50
+
+
+
+QUE_272_A4
+
+20
+
+
+
+QUE_272_A5
+
+20
+
+
+
+
+-
+
+
+ freq = 1000 Hz and you have added the fifth harmonic which is at ff = 5000 Hz. Will there be aliasing in the resulting signal if a sampling frequency of 8000 Hz is used?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_273_A1
+
+100
+
+
+
+QUE_273_A2
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_276_A1
+
+20
+
+
+
+QUE_276_A2
+
+20
+
+
+
+QUE_276_A3
+
+20
+
+
+
+QUE_276_A4
+
+50
+
+
+
+QUE_276_A5
+
+100
+
+
+
+
+-
+
+
+M = 50;
+nn = 0:M;
+VH = (sin(pi*nn/M)).^2;
+wc = 0.3*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2));
+sincwc(M/2 + 1) = wc/pi;
+bb = sincwc.*VH;
+
+
+Choose all correct answers from the following choices, which will evaluate the frequency response of the filter at frequency 0.
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_280_A1
+
+-25
+
+
+
+QUE_280_A2
+
+25
+
+
+
+QUE_280_A3
+
+-25
+
+
+
+QUE_280_A4
+
+-25
+
+
+
+QUE_280_A5
+
+-25
+
+
+
+QUE_280_A6
+
+-25
+
+
+
+QUE_280_A7
+
+-25
+
+
+
+QUE_280_A8
+
+75
+
+
+
+QUE_280_A9
+
+-25
+
+
+
+QUE_280_A10
+
+-25
+
+
+
+
+-
+
+
+M = 50; nn = 0:M;
+VH = (sin(pi*nn/M)).^2;
+wc = 0.3*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2));
+sincwc(M/2 + 1) = wc/pi;
+bb = sincwc.*VH;
+
+
+Choose all correct answers from the following choices, which will evaluate the frequency response of the filter at frequency equal to π.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_282_A1
+
+-25
+
+
+
+QUE_282_A2
+
+-25
+
+
+
+QUE_282_A3
+
+-25
+
+
+
+QUE_282_A4
+
+-25
+
+
+
+QUE_282_A5
+
+-25
+
+
+
+QUE_282_A6
+
+25
+
+
+
+QUE_282_A7
+
+-25
+
+
+
+QUE_282_A8
+
+-25
+
+
+
+QUE_282_A9
+
+-25
+
+
+
+QUE_282_A10
+
+75
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_283_A1
+
+100
+
+
+
+
+-
+
+
+M = 50;
+nn = 0:M;
+VH = (sin(pi*nn/M)).^2;
+wc = 0.3*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2));
+sincwc(M/2 + 1) = wc/pi;
+bb = sincwc.*VH;
+
+
+Choose all correct answers from the following choices, which will generate a highpass filter.
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_284_A1
+
+-25
+
+
+
+QUE_284_A2
+
+-25
+
+
+
+QUE_284_A3
+
+-25
+
+
+
+QUE_284_A4
+
+-25
+
+
+
+QUE_284_A5
+
+25
+
+
+
+QUE_284_A6
+
+-25
+
+
+
+QUE_284_A7
+
+-25
+
+
+
+QUE_284_A8
+
+-25
+
+
+
+QUE_284_A9
+
+75
+
+
+
+QUE_284_A10
+
+-25
+
+
+
+
+-
+
+
+M = 50;
+nn = 0:M;
+VH = (sin(pi*nn/M)).^2;
+wc = 0.3*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2));
+sincwc(M/2 + 1) = wc/pi;
+bb = sincwc.*VH;
+
+
+Choose all correct answers from the following choices, which will evaluate the frequency response of the filter at frequency 0.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_285_A1
+
+-25
+
+
+
+QUE_285_A2
+
+50
+
+
+
+QUE_285_A3
+
+50
+
+
+
+QUE_285_A4
+
+-25
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_293_A1
+
+0
+
+
+
+QUE_293_A2
+
+0
+
+
+
+
+-
+
+
+bb containing filter coefficients, how do we plot the phase of the frequency response?
+]]>
+
+
+
+
+
+ww=-pi:pi/100:pi;
plot(ww,angle(bb));
+]]>
+
+
+
+
+ww=-pi:pi/100:pi;
H=freqz(bb,1,ww);
plot(ww,imag(H));
+]]>
+
+
+
+
+ww=-pi:pi/100:pi;
H=freqz(bb,1,ww);
plot(ww,angle(H));
+]]>
+
+
+
+
+ww=-pi:pi/100:pi;
H=freqz(ww,1,bb);
plot(ww,angle(H));
+]]>
+
+
+
+
+ww=-pi:pi/100:pi;
plot(ww,bb);
+]]>
+
+
+
+
+ww=-pi:pi/100:pi;
H=freqz(bb,1,ww);
plot(ww,abs(H));
+]]>
+
+
+
+
+ww=-pi:pi/100:pi;
H=freqz(bb,1,ww);
plot(ww,H);
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_297_A1
+
+0
+
+
+
+QUE_297_A2
+
+30
+
+
+
+QUE_297_A3
+
+100
+
+
+
+QUE_297_A4
+
+0
+
+
+
+QUE_297_A5
+
+0
+
+
+
+QUE_297_A6
+
+30
+
+
+
+QUE_297_A7
+
+30
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_298_A1
+
+0
+
+
+
+QUE_298_A2
+
+0
+
+
+
+QUE_298_A3
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_299_A1
+
+0
+
+
+
+QUE_299_A2
+
+0
+
+
+
+QUE_299_A3
+
+0
+
+
+
+QUE_299_A4
+
+0
+
+
+
+QUE_299_A5
+
+0
+
+
+
+
+-
+
+
+digital pens, would you be willing to purchase one in order to use this service? (a Logitech digital pen costs about $180)
+
+(Repeated here for convenience: technology that will support in class note taking, connect those notes with the online lecture material, and also connect those notes with other resources available for the course)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_300_A1
+
+0
+
+
+
+QUE_300_A2
+
+0
+
+
+
+
+-
+
+
+
+f(t) = t, when (0<= t <2)
+ t2 when (3<= t <=5)
+ exp(0.25*t) when (6<= t <=10)
+ 0, otherwise
+
+
+which of the following codes DOES NOT plot correctly the above function over the period [0, 10] using fplot() and inline()?
+
+]]>
+
+
+
+
+
+fplot(inline('t.*(t>=0 & t<2 )+ t.^2.*(t>=3 & t<=5) + exp(0.25*t).*(t>=6 & t<=10)') , [0,10])
+]]>
+
+
+
+
+fplot(inline('t.*(t>=0 & t<2 )+ t.^2.*(t>=3 & t<=5) + exp(0.25*t).*(t>=6 & t<=10)','t') , [0,10])
+]]>
+
+
+
+
+fplot(inline('t.*(t>=0 & t<2 )+ t.^2.*(t>=3 & t<=5) + exp(0.25*t).*(t>=6 & t<=10)','x') , [0,10])
+]]>
+
+
+
+
+fplot(inline('t.*(t>=0 & t<2 )+ t.^2.*(t>=3 & t<=5) + exp(0.25*t).*(t>=6 & t<=10)','t') , [0,10],200,[ ], [ ])
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_302_A1
+
+0
+
+
+
+QUE_302_A2
+
+0
+
+
+
+QUE_302_A3
+
+100
+
+
+
+QUE_302_A4
+
+0
+
+
+
+
+-
+
+
+not work?
+]]>
+
+
+
+
+
+[1; 2; 3] * [3 4 5 6]
+]]>
+
+
+
+
+5 .* [1 2 3]
+]]>
+
+
+
+
+exp([1; 2; 3])
+]]>
+
+
+
+
+[1; 2; 3] .* [4; 5; 6; 8]
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_303_A1
+
+0
+
+
+
+QUE_303_A2
+
+0
+
+
+
+QUE_303_A3
+
+0
+
+
+
+QUE_303_A4
+
+100
+
+
+
+
+-
+
+
+ tt = (0:8000)/8000;
+ xx = cos(2*pi*2000*tt);Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(xx,8000)
+
+]]>
+
+
+
+
+ soundsc(xx,tt)
+
+]]>
+
+
+
+
+ soundsc(tt,xx)
+
+]]>
+
+
+
+
+ soundsc(xx,11025)
+
+]]>
+
+
+
+
+ soundsc(xx,2000)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_305_A1
+
+100
+
+
+
+QUE_305_A2
+
+0
+
+
+
+QUE_305_A3
+
+0
+
+
+
+QUE_305_A4
+
+0
+
+
+
+QUE_305_A5
+
+0
+
+
+
+
+-
+
+
+
+f(t) =
+
2*t, when (0<= t <2)
+
t-5 when (3<= t <=5)
+
exp(0.4*t) when (6<= t <=10)
+
zero, otherwise
+
+
+which of the following codes plots correctly the function defined above over the period [0, 10] using fplot() and inline()?
+
There might be 2 correct answers. Choose any one.
+]]>
+
+
+
+
+
+ fplot(inline('2*t.*(t>=0 & t<2 )+ (t-5).*(t>=3 & t<=5) + exp(0.4*t).*(t>=6 & t<=10)','t') , [0,10],200,[ ], [ ])
+]]>
+
+
+
+
+fplot(inline('2*t*(t>=0 & t<2 )+ (t-5)*(t>=3 & t<=5) + exp(0.4*t)*(t>=6 & t<=10)','t') , [0,10],200,[ ], [ ])
+]]>
+
+
+
+
+ fplot(inline('2*t*(t>=0 & t<2 )+ (t-5)*(t>=3 & t<=5) + exp(0.4*t)*(t>=6 & t<=10)') , 0,10)
+]]>
+
+
+
+
+ fplot(inline('2*t.*(t>=0 & t<2 )+ (t-5).*(t>=3 & t<=5) + exp(0.4*t).*(t>=6 & t<=10)') , 0,10)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_307_A1
+
+100
+
+
+
+QUE_307_A2
+
+100
+
+
+
+QUE_307_A3
+
+0
+
+
+
+QUE_307_A4
+
+0
+
+
+
+
+-
+
+
+1850 Hz. If you have a Lowpass filter whose passband edge is 0.7*pi, determine which of the following signal touch-tone frequency(ies) will be passed.
+LPFs Passband edge of 0.7*pi means, the passband extends from the frequency -0.7*pi to +0.7*pi.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_308_A1
+
+-50
+
+
+
+QUE_308_A2
+
+-50
+
+
+
+QUE_308_A3
+
+50
+
+
+
+QUE_308_A4
+
+50
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_312_A1
+
+0
+
+
+
+QUE_312_A2
+
+0
+
+
+
+QUE_312_A3
+
+0
+
+
+
+QUE_312_A4
+
+0
+
+
+
+QUE_312_A5
+
+0
+
+
+
+
+-
+
+
+1850 Hz. If you have a Lowpass filter whose passband edge is 0.6*pi, determine which of the following signal touch-tone frequency(ies) will be passed.
+LPFs Passband edge of 0.6*pi means, the passband extends from the frequency -0.6*pi to +0.6*pi.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_313_A1
+
+-50
+
+
+
+QUE_313_A2
+
+-50
+
+
+
+QUE_313_A3
+
+50
+
+
+
+QUE_313_A4
+
+50
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_315_A1
+
+100
+
+
+
+QUE_315_A2
+
+0
+
+
+
+QUE_315_A3
+
+0
+
+
+
+QUE_315_A4
+
+0
+
+
+
+QUE_315_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+1002:2:2001
+]]>
+
+
+
+
+1001:2:2001
+]]>
+
+
+
+
+1002:2000:2
+]]>
+
+
+
+
+linspace(1002,2000,2)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_316_A1
+
+100
+
+
+
+QUE_316_A2
+
+0
+
+
+
+QUE_316_A3
+
+0
+
+
+
+QUE_316_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+a=[1 0 .64]
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_318_A1
+
+100
+
+
+
+
+-
+
+
+fcos.m
function PreLab10 = mycos(t)
+
+PreLab10 = cos(pi*t);
+
Which command will correctly plot one period of the cosine?
]]>
+
+
+
+
+
+fplot('fcos',0,2);
+]]>
+
+
+
+
+fplot('mycos',0,2);
+]]>
+
+
+
+
+fplot('PreLab10',0,2);
+]]>
+
+
+
+
+fplot('fcos',[0 2]);
+]]>
+
+
+
+
+fplot('mycos',[0 2]);
+]]>
+
+
+
+
+fplot('PreLab10',[0 2]);
+]]>
+
+
+
+
+fplot(fcos,[0 2]);
+]]>
+
+
+
+
+fplot(mycos,[0 2]);
+]]>
+
+
+
+
+fplot(PreLab10,[0 2]);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_320_A1
+
+50
+
+
+
+QUE_320_A2
+
+33
+
+
+
+QUE_320_A3
+
+0
+
+
+
+QUE_320_A4
+
+100
+
+
+
+QUE_320_A5
+
+50
+
+
+
+QUE_320_A6
+
+33
+
+
+
+QUE_320_A7
+
+50
+
+
+
+QUE_320_A8
+
+33
+
+
+
+QUE_320_A9
+
+0
+
+
+
+
+-
+
+
+
+You have a deadline for this on-Line Exercise. After the time expires, you will NOT BE ABLE TO SAVE ANY MORE ANSWERS.
+Thus, hit the "Save Answer" button often.
+That will also update the timer.
+
Check the button below to confirm that you understand these instructions.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_321_A1
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_322_A1
+
+0
+
+
+
+QUE_322_A2
+
+0
+
+
+
+QUE_322_A3
+
+0
+
+
+
+QUE_322_A4
+
+0
+
+
+
+QUE_322_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_323_A1
+
+0
+
+
+
+QUE_323_A2
+
+0
+
+
+
+QUE_323_A3
+
+0
+
+
+
+QUE_323_A4
+
+0
+
+
+
+QUE_323_A5
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:2;
xx = cos(2*pi*250*tt+pi/3); ]]>
+
+
+
+
+
+f = 250
+]]>
+
+
+
+
+f = pi/3
+]]>
+
+
+
+
+f = 8000
+]]>
+
+
+
+
+f = 250
+]]>
+
+
+
+
+f = 32
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_324_A1
+
+100
+
+
+
+QUE_324_A2
+
+0
+
+
+
+QUE_324_A3
+
+0
+
+
+
+QUE_324_A4
+
+50
+
+
+
+QUE_324_A5
+
+0
+
+
+
+
+-
+
+
+1850 Hz. If you have a Highpass filter whose passband edge is 0.7*pi, determine which of the following signal touch-tone frequency(ies) will be passed.
+HPFs Passband edge of 0.7*pi means, the passband extends from the frequency -0.7*pi to -pi and 0.7*pi to pi
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_325_A1
+
+50
+
+
+
+QUE_325_A2
+
+50
+
+
+
+QUE_325_A3
+
+-50
+
+
+
+QUE_325_A4
+
+-50
+
+
+
+
+-
+
+
+1850 Hz. If you have a Highpass filter whose passband edge is 0.9*pi, determine which of the following signal touch-tone frequency(ies) will be passed.
+HPFs Passband edge of 0.9*pi means, the passband extends from the frequency -0.9*pi to -pi and 0.9*pi to pi
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_328_A1
+
+50
+
+
+
+QUE_328_A2
+
+50
+
+
+
+QUE_328_A3
+
+-50
+
+
+
+QUE_328_A4
+
+-50
+
+
+
+
+-
+
+
+1850 Hz. If you have a Highpass filter whose passband edge is 0.8*pi, determine all of the following signals (touch-tone frequency(ies)) that will be passed.
+HPFs Passband edge of 0.8*pi means, the passband extends from the frequency -0.8*pi to -pi and 0.8*pi to pi
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_330_A1
+
+-50
+
+
+
+QUE_330_A2
+
+50
+
+
+
+QUE_330_A3
+
+50
+
+
+
+QUE_330_A4
+
+-50
+
+
+
+
+-
+
+
+vv = A : B : C;]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_332_A1
+
+0
+
+
+
+QUE_332_A2
+
+0
+
+
+
+QUE_332_A3
+
+100
+
+
+
+QUE_332_A4
+
+0
+
+
+
+
+-
+
+
+
+fs = 1850;
+
+Which of the following pair of frequencies will be seen in a spectrogram for
+the DTMF signal generated by telephone key number 2?
+]]>
+
+
+
+
+
+697 and 1209
+]]>
+
+
+
+
+697 and 514
+]]>
+
+
+
+
+697 and 373
+]]>
+
+
+
+
+697 and 1336
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_333_A1
+
+0
+
+
+
+QUE_333_A2
+
+100
+
+
+
+QUE_333_A3
+
+0
+
+
+
+QUE_333_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_334_A1
+
+0
+
+
+
+QUE_334_A2
+
+0
+
+
+
+QUE_334_A3
+
+0
+
+
+
+QUE_334_A4
+
+100
+
+
+
+
+-
+
+
+
+fs = 1850;
+
+Which of the following pair of frequencies will be seen in a spectrogram for
+the DTMF signal generated by telephone key number 1?
+]]>
+
+
+
+
+
+697 and 1209
+]]>
+
+
+
+
+697 and 514
+]]>
+
+
+
+
+697 and 373
+]]>
+
+
+
+
+697 and 641
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_336_A1
+
+0
+
+
+
+QUE_336_A2
+
+0
+
+
+
+QUE_336_A3
+
+0
+
+
+
+QUE_336_A4
+
+100
+
+
+
+
+-
+
+
+ LOWPASS IIR filter, pick the correct (or BEST) one:
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_337_A1
+
+0
+
+
+
+QUE_337_A2
+
+0
+
+
+
+QUE_337_A3
+
+100
+
+
+
+QUE_337_A4
+
+0
+
+
+
+QUE_337_A5
+
+0
+
+
+
+
+-
+
+
+yy with the x-axis ranging over the time indices: 0 <= n <= 49 ?
+
+]]>
+
+
+
+
+
+nn = 0:49;
stem(yy(nn),nn)
+]]>
+
+
+
+
+nn = 0:49;
stem(nn,yy(nn))
+]]>
+
+
+
+
+nn = 0:50;
stem(nn,yy(nn))
+]]>
+
+
+
+
+nn = 0:49;
stem(nn,yy(nn+1))
+]]>
+
+
+
+
+stem(yy(1:50),0:50)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_339_A1
+
+0
+
+
+
+QUE_339_A2
+
+40
+
+
+
+QUE_339_A3
+
+0
+
+
+
+QUE_339_A4
+
+100
+
+
+
+QUE_339_A5
+
+0
+
+
+
+
+-
+
+
+
+fs = 1850;
+
+Which of the following pair of frequencies will be seen in a spectrogram for
+the DTMF signal generated by telephone key number 3?
+]]>
+
+
+
+
+
+697 and 1477
+]]>
+
+
+
+
+697 and 514
+]]>
+
+
+
+
+697 and 373
+]]>
+
+
+
+
+697 and 641
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_340_A1
+
+0
+
+
+
+QUE_340_A2
+
+0
+
+
+
+QUE_340_A3
+
+100
+
+
+
+QUE_340_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_341_A1
+
+100
+
+
+
+QUE_341_A2
+
+0
+
+
+
+
+-
+
+
+Evaluate the following statement "In this course, academic dishonesty is widespread."
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_342_A1
+
+0
+
+
+
+QUE_342_A2
+
+0
+
+
+
+QUE_342_A3
+
+0
+
+
+
+QUE_342_A4
+
+0
+
+
+
+QUE_342_A5
+
+0
+
+
+
+
+-
+
+
+z = -3 +j4 , determine its conguate. ]]>
+
+
+
+
+
+-3-j4]]>
+
+
+
+
+5]]>
+
+
+
+
+2.214]]>
+
+
+
+
+3+j4]]>
+
+
+
+
+1/3-j(1/4)]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_344_A1
+
+100
+
+
+
+QUE_344_A2
+
+0
+
+
+
+QUE_344_A3
+
+0
+
+
+
+QUE_344_A4
+
+0
+
+
+
+QUE_344_A5
+
+0
+
+
+
+
+-
+
+
+ ctranspose(A) when the vector A has the following form:
+
+ A = [ a+b*j , c+d*j ]
+
+Assume that the parameters a, b, c, and d would have numerical values.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+A =
+ a-b*j c-d*j
+
+]]>
+
+
+
+
+
+A =
+ -a+b*j -c+d*j
+
+]]>
+
+
+
+
+
+A =
+ -a+b*j
+ -c+d*j
+
+]]>
+
+
+
+
+
+A =
+ a-b*j
+ c-d*j
+
+]]>
+
+
+
+
+
+A =
+ -a-b*j
+ -c-d*j
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_345_A1
+
+0
+
+
+
+QUE_345_A2
+
+50
+
+
+
+QUE_345_A3
+
+0
+
+
+
+QUE_345_A4
+
+0
+
+
+
+QUE_345_A5
+
+100
+
+
+
+QUE_345_A6
+
+0
+
+
+
+
+-
+
+
+not valid m-file names? (NOTE: multiple selections are allowed)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_347_A1
+
+50
+
+
+
+QUE_347_A2
+
+-50
+
+
+
+QUE_347_A3
+
+50
+
+
+
+QUE_347_A4
+
+-50
+
+
+
+
+-
+
+
+ HIGHPASS IIR filter, pick the correct (or BEST) one:
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_348_A1
+
+0
+
+
+
+QUE_348_A2
+
+0
+
+
+
+QUE_348_A3
+
+0
+
+
+
+QUE_348_A4
+
+100
+
+
+
+QUE_348_A5
+
+0
+
+
+
+
+-
+
+
+synsig.m. Below is the code.
+
function [xx, times] = signal(tstart,tend)
+times = tstart:1/100:tend;
+xx = [];
+for ii=1:length(times)
+ xx = [xx, cos(2*pi*times(ii))];
+end;
+
+
+What is the correct way to call this function and make a plot of the sinusoid over the interval from t=1 to t=2 ?
+]]>
+
+
+
+
+
+
+yy = signal(1,2); plot(times,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = synsig([1,2]); plot(tt,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = signal(1,2); plot(tt,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = synsig(1,2); plot(tt,yy)
+
+]]>
+
+
+
+
+
+plot( 1:2, synsig(1,2) )
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_350_A1
+
+0
+
+
+
+QUE_350_A2
+
+30
+
+
+
+QUE_350_A3
+
+30
+
+
+
+QUE_350_A4
+
+100
+
+
+
+QUE_350_A5
+
+0
+
+
+
+
+-
+
+
+
+fs = 1850;
+
+Which of the following pair of frequencies will be seen in a spectrogram for
+the DTMF signal generated by telephone key number 4?
+]]>
+
+
+
+
+
+770 and 1209
+]]>
+
+
+
+
+770 and 514
+]]>
+
+
+
+
+770 and 373
+]]>
+
+
+
+
+770 and 641
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_351_A1
+
+0
+
+
+
+QUE_351_A2
+
+0
+
+
+
+QUE_351_A3
+
+0
+
+
+
+QUE_351_A4
+
+100
+
+
+
+
+-
+
+
+
+fs = 1850;
+
+Which of the following pair of frequencies will be seen in a spectrogram for
+the DTMF signal generated by telephone key number 5?
+]]>
+
+
+
+
+
+770 and 1336
+]]>
+
+
+
+
+770 and 514
+]]>
+
+
+
+
+770 and 373
+]]>
+
+
+
+
+770 and 641
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_352_A1
+
+0
+
+
+
+QUE_352_A2
+
+100
+
+
+
+QUE_352_A3
+
+0
+
+
+
+QUE_352_A4
+
+0
+
+
+
+
+-
+
+
+
+fs = 1850;
+
+Which of the following pair of frequencies will be seen in a spectrogram for
+the DTMF signal generated by telephone key number 6?
+]]>
+
+
+
+
+
+770 and 1477
+]]>
+
+
+
+
+770 and 514
+]]>
+
+
+
+
+770 and 373
+]]>
+
+
+
+
+770 and 641
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_353_A1
+
+0
+
+
+
+QUE_353_A2
+
+0
+
+
+
+QUE_353_A3
+
+100
+
+
+
+QUE_353_A4
+
+0
+
+
+
+
+-
+
+
+
+ak = (1/pi)*(k.^2 - 2).*sin(pi*k)./(k.*(k.^2 - 4));
+ak(ceil(length(ak)/2))=0.5;
+ak(ceil(length(ak)/2)+2)=0.25;
+ak(ceil(length(ak)/2)-2)=0.25;
+
+using the ak2sig function in MATLAB.
+
+If the FUNDAMENTAL period is defined to be To = 12, which of the following signals is synthesized (approximately) as N becomes large (>20)?
+
NOTE: The Fourier Series coefficients for |k| < N are used in the synthesis.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_354_A1
+
+0
+
+
+
+QUE_354_A2
+
+100
+
+
+
+QUE_354_A3
+
+40
+
+
+
+QUE_354_A4
+
+0
+
+
+
+QUE_354_A5
+
+0
+
+
+
+QUE_354_A6
+
+0
+
+
+
+
+-
+
+
+
+fs = 1850;
+
+Which of the following pair of frequencies will be seen in a spectrogram for
+the DTMF signal generated by telephone key number 7?
+]]>
+
+
+
+
+
+852 and 1209
+]]>
+
+
+
+
+852 and 514
+]]>
+
+
+
+
+852 and 373
+]]>
+
+
+
+
+852 and 641
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_355_A1
+
+0
+
+
+
+QUE_355_A2
+
+0
+
+
+
+QUE_355_A3
+
+0
+
+
+
+QUE_355_A4
+
+100
+
+
+
+
+-
+
+
+fs = 11025;
nn = (0:round(0.25*fs));Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 9? ]]>
+
+
+
+
+
+yy = cos(2*pi*1477*nn) * cos(2*pi*852*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*1477*nn) + cos(2*pi*852*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*1477*852*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1477+852)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1477/fs)*nn) * cos(2*pi*(852/fs)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*((1477+852)/fs)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1477/fs)*nn) + cos(2*pi*(852/fs)*nn);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_356_A1
+
+0
+
+
+
+QUE_356_A2
+
+50
+
+
+
+QUE_356_A3
+
+0
+
+
+
+QUE_356_A4
+
+0
+
+
+
+QUE_356_A5
+
+0
+
+
+
+QUE_356_A6
+
+0
+
+
+
+QUE_356_A7
+
+100
+
+
+
+
+-
+
+
+
+fs = 1850;
+
+Which of the following pair of frequencies will be seen in a spectrogram for
+the DTMF signal generated by telephone key number 8?
+]]>
+
+
+
+
+
+852 and 1336
+]]>
+
+
+
+
+852 and 514
+]]>
+
+
+
+
+852 and 373
+]]>
+
+
+
+
+852 and 641
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_357_A1
+
+0
+
+
+
+QUE_357_A2
+
+100
+
+
+
+QUE_357_A3
+
+0
+
+
+
+QUE_357_A4
+
+0
+
+
+
+
+-
+
+
+
+fs = 1850;
+
+Which of the following pair of frequencies will be seen in a spectrogram for
+the DTMF signal generated by telephone key number 9?
+]]>
+
+
+
+
+
+852 and 1477
+]]>
+
+
+
+
+852 and 514
+]]>
+
+
+
+
+852 and 373
+]]>
+
+
+
+
+852 and 641
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_360_A1
+
+0
+
+
+
+QUE_360_A2
+
+0
+
+
+
+QUE_360_A3
+
+100
+
+
+
+QUE_360_A4
+
+0
+
+
+
+
+-
+
+
+NoteNexus survey about laptops
+ under Online Quizzes / Surveys ?
+
+If not, Please complete it now.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_361_A1
+
+100
+
+
+
+QUE_361_A2
+
+100
+
+
+
+
+-
+
+
+magnitude and phase of a complex-valued vector zz?
+]]>
+
+
+
+
+
+abs(zz), phase(zz)
+]]>
+
+
+
+
+mag(zz), phase(zz)
+]]>
+
+
+
+
+abs(zz), angle(zz)
+]]>
+
+
+
+
+mag(zz), angle(zz)
+]]>
+
+
+
+
+real(zz), imag(zz)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_364_A1
+
+80
+
+
+
+QUE_364_A2
+
+25
+
+
+
+QUE_364_A3
+
+100
+
+
+
+QUE_364_A4
+
+50
+
+
+
+QUE_364_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_365_A1
+
+0
+
+
+
+QUE_365_A2
+
+0
+
+
+
+QUE_365_A3
+
+0
+
+
+
+QUE_365_A4
+
+0
+
+
+
+QUE_365_A5
+
+0
+
+
+
+
+-
+
+
+φ) for the following sinusoid where
xx = cos(w*t + phi);
]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_367_A1
+
+0
+
+
+
+QUE_367_A2
+
+0
+
+
+
+QUE_367_A3
+
+0
+
+
+
+QUE_367_A4
+
+0
+
+
+
+QUE_367_A5
+
+0
+
+
+
+QUE_367_A6
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_369_A1
+
+100
+
+
+
+
+-
+
+
+z = -3 +j4, determine its magnitude. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_372_A1
+
+0
+
+
+
+QUE_372_A2
+
+100
+
+
+
+QUE_372_A3
+
+0
+
+
+
+QUE_372_A4
+
+0
+
+
+
+QUE_372_A5
+
+0
+
+
+
+
+-
+
+
+z=0.999999, what happens to the frequency response?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_374_A1
+
+100
+
+
+
+QUE_374_A2
+
+0
+
+
+
+QUE_374_A3
+
+0
+
+
+
+QUE_374_A4
+
+0
+
+
+
+
+-
+
+
+PreLab10.m
function PreLab10 = fcos(t)
+
+PreLab10 = cos(pi*t);
+
Which command will correctly plot one period of the cosine?
]]>
+
+
+
+
+
+fplot('fcos',0,2);
+]]>
+
+
+
+
+fplot('mycos',0,2);
+]]>
+
+
+
+
+fplot('PreLab10',0,2);
+]]>
+
+
+
+
+fplot('fcos',[0 2]);
+]]>
+
+
+
+
+fplot('mycos',[0 2]);
+]]>
+
+
+
+
+fplot('PreLab10',[0 2]);
+]]>
+
+
+
+
+fplot(fcos,[0 2]);
+]]>
+
+
+
+
+fplot(mycos,[0 2]);
+]]>
+
+
+
+
+fplot(PreLab10,[0 2]);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_376_A1
+
+33
+
+
+
+QUE_376_A2
+
+0
+
+
+
+QUE_376_A3
+
+50
+
+
+
+QUE_376_A4
+
+50
+
+
+
+QUE_376_A5
+
+33
+
+
+
+QUE_376_A6
+
+100
+
+
+
+QUE_376_A7
+
+0
+
+
+
+QUE_376_A8
+
+0
+
+
+
+QUE_376_A9
+
+50
+
+
+
+
+-
+
+
+z1 and z2, have been defined in MATLAB. Which one of the following MATLAB statements will give the phase of z1*z2 (i.e., the product) ?
+]]>
+
+
+
+
+
+
angle(z1) + angle(z2)
+
+]]>
+
+
+
+
+ real(z1*z2) + j*imag(z1*z2)
+
+]]>
+
+
+
+
+ phase(z1+z2)
+
+]]>
+
+
+
+
+ angle(z1) * angle(z2)
+
+]]>
+
+
+
+
+ atan( imag(z1*z2)/real(z1*z2) )
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_378_A1
+
+100
+
+
+
+QUE_378_A2
+
+0
+
+
+
+QUE_378_A3
+
+0
+
+
+
+QUE_378_A4
+
+0
+
+
+
+QUE_378_A5
+
+50
+
+
+
+
+-
+
+
+THIS IS NOT THE REAL Pre-LAB
+
+You have a time limit for this on-Line Exercise.
+Whenever you complete an answer, hit the "Save Answer" button to update your answer in the WebCT record.
+When you are finished with all the questions, hit the "FINISH" button.
+
+
+Check the button below to confirm that you understand these instructions.
+]]>
+
+
+
+
+
+THIS IS NOT THE REAL Pre-LAB
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_379_A1
+
+100
+
+
+
+
+-
+
+
+N = 100;
+x = (1:N)/10;
+y = exp(-j*pi*x);
+plot(x,real(y));
+
+
You are asked to replace this block of code by another one that contains ONE for loop. Which of the following is the correct code to make the same plot? ]]>
+
+
+
+
+
+N = 100;
+for k=1:N
+ x(k) = k/10;
+ y(k) = exp(-j*pi*k/10);
+end
+plot(x, real(y));]]>
+
+
+
+
+N = 100;
+for k=1:N
+ x = k/10;
+ y = exp(-j*pi*x(k));
+end
+plot(x, real(y));
+ ]]>
+
+
+
+
+N = 100;
+for k=(1:N)/10
+ x(k) = k;
+ y(k) = exp(-j*pi*x);
+end
+plot(x, real(y));
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_380_A1
+
+100
+
+
+
+QUE_380_A2
+
+0
+
+
+
+QUE_380_A3
+
+0
+
+
+
+
+-
+
+
+ak = (sin(k).^2)./(k.^2);
+ak(ceil(length(ak)/2))=1;
+using the ak2sig function in MATLAB.
If the FUNDAMENTAL period is defined to be To = 2, which of the following signals is synthesized (approximately) as N becomes large (>20)?
NOTE: The Fourier Series coefficients for |k| < N are used in the synthesis. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_382_A1
+
+25
+
+
+
+QUE_382_A2
+
+25
+
+
+
+QUE_382_A3
+
+100
+
+
+
+QUE_382_A4
+
+0
+
+
+
+QUE_382_A5
+
+0
+
+
+
+QUE_382_A6
+
+0
+
+
+
+
+-
+
+
+HH of a Bandpass filter:
hh = (2/32)*cos(0.75*pi*[0:31]);
+ww = 0.1*pi*(0:0.0001:10);
+HH = freqz(hh,1,ww);
+
Find both the center frequency wc for this BPF and its passband width.
The passband width is defined as the length of the frequency region where the magnitude of the frequency response is greater than 0.707. ]]>
+
+
+
+
+
+wc = 2.3562
+
passband width = 0.1738
+
+]]>
+
+
+
+
+wc = 0.75
+
passband width = 0.1738
+
+]]>
+
+
+
+
+wc = 0.1*pi
+
passband width = 2/32
+
+]]>
+
+
+
+
+wc = 2.3562
+
passband width = 0.0869
+
+]]>
+
+
+
+
+wc = 0.75
+
passband width = 0.0869
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_383_A1
+
+100
+
+
+
+QUE_383_A2
+
+50
+
+
+
+QUE_383_A3
+
+0
+
+
+
+QUE_383_A4
+
+50
+
+
+
+QUE_383_A5
+
+0
+
+
+
+
+-
+
+
+signal.m. Below is the code.
function [xx, times] = signal(tend)
+times = tend(1):1/100:tend(2);
+xx = [];
+for ii=1:length(times)
+ xx = [xx, cos(2*pi*times(ii))];
+end;
+
What is the correct way to call this function and make a plot of the sinusoid over the interval from t=1 to t=2 ? ]]>
+
+
+
+
+
+signal(1,2); plot(xx, times)]]>
+
+
+
+
+signal(1,2); plot(times, xx)]]>
+
+
+
+
+yy = signal(1,2); plot(times,yy)]]>
+
+
+
+
+[yy,tt] = signal([1,2]); plot(tt,yy)]]>
+
+
+
+
+[yy,tt] = signal(1,2); plot(tt,yy)]]>
+
+
+
+
+plot( 1:2, signal(1,2) )]]>
+
+
+
+
+[tt,yy] = signal(1,2); plot(tt,yy)]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_385_A1
+
+0
+
+
+
+QUE_385_A2
+
+0
+
+
+
+QUE_385_A3
+
+30
+
+
+
+QUE_385_A4
+
+100
+
+
+
+QUE_385_A5
+
+30
+
+
+
+QUE_385_A6
+
+0
+
+
+
+QUE_385_A7
+
+30
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_386_A1
+
+0
+
+
+
+QUE_386_A2
+
+0
+
+
+
+QUE_386_A3
+
+0
+
+
+
+QUE_386_A4
+
+0
+
+
+
+QUE_386_A5
+
+0
+
+
+
+
+-
+
+
+ xx with a
+digital bandpass filter of impulse response hh,
+and plot the magnitude of the output spectrum,
+Y(e^(j*omega_hat)). Which of the following procedures will
+achieve the desired plot.
+
+
+
+]]>
+
+
+
+
+
+y=conv(hh,xx); ww=-pi:pi/100:pi; Y=freqz(ww,y); plot(ww,abs(Y))
+
+
+]]>
+
+
+
+
+y=conv(hh,xx); ww=-pi:pi/100:pi; Y=freqz(y,ww); plot(ww,abs(Y))
+
+
+]]>
+
+
+
+
+y=conv(hh,xx); ww=-pi:pi/100:pi; Y=freqz(y,1,ww); plot(ww,abs(Y))
+
+
+]]>
+
+
+
+
+y=conv(hh,xx); ww=-pi:pi/100:pi; Y=freqz(y,1,ww); plot(ww,Y)
+
+
+]]>
+
+
+
+
+y=conv(hh,xx); ww=-pi:pi; Y=freqz(y,1,ww); plot(ww,abs(Y))
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_388_A1
+
+0
+
+
+
+QUE_388_A2
+
+0
+
+
+
+QUE_388_A3
+
+100
+
+
+
+QUE_388_A4
+
+50
+
+
+
+QUE_388_A5
+
+50
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_389_A1
+
+0
+
+
+
+QUE_389_A2
+
+0
+
+
+
+QUE_389_A3
+
+0
+
+
+
+QUE_389_A4
+
+0
+
+
+
+QUE_389_A5
+
+0
+
+
+
+
+-
+
+
+z1 = 1 + 0j;
+z2 = 1 + 1j;
+z3 = 3 + 2j;
+z4 = -5 + 7.9j;
+z5 = 0.3-8j;
+Which statement will generate a plot in the complex plane showing all five numbers as vectors concatenated head-to-tail ? ]]>
+
+
+
+
+
+ zcat( z1,z2,z3,z4,z5 );
+]]>
+
+
+
+
+ zvect( z1,z2,z3,z4,z5 );
+]]>
+
+
+
+
+ plot( [z1,z2,z3,z4,z5] );
+]]>
+
+
+
+
+ zcat( [z1,z2,z3,z4,z5] );
+]]>
+
+
+
+
+ zcat( {z1,z2,z3,z4,z5} );
+]]>
+
+
+
+
+ zvect( [z1,z2,z3,z4,z5] );
+]]>
+
+
+
+
+ plot( z1,z2,z3,z4,z5 );
+]]>
+
+
+
+
+ zvect( (z1,z2,z3,z4,z5) );
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_390_A1
+
+30
+
+
+
+QUE_390_A2
+
+0
+
+
+
+QUE_390_A3
+
+0
+
+
+
+QUE_390_A4
+
+100
+
+
+
+QUE_390_A5
+
+30
+
+
+
+QUE_390_A6
+
+0
+
+
+
+QUE_390_A7
+
+0
+
+
+
+QUE_390_A8
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_392_A1
+
+0
+
+
+
+QUE_392_A2
+
+0
+
+
+
+QUE_392_A3
+
+0
+
+
+
+QUE_392_A4
+
+0
+
+
+
+QUE_392_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_393_A1
+
+0
+
+
+
+QUE_393_A2
+
+0
+
+
+
+QUE_393_A3
+
+0
+
+
+
+QUE_393_A4
+
+0
+
+
+
+QUE_393_A5
+
+0
+
+
+
+
+-
+
+
+LECTURE
+portion of ECE-2025 ?
+
+If not, go to
+
+https://gtwebapps.gatech.edu/cfprod/cios_new/student_login.cfm and look for ECE2025A.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_395_A1
+
+100
+
+
+
+QUE_395_A2
+
+100
+
+
+
+
+-
+
+
+ LOWPASS IIR filter, pick the correct (or BEST) one:
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_398_A1
+
+0
+
+
+
+QUE_398_A2
+
+0
+
+
+
+QUE_398_A3
+
+0
+
+
+
+QUE_398_A4
+
+100
+
+
+
+QUE_398_A5
+
+0
+
+
+
+
+-
+
+
+AVERAGE time I spent on labs each week (including time in lab) was
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_400_A1
+
+0
+
+
+
+QUE_400_A2
+
+0
+
+
+
+QUE_400_A3
+
+0
+
+
+
+QUE_400_A4
+
+0
+
+
+
+QUE_400_A5
+
+0
+
+
+
+QUE_400_A6
+
+0
+
+
+
+
+-
+
+
+(Answer given in integer format)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_406_A1
+
+0
+
+
+
+QUE_406_A2
+
+100
+
+
+
+QUE_406_A3
+
+0
+
+
+
+QUE_406_A4
+
+0
+
+
+
+QUE_406_A5
+
+0
+
+
+
+QUE_406_A6
+
+0
+
+
+
+QUE_406_A7
+
+0
+
+
+
+QUE_406_A8
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_408_A1
+
+20
+
+
+
+QUE_408_A2
+
+20
+
+
+
+QUE_408_A3
+
+100
+
+
+
+QUE_408_A4
+
+50
+
+
+
+QUE_408_A5
+
+20
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_409_A1
+
+100
+
+
+
+QUE_409_A2
+
+0
+
+
+
+QUE_409_A3
+
+0
+
+
+
+QUE_409_A4
+
+0
+
+
+
+QUE_409_A5
+
+0
+
+
+
+
+-
+
+
+xx?
Assume the length of xx is greater than 100.
+]]>
+
+
+
+
+
+L = length(xx); yy = xx(L-99:L);
+]]>
+
+
+
+
+L = length(xx); yy = xx(100:L);
+]]>
+
+
+
+
+L = length(xx); yy = xx(L:L-100);
+]]>
+
+
+
+
+L = length(xx); yy = xx(L-100:L);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_410_A1
+
+100
+
+
+
+QUE_410_A2
+
+0
+
+
+
+QUE_410_A3
+
+0
+
+
+
+QUE_410_A4
+
+50
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_413_A1
+
+0
+
+
+
+QUE_413_A2
+
+0
+
+
+
+QUE_413_A3
+
+0
+
+
+
+QUE_413_A4
+
+0
+
+
+
+QUE_413_A5
+
+0
+
+
+
+QUE_413_A6
+
+0
+
+
+
+
+-
+
+
+N = 40;
+for k=1:N
+ t(k) = 2*k;
+ y(k) = cos(2*pi*0.1*t(k));
+end
+plot(t, abs(y));
+
+You are asked to replace this block of code by another one that has NO for loop in it.
+Which of the following is the correct code to make the same plot?
+]]>
+
+
+
+
+
+N = 40;
+y = cos(2*pi*0.1*t);
+plot(2:80, abs(y));
+
+]]>
+
+
+
+
+N = 40;
+y(k) = cos(2*pi*0.2*(1:40));
+plot(2*k, abs(y));
+
+]]>
+
+
+
+
+N = 40;
+y = cos(2*pi*0.1*t);
+plot(t, abs(y));
+
+]]>
+
+
+
+
+N = 40;
+y = cos(2*pi*0.2*(1:40));
+plot(2:2:80, abs(y));
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_416_A1
+
+0
+
+
+
+QUE_416_A2
+
+0
+
+
+
+QUE_416_A3
+
+0
+
+
+
+QUE_416_A4
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_417_A1
+
+100
+
+
+
+
+-
+
+
+t = 1:50;
+y = cos(0.2*pi*t);
+plot( 0.1*t, abs(y) );
+
+
You are asked to replace this block of code by another one that contains ONE for loop. Which of the following is the correct code to make the same plot? ]]>
+
+
+
+
+
+N = 50;
+for k=1:N
+ t(k) = 0.1*k;
+ y(k) = cos(0.2*pi*t);
+end
+plot(t,abs(y));]]>
+
+
+
+
+N = 50;
+for k=1:N
+ t = 0.1*k;
+ y = cos(0.2*pi*t(k));
+end
+plot(t, abs(y));]]>
+
+
+
+
+N = 50;
+for k=(1:N)/10
+ t(k) = k;
+ y(k) = cos(0.2*pi*t(k));
+end
+plot(t, abs(y));]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_418_A1
+
+100
+
+
+
+QUE_418_A2
+
+0
+
+
+
+QUE_418_A3
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_419_A1
+
+0
+
+
+
+QUE_419_A2
+
+0
+
+
+
+QUE_419_A3
+
+0
+
+
+
+QUE_419_A4
+
+0
+
+
+
+QUE_419_A5
+
+0
+
+
+
+QUE_419_A6
+
+0
+
+
+
+QUE_419_A7
+
+0
+
+
+
+QUE_419_A8
+
+0
+
+
+
+QUE_419_A9
+
+0
+
+
+
+QUE_419_A10
+
+0
+
+
+
+QUE_419_A11
+
+0
+
+
+
+QUE_419_A12
+
+0
+
+
+
+
+-
+
+
+N = 10;
+for k=-N:N
+ x(k+N+1) = k;
+ y(k+N+1) = exp(-j*x(k+N+1).^2);
+end
+plot(x, real(y));
+
+You are asked to replace this block of code by another one that has NO for loop in it.
+Which of the following is the correct code to make the same plot?
+]]>
+
+
+
+
+
+N = 10;
+y = exp(-j*x.*x);
+plot(x, real(y));
+
+]]>
+
+
+
+
+N = 10;
+y(k) = exp(-j*(1:N).^2);
+plot(-N:N, real(y));
+
+]]>
+
+
+
+
+N = 10;
+y = exp(-j*(-N:N).^2);
+plot(k-N, real(y));
+
+]]>
+
+
+
+
+N = 10;
+y = exp(-j*(-N:N).*(-N:N));
+plot(-N:N, real(y));
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_420_A1
+
+0
+
+
+
+QUE_420_A2
+
+0
+
+
+
+QUE_420_A3
+
+0
+
+
+
+QUE_420_A4
+
+100
+
+
+
+
+-
+
+
+N = 10;
+x = -N:N;
+y = exp(-j*x.^2);
+plot(x, real(y));
+
You are asked to replace this block of code by another one that contains ONE for loop. Which of the following is the correct code to make the same plot? ]]>
+
+
+
+
+
+N = 10;
+for k=-N:N
+ x(k) = k;
+ y(k) = exp(-j*x.^2);
+end
+plot(x, real(y));]]>
+
+
+
+
+N = 10;
+for k=1:(2*N+1)
+ x(k) = k-N-1;
+ y(k) = exp(-j*x(k)*x(k));
+end
+plot(x, real(y));]]>
+
+
+
+
+N = 10;
+for k=-N:N
+ x(k) = k;
+ y = exp(-j*x(k).^2);
+end
+plot(x, real(y));]]>
+
+
+
+
+N = 10;
+for k=0:(2*N)
+ x(k) = k;
+ y(k) = exp(-j*x(k).^2);
+end
+plot(x, real(y));]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_423_A1
+
+0
+
+
+
+QUE_423_A2
+
+100
+
+
+
+QUE_423_A3
+
+0
+
+
+
+QUE_423_A4
+
+0
+
+
+
+
+-
+
+
+N is even and positive, what is the length (number of elements) of the vector nn defined as
nn = N/2:N-1?
+]]>
+
+
+
+
+
+N
+]]>
+
+
+
+
+N-1
+]]>
+
+
+
+
+N/2
+]]>
+
+
+
+
+N/2-1
+]]>
+
+
+
+
+nn contained previously
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_424_A1
+
+0
+
+
+
+QUE_424_A2
+
+0
+
+
+
+QUE_424_A3
+
+100
+
+
+
+QUE_424_A4
+
+40
+
+
+
+QUE_424_A5
+
+0
+
+
+
+
+-
+
+
+r=0.85 and an angle of 45 degrees, what does the frequency response (magnitude) look like?
+NOTE: PeZ will put a second pole at the conjugate location, which corresponds to negative frequency.
+
+]]>
+
+
+
+
+
+H(w) has peaks at +pi/2 and -pi/2 radians.
+]]>
+
+
+
+
+H(w) has peaks at +pi/4 and -pi/4 radians.
+]]>
+
+
+
+
+H(w) has peaks at +0.25 and -0.25 radians.
+]]>
+
+
+
+
+H(w) oscillates and decays.
+]]>
+
+
+
+
+H(w) has dips at +pi/4 and -pi/4 radians.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_426_A1
+
+0
+
+
+
+QUE_426_A2
+
+100
+
+
+
+QUE_426_A3
+
+0
+
+
+
+QUE_426_A4
+
+0
+
+
+
+QUE_426_A5
+
+0
+
+
+
+
+-
+
+
+Function1.m
function PreLab10 = fcos(t)
+
+PreLab10 = cos(pi*t);
Which command will correctly plot one period of the cosine? ]]>
+
+
+
+
+
+fplot('fcos',0,2);
+]]>
+
+
+
+
+fplot('Function1',0,2);
+]]>
+
+
+
+
+fplot('PreLab10',0,2);
+]]>
+
+
+
+
+fplot('fcos',[0 2]);
+]]>
+
+
+
+
+fplot('Function1',[0 2]);
+]]>
+
+
+
+
+fplot('PreLab10',[0 2]);
+]]>
+
+
+
+
+fplot(fcos,[0 2]);
+]]>
+
+
+
+
+fplot(Function1,[0 2]);
+]]>
+
+
+
+
+fplot(PreLab10,[0 2]);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_429_A1
+
+33
+
+
+
+QUE_429_A2
+
+50
+
+
+
+QUE_429_A3
+
+0
+
+
+
+QUE_429_A4
+
+50
+
+
+
+QUE_429_A5
+
+100
+
+
+
+QUE_429_A6
+
+33
+
+
+
+QUE_429_A7
+
+0
+
+
+
+QUE_429_A8
+
+50
+
+
+
+QUE_429_A9
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_430_A1
+
+0
+
+
+
+QUE_430_A2
+
+0
+
+
+
+QUE_430_A3
+
+0
+
+
+
+QUE_430_A4
+
+0
+
+
+
+QUE_430_A5
+
+0
+
+
+
+
+-
+
+
+RECITATION portion of ECE-2025 ?
+
+If not, go to
+
+https://gtwebapps.gatech.edu/cfprod/cios_new/student_login.cfm and look for ECE2025Lnn, where Lnn is your Lab section number
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_434_A1
+
+100
+
+
+
+QUE_434_A2
+
+100
+
+
+
+
+-
+
+
+
+You have a DEADLINE for this on-Line Exercise.
+
+
After the time expires, you will NOT BE ABLE TO SAVE ANY MORE ANSWERS.
+Hit the "Save Answer" button often.
+
+
Check the button below to confirm that you understand these instructions.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_440_A1
+
+100
+
+
+
+
+-
+
+
+ of 25 Hz, a stopband cutoff frequency of 50 Hz and a filter length
+of L = 101. The filter coefficients are stored in the vector bb.
+
+Given a signal:
+
+xx = cos(2*pi*100*tt) + sin(2*pi*200*tt) + cos(2*pi*300*tt);
+
+where tt=-4000:1/10000:4000;
+
+Which commands could be used to pass only the sine and reject the two cosines by
+using a bandpass filter?
+Note: the BPF would be created from the LPF.
+]]>
+
+
+
+
+
+bb2 = bb.*cos(2*pi*200*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*200*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = conv(hh,xx);
+]]>
+
+
+
+
+bb2 = conv(bb,cos(2*pi*200*((0:100)-50))) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+hh = freqz(bb,1,-pi:.01*pi:pi);
+yy = xx.*hh.*cos(2*pi*200*((0:100)-50))
+]]>
+
+
+
+
+bb2 = firfilt(bb,cos(2*pi*200*((0:100)-50)) );
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+bb2 = firfilt(bb,cos(2*pi*200*((0:100)-50)) );
+yy = bb2.*xx
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*200*((0:100)-50)) ;
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_442_A1
+
+0
+
+
+
+QUE_442_A2
+
+0
+
+
+
+QUE_442_A3
+
+0
+
+
+
+QUE_442_A4
+
+0
+
+
+
+QUE_442_A5
+
+0
+
+
+
+QUE_442_A6
+
+0
+
+
+
+QUE_442_A7
+
+100
+
+
+
+
+-
+
+
+
+Check the box below to indicate you have read these rules.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_443_A1
+
+100
+
+
+
+QUE_443_A2
+
+0
+
+
+
+
+-
+
+
+
3 7 11 15 19 23
+]]>
+
+
+
+
+
+1 : 3 : 23
+]]>
+
+
+
+
+ 3 : 4 : 23
+]]>
+
+
+
+
+ 3 : 23 : 4
+]]>
+
+
+
+
+ 3 : 7 : 11 : 23
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_445_A1
+
+0
+
+
+
+QUE_445_A2
+
+100
+
+
+
+QUE_445_A3
+
+0
+
+
+
+QUE_445_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_446_A1
+
+0
+
+
+
+QUE_446_A2
+
+0
+
+
+
+QUE_446_A3
+
+0
+
+
+
+QUE_446_A4
+
+0
+
+
+
+QUE_446_A5
+
+0
+
+
+
+
+-
+
+
+angle() function in MATLAB returns a value
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_448_A1
+
+0
+
+
+
+QUE_448_A2
+
+100
+
+
+
+QUE_448_A3
+
+0
+
+
+
+QUE_448_A4
+
+0
+
+
+
+QUE_448_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_452_A1
+
+0
+
+
+
+QUE_452_A2
+
+0
+
+
+
+QUE_452_A3
+
+0
+
+
+
+QUE_452_A4
+
+0
+
+
+
+QUE_452_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_454_A1
+
+0
+
+
+
+QUE_454_A2
+
+0
+
+
+
+QUE_454_A3
+
+0
+
+
+
+QUE_454_A4
+
+0
+
+
+
+QUE_454_A5
+
+0
+
+
+
+QUE_454_A6
+
+0
+
+
+
+QUE_454_A7
+
+0
+
+
+
+QUE_454_A8
+
+0
+
+
+
+QUE_454_A9
+
+0
+
+
+
+QUE_454_A10
+
+0
+
+
+
+QUE_454_A11
+
+0
+
+
+
+QUE_454_A12
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_455_A1
+
+100
+
+
+
+QUE_455_A2
+
+20
+
+
+
+QUE_455_A3
+
+50
+
+
+
+QUE_455_A4
+
+20
+
+
+
+QUE_455_A5
+
+20
+
+
+
+
+-
+
+
+stable system is one whose output does not blow up (that is, y[n] is bounded when x[n] is bounded). Therefore, the impulse response of a stable system must not blow up.
In general, what can be said about the placement of the poles to guarantee stability?
+If necessary, use PeZ to generate examples with multiple poles
+]]>
+
+
+
+
+
+
+
+
+
+
+ALL be inside the unit circle.
+]]>
+
+
+
+
+ALL be outside the unit circle.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_456_A1
+
+0
+
+
+
+QUE_456_A2
+
+100
+
+
+
+QUE_456_A3
+
+0
+
+
+
+QUE_456_A4
+
+0
+
+
+
+QUE_456_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_457_A1
+
+0
+
+
+
+QUE_457_A2
+
+0
+
+
+
+QUE_457_A3
+
+0
+
+
+
+QUE_457_A4
+
+0
+
+
+
+QUE_457_A5
+
+0
+
+
+
+
+-
+
+
+
C:\\appl\\matlab\\bin. while in an ECE computer lab.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_462_A1
+
+0
+
+
+
+QUE_462_A2
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_464_A1
+
+0
+
+
+
+QUE_464_A2
+
+0
+
+
+
+QUE_464_A3
+
+100
+
+
+
+QUE_464_A4
+
+0
+
+
+
+QUE_464_A5
+
+0
+
+
+
+
+-
+
+
+HH of a Bandpass filter:
+
hh = (2/64)*cos(1.6965*[0:63]);
+ww = 0.1*pi*(0:0.0001:10);
+HH = freqz(hh,1,ww);
+
+Find both the center frequency wc for this BPF, and its passband width.
+
The passband width is defined as the length of the frequency region where the magnitude of the frequency response is greater than 0.707.
+]]>
+
+
+
+
+
+ wc = 0.54*pi
+
passband width = 0.0435
+
+]]>
+
+
+
+
+ wc = 1.6965*pi
+
passband width = 0.0435
+
+]]>
+
+
+
+
+ wc = 0.1*pi
+
passband width = 2/64
+]]>
+
+
+
+
+ wc = 1.6965*pi
+
passband width = 0.0874
+
+]]>
+
+
+
+
+ wc = 0.54*pi
+
passband width = 0.0874
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_465_A1
+
+50
+
+
+
+QUE_465_A2
+
+0
+
+
+
+QUE_465_A3
+
+0
+
+
+
+QUE_465_A4
+
+50
+
+
+
+QUE_465_A5
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_470_A1
+
+20
+
+
+
+QUE_470_A2
+
+20
+
+
+
+QUE_470_A3
+
+100
+
+
+
+QUE_470_A4
+
+20
+
+
+
+QUE_470_A5
+
+20
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_475_A1
+
+100
+
+
+
+
+-
+
+
+specgram function in MATLAB. What can you say
+about the signal being represented?
+]]>
+
+
+
+
+
+
+added together.
+]]>
+
+
+
+
+addition of two sinusoids.
+]]>
+
+
+
+
+concatenated, and seems to be about 1 second long.
+]]>
+
+
+
+
+
+
+
+
+
+concatenation of two sinusoids, and
+the total length is 0.5 seconds.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_477_A1
+
+100
+
+
+
+QUE_477_A2
+
+25
+
+
+
+QUE_477_A3
+
+25
+
+
+
+QUE_477_A4
+
+0
+
+
+
+QUE_477_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_480_A1
+
+0
+
+
+
+QUE_480_A2
+
+0
+
+
+
+QUE_480_A3
+
+0
+
+
+
+QUE_480_A4
+
+100
+
+
+
+QUE_480_A5
+
+0
+
+
+
+QUE_480_A6
+
+0
+
+
+
+QUE_480_A7
+
+0
+
+
+
+QUE_480_A8
+
+0
+
+
+
+
+-
+
+
+Recall that A-440 is key number 49.
+
(Answer given in integer format)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_482_A1
+
+0
+
+
+
+QUE_482_A2
+
+0
+
+
+
+QUE_482_A3
+
+100
+
+
+
+QUE_482_A4
+
+0
+
+
+
+QUE_482_A5
+
+0
+
+
+
+QUE_482_A6
+
+0
+
+
+
+QUE_482_A7
+
+0
+
+
+
+QUE_482_A8
+
+0
+
+
+
+
+-
+
+
+3 kHz
and whose duration is one second, using a sampling rate of 11025 Hz?
+]]>
+
+
+
+
+
+tt = 0:1/11025:1;
xx = cos(2*pi*3*tt);
+]]>
+
+
+
+
+tt = 0:1/3000:1;
xx = cos(2*pi*11025*tt);
+]]>
+
+
+
+
+tt = 0:1/11025:1;
xx = cos(2*pi*3000*tt);
+]]>
+
+
+
+
+tt = 0:11025;
xx = cos(2*pi*3000*tt);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_485_A1
+
+0
+
+
+
+QUE_485_A2
+
+0
+
+
+
+QUE_485_A3
+
+100
+
+
+
+QUE_485_A4
+
+50
+
+
+
+
+-
+
+
+tt = (0:11025)/11025;
+xx = cos(2*pi*2000*tt);Which one of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(11025,xx)
+]]>
+
+
+
+
+ soundsc(tt,xx)
+]]>
+
+
+
+
+ soundsc(xx,tt)
+]]>
+
+
+
+
+ soundsc(xx,11025)
+]]>
+
+
+
+
+ soundsc(tt,11025)
+]]>
+
+
+
+
+ soundsc(tt)
+]]>
+
+
+
+
+ soundsc(2000,xx)
+]]>
+
+
+
+
+ soundsc(xx,2000)
+]]>
+
+
+
+
+ soundsc(tt,2000)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_490_A1
+
+25
+
+
+
+QUE_490_A2
+
+0
+
+
+
+QUE_490_A3
+
+25
+
+
+
+QUE_490_A4
+
+100
+
+
+
+QUE_490_A5
+
+0
+
+
+
+QUE_490_A6
+
+0
+
+
+
+QUE_490_A7
+
+0
+
+
+
+QUE_490_A8
+
+25
+
+
+
+QUE_490_A9
+
+0
+
+
+
+
+-
+
+
+On-Line SURVEY of ECE-2025 in Web-CT ?
+
+If not, go to that link under the "On-Line Quizzes and Surveys" in Web-CT.
+These questions are tailored to ECE-2025, so the
+answers will be more useful to us than the general ones in the required GT surveys.
+
+Note: the answer below counts 10 pts on Lab Quiz #4.
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_493_A1
+
+100
+
+
+
+QUE_493_A2
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_497_A1
+
+25
+
+
+
+QUE_497_A2
+
+25
+
+
+
+QUE_497_A3
+
+25
+
+
+
+QUE_497_A4
+
+25
+
+
+
+QUE_497_A5
+
+100
+
+
+
+
+-
+
+
+Function1.m
function PreLab10 = fcos(t)
+
+PreLab10 = cos(pi*t);
+
Which command will correctly calculate the integral of one period of the cosine?
]]>
+
+
+
+
+
+yy = quad8('fcos',0,2);
+]]>
+
+
+
+
+yy = quad8('Function1',0,2);
+]]>
+
+
+
+
+yy = quad8('PreLab10',0,2);
+]]>
+
+
+
+
+yy = quad8('fcos',[0 2]);
+]]>
+
+
+
+
+yy = quad8('Function1',[0 2]);
+]]>
+
+
+
+
+yy = quad8('PreLab10',[0 2]);
+]]>
+
+
+
+
+yy = quad8(fcos,0,2);
+]]>
+
+
+
+
+yy = quad8(Function1,0,2);
+]]>
+
+
+
+
+yy = quad8(PreLab10,0,2);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_498_A1
+
+50
+
+
+
+QUE_498_A2
+
+100
+
+
+
+QUE_498_A3
+
+33
+
+
+
+QUE_498_A4
+
+33
+
+
+
+QUE_498_A5
+
+50
+
+
+
+QUE_498_A6
+
+0
+
+
+
+QUE_498_A7
+
+0
+
+
+
+QUE_498_A8
+
+50
+
+
+
+QUE_498_A9
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+a=[1 -0.5774 .81]
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_502_A1
+
+100
+
+
+
+
+-
+
+
+ pre,
+the message bits in string row vector mm,
+and termination bits in string row vector tt.
+
+
Each string row vector is an array of characters ('0' or '1') in MATLAB, e.g., '0010110101110'.
+
+
Which of the following is the correct way
+to form the bit string sent out from modem?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_504_A1
+
+0
+
+
+
+QUE_504_A2
+
+0
+
+
+
+QUE_504_A3
+
+0
+
+
+
+QUE_504_A4
+
+0
+
+
+
+QUE_504_A5
+
+0
+
+
+
+QUE_504_A6
+
+100
+
+
+
+QUE_504_A7
+
+0
+
+
+
+QUE_504_A8
+
+0
+
+
+
+
+-
+
+
+ pp,
+the message bits in string row vector mm,
+and termination bits in string row vector term.
+
+
Each string row vector is an array of characters ('0' or '1') in MATLAB, e.g., '0010110101110'.
+
+
Which of the following is the correct way
+to form the bit string sent out from modem?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_506_A1
+
+0
+
+
+
+QUE_506_A2
+
+0
+
+
+
+QUE_506_A3
+
+0
+
+
+
+QUE_506_A4
+
+0
+
+
+
+QUE_506_A5
+
+100
+
+
+
+QUE_506_A6
+
+0
+
+
+
+QUE_506_A7
+
+0
+
+
+
+QUE_506_A8
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_509_A1
+
+0
+
+
+
+QUE_509_A2
+
+0
+
+
+
+QUE_509_A3
+
+0
+
+
+
+QUE_509_A4
+
+0
+
+
+
+QUE_509_A5
+
+0
+
+
+
+QUE_509_A6
+
+0
+
+
+
+QUE_509_A7
+
+100
+
+
+
+QUE_509_A8
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_513_A1
+
+100
+
+
+
+QUE_513_A2
+
+0
+
+
+
+QUE_513_A3
+
+0
+
+
+
+QUE_513_A4
+
+0
+
+
+
+QUE_513_A5
+
+0
+
+
+
+QUE_513_A6
+
+0
+
+
+
+QUE_513_A7
+
+0
+
+
+
+QUE_513_A8
+
+0
+
+
+
+
+-
+
+
+xx alias?
f = 32;
fs = 10;
tt = 0:(1/fs):3;
xx = cos(2*pi*f*tt);
+
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_516_A1
+
+100
+
+
+
+QUE_516_A2
+
+0
+
+
+
+
+-
+
+
+xc=cos(2π 6000 t) with the following chirp signal:
+
x1 = cos(2π 700 t + 30 cos(2π 10 t))
+Which of the following most accurately describes the shape of the spectrogram
+of the modulated signal?
+
NOTE: like the AM Lab Warm-up, the spectrogram will exhibit sinusoidal shapes.
+
+(Assume a sampling rate of 44.1kHz, and a spectrogram display that only shows positive frequencies)
+
+
+
+]]>
+
+
+
+
+
+ 700 Hz that varies plus or
+minus 30 Hz, i.e., between 670 Hz and 730 Hz.
+]]>
+
+
+
+
+ 5300 Hz varying between 5000 and
+ 5600 Hz; the other centered at 6700 Hz varying between 6400 Hz and 7000 Hz.
+]]>
+
+
+
+
+ 5300 Hz varying between 5290 and
+ 5310 Hz; the other centered at 6700 Hz varying between 6690 Hz and 6710 Hz.
+]]>
+
+
+
+
+ 670 Hz varying between 640 and
+ 700 Hz; the other centered at 730 Hz varying between 700 Hz and 760 Hz.
+]]>
+
+
+
+
+ 6000 Hz that varies between 5700 Hz and
+ 6300 Hz.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_517_A1
+
+0
+
+
+
+QUE_517_A2
+
+100
+
+
+
+QUE_517_A3
+
+50
+
+
+
+QUE_517_A4
+
+0
+
+
+
+QUE_517_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_520_A1
+
+0
+
+
+
+QUE_520_A2
+
+0
+
+
+
+QUE_520_A3
+
+0
+
+
+
+QUE_520_A4
+
+0
+
+
+
+QUE_520_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_521_A1
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_529_A1
+
+0
+
+
+
+QUE_529_A2
+
+0
+
+
+
+QUE_529_A3
+
+100
+
+
+
+QUE_529_A4
+
+0
+
+
+
+QUE_529_A5
+
+0
+
+
+
+QUE_529_A6
+
+0
+
+
+
+QUE_529_A7
+
+0
+
+
+
+QUE_529_A8
+
+0
+
+
+
+
+-
+
+
+φ) for the following sinusoid where
x(t) = cos(ωt + φ);
]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_530_A1
+
+0
+
+
+
+QUE_530_A2
+
+100
+
+
+
+QUE_530_A3
+
+0
+
+
+
+QUE_530_A4
+
+0
+
+
+
+QUE_530_A5
+
+0
+
+
+
+QUE_530_A6
+
+0
+
+
+
+
+-
+
+
+-jw + e-j2w, pick the correct simplification:
+
+]]>
+
+
+
+
+
+-jw
+
+]]>
+
+
+
+
+-j3w/2cos(w/2)
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_532_A1
+
+0
+
+
+
+QUE_532_A2
+
+100
+
+
+
+QUE_532_A3
+
+0
+
+
+
+QUE_532_A4
+
+0
+
+
+
+
+-
+
+
+(Answer given in integer format)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_533_A1
+
+0
+
+
+
+QUE_533_A2
+
+0
+
+
+
+QUE_533_A3
+
+0
+
+
+
+QUE_533_A4
+
+0
+
+
+
+QUE_533_A5
+
+0
+
+
+
+QUE_533_A6
+
+100
+
+
+
+QUE_533_A7
+
+0
+
+
+
+QUE_533_A8
+
+0
+
+
+
+
+-
+
+
+low pass filter with a passband cutoff frequency
of 25 Hz, a stopband cutoff frequency of 50 Hz and a filter length
+of L = 101. The filter coefficients are stored in the vector bb.
+
+Given a signal:
+
+xx = cos(2*pi*100*tt) + sin(2*pi*200*tt) + cos(2*pi*300*tt);
+
+where tt=-4000:1/10000:4000;
+
+Which commands could be used to pass only the sine and reject the two cosines by
+using a bandpass filter?
+Note: the BPF would be created from the LPF.
+]]>
+
+
+
+
+
+bb2 = bb.*cos(2*pi*100*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*100*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = conv(hh,xx);
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*100*((0:100)-50)) ;
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*200*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*200*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = conv(hh,xx);
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*200*((0:100)-50)) ;
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*300*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*300*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = conv(hh,xx);
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*300*((0:100)-50)) ;
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_536_A1
+
+0
+
+
+
+QUE_536_A2
+
+0
+
+
+
+QUE_536_A3
+
+50
+
+
+
+QUE_536_A4
+
+0
+
+
+
+QUE_536_A5
+
+0
+
+
+
+QUE_536_A6
+
+100
+
+
+
+QUE_536_A7
+
+0
+
+
+
+QUE_536_A8
+
+0
+
+
+
+QUE_536_A9
+
+50
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+a=[1 0 .81]
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_537_A1
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_538_A1
+
+0
+
+
+
+QUE_538_A2
+
+0
+
+
+
+QUE_538_A3
+
+0
+
+
+
+QUE_538_A4
+
+0
+
+
+
+QUE_538_A5
+
+0
+
+
+
+
+-
+
+
+A be an M x N matrix (elements may be complex).What does A .' represent in MATLAB?
+]]>
+
+
+
+
+
+A
+]]>
+
+
+
+
+A
+]]>
+
+
+
+
+A
+]]>
+
+
+
+
+A
+]]>
+
+
+
+
+A
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_540_A1
+
+0
+
+
+
+QUE_540_A2
+
+100
+
+
+
+QUE_540_A3
+
+0
+
+
+
+QUE_540_A4
+
+0
+
+
+
+QUE_540_A5
+
+0
+
+
+
+
+-
+
+
+function tone=note(keynum,dur)
fs = 11025;
tt = 0:1/fs:dur;
f0 = 440*2^((keynum-49)/12);
tone = cos(2*pi*f0*tt);
+A student wants to modify the function so that the tone created by this function has THREE frequency components. The new tone should be the sum of three sinusoids, one of which is the fundamental, f0, and the other two which are of frequencies 2 and 3 times higher than the fundamental respectively. The amplitudes (and phases) can be the same. Which one of the following is a correct modification that will accomplish this task?
+
+
+
+]]>
+
+
+
+
+
+note() with
tone = cos(2*pi*(2*f0+3*f0)*tt);
+]]>
+
+
+
+
+note() with
tone = cos(2*pi*f0*tt) + cos(2*pi*2*f0*tt) + cos(2*pi*3*f0*tt)
+]]>
+
+
+
+
+xx(n1:n2) = xx(n1:n2) + note([f 2*f 3*f],dur);
+]]>
+
+
+
+
+note() with
tone = cos(2*pi*f0*([1 2 3]')*tt);
+]]>
+
+
+
+
+note()
f0 = f0 + 2*f0 + 3*f0;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_543_A1
+
+0
+
+
+
+QUE_543_A2
+
+100
+
+
+
+QUE_543_A3
+
+0
+
+
+
+QUE_543_A4
+
+0
+
+
+
+QUE_543_A5
+
+0
+
+
+
+
+-
+
+
+xx is a vector of length 30. yy is a vector of length 10.
What is the correct way to add yy to the MIDDLE ten points of xx?
The result (called zz) should be 30 points long.
Assume all vectors are row vectors.
Do not assume that zz has been initialized.
+]]>
+
+
+
+
+
+zz = xx(11:20) + yy;
+]]>
+
+
+
+
+zz = xx + [zeros(1,10), yy, zeros(1,10)];
+]]>
+
+
+
+
+zz(11:20) = xx + yy;
+]]>
+
+
+
+
+zz = xx + yy;
+]]>
+
+
+
+
+zz = [zeros(1,10), xx+yy, zeros(1,10)];
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_545_A1
+
+0
+
+
+
+QUE_545_A2
+
+100
+
+
+
+QUE_545_A3
+
+0
+
+
+
+QUE_545_A4
+
+0
+
+
+
+QUE_545_A5
+
+25
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_548_A1
+
+0
+
+
+
+QUE_548_A2
+
+0
+
+
+
+QUE_548_A3
+
+0
+
+
+
+QUE_548_A4
+
+0
+
+
+
+QUE_548_A5
+
+0
+
+
+
+
+-
+
+
+x = [0:1/15:20];
+y = x(0:10);
+What is the length of y?]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_556_A1
+
+0
+
+
+
+QUE_556_A2
+
+0
+
+
+
+QUE_556_A3
+
+100
+
+
+
+QUE_556_A4
+
+0
+
+
+
+
+-
+
+
+ of 25 Hz, a stopband cutoff frequency of 50 Hz and a filter length
+of L = 101. The filter coefficients are stored in the vector bb.
+
+Given a signal:
+
+xx = sin(2*pi*100*tt) + cos(2*pi*200*tt) + cos(2*pi*300*tt);
+
+where tt=-4000:1/10000:4000;
+
+Which commands could be used to pass only the sine and reject the two cosines by
+using a bandpass filter?
+Note: the BPF would be created from the LPF.
+]]>
+
+
+
+
+
+bb2 = bb.*cos(2*pi*100*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*100*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = conv(hh,xx);
+]]>
+
+
+
+
+bb2 = conv(bb,cos(2*pi*100*((0:100)-50))) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*100*((0:100)-50)) ;
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+hh = freqz(bb,1,-pi:.01*pi:pi);
+yy = hh.*cos(2*pi*100*((0:100)-50))
+]]>
+
+
+
+
+bb2 = firfilt(bb,cos(2*pi*100*((0:100)-50)) );
+yy = bb2.*xx
+]]>
+
+
+
+
+bb2 = firfilt(bb,cos(2*pi*100*((0:100)-50)) );
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_558_A1
+
+0
+
+
+
+QUE_558_A2
+
+0
+
+
+
+QUE_558_A3
+
+0
+
+
+
+QUE_558_A4
+
+100
+
+
+
+QUE_558_A5
+
+0
+
+
+
+QUE_558_A6
+
+0
+
+
+
+QUE_558_A7
+
+0
+
+
+
+
+-
+
+
+
+Two for Georgia Tech: one for Lecture and one for Recitation. These can be found at
+
+http://www.coursesurvey.gatech.edu
+
Use your banner id
+and banner pin to fill out a survey for each of your courses.
+
+One in Web-CT. Look for the "Course Survey" under the on-line Quizzes link.
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_562_A1
+
+100
+
+
+
+
+-
+
+
+ office hours
+on (you may have multiple answers)
+]]>
+
+
+
+
+
+ Monday morning between 8-12
+]]>
+
+
+
+
+ Monday afternoon between 12-6
+]]>
+
+
+
+
+ Monday evening between 6-10
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_564_A1
+
+100
+
+
+
+QUE_564_A2
+
+100
+
+
+
+QUE_564_A3
+
+100
+
+
+
+QUE_564_A4
+
+100
+
+
+
+
+-
+
+
+ tt=[0:1/5620:10]; .
+
You construct a sinusoidal signal xx=cos(2*pi*100*tt);
+
You want to know an estimate of the value of the signal (xx) at the time 1.6 seconds . Which of the following MATLAB statements will do that for you (without errors or warnings)?
+]]>
+
+
+
+
+
+value = xx(1.6);
+]]>
+
+
+
+
+value = xx(1.6*5620);
+]]>
+
+
+
+
+value = xx(round(1.6*5620)+1);
+]]>
+
+
+
+
+value = 1.6*xx(5620);
+]]>
+
+
+
+
+value = 5620*xx(1.6);
+]]>
+
+
+
+
+value = xx(round(1.6/5620)+1);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_567_A1
+
+0
+
+
+
+QUE_567_A2
+
+90
+
+
+
+QUE_567_A3
+
+100
+
+
+
+QUE_567_A4
+
+0
+
+
+
+QUE_567_A5
+
+0
+
+
+
+QUE_567_A6
+
+0
+
+
+
+
+-
+
+
+complex number
yy?
There is only one correct answer. ]]>
+
+
+
+
+
+yy^2]]>
+
+
+
+
+abs(yy.^2)]]>
+
+
+
+
+ yy * yy]]>
+
+
+
+
+yy * yy']]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_570_A1
+
+0
+
+
+
+QUE_570_A2
+
+0
+
+
+
+QUE_570_A3
+
+0
+
+
+
+QUE_570_A4
+
+100
+
+
+
+
+-
+
+
+sound() and soundsc() statements.
+]]>
+
+
+
+
+
+sound() and soundsc() are different ways to call exactly the same function.
+]]>
+
+
+
+
+soundsc(x,Fs) scales the values in x and then passes them to sound()
+]]>
+
+
+
+
+sound() is the variable or array that holds the sound to be played by soundsc()
+]]>
+
+
+
+
+sound() declares an array as a special sound file format which is played by soundsc()
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_577_A1
+
+0
+
+
+
+QUE_577_A2
+
+100
+
+
+
+QUE_577_A3
+
+0
+
+
+
+QUE_577_A4
+
+0
+
+
+
+
+-
+
+
+not work?
+]]>
+
+
+
+
+
+[1 2 3] .* [4 5 6]]]>
+
+
+
+
+[1 2 3] * [4 5 6]]]>
+
+
+
+
+[1 2 3] * [4; 5; 6]]]>
+
+
+
+
+[1 2 3] * 4]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_582_A1
+
+0
+
+
+
+QUE_582_A2
+
+100
+
+
+
+QUE_582_A3
+
+0
+
+
+
+QUE_582_A4
+
+0
+
+
+
+
+-
+
+
+synsig.m. Below is the code.
+
function [xx, times] = signal(tend)
+times = tend(1):1/100:tend(2);
+xx = [];
+for ii=1:length(times)
+ xx = [xx, cos(2*pi*times(ii))];
+end;
+
+
+What is the correct way to call this function and make a plot of the sinusoid over the interval from t=1 to t=2?
+
+]]>
+
+
+
+
+
+
+yy = signal(1,2); plot(times,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = synsig([1,2]); plot(tt,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = signal(1,2); plot(tt,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = synsig(1,2); plot(tt,yy)
+
+]]>
+
+
+
+
+
+plot( 1:2, synsig(1,2) )
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_585_A1
+
+0
+
+
+
+QUE_585_A2
+
+100
+
+
+
+QUE_585_A3
+
+30
+
+
+
+QUE_585_A4
+
+30
+
+
+
+QUE_585_A5
+
+0
+
+
+
+
+-
+
+
+
+M = 50; nn = 0:M;
+LW = sin(2*pi/M*(nn-M/2))./(2*pi/M*(nn-M/2)); %-- Lanczos window
+LW(M/2 + 1) = 1; %-- fix divide by zero
+wc = 0.3*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2)); %-- sinc function
+sincwc(M/2 + 1) = wc/pi; %-- fix divide by zero
+bb = sincwc.*LW; %-- Filter Coefficients
+
+
+Choose all correct answers from the following choices, which will evaluate the frequency response of the filter at frequency 0.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_590_A1
+
+-25
+
+
+
+QUE_590_A2
+
+25
+
+
+
+QUE_590_A3
+
+-25
+
+
+
+QUE_590_A4
+
+-25
+
+
+
+QUE_590_A5
+
+-25
+
+
+
+QUE_590_A6
+
+-25
+
+
+
+QUE_590_A7
+
+-25
+
+
+
+QUE_590_A8
+
+75
+
+
+
+QUE_590_A9
+
+-25
+
+
+
+QUE_590_A10
+
+-25
+
+
+
+
+-
+
+
+
+M = 50; nn = 0:M;
+LW = sin(2*pi/M*(nn-M/2))./(2*pi/M*(nn-M/2)); %-- Lanczos window
+LW(M/2 + 1) = 1; %-- fix divide by zero
+wc = 0.3*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2)); %-- sinc function
+sincwc(M/2 + 1) = wc/pi; %-- fix divide by zero
+bb = sincwc.*LW; %-- Filter Coefficients
+
+
+Choose all correct answers from the following choices, which will evaluate the frequency response of the filter at frequency 0.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_592_A1
+
+-25
+
+
+
+QUE_592_A2
+
+50
+
+
+
+QUE_592_A3
+
+50
+
+
+
+QUE_592_A4
+
+-25
+
+
+
+
+-
+
+
+
+M = 50; nn = 0:M;
+LW = sin(2*pi/M*(nn-M/2))./(2*pi/M*(nn-M/2)); %-- Lanczos window
+LW(M/2 + 1) = 1; %-- fix divide by zero
+wc = 0.3*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2)); %-- sinc function
+sincwc(M/2 + 1) = wc/pi; %-- fix divide by zero
+bb = sincwc.*LW; %-- Filter Coefficients
+
+
+Choose all correct answers from the following choices, which will evaluate the frequency response of the filter at frequency equal to 'pi'.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_593_A1
+
+-25
+
+
+
+QUE_593_A2
+
+-25
+
+
+
+QUE_593_A3
+
+-25
+
+
+
+QUE_593_A4
+
+-25
+
+
+
+QUE_593_A5
+
+-25
+
+
+
+QUE_593_A6
+
+25
+
+
+
+QUE_593_A7
+
+-25
+
+
+
+QUE_593_A8
+
+-25
+
+
+
+QUE_593_A9
+
+-25
+
+
+
+QUE_593_A10
+
+75
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_597_A1
+
+0
+
+
+
+QUE_597_A2
+
+0
+
+
+
+QUE_597_A3
+
+0
+
+
+
+QUE_597_A4
+
+0
+
+
+
+QUE_597_A5
+
+0
+
+
+
+
+-
+
+
+ If the size of the vector V is 1 by 100, i.e.,
+
size(V) ==> 1 100
+
+
Which of the following statements will generate an error?
+
+
Mark all possible solutions.
+]]>
+
+
+
+
+
+V*transpose(V)
+]]>
+
+
+
+
+V*V
+]]>
+
+
+
+
+V^2
+]]>
+
+
+
+
+exp(V)
+]]>
+
+
+
+
+V+V
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_600_A1
+
+-30
+
+
+
+QUE_600_A2
+
+50
+
+
+
+QUE_600_A3
+
+50
+
+
+
+QUE_600_A4
+
+-30
+
+
+
+QUE_600_A5
+
+-30
+
+
+
+
+-
+
+
+tt = 0:(1/11025):1;
xx = cos(2*pi*2000*tt);Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(11025,xx)
+]]>
+
+
+
+
+ soundsc(tt,xx)
+]]>
+
+
+
+
+ soundsc(tt,2000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+ soundsc(xx,11025)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_601_A1
+
+0
+
+
+
+QUE_601_A2
+
+0
+
+
+
+QUE_601_A3
+
+0
+
+
+
+QUE_601_A4
+
+0
+
+
+
+QUE_601_A5
+
+100
+
+
+
+
+-
+
+
+PreLab10.m
function PreLab10 = fcos(t)
+PreLab10 = cos(pi*t);
+
Which command will correctly calculate the integral of one period of the cosine? ]]>
+
+
+
+
+
+yy = quad8('fcos',0,2);
+]]>
+
+
+
+
+yy = quad8('mycos',0,2);
+]]>
+
+
+
+
+yy = quad8('PreLab10',0,2);
+]]>
+
+
+
+
+yy = quad8('fcos',[0 2]);
+]]>
+
+
+
+
+yy = quad8('mycos',[0 2]);
+]]>
+
+
+
+
+yy = quad8('PreLab10',[0 2]);
+]]>
+
+
+
+
+yy = quad8(fcos,0,2);
+]]>
+
+
+
+
+yy = quad8(mycos,0,2);
+]]>
+
+
+
+
+yy = quad8(PreLab10,0,2);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_603_A1
+
+50
+
+
+
+QUE_603_A2
+
+33
+
+
+
+QUE_603_A3
+
+100
+
+
+
+QUE_603_A4
+
+33
+
+
+
+QUE_603_A5
+
+0
+
+
+
+QUE_603_A6
+
+50
+
+
+
+QUE_603_A7
+
+0
+
+
+
+QUE_603_A8
+
+0
+
+
+
+QUE_603_A9
+
+50
+
+
+
+
+-
+
+
+HH of a Bandpass filter:
+
hh = (2/16)*cos(0.25*pi*[0:15]);
+ww = 0.1*pi*(0:0.0001:10);
+HH = freqz(hh,1,ww);
+
+Find both the center frequency wc for this BPF, and its passband width.
+
The passband width is defined as the length of the frequency region where the magnitude of the frequency response is greater than 0.707.
+]]>
+
+
+
+
+
+wc = 0.25
+
passband width = 0.3466
+
+]]>
+
+
+
+
+wc = 0.25*pi
+
passband width = 0.1733
+
+]]>
+
+
+
+
+wc = 0.7854
+
passband width = 0.3466
+
+]]>
+
+
+
+
+wc = 0.7854*pi
+
passband width = 0.1733
+
+]]>
+
+
+
+
+wc = 0.7854*pi
+
passband width = 0.1733*2*pi
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_607_A1
+
+50
+
+
+
+QUE_607_A2
+
+50
+
+
+
+QUE_607_A3
+
+100
+
+
+
+QUE_607_A4
+
+0
+
+
+
+QUE_607_A5
+
+0
+
+
+
+
+-
+
+
+lowpass filter with a passband cutoff frequency
of 25 Hz, a stopband cutoff frequency of 50 Hz and a filter length
+of L = 101. The filter coefficients are stored in the vector bb.
+
+Given a signal:
+
+xx = cos(2*pi*100*tt) + cos(2*pi*200*tt) + sin(2*pi*300*tt);
+
+where tt=-4000:1/10000:4000;
+
+Which commands could be used to pass only the sine and reject the two cosines by
+using a bandpass filter?
+Note: the BPF would be created from the LPF.
+]]>
+
+
+
+
+
+bb2 = bb.*cos(2*pi*100*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*100*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = conv(hh,xx);
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*100*((0:100)-50)) ;
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*200*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*200*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = conv(hh,xx);
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*200*((0:100)-50)) ;
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*300*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*300*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = conv(hh,xx);
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*300*((0:100)-50)) ;
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_612_A1
+
+0
+
+
+
+QUE_612_A2
+
+0
+
+
+
+QUE_612_A3
+
+50
+
+
+
+QUE_612_A4
+
+0
+
+
+
+QUE_612_A5
+
+0
+
+
+
+QUE_612_A6
+
+50
+
+
+
+QUE_612_A7
+
+0
+
+
+
+QUE_612_A8
+
+0
+
+
+
+QUE_612_A9
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_613_A1
+
+0
+
+
+
+QUE_613_A2
+
+0
+
+
+
+QUE_613_A3
+
+0
+
+
+
+QUE_613_A4
+
+0
+
+
+
+QUE_613_A5
+
+0
+
+
+
+QUE_613_A6
+
+0
+
+
+
+QUE_613_A7
+
+0
+
+
+
+QUE_613_A8
+
+0
+
+
+
+QUE_613_A9
+
+0
+
+
+
+QUE_613_A10
+
+0
+
+
+
+QUE_613_A11
+
+0
+
+
+
+QUE_613_A12
+
+0
+
+
+
+
+-
+
+
+ office hours
+on (you may have multiple answers)
+]]>
+
+
+
+
+
+ Sunday morning between 8-12
+]]>
+
+
+
+
+ Sunday afternoon between 12-6
+]]>
+
+
+
+
+ Sunday evening between 6-10
+]]>
+
+
+
+
+ Monday morning between 8-12
+]]>
+
+
+
+
+ Monday afternoon between 12-6
+]]>
+
+
+
+
+ Monday evening between 6-10
+]]>
+
+
+
+
+ Tuesday morning between 8-12
+]]>
+
+
+
+
+ Tuesday afternoon between 12-6
+]]>
+
+
+
+
+ Tuesday evening between 6-10
+]]>
+
+
+
+
+ Wednesday morning between 8-12
+]]>
+
+
+
+
+ Wednesday afternoon between 12-6
+]]>
+
+
+
+
+ Wednesday evening between 6-10
+]]>
+
+
+
+
+ Thursday morning between 8-12
+]]>
+
+
+
+
+ Thursday afternoon between 12-6
+]]>
+
+
+
+
+ Thursday evening between 6-10
+]]>
+
+
+
+
+ Friday morning between 8-12
+]]>
+
+
+
+
+ Friday afternoon between 12-6
+]]>
+
+
+
+
+ Friday evening between 6-10
+]]>
+
+
+
+
+ Saturday morning between 8-12
+]]>
+
+
+
+
+ Saturday afternoon between 12-6
+]]>
+
+
+
+
+ Saturday evening between 6-10
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_614_A1
+
+100
+
+
+
+QUE_614_A2
+
+100
+
+
+
+QUE_614_A3
+
+100
+
+
+
+QUE_614_A4
+
+100
+
+
+
+QUE_614_A5
+
+100
+
+
+
+QUE_614_A6
+
+100
+
+
+
+QUE_614_A7
+
+100
+
+
+
+QUE_614_A8
+
+100
+
+
+
+QUE_614_A9
+
+100
+
+
+
+QUE_614_A10
+
+100
+
+
+
+QUE_614_A11
+
+100
+
+
+
+QUE_614_A12
+
+100
+
+
+
+QUE_614_A13
+
+100
+
+
+
+QUE_614_A14
+
+100
+
+
+
+QUE_614_A15
+
+100
+
+
+
+QUE_614_A16
+
+100
+
+
+
+QUE_614_A17
+
+100
+
+
+
+QUE_614_A18
+
+100
+
+
+
+QUE_614_A19
+
+100
+
+
+
+QUE_614_A20
+
+100
+
+
+
+QUE_614_A21
+
+100
+
+
+
+QUE_614_A22
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_615_A1
+
+-25
+
+
+
+QUE_615_A2
+
+-25
+
+
+
+QUE_615_A3
+
+-25
+
+
+
+QUE_615_A4
+
+-25
+
+
+
+QUE_615_A5
+
+-25
+
+
+
+QUE_615_A6
+
+-25
+
+
+
+QUE_615_A7
+
+-25
+
+
+
+QUE_615_A8
+
+-25
+
+
+
+QUE_615_A9
+
+-25
+
+
+
+QUE_615_A10
+
+-25
+
+
+
+QUE_615_A11
+
+25
+
+
+
+QUE_615_A12
+
+25
+
+
+
+QUE_615_A13
+
+25
+
+
+
+QUE_615_A14
+
+25
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+a=[1 -0.4944 .64]
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_616_A1
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_617_A1
+
+0
+
+
+
+QUE_617_A2
+
+0
+
+
+
+QUE_617_A3
+
+100
+
+
+
+QUE_617_A4
+
+0
+
+
+
+QUE_617_A5
+
+0
+
+
+
+
+-
+
+
+test.m contains the following lines of code:
tt = 0:1/8000:2;
+xx = cos(2pi*tt);
+yy = xx+3;
+plot(tt,yy)
+
When it is run, the following error is reported. ??? xx=cos(2 | Missing operator, comma, or semi-colon.
+Error in ==> h:\test.m
+On line 2 ==> xx=cos(2pi*tt);
+
Which line contains the error? ]]>
+
+
+
+
+
+tt = 0:1/8000:2;]]>
+
+
+
+
+xx = cos(2pi*tt);]]>
+
+
+
+
+yy = xx+3;]]>
+
+
+
+
+plot(tt,yy)]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_618_A1
+
+0
+
+
+
+QUE_618_A2
+
+100
+
+
+
+QUE_618_A3
+
+0
+
+
+
+QUE_618_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_624_A1
+
+100
+
+
+
+
+-
+
+
+sinusoidal signal for the impulse response?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_627_A1
+
+100
+
+
+
+QUE_627_A2
+
+0
+
+
+
+QUE_627_A3
+
+25
+
+
+
+QUE_627_A4
+
+0
+
+
+
+QUE_627_A5
+
+25
+
+
+
+QUE_627_A6
+
+0
+
+
+
+QUE_627_A7
+
+0
+
+
+
+QUE_627_A8
+
+0
+
+
+
+
+-
+
+
+
This goal has been accomplished by me.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_629_A1
+
+0
+
+
+
+QUE_629_A2
+
+0
+
+
+
+QUE_629_A3
+
+0
+
+
+
+QUE_629_A4
+
+0
+
+
+
+QUE_629_A5
+
+0
+
+
+
+
+-
+
+
+(Answer given in integer format)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_636_A1
+
+0
+
+
+
+QUE_636_A2
+
+0
+
+
+
+QUE_636_A3
+
+0
+
+
+
+QUE_636_A4
+
+0
+
+
+
+QUE_636_A5
+
+0
+
+
+
+QUE_636_A6
+
+0
+
+
+
+QUE_636_A7
+
+100
+
+
+
+QUE_636_A8
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_637_A1
+
+100
+
+
+
+QUE_637_A2
+
+20
+
+
+
+QUE_637_A3
+
+50
+
+
+
+QUE_637_A4
+
+20
+
+
+
+QUE_637_A5
+
+20
+
+
+
+
+-
+
+
+
+
+Check the box below to indicate you have read these rules.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_644_A1
+
+100
+
+
+
+QUE_644_A2
+
+0
+
+
+
+
+-
+
+
+
function tone = note(keynum,dur)
% Returns a single sinusoid with the key and duration specified
fs = 11025;
tt = 0:1/fs:dur;
f0 = 440*2^((keynum-49)/12);
tone = cos(2*pi*f0*tt);
A student wants to modify the function so that the tone created by this function has TWO frequency components. The new tone should be the sum of two sinusoids, one of which is the frequency for the key number, and the other of which has a frequency 1.5 times higher. The amplitudes (and phases) can be the same. Which one of the following is a correct modification that will accomplish this task?
+
+]]>
+
+
+
+
+
+note() with
tone = cos(2*pi*(3/2)*f0*tt);
+]]>
+
+
+
+
+note() with
tone = cos(2*pi*f0*([1 3/2]')*tt);
+]]>
+
+
+
+
+xx(n1:n2) = xx(n1:n2) + note([f 3/2*f],dur);
+]]>
+
+
+
+
+note() with
tone = cos(2*pi*f0*tt) + cos(2*pi*3/2*f0*tt)
+]]>
+
+
+
+
+note()
f0 = f0 + 3/2*f0;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_650_A1
+
+0
+
+
+
+QUE_650_A2
+
+0
+
+
+
+QUE_650_A3
+
+0
+
+
+
+QUE_650_A4
+
+100
+
+
+
+QUE_650_A5
+
+0
+
+
+
+
+-
+
+
+A be an M x N matrix (elements may be complex).What does A' represent in MATLAB?
+]]>
+
+
+
+
+
+A
+]]>
+
+
+
+
+A
+]]>
+
+
+
+
+A
+]]>
+
+
+
+
+A
+]]>
+
+
+
+
+A
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_653_A1
+
+0
+
+
+
+QUE_653_A2
+
+0
+
+
+
+QUE_653_A3
+
+100
+
+
+
+QUE_653_A4
+
+0
+
+
+
+QUE_653_A5
+
+0
+
+
+
+
+-
+
+
+Matlab quiz tip:
+
+You may cut ("CTRL-C") and paste ("CTRL-V") lines from the WebCT quiz window to the MATLAB window to speed up your problem solving.
+For example, cut a MATLAB statement from WebCT, and paste it into the MATLAB command window in order to execute it.
+
+Check the button below to confirm that you understand this tip.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_657_A1
+
+100
+
+
+
+
+-
+
+
+ xx and yy. You are asked to construct a new vector that has first xx, then a silence vector of length 2 seconds, and then the vector yy. Name the final long vector as sig. Let the sampling rate (fs) be 11025 samples per second.
+Which of the following code fragments will do the job?
+
+Note: this operation is called "CONCATENATION."
+]]>
+
+
+
+
+
+sig = [xx, zeros(1, 2*11025), yy];
+]]>
+
+
+
+
+silence = 0*[0:1/11025:2];
+
sig = [xx, zeros(1, silence), yy];
+]]>
+
+
+
+
+sig = [xx, zeros(1, 2), yy];
+]]>
+
+
+
+
+sig = [xx, zeros(1, round(2/11025)), yy];
+]]>
+
+
+
+
+sig = [xx, zeros(1, round(11025/2)), yy];
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_658_A1
+
+100
+
+
+
+QUE_658_A2
+
+0
+
+
+
+QUE_658_A3
+
+0
+
+
+
+QUE_658_A4
+
+0
+
+
+
+QUE_658_A5
+
+0
+
+
+
+
+-
+
+
+Bandpass filter?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_664_A1
+
+50
+
+
+
+QUE_664_A2
+
+0
+
+
+
+QUE_664_A3
+
+100
+
+
+
+QUE_664_A4
+
+0
+
+
+
+QUE_664_A5
+
+0
+
+
+
+QUE_664_A6
+
+0
+
+
+
+QUE_664_A7
+
+0
+
+
+
+QUE_664_A8
+
+0
+
+
+
+
+-
+
+
+N is even and greater than 2, what is the length (number of elements) of the vector nn defined as nn = 0:2:N/2?
+NOTE: fix(N/4) takes the integer part if N is not evenly divisible by 4.
+]]>
+
+
+
+
+
+N/2
+]]>
+
+
+
+
+N/2 + 1
+]]>
+
+
+
+
+fix(N/4)
+]]>
+
+
+
+
+fix(N/4) + 1
+]]>
+
+
+
+
+nn contained previously
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_672_A1
+
+0
+
+
+
+QUE_672_A2
+
+0
+
+
+
+QUE_672_A3
+
+40
+
+
+
+QUE_672_A4
+
+100
+
+
+
+QUE_672_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_674_A1
+
+0
+
+
+
+QUE_674_A2
+
+0
+
+
+
+QUE_674_A3
+
+0
+
+
+
+QUE_674_A4
+
+0
+
+
+
+QUE_674_A5
+
+0
+
+
+
+
+-
+
+
+x.A = 10;
+x.t = [0:1/11025:2];
+x.phi = pi/3;
+x.freq = 100;
+You are asked to write ONE line of MATLAB code that constructs a sinusoidal signal ''y" that has the above parameters. Mark all possible solutions from the following: ]]>
+
+
+
+
+
+ y = A*cos(2*pi*freq*t + phi);
+]]>
+
+
+
+
+ y = x.A * cos(2*pi*x.freq*x.t + x.phi);
+]]>
+
+
+
+
+ y = real(x.A*exp(j*x.phi) * exp(j*2*pi*x.freq*x.t) )
+]]>
+
+
+
+
+ y = abs(x.A*exp(j*x.phi) * exp(j*2*pi*x.freq*x.t) )
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_679_A1
+
+-50
+
+
+
+QUE_679_A2
+
+50
+
+
+
+QUE_679_A3
+
+50
+
+
+
+QUE_679_A4
+
+-50
+
+
+
+
+-
+
+
+
+ak = sin(k)./(pi*k);
+ak(ceil(length(ak)/2))=1/pi;
+
+using the ak2sig function in MATLAB.
+
+If the FUNDAMENTAL period is defined to be To = 5, which of the following signals is synthesized (approximately) as N becomes large (>20)?
+
NOTE: The Fourier Series coefficients for |k| < N are used in the synthesis.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_681_A1
+
+0
+
+
+
+QUE_681_A2
+
+100
+
+
+
+QUE_681_A3
+
+40
+
+
+
+QUE_681_A4
+
+25
+
+
+
+QUE_681_A5
+
+0
+
+
+
+QUE_681_A6
+
+0
+
+
+
+
+-
+
+
+fc = 900 Hz and delf = 20 Hz, the beatcon tool will create a signal containing two frequency components (f1, f2) which exhibit a beat note behavior. Which is a correct description of the signal?
+
+]]>
+
+
+
+
+
+f1 = 900 Hz, f2 = 910 Hz
+
+]]>
+
+
+
+
+f1 = 910 Hz, f2 = 920 Hz
+
+]]>
+
+
+
+
+f1 = 880 Hz, f2 = 920 Hz
+
+]]>
+
+
+
+
+f1 = 890 Hz, f2 = 910 Hz
+
+]]>
+
+
+
+
+f1 = 900 Hz, f2 = 920 Hz
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_685_A1
+
+0
+
+
+
+QUE_685_A2
+
+0
+
+
+
+QUE_685_A3
+
+100
+
+
+
+QUE_685_A4
+
+0
+
+
+
+QUE_685_A5
+
+0
+
+
+
+
+-
+
+
+fs = 11025;
nn = (0:round(0.25*fs));Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 1? ]]>
+
+
+
+
+
+yy = cos(2*pi*1209*nn) * cos(2*pi*697*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*1209*nn) + cos(2*pi*697*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*1209*697*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1209+697)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1209/fs)*nn) * cos(2*pi*(697/fs)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1209/fs)*nn) + cos(2*pi*(697/fs)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*((1209+697)/fs)*nn);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_686_A1
+
+0
+
+
+
+QUE_686_A2
+
+50
+
+
+
+QUE_686_A3
+
+0
+
+
+
+QUE_686_A4
+
+0
+
+
+
+QUE_686_A5
+
+0
+
+
+
+QUE_686_A6
+
+100
+
+
+
+QUE_686_A7
+
+0
+
+
+
+
+-
+
+
+
tt = 0:1/8000:1.0;
+xx1 = cos(2*pi*440*tt);
+xx2 = cos(2*pi*360*tt);
+
We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being HIGHER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_688_A1
+
+0
+
+
+
+QUE_688_A2
+
+0
+
+
+
+QUE_688_A3
+
+100
+
+
+
+QUE_688_A4
+
+25
+
+
+
+QUE_688_A5
+
+0
+
+
+
+
+-
+
+
+signal.m. Below is the code.
+
function [xx, times] = signal(tstart,tend)
+times = tstart:1/100:tend;
+xx = [];
+for ii=1:length(times)
+ xx = [xx, cos(2*pi*times(ii))];
+end;
+
+
+What is the correct way to call this function and make a plot of the sinusoid over the interval from t=1 to t=2 ?
+
+]]>
+
+
+
+
+
+
+signal(1,2); plot(xx, times)
+
+]]>
+
+
+
+
+
+signal(1,2); plot(times, xx)
+
+]]>
+
+
+
+
+
+yy = signal(1,2); plot(times,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = signal([1,2]); plot(tt,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = signal(1,2); plot(tt,yy)
+
+]]>
+
+
+
+
+
+plot( 1:2, signal(1,2) )
+
+]]>
+
+
+
+
+
+[tt,yy] = signal(1,2); plot(tt,yy)
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_690_A1
+
+0
+
+
+
+QUE_690_A2
+
+0
+
+
+
+QUE_690_A3
+
+30
+
+
+
+QUE_690_A4
+
+30
+
+
+
+QUE_690_A5
+
+100
+
+
+
+QUE_690_A6
+
+0
+
+
+
+QUE_690_A7
+
+30
+
+
+
+
+-
+
+
+
+
+
+
+
+
+ dbstop
+]]>
+
+
+
+
+ dbcont
+]]>
+
+
+
+
+ dbclear
+]]>
+
+
+
+
+ dbstart
+]]>
+
+
+
+
+ dbstop if error
+]]>
+
+
+
+
+ dbmode
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_692_A1
+
+25
+
+
+
+QUE_692_A2
+
+0
+
+
+
+QUE_692_A3
+
+0
+
+
+
+QUE_692_A4
+
+0
+
+
+
+QUE_692_A5
+
+100
+
+
+
+QUE_692_A6
+
+0
+
+
+
+
+-
+
+
+t)], the instantaneous frequency (in Hz) is related to the quadratic "angle" function,
Ψ(t) = 2πμt2 + 2πf0t + φ
as: ]]>
+
+
+
+
+
+t) is the instantaneous frequency.
+]]>
+
+
+
+
+t
+]]>
+
+
+
+
+t)
+]]>
+
+
+
+
+t).
+]]>
+
+
+
+
+t)/(2π).
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_696_A1
+
+0
+
+
+
+QUE_696_A2
+
+0
+
+
+
+QUE_696_A3
+
+100
+
+
+
+QUE_696_A4
+
+0
+
+
+
+QUE_696_A5
+
+0
+
+
+
+
+-
+
+
+ALL of the
+VALID ways to write an expression whose value is the "square root of -1"
+]]>
+
+
+
+
+
+i
+]]>
+
+
+
+
+0 + 1i
+]]>
+
+
+
+
+sqrt(-1)
+]]>
+
+
+
+
+j
+]]>
+
+
+
+
+0 + 1*j
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_701_A1
+
+20
+
+
+
+QUE_701_A2
+
+20
+
+
+
+QUE_701_A3
+
+20
+
+
+
+QUE_701_A4
+
+20
+
+
+
+QUE_701_A5
+
+20
+
+
+
+
+-
+
+
+Nulling filter?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_704_A1
+
+0
+
+
+
+QUE_704_A2
+
+0
+
+
+
+QUE_704_A3
+
+0
+
+
+
+QUE_704_A4
+
+100
+
+
+
+QUE_704_A5
+
+0
+
+
+
+QUE_704_A6
+
+0
+
+
+
+QUE_704_A7
+
+0
+
+
+
+QUE_704_A8
+
+0
+
+
+
+
+-
+
+
+fs = 11025;
+tt = (0:round(0.25*fs))/fs;
+Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 0?
+]]>
+
+
+
+
+
+yy = cos(2*pi*1336*tt) * cos(2*pi*941*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*1336*tt) + cos(2*pi*941*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*1336*941*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1336+941)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1336/fs)*tt) * cos(2*pi*(941/fs)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1336/fs)*tt) + cos(2*pi*(941/fs)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*((1336+941)/fs)*tt);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_708_A1
+
+0
+
+
+
+QUE_708_A2
+
+100
+
+
+
+QUE_708_A3
+
+0
+
+
+
+QUE_708_A4
+
+0
+
+
+
+QUE_708_A5
+
+0
+
+
+
+QUE_708_A6
+
+50
+
+
+
+QUE_708_A7
+
+0
+
+
+
+
+-
+
+
+ ** WARNING **
+Running the MATLAB code in the next problem(s) will lock up your computer.
+
+
+For such questions you should ANALYZE the code, not "cut and paste" the whole thing to run it.
+
+As usual, Hit the "Save Answer" button often, and when you are finished with all the questions, hit the "FINISH" button.
+
+
Check the button below to confirm that you understand these instructions.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_711_A1
+
+100
+
+
+
+
+-
+
+
+tt = (0:8000)/8000;
+xx = cos(2*pi*2000*tt);Which one of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+ soundsc(tt,xx)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+ soundsc(xx,tt)
+]]>
+
+
+
+
+ soundsc(tt)
+]]>
+
+
+
+
+ soundsc(tt,8000)
+]]>
+
+
+
+
+ soundsc(2000,xx)
+]]>
+
+
+
+
+ soundsc(xx,2000)
+]]>
+
+
+
+
+ soundsc(tt,2000)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_716_A1
+
+25
+
+
+
+QUE_716_A2
+
+0
+
+
+
+QUE_716_A3
+
+100
+
+
+
+QUE_716_A4
+
+25
+
+
+
+QUE_716_A5
+
+0
+
+
+
+QUE_716_A6
+
+0
+
+
+
+QUE_716_A7
+
+0
+
+
+
+QUE_716_A8
+
+25
+
+
+
+QUE_716_A9
+
+0
+
+
+
+
+-
+
+
+ pp,
+the message bits in string row vector mm,
+and termination bits in string row vector term.
+
+
Each string row vector is an array of characters ('0' or '1') in MATLAB, e.g., '0010110101110'.
+
+
Which of the following is the correct way
+to form the bit string sent out from modem?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_720_A1
+
+0
+
+
+
+QUE_720_A2
+
+0
+
+
+
+QUE_720_A3
+
+0
+
+
+
+QUE_720_A4
+
+0
+
+
+
+QUE_720_A5
+
+0
+
+
+
+QUE_720_A6
+
+0
+
+
+
+QUE_720_A7
+
+0
+
+
+
+QUE_720_A8
+
+100
+
+
+
+
+-
+
+
+Z is a complex number, and that Z is equal to the congugate of Z. Then we can conclude:
+
+]]>
+
+
+
+
+
+Z is zero.
+
+]]>
+
+
+
+
+Z is purely imaginary (no real part)
+
+]]>
+
+
+
+
+Z is a complex exponential
+
+]]>
+
+
+
+
+Z is zero
+
+]]>
+
+
+
+
+Z
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_722_A1
+
+33
+
+
+
+QUE_722_A2
+
+0
+
+
+
+QUE_722_A3
+
+0
+
+
+
+QUE_722_A4
+
+100
+
+
+
+QUE_722_A5
+
+0
+
+
+
+
+-
+
+
+5 with the number 12 in the lengths field of the structure array SS ?
+
+SS = struct('strings',{{'hello','yes'}},'lengths',[5 3])
+
+]]>
+
+
+
+
+
+ SS.5 = 12;
+]]>
+
+
+
+
+ SS(2,1) = 12
+]]>
+
+
+
+
+ SS.lengths.5 = 12
+]]>
+
+
+
+
+ SS.lengths(1) = {'12'}
+]]>
+
+
+
+
+ SS.lengths(1) = 12
+]]>
+
+
+
+
+ SS.lengths(2) = 12
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_725_A1
+
+0
+
+
+
+QUE_725_A2
+
+0
+
+
+
+QUE_725_A3
+
+0
+
+
+
+QUE_725_A4
+
+0
+
+
+
+QUE_725_A5
+
+100
+
+
+
+QUE_725_A6
+
+0
+
+
+
+
+-
+
+
+bb, whose frequency response of the filter is assigned as HH.
+
+bb = ones(1,4)/2;
+ww = [-pi:2*pi/99741000:pi]
+HH = exp(-j*1.5*ww).*(cos(0.5*ww)+cos(1.5*ww));
+plot(ww,abs(HH));
+
+
+Which of the following code fragments gives the same plot as the one produced by the above code?
+
(Don't try to run this code, just analyze it.)
+]]>
+
+
+
+
+
+ ww = [-pi:2*pi/99741000:pi];
+
H = freqz(bb,1,ww)
+
plot(ww,abs(bb));
+]]>
+
+
+
+
+ ww = [-pi:2*pi/99741000:pi];
+
H = freqz(bb,HH,ww)
+
plot(ww,abs(H));
+]]>
+
+
+
+
+ ww = [-pi:2*pi/99741000:pi];
+
H = freqz(HH,1,ww)
+
plot(ww,abs(H));
+]]>
+
+
+
+
+ ww = [-pi:2*pi/99741000:pi];
+
H = freqz(bb,1,ww)
+
plot(ww,H);
+]]>
+
+
+
+
+ ww = [-pi:2*pi/99741000:pi];
+
H = freqz(bb,1,ww)
+
plot(ww,abs(H));
+]]>
+
+
+
+
+ ww = [-pi:2*pi/99741000:pi];
+
H = freqz(ww,1,bb)
+
plot(ww,abs(H));
+]]>
+
+
+
+
+ ww = [-pi:2*pi/99741000:pi];
+
H = freqz(HH,bb,ww)
+
plot(ww,abs(H));
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_726_A1
+
+25
+
+
+
+QUE_726_A2
+
+0
+
+
+
+QUE_726_A3
+
+0
+
+
+
+QUE_726_A4
+
+50
+
+
+
+QUE_726_A5
+
+100
+
+
+
+QUE_726_A6
+
+0
+
+
+
+QUE_726_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_727_A1
+
+0
+
+
+
+QUE_727_A2
+
+0
+
+
+
+QUE_727_A3
+
+0
+
+
+
+QUE_727_A4
+
+0
+
+
+
+QUE_727_A5
+
+0
+
+
+
+
+-
+
+
+0 was pressed, which of following frequencies will be transmitted?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_729_A1
+
+-50
+
+
+
+QUE_729_A2
+
+-50
+
+
+
+QUE_729_A3
+
+-50
+
+
+
+QUE_729_A4
+
+50
+
+
+
+QUE_729_A5
+
+-50
+
+
+
+QUE_729_A6
+
+50
+
+
+
+QUE_729_A7
+
+-50
+
+
+
+QUE_729_A8
+
+-50
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_730_A1
+
+0
+
+
+
+QUE_730_A2
+
+0
+
+
+
+QUE_730_A3
+
+0
+
+
+
+QUE_730_A4
+
+0
+
+
+
+QUE_730_A5
+
+0
+
+
+
+
+-
+
+
+7 was pressed, which of following frequencies will be transmitted?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_736_A1
+
+-50
+
+
+
+QUE_736_A2
+
+-50
+
+
+
+QUE_736_A3
+
+50
+
+
+
+QUE_736_A4
+
+-50
+
+
+
+QUE_736_A5
+
+50
+
+
+
+QUE_736_A6
+
+-50
+
+
+
+QUE_736_A7
+
+-50
+
+
+
+QUE_736_A8
+
+-50
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_742_A1
+
+0
+
+
+
+QUE_742_A2
+
+0
+
+
+
+QUE_742_A3
+
+0
+
+
+
+QUE_742_A4
+
+0
+
+
+
+QUE_742_A5
+
+0
+
+
+
+
+-
+
+
+
+When you are finished with all the questions, hit the "FINISH" button.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_743_A1
+
+100
+
+
+
+
+-
+
+
+specgram function in MATLAB. What can you say
+about the signal being represented?
+]]>
+
+
+
+
+
+
+added together.
+]]>
+
+
+
+
+addition of two sinusoids.
+]]>
+
+
+
+
+concatenated, but I cannot tell how long the original signal is.
+]]>
+
+
+
+
+
+
+
+
+
+concatenation of two sinusoids, and
+the total length is exactly 2 seconds.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_745_A1
+
+0
+
+
+
+QUE_745_A2
+
+0
+
+
+
+QUE_745_A3
+
+100
+
+
+
+QUE_745_A4
+
+0
+
+
+
+QUE_745_A5
+
+50
+
+
+
+
+-
+
+
+
+
fs = 11025;
+tt = (0:round(0.25*fs))/fs;
+Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 2?
+
+]]>
+
+
+
+
+
+yy = cos(2*pi*1336*tt) * cos(2*pi*697*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*1336*tt) + cos(2*pi*697*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*1336*697*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1336+697)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1336/fs)*tt) * cos(2*pi*(697/fs)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1336/fs)*tt) + cos(2*pi*(697/fs)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*((1336+697)/fs)*tt);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_746_A1
+
+0
+
+
+
+QUE_746_A2
+
+100
+
+
+
+QUE_746_A3
+
+0
+
+
+
+QUE_746_A4
+
+0
+
+
+
+QUE_746_A5
+
+0
+
+
+
+QUE_746_A6
+
+50
+
+
+
+QUE_746_A7
+
+0
+
+
+
+
+-
+
+
+
+
fs = 11025;
+tt = (0:round(0.25*fs))/fs;
+
+Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 3?
+
+]]>
+
+
+
+
+
+yy = cos(2*pi*1477*tt) * cos(2*pi*697*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*1477*tt) + cos(2*pi*697*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*1477*697*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1477+697)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1477/fs)*tt) * cos(2*pi*(697/fs)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1477/fs)*tt) + cos(2*pi*(697/fs)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*((1477+697)/fs)*tt);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_747_A1
+
+0
+
+
+
+QUE_747_A2
+
+100
+
+
+
+QUE_747_A3
+
+0
+
+
+
+QUE_747_A4
+
+0
+
+
+
+QUE_747_A5
+
+0
+
+
+
+QUE_747_A6
+
+50
+
+
+
+QUE_747_A7
+
+0
+
+
+
+
+-
+
+
+
+
fs = 11025;
+tt = (0:round(0.25*fs))/fs;
+
+Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number A?
+]]>
+
+
+
+
+
+yy = cos(2*pi*1633*tt) * cos(2*pi*697*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*1633*tt) + cos(2*pi*697*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*1633*697*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1633+697)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1633/fs)*tt) * cos(2*pi*(697/fs)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1633/fs)*tt) + cos(2*pi*(697/fs)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*((1633+697)/fs)*tt);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_748_A1
+
+0
+
+
+
+QUE_748_A2
+
+100
+
+
+
+QUE_748_A3
+
+0
+
+
+
+QUE_748_A4
+
+0
+
+
+
+QUE_748_A5
+
+0
+
+
+
+QUE_748_A6
+
+50
+
+
+
+QUE_748_A7
+
+0
+
+
+
+
+-
+
+
+fs = 11025;
+tt = (0:round(0.25*fs))/fs;
+Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number B?
+
+]]>
+
+
+
+
+
+yy = cos(2*pi*1633*tt) * cos(2*pi*770*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*1633*tt) + cos(2*pi*770*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*1633*770*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1633+770)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1633/fs)*tt) * cos(2*pi*(770/fs)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*(1633/fs)*tt) + cos(2*pi*(770/fs)*tt);
+]]>
+
+
+
+
+yy = cos(2*pi*((1633+770)/fs)*tt);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_749_A1
+
+0
+
+
+
+QUE_749_A2
+
+100
+
+
+
+QUE_749_A3
+
+0
+
+
+
+QUE_749_A4
+
+0
+
+
+
+QUE_749_A5
+
+0
+
+
+
+QUE_749_A6
+
+50
+
+
+
+QUE_749_A7
+
+0
+
+
+
+
+-
+
+
+fs = 11025;
+nn = (0:round(0.25*fs));
+Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 6?
+
+]]>
+
+
+
+
+
+yy = cos(2*pi*1477*nn) * cos(2*pi*770*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*1477*nn) + cos(2*pi*770*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*1477*770*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1477+770)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1477/fs)*nn) * cos(2*pi*(770/fs)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*((1477+770)/fs)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1477/fs)*nn) + cos(2*pi*(770/fs)*nn);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_750_A1
+
+0
+
+
+
+QUE_750_A2
+
+50
+
+
+
+QUE_750_A3
+
+0
+
+
+
+QUE_750_A4
+
+0
+
+
+
+QUE_750_A5
+
+0
+
+
+
+QUE_750_A6
+
+0
+
+
+
+QUE_750_A7
+
+100
+
+
+
+
+-
+
+
+
+
fs = 11025;
+nn = (0:round(0.25*fs));
+Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 4?
+
+]]>
+
+
+
+
+
+yy = cos(2*pi*1209*nn) * cos(2*pi*770*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*1209*nn) + cos(2*pi*770*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*1209*770*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1209+770)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1209/fs)*nn) * cos(2*pi*(770/fs)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*((1209+770)/fs)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1209/fs)*nn) + cos(2*pi*(770/fs)*nn);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_751_A1
+
+0
+
+
+
+QUE_751_A2
+
+50
+
+
+
+QUE_751_A3
+
+0
+
+
+
+QUE_751_A4
+
+0
+
+
+
+QUE_751_A5
+
+0
+
+
+
+QUE_751_A6
+
+0
+
+
+
+QUE_751_A7
+
+100
+
+
+
+
+-
+
+
+
+
fs = 11025;
+nn = (0:round(0.25*fs));
+Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 7?
+]]>
+
+
+
+
+
+yy = cos(2*pi*1209*nn) * cos(2*pi*852*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*1209*nn) + cos(2*pi*852*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*1209*852*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1209+852)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1209/fs)*nn) * cos(2*pi*(852/fs)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*((1209+852)/fs)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1209/fs)*nn) + cos(2*pi*(852/fs)*nn);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_753_A1
+
+0
+
+
+
+QUE_753_A2
+
+50
+
+
+
+QUE_753_A3
+
+0
+
+
+
+QUE_753_A4
+
+0
+
+
+
+QUE_753_A5
+
+0
+
+
+
+QUE_753_A6
+
+0
+
+
+
+QUE_753_A7
+
+100
+
+
+
+
+-
+
+
+
+
fs = 11025;
+nn = (0:round(0.25*fs));
+Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 8?
+
+]]>
+
+
+
+
+
+yy = cos(2*pi*1336*nn) * cos(2*pi*852*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*1336*nn) + cos(2*pi*852*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*1336*852*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1336+852)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1336/fs)*nn) * cos(2*pi*(852/fs)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*((1336+852)/fs)*nn);
+]]>
+
+
+
+
+yy = cos(2*pi*(1336/fs)*nn) + cos(2*pi*(852/fs)*nn);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_754_A1
+
+0
+
+
+
+QUE_754_A2
+
+50
+
+
+
+QUE_754_A3
+
+0
+
+
+
+QUE_754_A4
+
+0
+
+
+
+QUE_754_A5
+
+0
+
+
+
+QUE_754_A6
+
+0
+
+
+
+QUE_754_A7
+
+100
+
+
+
+
+-
+
+
+ office hours
+on (you may have multiple answers)
+]]>
+
+
+
+
+
+ Sunday morning between 8-12
+]]>
+
+
+
+
+ Sunday afternoon between 12-6
+]]>
+
+
+
+
+ Sunday evening between 6-10
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_755_A1
+
+100
+
+
+
+QUE_755_A2
+
+100
+
+
+
+QUE_755_A3
+
+100
+
+
+
+QUE_755_A4
+
+100
+
+
+
+
+-
+
+
+magnitude and phase of a frequency response vector HH?
+]]>
+
+
+
+
+
+abs(HH), phase(HH)
+]]>
+
+
+
+
+mag(HH), phase(HH)
+]]>
+
+
+
+
+abs(HH), angle(HH)
+]]>
+
+
+
+
+mag(HH), angle(HH)
+]]>
+
+
+
+
+real(HH), imag(HH)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_756_A1
+
+0
+
+
+
+QUE_756_A2
+
+0
+
+
+
+QUE_756_A3
+
+100
+
+
+
+QUE_756_A4
+
+0
+
+
+
+QUE_756_A5
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*pi*440*tt);
+xx2 = cos(2*pi*360*tt);
+
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
+
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this:
+]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_758_A1
+
+0
+
+
+
+QUE_758_A2
+
+0
+
+
+
+QUE_758_A3
+
+25
+
+
+
+QUE_758_A4
+
+100
+
+
+
+QUE_758_A5
+
+0
+
+
+
+
+-
+
+
+bb containing filter coefficients, how do we plot the magnitude of the frequency response?
+]]>
+
+
+
+
+
+ww=-pi:pi/100:pi;
plot(ww,abs(bb));
+]]>
+
+
+
+
+ww=-pi:pi/100:pi;
H=freqz(bb,1,ww);
plot(ww,real(H));
+]]>
+
+
+
+
+ww=-pi:pi/100:pi;
H=freqz(ww,1,bb);
plot(ww,abs(H));
+]]>
+
+
+
+
+ww=-pi:pi/100:pi;
H=freqz(bb,1,ww);
plot(ww,abs(H));
+]]>
+
+
+
+
+ww=-pi:pi/100:pi;
H=freqz(bb,1,ww);
plot(ww,H);
+]]>
+
+
+
+
+ww=-pi:pi/100:pi;
H=freqz(bb,1,ww);
plot(ww,angle(H));
+]]>
+
+
+
+
+ww=-pi:pi/100:pi;
H=freqz(bb,1,ww);
plot(ww,mag(H));
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_759_A1
+
+0
+
+
+
+QUE_759_A2
+
+30
+
+
+
+QUE_759_A3
+
+0
+
+
+
+QUE_759_A4
+
+100
+
+
+
+QUE_759_A5
+
+30
+
+
+
+QUE_759_A6
+
+30
+
+
+
+QUE_759_A7
+
+30
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_763_A1
+
+0
+
+
+
+QUE_763_A2
+
+0
+
+
+
+QUE_763_A3
+
+0
+
+
+
+QUE_763_A4
+
+0
+
+
+
+QUE_763_A5
+
+0
+
+
+
+
+-
+
+
+5 was pressed, which of following frequencies will be transmitted?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_771_A1
+
+-50
+
+
+
+QUE_771_A2
+
+50
+
+
+
+QUE_771_A3
+
+-50
+
+
+
+QUE_771_A4
+
+-50
+
+
+
+QUE_771_A5
+
+-50
+
+
+
+QUE_771_A6
+
+50
+
+
+
+QUE_771_A7
+
+-50
+
+
+
+QUE_771_A8
+
+-50
+
+
+
+
+-
+
+
+Tower. The matrix encodes a digital image of the Tech Tower.
+
Which of the following commands will properly display the image of the Tech Tower? Pick ONE.
+]]>
+
+
+
+
+
+ show_img(Tower)
+]]>
+
+
+
+
+ figure(Tower)
+]]>
+
+
+
+
+ plot(Tower)
+]]>
+
+
+
+
+ show_img(tower)
+]]>
+
+
+
+
+ colormap(Tower)
+]]>
+
+
+
+
+ print(Tower)
+]]>
+
+
+
+
+display(TechTower)
+]]>
+
+
+
+
+show_img('Tech Tower')
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_774_A1
+
+100
+
+
+
+QUE_774_A2
+
+0
+
+
+
+QUE_774_A3
+
+0
+
+
+
+QUE_774_A4
+
+60
+
+
+
+QUE_774_A5
+
+0
+
+
+
+QUE_774_A6
+
+0
+
+
+
+QUE_774_A7
+
+0
+
+
+
+QUE_774_A8
+
+20
+
+
+
+
+-
+
+
+9 was pressed, which of following frequencies will be transmitted?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_778_A1
+
+-50
+
+
+
+QUE_778_A2
+
+-50
+
+
+
+QUE_778_A3
+
+50
+
+
+
+QUE_778_A4
+
+-50
+
+
+
+QUE_778_A5
+
+-50
+
+
+
+QUE_778_A6
+
+-50
+
+
+
+QUE_778_A7
+
+50
+
+
+
+QUE_778_A8
+
+-50
+
+
+
+
+-
+
+
+
+
+H(jω) = 3/(jω + 2)
+
+
+
+Signal y1(t) is output of the system with input signal
+
+x1(t) = 5 + 3 cos( 30 π t)
+
+
+
+Similarly, signal y2(t) is output of the system with input signal
+
+x2(t) = 5 + 3 cos( 70 π t)
+
+
+
+
+Choose correct answer(s) from the following (it could be multiple answers)
+]]>
+
+
+
+
+
+1(t) is greater than ripple of y2(t)
+]]>
+
+
+
+
+1(t) is less than ripple of y2(t)
+]]>
+
+
+
+
+1(t) is equal to ripple of y2(t)
+]]>
+
+
+
+
+1(t) is greater than DC of y2(t)
+]]>
+
+
+
+
+1(t) is less than DC of y2(t)
+]]>
+
+
+
+
+1(t) is equal to DC of y2(t)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_781_A1
+
+50
+
+
+
+QUE_781_A2
+
+-25
+
+
+
+QUE_781_A3
+
+-25
+
+
+
+QUE_781_A4
+
+-25
+
+
+
+QUE_781_A5
+
+-25
+
+
+
+QUE_781_A6
+
+50
+
+
+
+
+-
+
+
+
+
+H(jω) = 6jω/(jω + 7)
+
+
+
+Signal y1(t) is output of the system with input signal
+
+x1(t) = 3 + 8 cos( 30 π t)
+
+
+
+Similarly, signal y2(t) is output of the system with input signal
+
+x2(t) = 3 + 8 cos( 80 π t)
+
+
+
+
+Choose correct answer(s) from the following (it could be multiple answers)
+]]>
+
+
+
+
+
+1(t) is greater than ripple of y2(t) ]]>
+
+
+
+
+1(t) is less than ripple of y2(t)
+]]>
+
+
+
+
+1(t) is equal to ripple of y2(t)
+]]>
+
+
+
+
+1(t) is greater than DC of y2(t)
+]]>
+
+
+
+
+1(t) is less than DC of y2(t)
+]]>
+
+
+
+
+1(t) is equal to DC of y2(t)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_783_A1
+
+-25
+
+
+
+QUE_783_A2
+
+50
+
+
+
+QUE_783_A3
+
+-25
+
+
+
+QUE_783_A4
+
+-25
+
+
+
+QUE_783_A5
+
+-25
+
+
+
+QUE_783_A6
+
+50
+
+
+
+
+-
+
+
+magnitude of the frequency
+response of an FIR digital highpass filter
+H(z) when given the filter coefficients,
+bb. Which of the following procedures will
+achieve the desired plot. Pick the BEST answer.
+
+
+
+]]>
+
+
+
+
+
+ ww=-pi:pi; HH=freqz(bb,1,ww); plot(ww,abs(HH))
+
+
+]]>
+
+
+
+
+ ww=-pi:pi/100:pi; HH=freqz(bb,ww); plot(ww,abs(HH))
+
+
+]]>
+
+
+
+
+ ww=-pi:pi/100:pi; HH=freqz(bb,1,ww); plot(ww,HH)
+
+
+]]>
+
+
+
+
+ ww=-pi:pi/100:pi; HH=freqz(bb,1,ww); plot(ww,abs(HH))
+
+
+]]>
+
+
+
+
+ ww=-pi:pi/100:pi; HH=freqz(ww,bb); plot(ww,abs(HH))
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_787_A1
+
+50
+
+
+
+QUE_787_A2
+
+0
+
+
+
+QUE_787_A3
+
+50
+
+
+
+QUE_787_A4
+
+100
+
+
+
+QUE_787_A5
+
+0
+
+
+
+
+-
+
+
+xx is a complex-valued ROW vector of length equal to 100. Which of the following one-liners will sum the values in xx ?
+]]>
+
+
+
+
+
+ res = xx * ones(1,100);
+]]>
+
+
+
+
+
res = 0; res = res + xx(:);
+
+]]>
+
+
+
+
+ res = ones(1,100) * xx';
+
+]]>
+
+
+
+
+ res = xx(1:100);
+
+]]>
+
+
+
+
+ res = xx * ones(100,1);
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_791_A1
+
+0
+
+
+
+QUE_791_A2
+
+0
+
+
+
+QUE_791_A3
+
+50
+
+
+
+QUE_791_A4
+
+0
+
+
+
+QUE_791_A5
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_793_A1
+
+20
+
+
+
+QUE_793_A2
+
+50
+
+
+
+QUE_793_A3
+
+100
+
+
+
+QUE_793_A4
+
+0
+
+
+
+QUE_793_A5
+
+20
+
+
+
+
+-
+
+
+NOT a graded Pre/Post Lab quiz. This is for entering concepts for section 3.3 of lab #12. Before you hit "Finish" button, you are required to show your answers to lab TAs.
+Check the button below to confirm that you understand these instructions
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_795_A1
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_799_A1
+
+0
+
+
+
+QUE_799_A2
+
+0
+
+
+
+QUE_799_A3
+
+0
+
+
+
+QUE_799_A4
+
+0
+
+
+
+QUE_799_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_805_A1
+
+20
+
+
+
+QUE_805_A2
+
+20
+
+
+
+QUE_805_A3
+
+-20
+
+
+
+QUE_805_A4
+
+20
+
+
+
+QUE_805_A5
+
+20
+
+
+
+QUE_805_A6
+
+-20
+
+
+
+QUE_805_A7
+
+20
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_808_A1
+
+100
+
+
+
+QUE_808_A2
+
+0
+
+
+
+QUE_808_A3
+
+0
+
+
+
+QUE_808_A4
+
+0
+
+
+
+QUE_808_A5
+
+0
+
+
+
+
+-
+
+
+Warning!! You are REQUIRED to show your answers to one of the lab TAs, and then to hit the "Finish" button in front of your Lab TA so that you can get the check-off for this part.
+Check the button below to confirm that you understand these instructions
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_809_A1
+
+100
+
+
+
+
+-
+
+
+Semicolon, ;, in MATLAB. Which of the following commands would help him/her find the answer?
+]]>
+
+
+
+
+
+help ;
+]]>
+
+
+
+
+help Semicolon
+]]>
+
+
+
+
+help ops
+]]>
+
+
+
+
+find ;
+]]>
+
+
+
+
+lookfor ;
+]]>
+
+
+
+
+;
+]]>
+
+
+
+
+whos ;
+]]>
+
+
+
+
+tell me ;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_813_A1
+
+0
+
+
+
+QUE_813_A2
+
+0
+
+
+
+QUE_813_A3
+
+100
+
+
+
+QUE_813_A4
+
+0
+
+
+
+QUE_813_A5
+
+0
+
+
+
+QUE_813_A6
+
+0
+
+
+
+QUE_813_A7
+
+0
+
+
+
+QUE_813_A8
+
+0
+
+
+
+
+-
+
+
+ A = exp(j*pi*2); pp = cos(5*pi);
+ z = 8 + 7j; w = -5-9j;
+ conj(z+w);
+ tan(90);
+ B = sin(100); gg = sqrt(99+pp);
+
+(Note: it is possible to cut and paste from WebCT to MATLAB.)
+At the end of these commands, what is the variable ans equal to?
+]]>
+
+
+
+
+
+A
+]]>
+
+
+
+
+B
+]]>
+
+
+
+
+tan(90)
+]]>
+
+
+
+
+z
+]]>
+
+
+
+
+w
+]]>
+
+
+
+
+conj(z+w)
+]]>
+
+
+
+
+pp
+]]>
+
+
+
+
+gg
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_814_A1
+
+0
+
+
+
+QUE_814_A2
+
+0
+
+
+
+QUE_814_A3
+
+100
+
+
+
+QUE_814_A4
+
+0
+
+
+
+QUE_814_A5
+
+0
+
+
+
+QUE_814_A6
+
+0
+
+
+
+QUE_814_A7
+
+0
+
+
+
+QUE_814_A8
+
+0
+
+
+
+
+-
+
+
+ cc. Which of the following commands extracts the real part of cc ?
+]]>
+
+
+
+
+
+REAL(cc)
+]]>
+
+
+
+
+real(cc)
+]]>
+
+
+
+
+real cc
+]]>
+
+
+
+
+REAL cc
+]]>
+
+
+
+
+RealPart(cc)
+]]>
+
+
+
+
+rel cc
+]]>
+
+
+
+
+rel(cc)
+]]>
+
+
+
+
+R(cc)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_815_A1
+
+0
+
+
+
+QUE_815_A2
+
+100
+
+
+
+QUE_815_A3
+
+0
+
+
+
+QUE_815_A4
+
+0
+
+
+
+QUE_815_A5
+
+0
+
+
+
+QUE_815_A6
+
+0
+
+
+
+QUE_815_A7
+
+0
+
+
+
+QUE_815_A8
+
+0
+
+
+
+
+-
+
+
+ cc. Which of the following commands can get imaginary part of cc ?
+]]>
+
+
+
+
+
+imaginary(cc)
+]]>
+
+
+
+
+imaginary cc
+]]>
+
+
+
+
+image(cc)
+]]>
+
+
+
+
+ImagPart(cc)
+]]>
+
+
+
+
+imag(cc)
+]]>
+
+
+
+
+imag cc
+]]>
+
+
+
+
+im(cc)
+]]>
+
+
+
+
+im cc
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_816_A1
+
+0
+
+
+
+QUE_816_A2
+
+0
+
+
+
+QUE_816_A3
+
+0
+
+
+
+QUE_816_A4
+
+0
+
+
+
+QUE_816_A5
+
+100
+
+
+
+QUE_816_A6
+
+0
+
+
+
+QUE_816_A7
+
+0
+
+
+
+QUE_816_A8
+
+0
+
+
+
+
+-
+
+
+
aa = 5 + 5i;
+ bb = 3 + 3i;
+ cc = 7 + 7i;
+
+
+Which of the following commands can construct a row vector with 3+3i as the first element, 5+5i as the second element, and 7+7i as the last element?
+]]>
+
+
+
+
+
+aa+bb+cc
+]]>
+
+
+
+
+bb+aa+cc
+]]>
+
+
+
+
+aa, bb, cc
+]]>
+
+
+
+
+bb, aa, cc
+]]>
+
+
+
+
+(aa, bb, cc)
+]]>
+
+
+
+
+(bb, aa, cc)
+]]>
+
+
+
+
+[aa, bb, cc]
+]]>
+
+
+
+
+[bb, aa, cc]
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_817_A1
+
+0
+
+
+
+QUE_817_A2
+
+0
+
+
+
+QUE_817_A3
+
+0
+
+
+
+QUE_817_A4
+
+0
+
+
+
+QUE_817_A5
+
+0
+
+
+
+QUE_817_A6
+
+0
+
+
+
+QUE_817_A7
+
+0
+
+
+
+QUE_817_A8
+
+100
+
+
+
+
+-
+
+
+mysig.m.
+
+function [xxx, times] = makesig(ttt)
+times = ttt(1):1/100:ttt(2);
+xxx = real( exp( 2i*pi*times ) );
+
+
+What is the correct way to call this function and make a plot of the signal for t from 0 to 10 in a subplot frame?
+]]>
+
+
+
+
+
+
+yy = mysig(0,10); subplot(2,1,1), plot(times,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = mysig([0,10]); subplot(2,1,1), plot(tt,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = makesig(0,10); plot(tt,yy), subplot(2,1,1)
+
+]]>
+
+
+
+
+
+[yy,tt] = makesig([0,10]); plot(tt,yy), subplot(2,1,1)
+
+]]>
+
+
+
+
+
+plot( 0:10, mysig([0,10]) ), subplot(2,1,1)
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_835_A1
+
+30
+
+
+
+QUE_835_A2
+
+100
+
+
+
+QUE_835_A3
+
+30
+
+
+
+QUE_835_A4
+
+30
+
+
+
+QUE_835_A5
+
+0
+
+
+
+
+-
+
+
+nonzero complex numbers, z1 and z2, have been defined in MATLAB. Which of the following MATLAB statements will NOT give the phase difference between z1 and z2 ?
+]]>
+
+
+
+
+
+
angle(z1) - angle(z2)
+
+]]>
+
+
+
+
+ angle( z1 * conj(z2) )
+
+]]>
+
+
+
+
+ angle(z1 - z2)
+
+]]>
+
+
+
+
+ angle(z1/z2)
+
+]]>
+
+
+
+
+ angle( z1 * z2' )
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_836_A1
+
+0
+
+
+
+QUE_836_A2
+
+0
+
+
+
+QUE_836_A3
+
+100
+
+
+
+QUE_836_A4
+
+0
+
+
+
+QUE_836_A5
+
+0
+
+
+
+
+-
+
+
+ freq = 1000 Hz and you have added the fifth harmonic which is at ff = 5000 Hz. Will there be aliasing in the resulting signal if a sampling frequency of 11025 Hz is used?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_840_A1
+
+0
+
+
+
+QUE_840_A2
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_844_A1
+
+0
+
+
+
+QUE_844_A2
+
+0
+
+
+
+QUE_844_A3
+
+0
+
+
+
+QUE_844_A4
+
+0
+
+
+
+QUE_844_A5
+
+0
+
+
+
+
+-
+
+
+z = -3 + j4, determine its inverse, 1/z. ]]>
+
+
+
+
+
+-3 - j4]]>
+
+
+
+
+1/5]]>
+
+
+
+
+2.214]]>
+
+
+
+
+
+
+
+
+
+-1/3 + j/4]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_845_A1
+
+0
+
+
+
+QUE_845_A2
+
+0
+
+
+
+QUE_845_A3
+
+0
+
+
+
+QUE_845_A4
+
+100
+
+
+
+QUE_845_A5
+
+0
+
+
+
+
+-
+
+
+lowpass filter with a passband cutoff frequency
of 25 Hz, a stopband cutoff frequency of 50 Hz and a filter length
+of L = 101. The filter coefficients are stored in the vector bb.
+
+Given a signal:
+
+xx = sin(2*pi*100*tt) + cos(2*pi*200*tt) + cos(2*pi*300*tt);
+
+where tt=-4000:1/10000:4000;
+
+Which commands could be used to pass only the sine and reject the two cosines by
+using a bandpass filter?
+Note: the BPF would be created from the LPF.
+]]>
+
+
+
+
+
+bb2 = bb.*cos(2*pi*100*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*100*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = conv(hh,xx);
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*100*((0:100)-50)) ;
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*200*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*200*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = conv(hh,xx);
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*200*((0:100)-50)) ;
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*300*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*300*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = conv(hh,xx);
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*300*((0:100)-50)) ;
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_846_A1
+
+0
+
+
+
+QUE_846_A2
+
+0
+
+
+
+QUE_846_A3
+
+100
+
+
+
+QUE_846_A4
+
+0
+
+
+
+QUE_846_A5
+
+0
+
+
+
+QUE_846_A6
+
+50
+
+
+
+QUE_846_A7
+
+0
+
+
+
+QUE_846_A8
+
+0
+
+
+
+QUE_846_A9
+
+50
+
+
+
+
+-
+
+
+ For this problem you need to watch the movie and then determine the spectrum of x[n] of the movie called "Sampling Theorem" which is the THIRD movie in this set (screen shot shown below).
Since x[n] is a discrete-time sinusoid, its spectrum will contain an infinite number of lines in the omega-hat domain. Select the location of two of these omega-hat frequencies (in radians).
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_847_A1
+
+0
+
+
+
+QUE_847_A2
+
+0
+
+
+
+QUE_847_A3
+
+100
+
+
+
+QUE_847_A4
+
+0
+
+
+
+QUE_847_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_848_A1
+
+0
+
+
+
+QUE_848_A2
+
+0
+
+
+
+QUE_848_A3
+
+0
+
+
+
+QUE_848_A4
+
+0
+
+
+
+QUE_848_A5
+
+0
+
+
+
+
+-
+
+
+signal.m. Below is the code:
+
function [xx, times] = synsig(tstart,tend)
+times = tstart:1/100:tend;
+xx = [];
+for ii=1:length(times)
+ xx = [xx, cos(2*pi*times(ii))];
+end;
+
+
+What is the correct way to call this function and make a plot of the sinusoid over the interval from t=1 to t=2 ?
+]]>
+
+
+
+
+
+
+yy = signal(1,2); plot(times,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = signal([1,2]); plot(tt,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = signal(1,2); plot(tt,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = synsig(1,2); plot(tt,yy)
+
+]]>
+
+
+
+
+
+plot( 1:2, synsig(1,2) )
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_850_A1
+
+30
+
+
+
+QUE_850_A2
+
+30
+
+
+
+QUE_850_A3
+
+100
+
+
+
+QUE_850_A4
+
+30
+
+
+
+QUE_850_A5
+
+0
+
+
+
+
+-
+
+
+specgram function in MATLAB. What can you say
+about the signal being represented?
+]]>
+
+
+
+
+
+
+added together.
+]]>
+
+
+
+
+addition of two sinusoids.
+]]>
+
+
+
+
+concatenated, but I cannot tell how long the original signal is.
+]]>
+
+
+
+
+
+
+
+
+
+concatenation of two sinusoids, and
+the total length is approximately 2 seconds.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_853_A1
+
+40
+
+
+
+QUE_853_A2
+
+0
+
+
+
+QUE_853_A3
+
+50
+
+
+
+QUE_853_A4
+
+0
+
+
+
+QUE_853_A5
+
+100
+
+
+
+
+-
+
+
+z = -1 - j, determine its inverse, 1/z.]]>
+
+
+
+
+
+-0.5 + 0.5j]]>
+
+
+
+
+-1 + j]]>
+
+
+
+
+-2.356]]>
+
+
+
+
+0.707*exp(-j0.785)]]>
+
+
+
+
+(-1 - j)/2]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_855_A1
+
+100
+
+
+
+QUE_855_A2
+
+0
+
+
+
+QUE_855_A3
+
+0
+
+
+
+QUE_855_A4
+
+0
+
+
+
+QUE_855_A5
+
+0
+
+
+
+
+-
+
+
+xx is a complex-valued ROW vector of length equal to 100. Which of the following one-liners will compute the sum of the magnitude-squared of the values in xx ?
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_857_A1
+
+0
+
+
+
+QUE_857_A2
+
+100
+
+
+
+QUE_857_A3
+
+0
+
+
+
+QUE_857_A4
+
+0
+
+
+
+QUE_857_A5
+
+50
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_858_A1
+
+0
+
+
+
+QUE_858_A2
+
+0
+
+
+
+QUE_858_A3
+
+0
+
+
+
+QUE_858_A4
+
+0
+
+
+
+QUE_858_A5
+
+0
+
+
+
+
+-
+
+
+z = 0.75 to z = 0.125
How does this affect the impulse response h[n], and frequency response?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_859_A1
+
+25
+
+
+
+QUE_859_A2
+
+100
+
+
+
+QUE_859_A3
+
+25
+
+
+
+QUE_859_A4
+
+0
+
+
+
+
+-
+
+
+
+You have a hard time limit for this on-Line Exercise. After the time expires, you will NOT BE ABLE TO SAVE ANY MORE ANSWERS.
+Whenever you complete an answer, hit the "Save Answer" button, and that will update the timer.
+When you are finished with all the questions, hit the "FINISH" button.
+
+You can have MATLAB running while you answer these questions.
+
+Check the button below to confirm that you understand these instructions.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_860_A1
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_862_A1
+
+50
+
+
+
+QUE_862_A2
+
+20
+
+
+
+QUE_862_A3
+
+100
+
+
+
+QUE_862_A4
+
+20
+
+
+
+QUE_862_A5
+
+0
+
+
+
+
+-
+
+
+ xc=cos(2*pi*4000*t) with the following chirp signal:
+
+x1 = cos(2*pi*500*t + 25*cos(2*pi*10*t))
+
+Which of the following most accurately describes the shape of the spectrogram
+of the modulated signal?
+
NOTE: like the AM Lab Warm-up, the spectrogram will exhibit sinusoidal shapes.
+
+(Assume a sampling rate of 44.1kHz, and a spectrogram display that only shows positive frequencies)
+
+]]>
+
+
+
+
+
+ 500 Hz that varies plus or
+minus 25 Hz, i.e., between 475 Hz and 525 Hz.
+]]>
+
+
+
+
+ 4000 Hz that varies between 3750 Hz and
+ 4250 Hz.
+]]>
+
+
+
+
+ 4500 Hz varying between 4475 and
+ 4525 Hz; the other centered at 3500 Hz varying between 3475 Hz and 3525 Hz.
+]]>
+
+
+
+
+ 5000 Hz varying between 4500 and
+ 5500 Hz; the other centered at 3000 Hz varying between 2500 Hz and 3500 Hz.
+]]>
+
+
+
+
+ 4500 Hz varying between 4250 and
+ 4750 Hz; the other centered at 3500 Hz varying between 3250 Hz and 3750 Hz.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_867_A1
+
+0
+
+
+
+QUE_867_A2
+
+0
+
+
+
+QUE_867_A3
+
+50
+
+
+
+QUE_867_A4
+
+0
+
+
+
+QUE_867_A5
+
+100
+
+
+
+
+-
+
+
+xx in MATLAB, that begins at 200Hz at time t=0, and linearly rises to 1800Hz at time t=2.
The tt vector is defined via: tt = 0:(1/fs):2;
Assume that the sampling frequency (fs) is very high. Which one of the following signals could have been used to generate the linear sweep in instantaneous frequency? ]]>
+
+
+
+
+
+xx = cos(2*pi*((200*tt.^2)+200*tt));
+]]>
+
+
+
+
+xx = cos(2*pi*((400*tt.^2)+200*tt));
+]]>
+
+
+
+
+xx = cos(2*pi*((200*tt.^2)+1600*tt));
+]]>
+
+
+
+
+xx = cos(2*pi*(800*tt)+200);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_868_A1
+
+50
+
+
+
+QUE_868_A2
+
+100
+
+
+
+QUE_868_A3
+
+0
+
+
+
+QUE_868_A4
+
+0
+
+
+
+
+-
+
+
+ office hours
+on (you may have multiple answers)
+]]>
+
+
+
+
+
+ Wednesday morning between 8-12
+]]>
+
+
+
+
+ Wednesday afternoon between 12-6
+]]>
+
+
+
+
+ Wednesday evening between 6-10
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_869_A1
+
+100
+
+
+
+QUE_869_A2
+
+100
+
+
+
+QUE_869_A3
+
+100
+
+
+
+QUE_869_A4
+
+100
+
+
+
+
+-
+
+
+xc=cos(2*pi*5000*t) with the following chirp signal:
x1 = cos(2*pi*1000*t + 50*cos(2*pi*10*t))
Which of the following most accurately describes the shape of the spectrogram of the modulated signal?NOTE: The spectrogram will exhibit sinusoidal shapes.
(Assume a sampling rate of 44.1kHz, and a spectrogram display that only shows positive frequencies) ]]>
+
+
+
+
+
+ 1000 Hz that varies plus or
+minus 50 Hz, i.e., between 950 Hz and 1050 Hz.
+]]>
+
+
+
+
+ 950 Hz varying between
+450 and
+ 1450 Hz; the other centered at 1050 Hz varying between 550 Hz and 1550 Hz.
+]]>
+
+
+
+
+ 4000 Hz varying between 3500 and
+ 4500 Hz; the other centered at 6000 Hz varying between 5500 Hz and 6500 Hz.
+]]>
+
+
+
+
+ 5000 Hz that varies between 4500 Hz and
+ 5500 Hz.
+]]>
+
+
+
+
+ 4000 Hz varying between 3950 and
+ 4050 Hz; the other centered at 6000 Hz varying between 5950 Hz and 6050 Hz.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_872_A1
+
+0
+
+
+
+QUE_872_A2
+
+0
+
+
+
+QUE_872_A3
+
+100
+
+
+
+QUE_872_A4
+
+0
+
+
+
+QUE_872_A5
+
+50
+
+
+
+
+-
+
+
+shaft. The matrix encodes a digital image of the Kessler Campanile.
+
Which of the following commands will properly display the image of the shaft? Pick ONE.
+]]>
+
+
+
+
+
+ plot(shaft)
+]]>
+
+
+
+
+ figure(TheShaft)
+]]>
+
+
+
+
+ show_img('The Shaft')
+]]>
+
+
+
+
+ colormap(shaft)
+]]>
+
+
+
+
+ show_img(Shaft)
+]]>
+
+
+
+
+ print(shaft)
+]]>
+
+
+
+
+display(shaft)
+]]>
+
+
+
+
+show_img(shaft)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_874_A1
+
+0
+
+
+
+QUE_874_A2
+
+0
+
+
+
+QUE_874_A3
+
+20
+
+
+
+QUE_874_A4
+
+0
+
+
+
+QUE_874_A5
+
+60
+
+
+
+QUE_874_A6
+
+0
+
+
+
+QUE_874_A7
+
+0
+
+
+
+QUE_874_A8
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_878_A1
+
+0
+
+
+
+QUE_878_A2
+
+0
+
+
+
+QUE_878_A3
+
+0
+
+
+
+QUE_878_A4
+
+0
+
+
+
+QUE_878_A5
+
+0
+
+
+
+QUE_878_A6
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_879_A1
+
+20
+
+
+
+QUE_879_A2
+
+0
+
+
+
+QUE_879_A3
+
+50
+
+
+
+QUE_879_A4
+
+100
+
+
+
+QUE_879_A5
+
+50
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_883_A1
+
+0
+
+
+
+QUE_883_A2
+
+0
+
+
+
+QUE_883_A3
+
+0
+
+
+
+QUE_883_A4
+
+0
+
+
+
+QUE_883_A5
+
+0
+
+
+
+
+-
+
+
+φ) for the following sinusoid where
x(t) = cos(ωt + φ)
]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_885_A1
+
+0
+
+
+
+QUE_885_A2
+
+0
+
+
+
+QUE_885_A3
+
+0
+
+
+
+QUE_885_A4
+
+100
+
+
+
+QUE_885_A5
+
+0
+
+
+
+QUE_885_A6
+
+0
+
+
+
+
+-
+
+
+ mydir to the path?
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_886_A1
+
+20
+
+
+
+QUE_886_A2
+
+20
+
+
+
+QUE_886_A3
+
+20
+
+
+
+QUE_886_A4
+
+100
+
+
+
+QUE_886_A5
+
+0
+
+
+
+
+-
+
+
+
+z1 = 1 + 0j;
+z2 = 1 + 1j;
+z3 = 3 + 2j;
+z4 = -5 + 7.9j;
+z5 = 0.3-8j;
+
+Which statement will generate a plot in the complex plane
+showing all five numbers as vectors emanating from the origin ?
+]]>
+
+
+
+
+
+ zcat( z1,z2,z3,z4,z5 );
+]]>
+
+
+
+
+ zvect( z1,z2,z3,z4,z5 );
+]]>
+
+
+
+
+ plot( [z1,z2,z3,z4,z5] );
+]]>
+
+
+
+
+ zcat( [z1,z2,z3,z4,z5] );
+]]>
+
+
+
+
+ zcat( {z1,z2,z3,z4,z5} );
+]]>
+
+
+
+
+ zvect( [z1,z2,z3,z4,z5] );
+]]>
+
+
+
+
+ plot( z1,z2,z3,z4,z5 );
+]]>
+
+
+
+
+ zvect( (z1,z2,z3,z4,z5) );
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_888_A1
+
+0
+
+
+
+QUE_888_A2
+
+30
+
+
+
+QUE_888_A3
+
+0
+
+
+
+QUE_888_A4
+
+0
+
+
+
+QUE_888_A5
+
+0
+
+
+
+QUE_888_A6
+
+100
+
+
+
+QUE_888_A7
+
+0
+
+
+
+QUE_888_A8
+
+30
+
+
+
+
+-
+
+
+ For this problem you need to watch the movie and then determine the spectrum of x[n] of the movie called "Folding" which is the SECOND movie in this set (screen shot shown below).
Since x[n] is a discrete-time sinusoid, its spectrum will contain an infinite number of lines in the omega-hat domain. Select the location of two of these omega-hat frequencies (in radians).
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_890_A1
+
+0
+
+
+
+QUE_890_A2
+
+0
+
+
+
+QUE_890_A3
+
+0
+
+
+
+QUE_890_A4
+
+0
+
+
+
+QUE_890_A5
+
+100
+
+
+
+
+-
+
+
+B(z) = 1 + b1z-1 + b2z-2 will always have two roots.
+
+Suppose that the two roots from a second-degree polynomial B(z) are complex and they are also complex conjugates of one another. What can be said about the values of the polynomial coefficients b1 and b2 ?
+
HINT: Try help roots in MATLAB; generate numerical examples to test your answer.
+]]>
+
+
+
+
+
+b1 and b2 will both be real and positive.
+]]>
+
+
+
+
+
+
+
+
+
+b1 and b2 will be complex conjugate pairs.
+]]>
+
+
+
+
+b2 will be positive
+]]>
+
+
+
+
+b2 will be negative
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_891_A1
+
+70
+
+
+
+QUE_891_A2
+
+0
+
+
+
+QUE_891_A3
+
+0
+
+
+
+QUE_891_A4
+
+100
+
+
+
+QUE_891_A5
+
+40
+
+
+
+
+-
+
+
+signal.m. Below is the code:
+
function [xx, times] = synsig(tend)
+times = tend(1):1/100:tend(2);
+xx = [];
+for ii=1:length(times)
+ xx = [xx, cos(2*pi*times(ii))];
+end;
+
+
+What is the correct way to call this function and make a plot of the sinusoid over the interval from t=1 to t=2 ?
+]]>
+
+
+
+
+
+
+yy = signal(1,2); plot(times,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = signal([1,2]); plot(tt,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = signal(1,2); plot(tt,yy)
+
+]]>
+
+
+
+
+
+[yy,tt] = synsig([1,2]); plot(tt,yy)
+
+]]>
+
+
+
+
+
+plot( 1:2, synsig(1,2) )
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_896_A1
+
+30
+
+
+
+QUE_896_A2
+
+100
+
+
+
+QUE_896_A3
+
+30
+
+
+
+QUE_896_A4
+
+30
+
+
+
+QUE_896_A5
+
+0
+
+
+
+
+-
+
+
+
+fs = 11025;
+tt = 0:1/fs:3;
+xx = exp(tt);
Which of the following MATLAB commands will produce a plot of xx versus tt (where tt is in seconds)? ]]>
+
+
+
+
+
+plot(xx,tt)
+]]>
+
+
+
+
+plot(xx)
+]]>
+
+
+
+
+plot(tt,xx)
+]]>
+
+
+
+
+plot(tt)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_898_A1
+
+0
+
+
+
+QUE_898_A2
+
+50
+
+
+
+QUE_898_A3
+
+100
+
+
+
+QUE_898_A4
+
+0
+
+
+
+
+-
+
+
+
+M = 50; nn = 0:M;
+alpha = 2;
+GW = exp(-0.5*( ((alpha*(nn-M/2))/(M/2)).^2 )); %-- Gaussian window
+wc = 0.3*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2)); %-- sinc function
+sincwc(M/2 + 1) = wc/pi; %-- fix divide by zero
+bb = sincwc.*GW; %-- Filter Coefficients
+
+
+Choose all correct answers from the following choices, which will evaluate the frequency response of the filter at frequency 0.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_903_A1
+
+0
+
+
+
+QUE_903_A2
+
+-25
+
+
+
+QUE_903_A3
+
+-25
+
+
+
+QUE_903_A4
+
+100
+
+
+
+QUE_903_A5
+
+-25
+
+
+
+QUE_903_A6
+
+-25
+
+
+
+
+-
+
+
+
+M = 50; nn = 0:M;
+alpha = 2;
+GW = exp(-0.5*( ((alpha*(nn-M/2))/(M/2)).^2 )); %-- Gaussian window
+wc = 0.3*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2)); %-- sinc function
+sincwc(M/2 + 1) = wc/pi; %-- fix divide by zero
+bb = sincwc.*GW; %-- Filter Coefficients
+
+
+Choose all correct answers from the following choices, which will evaluate the frequency response of the filter at frequency 'pi' .
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_908_A1
+
+-25
+
+
+
+QUE_908_A2
+
+-25
+
+
+
+QUE_908_A3
+
+-25
+
+
+
+QUE_908_A4
+
+-25
+
+
+
+QUE_908_A5
+
+-25
+
+
+
+QUE_908_A6
+
+100
+
+
+
+
+-
+
+
+specgram function in MATLAB. What can you say
+about the signal being represented?
+]]>
+
+
+
+
+
+
+added together.
+]]>
+
+
+
+
+added together.
+]]>
+
+
+
+
+added, but I cannot tell how many or how long the original signal is.
+]]>
+
+
+
+
+
+
+
+
+
+concatenating three sinusoids, and
+the total length is 2 seconds.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_909_A1
+
+0
+
+
+
+QUE_909_A2
+
+100
+
+
+
+QUE_909_A3
+
+40
+
+
+
+QUE_909_A4
+
+0
+
+
+
+QUE_909_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_910_A1
+
+0
+
+
+
+QUE_910_A2
+
+0
+
+
+
+QUE_910_A3
+
+0
+
+
+
+QUE_910_A4
+
+0
+
+
+
+QUE_910_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+ dbstop
+]]>
+
+
+
+
+ dbend
+]]>
+
+
+
+
+ dbstatus
+]]>
+
+
+
+
+ dbstart
+]]>
+
+
+
+
+ dbtype
+]]>
+
+
+
+
+ dbquit
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_911_A1
+
+0
+
+
+
+QUE_911_A2
+
+0
+
+
+
+QUE_911_A3
+
+0
+
+
+
+QUE_911_A4
+
+0
+
+
+
+QUE_911_A5
+
+0
+
+
+
+QUE_911_A6
+
+100
+
+
+
+
+-
+
+
+conv2(bb,xx), where the coefficients are obtained using the Matlab command:
+
+ bb = ones(1,21)/21;
+
+
+Mark all the choices (given below) that describe the output image:
+]]>
+
+
+
+
+
+
+All pixel values will be modified.
+]]>
+
+
+
+
+vertical edges of the white box will be blurred.
+]]>
+
+
+
+
+horizontal edges of the white box will be blurred.
+]]>
+
+
+
+
+horizontal and vertical edges of the white box will be blurred
+]]>
+
+
+
+
+horizontal and vertical edges of the white box will have high pixel values compared to the rest of the image.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_912_A1
+
+-25
+
+
+
+QUE_912_A2
+
+100
+
+
+
+QUE_912_A3
+
+-25
+
+
+
+QUE_912_A4
+
+-25
+
+
+
+QUE_912_A5
+
+-25
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_913_A1
+
+0
+
+
+
+QUE_913_A2
+
+0
+
+
+
+QUE_913_A3
+
+0
+
+
+
+QUE_913_A4
+
+0
+
+
+
+QUE_913_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_916_A1
+
+0
+
+
+
+QUE_916_A2
+
+0
+
+
+
+QUE_916_A3
+
+0
+
+
+
+QUE_916_A4
+
+0
+
+
+
+QUE_916_A5
+
+0
+
+
+
+QUE_916_A6
+
+100
+
+
+
+QUE_916_A7
+
+0
+
+
+
+QUE_916_A8
+
+0
+
+
+
+
+-
+
+
+specgram function in MATLAB. What can you say
+about the signal being represented?
+]]>
+
+
+
+
+
+
+added together.
+]]>
+
+
+
+
+addition of two sinusoids.
+]]>
+
+
+
+
+added, but it is impossible to tell how long the original signal is.
+]]>
+
+
+
+
+
+
+
+
+
+concatenation of two sinusoids.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_917_A1
+
+100
+
+
+
+QUE_917_A2
+
+40
+
+
+
+QUE_917_A3
+
+50
+
+
+
+QUE_917_A4
+
+0
+
+
+
+QUE_917_A5
+
+0
+
+
+
+
+-
+
+
+
+You have a DEADLINE for this on-Line Exercise.
+
+
After the time expires, you will NOT BE ABLE TO SAVE ANY MORE ANSWERS.
+Hit the "Save Answer" button often.
+
+
+When you are finished with all the questions, hit the "FINISH" button.
+
+
Check the button below to confirm that you understand these instructions.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_918_A1
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_920_A1
+
+0
+
+
+
+QUE_920_A2
+
+0
+
+
+
+QUE_920_A3
+
+100
+
+
+
+QUE_920_A4
+
+0
+
+
+
+
+-
+
+
+(Answer given in integer format)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_922_A1
+
+100
+
+
+
+QUE_922_A2
+
+0
+
+
+
+QUE_922_A3
+
+0
+
+
+
+QUE_922_A4
+
+0
+
+
+
+QUE_922_A5
+
+0
+
+
+
+QUE_922_A6
+
+0
+
+
+
+QUE_922_A7
+
+0
+
+
+
+QUE_922_A8
+
+0
+
+
+
+
+-
+
+
+ BANDPASS IIR filter, pick the correct (or BEST) one:
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_923_A1
+
+0
+
+
+
+QUE_923_A2
+
+0
+
+
+
+QUE_923_A3
+
+0
+
+
+
+QUE_923_A4
+
+0
+
+
+
+QUE_923_A5
+
+100
+
+
+
+
+-
+
+
+conv2(bb,xx), where the coefficients are obtained using the Matlab command:
+
+ bb = [1 -1];
+
+
+Mark all the choices (given below) that describe the output image:
+]]>
+
+
+
+
+
+
+All pixel values will be modified.
+]]>
+
+
+
+
+vertical edges of the white box will be blurred.
+]]>
+
+
+
+
+horizontal edges of the white box will be blurred.
+]]>
+
+
+
+
+vertical edges of the white box can be detected after thresholding.
+]]>
+
+
+
+
+horizontal edges of the white box can be detected after thresholding.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_926_A1
+
+-25
+
+
+
+QUE_926_A2
+
+-25
+
+
+
+QUE_926_A3
+
+-25
+
+
+
+QUE_926_A4
+
+100
+
+
+
+QUE_926_A5
+
+-25
+
+
+
+
+-
+
+
+magnitude and phase of a frequency response vector HH?
+]]>
+
+
+
+
+
+real(HH), imag(HH)
+]]>
+
+
+
+
+abs(HH), angle(HH)
+]]>
+
+
+
+
+abs(HH), phase(HH)
+]]>
+
+
+
+
+mag(HH), angle(HH)
+]]>
+
+
+
+
+mag(HH), phase(HH)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_929_A1
+
+0
+
+
+
+QUE_929_A2
+
+100
+
+
+
+QUE_929_A3
+
+0
+
+
+
+QUE_929_A4
+
+0
+
+
+
+QUE_929_A5
+
+0
+
+
+
+
+-
+
+
+conv2(bb,xx), where the coefficients are obtained using the Matlab command:
+
+ bb = ones(21,1)/21;
+
+
+Mark all the choices (given below) that describe the output image:
+]]>
+
+
+
+
+
+
+All pixel values will be modified.
+]]>
+
+
+
+
+vertical edges of the white box will be blurred.
+]]>
+
+
+
+
+horizontal edges of the white box will be blurred.
+]]>
+
+
+
+
+horizontal and vertical edges of the white box will be blurred
+]]>
+
+
+
+
+horizontal and vertical edges of the white box will have high pixel values compared to the rest of the image.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_934_A1
+
+-25
+
+
+
+QUE_934_A2
+
+-25
+
+
+
+QUE_934_A3
+
+100
+
+
+
+QUE_934_A4
+
+-25
+
+
+
+QUE_934_A5
+
+-25
+
+
+
+
+-
+
+
+specgram function in MATLAB. What can you say
+about the signal being represented?
+]]>
+
+
+
+
+
+
+added together.
+]]>
+
+
+
+
+added together.
+]]>
+
+
+
+
+concatenated, but it is impossible to tell how long the original signal is.
+]]>
+
+
+
+
+
+
+
+
+
+concatenation of three sinusoids, and
+the total length is approximately 2.5 seconds.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_935_A1
+
+0
+
+
+
+QUE_935_A2
+
+0
+
+
+
+QUE_935_A3
+
+40
+
+
+
+QUE_935_A4
+
+0
+
+
+
+QUE_935_A5
+
+100
+
+
+
+
+-
+
+
+conv2(bb,xx), where the coefficients are obtained using the Matlab command:
+
+ bb = [1; -1];
+
+
+Mark all the choices (given below) that describe the output image:
+]]>
+
+
+
+
+
+
+All pixel values will be modified.
+]]>
+
+
+
+
+vertical edges of the white box will be blurred.
+]]>
+
+
+
+
+horizontal edges of the white box will be blurred.
+]]>
+
+
+
+
+vertical edges of the white box can be detected after thresholding.
+]]>
+
+
+
+
+horizontal edges of the white box can be detected after thresholding.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_938_A1
+
+-25
+
+
+
+QUE_938_A2
+
+-25
+
+
+
+QUE_938_A3
+
+-25
+
+
+
+QUE_938_A4
+
+-25
+
+
+
+QUE_938_A5
+
+100
+
+
+
+
+-
+
+
+complex vector zz has been defined in MATLAB. Which one of the following MATLAB statements will NOT give the magnitude squared of each of the elements of zz ?
+]]>
+
+
+
+
+
+abs(zz).^2]]>
+
+
+
+
+ zz .* conj(zz)
+]]>
+
+
+
+
+real(zz).^2 + imag(zz).^2
+]]>
+
+
+
+
+ zz .* zz ]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_945_A1
+
+0
+
+
+
+QUE_945_A2
+
+0
+
+
+
+QUE_945_A3
+
+0
+
+
+
+QUE_945_A4
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_946_A1
+
+100
+
+
+
+
+-
+
+
+ mm,
+the message bits in string row vector pp,
+and termination bits in string row vector term.
+
+
Each string row vector is an array of characters ('0' or '1') in MATLAB, e.g., '0010110101110'.
+
+
Which of the following is the correct way
+to form the bit string sent out from modem?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_947_A1
+
+0
+
+
+
+QUE_947_A2
+
+0
+
+
+
+QUE_947_A3
+
+0
+
+
+
+QUE_947_A4
+
+0
+
+
+
+QUE_947_A5
+
+0
+
+
+
+QUE_947_A6
+
+0
+
+
+
+QUE_947_A7
+
+100
+
+
+
+QUE_947_A8
+
+0
+
+
+
+
+-
+
+
+xx, increasing the length of the averager to be 2*L will:
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_948_A1
+
+0
+
+
+
+QUE_948_A2
+
+0
+
+
+
+QUE_948_A3
+
+0
+
+
+
+QUE_948_A4
+
+0
+
+
+
+QUE_948_A5
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_949_A1
+
+0
+
+
+
+QUE_949_A2
+
+0
+
+
+
+QUE_949_A3
+
+0
+
+
+
+QUE_949_A4
+
+0
+
+
+
+QUE_949_A5
+
+0
+
+
+
+
+-
+
+
+
+M = 50; nn = 0:M;
+alpha = 2;
+GW = exp(-0.5*( ((alpha*(nn-M/2))/(M/2)).^2 )); %-- Gaussian window
+wc = 0.3*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2)); %-- sinc function
+sincwc(M/2 + 1) = wc/pi; %-- fix divide by zero
+bb = sincwc.*GW; %-- Filter Coefficients
+
+
+Choose all correct answers from the following choices, which will evaluate the frequency response of the filter at frequency 0.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_951_A1
+
+-50
+
+
+
+QUE_951_A2
+
+-50
+
+
+
+QUE_951_A3
+
+100
+
+
+
+QUE_951_A4
+
+-50
+
+
+
+
+-
+
+
+
+M = 50; nn = 0:M;
+alpha = 2;
+GW = exp(-0.5*( ((alpha*(nn-M/2))/(M/2)).^2 )); %-- Gaussian window
+wc = 0.3*pi;
+sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2)); %-- sinc function
+sincwc(M/2 + 1) = wc/pi; %-- fix divide by zero
+bb = sincwc.*GW; %-- Filter Coefficients
+
+
+Choose all correct answers from the following choices, which will evaluate the frequency response of the filter at frequency "pi".
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_952_A1
+
+-50
+
+
+
+QUE_952_A2
+
+-50
+
+
+
+QUE_952_A3
+
+-50
+
+
+
+QUE_952_A4
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_954_A1
+
+0
+
+
+
+QUE_954_A2
+
+0
+
+
+
+QUE_954_A3
+
+0
+
+
+
+QUE_954_A4
+
+0
+
+
+
+QUE_954_A5
+
+0
+
+
+
+
+-
+
+
+ of 25 Hz, a stopband cutoff frequency of 50 Hz and a filter length
+of L = 101. The filter coefficients are stored in the vector bb.
+
+Given a signal:
+
+xx = cos(2*pi*100*tt) + cos(2*pi*200*tt) + sin(2*pi*300*tt);
+
+where tt=-4000:1/10000:4000;
+
+Which commands could be used to pass only the sine and reject the two cosines by
+using a bandpass filter?
+Note: the BPF would be created from the LPF.
+]]>
+
+
+
+
+
+bb2 = bb.*cos(2*pi*300*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*300*((0:100)-50)) ;
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+bb2 = conv(bb,cos(2*pi*300*((0:100)-50))) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = hh.*xx;
+]]>
+
+
+
+
+bb2 = bb.*cos(2*pi*300*((0:100)-50)) ;
+hh = freqz(bb2,1,-pi:.01*pi:pi);
+yy = conv(hh,xx);
+]]>
+
+
+
+
+bb2 = firfilt(bb,cos(2*pi*300*((0:100)-50)) );
+yy = conv(bb2,xx)
+]]>
+
+
+
+
+bb2 = firfilt(bb,cos(2*pi*300*((0:100)-50)) );
+yy = bb2.*xx
+]]>
+
+
+
+
+hh = freqz(bb,1,-pi:.01*pi:pi);
+yy = xx.*hh.*cos(2*pi*300*((0:100)-50))
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_956_A1
+
+0
+
+
+
+QUE_956_A2
+
+100
+
+
+
+QUE_956_A3
+
+0
+
+
+
+QUE_956_A4
+
+0
+
+
+
+QUE_956_A5
+
+0
+
+
+
+QUE_956_A6
+
+0
+
+
+
+QUE_956_A7
+
+0
+
+
+
+
+-
+
+
+2 kHz tone in Matlab and listen to it. The following lines of code have already been written:
+
nn = 0:10000;
+xx = 99*sin(2*pi*0.25*nn);
+Which one of the following will correctly play the sound?
+]]>
+
+
+
+
+
+ soundsc(xx, 2000)
+]]>
+
+
+
+
+ soundsc(xx, 8000)
+]]>
+
+
+
+
+ soundsc(xx, 10000)
+]]>
+
+
+
+
+ soundsc(xx, 11025)
+]]>
+
+
+
+
+ soundsc(xx, 2*pi)
+]]>
+
+
+
+
+ soundsc(xx, nn)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_959_A1
+
+0
+
+
+
+QUE_959_A2
+
+100
+
+
+
+QUE_959_A3
+
+0
+
+
+
+QUE_959_A4
+
+0
+
+
+
+QUE_959_A5
+
+0
+
+
+
+QUE_959_A6
+
+0
+
+
+
+
+-
+
+
+ office hours
+on (you may have multiple answers)
+]]>
+
+
+
+
+
+ Friday morning between 8-12
+]]>
+
+
+
+
+ Friday afternoon between 12-6
+]]>
+
+
+
+
+ Friday evening between 6-10
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_960_A1
+
+100
+
+
+
+QUE_960_A2
+
+100
+
+
+
+QUE_960_A3
+
+100
+
+
+
+QUE_960_A4
+
+100
+
+
+
+
+-
+
+
+Nulling filter?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_961_A1
+
+0
+
+
+
+QUE_961_A2
+
+100
+
+
+
+QUE_961_A3
+
+0
+
+
+
+QUE_961_A4
+
+0
+
+
+
+QUE_961_A5
+
+0
+
+
+
+QUE_961_A6
+
+0
+
+
+
+QUE_961_A7
+
+0
+
+
+
+QUE_961_A8
+
+0
+
+
+
+
+-
+
+
+SS contains?
+
+SS = struct('type',['A';'B'],'color','red','x',[3 4])
+
+]]>
+
+
+
+
+
+ size(SS)
+]]>
+
+
+
+
+ fieldnames(SS)
+]]>
+
+
+
+
+ listfields(SS)
+]]>
+
+
+
+
+ getfield(SS)
+]]>
+
+
+
+
+ SS.fieldnames
+]]>
+
+
+
+
+ SS.getfield
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_963_A1
+
+0
+
+
+
+QUE_963_A2
+
+100
+
+
+
+QUE_963_A3
+
+0
+
+
+
+QUE_963_A4
+
+0
+
+
+
+QUE_963_A5
+
+0
+
+
+
+QUE_963_A6
+
+0
+
+
+
+
+-
+
+
+not work?
+]]>
+
+
+
+
+
+[1; 2; 3] * [4 5 6]
+]]>
+
+
+
+
+[1 2 3] .* 5
+]]>
+
+
+
+
+cos([1 2 3])
+]]>
+
+
+
+
+[1 2 3] .* [4; 5; 6]
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_966_A1
+
+0
+
+
+
+QUE_966_A2
+
+0
+
+
+
+QUE_966_A3
+
+0
+
+
+
+QUE_966_A4
+
+100
+
+
+
+
+-
+
+
+fc = 900 Hz and delf = 10 Hz, the beatcon tool will create a signal containing two frequency components (f1, f2) which exhibit a beat note behavior. Which is a correct description of the signal?
+
+]]>
+
+
+
+
+
+f1 = 900 Hz, f2 = 910 Hz
+
+]]>
+
+
+
+
+f1 = 910 Hz, f2 = 920 Hz
+
+]]>
+
+
+
+
+f1 = 895 Hz, f2 = 905 Hz
+
+]]>
+
+
+
+
+f1 = 890 Hz, f2 = 910 Hz
+
+]]>
+
+
+
+
+f1 = 900 Hz, f2 = 920 Hz
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_968_A1
+
+0
+
+
+
+QUE_968_A2
+
+0
+
+
+
+QUE_968_A3
+
+0
+
+
+
+QUE_968_A4
+
+100
+
+
+
+QUE_968_A5
+
+0
+
+
+
+
+-
+
+
+ office hours
+on (you may have multiple answers)
+]]>
+
+
+
+
+
+ Thursday morning between 8-12
+]]>
+
+
+
+
+ Thursday afternoon between 12-6
+]]>
+
+
+
+
+ Thursday evening between 6-10
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_969_A1
+
+100
+
+
+
+QUE_969_A2
+
+100
+
+
+
+QUE_969_A3
+
+100
+
+
+
+QUE_969_A4
+
+100
+
+
+
+
+-
+
+
+phi) for the following sinusoid where
+
xx = cos(w*t + phi);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_971_A1
+
+0
+
+
+
+QUE_971_A2
+
+0
+
+
+
+QUE_971_A3
+
+100
+
+
+
+QUE_971_A4
+
+0
+
+
+
+QUE_971_A5
+
+0
+
+
+
+QUE_971_A6
+
+0
+
+
+
+
+-
+
+
+interp1() to reconstruct an image. If you are given the MATLAB statement:
w = interp1(xx,yy,zz),
+what do xx, yy, and zz represent?
+]]>
+
+
+
+
+
+ xx is the vector representing the function values that we want to interpolate.
+
yy contains the points at which the function xx is given (independent variable).
+
zz is a vector containing the points at which we want to evaluate and interpolate the values of the function xx at.
+]]>
+
+
+
+
+ xx contains the points at which the function yy is given (independent variable).
+
yy is the vector representing the function values that we want to interpolate.
+
zz is a vector containing the points at which we want to evaluate and interpolate the values of the function yy at.
+]]>
+
+
+
+
+ xx is the vector representing the function values that we want to interpolate.
+
zz is a vector containing the points at which we want to evaluate and interpolate the values of the function xx at.
+
yy is just a dummy vector.
+]]>
+
+
+
+
+ zz is the vector representing the function values that we want to interpolate.
+
xx is a vector containing the points at which we want to evaluate and interpolate the values of the function zz at.
+
yy contains the points at which the function zz is given (independent variable).
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_973_A1
+
+0
+
+
+
+QUE_973_A2
+
+100
+
+
+
+QUE_973_A3
+
+0
+
+
+
+QUE_973_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_974_A1
+
+20
+
+
+
+QUE_974_A2
+
+50
+
+
+
+QUE_974_A3
+
+100
+
+
+
+QUE_974_A4
+
+0
+
+
+
+QUE_974_A5
+
+20
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_976_A1
+
+0
+
+
+
+QUE_976_A2
+
+0
+
+
+
+QUE_976_A3
+
+0
+
+
+
+
+-
+
+
+H(z) shown below:
+{Equation:eqn=
+
+
+
+
+
+w = 0.25pi .
+]]>
+
+
+
+
+ w = 0.25*pi .
+]]>
+
+
+
+
+w = 1 .
+]]>
+
+
+
+
+ w = .75pi .
+]]>
+
+
+
+
+w = 0.25pi .
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_980_A1
+
+100
+
+
+
+QUE_980_A2
+
+0
+
+
+
+QUE_980_A3
+
+0
+
+
+
+QUE_980_A4
+
+0
+
+
+
+QUE_980_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_981_A1
+
+100
+
+
+
+QUE_981_A2
+
+0
+
+
+
+
+-
+
+
+cos(2π(4200)t) is sampled with a sampling frequency of 8000 Hz,which of the following signals would yield a sampled signal of the same frequency if also sampled at 8000 Hz? ]]>
+
+
+
+
+
+cos(2π(4200)t + π/2)]]>
+
+
+
+
+cos(2π(3800)t)]]>
+
+
+
+
+cos(2π(11800)t)]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_982_A1
+
+25
+
+
+
+QUE_982_A2
+
+25
+
+
+
+QUE_982_A3
+
+25
+
+
+
+QUE_982_A4
+
+100
+
+
+
+QUE_982_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_983_A1
+
+0
+
+
+
+QUE_983_A2
+
+100
+
+
+
+QUE_983_A3
+
+30
+
+
+
+QUE_983_A4
+
+30
+
+
+
+
+-
+
+
+H(z) shown below:
+{Equation:eqn=
+
+
+
+
+
+w = 0.75pi .
+]]>
+
+
+
+
+ w = 0.75*pi .
+]]>
+
+
+
+
+w = 1 .
+]]>
+
+
+
+
+ w = 0.25pi .
+]]>
+
+
+
+
+w = 0.75pi .
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_984_A1
+
+100
+
+
+
+QUE_984_A2
+
+0
+
+
+
+QUE_984_A3
+
+0
+
+
+
+QUE_984_A4
+
+0
+
+
+
+QUE_984_A5
+
+0
+
+
+
+
+-
+
+
+fcos.m
function PreLab10 = mycos(t)
+
+PreLab10 = cos(pi*t);
+
Which command will correctly calculate the integral of one period of the cosine?
]]>
+
+
+
+
+
+yy = quad8('fcos',0,2);
+]]>
+
+
+
+
+yy = quad8('mycos',0,2);
+]]>
+
+
+
+
+yy = quad8('PreLab10',0,2);
+]]>
+
+
+
+
+yy = quad8('fcos',[0 2]);
+]]>
+
+
+
+
+yy = quad8('mycos',[0 2]);
+]]>
+
+
+
+
+yy = quad8('PreLab10',[0 2]);
+]]>
+
+
+
+
+yy = quad8(fcos,0,2);
+]]>
+
+
+
+
+yy = quad8(mycos,0,2);
+]]>
+
+
+
+
+yy = quad8(PreLab10,0,2);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_985_A1
+
+100
+
+
+
+QUE_985_A2
+
+50
+
+
+
+QUE_985_A3
+
+33
+
+
+
+QUE_985_A4
+
+50
+
+
+
+QUE_985_A5
+
+33
+
+
+
+QUE_985_A6
+
+0
+
+
+
+QUE_985_A7
+
+50
+
+
+
+QUE_985_A8
+
+0
+
+
+
+QUE_985_A9
+
+0
+
+
+
+
+-
+
+
+xx is a vector of length 15. yy is a vector of length 5.
What is the correct way to add yy to the LAST 5 points of xx?
The result (called zz) should be 15 points long.
Assume all vectors are row vectors.
Do not assume that zz has been initialized.
+]]>
+
+
+
+
+
+zz = xx(11:15) + yy;
+]]>
+
+
+
+
+zz(11:15) = xx + yy;
+]]>
+
+
+
+
+zz = xx + [yy,zeros(1,10)];
+]]>
+
+
+
+
+zz = xx + [zeros(1,10),yy];
+]]>
+
+
+
+
+zz = xx + yy;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_986_A1
+
+0
+
+
+
+QUE_986_A2
+
+0
+
+
+
+QUE_986_A3
+
+0
+
+
+
+QUE_986_A4
+
+100
+
+
+
+QUE_986_A5
+
+0
+
+
+
+
+-
+
+
+ pre,
+the message bits in string row vector mm,
+and termination bits in string row vector tt.
+
+
Each string row vector is an array of characters ('0' or '1') in MATLAB, e.g., '0010110101110'.
+
+
Which of the following is the correct way
+to form the bit string sent out from modem?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_989_A1
+
+0
+
+
+
+QUE_989_A2
+
+100
+
+
+
+QUE_989_A3
+
+0
+
+
+
+QUE_989_A4
+
+0
+
+
+
+QUE_989_A5
+
+0
+
+
+
+QUE_989_A6
+
+0
+
+
+
+QUE_989_A7
+
+0
+
+
+
+QUE_989_A8
+
+0
+
+
+
+
+-
+
+
+z = -3 -j4 , determine its angle in radians. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_990_A1
+
+0
+
+
+
+QUE_990_A2
+
+0
+
+
+
+QUE_990_A3
+
+0
+
+
+
+QUE_990_A4
+
+100
+
+
+
+QUE_990_A5
+
+0
+
+
+
+
+-
+
+
+ZEROS at radius=1.0 and at angles of +60 and -60 degrees, what features are easy to see in the frequency response (versus omega_hat)?
+
+NOTE: you only need to place one of these zeros, because PeZ will automatically include a companion zero at the conjugate location.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_991_A1
+
+25
+
+
+
+QUE_991_A2
+
+100
+
+
+
+QUE_991_A3
+
+25
+
+
+
+QUE_991_A4
+
+0
+
+
+
+QUE_991_A5
+
+50
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_995_A1
+
+0
+
+
+
+QUE_995_A2
+
+0
+
+
+
+QUE_995_A3
+
+0
+
+
+
+QUE_995_A4
+
+0
+
+
+
+QUE_995_A5
+
+0
+
+
+
+
+-
+
+
+
+f(t) =
+
t, when (0<= t <2)
+
t^2 when (3<= t <=5)
+
4*t when (6<= t <=10)
+
zero, otherwise
+
+
+which of the following codes computes correctly the integral of the function defined above over the period [2, 5] using quad8() and inline()?
+]]>
+
+
+
+
+
+quad8(inline('t.*(t>=0 & t<2 )+ t.^2.*(t>=3 & t<=5) + 4*t.*(t>=6 & t<=10)','t') , [2,5])
+]]>
+
+
+
+
+quad8(inline('t*(t>=0 & t<2 )+ t^2*(t>=3 & t<=5) + 4*t*(t>=6 & t<=10)','t') , 2,5)
+]]>
+
+
+
+
+quad8(inline('t*(t>=0 & t<2 )+ t^2*(t>=3 & t<=5) + 4*t*(t>=6 & t<=10)') , 2,5)
+]]>
+
+
+
+
+quad8(inline('t.*(t>=0 & t<2 )+ t.^2.*(t>=3 & t<=5) + 4*t.*(t>=6 & t<=10)') , 2,5)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_996_A1
+
+0
+
+
+
+QUE_996_A2
+
+0
+
+
+
+QUE_996_A3
+
+0
+
+
+
+QUE_996_A4
+
+100
+
+
+
+
+-
+
+
+H(z) shown below:
+{Equation:eqn=
+
+
+
+
+
+w = 0.6pi .
+]]>
+
+
+
+
+ w = 0.6*pi .
+]]>
+
+
+
+
+w = 1 .
+]]>
+
+
+
+
+ w = 0.1pi .
+]]>
+
+
+
+
+w = 0.6pi .
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_998_A1
+
+100
+
+
+
+QUE_998_A2
+
+0
+
+
+
+QUE_998_A3
+
+0
+
+
+
+QUE_998_A4
+
+0
+
+
+
+QUE_998_A5
+
+0
+
+
+
+
+-
+
+
+H(z) shown below:
+{Equation:eqn=
+
+
+
+
+
+w = 0.1pi .
+]]>
+
+
+
+
+ w = 0.1*pi .
+]]>
+
+
+
+
+w = 1 .
+]]>
+
+
+
+
+ w = 0.6pi .
+]]>
+
+
+
+
+w = 0.1pi .
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_999_A1
+
+100
+
+
+
+QUE_999_A2
+
+0
+
+
+
+QUE_999_A3
+
+0
+
+
+
+QUE_999_A4
+
+0
+
+
+
+QUE_999_A5
+
+0
+
+
+
+
+-
+
+
+radians/sec
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1000_A1
+
+0
+
+
+
+QUE_1000_A2
+
+25
+
+
+
+QUE_1000_A3
+
+0
+
+
+
+QUE_1000_A4
+
+40
+
+
+
+QUE_1000_A5
+
+100
+
+
+
+
+-
+
+
+H(z) shown below:
+{Equation:eqn=
+
+
+
+
+
+w = 0.4pi .
+]]>
+
+
+
+
+ w = 0.4*pi .
+]]>
+
+
+
+
+w = 1 .
+]]>
+
+
+
+
+ w = 0.8pi .
+]]>
+
+
+
+
+w = 0.8pi .
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1001_A1
+
+100
+
+
+
+QUE_1001_A2
+
+0
+
+
+
+QUE_1001_A3
+
+0
+
+
+
+QUE_1001_A4
+
+0
+
+
+
+QUE_1001_A5
+
+0
+
+
+
+
+-
+
+
+H(z) shown below:
+{Equation:eqn=
+
+
+
+
+
+w = 0.8pi .
+]]>
+
+
+
+
+ w = 0.8*pi .
+]]>
+
+
+
+
+w = 1 .
+]]>
+
+
+
+
+ w = 0.4pi .
+]]>
+
+
+
+
+w = 0.4pi .
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1002_A1
+
+100
+
+
+
+QUE_1002_A2
+
+0
+
+
+
+QUE_1002_A3
+
+0
+
+
+
+QUE_1002_A4
+
+0
+
+
+
+QUE_1002_A5
+
+0
+
+
+
+
+-
+
+
+'yes' with the string 'no' in the structure array SS ?
+
SS = struct('strings',{{'hello','yes'}},'lengths',[5 3])
+
+]]>
+
+
+
+
+
+ SS.strings(2) = {'no'}
+]]>
+
+
+
+
+ SS(1,2) = {'no'}
+]]>
+
+
+
+
+ SS.strings.yes = {'no'}
+]]>
+
+
+
+
+ SS.strings(1) = {'no'}
+]]>
+
+
+
+
+ SS.fieldnames
+]]>
+
+
+
+
+ SS.yes = {'no'}
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1003_A1
+
+100
+
+
+
+QUE_1003_A2
+
+0
+
+
+
+QUE_1003_A3
+
+0
+
+
+
+QUE_1003_A4
+
+0
+
+
+
+QUE_1003_A5
+
+0
+
+
+
+QUE_1003_A6
+
+0
+
+
+
+
+-
+
+
+Select the appropriate Matlab code to generate the following sinusoid with a sampling rate of 8000 samples/sec.
+
x(t) = 8.5cos(2π(350)t +π/3)
+]]>
+
+
+
+
+
+tt = [0:1/8000:1];
xx = 8.5 cos(2 pi 350 tt + pi / 3);
+]]>
+
+
+
+
+tt = [0:1/8000:1];
xx = 8.5*cos(2*pi*350*tt) + pi/3;
+]]>
+
+
+
+
+tt = [0:1/8000:1];
xx = 8.5*cos(2*pi*350*tt+pi/3);
+]]>
+
+
+
+
+tt = [0:1/350:1];
xx = 8.5cos(2*pi*8000*tt+pi/3);
+]]>
+
+
+
+
+tt = [0:8000];
xx = cos(2*pi*350*tt);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1004_A1
+
+25
+
+
+
+QUE_1004_A2
+
+50
+
+
+
+QUE_1004_A3
+
+100
+
+
+
+QUE_1004_A4
+
+0
+
+
+
+QUE_1004_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = x[n] + x[n-1] + 0.5x[n-2]
+What is its system function H(ejω) ? ]]>
+
+
+
+
+
+jω) = ω + ω-1 + 0.5ω-2]]>
+
+
+
+
+jω) = 1 + e-jω + 0.5e-2jω]]>
+
+
+
+
+jω) = ejω + ejω + 0.5 ej2ω]]>
+
+
+
+
+jω) = ejω + e-jω + 0.5e-j2ω]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1007_A1
+
+0
+
+
+
+QUE_1007_A2
+
+100
+
+
+
+QUE_1007_A3
+
+0
+
+
+
+QUE_1007_A4
+
+0
+
+
+
+
+-
+
+
+zero at z = 0.2 + 0.5j
+
+Which of the following zeros does not belong to this filter?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1010_A1
+
+0
+
+
+
+QUE_1010_A2
+
+0
+
+
+
+QUE_1010_A3
+
+100
+
+
+
+QUE_1010_A4
+
+0
+
+
+
+
+-
+
+
+xx is a vector of length 15. yy is a vector of length 5.
What is the correct way to add yy to the FIRST 5 points of xx?
The result (called zz) should be 15 points long.
Assume all vectors are row vectors.
Do not assume that zz has been initialized.
+]]>
+
+
+
+
+
+zz = xx(1:5) + yy;
+]]>
+
+
+
+
+zz(1:5) = xx + yy;
+]]>
+
+
+
+
+zz = xx + [yy,zeros(1,10)];
+]]>
+
+
+
+
+zz = xx + yy;
+]]>
+
+
+
+
+zz = xx + [zeros(1,10),yy];
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1011_A1
+
+0
+
+
+
+QUE_1011_A2
+
+0
+
+
+
+QUE_1011_A3
+
+100
+
+
+
+QUE_1011_A4
+
+0
+
+
+
+QUE_1011_A5
+
+0
+
+
+
+
+-
+
+
+xx, increasing the length of the averager to be 2*L will:
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1012_A1
+
+0
+
+
+
+QUE_1012_A2
+
+0
+
+
+
+QUE_1012_A3
+
+0
+
+
+
+QUE_1012_A4
+
+0
+
+
+
+QUE_1012_A5
+
+100
+
+
+
+
+-
+
+
+y[n] = 2 x[n] + x[n-1] - x[n-2] + 3 x[n-3] ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1013_A1
+
+0
+
+
+
+QUE_1013_A2
+
+100
+
+
+
+QUE_1013_A3
+
+0
+
+
+
+QUE_1013_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1014_A1
+
+0
+
+
+
+QUE_1014_A2
+
+100
+
+
+
+QUE_1014_A3
+
+0
+
+
+
+QUE_1014_A4
+
+0
+
+
+
+QUE_1014_A5
+
+0
+
+
+
+QUE_1014_A6
+
+0
+
+
+
+QUE_1014_A7
+
+0
+
+
+
+QUE_1014_A8
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1016_A1
+
+0
+
+
+
+QUE_1016_A2
+
+0
+
+
+
+QUE_1016_A3
+
+0
+
+
+
+QUE_1016_A4
+
+0
+
+
+
+QUE_1016_A5
+
+0
+
+
+
+
+-
+
+
+is not the solution to the equation
+
z6 - 1 = 0
]]>
+
+
+
+
+
+z = ejπ]]>
+
+
+
+
+z = 1]]>
+
+
+
+
+z = ej2π/3]]>
+
+
+
+
+z = ejπ/6]]>
+
+
+
+
+z = -1]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1017_A1
+
+0
+
+
+
+QUE_1017_A2
+
+0
+
+
+
+QUE_1017_A3
+
+0
+
+
+
+QUE_1017_A4
+
+100
+
+
+
+QUE_1017_A5
+
+0
+
+
+
+
+-
+
+
+a[n] = δ[n] - 2δ[n-2]
+
b[n] = δ[n-1] + δ[n-2]
+Define c[n] = a[n]*b[n] where * denotes convolution.
+What is C(z)?
]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1018_A1
+
+0
+
+
+
+QUE_1018_A2
+
+0
+
+
+
+QUE_1018_A3
+
+0
+
+
+
+QUE_1018_A4
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1019_A1
+
+0
+
+
+
+QUE_1019_A2
+
+0
+
+
+
+QUE_1019_A3
+
+100
+
+
+
+QUE_1019_A4
+
+0
+
+
+
+
+-
+
+
+ office hours
+on (you may have multiple answers)
+]]>
+
+
+
+
+
+ Saturday morning between 8-12
+]]>
+
+
+
+
+ Saturday afternoon between 12-6
+]]>
+
+
+
+
+ Saturday evening between 6-10
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1020_A1
+
+100
+
+
+
+QUE_1020_A2
+
+100
+
+
+
+QUE_1020_A3
+
+100
+
+
+
+QUE_1020_A4
+
+100
+
+
+
+
+-
+
+
+x[n] given by
x[n] = 2 ,for n = 1,2
x[n] = 4 ,for n = 3
x[n] = 0 ,otherwise
What is the z-transform of this sequence? ]]>
+
+
+
+
+
+X(z) = 2z-1 + 2z-2 + 4z-3]]>
+
+
+
+
+X(z) = 2 + 2z-1 + 4z-2]]>
+
+
+
+
+X(z) = 2z + 2z2 + 4z3]]>
+
+
+
+
+X(z) = 2z + 2z2 + 4z3]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1023_A1
+
+100
+
+
+
+QUE_1023_A2
+
+0
+
+
+
+QUE_1023_A3
+
+0
+
+
+
+QUE_1023_A4
+
+0
+
+
+
+
+-
+
+
+h[n] = δ[n] - δ[n-1]
+and an input
x[n] = 2δ[n] + 3δ[n-1]
is applied.
+What is the output Y(z)? ]]>
+
+
+
+
+
+Y(z) = 2z + 1 - 3z-2]]>
+
+
+
+
+Y(z) = 2z2 + z - 3]]>
+
+
+
+
+Y(z) = 2 + z-1 - 3z-2]]>
+
+
+
+
+Y(z) = 2z-1 + z-2 - 3z-3]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1025_A1
+
+0
+
+
+
+QUE_1025_A2
+
+0
+
+
+
+QUE_1025_A3
+
+100
+
+
+
+QUE_1025_A4
+
+0
+
+
+
+
+-
+
+
+specgram function in MATLAB. What can you say
+about the signal being represented?
+]]>
+
+
+
+
+
+
+added together.
+]]>
+
+
+
+
+addition of two sinusoids.
+]]>
+
+
+
+
+added, but I cannot tell how long the original signal is.
+]]>
+
+
+
+
+
+
+
+
+
+concatenation of two sinusoids, but I cannot tell how long the original signal is.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1026_A1
+
+40
+
+
+
+QUE_1026_A2
+
+30
+
+
+
+QUE_1026_A3
+
+100
+
+
+
+QUE_1026_A4
+
+0
+
+
+
+QUE_1026_A5
+
+0
+
+
+
+
+-
+
+
+H(z) when two filters
+
h1[n] = 0.5 ( δ[n] + δ[n-1] + δ[n-2] )
h2[n] = 0.4 ( δ[n] + δ[n-1] )
are cascaded. ]]>
+
+
+
+
+
+H(z) = 0.9 (2 + 2z-1 + z-2)]]>
+
+
+
+
+H(z) = 0.2 (1 + 2z-1 + 2z-2 + z-3)]]>
+
+
+
+
+H(z) = 0.9 (1 + z-1 + 2z-3)]]>
+
+
+
+
+H(z) = z + 2z-1 + 2z-2 + z-3]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1027_A1
+
+0
+
+
+
+QUE_1027_A2
+
+100
+
+
+
+QUE_1027_A3
+
+0
+
+
+
+QUE_1027_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1028_A1
+
+100
+
+
+
+QUE_1028_A2
+
+-200
+
+
+
+
+-
+
+
+z-transform X(z) given by the equation
+
X(z) = 1 - 2z-1 + 3z-3
+
Determine x[n]? ]]>
+
+
+
+
+
+x[n] = 1 - 2n-2 + 3n-3]]>
+
+
+
+
+x[n] = n - 2n2 + 3n3]]>
+
+
+
+
+x[n] = 1 - 2δ[n-1] + 3δ[n-3]]]>
+
+
+
+
+x[n] = δ[n] - 2δ[n-1] + 3δ[n-3]]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1029_A1
+
+0
+
+
+
+QUE_1029_A2
+
+0
+
+
+
+QUE_1029_A3
+
+0
+
+
+
+QUE_1029_A4
+
+100
+
+
+
+
+-
+
+
+function tone=note(keynum,dur)
% Returns a single sinusoid with the key and duration specified
fs = 11025;
tt = 0:1/fs:dur;
f0 = 440*2^((keynum-49)/12);
tone = cos(2*pi*f0*tt);A student wants to modify the function so that the tone created by this function has TWO frequency components. The new tone should be the sum of two sinusoids, one of which is the fundamental and the other of which has a frequency 2 times higher. The amplitudes (and phases) can be the same. Which one of the following is a correct modification that will accomplish this task?
+]]>
+
+
+
+
+
+note() with
tone = cos(2*pi*2*f0*tt);
+]]>
+
+
+
+
+note() with
tone = cos(2*pi*f0*([1 2]')*tt);
+]]>
+
+
+
+
+xx(n1:n2) = xx(n1:n2) + note([f 2*f],dur);
+]]>
+
+
+
+
+note()
f0 = f0 + 2*f0;
+]]>
+
+
+
+
+note() with
tone = cos(2*pi*f0*tt) + cos(2*pi*2*f0*tt)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1030_A1
+
+0
+
+
+
+QUE_1030_A2
+
+0
+
+
+
+QUE_1030_A3
+
+0
+
+
+
+QUE_1030_A4
+
+0
+
+
+
+QUE_1030_A5
+
+100
+
+
+
+
+-
+
+
+System 1 is described by the difference equation
y1[n] = ( x[n] + x[n-1] + x[n-2] ) / 3
+and System 2 is described by the system function
H2(z) = 1 + z-2
What is the length of the overall cascade system. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1031_A1
+
+100
+
+
+
+QUE_1031_A2
+
+0
+
+
+
+QUE_1031_A3
+
+0
+
+
+
+QUE_1031_A4
+
+0
+
+
+
+QUE_1031_A5
+
+0
+
+
+
+
+-
+
+
+Lowpass filter?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1032_A1
+
+0
+
+
+
+QUE_1032_A2
+
+0
+
+
+
+QUE_1032_A3
+
+0
+
+
+
+QUE_1032_A4
+
+0
+
+
+
+QUE_1032_A5
+
+0
+
+
+
+QUE_1032_A6
+
+0
+
+
+
+QUE_1032_A7
+
+100
+
+
+
+QUE_1032_A8
+
+0
+
+
+
+
+-
+
+
+The inverse filter is of the form:]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1033_A1
+
+0
+
+
+
+QUE_1033_A2
+
+0
+
+
+
+QUE_1033_A3
+
+100
+
+
+
+QUE_1033_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1034_A1
+
+25
+
+
+
+QUE_1034_A2
+
+25
+
+
+
+QUE_1034_A3
+
+25
+
+
+
+QUE_1034_A4
+
+25
+
+
+
+QUE_1034_A5
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1036_A1
+
+0
+
+
+
+QUE_1036_A2
+
+0
+
+
+
+QUE_1036_A3
+
+0
+
+
+
+QUE_1036_A4
+
+0
+
+
+
+QUE_1036_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1039_A1
+
+100
+
+
+
+
+-
+
+
+magnitude of the frequency
+response of a digital lowpass filter
+H(z) when given the filter's impulse response,
+hh. Which of the following procedures will
+achieve the desired plot. Pick the BEST answer.
+
+
+]]>
+
+
+
+
+
+ ww=-pi:pi/100:pi; HH=freqz(hh,1,ww); plot(ww,HH)
+
+]]>
+
+
+
+
+ ww=-pi:pi; HH=freqz(hh,1,ww); plot(ww,abs(HH))
+
+]]>
+
+
+
+
+ ww=-pi:pi/100:pi; HH=freqz(hh,ww); plot(ww,abs(HH))
+
+]]>
+
+
+
+
+ ww=-pi:pi/100:pi; HH=freqz(hh,1,ww); plot(ww,abs(HH))
+
+]]>
+
+
+
+
+ ww=-pi:pi/100:pi; HH=freqz(ww,hh); plot(ww,abs(HH))
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1041_A1
+
+50
+
+
+
+QUE_1041_A2
+
+50
+
+
+
+QUE_1041_A3
+
+0
+
+
+
+QUE_1041_A4
+
+100
+
+
+
+QUE_1041_A5
+
+0
+
+
+
+
+-
+
+
+z in the figure below? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1042_A1
+
+0
+
+
+
+QUE_1042_A2
+
+100
+
+
+
+QUE_1042_A3
+
+0
+
+
+
+QUE_1042_A4
+
+0
+
+
+
+
+-
+
+
+z-plane is located on the unit circle? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1043_A1
+
+0
+
+
+
+QUE_1043_A2
+
+0
+
+
+
+QUE_1043_A3
+
+0
+
+
+
+QUE_1043_A4
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1044_A1
+
+100
+
+
+
+QUE_1044_A2
+
+0
+
+
+
+QUE_1044_A3
+
+0
+
+
+
+QUE_1044_A4
+
+0
+
+
+
+QUE_1044_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+ h[n] = δ[n] - 0.618 δ[n-1] + δ[n-2]
+]]>
+
+
+
+
+ h[n] = δ[n] - 0.4 δ[n-1] - δ[n-2]
+]]>
+
+
+
+
+ h[n] = 1 - 0.4 δ[n-1] - δ[n-2]
+]]>
+
+
+
+
+ h[n] = δ[n] - 0.433 δ[n-1] + δ[n-2]
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1045_A1
+
+100
+
+
+
+QUE_1045_A2
+
+0
+
+
+
+QUE_1045_A3
+
+0
+
+
+
+QUE_1045_A4
+
+0
+
+
+
+
+-
+
+
+H(z)
for the pole-zero plot shown below?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1048_A1
+
+0
+
+
+
+QUE_1048_A2
+
+0
+
+
+
+QUE_1048_A3
+
+100
+
+
+
+QUE_1048_A4
+
+0
+
+
+
+
+-
+
+
+
+ak = 0.5 for k=0
+ak = 0.25 for k=2
+ak = 0.25 for k=-2
+ak = 0 for all other k's
+
+using the ak2sig function in MATLAB.
+
+If the FUNDAMENTAL period is defined to be To = 2*pi, which of the following signals is synthesized (approximately) as N becomes large (>20)?
+
NOTE: The Fourier Series coefficients for |k| < N are used in the synthesis.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1050_A1
+
+0
+
+
+
+QUE_1050_A2
+
+100
+
+
+
+QUE_1050_A3
+
+25
+
+
+
+QUE_1050_A4
+
+25
+
+
+
+QUE_1050_A5
+
+0
+
+
+
+QUE_1050_A6
+
+0
+
+
+
+
+-
+
+
+
+Specifications require that L > 6, what is suitable L?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1052_A1
+
+0
+
+
+
+QUE_1052_A2
+
+0
+
+
+
+QUE_1052_A3
+
+100
+
+
+
+QUE_1052_A4
+
+0
+
+
+
+QUE_1052_A5
+
+0
+
+
+
+
+-
+
+
+
+How many coefficients of this filter are complex?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1056_A1
+
+0
+
+
+
+QUE_1056_A2
+
+0
+
+
+
+QUE_1056_A3
+
+0
+
+
+
+QUE_1056_A4
+
+100
+
+
+
+QUE_1056_A5
+
+0
+
+
+
+
+-
+
+
+
h[n] = δ[n] - δ[n-1] + δ[n-2] - δ[n-3]
What are the poles of this filter?]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1058_A1
+
+100
+
+
+
+QUE_1058_A2
+
+0
+
+
+
+QUE_1058_A3
+
+0
+
+
+
+QUE_1058_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1059_A1
+
+0
+
+
+
+QUE_1059_A2
+
+0
+
+
+
+QUE_1059_A3
+
+0
+
+
+
+QUE_1059_A4
+
+0
+
+
+
+QUE_1059_A5
+
+0
+
+
+
+
+-
+
+
+x[n] = δ[n-2] + 2δ[n-4]What is X(z) when x[n] has been delayed by 2? ]]>
+
+
+
+
+
+X(z) = 2z-2 + 4z-4]]>
+
+
+
+
+X(z) = 1 + 2z-2]]>
+
+
+
+
+X(z) = (z-2)-2 + 2(z-2)-4]]>
+
+
+
+
+X(z) = z-4 + 2z-6]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1063_A1
+
+0
+
+
+
+QUE_1063_A2
+
+0
+
+
+
+QUE_1063_A3
+
+0
+
+
+
+QUE_1063_A4
+
+100
+
+
+
+
+-
+
+
+
+ak = (2*pi*cos(pi*k))./(pi.^2 - 4*pi.^2*k.^2)
+
+using the ak2sig function in MATLAB.
+
+If the FUNDAMENTAL period is defined to be To = 12, which of the following signals is synthesized (approximately) as N becomes large (>20)?
+
NOTE: The Fourier Series coefficients for |k| < N are used in the synthesis.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1064_A1
+
+100
+
+
+
+QUE_1064_A2
+
+0
+
+
+
+QUE_1064_A3
+
+50
+
+
+
+QUE_1064_A4
+
+0
+
+
+
+QUE_1064_A5
+
+0
+
+
+
+QUE_1064_A6
+
+0
+
+
+
+
+-
+
+
+ALL of the ways that will provide help to you while running MATLAB.
+]]>
+
+
+
+
+
+help at the command prompt
+]]>
+
+
+
+
+I don't know at the command prompt
+]]>
+
+
+
+
+
+
+
+
+
+helpdesk at the command prompt
+]]>
+
+
+
+
+? (question mark) in the MATLAB toolbar
+
+
+]]>
+
+
+
+
+doc at the command prompt
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1065_A1
+
+40
+
+
+
+QUE_1065_A2
+
+-50
+
+
+
+QUE_1065_A3
+
+-50
+
+
+
+QUE_1065_A4
+
+20
+
+
+
+QUE_1065_A5
+
+20
+
+
+
+QUE_1065_A6
+
+20
+
+
+
+
+-
+
+
+outside the unit circle, what happens to the impulse reponse?
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1067_A1
+
+0
+
+
+
+QUE_1067_A2
+
+0
+
+
+
+QUE_1067_A3
+
+100
+
+
+
+QUE_1067_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+how do I plot?"
+]]>
+
+
+
+
+help plot"
+]]>
+
+
+
+
+plot(cosine,wave);"
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1069_A1
+
+0
+
+
+
+QUE_1069_A2
+
+0
+
+
+
+QUE_1069_A3
+
+100
+
+
+
+QUE_1069_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1070_A1
+
+0
+
+
+
+QUE_1070_A2
+
+100
+
+
+
+QUE_1070_A3
+
+0
+
+
+
+QUE_1070_A4
+
+0
+
+
+
+
+-
+
+
+freqz(bb,1,ww). The system is defined by the following difference equation:
y[n] = x[n] - x[n-2] + x[n-3]
What should bb, the vector of filter coefficients, be defined as? ]]>
+
+
+
+
+
+bb = [-1, 1, -1];
+]]>
+
+
+
+
+bb = [-1, 0, 1, -1];
+]]>
+
+
+
+
+bb = [1, -1, 1];
+]]>
+
+
+
+
+bb = [1, 0, -1, 1];
+]]>
+
+
+
+
+bb = [0, 1, -1];
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1072_A1
+
+0
+
+
+
+QUE_1072_A2
+
+0
+
+
+
+QUE_1072_A3
+
+0
+
+
+
+QUE_1072_A4
+
+100
+
+
+
+QUE_1072_A5
+
+0
+
+
+
+
+-
+
+
+g[n] is a unit delay of h[n], where h[n] is defined as
h[n] = δ[n] - δ[n-1]
What is G(z)? ]]>
+
+
+
+
+
+G(z) = z-1 - z-2 ]]>
+
+
+
+
+G(z) = 1 - z-1 ]]>
+
+
+
+
+G(z) = 1 - z-2 ]]>
+
+
+
+
+G(z) = 1 - z-1 - z-2 ]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1073_A1
+
+100
+
+
+
+QUE_1073_A2
+
+0
+
+
+
+QUE_1073_A3
+
+0
+
+
+
+QUE_1073_A4
+
+0
+
+
+
+
+-
+
+
+A(z) = 1 + z^(-1) and
b[n] = δ[n] + δ[n-2]
+
+Define C(z) = A(z) + B(z)
+
+What is C(z)?
+
]]>
+
+
+
+
+
+-2]]>
+
+
+
+
+-1]]>
+
+
+
+
+-1 + z-2]]>
+
+
+
+
+-1 + z-2 + z-3]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1076_A1
+
+0
+
+
+
+QUE_1076_A2
+
+0
+
+
+
+QUE_1076_A3
+
+100
+
+
+
+QUE_1076_A4
+
+0
+
+
+
+
+-
+
+
+before going to lab.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1078_A1
+
+0
+
+
+
+QUE_1078_A2
+
+0
+
+
+
+QUE_1078_A3
+
+0
+
+
+
+QUE_1078_A4
+
+0
+
+
+
+QUE_1078_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = x[n] + x[n-1] + x[n-2] + x[n-4]How many unit delays would a block diagram representing this system have? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1079_A1
+
+0
+
+
+
+QUE_1079_A2
+
+0
+
+
+
+QUE_1079_A3
+
+100
+
+
+
+QUE_1079_A4
+
+0
+
+
+
+
+-
+
+
+x[n] = 7cos(0.2πn + π/3)
can also be written in the following form
x[n] = Re{Xej0.2πn}
where Re{ } denotes the real operator.How would you define the complex amplitude X in Matlab notation?
+]]>
+
+
+
+
+
+X = 7*e^(pi/3);
+]]>
+
+
+
+
+X = 7*e^(j*pi/3);
+]]>
+
+
+
+
+X = 7*exp(pi/3);
+]]>
+
+
+
+
+X = 7*exp(j*pi/3);
+]]>
+
+
+
+
+X = 7*exp(j*0.2*pi);
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1081_A1
+
+0
+
+
+
+QUE_1081_A2
+
+20
+
+
+
+QUE_1081_A3
+
+40
+
+
+
+QUE_1081_A4
+
+100
+
+
+
+QUE_1081_A5
+
+0
+
+
+
+
+-
+
+
+H(z) for the FIR imulse response
+
h[n] = δ[n] - 2cos( 0.5π[n-1] ) + δ[n-2]
]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1082_A1
+
+0
+
+
+
+QUE_1082_A2
+
+100
+
+
+
+QUE_1082_A3
+
+0
+
+
+
+QUE_1082_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:2;
+xx = cos(2*pi*2000*tt+pi/3);
+]]>
+
+
+
+
+
+f = 8000
+]]>
+
+
+
+
+f = pi/3
+]]>
+
+
+
+
+f = 2000
+]]>
+
+
+
+
+f = 2000
+]]>
+
+
+
+
+f = 8000
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1083_A1
+
+0
+
+
+
+QUE_1083_A2
+
+0
+
+
+
+QUE_1083_A3
+
+100
+
+
+
+QUE_1083_A4
+
+50
+
+
+
+QUE_1083_A5
+
+0
+
+
+
+
+-
+
+
+h[n] = δ[n] - δ[n-1] + δ[n-2] - δ[n-3]Which zero(s) correspond(s) to this filter? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1085_A1
+
+0
+
+
+
+QUE_1085_A2
+
+0
+
+
+
+QUE_1085_A3
+
+100
+
+
+
+QUE_1085_A4
+
+0
+
+
+
+
+-
+
+
+When you are finished with all the questions, hit the "FINISH" button.
+
+You can have MATLAB running while you answer these questions.
+
+Check the button below to confirm that you understand these instructions.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1088_A1
+
+100
+
+
+
+
+-
+
+
+ Reminder !!
+Whenever you complete an answer, hit the "Save Answer" button.
+When you are finished with all the questions, hit the "FINISH" button.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1089_A1
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1090_A1
+
+100
+
+
+
+
+-
+
+
+h1[n] = δ[n-1] - δ[n-2]and
h2[n] = δ[n] + δ[n-2]
What is the impulse response of this system? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1091_A1
+
+0
+
+
+
+QUE_1091_A2
+
+100
+
+
+
+QUE_1091_A3
+
+0
+
+
+
+QUE_1091_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1092_A1
+
+0
+
+
+
+QUE_1092_A2
+
+0
+
+
+
+QUE_1092_A3
+
+0
+
+
+
+QUE_1092_A4
+
+0
+
+
+
+QUE_1092_A5
+
+100
+
+
+
+QUE_1092_A6
+
+0
+
+
+
+QUE_1092_A7
+
+0
+
+
+
+QUE_1092_A8
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1149_A1
+
+0
+
+
+
+QUE_1149_A2
+
+100
+
+
+
+QUE_1149_A3
+
+0
+
+
+
+QUE_1149_A4
+
+0
+
+
+
+QUE_1149_A5
+
+0
+
+
+
+
+-
+
+
+z in the figure below?
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1150_A1
+
+0
+
+
+
+QUE_1150_A2
+
+0
+
+
+
+QUE_1150_A3
+
+100
+
+
+
+QUE_1150_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1151_A1
+
+0
+
+
+
+QUE_1151_A2
+
+100
+
+
+
+QUE_1151_A3
+
+0
+
+
+
+QUE_1151_A4
+
+0
+
+
+
+
+-
+
+
+z-plane is located on the unit circle? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1152_A1
+
+0
+
+
+
+QUE_1152_A2
+
+0
+
+
+
+QUE_1152_A3
+
+0
+
+
+
+QUE_1152_A4
+
+100
+
+
+
+
+-
+
+
+y[n] = x[n] + x[n-1] + 0.5 x[n-2] What is its system function H(ejω)?
+]]>
+
+
+
+
+
+jω) = ω + ω-1 + 0.5 ω-2]]>
+
+
+
+
+jω) = 1 + e-jω + 0.5 e-2jω]]>
+
+
+
+
+jω) = ejω + ejω + 0.5 e2jω]]>
+
+
+
+
+jω) = ejω + e-jω + 0.5 e-2jω]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1153_A1
+
+0
+
+
+
+QUE_1153_A2
+
+100
+
+
+
+QUE_1153_A3
+
+0
+
+
+
+QUE_1153_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1154_A1
+
+100
+
+
+
+QUE_1154_A2
+
+0
+
+
+
+QUE_1154_A3
+
+0
+
+
+
+QUE_1154_A4
+
+0
+
+
+
+
+-
+
+
+H(z) for the pole-zero plot shown below? ]]>
+
+
+
+
+
+
+ -1 - 0.5z -2 ]]>
+
+
+
+
+ -1 - 0.25z -2]]>
+
+
+
+
+ -2]]>
+
+
+
+
+ -2]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1155_A1
+
+0
+
+
+
+QUE_1155_A2
+
+0
+
+
+
+QUE_1155_A3
+
+0
+
+
+
+QUE_1155_A4
+
+0
+
+
+
+
+-
+
+
+zero at:
z = 0.2 + 0.5j
+Which of the following zeros does not belong to this filter?
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1156_A1
+
+0
+
+
+
+QUE_1156_A2
+
+0
+
+
+
+QUE_1156_A3
+
+100
+
+
+
+QUE_1156_A4
+
+0
+
+
+
+
+-
+
+
+L? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1157_A1
+
+0
+
+
+
+QUE_1157_A2
+
+0
+
+
+
+QUE_1157_A3
+
+0
+
+
+
+QUE_1157_A4
+
+0
+
+
+
+QUE_1157_A5
+
+100
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1158_A1
+
+0
+
+
+
+QUE_1158_A2
+
+0
+
+
+
+QUE_1158_A3
+
+0
+
+
+
+QUE_1158_A4
+
+0
+
+
+
+QUE_1158_A5
+
+100
+
+
+
+
+-
+
+
+How many coefficients of this filter are complex? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1159_A1
+
+100
+
+
+
+QUE_1159_A2
+
+0
+
+
+
+QUE_1159_A3
+
+0
+
+
+
+QUE_1159_A4
+
+0
+
+
+
+QUE_1159_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 2x[n] + x[n-1] - x[n-2] + 3x[n-3] ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1160_A1
+
+0
+
+
+
+QUE_1160_A2
+
+0
+
+
+
+QUE_1160_A3
+
+0
+
+
+
+QUE_1160_A4
+
+0
+
+
+
+
+-
+
+
+y[n] = 3-x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1161_A1
+
+0
+
+
+
+QUE_1161_A2
+
+0
+
+
+
+QUE_1161_A3
+
+100
+
+
+
+QUE_1161_A4
+
+0
+
+
+
+
+-
+
+
+lowpass filter is a filter with magnitude response that suppresses high frequencies of the input. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1162_A1
+
+100
+
+
+
+
+-
+
+
+h[n] = δ[n] - δ[n-1] + δ[n-2] - δ[n-3]What are the poles of this filter? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1163_A1
+
+0
+
+
+
+QUE_1163_A2
+
+0
+
+
+
+QUE_1163_A3
+
+100
+
+
+
+QUE_1163_A4
+
+0
+
+
+
+
+-
+
+
+z-domain is to transform time-domain signals x[n] into another domain where signals can be represented by polynomials, and systems can be represented by rational functions. This transformation greatly simplifies signal manipulation and filter design. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1164_A1
+
+100
+
+
+
+
+-
+
+
+z-transform pair:
y[n] = δ[n] * δ[n+1]
]]>
+
+
+
+
+
+Y(z) = z-1]]>
+
+
+
+
+Y(z) = 1]]>
+
+
+
+
+Y(z) = z]]>
+
+
+
+
+Y(z) = 0]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1165_A1
+
+0
+
+
+
+QUE_1165_A2
+
+0
+
+
+
+QUE_1165_A3
+
+0
+
+
+
+QUE_1165_A4
+
+0
+
+
+
+
+-
+
+
+Which coefficient is equal to - 1? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1166_A1
+
+0
+
+
+
+QUE_1166_A2
+
+0
+
+
+
+QUE_1166_A3
+
+0
+
+
+
+QUE_1166_A4
+
+0
+
+
+
+QUE_1166_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1167_A1
+
+0
+
+
+
+QUE_1167_A2
+
+0
+
+
+
+QUE_1167_A3
+
+0
+
+
+
+QUE_1167_A4
+
+0
+
+
+
+QUE_1167_A5
+
+0
+
+
+
+
+-
+
+
+x[n] described by the equation
x[n] = δ[n-2] + 2δ[n-4]
What is X(z) when x[n] has been delayed by 2? ]]>
+
+
+
+
+
+X(z) = 2z-2 + 4z-4 ]]>
+
+
+
+
+X(z) = 1 + 2z-2]]>
+
+
+
+
+X(z) = (z - 2)-2 + 2(z - 2)-4]]>
+
+
+
+
+X(z) = z-4 + 2z-6]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1168_A1
+
+0
+
+
+
+QUE_1168_A2
+
+0
+
+
+
+QUE_1168_A3
+
+0
+
+
+
+QUE_1168_A4
+
+100
+
+
+
+
+-
+
+
+h[n] = δ[n-1] + 2δ[n-2]What is the frequency response of this FIR filter ? ]]>
+
+
+
+
+
+jω) = 3 e-jω]]>
+
+
+
+
+jω) = 1 + e-jω ]]>
+
+
+
+
+jω) = e-jω - 2jω]]>
+
+
+
+
+jω) = e-jω + e-2jω]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1169_A1
+
+0
+
+
+
+QUE_1169_A2
+
+0
+
+
+
+QUE_1169_A3
+
+0
+
+
+
+QUE_1169_A4
+
+0
+
+
+
+
+-
+
+
+H(z) = 1 - z-1 + z-3 What is the frequency response of this system? ]]>
+
+
+
+
+
+jω) = 1 + e-2jω]]>
+
+
+
+
+jω) = 1 - e-jω + e-3jω]]>
+
+
+
+
+jω) = 1 - e-jω + 3 e-jω]]>
+
+
+
+
+jω) = e-jω - e-2jω + e-3jω]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1170_A1
+
+0
+
+
+
+QUE_1170_A2
+
+0
+
+
+
+QUE_1170_A3
+
+0
+
+
+
+QUE_1170_A4
+
+0
+
+
+
+
+-
+
+
+not the solution to the equation
z6 - 1 = 0
]]>
+
+
+
+
+
+ j π]]>
+
+
+
+
+
+
+
+
+
+ j 2π/3]]>
+
+
+
+
+ j π/6]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1171_A1
+
+0
+
+
+
+QUE_1171_A2
+
+0
+
+
+
+QUE_1171_A3
+
+0
+
+
+
+QUE_1171_A4
+
+0
+
+
+
+QUE_1171_A5
+
+0
+
+
+
+
+-
+
+
+a[n] = δ[n] - 2 δ[n-2]
b[n] = δ[n-1] + δ[n-2]
Define c[n] = a[n] * b[n]
where * denotes convolution. What is C(z)? ]]>
+
+
+
+
+
+C(z) = z-1 + z-2 + 2z-4]]>
+
+
+
+
+C(z) = z1 + z2 - z4]]>
+
+
+
+
+C(z) = 1 + z-1 + z-2]]>
+
+
+
+
+C(z) = z-1 + z-2 - 2z-3 - 2z-4]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1172_A1
+
+0
+
+
+
+QUE_1172_A2
+
+0
+
+
+
+QUE_1172_A3
+
+0
+
+
+
+QUE_1172_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+ n ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ne- 2n u[n]]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1173_A1
+
+0
+
+
+
+QUE_1173_A2
+
+0
+
+
+
+QUE_1173_A3
+
+0
+
+
+
+QUE_1173_A4
+
+0
+
+
+
+
+-
+
+
+1 + α + α 2 + ... + α k
+with α = 0.4
+
What is the sum of this sequence?
]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1174_A1
+
+0
+
+
+
+QUE_1174_A2
+
+0
+
+
+
+QUE_1174_A3
+
+0
+
+
+
+QUE_1174_A4
+
+0
+
+
+
+
+-
+
+
+x[n] given by
+
x[n] = 2 for n = 1, 2
+
x[n] = 4 for n = 3
+
x[n] = 0 otherwise
+
What is the z-transform of this sequence?
]]>
+
+
+
+
+
+X(z) = 2z-1 + 2z-2 + 4z-3]]>
+
+
+
+
+X(z) = 2 + 2z-1 + 4z-2]]>
+
+
+
+
+X(z) = 2(z - 1) + 2(z - 2) + 4(z - 3)]]>
+
+
+
+
+X(z) = 2z + 2z2 + 4z3]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1175_A1
+
+0
+
+
+
+QUE_1175_A2
+
+0
+
+
+
+QUE_1175_A3
+
+0
+
+
+
+QUE_1175_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1176_A1
+
+0
+
+
+
+QUE_1176_A2
+
+0
+
+
+
+QUE_1176_A3
+
+0
+
+
+
+QUE_1176_A4
+
+0
+
+
+
+
+-
+
+
+g[n] is a unit delay of h[n], where h[n] is denoted by
h[n] = δ[n] - δ[n-1]
What is G(z)? ]]>
+
+
+
+
+
+G(z) = z-1 - z-2]]>
+
+
+
+
+G(z) = 1 - z-1]]>
+
+
+
+
+G(z) = 1 - z-2]]>
+
+
+
+
+G(z) = 1 - z-1 - z-2]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1177_A1
+
+0
+
+
+
+QUE_1177_A2
+
+0
+
+
+
+QUE_1177_A3
+
+0
+
+
+
+QUE_1177_A4
+
+0
+
+
+
+
+-
+
+
+h[n] = δ[n] - δ[n-1] and an input
x[n] = 2δ[n] + 3δ[n-1]
is applied. What is the output Y(z)? ]]>
+
+
+
+
+
+Y(z) = 2z + 1 - 3z-2]]>
+
+
+
+
+Y(z) = 2-2 + z-3]]>
+
+
+
+
+Y(z) = 2 + z-1 - 3z-2]]>
+
+
+
+
+Y(z) = 2z-1 + z-2 - 3z-3]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1178_A1
+
+0
+
+
+
+QUE_1178_A2
+
+0
+
+
+
+QUE_1178_A3
+
+0
+
+
+
+QUE_1178_A4
+
+0
+
+
+
+
+-
+
+
+A(z) = 1 + z -1 and
b[n] = δ[n] + δ[n-2]
Denote C(z) = A(z) + B(z)
What is C(z)?]]>
+
+
+
+
+
+C(z) = 2 + z-2]]>
+
+
+
+
+C(z) = 1 + z-1]]>
+
+
+
+
+C(z) = 2 + z-1 + z-2]]>
+
+
+
+
+C(z) = 1 + z-1 + z-2 + z-3]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1179_A1
+
+0
+
+
+
+QUE_1179_A2
+
+0
+
+
+
+QUE_1179_A3
+
+0
+
+
+
+QUE_1179_A4
+
+0
+
+
+
+
+-
+
+
+h1[n] = 0.5 ( δ[n] + δ[n-1] + δ[n-2] )
h2[n] = 0.4 ( δ[n] + δ[n-1] )
are cascaded. ]]>
+
+
+
+
+
+H(z) = 0.9 (2 + 2z-1 + z-2)]]>
+
+
+
+
+H(z) = 0.2(1 + 2 z-1 + 2 z-2 + z-3)]]>
+
+
+
+
+H(z) = 0.9(1 + z-1 + 2z-3)]]>
+
+
+
+
+H(z) = z + 2z-1 + 2z-2 + z-3]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1180_A1
+
+0
+
+
+
+QUE_1180_A2
+
+0
+
+
+
+QUE_1180_A3
+
+0
+
+
+
+QUE_1180_A4
+
+0
+
+
+
+
+-
+
+
+y[n] = x[n] + x[n-1] + x[n-2] + x[n-4] How many unit delays would a block diagram representing this system have? ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1181_A1
+
+0
+
+
+
+QUE_1181_A2
+
+0
+
+
+
+QUE_1181_A3
+
+100
+
+
+
+QUE_1181_A4
+
+0
+
+
+
+
+-
+
+
+z-transform X(z) given by the equation
X(z) = 1 - 2z -1 + 3z -3
Determine x[n]? ]]>
+
+
+
+
+
+x[n] = 1 - 2n-2 + 3n-3]]>
+
+
+
+
+x[n] = n - 2n2 + 3n3]]>
+
+
+
+
+x[n] = 1 - 2δ[n-1] + 3δ[n-3]]]>
+
+
+
+
+x[n] = δ[n] - 2δ[n-1] + 3δ[n-3]]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1182_A1
+
+0
+
+
+
+QUE_1182_A2
+
+0
+
+
+
+QUE_1182_A3
+
+0
+
+
+
+QUE_1182_A4
+
+0
+
+
+
+
+-
+
+
+y1[n] = ¾( x[n] + x[n-1] + x[n-2] )and system 2 is described by its system function:
H2(z) = 1 + z -2
What is the length of the overall cascaded system. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1183_A1
+
+0
+
+
+
+QUE_1183_A2
+
+0
+
+
+
+QUE_1183_A3
+
+0
+
+
+
+QUE_1183_A4
+
+0
+
+
+
+QUE_1183_A5
+
+0
+
+
+
+
+-
+
+
+H(z) for the FIR impulse response
h[n] = δ[n] - 2cos( 0.5 ω[n-1] ) + δ[n-2]
]]>
+
+
+
+
+
+H(z) = (1 - cos(z))(1 + cos(z)) ]]>
+
+
+
+
+H(z) = (1 - ej0.5πz-1)]]>
+
+
+
+
+H(z) = (1 - z-1)(1 - z-1)]]>
+
+
+
+
+H(z) = (1 - 2ejπz-1)(1 - 2e-jπ z-1)]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1184_A1
+
+0
+
+
+
+QUE_1184_A2
+
+0
+
+
+
+QUE_1184_A3
+
+0
+
+
+
+QUE_1184_A4
+
+0
+
+
+
+
+-
+
+
+h[n] = δ[n] - δ[n-1] + δ[n-2] - δ[n-3]Which zero(s) correspond(s) to this filter?]]>
+
+
+
+
+
+z = 0]]>
+
+
+
+
+z = 1 and z = -1 ]]>
+
+
+
+
+z = -j and z = j ]]>
+
+
+
+
+z = -1 and z = j ]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1185_A1
+
+0
+
+
+
+QUE_1185_A2
+
+0
+
+
+
+QUE_1185_A3
+
+0
+
+
+
+QUE_1185_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1186_A1
+
+0
+
+
+
+QUE_1186_A2
+
+0
+
+
+
+QUE_1186_A3
+
+0
+
+
+
+QUE_1186_A4
+
+100
+
+
+
+
+-
+
+
+2 - 1.697z -1 + 0.72 z -2match its corresponding answer. ]]>
+
+
+
+
+
+2(1 - 0.2z-1 )(1 + 0.1333z-1) ]]>
+
+
+
+
+
+
+
+
+
+2(1 + 0.2z-1)(1 - 0.1333 z-1) ]]>
+
+
+
+
+2(1 - 0.6ej0.25πz-1)(1 - 0.6e-j0.25π z-1)]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1187_A1
+
+0
+
+
+
+QUE_1187_A2
+
+0
+
+
+
+QUE_1187_A3
+
+0
+
+
+
+QUE_1187_A4
+
+0
+
+
+
+
+-
+
+
+complex plane is a set of complex points
z = x + jy
where the real x and the imaginary y parts are the horizontal and vertical coordinates. ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1188_A1
+
+0
+
+
+
+
+-
+
+
+h1[n] = δ[n-1] - δ[n-2]
+and
+
h2[n] = δ[n] + δ[n-2]
+
+What is the impulse response of this system?]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1189_A1
+
+0
+
+
+
+QUE_1189_A2
+
+100
+
+
+
+QUE_1189_A3
+
+0
+
+
+
+QUE_1189_A4
+
+0
+
+
+
+
+-
+
+
+ find its correct match among the signals.]]>
+
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1190_A1
+
+0
+
+
+
+QUE_1190_A2
+
+0
+
+
+
+QUE_1190_A3
+
+0
+
+
+
+QUE_1190_A4
+
+100
+
+
+
+QUE_1190_A5
+
+0
+
+
+
+
+-
+
+
+ find its correct match among the signals.]]>
+
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1191_A1
+
+0
+
+
+
+QUE_1191_A2
+
+0
+
+
+
+QUE_1191_A3
+
+0
+
+
+
+QUE_1191_A4
+
+0
+
+
+
+QUE_1191_A5
+
+0
+
+
+
+
+-
+
+
+10cos(77t - 1) + 8cos(77t + 2) = Acos(ωt + φ)Find the parameters: A, ω, and φ]]>
+
+
+
+
+
+A = 15.4 | ω = 77]]>
+
+
+
+
+ω = 18 | φ = 0.707]]>
+
+
+
+
+A = 18 | φ = 1.81]]>
+
+
+
+
+A = 2.37 | ω = 77]]>
+
+
+
+
+A = 3.76 | φ = 1.62]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1193_A1
+
+0
+
+
+
+QUE_1193_A2
+
+0
+
+
+
+QUE_1193_A3
+
+0
+
+
+
+QUE_1193_A4
+
+100
+
+
+
+QUE_1193_A5
+
+0
+
+
+
+
+-
+
+
+
can also be expressed as:]]>
+
+
+
+
+
+sin(123t)]]>
+
+
+
+
+cos(123t + 2π)]]>
+
+
+
+
+2cos(123t + π)]]>
+
+
+
+
+sin(123t)+cos(123t)]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1194_A1
+
+100
+
+
+
+QUE_1194_A2
+
+0
+
+
+
+QUE_1194_A3
+
+0
+
+
+
+QUE_1194_A4
+
+0
+
+
+
+
+-
+
+
+x(t) has the following spectrum representation:

What is the equation for x(t)?]]>
+
+
+
+
+
+x(t) = 0.5 + cos(100πt)]]>
+
+
+
+
+x(t) = cos(50πt)]]>
+
+
+
+
+x(t) = 0.5 + 1.5cos(100πt)]]>
+
+
+
+
+x(t) = 0.5 + 3cos(100πt)]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1196_A1
+
+0
+
+
+
+QUE_1196_A2
+
+0
+
+
+
+QUE_1196_A3
+
+0
+
+
+
+QUE_1196_A4
+
+100
+
+
+
+
+-
+
+
+fundamental frequency for the signal shown below:]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1197_A1
+
+0
+
+
+
+QUE_1197_A2
+
+100
+
+
+
+QUE_1197_A3
+
+0
+
+
+
+QUE_1197_A4
+
+0
+
+
+
+
+-
+
+
+

Which MATLAB code generated this signal?]]>
+
+
+
+
+
+xx = real(exp(-j*6000*pi.*tt.^2 + j*2000*pi.*tt + j*6000));
spectrogram(xx,512,[],[],fsamp,'yaxis');]]>
+
+
+
+
+xx = real(exp(-j*2000*pi.*tt.^2 + j*4000*pi.*tt + j*200));
spectrogram(xx,512,[],[],fsamp,'yaxis');]]>
+
+
+
+
+xx = real(exp(j*1000*pi.*tt.^2 + j*6000*pi.*tt));
spectrogram(xx,512,[],[],fsamp,'yaxis');]]>
+
+
+
+
+xx = real(exp(-j*2000*pi.*tt.^2 + j*6000*pi.*tt + j*100));
spectrogram(xx,512,[],[],fsamp,'yaxis');]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1199_A1
+
+0
+
+
+
+QUE_1199_A2
+
+0
+
+
+
+QUE_1199_A3
+
+0
+
+
+
+QUE_1199_A4
+
+100
+
+
+
+
+-
+
+
+fundamental frequency for the periodic signal whose spectrogram is shown below:]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1200_A1
+
+0
+
+
+
+QUE_1200_A2
+
+100
+
+
+
+QUE_1200_A3
+
+0
+
+
+
+QUE_1200_A4
+
+0
+
+
+
+QUE_1200_A5
+
+0
+
+
+
+
+-
+
+
+x(t) = e2cos(5πt)cos(2πfct)Determine fc.]]>
+
+
+
+
+
+
+c = 2.5 Hz]]>
+
+
+
+
+c = 5 Hz]]>
+
+
+
+
+c = 7.5 Hz]]>
+
+
+
+
+c = 10 Hz]]>
+
+
+
+
+c = 15 Hz]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1201_A1
+
+0
+
+
+
+QUE_1201_A2
+
+0
+
+
+
+QUE_1201_A3
+
+100
+
+
+
+QUE_1201_A4
+
+0
+
+
+
+QUE_1201_A5
+
+0
+
+
+
+
+-
+
+
+s(t) = π2cos(100πt + 2cos(4πt))Determine the fundamental period of this signal, i.e., the shortest period.]]>
+
+
+
+
+
+o = 0.01]]>
+
+
+
+
+o = 0.0192]]>
+
+
+
+
+o = 0.02]]>
+
+
+
+
+o = 0.25]]>
+
+
+
+
+o = 0.5]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1202_A1
+
+0
+
+
+
+QUE_1202_A2
+
+0
+
+
+
+QUE_1202_A3
+
+0
+
+
+
+QUE_1202_A4
+
+0
+
+
+
+QUE_1202_A5
+
+100
+
+
+
+
+-
+
+
+ƒ0 = 13.4 Hz. Determine the smallest integer value of the sampling rate ƒs so that no aliasing occurs. The units of ƒs are samples per second. You must justify your response by citing a theorem or property about sampling.]]>
+
+
+
+
+
+ƒs = 7 Hz]]>
+
+
+
+
+ƒs = 27 Hz]]>
+
+
+
+
+ƒs = 14 Hz]]>
+
+
+
+
+ƒs = 20 Hz]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1203_A1
+
+0
+
+
+
+QUE_1203_A2
+
+100
+
+
+
+QUE_1203_A3
+
+0
+
+
+
+QUE_1203_A4
+
+0
+
+
+
+
+-
+
+
+ƒ0 = 13 Hz and the input phase to φ = -1.3 rads. Determine the locations of the spectral lines in the spectrum of the discrete-time signal (middle plot of the bottom row) when the sampling rate is ƒs = 29 Hz. Calculate
for the two spectral lines that lie in the range -π ≤
≤ π. Explain how you calculated the two values for
, i.e., give the formula for
in terms of ƒ0 and ƒs.]]>
+
+
+
+
+
+
= ± 0.103π]]>
+
+
+
+
+
= ± 0.569π]]>
+
+
+
+
+
= ± 0.924π]]>
+
+
+
+
+
= ± 1.103π]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1204_A1
+
+0
+
+
+
+QUE_1204_A2
+
+0
+
+
+
+QUE_1204_A3
+
+100
+
+
+
+QUE_1204_A4
+
+0
+
+
+
+
+-
+
+
+Folded Alias: Set the input frequency to ƒ0 = 13 Hz, the input phase to φ = -1.3 rads, and ƒs = 20 Hz. Write down the formula for the output signal, and then write a justification consisting of three steps:
- calculating the values of
for the blue spectral lines in the spectrum of the discrete-time signal x[n] shown in the middle plots, - aliasing
(blue to red), and - transforming x[n] into y(t) using an equation that describes the ideal D-to-C converter and uses the principal aias.
]]>
+
+
+
+
+
+
= ± 0.7π]]>
+
+
+
+
+
= ± 1.3π]]>
+
+
+
+
+
= ± 0.8π]]>
+
+
+
+
+
= ± 1.7π]]>
+
+
+
+
+
= ± 1.6π]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1205_A1
+
+100
+
+
+
+QUE_1205_A2
+
+0
+
+
+
+QUE_1205_A3
+
+0
+
+
+
+QUE_1205_A4
+
+0
+
+
+
+QUE_1205_A5
+
+0
+
+
+
+
+-
+
+
+ƒs = 23 Hz, and assume that the output signal has a frequency of 9 Hz, and a phase of +1.3. Determine ONE ( ƒ0 , φ ) pair value that will give this output signal. Assume that the amplitude is one.]]>
+
+
+
+
+
+ƒ0 = 32 Hz, φ = -1.3]]>
+
+
+
+
+ƒ0 = 23 Hz, φ = -1.3]]>
+
+
+
+
+ƒ0 = 14 Hz, φ = 1.3]]>
+
+
+
+
+ƒ0 = 14 Hz, φ = -1.3]]>
+
+
+
+
+ƒ0 = 9 Hz, φ = 0]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1206_A1
+
+0
+
+
+
+QUE_1206_A2
+
+0
+
+
+
+QUE_1206_A3
+
+0
+
+
+
+QUE_1206_A4
+
+100
+
+
+
+QUE_1206_A5
+
+0
+
+
+
+
+-
+
+
+ƒ0 = 13 Hz and the input phase to φ = -1.3 rads. Determine the sampling rate ƒs so that the output signal has a frequency of 9 Hz, and a phase of +1.3 rads. Trial and error helps in getting the answer, but you must write an explanation based on theory.]]>
+
+
+
+
+
+ƒs = 9 Hz]]>
+
+
+
+
+ƒs = 13 Hz]]>
+
+
+
+
+ƒs = 22 Hz]]>
+
+
+
+
+ƒs = 35 Hz]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1207_A1
+
+0
+
+
+
+QUE_1207_A2
+
+0
+
+
+
+QUE_1207_A3
+
+100
+
+
+
+QUE_1207_A4
+
+0
+
+
+
+QUE_1207_A5
+
+0
+
+
+
+
+-
+
+
+bb needed to implement a first-difference FIR filter in MATLAB via
yy = conv(bb,xx)
]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1208_A1
+
+0
+
+
+
+QUE_1208_A2
+
+100
+
+
+
+QUE_1208_A3
+
+0
+
+
+
+QUE_1208_A4
+
+0
+
+
+
+
+-
+
+
+bb needed to implement a length-3 running-average FIR filter in MATLAB via
yy = conv(bb,xx)
]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1209_A1
+
+0
+
+
+
+QUE_1209_A2
+
+0
+
+
+
+QUE_1209_A3
+
+0
+
+
+
+QUE_1209_A4
+
+100
+
+
+
+
+-
+
+
+',1)" onmouseout="footerIMG(this,'',0)">lighthouse image, downsampling causes aliasing which can be seen where? (pick the best one):]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1210_A1
+
+100
+
+
+
+QUE_1210_A2
+
+0
+
+
+
+QUE_1210_A3
+
+0
+
+
+
+QUE_1210_A4
+
+0
+
+
+
+QUE_1210_A5
+
+0
+
+
+
+
+-
+
+
+poles of this filter?]]>
+
+
+
+
+
+
+0.95ej3π/4, 0.95e-j3π/4]]>
+
+
+
+
+0.95, -0.95]]>
+
+
+
+
+0.95ejπ/2, 0.95e-jπ/2]]>
+
+
+
+
+0.95ejπ/4, 0.95e-jπ/4]]>
+
+
+
+
+0.95ejπ/4, 0.95e-jπ/4, 0.95]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1215_A1
+
+100
+
+
+
+QUE_1215_A2
+
+0
+
+
+
+QUE_1215_A3
+
+0
+
+
+
+QUE_1215_A4
+
+0
+
+
+
+QUE_1215_A5
+
+0
+
+
+
+
+-
+
+
+pole-zero plot?]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1216_A1
+
+0
+
+
+
+QUE_1216_A2
+
+0
+
+
+
+QUE_1216_A3
+
+100
+
+
+
+QUE_1216_A4
+
+0
+
+
+
+
+-
+
+
+pole-zero plot?]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1217_A1
+
+0
+
+
+
+QUE_1217_A2
+
+100
+
+
+
+QUE_1217_A3
+
+0
+
+
+
+QUE_1217_A4
+
+0
+
+
+
+
+-
+
+
+
has two poles at: 0.8ej2π/3 and 0.8e-j2π/3.Find a1 and a2.]]>
+
+
+
+
+
+a1 = -1.6
a2 = -0.8]]>
+
+
+
+
+a1 = 0.8
a2 = -0.64]]>
+
+
+
+
+a1 = 0.4
a2 = -0.8]]>
+
+
+
+
+a1 = 0.8
a2 = 0.64]]>
+
+
+
+
+a1 = -0.8
a2 = -0.64]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1218_A1
+
+0
+
+
+
+QUE_1218_A2
+
+0
+
+
+
+QUE_1218_A3
+
+0
+
+
+
+QUE_1218_A4
+
+0
+
+
+
+QUE_1218_A5
+
+100
+
+
+
+
+-
+
+
+
*
]]>
+
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1219_A1
+
+0
+
+
+
+QUE_1219_A2
+
+0
+
+
+
+QUE_1219_A3
+
+0
+
+
+
+QUE_1219_A4
+
+100
+
+
+
+
+-
+
+
+notch filter.]]>
+
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1221_A1
+
+0
+
+
+
+QUE_1221_A2
+
+0
+
+
+
+QUE_1221_A3
+
+100
+
+
+
+QUE_1221_A4
+
+0
+
+
+
+QUE_1221_A5
+
+0
+
+
+
+
+-
+
+
+50-Hz interferance. Suppose that this is done with a digital IIR notch filter whose frequency response is shown in the figure.
Determine the sampling frequency used when the ECG was recorded.]]>
+
+
+
+
+
+
+s = 100 Hz]]>
+
+
+
+
+s = 400 Hz]]>
+
+
+
+
+s = 800 Hz]]>
+
+
+
+
+s = 1200 Hz]]>
+
+
+
+
+s = 8000 Hz]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1222_A1
+
+0
+
+
+
+QUE_1222_A2
+
+100
+
+
+
+QUE_1222_A3
+
+0
+
+
+
+QUE_1222_A4
+
+0
+
+
+
+QUE_1222_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+Fs = 8000 Hz]]>
+
+
+
+
+Fs = 16,000 Hz]]>
+
+
+
+
+Fs = 22,050 Hz]]>
+
+
+
+
+Fs = 44,100 Hz]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1300_A1
+
+
+
+
+
+QUE_1300_A2
+
+
+
+
+
+QUE_1300_A3
+
+
+
+
+
+QUE_1300_A4
+
+
+
+
+
+QUE_1300_A5
+
+
+
+
+
+
+-
+
+
+
+
+
+
+
+
+2]]>
+
+
+
+
+4]]>
+
+
+
+
+8]]>
+
+
+
+
+16]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1301_A1
+
+
+
+
+
+QUE_1301_A2
+
+
+
+
+
+QUE_1301_A3
+
+
+
+
+
+QUE_1301_A4
+
+
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1303_A1
+
+
+
+
+
+QUE_1303_A2
+
+
+
+
+
+QUE_1303_A3
+
+
+
+
+
+QUE_1303_A4
+
+
+
+
+
+QUE_1303_A5
+
+
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1304_A1
+
+
+
+
+
+QUE_1304_A2
+
+
+
+
+
+QUE_1304_A3
+
+
+
+
+
+QUE_1304_A4
+
+
+
+
+
+QUE_1304_A5
+
+
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1305_A1
+
+
+
+
+
+QUE_1305_A2
+
+
+
+
+
+QUE_1305_A3
+
+
+
+
+
+QUE_1305_A4
+
+
+
+
+
+QUE_1305_A5
+
+
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_1306_A1
+
+
+
+
+
+QUE_1306_A2
+
+
+
+
+
+QUE_1306_A3
+
+
+
+
+
+QUE_1306_A4
+
+
+
+
+
+QUE_1306_A5
+
+
+
+
+
+
+-
+
+
+ƒ0=11.9 Hz. Determine the minimum sampling rate ƒs so that no aliasing occurs. The units of ƒs are samples per second. The con2dis GUI allows you to change ƒs with a slider, so you can experiment with different values, but the GUI shows integers. Try this with two different phases, φ=0 and φ=2 rads, and note the different outputs. Once you learn the answer, you must justify your response by citing a theorem or property about sampling.]]>
+
+
+
+
+
+Slightly larger than ƒs = 5.8 Hz]]>
+
+
+
+
+Slightly larger than ƒs = 0.8 Hz]]>
+
+
+
+
+Slightly larger than ƒs = 25.9 Hz]]>
+
+
+
+
+Slightly larger than ƒs = 23.8 Hz]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2034_A1
+
+0
+
+
+
+QUE_2034_A2
+
+0
+
+
+
+QUE_2034_A3
+
+0
+
+
+
+QUE_2034_A4
+
+100
+
+
+
+
+-
+
+
+ƒ0=9 Hz and the input phase to φ = 2 rads. Determine the locations of the spectral lines in the spectrum of the discrete-time signal (middle plot of the bottom row) when the sampling rate is ƒs=20 Hz. Calculate
for the two spectral lines that lie in the range -π≤
≤π. Explain how you calculated the two values for
, i.e., give the formula for
in terms of ƒ0 and ƒs.]]>
+
+
+
+
+
+
= ± 0.1π]]>
+
+
+
+
+
= ± 1.7π]]>
+
+
+
+
+
= ± 0.9π]]>
+
+
+
+
+
= ± 1.8π]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2035_A1
+
+0
+
+
+
+QUE_2035_A2
+
+0
+
+
+
+QUE_2035_A3
+
+100
+
+
+
+QUE_2035_A4
+
+0
+
+
+
+
+-
+
+
+-π≤
≤π; these are the blue lines in the middle plot of the bottom row. Give the magnitude and phase of both complex amplitudes, i.e., polar form. Explain how you get these.]]>
+
+
+
+
+
+ak = 0.5ej2]]>
+
+
+
+
+ak = 0.5]]>
+
+
+
+
+ak = ej2]]>
+
+
+
+
+ak = 0.5ej]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2036_A1
+
+100
+
+
+
+QUE_2036_A2
+
+0
+
+
+
+QUE_2036_A3
+
+0
+
+
+
+QUE_2036_A4
+
+0
+
+
+
+
+-
+
+
+Aliasing: Set the input frequency to ƒ0=13 Hz and the input phase is φ=2 rads. Use the GUI to find the sampling rate ƒs for which the output signal y(t) is DC, i.e., a constant. Using this ƒs, calculate
=2π(ƒ0/ƒs). Then explain how you get zero frequency from this value of
.]]>
+
+
+
+
+
+ƒs = 20]]>
+
+
+
+
+ƒs = 13]]>
+
+
+
+
+ƒs = 10]]>
+
+
+
+
+ƒs = 26]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2037_A1
+
+0
+
+
+
+QUE_2037_A2
+
+100
+
+
+
+QUE_2037_A3
+
+0
+
+
+
+QUE_2037_A4
+
+0
+
+
+
+
+-
+
+
+Aliasing: Set the input frequency to ƒ0=23 Hz and the input phase to φ=2 rads. Write down the formula for the output signal when ƒs=20 Hz. Note: y(t) can be found in the GUI.]]>
+
+
+
+
+
+y(t) = cos(2π(23)t + 2)]]>
+
+
+
+
+y(t) = cos(6πt - 2)]]>
+
+
+
+
+y(t) = cos(2π(23)t - 2)]]>
+
+
+
+
+y(t) = cos(6πt + 2)]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2038_A1
+
+0
+
+
+
+QUE_2038_A2
+
+0
+
+
+
+QUE_2038_A3
+
+0
+
+
+
+QUE_2038_A4
+
+100
+
+
+
+
+-
+
+
+Folding: Set the input frequency to ƒ0=17 Hz and the input phase to φ=2 rads. Write down the formula for the output signal when ƒs=20 Hz.]]>
+
+
+
+
+
+y(t) = cos(2π(23)t + 2)]]>
+
+
+
+
+y(t) = cos(2π(23)t - 2)]]>
+
+
+
+
+y(t) = cos(6πt + 2)]]>
+
+
+
+
+y(t) = cos(6πt - 2)]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2039_A1
+
+0
+
+
+
+QUE_2039_A2
+
+100
+
+
+
+QUE_2039_A3
+
+0
+
+
+
+QUE_2039_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_2117_A1
+
+
+
+
+
+QUE_2117_A2
+
+
+
+
+
+QUE_2117_A3
+
+
+
+
+
+QUE_2117_A4
+
+
+
+
+
+QUE_2117_A5
+
+
+
+
+
+
+-
+
+
+7 - 5j]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_2118_A1
+
+0
+
+
+
+QUE_2118_A2
+
+0
+
+
+
+QUE_2118_A3
+
+0
+
+
+
+QUE_2118_A4
+
+100
+
+
+
+
+-
+
+
+i(1-i)? ]]>
+
+
+
+
+
+-1 + i]]>
+
+
+
+
+1 + i]]>
+
+
+
+
+1 - i]]>
+
+
+
+
+-1 - i]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2119_A1
+
+0
+
+
+
+QUE_2119_A2
+
+0
+
+
+
+QUE_2119_A3
+
+100
+
+
+
+QUE_2119_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_2120_A1
+
+0
+
+
+
+QUE_2120_A2
+
+100
+
+
+
+QUE_2120_A3
+
+0
+
+
+
+QUE_2120_A4
+
+0
+
+
+
+
+-
+
+
+(2-i)/(3+2i)]]>
+
+
+
+
+
+5 - 7/13i]]>
+
+
+
+
+4/13 + 7/13i]]>
+
+
+
+
+4/13 - 7/13i]]>
+
+
+
+
+5 + 7/13i]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2121_A1
+
+0
+
+
+
+QUE_2121_A2
+
+0
+
+
+
+QUE_2121_A3
+
+100
+
+
+
+QUE_2121_A4
+
+0
+
+
+
+
+-
+
+
+[2{ei(-5π/6)}]30]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_2122_A1
+
+100
+
+
+
+QUE_2122_A2
+
+0
+
+
+
+QUE_2122_A3
+
+0
+
+
+
+QUE_2122_A4
+
+0
+
+
+
+
+-
+
+
+z5 = -1]]>
+
+
+
+
+
+j10π/7]]>
+
+
+
+
+2π]]>
+
+
+
+
+j5π/7]]>
+
+
+
+
+-j5π/7]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2123_A1
+
+100
+
+
+
+QUE_2123_A2
+
+0
+
+
+
+QUE_2123_A3
+
+0
+
+
+
+QUE_2123_A4
+
+0
+
+
+
+
+-
+
+
+xx = real( exp( -j*1000*pi.*tt.^2 + j*6000*pi.*tt + j*1000 ) );Which spectrogram is described by this signal?
]]>
+
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2124_A1
+
+0
+
+
+
+QUE_2124_A2
+
+0
+
+
+
+QUE_2124_A3
+
+0
+
+
+
+QUE_2124_A4
+
+100
+
+
+
+
+-
+
+
+fundamental frequency for the periodic signal whose spectrogram is shown below:]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_2125_A1
+
+0
+
+
+
+QUE_2125_A2
+
+100
+
+
+
+QUE_2125_A3
+
+0
+
+
+
+QUE_2125_A4
+
+0
+
+
+
+QUE_2125_A5
+
+0
+
+
+
+
+-
+
+
+s(t), the spectrogram shows
horizontal lines at the following set of frequencies
{ 400, 800, 1000, 2000, 2500 } Hz.Determine the fundamental period of s(t).]]>
+
+
+
+
+
+
+o = 10 msec]]>
+
+
+
+
+o = 5 msec]]>
+
+
+
+
+o = 2.5 msec]]>
+
+
+
+
+o = 2 msec]]>
+
+
+
+
+o = 1 msec]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2126_A1
+
+0
+
+
+
+QUE_2126_A2
+
+100
+
+
+
+QUE_2126_A3
+
+0
+
+
+
+QUE_2126_A4
+
+0
+
+
+
+QUE_2126_A5
+
+100
+
+
+
+
+-
+
+
+s(t) = π cos( 5 cos( 5πt ) )Determine the fundamental period of this signal, i.e., the shortest period.]]>
+
+
+
+
+
+o = 0.04]]>
+
+
+
+
+o = 0.1]]>
+
+
+
+
+o = 0.25]]>
+
+
+
+
+o = 0.4]]>
+
+
+
+
+o = 0.5]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2127_A1
+
+0
+
+
+
+QUE_2127_A2
+
+0
+
+
+
+QUE_2127_A3
+
+0
+
+
+
+QUE_2127_A4
+
+100
+
+
+
+QUE_2127_A5
+
+0
+
+
+
+
+-
+
+
+
x[n] = δ[n-1] + δ[n-2]
plot is passed through a first-difference FIR filter, what is the output?]]>
+
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2129_A1
+
+100
+
+
+
+QUE_2129_A2
+
+0
+
+
+
+QUE_2129_A3
+
+0
+
+
+
+QUE_2129_A4
+
+0
+
+
+
+
+-
+
+
+x[n] = δ[n-1] + δ[n-2] an FIR filter outputs the follwing signal.
Determine the filter coefficients for this system.
]]>
+
+
+
+
+
+
+{1 , -1}]]>
+
+
+
+
+{1 , 0}]]>
+
+
+
+
+{1/3 , 1/3 , 1/3}]]>
+
+
+
+
+{1 , -1 , 1}]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2130_A1
+
+100
+
+
+
+QUE_2130_A2
+
+0
+
+
+
+QUE_2130_A3
+
+100
+
+
+
+QUE_2130_A4
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+factor]]>
+
+
+
+
+roots]]>
+
+
+
+
+poly]]>
+
+
+
+
+makepoly]]>
+
+
+
+
+zeros]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2131_A1
+
+0
+
+
+
+QUE_2131_A2
+
+100
+
+
+
+QUE_2131_A3
+
+0
+
+
+
+QUE_2131_A4
+
+0
+
+
+
+QUE_2131_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+factor]]>
+
+
+
+
+roots]]>
+
+
+
+
+poly]]>
+
+
+
+
+makepoly]]>
+
+
+
+
+zeros]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2132_A1
+
+0
+
+
+
+QUE_2132_A2
+
+0
+
+
+
+QUE_2132_A3
+
+100
+
+
+
+QUE_2132_A4
+
+0
+
+
+
+QUE_2132_A5
+
+0
+
+
+
+
+-
+
+
+1 + z-4 ]]>
+
+
+
+
+
+1, j, -1, -j]]>
+
+
+
+
+ejπ/4, ej3π/4, e-jπ/4, e-j3π/4]]>
+
+
+
+
+-1, -1, -1, -1]]>
+
+
+
+
+1, 1, 1, 1]]>
+
+
+
+
+j, j, j, j]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_2133_A1
+
+0
+
+
+
+QUE_2133_A2
+
+100
+
+
+
+QUE_2133_A3
+
+0
+
+
+
+QUE_2133_A4
+
+0
+
+
+
+QUE_2133_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_2134_A1
+
+100
+
+
+
+QUE_2134_A2
+
+0
+
+
+
+QUE_2134_A3
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_2135_A1
+
+0
+
+
+
+QUE_2135_A2
+
+0
+
+
+
+QUE_2135_A3
+
+0
+
+
+
+QUE_2135_A4
+
+100
+
+
+
+QUE_2135_A5
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_2136_A1
+
+100
+
+
+
+QUE_2136_A2
+
+0
+
+
+
+QUE_2136_A3
+
+0
+
+
+
+QUE_2136_A4
+
+0
+
+
+
+QUE_2136_A5
+
+0
+
+
+
+QUE_2136_A6
+
+0
+
+
+
+
+
+
+
diff --git a/test/unit/qti_import_test.rb b/test/unit/qti_import_test.rb
index 4281306..fd4f00a 100644
--- a/test/unit/qti_import_test.rb
+++ b/test/unit/qti_import_test.rb
@@ -4,28 +4,33 @@
require 'test_helper'
class QTImportTest < ActiveSupport::TestCase
- test "1_question" do
- import = QTImport.new('/home/railsoer/Documents/spqr1.xml','SPQR')
- assert_nothing_raised(import)
+ test "1_question" do
+ assert_nothing_raised do
+ QTImport.new("#{::Rails.root}/test/fixtures/files/spqr1.xml",'SPQR')
+ end
end
- test "2_question" do
- import = QTImport.new('home/railsoer/Documents/spqr2.xml','SPQR')
- assert_nothing_raised(import)
+ test "2_question" do
+ assert_nothing_raised do
+ QTImport.new("#{::Rails.root}/test/fixtures/files/spqr2.xml",'SPQR')
+ end
end
test "5_question" do
- import = QTImport.new('home/railsoer/Documents/spqr3.xml','SPQR')
- assert_nothing_raised(import)
+ assert_nothing_raised do
+ QTImport.new("#{::Rails.root}/test/fixtures/files/spqr3.xml",'SPQR')
+ end
end
test "25_question" do
- import = QTImport.new('home/railsoer/Documents/spqr4.xml','SPQR')
- assert_nothing_raised(import)
+ assert_nothing_raised do
+ QTImport.new("#{::Rails.root}/test/fixtures/files/spqr4.xml",'SPQR')
+ end
end
test "all_question" do
- import = QTImport.new('home/railsoer/Documents/spqr_original.xml','SPQR')
- assert_nothing_raised(import)
+ assert_nothing_raised do
+ QTImport.new("#{::Rails.root}/test/fixtures/files/spqr_original.xml",'SPQR')
+ end
end
end
From 78796c6f393851e296aeb8f36c52423337451c75 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sun, 27 May 2012 11:21:01 -0400
Subject: [PATCH 26/60] The import class is done. Everything works and the
structure has been set up so that it can easily be used by a controller.
---
lib/qti_import.rb | 155 +++++++++++++++--------------------
test/unit/qti_import_test.rb | 35 ++++++--
2 files changed, 97 insertions(+), 93 deletions(-)
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index 8a46519..3fb685a 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -4,67 +4,30 @@
require 'open-uri'
require 'spqr_parser.rb'
-module ImportQuestions
- def openfile(filename)
- f = File.open(filename)
- doc = Nokogiri::XML(f)
+class QTImport
+ attr_reader :filename, :content_type, :parser, :transformer
+
+private
+ def self.add_questions(project,questions)
+ for a in 0..(questions.length-1)
+ project.add_question!(questions[a])
+ end
end
- def savefile(document)
- a = File.open("/home/railsoer/Documents/values.txt",'w') {|f| f.write(document)}
+ def self.choose_import(content_type)
+ if (content_type == 'SPQR')
+ a = SPQRParser.new
+ b = SPQRTransform.new
+ end
+ return a, b
end
- def createproject
+ def self.createproject
a = Project.create(:name => 'Import')
# a.add_member!(current_user)
end
-end
-
-#For the SPQR content, it seems that a series of questions are embedded
-#within each tag. As such, we search and save only
-#content within each tag and "discard" the rest.
-module GetContent
- def iterate_items(document)
- items = document.xpath('//item')
- end
-#Why is this such a roundabout way of getting the question? Well, the
-#questions and answer choices have the same tag, with the answer choices
-#nested more deeply. I can do a specific search for the path the answer
-#choices are on and get those back. But, I can't do a more general
-#search and get only questions back. Each time it returns the questions
-#and answer choices, in sequence, but this is a problem, especially since
-#the number of answer choices per question varies widely. Hence the
-#roundabout method.
- def get_questions(content,parser,transformer)
- ques = Array.new
- ques_id = Array.new
- questions = Array.new
- for z in 0..(content.length-1)
- y = content[z]
- ques_num = y.attributes["ident"].value
- ques_id << ques_num
- x = y.xpath('//presentation')
- w = x[0].children.children.children
- text = w[0].content
- v = parser.parse(text)
- ques1 = transformer.apply(v)
- ques << ques1
- end
- answers = get_answers(content,parser,transformer,ques_num)
- for a in 0..(ques.length-1)
- b = Comment.new(:message => ques_id[a])
- q = SimpleQuestion.new(:content => ques[a])
- q.comment_thread = b.comment_thread
- for i in 0..(answers.length-1)
- q.answer_choices << answers[i]
- end
- q.save!
- questions << q
- end
- return questions
- end
- def get_answers(content,parser,transformer,id_num)
+ def self.get_answers(content,parser,transformer,id_num)
#Find only the relevant answer choices, using the question id number
answers = Array.new
z = content.xpath('//presentation//response_lid//response_label')
@@ -76,7 +39,7 @@ def get_answers(content,parser,transformer,id_num)
end
end
choices = Array.new
- credit = get_credit(content,id_num)
+ credit = self.get_credit(content,id_num)
for a in 0..(answers.length-1)
b = answers[a].children.children.children
text = b[0].content
@@ -88,7 +51,7 @@ def get_answers(content,parser,transformer,id_num)
return choices
end
- def get_credit(content,id_num)
+ def self.get_credit(content,id_num)
numbers = Array.new
points = Array.new
a = content.xpath('//resprocessing//respcondition')
@@ -105,49 +68,65 @@ def get_credit(content,id_num)
k = (j.content).to_f
points << k
end
- credits = normalize(points)
+ credits = self.normalize(points)
end
- def normalize(array)
+#Why is this such a roundabout way of getting the question? Well, the
+#questions and answer choices have the same tag, with the answer choices
+#nested more deeply. I can do a specific search for the path the answer
+#choices are on and get those back. But, I can't do a more general
+#search and get only questions back. Each time it returns the questions
+#and answer choices, in sequence, but this is a problem, especially since
+#the number of answer choices per question varies widely. Hence the
+#roundabout method.
+ def self.get_questions(content,parser,transformer)
+ ques = Array.new
+ ques_id = Array.new
+ questions = Array.new
+ for z in 0..(content.length-1)
+ y = content[z]
+ ques_num = y.attributes["ident"].value
+ ques_id << ques_num
+ x = y.xpath('//presentation')
+ w = x[0].children.children.children
+ text = w[0].content
+ v = parser.parse(text)
+ ques1 = transformer.apply(v)
+ ques << ques1
+ end
+ answers = self.get_answers(content,parser,transformer,ques_num)
+ for a in 0..(ques.length-1)
+ b = Comment.new(:message => ques_id[a])
+ q = SimpleQuestion.new(:content => ques[a])
+ q.comment_thread = b.comment_thread
+ for i in 0..(answers.length-1)
+ q.answer_choices << answers[i]
+ end
+ q.save!
+ questions << q
+ end
+ return questions
+ end
+
+#For the SPQR content, it seems that a series of questions are embedded
+#within each tag. As such, we search and save only
+#content within each tag and "discard" the rest.
+ def self.iterate_items(document)
+ items = document.xpath('//item')
+ end
+
+ def self.normalize(array)
a = array.max
for z in 0..(array.length-1)
array[z] = array[z]/a
end
return array
end
-end
-module AddQuestions
- def add_questions(project,questions)
- for a in 0..(questions.length-1)
- project.add_question!(questions[a])
- end
+ def self.openfile(filename)
+ f = File.open(filename)
+ doc = Nokogiri::XML(f)
end
-end
-class QTImport
- include ImportQuestions
- include GetContent
- include AddQuestions
- attr_reader :filename, :content_type, :parser, :transformer
-
- def initialize(filename, content_type)
- @filename = filename
- @content_type = content_type
- document = openfile(filename)
- import_project = createproject
- parser, transformer = choose_import(content_type)
- content = iterate_items(document)
- questions = get_questions(content,parser,transformer)
- add_questions(import_project,questions)
- end
-private
- def choose_import(content_type)
- if (content_type == 'SPQR')
- a = SPQRParser.new
- b = SPQRTransform.new
- end
- return a, b
- end
end
\ No newline at end of file
diff --git a/test/unit/qti_import_test.rb b/test/unit/qti_import_test.rb
index fd4f00a..f6c02f0 100644
--- a/test/unit/qti_import_test.rb
+++ b/test/unit/qti_import_test.rb
@@ -6,31 +6,56 @@
class QTImportTest < ActiveSupport::TestCase
test "1_question" do
assert_nothing_raised do
- QTImport.new("#{::Rails.root}/test/fixtures/files/spqr1.xml",'SPQR')
+ document = QTImport.openfile("#{::Rails.root}/test/fixtures/files/spqr1.xml")
+ parser, transformer = QTImport.choose_import('SPQR')
+ content = QTImport.iterate_items(document)
+ questions = QTImport.get_questions(content,parser,transformer)
+ project = QTImport.createproject
+ QTImport.add_questions(project,questions)
end
end
test "2_question" do
assert_nothing_raised do
- QTImport.new("#{::Rails.root}/test/fixtures/files/spqr2.xml",'SPQR')
+ document = QTImport.openfile("#{::Rails.root}/test/fixtures/files/spqr2.xml")
+ parser, transformer = QTImport.choose_import('SPQR')
+ content = QTImport.iterate_items(document)
+ questions = QTImport.get_questions(content,parser,transformer)
+ project = QTImport.createproject
+ QTImport.add_questions(project,questions)
end
end
test "5_question" do
assert_nothing_raised do
- QTImport.new("#{::Rails.root}/test/fixtures/files/spqr3.xml",'SPQR')
+ document = QTImport.openfile("#{::Rails.root}/test/fixtures/files/spqr3.xml")
+ parser, transformer = QTImport.choose_import('SPQR')
+ content = QTImport.iterate_items(document)
+ questions = QTImport.get_questions(content,parser,transformer)
+ project = QTImport.createproject
+ QTImport.add_questions(project,questions)
end
end
test "25_question" do
assert_nothing_raised do
- QTImport.new("#{::Rails.root}/test/fixtures/files/spqr4.xml",'SPQR')
+ document = QTImport.openfile("#{::Rails.root}/test/fixtures/files/spqr4.xml")
+ parser, transformer = QTImport.choose_import('SPQR')
+ content = QTImport.iterate_items(document)
+ questions = QTImport.get_questions(content,parser,transformer)
+ project = QTImport.createproject
+ QTImport.add_questions(project,questions)
end
end
test "all_question" do
assert_nothing_raised do
- QTImport.new("#{::Rails.root}/test/fixtures/files/spqr_original.xml",'SPQR')
+ document = QTImport.openfile("#{::Rails.root}/test/fixtures/files/spqr_original.xml")
+ parser, transformer = QTImport.choose_import('SPQR')
+ content = QTImport.iterate_items(document)
+ questions = QTImport.get_questions(content,parser,transformer)
+ project = QTImport.createproject
+ QTImport.add_questions(project,questions)
end
end
end
From 961cb954f54427be50064001f389ad7602f40933 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sun, 27 May 2012 16:51:51 -0400
Subject: [PATCH 27/60] So, I've created a view that contains a form to enter
the information for importing an XML file with questions. Right now, it just
has a drop-down menu to select the type of formatting the questions are in.
---
app/controllers/qt_import_controller.rb | 9 +++++++++
app/helpers/qt_import_helper.rb | 2 ++
app/views/qt_import/_form.html.erb | 13 +++++++++++++
app/views/qt_import/index.html.erb | 4 ++++
app/views/qt_import/new.html.erb | 4 ++++
config/routes.rb | 4 ++++
db/schema.rb | 9 ++++++++-
lib/qti_import.rb | 8 +++++++-
8 files changed, 51 insertions(+), 2 deletions(-)
create mode 100644 app/controllers/qt_import_controller.rb
create mode 100644 app/helpers/qt_import_helper.rb
create mode 100644 app/views/qt_import/_form.html.erb
create mode 100644 app/views/qt_import/index.html.erb
create mode 100644 app/views/qt_import/new.html.erb
diff --git a/app/controllers/qt_import_controller.rb b/app/controllers/qt_import_controller.rb
new file mode 100644
index 0000000..82e4922
--- /dev/null
+++ b/app/controllers/qt_import_controller.rb
@@ -0,0 +1,9 @@
+class QtImportController < ApplicationController
+ def new
+ @content_types = QTImport.content_types
+ end
+
+ def create
+
+ end
+end
diff --git a/app/helpers/qt_import_helper.rb b/app/helpers/qt_import_helper.rb
new file mode 100644
index 0000000..4a5d380
--- /dev/null
+++ b/app/helpers/qt_import_helper.rb
@@ -0,0 +1,2 @@
+module QtImportHelper
+end
diff --git a/app/views/qt_import/_form.html.erb b/app/views/qt_import/_form.html.erb
new file mode 100644
index 0000000..7258d5f
--- /dev/null
+++ b/app/views/qt_import/_form.html.erb
@@ -0,0 +1,13 @@
+<%= form_tag :url => 'import/qti' do %>
+ <%= label_tag "File", "File" %>
+
+ <%= text_field_tag :File %>
+
+
+ <%= label_tag "name", "Content Type" %>
+
+ <%= select_tag :content_type, options_for_select(@content_types).html_safe, :include_blank => true %>
+
+
+ <%= submit_tag "Import" %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/qt_import/index.html.erb b/app/views/qt_import/index.html.erb
new file mode 100644
index 0000000..7ef2a53
--- /dev/null
+++ b/app/views/qt_import/index.html.erb
@@ -0,0 +1,4 @@
+Import Questions
+ Note: All files uploaded MUST be XML files.
+
+<%= render 'form' %>
diff --git a/app/views/qt_import/new.html.erb b/app/views/qt_import/new.html.erb
new file mode 100644
index 0000000..7ef2a53
--- /dev/null
+++ b/app/views/qt_import/new.html.erb
@@ -0,0 +1,4 @@
+Import Questions
+ Note: All files uploaded MUST be XML files.
+
+<%= render 'form' %>
diff --git a/config/routes.rb b/config/routes.rb
index a06f9e8..9162642 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -3,6 +3,10 @@
Quadbase::Application.routes.draw do
+ get "import/qti/new", :to => 'qt_import#new'
+
+ post "import/qti", :to => 'qt_import#create'
+
namespace :admin do
resources :logic_libraries do
resources :logic_library_versions, :shallow => true
diff --git a/db/schema.rb b/db/schema.rb
index 3f91387..94644e6 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120424015013) do
+ActiveRecord::Schema.define(:version => 20120527160608) do
create_table "announcements", :force => true do |t|
t.integer "user_id"
@@ -177,6 +177,13 @@
t.datetime "updated_at"
end
+ create_table "question_imports", :force => true do |t|
+ t.string "File"
+ t.string "ContentType"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "question_parts", :force => true do |t|
t.integer "multipart_question_id"
t.integer "child_question_id"
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index 3fb685a..3256a12 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -5,9 +5,15 @@
require 'spqr_parser.rb'
class QTImport
+
+ @@content_types = ['SPQR']
+
attr_reader :filename, :content_type, :parser, :transformer
-private
+ def self.content_types
+ @@content_types
+ end
+
def self.add_questions(project,questions)
for a in 0..(questions.length-1)
project.add_question!(questions[a])
From 6078baec53c8039560c3e1806df73542b9ddeaf1 Mon Sep 17 00:00:00 2001
From: jrb6
Date: Mon, 4 Jun 2012 11:20:04 -0500
Subject: [PATCH 28/60] Added extra line to allow clicking outside of modal
dialog
---
app/views/dev/toolbox.js.erb | 3 +++
app/views/help/topic.js.erb | 5 ++++-
app/views/project_questions/attribution.js.erb | 3 +++
app/views/questions/preview.js.erb | 3 +++
app/views/questions/quickview.js.erb | 3 +++
app/views/users/action_new.js.erb | 5 ++++-
6 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/app/views/dev/toolbox.js.erb b/app/views/dev/toolbox.js.erb
index 1d45066..e12cdd8 100644
--- a/app/views/dev/toolbox.js.erb
+++ b/app/views/dev/toolbox.js.erb
@@ -7,3 +7,6 @@ refresh_buttons();
refresh_datetime_pickers();
$("#dev_toolbox_dialog").dialog('open');
+$('.ui-widget-overlay').live("click",function(){
+ $("#dev_toolbox_dialog").dialog("close");
+ });
diff --git a/app/views/help/topic.js.erb b/app/views/help/topic.js.erb
index a4aee2b..4ecbbd6 100644
--- a/app/views/help/topic.js.erb
+++ b/app/views/help/topic.js.erb
@@ -18,4 +18,7 @@ $("#help_dialog").dialog({
<%= reload_mathjax("help_dialog") if @options[:include_mathjax] %>
$("#help_dialog").dialog('open');
-$("#help_dialog").scrollTop(0);
\ No newline at end of file
+$('.ui-widget-overlay').live("click",function(){
+ $("#help_dialog").dialog("close");
+ });
+$("#help_dialog").scrollTop(0);
diff --git a/app/views/project_questions/attribution.js.erb b/app/views/project_questions/attribution.js.erb
index 4649ebc..ebf8633 100644
--- a/app/views/project_questions/attribution.js.erb
+++ b/app/views/project_questions/attribution.js.erb
@@ -6,3 +6,6 @@ $("#attribution_dialog").html("<%= escape_javascript(
:locals => {:question_ids => @question_ids}) %>");
$("#attribution_dialog").dialog('open');
+$('.ui-widget-overlay').live("click",function(){
+ $("#attribution_dialog").dialog("close");
+ });
diff --git a/app/views/questions/preview.js.erb b/app/views/questions/preview.js.erb
index 3dd3f26..4b6dbc9 100644
--- a/app/views/questions/preview.js.erb
+++ b/app/views/questions/preview.js.erb
@@ -7,6 +7,9 @@
<%= reload_mathjax("preview_dialog") %>
$("#preview_dialog").dialog('open');
+ $('.ui-widget-overlay').live("click",function(){
+ $("#preview_dialog").dialog("close");
+ });
<% else %>
// Submit the form so that the error messages display nicely with formatting
// around the offending entries (use the trigger approach so we don't get
diff --git a/app/views/questions/quickview.js.erb b/app/views/questions/quickview.js.erb
index a6978c3..de5f847 100644
--- a/app/views/questions/quickview.js.erb
+++ b/app/views/questions/quickview.js.erb
@@ -6,3 +6,6 @@ $("#quickview_dialog").html("<%= escape_javascript(render :partial => "show",
<%= reload_mathjax("quickview_dialog") %>
$("#quickview_dialog").dialog('open');
+$('.ui-widget-overlay').live("click",function(){
+ $("#quickview_dialog").dialog("close");
+ });
diff --git a/app/views/users/action_new.js.erb b/app/views/users/action_new.js.erb
index ab22a75..55a4ba2 100644
--- a/app/views/users/action_new.js.erb
+++ b/app/views/users/action_new.js.erb
@@ -11,4 +11,7 @@ $("#user_action_dialog").dialog({
width:600,
buttons: { "Close": function() { $(this).dialog("close"); }},
open: function(event, ui) { $("#text_query").val(''); $("#selected_type").val(''); }
-});
\ No newline at end of file
+});
+$('.ui-widget-overlay').live("click",function(){
+ $("#user_action_dialog").dialog('close');
+ });
From a2ad4f6753971ad4f9bf59cb1accee774ff27753 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Wed, 13 Jun 2012 16:27:23 -0400
Subject: [PATCH 29/60] Added gem Carrierwave to handle file uploads.
---
Gemfile | 2 ++
Gemfile.lock | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/Gemfile b/Gemfile
index 1526cda..ff58df6 100644
--- a/Gemfile
+++ b/Gemfile
@@ -8,6 +8,8 @@ gem 'rake', '0.8.7'
gem 'nokogiri'
+gem 'carrierwave'
+
# Deploy with Capistrano
gem 'capistrano'
diff --git a/Gemfile.lock b/Gemfile.lock
index 4f78d0d..c0bfaa0 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -47,6 +47,8 @@ GEM
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.0.0)
+ carrierwave (0.5.8)
+ activesupport (~> 3.0)
columnize (0.3.4)
devise (1.2.1)
bcrypt-ruby (~> 2.1.2)
@@ -95,6 +97,7 @@ GEM
net-ssh-gateway (1.0.1)
net-ssh (>= 1.99.1)
nokogiri (1.5.3)
+ nokogiri (1.5.3-x86-mingw32)
orm_adapter (0.0.4)
paperclip (2.3.11)
activerecord (>= 2.3.0)
@@ -167,6 +170,7 @@ DEPENDENCIES
acts-as-taggable-on (~> 2.1.0)
bullring (~> 0.7.4)
capistrano
+ carrierwave
devise
execjs
factory_girl_rails (< 2.0)
From 26e9bfef5a7856149084179126ecdd0af5ecad94 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Wed, 13 Jun 2012 16:31:04 -0400
Subject: [PATCH 30/60] All of the files associated with creating the form to
upload files, choose content, and import the questions.
---
app/controllers/qt_import_controller.rb | 17 ++++++-
app/models/file_upload.rb | 7 +++
app/uploaders/question_uploader.rb | 48 +++++++++++++++++++
app/views/qt_import/_form.html.erb | 4 +-
app/views/qt_import/create.html.erb | 3 ++
.../20120613190208_create_file_uploads.rb | 12 +++++
db/schema.rb | 7 ++-
lib/qti_import.rb | 6 +--
test/functional/qt_import_controller_test.rb | 9 ++++
test/unit/file_upload_test.rb | 8 ++++
test/unit/helpers/qt_import_helper_test.rb | 4 ++
11 files changed, 118 insertions(+), 7 deletions(-)
create mode 100644 app/models/file_upload.rb
create mode 100644 app/uploaders/question_uploader.rb
create mode 100644 app/views/qt_import/create.html.erb
create mode 100644 db/migrate/20120613190208_create_file_uploads.rb
create mode 100644 test/functional/qt_import_controller_test.rb
create mode 100644 test/unit/file_upload_test.rb
create mode 100644 test/unit/helpers/qt_import_helper_test.rb
diff --git a/app/controllers/qt_import_controller.rb b/app/controllers/qt_import_controller.rb
index 82e4922..b3265b8 100644
--- a/app/controllers/qt_import_controller.rb
+++ b/app/controllers/qt_import_controller.rb
@@ -4,6 +4,21 @@ def new
end
def create
-
+ f = FileUpload.new
+ f.importfile.cache!(@file)
+ storage = f.importfile.cache_name
+ document = QTImport.openfile(f.retrieve_from_cache!(storage))
+ parser, transformer = QTImport.choose(@content_types)
+ content = QTImport.iterate_items(document)
+ questions = QTImport.get_questions(content,parser,transformer)
+ project = QTImport.createproject(@current_user)
+ QTImport.add_questions(project,questions)
+
+ render 'create'
+
+ # rescue
+ # render :text => "Sorry, there was a problem with importing your questions."
+ # redirect_to :new
+ # end
end
end
diff --git a/app/models/file_upload.rb b/app/models/file_upload.rb
new file mode 100644
index 0000000..7a61681
--- /dev/null
+++ b/app/models/file_upload.rb
@@ -0,0 +1,7 @@
+class FileUpload < ActiveRecord::Base
+ mount_uploader :importfile, QuestionUploader
+
+ def extension_white_list
+ %w(xml)
+ end
+end
diff --git a/app/uploaders/question_uploader.rb b/app/uploaders/question_uploader.rb
new file mode 100644
index 0000000..48391f8
--- /dev/null
+++ b/app/uploaders/question_uploader.rb
@@ -0,0 +1,48 @@
+# encoding: utf-8
+
+class QuestionUploader < CarrierWave::Uploader::Base
+
+ # Include RMagick or MiniMagick support:
+ # include CarrierWave::RMagick
+ # include CarrierWave::MiniMagick
+
+ # Choose what kind of storage to use for this uploader:
+ storage :file
+ # storage :fog
+
+ # Override the directory where uploaded files will be stored.
+ # This is a sensible default for uploaders that are meant to be mounted:
+ def store_dir
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
+ end
+
+ # Provide a default URL as a default if there hasn't been a file uploaded:
+ # def default_url
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
+ # end
+
+ # Process files as they are uploaded:
+ # process :scale => [200, 300]
+ #
+ # def scale(width, height)
+ # # do something
+ # end
+
+ # Create different versions of your uploaded files:
+ # version :thumb do
+ # process :scale => [50, 50]
+ # end
+
+ # Add a white list of extensions which are allowed to be uploaded.
+ # For images you might use something like this:
+ # def extension_white_list
+ # %w(jpg jpeg gif png)
+ # end
+
+ # Override the filename of the uploaded files:
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
+ # def filename
+ # "something.jpg" if original_filename
+ # end
+
+end
diff --git a/app/views/qt_import/_form.html.erb b/app/views/qt_import/_form.html.erb
index 7258d5f..f037c9a 100644
--- a/app/views/qt_import/_form.html.erb
+++ b/app/views/qt_import/_form.html.erb
@@ -1,7 +1,7 @@
-<%= form_tag :url => 'import/qti' do %>
+<%= form_tag :url => 'import/qti', :method => 'post', :multipart => true, do %>
<%= label_tag "File", "File" %>
- <%= text_field_tag :File %>
+ <%= file_field_tag :file %>
<%= label_tag "name", "Content Type" %>
diff --git a/app/views/qt_import/create.html.erb b/app/views/qt_import/create.html.erb
new file mode 100644
index 0000000..3e48caa
--- /dev/null
+++ b/app/views/qt_import/create.html.erb
@@ -0,0 +1,3 @@
+Your questions were successfully imported!
+
+They have been added to a new project named "Import", and are now unpublished questions.
\ No newline at end of file
diff --git a/db/migrate/20120613190208_create_file_uploads.rb b/db/migrate/20120613190208_create_file_uploads.rb
new file mode 100644
index 0000000..6736a71
--- /dev/null
+++ b/db/migrate/20120613190208_create_file_uploads.rb
@@ -0,0 +1,12 @@
+class CreateFileUploads < ActiveRecord::Migration
+ def self.up
+ create_table :file_uploads do |t|
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :file_uploads
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 94644e6..879b723 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120527160608) do
+ActiveRecord::Schema.define(:version => 20120613190208) do
create_table "announcements", :force => true do |t|
t.integer "user_id"
@@ -82,6 +82,11 @@
t.datetime "updated_at"
end
+ create_table "file_uploads", :force => true do |t|
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "licenses", :force => true do |t|
t.string "short_name"
t.string "long_name"
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index 3256a12..b541c80 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -28,9 +28,9 @@ def self.choose_import(content_type)
return a, b
end
- def self.createproject
+ def self.createproject(current_user)
a = Project.create(:name => 'Import')
- # a.add_member!(current_user)
+ a.add_member!(current_user)
end
def self.get_answers(content,parser,transformer,id_num)
@@ -135,4 +135,4 @@ def self.openfile(filename)
end
-end
\ No newline at end of file
+end
diff --git a/test/functional/qt_import_controller_test.rb b/test/functional/qt_import_controller_test.rb
new file mode 100644
index 0000000..62367ae
--- /dev/null
+++ b/test/functional/qt_import_controller_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class QtImportControllerTest < ActionController::TestCase
+
+ test "should_show_form" do
+ get :new
+ assert_response :success
+ end
+end
diff --git a/test/unit/file_upload_test.rb b/test/unit/file_upload_test.rb
new file mode 100644
index 0000000..0595d1a
--- /dev/null
+++ b/test/unit/file_upload_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class FileUploadTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
diff --git a/test/unit/helpers/qt_import_helper_test.rb b/test/unit/helpers/qt_import_helper_test.rb
new file mode 100644
index 0000000..cdbdf84
--- /dev/null
+++ b/test/unit/helpers/qt_import_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class QtImportHelperTest < ActionView::TestCase
+end
From fbfbb34fe6dec7048f3bb4370410560bd9b7dd7a Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Fri, 15 Jun 2012 07:59:15 -0400
Subject: [PATCH 31/60] Updated parser to account for more hidden HTML tags.
---
lib/spqr_parser.rb | 59 ++++--
test/unit/spqr_transform_test.rb | 330 +++++++++++++++++--------------
2 files changed, 224 insertions(+), 165 deletions(-)
diff --git a/lib/spqr_parser.rb b/lib/spqr_parser.rb
index a9aad8e..9e74c9b 100644
--- a/lib/spqr_parser.rb
+++ b/lib/spqr_parser.rb
@@ -11,10 +11,14 @@ def parse(str)
super(str)
end
#Check for accompanying images
- rule(:filename) { match(/[a-z|0-9|\/|\-|\.|\?|\\\n\t\s]/).repeat(1).as(:filename) }
- rule(:image_start_tag) { str('
') }
- rule(:image) { (image_start_tag >> ( filename >> image_end_tag ).repeat(1)).as(:image) }
+ rule(:file) { space? >> str('src="') >> name >> str('"') }
+ rule(:name) { match(/[a-z|A-Z|0-9|\/|\-|\.|\?|\s|\\|\n|\t|\_|\{|\}|=]/).repeat(1).as(:filename) }
+ rule(:image_start_tag) { str('
') }
+ rule(:quote) { str('"')}
+ rule(:attribute_con) { match(/[a-z|A-Z|0-9|\/|\-|\.|\?|\s|\\|\n|\t|\_|\{|\}|=]/)}
+ rule(:attribute) { attribute_con >> quote >> attribute_con >> quote }
+ rule(:image) { (image_start_tag >> space? >> (( file | attribute ).repeat(1)) >> space? >> image_end_tag.maybe ).as(:image) }
#Check for formatting
rule(:italic_tag) { (str("") | str("") | str("") | str("")).as(:italic) }
@@ -22,15 +26,37 @@ def parse(str)
rule(:line_break) { (str("
") | str("
")).as(:line_break) }
rule(:tt_tag) { (str("") | str("") | str("") | str("")).as(:ttype)}
rule(:new_p) { (str("") | str("
") | str("") | str("
")).as(:para)}
+ rule(:center) { (str("") | str("") | str("") | str("")).as(:center)}
#Check for any font changes
- rule(:font1) { str("")}
- rule(:font_open) { (font1 >> (extra_f >> font2).repeat(1)) }
- rule(:content_f) { match(/[a-z|A-Z|0-9|\/|\-|\.|\?|\s|\\|\n|\t|\"|=]/).repeat(1).as(:content_f) }
- rule(:font_close) { str("") }
- rule(:font) { ( font_open >> (content_f >> font_close).repeat(1) ).as(:font) }
+ rule(:font1) { str("")}
+ rule(:font_open) { font1 >> extra >> font2 }
+ rule(:content_f) { text.as(:content_f) }
+ rule(:font_close) { str("") | str("") }
+ rule(:font) { ( font_open >> ( content_f ).repeat ).as(:font) }
+
+ #Check for any special display classes
+ rule(:pre1) { str("") }
+ rule(:pre_open) { pre1 >> extra >> pre2 }
+ rule(:content_p) { text.as(:content_p) }
+ rule(:pre_close) { str("") | str("") }
+ rule(:pre) { ( pre_open >> ( content_p ).repeat ).as(:pre) }
+
+ rule(:span1) { str("") }
+ rule(:span_open) { span1 >> extra >> span2 }
+ rule(:content) { text.as(:content) }
+ rule(:span_close) { str("") | str("") }
+ rule(:span) { ( span_open >> ( content ).repeat ).as(:span) }
+
+ rule(:div1) { str("") }
+ rule(:div_open) { div1 >> extra >> div2 }
+ rule(:div_close) { str("
") | str("") }
+ rule(:div) { ( div_open >> ( content ).repeat ).as(:div)}
#Greek letters
rule(:phi) { str("φ").as(:phi) }
@@ -40,7 +66,7 @@ def parse(str)
#Superscripts and Subscripts
rule(:sub1) { str("") | str("") }
- rule(:con) { match(/[a-z|A-Z|0-9]/).repeat(1).as(:con) }
+ rule(:con) { match(/[a-z|A-Z|0-9]/).repeat(1).as(:con) }
rule(:sub2) { str("") | str("") }
rule(:sub) { sub1 >> (con | greek).as(:sub) >> sub2 }
rule(:sup1) { str("") | str("") }
@@ -61,9 +87,10 @@ def parse(str)
rule(:fnof) { str("ƒ").as(:fnof) }
#Grammar parts
- rule(:format) { italic_tag | bold_tag | line_break | tt_tag | font | fnof | sub | sup }
- rule(:text) { ( image | format | letters | eol | new_p | greek | (any.as(:any)) ).repeat(1) }
- rule(:ques) { text.repeat(1).as(:text) }
+ rule(:tags) { font | font_close | pre | pre_close | span | span_close | div | div_close | image }
+ rule(:format) { italic_tag | bold_tag | line_break | tt_tag | fnof | sub | sup }
+ rule(:text) { ( tags | format | letters | eol | new_p | greek | (any.as(:any)) ).repeat(1) }
+ rule(:ques) { text.repeat.as(:text) }
rule(:expression) { ques }
root :expression
@@ -80,6 +107,8 @@ class SPQRTransform < Parslet::Transform
rule(:eol => simple(:eol)) { eol }
rule(:content_f => simple(:content_f)) {"!!" + content_f + "!!"}
rule(:font => sequence(:font)) {"#{font[0].to_s}"}
+ rule(:content_p => simple(:content_p)) {"$$" + content_p + "$$"}
+ rule(:pre => sequence(:pre)) {"#{pre[0].to_s}"}
rule(:phi => simple(:phi)) {"\phi"}
rule(:pi => simple(:pi)) {"\pi"}
rule(:omega => simple(:omega)) {"\omega"}
diff --git a/test/unit/spqr_transform_test.rb b/test/unit/spqr_transform_test.rb
index 323a14a..a10aca0 100644
--- a/test/unit/spqr_transform_test.rb
+++ b/test/unit/spqr_transform_test.rb
@@ -9,173 +9,203 @@
class SPQRTransfromTest < ActiveSupport::TestCase
#This array contains sample questions used for testing.
samples = Array.new
- samples [0] = 'iejfei
(blue to red), '
- samples [1] = 'Determine the smallest integer
- value of the sampling rate'
+ samples [0] = '
blue'
+ samples [1] = 'Determine the smallest integer value of the sampling rate'
- test "img_filename" do
- parser = SPQRParser.new
- a = parser.filename.parse('/ece2025/cgi-bin/mimetex.exe?\hat\om')
- expected = "{:filename=>\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\om\"@0}"
- assert_equal expected, a.to_s()
- end
+ # test "img_filename" do
+ # parser = SPQRParser.new
+ # a = parser.filename.parse('/ece2025/cgi-bin/mimetex.exe?\hat\om')
+ # expected = "{:filename=>\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\om\"@0}"
+ # assert_equal expected, a.to_s()
+ # end
test "image_start_tag" do
parser = SPQRParser.new
- a = parser.image_start_tag.parse('
')
- expected1 = "{:image=>[{:filename=>\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\omega\"@10}]}"
- assert_equal expected1,a.to_s()
- end
+ # test "images" do
+ # parser = SPQRParser.new
+ # a = parser.image.parse('
')
+ # expected1 = "{:image=>[{:filename=>\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\omega\"@10}]}"
+ # assert_equal expected1,a.to_s()
+ # end
test "text_w_images" do
parser = SPQRParser.new
a = parser.parse(samples[0])
- expected = "iejfeiMISSING IMAGE: /ece2025/cgi-bin/mimetex.exe?\\hat\\omega (blue to red), "
- output1 = SPQRTransform.new.apply(a)
- assert_equal expected, output1
- end
-
- test "italics" do
- parser = SPQRParser.new
- a = parser.parse('aThis is italics.')
- expected = "a'This is italics.'"
- output1 = SPQRTransform.new.apply(a)
- assert_equal expected, output1
- b = parser.parse('aThis is italics.')
- output2 = SPQRTransform.new.apply(b)
- assert_equal expected, output2
- end
-
- test "bold" do
- parser = SPQRParser.new
- a = parser.parse('aThis is bold text.')
- expected = "a!!This is bold text.!!"
- output1 = SPQRTransform.new.apply(a)
- assert_equal expected, output1
- b = parser.parse('aThis is bold text.')
- output2 = SPQRTransform.new.apply(b)
- assert_equal expected, output2
- end
-
- test "line_break" do
- parser = SPQRParser.new
- a = parser.parse('That was
unexpected.')
- expected = "That was \nunexpected."
- output1 = SPQRTransform.new.apply(a)
- assert_equal expected, output1
- b = parser.parse('That was
unexpected.')
- output2 = SPQRTransform.new.apply(b)
- assert_equal expected, output2
- end
-
- test "teletype" do
- parser = SPQRParser.new
- a = parser.parse('aMATH111')
- expected = "a$MATH111$"
- output1 = SPQRTransform.new.apply(a)
- assert_equal expected, output1
- b = parser.parse('aMATH111')
- output2 = SPQRTransform.new.apply(b)
- assert_equal expected, output2
- end
-
- test "new_paragraph" do
- parser = SPQRParser.new
- a = parser.parse('That was unexpected
.')
- expected = "That was \n\nunexpected\n\n."
- output1 = SPQRTransform.new.apply(a)
- assert_equal expected, output1
- b = parser.parse('That was unexpected
.')
- output2 = SPQRTransform.new.apply(b)
- assert_equal expected, output2
- end
-
- test "font_open" do
- parser = SPQRParser.new
- a = parser.font_open.parse('')
- expected = ""
- assert_equal expected, a.to_s
- end
-
- test "font_change" do
- parser = SPQRParser.new
- a = parser.font.parse('blah')
- expected = "{:font=>[{:content_f=>\"blah\"@19}]}"
- assert_equal expected, a.to_s
- end
+ p a
+ # expected = "iejfeiMISSING IMAGE: /ece2025/cgi-bin/mimetex.exe?\\hat\\omega (blue to red), "
+ # output1 = SPQRTransform.new.apply(a)
+ # assert_equal expected, output1
+ end
+
+ # test "italics" do
+ # parser = SPQRParser.new
+ # a = parser.parse('aThis is italics.')
+ # expected = "a'This is italics.'"
+ # output1 = SPQRTransform.new.apply(a)
+ # assert_equal expected, output1
+ # b = parser.parse('aThis is italics.')
+ # output2 = SPQRTransform.new.apply(b)
+ # assert_equal expected, output2
+ # end
+
+ # test "bold" do
+ # parser = SPQRParser.new
+ # a = parser.parse('aThis is bold text.')
+ # expected = "a!!This is bold text.!!"
+ # output1 = SPQRTransform.new.apply(a)
+ # assert_equal expected, output1
+ # b = parser.parse('aThis is bold text.')
+ # output2 = SPQRTransform.new.apply(b)
+ # assert_equal expected, output2
+ # end
+
+ # test "line_break" do
+ # parser = SPQRParser.new
+ # a = parser.parse('That was
unexpected.')
+ # expected = "That was \nunexpected."
+ # output1 = SPQRTransform.new.apply(a)
+ # assert_equal expected, output1
+ # b = parser.parse('That was
unexpected.')
+ # output2 = SPQRTransform.new.apply(b)
+ # assert_equal expected, output2
+ # end
+
+ # test "teletype" do
+ # parser = SPQRParser.new
+ # a = parser.parse('aMATH111')
+ # expected = "a$MATH111$"
+ # output1 = SPQRTransform.new.apply(a)
+ # assert_equal expected, output1
+ # b = parser.parse('aMATH111')
+ # output2 = SPQRTransform.new.apply(b)
+ # assert_equal expected, output2
+ # end
+
+ # test "new_paragraph" do
+ # parser = SPQRParser.new
+ # a = parser.parse('That was unexpected
.')
+ # expected = "That was \n\nunexpected\n\n."
+ # output1 = SPQRTransform.new.apply(a)
+ # assert_equal expected, output1
+ # b = parser.parse('That was unexpected
.')
+ # output2 = SPQRTransform.new.apply(b)
+ # assert_equal expected, output2
+ # end
+
+ # test "font_open" do
+ # parser = SPQRParser.new
+ # a = parser.font_open.parse('')
+ # expected = ""
+ # assert_equal expected, a.to_s
+ # end
+
+ # test "font_change" do
+ # parser = SPQRParser.new
+ # a = parser.font.parse('blah')
+ # expected = "{:font=>[{:content_f=>\"blah\"@19}]}"
+ # assert_equal expected, a.to_s
+ # end
test "font" do
parser = SPQRParser.new
a = parser.parse(samples[1])
- output1 = SPQRTransform.new.apply(a)
- expected = "Determine the smallest !!integer!! \n\tvalue of the sampling rate"
- assert_equal expected, output1
- end
-
- test "phi" do
- parser = SPQRParser.new
- a = parser.parse('φ')
- expected = "\phi"
- output1 = SPQRTransform.new.apply(a)
- assert_equal expected, output1
- end
-
- test "pi" do
- parser = SPQRParser.new
- a = parser.parse('aπ')
- expected = "a\pi"
- output1 = SPQRTransform.new.apply(a)
- assert_equal expected, output1
- end
-
- test "omega" do
- parser = SPQRParser.new
- a = parser.parse('aω')
- expected = "a\omega"
- output1 = SPQRTransform.new.apply(a)
- assert_equal expected, output1
- end
-
- test "curly_f" do
- parser = SPQRParser.new
- a = parser.parse('ƒs')
- expected = "fs"
- output1 = SPQRTransform.new.apply(a)
- assert_equal expected, output1
- end
-
- test "sub" do
- parser = SPQRParser.new
- a = parser.parse('aφ')
- expected1 = "a_{phi}"
- output1 = SPQRTransform.new.apply(a)
- assert_equal expected1, output1
- b = parser.parse('aeiew')
- expected2 = "a_{eie}w"
- output2 = SPQRTransform.new.apply(b)
- assert_equal expected2, output2
- end
-
- test "sup" do
- parser = SPQRParser.new
- a = parser.parse('aπ')
- expected1 = "a^{\pi}"
- output1 = SPQRTransform.new.apply(a)
- assert_equal expected1, output1
- b = parser.parse('biefie')
- expected2 = "b^{iefie}"
- output2 = SPQRTransform.new.apply(b)
- assert_equal expected2, output2
+ p a
+ # output1 = SPQRTransform.new.apply(a)
+ # expected = "Determine the smallest !!integer!! value of the sampling rate"
+ # assert_equal expected, output1
+ end
+
+ # test "phi" do
+ # parser = SPQRParser.new
+ # a = parser.parse('φ')
+ # expected = "\phi"
+ # output1 = SPQRTransform.new.apply(a)
+ # assert_equal expected, output1
+ # end
+
+ # test "pi" do
+ # parser = SPQRParser.new
+ # a = parser.parse('aπ')
+ # expected = "a\pi"
+ # output1 = SPQRTransform.new.apply(a)
+ # assert_equal expected, output1
+ # end
+
+ # test "omega" do
+ # parser = SPQRParser.new
+ # a = parser.parse('aω')
+ # expected = "a\omega"
+ # output1 = SPQRTransform.new.apply(a)
+ # assert_equal expected, output1
+ # end
+
+ # test "curly_f" do
+ # parser = SPQRParser.new
+ # a = parser.parse('ƒs')
+ # expected = "fs"
+ # output1 = SPQRTransform.new.apply(a)
+ # assert_equal expected, output1
+ # end
+
+ # test "sub" do
+ # parser = SPQRParser.new
+ # a = parser.parse('aφ')
+ # expected1 = "a_{phi}"
+ # output1 = SPQRTransform.new.apply(a)
+ # assert_equal expected1, output1
+ # b = parser.parse('aeiew')
+ # expected2 = "a_{eie}w"
+ # output2 = SPQRTransform.new.apply(b)
+ # assert_equal expected2, output2
+ # end
+
+ # test "sup" do
+ # parser = SPQRParser.new
+ # a = parser.parse('aπ')
+ # expected1 = "a^{\pi}"
+ # output1 = SPQRTransform.new.apply(a)
+ # assert_equal expected1, output1
+ # b = parser.parse('biefie')
+ # expected2 = "b^{iefie}"
+ # output2 = SPQRTransform.new.apply(b)
+ # assert_equal expected2, output2
+ # end
+
+ test "pre_class" do
+ parser = SPQRParser.new
+ a = parser.parse('ablah
')
+ p a
+ # expected = "a$$blah$$"
+ # output1 = SPQRTransform.new.apply(a)
+ # assert_equal expected, output1
+ # b = parser.parse('ablah
')
+ # output2 = SPQRTransform.new.apply(b)
+ # assert_equal expected, output2
+ end
+
+ test "span" do
+ parser = SPQRParser.new
+ a = parser.parse('a')
+ p a
+ end
+
+ test "div" do
+ parser = SPQRParser.new
+ a = parser.parse('aText!
')
+ p a
+ end
+
+ test "center" do
+ parser = SPQRParser.new
+ a = parser.parse('aImage')
+ p a
end
end
\ No newline at end of file
From 1c818c090c68b540cf048efe64c2d6a3d321e9b6 Mon Sep 17 00:00:00 2001
From: Daniel Reiter
Date: Fri, 15 Jun 2012 13:06:09 -0500
Subject: [PATCH 32/60] added unfinished solution message
---
app/views/questions/show.html.erb | 5 +++++
app/views/solutions/_single_solution.html.erb | 3 +++
2 files changed, 8 insertions(+)
diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb
index 105eb87..b0e116b 100644
--- a/app/views/questions/show.html.erb
+++ b/app/views/questions/show.html.erb
@@ -17,6 +17,11 @@
<% if @question.errors.none? %>
+ <% @question.solution.each do |solution| %>
+ <% if solution.is_visible == false && present_user == solution.creator %>
+
This question has unfinished solutions
+ <% break %>
+ <% end %>
<%= render :partial => "show",
:locals => {:question => @question} %>
<% else %>
diff --git a/app/views/solutions/_single_solution.html.erb b/app/views/solutions/_single_solution.html.erb
index 524f298..665420a 100644
--- a/app/views/solutions/_single_solution.html.erb
+++ b/app/views/solutions/_single_solution.html.erb
@@ -78,6 +78,9 @@
<% if !solution.explanation.blank? %>
+ <% if !solution.is_visible %>
+
This solution is not ready to be viewed.
+ <% end %>
High-Level Explanation
<%= simple_format solution.explanation %>
From c9f61eefccd905ea44715367c33009f584a72600 Mon Sep 17 00:00:00 2001
From: Daniel Reiter
Date: Fri, 15 Jun 2012 13:11:25 -0500
Subject: [PATCH 33/60] added a missing end
---
app/views/questions/show.html.erb | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb
index b0e116b..9a8f790 100644
--- a/app/views/questions/show.html.erb
+++ b/app/views/questions/show.html.erb
@@ -17,10 +17,11 @@
<% if @question.errors.none? %>
- <% @question.solution.each do |solution| %>
- <% if solution.is_visible == false && present_user == solution.creator %>
-
This question has unfinished solutions
- <% break %>
+ <% @question.solutions.each do |solution| %>
+ <% if solution.is_visible == false && present_user == solution.creator %>
+
This question has unfinished solutions
+ <% break %>
+ <% end %>
<% end %>
<%= render :partial => "show",
:locals => {:question => @question} %>
From c84ad439edc5cd8b3996ca584ca0ad40790c0090 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Fri, 15 Jun 2012 14:29:38 -0400
Subject: [PATCH 34/60] Just updated the parser to account for more tags.
---
lib/spqr_parser.rb | 37 ++--
test/unit/spqr_parser_test.rb | 151 +++++----------
test/unit/spqr_transform_test.rb | 310 ++++++++++++++++---------------
3 files changed, 224 insertions(+), 274 deletions(-)
diff --git a/lib/spqr_parser.rb b/lib/spqr_parser.rb
index 9e74c9b..3179d4f 100644
--- a/lib/spqr_parser.rb
+++ b/lib/spqr_parser.rb
@@ -8,7 +8,7 @@
class SPQRParser < Parslet::Parser
def parse(str)
- super(str)
+ a = super(str)
end
#Check for accompanying images
rule(:file) { space? >> str('src="') >> name >> str('"') }
@@ -32,31 +32,31 @@ def parse(str)
rule(:font1) { str("")}
- rule(:font_open) { font1 >> extra >> font2 }
- rule(:content_f) { text.as(:content_f) }
+ rule(:font_open) { font1 >> extra.maybe >> font2 }
+ rule(:content_f) { ( tags | format | letters | eol | new_p | greek | (punc.as(:any)) ).as(:content_f) }
rule(:font_close) { str("") | str("") }
- rule(:font) { ( font_open >> ( content_f ).repeat ).as(:font) }
+ rule(:font) { ( font_open >> content_f >> font_close ).as(:font) }
#Check for any special display classes
rule(:pre1) { str("") }
- rule(:pre_open) { pre1 >> extra >> pre2 }
- rule(:content_p) { text.as(:content_p) }
+ rule(:pre_open) { pre1 >> extra.maybe >> pre2 }
+ rule(:content_p) { ( tags | format | letters | eol | new_p | greek | (punc.as(:any)) ).as(:content_p) }
rule(:pre_close) { str("") | str("") }
- rule(:pre) { ( pre_open >> ( content_p ).repeat ).as(:pre) }
+ rule(:pre) { ( pre_open >> content_p >> pre_close ).as(:pre) }
rule(:span1) { str("") }
- rule(:span_open) { span1 >> extra >> span2 }
- rule(:content) { text.as(:content) }
+ rule(:span_open) { span1 >> extra.maybe >> span2 }
+ rule(:content) { ( tags | format | letters | eol | new_p | greek | (punc.as(:any)) ).repeat.as(:content) }
rule(:span_close) { str("") | str("") }
- rule(:span) { ( span_open >> ( content ).repeat ).as(:span) }
+ rule(:span) { ( span_open >> content >> span_close ).as(:span) }
rule(:div1) { str("") }
- rule(:div_open) { div1 >> extra >> div2 }
+ rule(:div_open) { div1 >> extra.maybe >> div2 }
rule(:div_close) { str("
") | str(" ") }
- rule(:div) { ( div_open >> ( content ).repeat ).as(:div)}
+ rule(:div) { ( div_open >> content >> div_close ).as(:div)}
#Greek letters
rule(:phi) { str("φ").as(:phi) }
@@ -87,8 +87,9 @@ def parse(str)
rule(:fnof) { str("ƒ").as(:fnof) }
#Grammar parts
- rule(:tags) { font | font_close | pre | pre_close | span | span_close | div | div_close | image }
- rule(:format) { italic_tag | bold_tag | line_break | tt_tag | fnof | sub | sup }
+ rule(:punc) { match(/[^<]/) }
+ rule(:tags) { font | pre | span | div | image }
+ rule(:format) { italic_tag | bold_tag | line_break | tt_tag | fnof | sub | sup | center }
rule(:text) { ( tags | format | letters | eol | new_p | greek | (any.as(:any)) ).repeat(1) }
rule(:ques) { text.repeat.as(:text) }
@@ -99,6 +100,7 @@ def parse(str)
#class UnavailableImage < StandardError; end
class SPQRTransform < Parslet::Transform
+ rule(:center => simple(:center)) {}
rule(:italic => simple(:italic)) {"'"}
rule(:bold => simple(:bold)) {"!!"}
rule(:line_break => simple(:break)) {"\n"}
@@ -106,9 +108,12 @@ class SPQRTransform < Parslet::Transform
rule(:para => simple(:para)) {"\n\n"}
rule(:eol => simple(:eol)) { eol }
rule(:content_f => simple(:content_f)) {"!!" + content_f + "!!"}
- rule(:font => sequence(:font)) {"#{font[0].to_s}"}
+ rule(:font => simple(:font)) { font }
rule(:content_p => simple(:content_p)) {"$$" + content_p + "$$"}
- rule(:pre => sequence(:pre)) {"#{pre[0].to_s}"}
+ rule(:pre => simple(:pre)) { pre }
+ rule(:content => sequence(:content)) { content.join}
+ rule(:span => simple(:span)) { span }
+ rule(:div => simple(:div)) { div }
rule(:phi => simple(:phi)) {"\phi"}
rule(:pi => simple(:pi)) {"\pi"}
rule(:omega => simple(:omega)) {"\omega"}
diff --git a/test/unit/spqr_parser_test.rb b/test/unit/spqr_parser_test.rb
index d235461..7084026 100644
--- a/test/unit/spqr_parser_test.rb
+++ b/test/unit/spqr_parser_test.rb
@@ -8,10 +8,6 @@
class SPQRParserTest < ActiveSupport::TestCase
- def setup
- @parser = SPQRParser.new
- end
-
test "space" do
parser = SPQRParser.new
assert_equal parser.space.parse(" ").to_s, " "
@@ -25,193 +21,140 @@ def setup
test "letters" do
parser = SPQRParser.new
- a = parser.parse("aifjeovj")
- assert_equal "aifjeovj", SPQRTransform.new.apply(a)
- b = parser.parse("ei ief ")
- assert_equal "ei ief ", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("aifjeovj")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("ei ief ")}
end
test "numbers" do
parser = SPQRParser.new
- a = parser.parse("4846473")
- assert_equal "4846473", SPQRTransform.new.apply(a)
- b = parser.parse("38 28 482 ")
- assert_equal "38 28 482 ", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("484673")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("38 28 482")}
end
test "fslash" do
parser = SPQRParser.new
- a = parser.parse("/ ")
- assert_equal "/ ", SPQRTransform.new.apply(a)
- b = parser.parse("/")
- assert_equal "/", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("/ ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("/")}
end
test "bslash" do
parser = SPQRParser.new
- a = parser.parse("\\ ")
- assert_equal "\\ ", SPQRTransform.new.apply(a)
- b = parser.parse("\\")
- assert_equal "\\", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("\\ ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("\\")}
end
+
test "lparen" do
parser = SPQRParser.new
- a = parser.parse("( ")
- assert_equal "( ", SPQRTransform.new.apply(a)
- b = parser.parse("(")
- assert_equal "(", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("( ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("(")}
end
test "rparen" do
parser = SPQRParser.new
- a = parser.parse(") ")
- assert_equal ") ", SPQRTransform.new.apply(a)
- b = parser.parse(")")
- assert_equal ")", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse(") ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse(")")}
end
test "lbracket" do
parser = SPQRParser.new
- a = parser.parse("[ ")
- assert_equal "[ ", SPQRTransform.new.apply(a)
- b = parser.parse("[")
- assert_equal "[", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("[ ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("[")}
end
test "rbracket" do
parser = SPQRParser.new
- a = parser.parse("] ")
- assert_equal "] ", SPQRTransform.new.apply(a)
- b = parser.parse("]")
- assert_equal "]", SPQRTransform.new.apply(b)
- end
-
- test "lthan" do
- parser = SPQRParser.new
- a = parser.parse("< ")
- assert_equal "< ", SPQRTransform.new.apply(a)
- b = parser.parse("<")
- assert_equal "<", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("] ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("]")}
end
test "greaterthan" do
parser = SPQRParser.new
- a = parser.parse("> ")
- assert_equal "> ", SPQRTransform.new.apply(a)
- b = parser.parse(">")
- assert_equal ">", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("> ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse(">")}
end
test "equal" do
parser = SPQRParser.new
- a = parser.parse("= ")
- assert_equal "= ", SPQRTransform.new.apply(a)
- b = parser.parse("=")
- assert_equal "=", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("= ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("=")}
end
test "hyphen" do
parser = SPQRParser.new
- a = parser.parse("- ")
- assert_equal "- ", SPQRTransform.new.apply(a)
- b = parser.parse("-")
- assert_equal "-", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("- ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("-")}
end
test "underscore" do
parser = SPQRParser.new
- a = parser.parse("_ ")
- assert_equal "_ ", SPQRTransform.new.apply(a)
- b = parser.parse("_")
- assert_equal "_", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("_ ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("_")}
end
test "semicolon" do
parser = SPQRParser.new
- a = parser.parse("; ")
- assert_equal "; ", SPQRTransform.new.apply(a)
- b = parser.parse(";")
- assert_equal ";", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("; ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse(";")}
end
test "colon" do
parser = SPQRParser.new
- a = parser.parse(": ")
- assert_equal ": ", SPQRTransform.new.apply(a)
- b = parser.parse(":")
- assert_equal ":", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse(": ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse(":")}
end
test "comma" do
parser = SPQRParser.new
- a = parser.parse(", ")
- assert_equal ", ", SPQRTransform.new.apply(a)
- b = parser.parse(",")
- assert_equal ",", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse(", ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse(",")}
end
test "period" do
parser = SPQRParser.new
- a = parser.parse(". ")
- assert_equal ". ", SPQRTransform.new.apply(a)
- b = parser.parse(".")
- assert_equal ".", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse(". ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse(".")}
end
test "qmark" do
parser = SPQRParser.new
- a = parser.parse("? ")
- assert_equal "? ", SPQRTransform.new.apply(a)
- b = parser.parse("?")
- assert_equal "?", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("? ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("?")}
end
test "exclamation" do
parser = SPQRParser.new
- a = parser.parse("! ")
- assert_equal "! ", SPQRTransform.new.apply(a)
- b = parser.parse("!")
- assert_equal "!", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("! ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("!")}
end
test "ampersand" do
parser = SPQRParser.new
- a = parser.parse("& ")
- assert_equal "& ", SPQRTransform.new.apply(a)
- b = parser.parse("&")
- assert_equal "&", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("& ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("&")}
end
test "percent" do
parser = SPQRParser.new
- a = parser.parse("% ")
- assert_equal "% ", SPQRTransform.new.apply(a)
- b = parser.parse("%")
- assert_equal "%", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("% ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("%")}
end
test "star" do
parser = SPQRParser.new
- a = parser.parse("* ")
- assert_equal "* ", SPQRTransform.new.apply(a)
- b = parser.parse("*")
- assert_equal "*", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("* ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("*")}
end
test "caret" do
parser = SPQRParser.new
- a = parser.parse("^ ")
- assert_equal "^ ", SPQRTransform.new.apply(a)
- b = parser.parse("^")
- assert_equal "^", SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("^ ")}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse("^")}
end
test "quote" do
parser = SPQRParser.new
- a = parser.parse('" ')
- assert_equal '" ', SPQRTransform.new.apply(a)
- b = parser.parse('"')
- assert_equal '"', SPQRTransform.new.apply(b)
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse('" ')}
+ assert_nothing_raised(Parslet::ParseFailed) {parser.parse('"')}
end
test "samples" do
diff --git a/test/unit/spqr_transform_test.rb b/test/unit/spqr_transform_test.rb
index a10aca0..1e79200 100644
--- a/test/unit/spqr_transform_test.rb
+++ b/test/unit/spqr_transform_test.rb
@@ -9,16 +9,16 @@
class SPQRTransfromTest < ActiveSupport::TestCase
#This array contains sample questions used for testing.
samples = Array.new
- samples [0] = '
blue'
+ samples [0] = 'iejfei
blue'
samples [1] = 'Determine the smallest integer value of the sampling rate'
- # test "img_filename" do
- # parser = SPQRParser.new
- # a = parser.filename.parse('/ece2025/cgi-bin/mimetex.exe?\hat\om')
- # expected = "{:filename=>\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\om\"@0}"
- # assert_equal expected, a.to_s()
- # end
+ test "img_filename" do
+ parser = SPQRParser.new
+ a = parser.name.parse('/ece2025/cgi-bin/mimetex.exe?\hat\om')
+ expected = "{:filename=>\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\om\"@0}"
+ assert_equal expected, a.to_s()
+ end
test "image_start_tag" do
parser = SPQRParser.new
@@ -28,184 +28,186 @@ class SPQRTransfromTest < ActiveSupport::TestCase
end
- # test "images" do
- # parser = SPQRParser.new
- # a = parser.image.parse('
')
- # expected1 = "{:image=>[{:filename=>\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\omega\"@10}]}"
- # assert_equal expected1,a.to_s()
- # end
+ test "images" do
+ parser = SPQRParser.new
+ a = parser.image.parse('
')
+ expected = "{:image=>[{:filename=>\"/ece2025/cgi-bin/mimetex.exe?\\\\hat\\\\omega\"@10}]}"
+ assert_equal expected,a.to_s()
+ end
test "text_w_images" do
parser = SPQRParser.new
a = parser.parse(samples[0])
- p a
- # expected = "iejfeiMISSING IMAGE: /ece2025/cgi-bin/mimetex.exe?\\hat\\omega (blue to red), "
- # output1 = SPQRTransform.new.apply(a)
- # assert_equal expected, output1
- end
-
- # test "italics" do
- # parser = SPQRParser.new
- # a = parser.parse('aThis is italics.')
- # expected = "a'This is italics.'"
- # output1 = SPQRTransform.new.apply(a)
- # assert_equal expected, output1
- # b = parser.parse('aThis is italics.')
- # output2 = SPQRTransform.new.apply(b)
- # assert_equal expected, output2
- # end
-
- # test "bold" do
- # parser = SPQRParser.new
- # a = parser.parse('aThis is bold text.')
- # expected = "a!!This is bold text.!!"
- # output1 = SPQRTransform.new.apply(a)
- # assert_equal expected, output1
- # b = parser.parse('aThis is bold text.')
- # output2 = SPQRTransform.new.apply(b)
- # assert_equal expected, output2
- # end
-
- # test "line_break" do
- # parser = SPQRParser.new
- # a = parser.parse('That was
unexpected.')
- # expected = "That was \nunexpected."
- # output1 = SPQRTransform.new.apply(a)
- # assert_equal expected, output1
- # b = parser.parse('That was
unexpected.')
- # output2 = SPQRTransform.new.apply(b)
- # assert_equal expected, output2
- # end
-
- # test "teletype" do
- # parser = SPQRParser.new
- # a = parser.parse('aMATH111')
- # expected = "a$MATH111$"
- # output1 = SPQRTransform.new.apply(a)
- # assert_equal expected, output1
- # b = parser.parse('aMATH111')
- # output2 = SPQRTransform.new.apply(b)
- # assert_equal expected, output2
- # end
-
- # test "new_paragraph" do
- # parser = SPQRParser.new
- # a = parser.parse('That was unexpected
.')
- # expected = "That was \n\nunexpected\n\n."
- # output1 = SPQRTransform.new.apply(a)
- # assert_equal expected, output1
- # b = parser.parse('That was unexpected
.')
- # output2 = SPQRTransform.new.apply(b)
- # assert_equal expected, output2
- # end
-
- # test "font_open" do
- # parser = SPQRParser.new
- # a = parser.font_open.parse('')
- # expected = ""
- # assert_equal expected, a.to_s
- # end
+ expected = "iejfeiMISSING IMAGE: /ece2025/cgi-bin/mimetex.exe?\\hat\\omega blue"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
+
+ test "italics" do
+ parser = SPQRParser.new
+ a = parser.parse('aThis is italics.')
+ expected = "a'This is italics.'"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ b = parser.parse('aThis is italics.')
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected, output2
+ end
+
+ test "bold" do
+ parser = SPQRParser.new
+ a = parser.parse('aThis is bold text.')
+ expected = "a!!This is bold text.!!"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ b = parser.parse('aThis is bold text.')
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected, output2
+ end
+
+ test "line_break" do
+ parser = SPQRParser.new
+ a = parser.parse('That was
unexpected.')
+ expected = "That was \nunexpected."
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ b = parser.parse('That was
unexpected.')
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected, output2
+ end
+
+ test "teletype" do
+ parser = SPQRParser.new
+ a = parser.parse('aMATH111')
+ expected = "a$MATH111$"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ b = parser.parse('aMATH111')
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected, output2
+ end
+
+ test "new_paragraph" do
+ parser = SPQRParser.new
+ a = parser.parse('That was unexpected
.')
+ expected = "That was \n\nunexpected\n\n."
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ b = parser.parse('That was unexpected
.')
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected, output2
+ end
+
+ test "font_open" do
+ parser = SPQRParser.new
+ a = parser.font_open.parse('')
+ expected = ""
+ assert_equal expected, a.to_s
+ end
- # test "font_change" do
- # parser = SPQRParser.new
- # a = parser.font.parse('blah')
- # expected = "{:font=>[{:content_f=>\"blah\"@19}]}"
- # assert_equal expected, a.to_s
- # end
+ test "font_change" do
+ parser = SPQRParser.new
+ a = parser.font.parse('blah')
+ expected = "{:font=>{:content_f=>{:letters=>\"blah\"@19}}}"
+ assert_equal expected, a.to_s
+ end
test "font" do
parser = SPQRParser.new
a = parser.parse(samples[1])
- p a
- # output1 = SPQRTransform.new.apply(a)
- # expected = "Determine the smallest !!integer!! value of the sampling rate"
- # assert_equal expected, output1
- end
-
- # test "phi" do
- # parser = SPQRParser.new
- # a = parser.parse('φ')
- # expected = "\phi"
- # output1 = SPQRTransform.new.apply(a)
- # assert_equal expected, output1
- # end
+ output1 = SPQRTransform.new.apply(a)
+ expected = "Determine the smallest !!integer!! value of the sampling rate"
+ assert_equal expected, output1
+ end
- # test "pi" do
- # parser = SPQRParser.new
- # a = parser.parse('aπ')
- # expected = "a\pi"
- # output1 = SPQRTransform.new.apply(a)
- # assert_equal expected, output1
- # end
+ test "phi" do
+ parser = SPQRParser.new
+ a = parser.parse('φ')
+ expected = "\phi"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
- # test "omega" do
- # parser = SPQRParser.new
- # a = parser.parse('aω')
- # expected = "a\omega"
- # output1 = SPQRTransform.new.apply(a)
- # assert_equal expected, output1
- # end
+ test "pi" do
+ parser = SPQRParser.new
+ a = parser.parse('aπ')
+ expected = "a\pi"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
- # test "curly_f" do
- # parser = SPQRParser.new
- # a = parser.parse('ƒs')
- # expected = "fs"
- # output1 = SPQRTransform.new.apply(a)
- # assert_equal expected, output1
- # end
+ test "omega" do
+ parser = SPQRParser.new
+ a = parser.parse('aω')
+ expected = "a\omega"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
- # test "sub" do
- # parser = SPQRParser.new
- # a = parser.parse('aφ')
- # expected1 = "a_{phi}"
- # output1 = SPQRTransform.new.apply(a)
- # assert_equal expected1, output1
- # b = parser.parse('aeiew')
- # expected2 = "a_{eie}w"
- # output2 = SPQRTransform.new.apply(b)
- # assert_equal expected2, output2
- # end
+ test "curly_f" do
+ parser = SPQRParser.new
+ a = parser.parse('ƒs')
+ expected = "fs"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
- # test "sup" do
- # parser = SPQRParser.new
- # a = parser.parse('aπ')
- # expected1 = "a^{\pi}"
- # output1 = SPQRTransform.new.apply(a)
- # assert_equal expected1, output1
- # b = parser.parse('biefie')
- # expected2 = "b^{iefie}"
- # output2 = SPQRTransform.new.apply(b)
- # assert_equal expected2, output2
- # end
+ test "sub" do
+ parser = SPQRParser.new
+ a = parser.parse('aφ')
+ expected1 = "a_{phi}"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected1, output1
+ b = parser.parse('aeiew')
+ expected2 = "a_{eie}w"
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected2, output2
+ end
+
+ test "sup" do
+ parser = SPQRParser.new
+ a = parser.parse('aπ')
+ expected1 = "a^{\pi}"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected1, output1
+ b = parser.parse('biefie')
+ expected2 = "b^{iefie}"
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected2, output2
+ end
test "pre_class" do
parser = SPQRParser.new
- a = parser.parse('ablah
')
- p a
- # expected = "a$$blah$$"
- # output1 = SPQRTransform.new.apply(a)
- # assert_equal expected, output1
- # b = parser.parse('ablah
')
- # output2 = SPQRTransform.new.apply(b)
- # assert_equal expected, output2
+ a = parser.parse('ablah
more')
+ expected = "a$$blah$$more"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
end
test "span" do
parser = SPQRParser.new
- a = parser.parse('a')
- p a
+ a = parser.parse('amore')
+ expected = "aUh, something.more"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
end
test "div" do
parser = SPQRParser.new
a = parser.parse('aText!
')
- p a
+ expected = "aText!"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
end
test "center" do
parser = SPQRParser.new
a = parser.parse('aImage')
- p a
+ expected = "aImage"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
end
+ # test "less_than" do
+ # end
end
\ No newline at end of file
From 6928c3f0a943c1206acc0ad5e199302f776c5c47 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Fri, 15 Jun 2012 15:14:24 -0400
Subject: [PATCH 35/60] Updated parser to handle arbitrarily nested HTML tags.
---
lib/spqr_parser.rb | 8 ++++----
test/unit/spqr_transform_test.rb | 19 ++++++++++++++++---
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/lib/spqr_parser.rb b/lib/spqr_parser.rb
index 3179d4f..4f23e51 100644
--- a/lib/spqr_parser.rb
+++ b/lib/spqr_parser.rb
@@ -33,7 +33,7 @@ def parse(str)
rule(:extra) { match(/[a-z|A-Z|0-9|\/|\-|\.|\?|\s|\\|\n|\t|\"|\_|\{|\}|=]/).repeat(1)}
rule(:font2) { str(">")}
rule(:font_open) { font1 >> extra.maybe >> font2 }
- rule(:content_f) { ( tags | format | letters | eol | new_p | greek | (punc.as(:any)) ).as(:content_f) }
+ rule(:content_f) { ( tags | format | letters | eol | new_p | greek | (punc.as(:any)) ).repeat.as(:content_f) }
rule(:font_close) { str("") | str("") }
rule(:font) { ( font_open >> content_f >> font_close ).as(:font) }
@@ -41,7 +41,7 @@ def parse(str)
rule(:pre1) { str("") }
rule(:pre_open) { pre1 >> extra.maybe >> pre2 }
- rule(:content_p) { ( tags | format | letters | eol | new_p | greek | (punc.as(:any)) ).as(:content_p) }
+ rule(:content_p) { ( tags | format | letters | eol | new_p | greek | (punc.as(:any)) ).repeat.as(:content_p) }
rule(:pre_close) { str("") | str("") }
rule(:pre) { ( pre_open >> content_p >> pre_close ).as(:pre) }
@@ -107,9 +107,9 @@ class SPQRTransform < Parslet::Transform
rule(:ttype => simple(:ttype)) {"$"}
rule(:para => simple(:para)) {"\n\n"}
rule(:eol => simple(:eol)) { eol }
- rule(:content_f => simple(:content_f)) {"!!" + content_f + "!!"}
+ rule(:content_f => sequence(:content_f)) {"!!" + content_f.join + "!!"}
rule(:font => simple(:font)) { font }
- rule(:content_p => simple(:content_p)) {"$$" + content_p + "$$"}
+ rule(:content_p => sequence(:content_p)) {"$$" + content_p.join + "$$"}
rule(:pre => simple(:pre)) { pre }
rule(:content => sequence(:content)) { content.join}
rule(:span => simple(:span)) { span }
diff --git a/test/unit/spqr_transform_test.rb b/test/unit/spqr_transform_test.rb
index 1e79200..5eadcee 100644
--- a/test/unit/spqr_transform_test.rb
+++ b/test/unit/spqr_transform_test.rb
@@ -108,7 +108,7 @@ class SPQRTransfromTest < ActiveSupport::TestCase
test "font_change" do
parser = SPQRParser.new
a = parser.font.parse('blah')
- expected = "{:font=>{:content_f=>{:letters=>\"blah\"@19}}}"
+ expected = "{:font=>{:content_f=>[{:letters=>\"blah\"@19}]}}"
assert_equal expected, a.to_s
end
@@ -208,6 +208,19 @@ class SPQRTransfromTest < ActiveSupport::TestCase
assert_equal expected, output1
end
- # test "less_than" do
- # end
+ test "2tags" do
+ parser = SPQRParser.new
+ a = parser.parse('a')
+ output1 = SPQRTransform.new.apply(a)
+ expected = "aMISSING IMAGE: filename.jpg"
+ assert_equal expected, output1
+ end
+
+ test "3tags" do
+ parser = SPQRParser.new
+ a = parser.parse('a')
+ expected = "a$$'\pi'$$"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
end
\ No newline at end of file
From 349d4429f847fac855ec9e68d97f1643abfaba64 Mon Sep 17 00:00:00 2001
From: jrb6
Date: Tue, 19 Jun 2012 10:40:29 -0500
Subject: [PATCH 36/60] Changed eval statement into a partial render of the
assets
---
app/views/attachable_assets/_form.html.erb | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/app/views/attachable_assets/_form.html.erb b/app/views/attachable_assets/_form.html.erb
index aeb9abc..9a389a6 100644
--- a/app/views/attachable_assets/_form.html.erb
+++ b/app/views/attachable_assets/_form.html.erb
@@ -63,7 +63,11 @@
sizeLimit : <%= max_size %>,
multi : <%= allow_multiple_files %>,
onComplete : function(event, queueID, fileObj, response, data) {
- eval(response);
+ $.ajax({
+ url: '/attachable_assets/' + response + '/finish_create',
+ dataType: 'script'
+ });
+ return true;
},
onAllComplete : function(event, data){
$('#uploadify_file_cancel').hide('blind');
From ccd14e6c9b798603b9b8ce606a237af8464164e2 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Wed, 20 Jun 2012 22:57:35 -0400
Subject: [PATCH 37/60] Updating rails
---
Gemfile | 4 +
Gemfile.lock | 5 +
Rakefile | 2 +
app/controllers/import_controller.rb | 5 +
app/controllers/qt_import_controller.rb | 18 +-
app/models/file_upload.rb | 4 -
app/uploaders/question_uploader.rb | 6 +-
app/views/qt_import/_form.html.erb | 2 +-
config/application.rb | 2 +
config/environment.rb | 4 +
config/initializers/carrierwave.rb | 5 +
config/routes.rb | 5 +-
lib/qti_import.rb | 26 +-
lib/qti_parser.rb | 21 +-
lib/sample_SPQR_questions.xml | 21 +
lib/spqr_parser.rb | 23 +-
.../tmp/20120614-1609-2218-8566/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1612-2221-7986/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1619-2241-4540/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1620-2244-5087/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1621-2247-1190/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1624-2251-3810/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1627-2255-0135/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1628-2259-0062/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1630-2262-9845/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1631-2265-9228/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1632-2268-6737/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1632-2271-7358/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1637-2281-1197/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1638-2284-6690/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1640-2292-9066/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1646-2304-3528/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1709-2348-2915/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1710-2351-8949/spqr3.xml | 457 ++++++++++++++++++
.../tmp/20120614-1720-2398-5985/spqr3.xml | 457 ++++++++++++++++++
test/fixtures/file_uploads.yml | 11 +
test/fixtures/files/spqr3.xml | 2 +-
test/fixtures/files/spqr4.xml | 2 +-
test/functional/qt_import_controller_test.rb | 35 +-
test/unit/file_upload_test.rb | 3 +-
test/unit/qti_transform_test.rb | 6 +
test/unit/simple_question_test.rb | 2 +
test/unit/spqr_transform_test.rb | 46 +-
43 files changed, 8886 insertions(+), 57 deletions(-)
create mode 100644 app/controllers/import_controller.rb
create mode 100644 config/initializers/carrierwave.rb
create mode 100644 lib/sample_SPQR_questions.xml
create mode 100644 public/uploads/tmp/20120614-1609-2218-8566/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1612-2221-7986/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1619-2241-4540/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1620-2244-5087/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1621-2247-1190/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1624-2251-3810/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1627-2255-0135/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1628-2259-0062/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1630-2262-9845/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1631-2265-9228/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1632-2268-6737/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1632-2271-7358/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1637-2281-1197/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1638-2284-6690/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1640-2292-9066/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1646-2304-3528/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1709-2348-2915/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1710-2351-8949/spqr3.xml
create mode 100644 public/uploads/tmp/20120614-1720-2398-5985/spqr3.xml
create mode 100644 test/fixtures/file_uploads.yml
diff --git a/Gemfile b/Gemfile
index ff58df6..c386a68 100644
--- a/Gemfile
+++ b/Gemfile
@@ -10,6 +10,10 @@ gem 'nokogiri'
gem 'carrierwave'
+gem 'upmark'
+
+gem 'htmlentities'
+
# Deploy with Capistrano
gem 'capistrano'
diff --git a/Gemfile.lock b/Gemfile.lock
index c0bfaa0..04051ea 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -65,6 +65,7 @@ GEM
faker (0.9.5)
i18n (~> 0.4)
highline (1.6.1)
+ htmlentities (4.3.1)
i18n (0.5.0)
jquery-rails (0.2.7)
rails (~> 3.0)
@@ -156,6 +157,8 @@ GEM
uglifier (1.2.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
+ upmark (0.1.3)
+ parslet
warden (1.0.3)
rack (>= 1.0.0)
will_paginate (3.0.pre2)
@@ -175,6 +178,7 @@ DEPENDENCIES
execjs
factory_girl_rails (< 2.0)
faker
+ htmlentities
jquery-rails
jsonify
jsonify-rails
@@ -195,5 +199,6 @@ DEPENDENCIES
therubyracer
timecop
uglifier
+ upmark
will_paginate (= 3.0.pre2)
yajl-ruby
diff --git a/Rakefile b/Rakefile
index 993dfbe..77b2ac1 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,3 +1,5 @@
+#encoding: utf-8
+
# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
# License version 3 or later. See the COPYRIGHT file for details.
diff --git a/app/controllers/import_controller.rb b/app/controllers/import_controller.rb
new file mode 100644
index 0000000..bffd587
--- /dev/null
+++ b/app/controllers/import_controller.rb
@@ -0,0 +1,5 @@
+class ImportController < ApplicationController
+ def index
+ @qt_import = QtImport.new
+ end
+end
diff --git a/app/controllers/qt_import_controller.rb b/app/controllers/qt_import_controller.rb
index b3265b8..5f5d8e8 100644
--- a/app/controllers/qt_import_controller.rb
+++ b/app/controllers/qt_import_controller.rb
@@ -1,21 +1,23 @@
+#encoding: utf-8
+
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
class QtImportController < ApplicationController
def new
@content_types = QTImport.content_types
end
def create
- f = FileUpload.new
- f.importfile.cache!(@file)
- storage = f.importfile.cache_name
- document = QTImport.openfile(f.retrieve_from_cache!(storage))
- parser, transformer = QTImport.choose(@content_types)
+ f = params[:file]
+ document = QTImport.openfile(f.path)
+ parser, transformer = QTImport.choose_import(params[:content_type])
content = QTImport.iterate_items(document)
+ debugger
questions = QTImport.get_questions(content,parser,transformer)
- project = QTImport.createproject(@current_user)
+ project = QTImport.createproject(current_user)
QTImport.add_questions(project,questions)
- render 'create'
-
# rescue
# render :text => "Sorry, there was a problem with importing your questions."
# redirect_to :new
diff --git a/app/models/file_upload.rb b/app/models/file_upload.rb
index 7a61681..adbaccb 100644
--- a/app/models/file_upload.rb
+++ b/app/models/file_upload.rb
@@ -1,7 +1,3 @@
class FileUpload < ActiveRecord::Base
mount_uploader :importfile, QuestionUploader
-
- def extension_white_list
- %w(xml)
- end
end
diff --git a/app/uploaders/question_uploader.rb b/app/uploaders/question_uploader.rb
index 48391f8..3e0fdba 100644
--- a/app/uploaders/question_uploader.rb
+++ b/app/uploaders/question_uploader.rb
@@ -35,9 +35,9 @@ def store_dir
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
- # def extension_white_list
- # %w(jpg jpeg gif png)
- # end
+ def extension_white_list
+ %w(xml)
+ end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
diff --git a/app/views/qt_import/_form.html.erb b/app/views/qt_import/_form.html.erb
index f037c9a..1e3e73b 100644
--- a/app/views/qt_import/_form.html.erb
+++ b/app/views/qt_import/_form.html.erb
@@ -1,4 +1,4 @@
-<%= form_tag :url => 'import/qti', :method => 'post', :multipart => true, do %>
+<%= form_tag '/import/qti', :multipart => true, do %>
<%= label_tag "File", "File" %>
<%= file_field_tag :file %>
diff --git a/config/application.rb b/config/application.rb
index 4624a1f..d02c239 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,3 +1,5 @@
+#encoding: utf-8
+
# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
# License version 3 or later. See the COPYRIGHT file for details.
diff --git a/config/environment.rb b/config/environment.rb
index 6215787..b080fe2 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -1,3 +1,5 @@
+#encoding: utf-8
+
# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
# License version 3 or later. See the COPYRIGHT file for details.
@@ -18,5 +20,7 @@
ActionMailer::Base.delivery_method = :sendmail
+Encoding.default_external = Encoding::UTF_8
+Encoding.default_internal = Encoding::UTF_8
# Initialize the rails application
Quadbase::Application.initialize!
diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb
new file mode 100644
index 0000000..7f4a20b
--- /dev/null
+++ b/config/initializers/carrierwave.rb
@@ -0,0 +1,5 @@
+if Rails.env.test?
+ CarrierWave.configure do |config|
+ config.storage = :file
+ end
+end
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 9162642..9b9447c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -3,9 +3,8 @@
Quadbase::Application.routes.draw do
- get "import/qti/new", :to => 'qt_import#new'
-
- post "import/qti", :to => 'qt_import#create'
+ get "/import/qti/new", :to => 'qt_import#new'
+ post "/import/qti", :to => 'qt_import#create'
namespace :admin do
resources :logic_libraries do
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index b541c80..b9aa66e 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -18,6 +18,7 @@ def self.add_questions(project,questions)
for a in 0..(questions.length-1)
project.add_question!(questions[a])
end
+ return project
end
def self.choose_import(content_type)
@@ -31,6 +32,7 @@ def self.choose_import(content_type)
def self.createproject(current_user)
a = Project.create(:name => 'Import')
a.add_member!(current_user)
+ a
end
def self.get_answers(content,parser,transformer,id_num)
@@ -49,9 +51,11 @@ def self.get_answers(content,parser,transformer,id_num)
for a in 0..(answers.length-1)
b = answers[a].children.children.children
text = b[0].content
+ text.force_encoding('UTF-8')
b1 = parser.parse(text)
- ans = transformer.apply(b1)
+ ans = transformer.apply(b1)
choice = AnswerChoice.new(:content => ans, :credit => credit[a])
+ choice.content.force_encoding("UTF-8")
choices << choice
end
return choices
@@ -93,21 +97,33 @@ def self.get_questions(content,parser,transformer)
y = content[z]
ques_num = y.attributes["ident"].value
ques_id << ques_num
- x = y.xpath('//presentation')
- w = x[0].children.children.children
+ end
+ x = content.xpath('//presentation')
+ for p in 0..(x.length-1)
+ w = x[p].children.children.children
text = w[0].content
+ #text.force_encoding('UTF-8')
v = parser.parse(text)
ques1 = transformer.apply(v)
ques << ques1
- end
- answers = self.get_answers(content,parser,transformer,ques_num)
+ end
+ debugger
for a in 0..(ques.length-1)
+ answers = self.get_answers(content,parser,transformer,ques_id[a])
b = Comment.new(:message => ques_id[a])
q = SimpleQuestion.new(:content => ques[a])
q.comment_thread = b.comment_thread
for i in 0..(answers.length-1)
q.answer_choices << answers[i]
+ if answers.length == 0
+ q.answer_choices << AnswerChoice.new(:content => "fake", :credit => 0)
+ q.answer_choices << AnswerChoice.new(:content => "not real", :credit => 1)
+ end
+ if answers.length == 1
+ q.answer_choices << AnswerChoice.new(:content => "fake", :credit => 0)
+ end
end
+ Rails.logger.debug{ q.content}
q.save!
questions << q
end
diff --git a/lib/qti_parser.rb b/lib/qti_parser.rb
index 2f1c420..9f11ab2 100644
--- a/lib/qti_parser.rb
+++ b/lib/qti_parser.rb
@@ -26,14 +26,23 @@ def parse(str)
rule(:new_p) { (str("") | str("
") | str("") | str("
")).as(:para)}
#Check for any font changes
- rule(:font1) { str("")}
- rule(:font_open) { (font1 >> (extra_f >> font2).repeat(1)) }
- rule(:content_f) { match(/[a-z|A-Z|0-9|\/|\-|\.|\?|\s|\\|\n|\t|\"|=]/).repeat(1).as(:content_f) }
+ rule(:font1) { str("")}
+ rule(:font_open) { (font1 >> (extra_f >> font2).repeat(1)) }
+ rule(:content_f) { match(/[a-z|A-Z|0-9|\/|\-|\.|\?|\s|\\|\n|\t|\"|=]/).repeat(1).as(:content_f) }
rule(:font_close) { str("") }
rule(:font) { ( font_open >> (content_f >> font_close).repeat(1) ).as(:font) }
+ #check for any special classes
+ rule(:pre1) { str("") }
+ rule(:pre_open) { (pre1 >> (extra_p >> pre2).repeat(1)) }
+ rule(:content_p) { match(/[a-z|A-Z|0-9|\/|\-|\.|\?|\s|\\|\n|\t|\"|=]/).repeat(1).as(:content_p) }
+ rule(:pre_close) { str("") | str("") }
+ rule(:pre) { (pre_open >> (content_p >> pre_close).repeat(1) ).as(:pre) }
+
#Single character rules
rule(:space) { match("\s").repeat(1) }
rule(:space?) { space.maybe }
@@ -46,7 +55,7 @@ def parse(str)
rule(:eol) { (crlf | lf | tab).as(:eol) }
#Grammar parts
- rule(:format) { italic_tag | bold_tag | line_break | tt_tag | font }
+ rule(:format) { italic_tag | bold_tag | line_break | tt_tag | font | pre }
rule(:text) { ( image | format | letters | eol | new_p | (any.as(:any)) ).repeat(1) }
rule(:ques) { text.repeat(1).as(:text) }
diff --git a/lib/sample_SPQR_questions.xml b/lib/sample_SPQR_questions.xml
new file mode 100644
index 0000000..25021f1
--- /dev/null
+++ b/lib/sample_SPQR_questions.xml
@@ -0,0 +1,21 @@
+
fs = 11025;
tt = (0:round(0.25*fs
+ ))/fs;
Which MATLAB code would you use to gene
+rate the appropriate DTMF signal to represent telephone key number
+ 5? And this is another way.]]>
+
+
+
+ φ) for the followi
+ ng sinusoid where x(t) = cos(ωt + φ);
+
]]>
+
+ function tone=note(keynum,dur)
% Returns a single sinusoid with the key and duration specified
fs = 11025;
tt = 0:1/fs:dur;
f0 = 440*2^((keynum-49)/12);
tone = cos(2*pi*f0*tt);A student wants to modify the function so that the tone created by this function has TWO frequency components. The new tone should be the sum of two sinusoids, one of which is the fundamental and the other of which has a frequency 2 times higher. The amplitudes (and phases) can be the same. Which one of the following is a correct modification that will accomplish this task?
+]]>
+
+x(t) = e2cos(5πt)cos(2πfct)Determine fc.]]>
+
+ƒ0 = 13.4 Hz. Determine the smallest integer value of the sampling rate ƒs so that no aliasing occurs. The units of ƒs are samples per second. You must justify your response by citing a theorem or property about sampling.]]>
+
+Folded Alias: Set the input frequency to ƒ0 = 13 Hz, the input phase to φ = -1.3 rads, and ƒs = 20 Hz. Write down the formula for the output signal, and then write a justification consisting of three steps:
- calculating the values of
for the blue spectral lines in the spectrum of the discrete-time signal x[n] shown in the middle plots, - aliasing
(blue to red), and - transforming x[n] into y(t) using an equation that describes the ideal D-to-C converter and uses the principal aias.
]]>
\ No newline at end of file
diff --git a/lib/spqr_parser.rb b/lib/spqr_parser.rb
index 4f23e51..162172b 100644
--- a/lib/spqr_parser.rb
+++ b/lib/spqr_parser.rb
@@ -1,5 +1,3 @@
-#encoding: utf-8
-
# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
# License version 3 or later. See the COPYRIGHT file for details.
@@ -27,7 +25,8 @@ def parse(str)
rule(:tt_tag) { (str("") | str("") | str("") | str("")).as(:ttype)}
rule(:new_p) { (str("") | str("
") | str("") | str("
")).as(:para)}
rule(:center) { (str("") | str("") | str("") | str("")).as(:center)}
-
+ rule(:asterisk) { str("*").as(:asterisk)}
+ rule(:quote1) { str('"').as(:quote1)}
#Check for any font changes
rule(:font1) { str("") | str("") }
rule(:con) { match(/[a-z|A-Z|0-9]/).repeat(1).as(:con) }
rule(:sub2) { str("") | str("") }
- rule(:sub) { sub1 >> (con | greek).as(:sub) >> sub2 }
+ rule(:sub) { sub1 >> (con | greek | punc.as(:any)).as(:sub) >> sub2 }
rule(:sup1) { str("") | str("") }
rule(:sup2) { str("") | str("") }
- rule(:sup) { sup1 >> (con | greek).as(:sup) >> sup2 }
+ rule(:sup) { sup1 >> space? >>(con | greek | punc.as(:any)).repeat.as(:sup) >> sup2 }
#Single character rules
@@ -89,7 +88,7 @@ def parse(str)
#Grammar parts
rule(:punc) { match(/[^<]/) }
rule(:tags) { font | pre | span | div | image }
- rule(:format) { italic_tag | bold_tag | line_break | tt_tag | fnof | sub | sup | center }
+ rule(:format) { italic_tag | bold_tag | line_break | tt_tag | fnof | sub | sup | center | asterisk | quote1 }
rule(:text) { ( tags | format | letters | eol | new_p | greek | (any.as(:any)) ).repeat(1) }
rule(:ques) { text.repeat.as(:text) }
@@ -100,6 +99,8 @@ def parse(str)
#class UnavailableImage < StandardError; end
class SPQRTransform < Parslet::Transform
+ rule(:quote1 => simple(:quote1)) {'\"'}
+ rule(:asterisk => simple(:asterisk)) {'×'}
rule(:center => simple(:center)) {}
rule(:italic => simple(:italic)) {"'"}
rule(:bold => simple(:bold)) {"!!"}
@@ -114,13 +115,13 @@ class SPQRTransform < Parslet::Transform
rule(:content => sequence(:content)) { content.join}
rule(:span => simple(:span)) { span }
rule(:div => simple(:div)) { div }
- rule(:phi => simple(:phi)) {"\phi"}
- rule(:pi => simple(:pi)) {"\pi"}
- rule(:omega => simple(:omega)) {"\omega"}
+ rule(:phi => simple(:phi)) {"\\phi"}
+ rule(:pi => simple(:pi)) {"\\pi"}
+ rule(:omega => simple(:omega)) {"\\omega"}
rule(:fnof => simple(:fnof)) {"f"}
rule(:con => simple(:con)) { con }
rule(:sub => simple(:sub)) {"_{" + sub + "}"}
- rule(:sup => simple(:sup)) {"^{" + sup + "}"}
+ rule(:sup => sequence(:sup)) {"^{" + sup.join + "}"}
rule(:letters => simple(:letters)) { letters }
rule(:any => simple(:any)) { any }
rule(:image => sequence(:image)) { "MISSING IMAGE: #{image[0].to_s}"}
diff --git a/public/uploads/tmp/20120614-1609-2218-8566/spqr3.xml b/public/uploads/tmp/20120614-1609-2218-8566/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1609-2218-8566/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1612-2221-7986/spqr3.xml b/public/uploads/tmp/20120614-1612-2221-7986/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1612-2221-7986/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1619-2241-4540/spqr3.xml b/public/uploads/tmp/20120614-1619-2241-4540/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1619-2241-4540/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1620-2244-5087/spqr3.xml b/public/uploads/tmp/20120614-1620-2244-5087/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1620-2244-5087/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1621-2247-1190/spqr3.xml b/public/uploads/tmp/20120614-1621-2247-1190/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1621-2247-1190/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1624-2251-3810/spqr3.xml b/public/uploads/tmp/20120614-1624-2251-3810/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1624-2251-3810/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1627-2255-0135/spqr3.xml b/public/uploads/tmp/20120614-1627-2255-0135/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1627-2255-0135/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1628-2259-0062/spqr3.xml b/public/uploads/tmp/20120614-1628-2259-0062/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1628-2259-0062/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1630-2262-9845/spqr3.xml b/public/uploads/tmp/20120614-1630-2262-9845/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1630-2262-9845/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1631-2265-9228/spqr3.xml b/public/uploads/tmp/20120614-1631-2265-9228/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1631-2265-9228/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1632-2268-6737/spqr3.xml b/public/uploads/tmp/20120614-1632-2268-6737/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1632-2268-6737/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1632-2271-7358/spqr3.xml b/public/uploads/tmp/20120614-1632-2271-7358/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1632-2271-7358/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1637-2281-1197/spqr3.xml b/public/uploads/tmp/20120614-1637-2281-1197/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1637-2281-1197/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1638-2284-6690/spqr3.xml b/public/uploads/tmp/20120614-1638-2284-6690/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1638-2284-6690/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1640-2292-9066/spqr3.xml b/public/uploads/tmp/20120614-1640-2292-9066/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1640-2292-9066/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1646-2304-3528/spqr3.xml b/public/uploads/tmp/20120614-1646-2304-3528/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1646-2304-3528/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1709-2348-2915/spqr3.xml b/public/uploads/tmp/20120614-1709-2348-2915/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1709-2348-2915/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1710-2351-8949/spqr3.xml b/public/uploads/tmp/20120614-1710-2351-8949/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1710-2351-8949/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/uploads/tmp/20120614-1720-2398-5985/spqr3.xml b/public/uploads/tmp/20120614-1720-2398-5985/spqr3.xml
new file mode 100644
index 0000000..3d15647
--- /dev/null
+++ b/public/uploads/tmp/20120614-1720-2398-5985/spqr3.xml
@@ -0,0 +1,457 @@
+
+
+
+
+
+ -
+
+
+
fs = 11025;
tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 5? And this is another way.]]>
+
+
+
+
+
+yy = cos(2*π*1336*tt) * cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*tt) + cos(2*π*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*1336*770*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336+770)*tt); ]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) * cos(2*π*(770/fs)*tt);]]>
+
+
+
+
+yy = cos(2*π*(1336/fs)*tt) + cos(2*π*(770/fs)*tt); ]]>
+
+
+
+
+yy = cos(2*π*((1336+770)/fs)*tt);]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_1_A1
+
+0
+
+
+
+QUE_1_A2
+
+100
+
+
+
+QUE_1_A3
+
+0
+
+
+
+QUE_1_A4
+
+0
+
+
+
+QUE_1_A5
+
+0
+
+
+
+QUE_1_A6
+
+50
+
+
+
+QUE_1_A7
+
+0
+
+
+
+
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_3_A1
+
+0
+
+
+
+QUE_3_A2
+
+0
+
+
+
+QUE_3_A3
+
+100
+
+
+
+QUE_3_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:1/8000:1.0;
+xx1 = cos(2*π*440*tt);
+xx2 = cos(2*π*660*tt);
+We want to create a new vector called zz that when played though the speaker with soundsc(zz,8000) will be two sequential tones with the FIRST tone being LOWER in frequency.
In other words, the vectors need to be "concatenated." Which of the following pieces of MATLAB code will do this: ]]>
+
+
+
+
+
+zz = xx1+xx2;
+]]>
+
+
+
+
+zz = xx1.*xx2;
+]]>
+
+
+
+
+zz = [xx1, xx2];
+]]>
+
+
+
+
+zz = [xx2, xx1];
+]]>
+
+
+
+
+zz = xx1, zeros(1,1000), xx2;
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_4_A1
+
+0
+
+
+
+QUE_4_A2
+
+0
+
+
+
+QUE_4_A3
+
+100
+
+
+
+QUE_4_A4
+
+25
+
+
+
+QUE_4_A5
+
+0
+
+
+
+
+-
+
+
+y[n] = 3 -x[n+3] is ... ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+QUE_6_A1
+
+0
+
+
+
+QUE_6_A2
+
+0
+
+
+
+QUE_6_A3
+
+100
+
+
+
+QUE_6_A4
+
+0
+
+
+
+
+-
+
+
+tt = 0:(1/10000):1;
+xx = cos(2*pi*3000*tt);
+Which of the following lines will correctly play the sound? ]]>
+
+
+
+
+
+ soundsc(10000,xx)
+]]>
+
+
+
+
+ soundsc(xx, tt)
+]]>
+
+
+
+
+ soundsc(xx,10000)
+]]>
+
+
+
+
+ soundsc(xx,8000)
+]]>
+
+
+
+
+soundsc(xx,3000) ]]>
+
+
+
+
+ soundsc(0.0001,xx)
+]]>
+
+
+
+
+ soundsc(xx,0.0001)
+]]>
+
+
+
+
+ soundsc(3000,xx)
+]]>
+
+
+
+
+ soundsc(8000,xx)
+]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_7_A1
+
+25
+
+
+
+QUE_7_A2
+
+0
+
+
+
+QUE_7_A3
+
+100
+
+
+
+QUE_7_A4
+
+25
+
+
+
+QUE_7_A5
+
+25
+
+
+
+QUE_7_A6
+
+0
+
+
+
+QUE_7_A7
+
+25
+
+
+
+QUE_7_A8
+
+0
+
+
+
+QUE_7_A9
+
+0
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/fixtures/file_uploads.yml b/test/fixtures/file_uploads.yml
new file mode 100644
index 0000000..2893341
--- /dev/null
+++ b/test/fixtures/file_uploads.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/fixtures/files/spqr3.xml b/test/fixtures/files/spqr3.xml
index 3d15647..644414f 100644
--- a/test/fixtures/files/spqr3.xml
+++ b/test/fixtures/files/spqr3.xml
@@ -454,4 +454,4 @@ xx = cos(2*pi*3000*tt);
-
\ No newline at end of file
+
diff --git a/test/fixtures/files/spqr4.xml b/test/fixtures/files/spqr4.xml
index 9185d3d..e6ac150 100644
--- a/test/fixtures/files/spqr4.xml
+++ b/test/fixtures/files/spqr4.xml
@@ -2479,4 +2479,4 @@ Below are five versions of a function that is supposed to square an input (ve
-
\ No newline at end of file
+
diff --git a/test/functional/qt_import_controller_test.rb b/test/functional/qt_import_controller_test.rb
index 62367ae..11e0323 100644
--- a/test/functional/qt_import_controller_test.rb
+++ b/test/functional/qt_import_controller_test.rb
@@ -1,9 +1,34 @@
+#encoding: utf-8
+
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
require 'test_helper'
class QtImportControllerTest < ActionController::TestCase
-
- test "should_show_form" do
- get :new
- assert_response :success
- end
+
+ setup do
+ @user = Factory.create(:user)
+ @file1 = fixture_file_upload("/files/spqr3.xml", 'xml')
+ @content = 'SPQR'
+ end
+
+ test "should get new" do
+ user_login
+ get :new
+ assert_response :success
+ end
+
+ test "should not get new not logged in" do
+ get :new
+ assert_redirected_to login_path
+ end
+
+ test "should import" do
+ sign_in @user
+ post :create, :file => @file1, :content_types => @content
+ @project = Project.find_by_name("Import")
+ assert(@project.is_member?(@user), "user is member of project")
+ assert_response :success
+ end
end
diff --git a/test/unit/file_upload_test.rb b/test/unit/file_upload_test.rb
index 0595d1a..46ca85f 100644
--- a/test/unit/file_upload_test.rb
+++ b/test/unit/file_upload_test.rb
@@ -1,8 +1,7 @@
require 'test_helper'
class FileUploadTest < ActiveSupport::TestCase
- # Replace this with your real tests.
- test "the truth" do
+ test "the truth" do
assert true
end
end
diff --git a/test/unit/qti_transform_test.rb b/test/unit/qti_transform_test.rb
index c6cb174..8cf318a 100644
--- a/test/unit/qti_transform_test.rb
+++ b/test/unit/qti_transform_test.rb
@@ -120,4 +120,10 @@ class QTITransfromTest < ActiveSupport::TestCase
assert_equal expected, output1
end
+ test "pre_class" do
+ parser = QTIParser.new
+ a = parser.parse('ablah
')
+ p a
+ end
+
end
\ No newline at end of file
diff --git a/test/unit/simple_question_test.rb b/test/unit/simple_question_test.rb
index ac3aa67..26f21f9 100644
--- a/test/unit/simple_question_test.rb
+++ b/test/unit/simple_question_test.rb
@@ -93,6 +93,8 @@ class SimpleQuestionTest < ActiveSupport::TestCase
sq.variate!(qv)
ContentParseAndCache.enable_test_parser = false
end
+
+
# TODO implement the following tests
#
diff --git a/test/unit/spqr_transform_test.rb b/test/unit/spqr_transform_test.rb
index 5eadcee..d118223 100644
--- a/test/unit/spqr_transform_test.rb
+++ b/test/unit/spqr_transform_test.rb
@@ -123,7 +123,7 @@ class SPQRTransfromTest < ActiveSupport::TestCase
test "phi" do
parser = SPQRParser.new
a = parser.parse('φ')
- expected = "\phi"
+ expected = "\\phi"
output1 = SPQRTransform.new.apply(a)
assert_equal expected, output1
end
@@ -131,7 +131,7 @@ class SPQRTransfromTest < ActiveSupport::TestCase
test "pi" do
parser = SPQRParser.new
a = parser.parse('aπ')
- expected = "a\pi"
+ expected = "a\\pi"
output1 = SPQRTransform.new.apply(a)
assert_equal expected, output1
end
@@ -139,7 +139,7 @@ class SPQRTransfromTest < ActiveSupport::TestCase
test "omega" do
parser = SPQRParser.new
a = parser.parse('aω')
- expected = "a\omega"
+ expected = "a\\omega"
output1 = SPQRTransform.new.apply(a)
assert_equal expected, output1
end
@@ -155,7 +155,7 @@ class SPQRTransfromTest < ActiveSupport::TestCase
test "sub" do
parser = SPQRParser.new
a = parser.parse('aφ')
- expected1 = "a_{phi}"
+ expected1 = "a_{\\phi}"
output1 = SPQRTransform.new.apply(a)
assert_equal expected1, output1
b = parser.parse('aeiew')
@@ -167,13 +167,17 @@ class SPQRTransfromTest < ActiveSupport::TestCase
test "sup" do
parser = SPQRParser.new
a = parser.parse('aπ')
- expected1 = "a^{\pi}"
+ expected1 = "a^{\\pi}"
output1 = SPQRTransform.new.apply(a)
assert_equal expected1, output1
b = parser.parse('biefie')
expected2 = "b^{iefie}"
output2 = SPQRTransform.new.apply(b)
assert_equal expected2, output2
+ c = parser.parse('3 -x[n+3]')
+ expected3 = "3^{-x[n+3]}"
+ output3 = SPQRTransform.new.apply(c)
+ assert_equal expected3, output3
end
test "pre_class" do
@@ -219,8 +223,36 @@ class SPQRTransfromTest < ActiveSupport::TestCase
test "3tags" do
parser = SPQRParser.new
a = parser.parse('a')
- expected = "a$$'\pi'$$"
+ expected = "a$$'\\pi'$$"
output1 = SPQRTransform.new.apply(a)
assert_equal expected, output1
end
-end
\ No newline at end of file
+
+ #Test for question that has answer choices that contain a formatting error.
+ # test "answer_choices" do
+ # parser = SPQRParser.new
+ # a = parser.parse('omega-hat = 600 and -600')
+ # b = parser.parse('omega-hat = 6/5 and -6/5')
+ # c = parser.parse('omega-hat = 1.2*pi and -1.2*pi')
+ # d = parser.parse('omega-hat = 0.4*pi and -0.4*pi')
+ # e = parser.parse('omega-hat = pi/5 and -pi/5')
+ # output1 = SPQRTransform.new.apply(a)
+ # output2 = SPQRTransform.new.apply(b)
+ # output3 = SPQRTransform.new.apply(c)
+ # output4 = SPQRTransform.new.apply(d)
+ # output5 = SPQRTransform.new.apply(e)
+ # p output1
+ # p output2
+ # p output3
+ # p output4
+ # p output5
+ # end
+
+ test "asterisk" do
+ parser = SPQRParser.new
+ a = parser.parse('3*4')
+ expected = "3×4"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
+end
From 7abbf7b6a439f60208e43f7af789778814cf1ca5 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Thu, 21 Jun 2012 00:54:40 -0400
Subject: [PATCH 38/60] Had to redo form to be compatible with new Rails.
---
app/views/qt_import/_form.html.erb | 24 +++---
lib/qti_import.rb | 13 ++-
test/fixtures/files/spqr4.xml | 122 ++++++++++++++---------------
3 files changed, 83 insertions(+), 76 deletions(-)
diff --git a/app/views/qt_import/_form.html.erb b/app/views/qt_import/_form.html.erb
index 1e3e73b..242837c 100644
--- a/app/views/qt_import/_form.html.erb
+++ b/app/views/qt_import/_form.html.erb
@@ -1,13 +1,13 @@
-<%= form_tag '/import/qti', :multipart => true, do %>
- <%= label_tag "File", "File" %>
-
- <%= file_field_tag :file %>
-
-
- <%= label_tag "name", "Content Type" %>
-
- <%= select_tag :content_type, options_for_select(@content_types).html_safe, :include_blank => true %>
-
-
- <%= submit_tag "Import" %>
+<%= form_tag("/import/qti", :multipart => true) do %>
+ <%= label_tag("File") %>
+
+ <%= file_field_tag(params[:File]) %>
+
+
+ <%= label_tag("Content Type") %>
+
+ <%= select_tag(:content_type, options_for_select(@content_types).html_safe, :include_blank => true) %>
+
+
+ <%= submit_tag("Import") %>
<% end %>
\ No newline at end of file
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index 539f85a..a1e8b62 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -1,3 +1,5 @@
+#encoding: utf-8
+
# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
# License version 3 or later. See the COPYRIGHT file for details.
@@ -6,7 +8,7 @@
class QTImport
- @@content_types = ['SPQR']
+ @@content_types = [['SPQR','SPQR']]
attr_reader :filename, :content_type, :parser, :transformer
@@ -51,6 +53,9 @@ def self.get_answers(content,parser,transformer,id_num)
for a in 0..(answers.length-1)
b = answers[a].children.children.children
text = b[0].content
+ text.gsub(/δ/,"\\delta")
+ text.gsub(/ω/,"\\omega")
+ text.gsub(/π/,"\\pi")
b1 = parser.parse(text)
ans = transformer.apply(b1)
choice = AnswerChoice.new(:content => ans, :credit => credit[a])
@@ -100,7 +105,10 @@ def self.get_questions(content,parser,transformer)
for p in 0..(x.length-1)
w = x[p].children.children.children
text = w[0].content
- #text.force_encoding('UTF-8')
+ text.gsub(/δ/,"\\delta")
+ text.gsub(/ω/,"\\omega")
+ text.gsub(/π/,"\\pi")
+ text.force_encoding('UTF-8')
v = parser.parse(text)
ques1 = transformer.apply(v)
ques << ques1
@@ -121,7 +129,6 @@ def self.get_questions(content,parser,transformer)
q.answer_choices << AnswerChoice.new(:content => "fake", :credit => 0)
end
end
- Rails.logger.debug{ q.content}
q.save!
questions << q
end
diff --git a/test/fixtures/files/spqr4.xml b/test/fixtures/files/spqr4.xml
index e6ac150..d8bdfe3 100644
--- a/test/fixtures/files/spqr4.xml
+++ b/test/fixtures/files/spqr4.xml
@@ -966,68 +966,68 @@ omega-hat = pi/5 and -pi/5
--
-
-
-h[n] = δ[n] + 2δ[n-1]
-
Find H(ejω) where ω is the normalized frequency called "omega-hat" in the text.
]]>
-
-
-
-
-
-jω) = 1 + 2(-1)]]>
-
-
-
-
-jω) = 1 + 2e-jω]]>
-
-
-
-
-jω) = e-jω - 2jω]]>
-
-
-
-
-jω) = e -jω + e -2jω ]]>
-
-
-
-
-
-
-
-
-
-
-
-QUE_19_A1
-
-0
-
-
-
-QUE_19_A2
-
-100
-
-
-
-QUE_19_A3
-
-0
-
-
-
-QUE_19_A4
-
-0
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
From b8fb54bbe38281e95552dd103d40ea913e0152de Mon Sep 17 00:00:00 2001
From: jrb6
Date: Thu, 21 Jun 2012 09:53:43 -0500
Subject: [PATCH 39/60] Added a check to see if there was no image, if there
isn't, display image name in error box.
---
app/models/logic_library_version.rb | 1 +
lib/asset_methods.rb | 9 +++++++--
lib/image_tag_maker.rb | 9 +++++++--
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/app/models/logic_library_version.rb b/app/models/logic_library_version.rb
index b4caf57..f146992 100644
--- a/app/models/logic_library_version.rb
+++ b/app/models/logic_library_version.rb
@@ -16,6 +16,7 @@ class LogicLibraryVersion < ActiveRecord::Base
after_save :send_to_bullring
scope :ordered, order{version.asc}
+ attr_accessible :code, :deprecated
def name
logic_library.name + " v." + version.to_s
diff --git a/lib/asset_methods.rb b/lib/asset_methods.rb
index e6e94a9..aefd48c 100644
--- a/lib/asset_methods.rb
+++ b/lib/asset_methods.rb
@@ -8,7 +8,12 @@ def get_image_tag_maker
end
def get_asset(local_name)
- attachable_assets.select{|aa| aa.local_name == local_name}.first.asset
+ checknil = attachable_assets.select{|aa| aa.local_name == local_name}.first
+ if checknil.nil?
+ checknil
+ else
+ checknil.asset
+ end
end
-end
\ No newline at end of file
+end
diff --git a/lib/image_tag_maker.rb b/lib/image_tag_maker.rb
index 2cd9883..e37ee04 100644
--- a/lib/image_tag_maker.rb
+++ b/lib/image_tag_maker.rb
@@ -9,7 +9,12 @@ def initialize(attachable)
def make_tag(image_name)
url = Rails.env.production? ? "https" : "http"
url += "://#{Rails.application.config.default_url_options[:host]}/"
- url += "#{@attachable.get_asset(image_name).path(:medium)}"
- "
"
+ temp = @attachable.get_asset(image_name)
+ if(temp != nil)
+ url += temp.path(:medium)
+ "
"
+ else
+ "#{image_name}"
+ end
end
end
From 88776ef5b38697381fdaf4915bbf18bab44be2db Mon Sep 17 00:00:00 2001
From: jrb6
Date: Thu, 21 Jun 2012 10:18:19 -0500
Subject: [PATCH 40/60] Neatened things up
---
lib/asset_methods.rb | 6 +-----
lib/image_tag_maker.rb | 6 +++---
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/lib/asset_methods.rb b/lib/asset_methods.rb
index aefd48c..86e0aaa 100644
--- a/lib/asset_methods.rb
+++ b/lib/asset_methods.rb
@@ -9,11 +9,7 @@ def get_image_tag_maker
def get_asset(local_name)
checknil = attachable_assets.select{|aa| aa.local_name == local_name}.first
- if checknil.nil?
- checknil
- else
- checknil.asset
- end
+ checknil.nil? ? checknil : checknil.asset
end
end
diff --git a/lib/image_tag_maker.rb b/lib/image_tag_maker.rb
index e37ee04..bcaa803 100644
--- a/lib/image_tag_maker.rb
+++ b/lib/image_tag_maker.rb
@@ -9,9 +9,9 @@ def initialize(attachable)
def make_tag(image_name)
url = Rails.env.production? ? "https" : "http"
url += "://#{Rails.application.config.default_url_options[:host]}/"
- temp = @attachable.get_asset(image_name)
- if(temp != nil)
- url += temp.path(:medium)
+ asset_got = @attachable.get_asset(image_name)
+ if !asset_got.nil?
+ url += asset_got.path(:medium)
"
"
else
"#{image_name}"
From e1ca277a9eb230257c4881fbb65f8d7874f37ee8 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sat, 23 Jun 2012 17:15:06 -0400
Subject: [PATCH 41/60] Switching branches
---
app/views/qt_import/_form.html.erb | 2 +-
lib/qti_import.rb | 3 +
lib/quadbase_markup.rb | 3 +-
test/fixtures/files/spqr4.xml | 122 ++++++++++----------
test/unit/quadbase_html_transformer_test.rb | 21 ++++
5 files changed, 88 insertions(+), 63 deletions(-)
diff --git a/app/views/qt_import/_form.html.erb b/app/views/qt_import/_form.html.erb
index 242837c..c2429be 100644
--- a/app/views/qt_import/_form.html.erb
+++ b/app/views/qt_import/_form.html.erb
@@ -1,7 +1,7 @@
<%= form_tag("/import/qti", :multipart => true) do %>
<%= label_tag("File") %>
- <%= file_field_tag(params[:File]) %>
+ <%= file_field_tag(:file) %>
<%= label_tag("Content Type") %>
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index a1e8b62..342833d 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -79,6 +79,9 @@ def self.get_credit(content,id_num)
for i in 0..(numbers.length-1)
j = numbers[i].children.children.last
k = (j.content).to_f
+ if k < 0
+ k = 0
+ end
points << k
end
credits = self.normalize(points)
diff --git a/lib/quadbase_markup.rb b/lib/quadbase_markup.rb
index 32d2117..66df51d 100644
--- a/lib/quadbase_markup.rb
+++ b/lib/quadbase_markup.rb
@@ -18,7 +18,7 @@ def parse(str)
root(:paragraphs)
rule(:paragraphs) { paragraph.repeat.as(:paragraphs) }
- rule(:paragraph) { (( line | bulleted_list | numbered_list ).repeat(1) >> spaces >> eol).as(:paragraph) }
+ rule(:paragraph) { (( line | bulleted_list | numbered_list ).repeat >> spaces >> eol).as(:paragraph) }
rule(:line) { (content >> eol).as(:line) }
rule(:content) { (math | image | bold | italic | text).repeat(1) }
@@ -113,6 +113,7 @@ class QuadbaseHtmlTransformer < Parslet::Transform
rule(:text => simple(:text)) { "#{text}" }
rule(:line => sequence(:entries)) { entries.join }
rule(:paragraph => sequence(:entries)) { "#{entries.join}
" }
+ rule(:paragraph => simple(:paragraph)) { "\n" }
rule(:paragraphs => sequence(:entries)) { entries.join("\n") }
rule(:filename => simple(:filename)) { "#{filename}" }
rule(:image => simple(:filename)) { "" + TagHelper.make_image_tag(filename) + "" }
diff --git a/test/fixtures/files/spqr4.xml b/test/fixtures/files/spqr4.xml
index d8bdfe3..e6ac150 100644
--- a/test/fixtures/files/spqr4.xml
+++ b/test/fixtures/files/spqr4.xml
@@ -966,68 +966,68 @@ omega-hat = pi/5 and -pi/5
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+-
+
+
+h[n] = δ[n] + 2δ[n-1]
+
Find H(ejω) where ω is the normalized frequency called "omega-hat" in the text.
]]>
+
+
+
+
+
+jω) = 1 + 2(-1)]]>
+
+
+
+
+jω) = 1 + 2e-jω]]>
+
+
+
+
+jω) = e-jω - 2jω]]>
+
+
+
+
+jω) = e -jω + e -2jω ]]>
+
+
+
+
+
+
+
+
+
+
+
+QUE_19_A1
+
+0
+
+
+
+QUE_19_A2
+
+100
+
+
+
+QUE_19_A3
+
+0
+
+
+
+QUE_19_A4
+
+0
+
-
-
+
+
-
diff --git a/test/unit/quadbase_html_transformer_test.rb b/test/unit/quadbase_html_transformer_test.rb
index d36ee0f..34b3d10 100644
--- a/test/unit/quadbase_html_transformer_test.rb
+++ b/test/unit/quadbase_html_transformer_test.rb
@@ -39,4 +39,25 @@ class QuadbaseHtmlTransformerTest < ActiveSupport::TestCase
# assert_equal_string_strip_whitespace expected1, output1.inspect()
assert_equal expected2, output2.to_s()
end
+
+ test "adjust_parser_output" do
+ parser = QuadbaseParser.new
+ transformer = QuadbaseHtmlTransformer.new
+ text = "A transmitted message must also have a preamble and a termination
+to mark the beginning and end of the message.
+If the preamble bits are contained in the string row vector !!$ pre, $!!
+the message bits in string row vector !!$ tt, $!!
+and termination bits in string row vector !!$ mm. $!!
+
+
+Each string row vector is an array of characters ('0' or '1') in MATLAB, e.g., '0010110101110'.
+
+
+Which of the following is the correct way
+to form the bit string sent out from modem?
+
+"
+ a = parser.parse(text)
+ p transformer.apply(a)
+ end
end
From 47c7aaf792834178709fdcb1f5864fb5f7dc7c13 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sun, 24 Jun 2012 02:48:51 -0400
Subject: [PATCH 42/60] Optimized the import functions, so this feature should
run faster now. Will clean up and code and look for more HTML tags and
formatting errors.
---
app/controllers/qt_import_controller.rb | 7 +-
lib/qti_import.rb | 295 ++++++++++++++++--------
lib/spqr_parser.rb | 64 ++---
lib/test_import.rb | 156 +++++++++++++
test/fixtures/files/spqr_original.xml | 2 +-
test/unit/spqr_transform_test.rb | 16 ++
6 files changed, 410 insertions(+), 130 deletions(-)
create mode 100644 lib/test_import.rb
diff --git a/app/controllers/qt_import_controller.rb b/app/controllers/qt_import_controller.rb
index 6e364d4..658432e 100644
--- a/app/controllers/qt_import_controller.rb
+++ b/app/controllers/qt_import_controller.rb
@@ -11,12 +11,13 @@ def new
def create
f = params[:file]
document = QTImport.openfile(f.path)
+ project = QTImport.createproject(current_user)
parser, transformer = QTImport.choose_import(params[:content_type])
content = QTImport.iterate_items(document)
# debugger
- questions = QTImport.get_questions(content,parser,transformer)
- project = QTImport.createproject(current_user)
- QTImport.add_questions(project,questions)
+ QTImport.get_questions(project,content,parser,transformer,current_user)
+ # project = QTImport.createproject(current_user)
+ # QTImport.add_questions(project,questions)
# rescue
# render :text => "Sorry, there was a problem with importing your questions."
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index 342833d..f91bf4a 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -16,12 +16,12 @@ def self.content_types
@@content_types
end
- def self.add_questions(project,questions)
- for a in 0..(questions.length-1)
- project.add_question!(questions[a])
- end
- return project
- end
+ # def self.add_questions(project,questions)
+ # for a in 0..(questions.length-1)
+ # project.add_question!(questions[a])
+ # end
+ # return project
+ # end
def self.choose_import(content_type)
if (content_type == 'SPQR')
@@ -37,55 +37,60 @@ def self.createproject(current_user)
a
end
- def self.get_answers(content,parser,transformer,id_num)
- #Find only the relevant answer choices, using the question id number
- answers = Array.new
- z = content.xpath('//presentation//response_lid//response_label')
- for y in 0..(z.length-1)
- label = z[y].attributes["ident"].value
- x = label.match(id_num + "_A")
- if x != nil
- answers << z[y]
- end
- end
- choices = Array.new
- credit = self.get_credit(content,id_num)
- for a in 0..(answers.length-1)
- b = answers[a].children.children.children
- text = b[0].content
- text.gsub(/δ/,"\\delta")
- text.gsub(/ω/,"\\omega")
- text.gsub(/π/,"\\pi")
- b1 = parser.parse(text)
- ans = transformer.apply(b1)
- choice = AnswerChoice.new(:content => ans, :credit => credit[a])
- choices << choice
- end
- return choices
- end
+ # def self.get_answers(content,parser,transformer,id_num)
+ # #Find only the relevant answer choices, using the question id number
+ # answers = Array.new
+ # z = content.xpath('//presentation//response_lid//response_label')
+ # for y in 0..(z.length-1)
+ # label = z[y].attributes["ident"].value
+ # x = label.match(id_num + "_A")
+ # if x != nil
+ # answers << z[y]
+ # end
+ # end
+ # choices = Array.new
+ # credit = self.get_credit(content,id_num)
+ # for a in 0..(answers.length-1)
+ # b = answers[a].children.children.children
+ # text = b[0].content
+ # text.gsub(/δ/,"\\delta")
+ # text.gsub(/ω/,"\\omega")
+ # text.gsub(/π/,"\\pi")
+ # b1 = parser.parse(text)
+ # ans = transformer.apply(b1)
+ # choice = AnswerChoice.new(:content => ans, :credit => credit[a])
+ # choices << choice
+ # end
+ # credit.keep_if {|b| b > 0 }
+ # if credit.length == 0
+ # choice = AnswerChoice.new(:content => 'fake', :credit => 1)
+ # choices << choice
+ # end
+ # return choices
+ # end
- def self.get_credit(content,id_num)
- numbers = Array.new
- points = Array.new
- a = content.xpath('//resprocessing//respcondition')
- for b in 0..(a.length-1)
- c = a[b].children.children[1].children[0]
- label = c.content
- d = label.match(id_num + "_A")
- if d != nil
- numbers << a[b]
- end
- end
- for i in 0..(numbers.length-1)
- j = numbers[i].children.children.last
- k = (j.content).to_f
- if k < 0
- k = 0
- end
- points << k
- end
- credits = self.normalize(points)
- end
+ # def self.get_credit(content,id_num)
+ # numbers = Array.new
+ # points = Array.new
+ # a = content.xpath('//resprocessing//respcondition')
+ # for b in 0..(a.length-1)
+ # c = a[b].children.children[1].children[0]
+ # label = c.content
+ # d = label.match(id_num + "_A")
+ # if d != nil
+ # numbers << a[b]
+ # end
+ # end
+ # for i in 0..(numbers.length-1)
+ # j = numbers[i].children.children.last
+ # k = (j.content).to_f
+ # if k < 0
+ # k = 0
+ # end
+ # points << k
+ # end
+ # credits = self.normalize(points)
+ # end
#Why is this such a roundabout way of getting the question? Well, the
#questions and answer choices have the same tag, with the answer choices
@@ -95,48 +100,48 @@ def self.get_credit(content,id_num)
#and answer choices, in sequence, but this is a problem, especially since
#the number of answer choices per question varies widely. Hence the
#roundabout method.
- def self.get_questions(content,parser,transformer)
- ques = Array.new
- ques_id = Array.new
- questions = Array.new
- for z in 0..(content.length-1)
- y = content[z]
- ques_num = y.attributes["ident"].value
- ques_id << ques_num
- end
- x = content.xpath('//presentation')
- for p in 0..(x.length-1)
- w = x[p].children.children.children
- text = w[0].content
- text.gsub(/δ/,"\\delta")
- text.gsub(/ω/,"\\omega")
- text.gsub(/π/,"\\pi")
- text.force_encoding('UTF-8')
- v = parser.parse(text)
- ques1 = transformer.apply(v)
- ques << ques1
- end
- # debugger
- for a in 0..(ques.length-1)
- answers = self.get_answers(content,parser,transformer,ques_id[a])
- b = Comment.new(:message => ques_id[a])
- q = SimpleQuestion.new(:content => ques[a])
- q.comment_thread = b.comment_thread
- for i in 0..(answers.length-1)
- q.answer_choices << answers[i]
- if answers.length == 0
- q.answer_choices << AnswerChoice.new(:content => "fake", :credit => 0)
- q.answer_choices << AnswerChoice.new(:content => "not real", :credit => 1)
- end
- if answers.length == 1
- q.answer_choices << AnswerChoice.new(:content => "fake", :credit => 0)
- end
- end
- q.save!
- questions << q
- end
- return questions
- end
+ # def self.get_questions(content,parser,transformer)
+ # ques = Array.new
+ # ques_id = Array.new
+ # questions = Array.new
+ # for z in 0..(content.length-1)
+ # y = content[z]
+ # ques_num = y.attributes["ident"].value
+ # ques_id << ques_num
+ # end
+ # x = content.xpath('//presentation')
+ # for p in 0..(x.length-1)
+ # w = x[p].children.children.children
+ # text = w[0].content
+ # text.gsub(/δ/,"\\delta")
+ # text.gsub(/ω/,"\\omega")
+ # text.gsub(/π/,"\\pi")
+ # text.force_encoding('UTF-8')
+ # v = parser.parse(text)
+ # ques1 = transformer.apply(v)
+ # ques << ques1
+ # end
+ # # debugger
+ # for a in 0..(ques.length-1)
+ # answers = self.get_answers(content,parser,transformer,ques_id[a])
+ # b = Comment.new(:message => ques_id[a])
+ # q = SimpleQuestion.new(:content => ques[a])
+ # q.comment_thread = b.comment_thread
+ # for i in 0..(answers.length-1)
+ # q.answer_choices << answers[i]
+ # if answers.length == 0
+ # q.answer_choices << AnswerChoice.new(:content => "fake", :credit => 0)
+ # q.answer_choices << AnswerChoice.new(:content => "not real", :credit => 1)
+ # end
+ # if answers.length == 1
+ # q.answer_choices << AnswerChoice.new(:content => "fake", :credit => 0)
+ # end
+ # end
+ # q.save!
+ # questions << q
+ # end
+ # return questions
+ # end
#For the SPQR content, it seems that a series of questions are embedded
#within each
tag. As such, we search and save only
@@ -146,7 +151,11 @@ def self.iterate_items(document)
end
def self.normalize(array)
- a = array.max
+ if array.max == 0
+ a = 1.0
+ else
+ a = array.max
+ end
for z in 0..(array.length-1)
array[z] = array[z]/a
end
@@ -158,5 +167,97 @@ def self.openfile(filename)
doc = Nokogiri::XML(f)
end
+ def self.get_answers(ans_content,credit_content,parser,transformer)
+ answers = Array.new
+ for z in 0..(ans_content.length-1)
+ label = ans_content[z].attributes["ident"].value
+ credit, credit_content = self.get_credit(credit_content,label)
+ extra_info_start = label.index("A")
+ ques_id = label[0..extra_info_start-2]
+ y = ans_content[z].children.children.children
+ text = y[0].content
+ text.gsub("\xCE\xB4","\\delta")
+ text.gsub("\xCF\x89","\\omega")
+ text.gsub("\xCF\x80","\\pi")
+ x = parser.parse(text)
+ ans = transformer.apply(x)
+ choice = [ques_id,ans,credit]
+ answers << choice
+ end
+ answers
+ end
+
+ def self.get_credit(content,id_num)
+ for a in 0..(content.length-1)
+ b = content[a].children.children[1].children[0]
+ label = b.content
+ c = label.match(id_num)
+ if c != nil
+ d = content[a].children.children.last
+ credit = (d.content).to_f
+ if credit < 0
+ credit = 0
+ end
+ content.delete(content[a])
+ end
+ unless c == nil
+ break
+ end
+ end
+ return credit, content
+ end
+
+ def self.get_questions(project, content, parser, transformer,current_user)
+ ques_nodes = content.xpath('//presentation')
+ ans_nodes = content.xpath('//presentation//response_lid//response_label')
+ credit_nodes = content.xpath('//resprocessing//respcondition')
+ answers = self.get_answers(ans_nodes,credit_nodes,parser,transformer)
+ for a in 0..(content.length-1)
+ b = content[a]
+ ques_id = b.attributes["ident"].value
+ c = ques_nodes[a].children.children.children
+ text = c[0].content
+ text.gsub("\xCE\xB4","\\delta")
+ text.gsub("\xCF\x89","\\omega")
+ text.gsub("\xCF\x80","\\pi")
+ d = parser.parse(text)
+ ques = transformer.apply(d)
+ q = SimpleQuestion.new(:content => ques)
+ q.save!
+ e = Comment.new(:message => ques_id)
+ e.comment_thread = q.comment_thread
+ e.creator = current_user
+ e.save!
+ temp_ans = Array.new
+ # debugger
+ for f in 0..(answers.length-1)
+ if ques_id == answers[f][0]
+ temp_ans << answers[f]
+ end
+ end
+ answers.each_index {|j| if answers[j][0] == ques_id then answers.delete_at(j) end }
+ if temp_ans.length == 0
+ temp_ans << [ques_id,'fake',0]
+ temp_ans << [ques_id,'not real',1]
+ elsif temp_ans.length == 1
+ temp_ans << [ques_id,'fake',0]
+ end
+ temp_credit = Array.new
+ for g in 0..(temp_ans.length-1)
+ temp_credit << temp_ans[g][2]
+ end
+ points = self.normalize(temp_credit)
+ if points.max == 0
+ temp_ans << [ques_id,'fake',1]
+ points << 1.0
+ end
+ for i in 0..(temp_ans.length-1)
+ q.answer_choices << AnswerChoice.new(:content => temp_ans[i][1], :credit => temp_credit[i])
+ end
+ q.save!
+ project.add_question!(q)
+ end
+ end
+
end
diff --git a/lib/spqr_parser.rb b/lib/spqr_parser.rb
index 162172b..ce7b85e 100644
--- a/lib/spqr_parser.rb
+++ b/lib/spqr_parser.rb
@@ -25,8 +25,13 @@ def parse(str)
rule(:tt_tag) { (str("") | str("") | str("") | str("")).as(:ttype)}
rule(:new_p) { (str("") | str("
") | str("") | str("
")).as(:para)}
rule(:center) { (str("") | str("") | str("") | str("")).as(:center)}
+
+ #Things to be changed to HTML entities
rule(:asterisk) { str("*").as(:asterisk)}
- rule(:quote1) { str('"').as(:quote1)}
+ rule(:lthan) { str("<").as(:lthan) }
+ rule(:gthan) { str(">").as(:gthan) }
+ rule(:entities) { asterisk | lthan | gthan }
+
#Check for any font changes
rule(:font1) { str(" simple(:quote1)) {'\"'}
- rule(:asterisk => simple(:asterisk)) {'×'}
- rule(:center => simple(:center)) {}
- rule(:italic => simple(:italic)) {"'"}
- rule(:bold => simple(:bold)) {"!!"}
- rule(:line_break => simple(:break)) {"\n"}
- rule(:ttype => simple(:ttype)) {"$"}
- rule(:para => simple(:para)) {"\n\n"}
- rule(:eol => simple(:eol)) { eol }
+ rule(:lthan => simple(:lthan)) {'<'}
+ rule(:gthan => simple(:gthan)) {'>'}
+ rule(:asterisk => simple(:asterisk)) {'×'}
+ rule(:center => simple(:center)) {}
+ rule(:italic => simple(:italic)) {"'"}
+ rule(:bold => simple(:bold)) {"!!"}
+ rule(:line_break => simple(:break)) {"\n"}
+ rule(:ttype => simple(:ttype)) {"$"}
+ rule(:para => simple(:para)) {"\n\n"}
+ rule(:eol => simple(:eol)) { eol }
rule(:content_f => sequence(:content_f)) {"!!" + content_f.join + "!!"}
- rule(:font => simple(:font)) { font }
+ rule(:font => simple(:font)) { font }
rule(:content_p => sequence(:content_p)) {"$$" + content_p.join + "$$"}
- rule(:pre => simple(:pre)) { pre }
- rule(:content => sequence(:content)) { content.join}
- rule(:span => simple(:span)) { span }
- rule(:div => simple(:div)) { div }
- rule(:phi => simple(:phi)) {"\\phi"}
- rule(:pi => simple(:pi)) {"\\pi"}
- rule(:omega => simple(:omega)) {"\\omega"}
- rule(:fnof => simple(:fnof)) {"f"}
- rule(:con => simple(:con)) { con }
- rule(:sub => simple(:sub)) {"_{" + sub + "}"}
- rule(:sup => sequence(:sup)) {"^{" + sup.join + "}"}
- rule(:letters => simple(:letters)) { letters }
- rule(:any => simple(:any)) { any }
- rule(:image => sequence(:image)) { "MISSING IMAGE: #{image[0].to_s}"}
- rule(:filename => simple(:filename)) { filename.str.gsub(/[\n\t]/, "").strip }
- rule(:text => sequence(:entries)) { entries.join }
+ rule(:pre => simple(:pre)) { pre }
+ rule(:content => sequence(:content)) { content.join}
+ rule(:span => simple(:span)) { span }
+ rule(:div => simple(:div)) { div }
+ rule(:phi => simple(:phi)) {"\\phi"}
+ rule(:pi => simple(:pi)) {"\\pi"}
+ rule(:omega => simple(:omega)) {"\\omega"}
+ rule(:fnof => simple(:fnof)) {"f"}
+ rule(:con => simple(:con)) { con }
+ rule(:sub => simple(:sub)) {"_{" + sub + "}"}
+ rule(:sup => sequence(:sup)) {"^{" + sup.join + "}"}
+ rule(:letters => simple(:letters)) { letters }
+ rule(:any => simple(:any)) { any }
+ rule(:image => sequence(:image)) { "MISSING IMAGE: #{image[0].to_s}"}
+ rule(:filename => simple(:filename)) { filename.str.gsub(/[\n\t]/, "").strip }
+ rule(:text => sequence(:entries)) { entries.join }
end
diff --git a/lib/test_import.rb b/lib/test_import.rb
new file mode 100644
index 0000000..1e2503d
--- /dev/null
+++ b/lib/test_import.rb
@@ -0,0 +1,156 @@
+#encoding: utf-8
+
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
+require 'open-uri'
+require 'spqr_parser.rb'
+
+class TestImport
+
+ @@content_types = [['SPQR','SPQR']]
+
+ attr_reader :filename, :content_type, :parser, :transformer
+
+ def self.content_types
+ @@content_types
+ end
+
+ # def self.add_questions(project,questions)
+ # for a in 0..(questions.length-1)
+ # project.add_question!(questions[a])
+ # end
+ # return project
+ # end
+
+ def self.choose_import(content_type)
+ if (content_type == 'SPQR')
+ a = SPQRParser.new
+ b = SPQRTransform.new
+ end
+ return a, b
+ end
+
+ def self.createproject(current_user)
+ a = Project.create(:name => 'Import')
+ # a.add_member!(current_user)
+ a
+ end
+
+ def self.get_answers(ans_content,credit_content,parser,transformer)
+ answers = Array.new
+ for z in 0..(ans_content.length-1)
+ label = ans_content[z].attributes["ident"].value
+ credit, credit_content = self.get_credit(credit_content,label)
+ extra_info_start = label.index("A")
+ ques_id = label[0..extra_info_start-2]
+ y = ans_content[z].children.children.children
+ text = y[0].content
+ text.gsub("\xCE\xB4","\\delta")
+ text.gsub("\xCF\x89","\\omega")
+ text.gsub("\xCF\x80","\\pi")
+ x = parser.parse(text)
+ ans = transformer.apply(x)
+ choice = [ques_id,ans,credit]
+ answers << choice
+ end
+ answers
+ end
+
+ def self.get_credit(content,id_num)
+ for a in 0..(content.length-1)
+ b = content[a].children.children[1].children[0]
+ label = b.content
+ c = label.match(id_num)
+ if c != nil
+ d = content[a].children.children.last
+ credit = (d.content).to_f
+ if credit < 0
+ credit = 0
+ end
+ content.delete(content[a])
+ end
+ unless c == nil
+ break
+ end
+ end
+ return credit, content
+ end
+
+ def self.get_questions(project, content, parser, transformer,current_user)
+ ques_nodes = content.xpath('//presentation')
+ ans_nodes = content.xpath('//presentation//response_lid//response_label')
+ credit_nodes = content.xpath('//resprocessing//respcondition')
+ answers = self.get_answers(ans_nodes,credit_nodes,parser,transformer)
+ for a in 0..(content.length-1)
+ b = content[a]
+ ques_id = b.attributes["ident"].value
+ c = ques_nodes[a].children.children.children
+ text = c[0].content
+ text.gsub("\xCE\xB4","\\delta")
+ text.gsub("\xCF\x89","\\omega")
+ text.gsub("\xCF\x80","\\pi")
+ d = parser.parse(text)
+ ques = transformer.apply(d)
+ q = SimpleQuestion.new(:content => ques)
+ q.save!
+ e = Comment.new(:message => ques_id)
+ e.comment_thread = q.comment_thread
+ e.creator = current_user
+ e.save!
+ temp_ans = Array.new
+ for f in 0..(answers.length-1)
+ if ques_id == answers[f][0]
+ temp_ans << answers[f]
+ answers.delete_at(f)
+ end
+ end
+ if temp_ans.length == 0
+ temp_ans << [ques_id,'fake',0]
+ temp_ans << [ques_id,'not real',1]
+ elsif temp_ans.length == 1
+ temp_ans << [ques_id,'fake',0]
+ end
+ temp_credit = Array.new
+ for g in 0..(temp_ans.length-1)
+ temp_credit << temp_ans[g][2]
+ end
+ points = self.normalize(temp_credit)
+ if points.max == 0
+ temp_ans << [ques_id,'fake',1]
+ points << 1.0
+ end
+ for i in 0..(temp_ans.length-1)
+ q.answer_choices << AnswerChoice.new(:content => temp_ans[i][1], :credit => temp_credit[i])
+ end
+ q.save!
+ project.add_question!(q)
+ end
+ end
+
+#For the SPQR content, it seems that a series of questions are embedded
+#within each tag. As such, we search and save only
+#content within each tag and "discard" the rest.
+ def self.iterate_items(document)
+ items = document.xpath('//item')
+ end
+
+ def self.normalize(array)
+ if array.max == 0
+ a = 1.0
+ else
+ a = array.max
+ end
+ for z in 0..(array.length-1)
+ array[z] = array[z]/a
+ end
+ return array
+ end
+
+ def self.openfile(filename)
+ f = File.open(filename)
+ doc = Nokogiri::XML(f)
+ end
+
+
+end
\ No newline at end of file
diff --git a/test/fixtures/files/spqr_original.xml b/test/fixtures/files/spqr_original.xml
index 166e652..8734d96 100644
--- a/test/fixtures/files/spqr_original.xml
+++ b/test/fixtures/files/spqr_original.xml
@@ -5062,7 +5062,7 @@ I will complete them now
xx = [9 2 7 5 1 4 2 6 4];
xx(4:6)]]>
+xx = [9 2 7 5 1 4 2 6 4];
xx(4:6)
]]>
diff --git a/test/unit/spqr_transform_test.rb b/test/unit/spqr_transform_test.rb
index d118223..3c2421f 100644
--- a/test/unit/spqr_transform_test.rb
+++ b/test/unit/spqr_transform_test.rb
@@ -255,4 +255,20 @@ class SPQRTransfromTest < ActiveSupport::TestCase
output1 = SPQRTransform.new.apply(a)
assert_equal expected, output1
end
+
+ test "lessthan" do
+ parser = SPQRParser.new
+ a = parser.parse('3<4')
+ expected = "3<4"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
+
+ test "greatthan" do
+ parser = SPQRParser.new
+ a = parser.parse('4>3')
+ expected = "4>3"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
end
From b0bacf03188b91f4d26a1cc645028e642e30e9d3 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sun, 24 Jun 2012 05:42:58 -0400
Subject: [PATCH 43/60] More changes to optimize the import function
---
lib/qti_import.rb | 195 ++++++--------------------
lib/spqr_parser.rb | 10 +-
lib/test_import.rb | 41 +++---
test/fixtures/files/spqr_original.xml | 2 +-
test/unit/spqr_transform_test.rb | 8 ++
5 files changed, 71 insertions(+), 185 deletions(-)
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index f91bf4a..79191fd 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -37,152 +37,17 @@ def self.createproject(current_user)
a
end
- # def self.get_answers(content,parser,transformer,id_num)
- # #Find only the relevant answer choices, using the question id number
- # answers = Array.new
- # z = content.xpath('//presentation//response_lid//response_label')
- # for y in 0..(z.length-1)
- # label = z[y].attributes["ident"].value
- # x = label.match(id_num + "_A")
- # if x != nil
- # answers << z[y]
- # end
- # end
- # choices = Array.new
- # credit = self.get_credit(content,id_num)
- # for a in 0..(answers.length-1)
- # b = answers[a].children.children.children
- # text = b[0].content
- # text.gsub(/δ/,"\\delta")
- # text.gsub(/ω/,"\\omega")
- # text.gsub(/π/,"\\pi")
- # b1 = parser.parse(text)
- # ans = transformer.apply(b1)
- # choice = AnswerChoice.new(:content => ans, :credit => credit[a])
- # choices << choice
- # end
- # credit.keep_if {|b| b > 0 }
- # if credit.length == 0
- # choice = AnswerChoice.new(:content => 'fake', :credit => 1)
- # choices << choice
- # end
- # return choices
- # end
-
- # def self.get_credit(content,id_num)
- # numbers = Array.new
- # points = Array.new
- # a = content.xpath('//resprocessing//respcondition')
- # for b in 0..(a.length-1)
- # c = a[b].children.children[1].children[0]
- # label = c.content
- # d = label.match(id_num + "_A")
- # if d != nil
- # numbers << a[b]
- # end
- # end
- # for i in 0..(numbers.length-1)
- # j = numbers[i].children.children.last
- # k = (j.content).to_f
- # if k < 0
- # k = 0
- # end
- # points << k
- # end
- # credits = self.normalize(points)
- # end
-
-#Why is this such a roundabout way of getting the question? Well, the
-#questions and answer choices have the same tag, with the answer choices
-#nested more deeply. I can do a specific search for the path the answer
-#choices are on and get those back. But, I can't do a more general
-#search and get only questions back. Each time it returns the questions
-#and answer choices, in sequence, but this is a problem, especially since
-#the number of answer choices per question varies widely. Hence the
-#roundabout method.
- # def self.get_questions(content,parser,transformer)
- # ques = Array.new
- # ques_id = Array.new
- # questions = Array.new
- # for z in 0..(content.length-1)
- # y = content[z]
- # ques_num = y.attributes["ident"].value
- # ques_id << ques_num
- # end
- # x = content.xpath('//presentation')
- # for p in 0..(x.length-1)
- # w = x[p].children.children.children
- # text = w[0].content
- # text.gsub(/δ/,"\\delta")
- # text.gsub(/ω/,"\\omega")
- # text.gsub(/π/,"\\pi")
- # text.force_encoding('UTF-8')
- # v = parser.parse(text)
- # ques1 = transformer.apply(v)
- # ques << ques1
- # end
- # # debugger
- # for a in 0..(ques.length-1)
- # answers = self.get_answers(content,parser,transformer,ques_id[a])
- # b = Comment.new(:message => ques_id[a])
- # q = SimpleQuestion.new(:content => ques[a])
- # q.comment_thread = b.comment_thread
- # for i in 0..(answers.length-1)
- # q.answer_choices << answers[i]
- # if answers.length == 0
- # q.answer_choices << AnswerChoice.new(:content => "fake", :credit => 0)
- # q.answer_choices << AnswerChoice.new(:content => "not real", :credit => 1)
- # end
- # if answers.length == 1
- # q.answer_choices << AnswerChoice.new(:content => "fake", :credit => 0)
- # end
- # end
- # q.save!
- # questions << q
- # end
- # return questions
- # end
-
-#For the SPQR content, it seems that a series of questions are embedded
-#within each tag. As such, we search and save only
-#content within each tag and "discard" the rest.
- def self.iterate_items(document)
- items = document.xpath('//item')
- end
-
- def self.normalize(array)
- if array.max == 0
- a = 1.0
- else
- a = array.max
- end
- for z in 0..(array.length-1)
- array[z] = array[z]/a
- end
- return array
- end
-
- def self.openfile(filename)
- f = File.open(filename)
- doc = Nokogiri::XML(f)
- end
-
def self.get_answers(ans_content,credit_content,parser,transformer)
- answers = Array.new
+ answers = Hash.new
for z in 0..(ans_content.length-1)
label = ans_content[z].attributes["ident"].value
- credit, credit_content = self.get_credit(credit_content,label)
- extra_info_start = label.index("A")
- ques_id = label[0..extra_info_start-2]
+ credit = self.get_credit(credit_content,label)
y = ans_content[z].children.children.children
text = y[0].content
- text.gsub("\xCE\xB4","\\delta")
- text.gsub("\xCF\x89","\\omega")
- text.gsub("\xCF\x80","\\pi")
x = parser.parse(text)
ans = transformer.apply(x)
- choice = [ques_id,ans,credit]
- answers << choice
+ choice = [ans,credit]
+ answers[label] = choice
end
answers
end
@@ -198,13 +63,12 @@ def self.get_credit(content,id_num)
if credit < 0
credit = 0
end
- content.delete(content[a])
end
unless c == nil
break
end
end
- return credit, content
+ return credit
end
def self.get_questions(project, content, parser, transformer,current_user)
@@ -216,10 +80,7 @@ def self.get_questions(project, content, parser, transformer,current_user)
b = content[a]
ques_id = b.attributes["ident"].value
c = ques_nodes[a].children.children.children
- text = c[0].content
- text.gsub("\xCE\xB4","\\delta")
- text.gsub("\xCF\x89","\\omega")
- text.gsub("\xCF\x80","\\pi")
+ text = c[0].content
d = parser.parse(text)
ques = transformer.apply(d)
q = SimpleQuestion.new(:content => ques)
@@ -230,29 +91,30 @@ def self.get_questions(project, content, parser, transformer,current_user)
e.save!
temp_ans = Array.new
# debugger
- for f in 0..(answers.length-1)
- if ques_id == answers[f][0]
- temp_ans << answers[f]
+ for f in 0..(answers.keys.length-1)
+ k = answers.keys[f]
+ if k.match(ques_id) != nil
+ temp_ans << answers[k]
end
end
- answers.each_index {|j| if answers[j][0] == ques_id then answers.delete_at(j) end }
+ answers.each_key {|j| if j.match(ques_id) then answers.delete(j) end }
if temp_ans.length == 0
- temp_ans << [ques_id,'fake',0]
- temp_ans << [ques_id,'not real',1]
+ temp_ans << ['fake',0]
+ temp_ans << ['not real',1]
elsif temp_ans.length == 1
- temp_ans << [ques_id,'fake',0]
+ temp_ans << ['fake',0]
end
temp_credit = Array.new
for g in 0..(temp_ans.length-1)
- temp_credit << temp_ans[g][2]
+ temp_credit << temp_ans[g][1]
end
points = self.normalize(temp_credit)
if points.max == 0
- temp_ans << [ques_id,'fake',1]
+ temp_ans << ['fake',1]
points << 1.0
end
for i in 0..(temp_ans.length-1)
- q.answer_choices << AnswerChoice.new(:content => temp_ans[i][1], :credit => temp_credit[i])
+ q.answer_choices << AnswerChoice.new(:content => temp_ans[i][0], :credit => temp_credit[i])
end
q.save!
project.add_question!(q)
@@ -260,4 +122,27 @@ def self.get_questions(project, content, parser, transformer,current_user)
end
+#For the SPQR content, it seems that a series of questions are embedded
+#within each tag. As such, we search and save only
+#content within each tag and "discard" the rest.
+ def self.iterate_items(document)
+ items = document.xpath('//item')
+ end
+
+ def self.normalize(array)
+ if array.max == 0
+ a = 1.0
+ else
+ a = array.max
+ end
+ for z in 0..(array.length-1)
+ array[z] = array[z]/a
+ end
+ return array
+ end
+
+ def self.openfile(filename)
+ f = File.open(filename)
+ doc = Nokogiri::XML(f)
+ end
end
diff --git a/lib/spqr_parser.rb b/lib/spqr_parser.rb
index ce7b85e..cb9f4e1 100644
--- a/lib/spqr_parser.rb
+++ b/lib/spqr_parser.rb
@@ -63,10 +63,11 @@ def parse(str)
rule(:div) { ( div_open >> content >> div_close ).as(:div)}
#Greek letters
+ rule(:delta) { str("\\xCE\\xB4").as(:delta) }
rule(:phi) { str("φ").as(:phi) }
- rule(:pi) { ( str("π") ).as(:pi) }
- rule(:omega) { str("ω").as(:omega) }
- rule(:greek) { phi | pi | omega }
+ rule(:pi) { ( str("π") | str("\\xCF\\x80") ).as(:pi) }
+ rule(:omega) { ( str("ω") | str("\\xCF\\x89") ).as(:omega) }
+ rule(:greek) { delta | phi | pi | omega }
#Superscripts and Subscripts
rule(:sub1) { str("") | str("") }
@@ -113,7 +114,7 @@ class SPQRTransform < Parslet::Transform
rule(:line_break => simple(:break)) {"\n"}
rule(:ttype => simple(:ttype)) {"$"}
rule(:para => simple(:para)) {"\n\n"}
- rule(:eol => simple(:eol)) { eol }
+ rule(:eol => simple(:eol)) {}
rule(:content_f => sequence(:content_f)) {"!!" + content_f.join + "!!"}
rule(:font => simple(:font)) { font }
rule(:content_p => sequence(:content_p)) {"$$" + content_p.join + "$$"}
@@ -121,6 +122,7 @@ class SPQRTransform < Parslet::Transform
rule(:content => sequence(:content)) { content.join}
rule(:span => simple(:span)) { span }
rule(:div => simple(:div)) { div }
+ rule(:delta => simple(:delta)) {"\\delta"}
rule(:phi => simple(:phi)) {"\\phi"}
rule(:pi => simple(:pi)) {"\\pi"}
rule(:omega => simple(:omega)) {"\\omega"}
diff --git a/lib/test_import.rb b/lib/test_import.rb
index 1e2503d..81284de 100644
--- a/lib/test_import.rb
+++ b/lib/test_import.rb
@@ -38,21 +38,16 @@ def self.createproject(current_user)
end
def self.get_answers(ans_content,credit_content,parser,transformer)
- answers = Array.new
+ answers = Hash.new
for z in 0..(ans_content.length-1)
label = ans_content[z].attributes["ident"].value
- credit, credit_content = self.get_credit(credit_content,label)
- extra_info_start = label.index("A")
- ques_id = label[0..extra_info_start-2]
+ credit = self.get_credit(credit_content,label)
y = ans_content[z].children.children.children
text = y[0].content
- text.gsub("\xCE\xB4","\\delta")
- text.gsub("\xCF\x89","\\omega")
- text.gsub("\xCF\x80","\\pi")
x = parser.parse(text)
ans = transformer.apply(x)
- choice = [ques_id,ans,credit]
- answers << choice
+ choice = [ans,credit]
+ answers[label] = choice
end
answers
end
@@ -68,13 +63,12 @@ def self.get_credit(content,id_num)
if credit < 0
credit = 0
end
- content.delete(content[a])
end
unless c == nil
break
end
end
- return credit, content
+ return credit
end
def self.get_questions(project, content, parser, transformer,current_user)
@@ -86,10 +80,7 @@ def self.get_questions(project, content, parser, transformer,current_user)
b = content[a]
ques_id = b.attributes["ident"].value
c = ques_nodes[a].children.children.children
- text = c[0].content
- text.gsub("\xCE\xB4","\\delta")
- text.gsub("\xCF\x89","\\omega")
- text.gsub("\xCF\x80","\\pi")
+ text = c[0].content
d = parser.parse(text)
ques = transformer.apply(d)
q = SimpleQuestion.new(:content => ques)
@@ -99,29 +90,29 @@ def self.get_questions(project, content, parser, transformer,current_user)
e.creator = current_user
e.save!
temp_ans = Array.new
- for f in 0..(answers.length-1)
- if ques_id == answers[f][0]
- temp_ans << answers[f]
- answers.delete_at(f)
+ for f in 0..(answers.keys.length-1)
+ k = answers.keys[f]
+ if k.match(ques_id) != nil
+ temp_ans << answers[k]
end
end
if temp_ans.length == 0
- temp_ans << [ques_id,'fake',0]
- temp_ans << [ques_id,'not real',1]
+ temp_ans << ['fake',0]
+ temp_ans << ['not real',1]
elsif temp_ans.length == 1
- temp_ans << [ques_id,'fake',0]
+ temp_ans << ['fake',0]
end
temp_credit = Array.new
for g in 0..(temp_ans.length-1)
- temp_credit << temp_ans[g][2]
+ temp_credit << temp_ans[g][1]
end
points = self.normalize(temp_credit)
if points.max == 0
- temp_ans << [ques_id,'fake',1]
+ temp_ans << ['fake',1]
points << 1.0
end
for i in 0..(temp_ans.length-1)
- q.answer_choices << AnswerChoice.new(:content => temp_ans[i][1], :credit => temp_credit[i])
+ q.answer_choices << AnswerChoice.new(:content => temp_ans[i][0], :credit => temp_credit[i])
end
q.save!
project.add_question!(q)
diff --git a/test/fixtures/files/spqr_original.xml b/test/fixtures/files/spqr_original.xml
index 8734d96..b57e10b 100644
--- a/test/fixtures/files/spqr_original.xml
+++ b/test/fixtures/files/spqr_original.xml
@@ -6422,7 +6422,7 @@ On the ECE2025 WebCT homepage.
tan(90);
z = 8 + 7j; w = -5-9j;
conj(z+w);
-pp = cos(5*pi); gg = sqrt(99+pp); (Note: it is possible to cut and paste from WebCT to MATLAB.)
At the end of these commands, what is the variable ans equal to? ]]>
+pp = cos(5*pi); gg = sqrt(99+pp);(Note: it is possible to cut and paste from WebCT to MATLAB.)
At the end of these commands, what is the variable ans equal to? ]]>
diff --git a/test/unit/spqr_transform_test.rb b/test/unit/spqr_transform_test.rb
index 3c2421f..1364aa2 100644
--- a/test/unit/spqr_transform_test.rb
+++ b/test/unit/spqr_transform_test.rb
@@ -120,6 +120,14 @@ class SPQRTransfromTest < ActiveSupport::TestCase
assert_equal expected, output1
end
+ test "delta" do
+ parser = SPQRParser.new
+ a = parser.parse('\xCE\xB4')
+ expected = "\\delta"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
+
test "phi" do
parser = SPQRParser.new
a = parser.parse('φ')
From 69a5ecc757b543ce151ebf9953023b0e33a51fab Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Tue, 26 Jun 2012 14:40:42 -0400
Subject: [PATCH 44/60] Made the import function a little bit faster and added
more things to the parser, including the ability to handle links embedded in
questions.
---
lib/qti_import.rb | 95 ++++++++++++++-------------
lib/spqr_parser.rb | 28 ++++++--
lib/test_import.rb | 87 +++++++++++-------------
test/fixtures/files/spqr_original.xml | 4 +-
test/unit/spqr_transform_test.rb | 53 ++++++++-------
5 files changed, 144 insertions(+), 123 deletions(-)
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index 79191fd..fbd22aa 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -3,6 +3,7 @@
# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
# License version 3 or later. See the COPYRIGHT file for details.
+require 'htmlentities'
require 'open-uri'
require 'spqr_parser.rb'
@@ -37,50 +38,49 @@ def self.createproject(current_user)
a
end
- def self.get_answers(ans_content,credit_content,parser,transformer)
- answers = Hash.new
- for z in 0..(ans_content.length-1)
- label = ans_content[z].attributes["ident"].value
- credit = self.get_credit(credit_content,label)
- y = ans_content[z].children.children.children
- text = y[0].content
- x = parser.parse(text)
- ans = transformer.apply(x)
- choice = [ans,credit]
- answers[label] = choice
- end
- answers
- end
+ # def self.get_answers(ans_content,credit_content,parser,transformer)
+ # answers = Hash.new
+ # for z in 0..(ans_content.length-1)
+ # label = ans_content[z].attributes["ident"].value
+ # credit = self.get_credit(credit_content,label)
+ # y = ans_content[z].children.children.children
+ # text = y[0].content
+ # x = parser.parse(text)
+ # ans = transformer.apply(x)
+ # choice = [ans,credit]
+ # answers[label] = choice
+ # end
+ # answers
+ # end
- def self.get_credit(content,id_num)
+ def self.get_credit(content)
+ credit = Hash.new
for a in 0..(content.length-1)
b = content[a].children.children[1].children[0]
label = b.content
- c = label.match(id_num)
- if c != nil
- d = content[a].children.children.last
- credit = (d.content).to_f
- if credit < 0
- credit = 0
- end
- end
- unless c == nil
- break
- end
+ c = content[a].children.children.last
+ d = (c.content).to_f
+ if d < 0
+ d = 0
+ end
+ credit[label] = d
end
return credit
end
def self.get_questions(project, content, parser, transformer,current_user)
+ coder = HTMLEntities.new
ques_nodes = content.xpath('//presentation')
- ans_nodes = content.xpath('//presentation//response_lid//response_label')
+ # ans_nodes = content.xpath('//presentation//response_lid//response_label')
credit_nodes = content.xpath('//resprocessing//respcondition')
- answers = self.get_answers(ans_nodes,credit_nodes,parser,transformer)
+ # answers = self.get_answers(ans_nodes,credit_nodes,parser,transformer)
+ credit = get_credit(credit_nodes)
for a in 0..(content.length-1)
b = content[a]
ques_id = b.attributes["ident"].value
c = ques_nodes[a].children.children.children
text = c[0].content
+ text = coder.decode(text)
d = parser.parse(text)
ques = transformer.apply(d)
q = SimpleQuestion.new(:content => ques)
@@ -90,31 +90,36 @@ def self.get_questions(project, content, parser, transformer,current_user)
e.creator = current_user
e.save!
temp_ans = Array.new
+ temp_credit = Array.new
# debugger
- for f in 0..(answers.keys.length-1)
- k = answers.keys[f]
- if k.match(ques_id) != nil
- temp_ans << answers[k]
- end
+ f = content[a].xpath('.//response_lid//response_label')
+ for g in 0..(f.length-1)
+ label = f[g].attributes["ident"].value
+ temp_credit << credit[label]
+ h = f[g].children.children.children
+ text = h[0].content
+ text = coder.decode(text)
+ i = parser.parse(text)
+ ans = transformer.apply(i)
+ temp_ans << ans
end
- answers.each_key {|j| if j.match(ques_id) then answers.delete(j) end }
+ # answers.each_key {|j| if j.match(ques_id) then answers.delete(j) end }
if temp_ans.length == 0
- temp_ans << ['fake',0]
- temp_ans << ['not real',1]
+ temp_ans << 'fake'
+ temp_credit << 0
+ temp_ans << 'not real'
+ temp_credit << 1
elsif temp_ans.length == 1
- temp_ans << ['fake',0]
- end
- temp_credit = Array.new
- for g in 0..(temp_ans.length-1)
- temp_credit << temp_ans[g][1]
- end
+ temp_ans << 'fake'
+ temp_credit << 0
+ end
points = self.normalize(temp_credit)
if points.max == 0
- temp_ans << ['fake',1]
+ temp_ans << 'fake'
points << 1.0
end
- for i in 0..(temp_ans.length-1)
- q.answer_choices << AnswerChoice.new(:content => temp_ans[i][0], :credit => temp_credit[i])
+ for j in 0..(temp_ans.length-1)
+ q.answer_choices << AnswerChoice.new(:content => temp_ans[j], :credit => temp_credit[j])
end
q.save!
project.add_question!(q)
diff --git a/lib/spqr_parser.rb b/lib/spqr_parser.rb
index cb9f4e1..d44f753 100644
--- a/lib/spqr_parser.rb
+++ b/lib/spqr_parser.rb
@@ -18,6 +18,16 @@ def parse(str)
rule(:attribute) { attribute_con >> quote >> attribute_con >> quote }
rule(:image) { (image_start_tag >> space? >> (( file | attribute ).repeat(1)) >> space? >> image_end_tag.maybe ).as(:image) }
+ #Check for any external links
+ rule(:link1) { str("") }
+ rule(:address) { match(/[a-z|A-Z|0-9|\/|\-|\.|\?|\s|\\|\n|\t|\_|\{|\}|=|]/).repeat(1).as(:address) }
+ rule(:link_info) { space? >> str("href=") >> quote.maybe >> address >> quote.maybe }
+ rule(:link) { (link1 >> space? >> (( link_info | attribute).repeat(1)) >> space? >> link2.maybe ) }
+ rule(:link_name) { match(/[a-z|A-Z|0-9|\/|\-|\.|\?|\s|\\|\n|\t|\_|\{|\}|=|\"]/).repeat(1).as(:link_name) }
+ rule(:link_end) { str("") | str("") }
+ rule(:link_full) { ( link >> link_name.maybe >> link_end ).as(:link_info)}
+
#Check for formatting
rule(:italic_tag) { (str("") | str("") | str("") | str("")).as(:italic) }
rule(:bold_tag) { (str("") | str("") | str("") | str("")).as(:bold) }
@@ -30,7 +40,9 @@ def parse(str)
rule(:asterisk) { str("*").as(:asterisk)}
rule(:lthan) { str("<").as(:lthan) }
rule(:gthan) { str(">").as(:gthan) }
- rule(:entities) { asterisk | lthan | gthan }
+ rule(:apos) { str("'").as(:apos) }
+ rule(:quote1) { str('"').as(:quote1)}
+ rule(:entities) { asterisk | lthan | gthan | apos | quote1 }
#Check for any font changes
rule(:font1) { str(" simple(:quote1)) {'"'}
rule(:lthan => simple(:lthan)) {'<'}
rule(:gthan => simple(:gthan)) {'>'}
rule(:asterisk => simple(:asterisk)) {'×'}
+ rule(:apos => simple(:apos)) {'''}
rule(:center => simple(:center)) {}
rule(:italic => simple(:italic)) {"'"}
rule(:bold => simple(:bold)) {"!!"}
@@ -115,7 +129,7 @@ class SPQRTransform < Parslet::Transform
rule(:ttype => simple(:ttype)) {"$"}
rule(:para => simple(:para)) {"\n\n"}
rule(:eol => simple(:eol)) {}
- rule(:content_f => sequence(:content_f)) {"!!" + content_f.join + "!!"}
+ rule(:content_f => sequence(:content_f)) {"'" + content_f.join + "'"}
rule(:font => simple(:font)) { font }
rule(:content_p => sequence(:content_p)) {"$$" + content_p.join + "$$"}
rule(:pre => simple(:pre)) { pre }
@@ -132,7 +146,11 @@ class SPQRTransform < Parslet::Transform
rule(:sup => sequence(:sup)) {"^{" + sup.join + "}"}
rule(:letters => simple(:letters)) { letters }
rule(:any => simple(:any)) { any }
- rule(:image => sequence(:image)) { "MISSING IMAGE: #{image[0].to_s}"}
+ rule(:image => sequence(:image)) { "\[MISSING IMAGE: #{image[0].to_s}\]"}
rule(:filename => simple(:filename)) { filename.str.gsub(/[\n\t]/, "").strip }
+ rule(:address => simple(:address)) { "\[LINK TO: #{address.to_s}\] "}
+ rule(:link_name => simple(:link_name)) { link_name }
+ rule(:link_info => simple(:link_info)) { link_info }
+ rule(:link_info => sequence(:info)) { info.join }
rule(:text => sequence(:entries)) { entries.join }
end
diff --git a/lib/test_import.rb b/lib/test_import.rb
index 81284de..96f2b98 100644
--- a/lib/test_import.rb
+++ b/lib/test_import.rb
@@ -16,13 +16,6 @@ def self.content_types
@@content_types
end
- # def self.add_questions(project,questions)
- # for a in 0..(questions.length-1)
- # project.add_question!(questions[a])
- # end
- # return project
- # end
-
def self.choose_import(content_type)
if (content_type == 'SPQR')
a = SPQRParser.new
@@ -37,45 +30,27 @@ def self.createproject(current_user)
a
end
- def self.get_answers(ans_content,credit_content,parser,transformer)
- answers = Hash.new
- for z in 0..(ans_content.length-1)
- label = ans_content[z].attributes["ident"].value
- credit = self.get_credit(credit_content,label)
- y = ans_content[z].children.children.children
- text = y[0].content
- x = parser.parse(text)
- ans = transformer.apply(x)
- choice = [ans,credit]
- answers[label] = choice
- end
- answers
- end
-
- def self.get_credit(content,id_num)
+ def self.get_credit(content)
+ credit = Hash.new
for a in 0..(content.length-1)
b = content[a].children.children[1].children[0]
label = b.content
- c = label.match(id_num)
- if c != nil
- d = content[a].children.children.last
- credit = (d.content).to_f
- if credit < 0
- credit = 0
+ c = content[a].children.children.last
+ d = (c.content).to_f
+ if d < 0
+ d = 0
end
- end
- unless c == nil
- break
- end
+ credit[label] = d
end
return credit
end
def self.get_questions(project, content, parser, transformer,current_user)
ques_nodes = content.xpath('//presentation')
- ans_nodes = content.xpath('//presentation//response_lid//response_label')
+ # ans_nodes = content.xpath('//presentation//response_lid//response_label')
credit_nodes = content.xpath('//resprocessing//respcondition')
- answers = self.get_answers(ans_nodes,credit_nodes,parser,transformer)
+ credit = get_credit(credit_nodes)
+ # answers = self.get_answers(ans_nodes,credit_nodes,parser,transformer)
for a in 0..(content.length-1)
b = content[a]
ques_id = b.attributes["ident"].value
@@ -90,29 +65,43 @@ def self.get_questions(project, content, parser, transformer,current_user)
e.creator = current_user
e.save!
temp_ans = Array.new
- for f in 0..(answers.keys.length-1)
- k = answers.keys[f]
- if k.match(ques_id) != nil
- temp_ans << answers[k]
- end
+ temp_credit = Array.new
+ f = content[a].xpath('//response_lid//response_label')
+ for g in 0..(f.length-1)
+ label = f[g].attributes["ident"].value
+ temp_credit << credit[label]
+ h = f[g].children.children.children
+ text = h[0].content
+ i = parser.parse(text)
+ ans = transformer.apply(i)
+ temp_ans << ans
end
+ # for f in 0..(answers.keys.length-1)
+ # k = answers.keys[f]
+ # if k.match(ques_id) != nil
+ # temp_ans << answers[k]
+ # end
+ # end
+ # answers.each_key {|j| if j.match(ques_id) then answers.delete(j) end }
if temp_ans.length == 0
- temp_ans << ['fake',0]
- temp_ans << ['not real',1]
+ temp_ans << 'fake'
+ temp_credit << 0
+ temp_ans << 'not real'
+ temp_credit << 1
elsif temp_ans.length == 1
- temp_ans << ['fake',0]
- end
- temp_credit = Array.new
- for g in 0..(temp_ans.length-1)
- temp_credit << temp_ans[g][1]
+ temp_ans << 'fake'
+ temp_credit << 0
end
+ # for g in 0..(temp_ans.length-1)
+ # temp_credit << temp_ans[g][1]
+ # end
points = self.normalize(temp_credit)
if points.max == 0
- temp_ans << ['fake',1]
+ temp_ans << 'fake'
points << 1.0
end
for i in 0..(temp_ans.length-1)
- q.answer_choices << AnswerChoice.new(:content => temp_ans[i][0], :credit => temp_credit[i])
+ q.answer_choices << AnswerChoice.new(:content => temp_ans[i], :credit => temp_credit[i])
end
q.save!
project.add_question!(q)
diff --git a/test/fixtures/files/spqr_original.xml b/test/fixtures/files/spqr_original.xml
index b57e10b..6603651 100644
--- a/test/fixtures/files/spqr_original.xml
+++ b/test/fixtures/files/spqr_original.xml
@@ -7561,7 +7561,7 @@ wc = 0.2*pi;
sincwc = sin(wc*(nn-M/2))./(pi*(nn-M/2));
sincwc(M/2 + 1) = wc/pi;
bb = hamm.*sincwc;
-
+
Choose all correct answers from followings, which will evaluate the frequency response of bb at frequency π.
@@ -10690,7 +10690,7 @@ One sinusoidal shape centered at 400 Hz that varies between 365 Hz
plus two sinusoidal shapes: one centered at
+A straight line at 2000 Hz plus two sinusoidal shapes: one centered at
2750 Hz varying plus or
minus 10 Hz; the other centered at 1250 Hz varying plus or
minus 10 Hz.
diff --git a/test/unit/spqr_transform_test.rb b/test/unit/spqr_transform_test.rb
index 1364aa2..3eb786f 100644
--- a/test/unit/spqr_transform_test.rb
+++ b/test/unit/spqr_transform_test.rb
@@ -38,7 +38,7 @@ class SPQRTransfromTest < ActiveSupport::TestCase
test "text_w_images" do
parser = SPQRParser.new
a = parser.parse(samples[0])
- expected = "iejfeiMISSING IMAGE: /ece2025/cgi-bin/mimetex.exe?\\hat\\omega blue"
+ expected = "iejfei[MISSING IMAGE: /ece2025/cgi-bin/mimetex.exe?\\hat\\omega] blue"
output1 = SPQRTransform.new.apply(a)
assert_equal expected, output1
end
@@ -116,7 +116,7 @@ class SPQRTransfromTest < ActiveSupport::TestCase
parser = SPQRParser.new
a = parser.parse(samples[1])
output1 = SPQRTransform.new.apply(a)
- expected = "Determine the smallest !!integer!! value of the sampling rate"
+ expected = "Determine the smallest 'integer' value of the sampling rate"
assert_equal expected, output1
end
@@ -236,26 +236,6 @@ class SPQRTransfromTest < ActiveSupport::TestCase
assert_equal expected, output1
end
- #Test for question that has answer choices that contain a formatting error.
- # test "answer_choices" do
- # parser = SPQRParser.new
- # a = parser.parse('omega-hat = 600 and -600')
- # b = parser.parse('omega-hat = 6/5 and -6/5')
- # c = parser.parse('omega-hat = 1.2*pi and -1.2*pi')
- # d = parser.parse('omega-hat = 0.4*pi and -0.4*pi')
- # e = parser.parse('omega-hat = pi/5 and -pi/5')
- # output1 = SPQRTransform.new.apply(a)
- # output2 = SPQRTransform.new.apply(b)
- # output3 = SPQRTransform.new.apply(c)
- # output4 = SPQRTransform.new.apply(d)
- # output5 = SPQRTransform.new.apply(e)
- # p output1
- # p output2
- # p output3
- # p output4
- # p output5
- # end
-
test "asterisk" do
parser = SPQRParser.new
a = parser.parse('3*4')
@@ -279,4 +259,33 @@ class SPQRTransfromTest < ActiveSupport::TestCase
output1 = SPQRTransform.new.apply(a)
assert_equal expected, output1
end
+
+ test "apostrophe" do
+ parser = SPQRParser.new
+ a = parser.parse("bb'")
+ expected = "bb'"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
+
+ test "one_quote" do
+ parser = SPQRParser.new
+ a = parser.parse('bb"')
+ expected = "bb""
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
+
+ test "link" do
+ parser = SPQRParser.new
+ a = parser.parse('')
+ expected1 = "[LINK TO: myblog.com/photos] "
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected1, output1
+ b = parser.parse('eachset of pictures')
+ p b
+ expected2 = "each[LINK TO: myblog.com/photos] set of pictures"
+ output2 = SPQRTransform.new.apply(b)
+ assert_equal expected2, output2
+ end
end
From 3c61d4a45b1223c3f30381b734867709d2df03e9 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Tue, 26 Jun 2012 20:32:05 -0400
Subject: [PATCH 45/60] Got the whole test file to be imported correctly.
---
lib/quadbase_markup.rb | 4 +-
lib/spqr_parser.rb | 89 +++++++++++++++------------
test/fixtures/files/spqr_original.xml | 44 ++++++-------
test/unit/spqr_transform_test.rb | 36 ++++++++++-
4 files changed, 107 insertions(+), 66 deletions(-)
diff --git a/lib/quadbase_markup.rb b/lib/quadbase_markup.rb
index 66df51d..861eb34 100644
--- a/lib/quadbase_markup.rb
+++ b/lib/quadbase_markup.rb
@@ -40,10 +40,10 @@ def parse(str)
).repeat(1).as(:text) }
rule(:bold_tag) { str("!!") }
- rule(:bold) { bold_tag >> content.as(:bold) >> bold_tag }
+ rule(:bold) { bold_tag >> ( ( content | eol ).repeat(1) ).as(:bold) >> bold_tag }
rule(:italic_tag) { str("''") }
- rule(:italic) { italic_tag >> content.as(:italic) >> italic_tag }
+ rule(:italic) { italic_tag >> ( ( content | eol ).repeat(1) ).as(:italic) >> italic_tag }
rule(:bullet_tag) { str("*") }
rule(:bullet) { bullet_tag >> spaces >> content.as(:bullet) }
diff --git a/lib/spqr_parser.rb b/lib/spqr_parser.rb
index d44f753..628f3a2 100644
--- a/lib/spqr_parser.rb
+++ b/lib/spqr_parser.rb
@@ -35,6 +35,10 @@ def parse(str)
rule(:tt_tag) { (str("") | str("") | str("") | str("")).as(:ttype)}
rule(:new_p) { (str("") | str("
") | str("") | str("
")).as(:para)}
rule(:center) { (str("") | str("") | str("") | str("")).as(:center)}
+ rule(:code) { (str("") | str("") | str("") | str("")).as(:code)}
+
+ #Two exclamation points in a row signifiy a bold tag, so those should be changed to avoid confusion.
+ rule(:exclamation) { str("!!").repeat(1).as(:exclamation) }
#Things to be changed to HTML entities
rule(:asterisk) { str("*").as(:asterisk)}
@@ -42,7 +46,9 @@ def parse(str)
rule(:gthan) { str(">").as(:gthan) }
rule(:apos) { str("'").as(:apos) }
rule(:quote1) { str('"').as(:quote1)}
- rule(:entities) { asterisk | lthan | gthan | apos | quote1 }
+ rule(:dollar) { str("$").as(:dollar) }
+ rule(:pound) { str("\#").as(:pound) }
+ rule(:entities) { asterisk | apos | quote1 | dollar | pound }
#Check for any font changes
rule(:font1) { str("> space? }
rule(:tab) { match("\t") >> space? }
rule(:eol) { (crlf | lf | tab).as(:eol) }
- rule(:fnof) { str("ƒ").as(:fnof) }
#Grammar parts
rule(:punc) { match(/[^<]/) }
rule(:tags) { font | pre | span | div | image | link_full }
- rule(:format) { italic_tag | bold_tag | line_break | tt_tag | fnof | sub | sup | center | asterisk | apos | quote1 }
- rule(:text) { ( tags | format | letters | eol | new_p | greek | entities | (any.as(:any)) ).repeat(1) }
+ rule(:format) { italic_tag | bold_tag | line_break | tt_tag | sub | sup | center | entities | exclamation | code }
+ rule(:text) { ( tags | format | letters | eol | new_p | greek | entities | lthan | gthan | (any.as(:any)) ).repeat(1) }
rule(:ques) { text.repeat.as(:text) }
rule(:expression) { ques }
@@ -117,40 +122,44 @@ def parse(str)
#class UnavailableImage < StandardError; end
class SPQRTransform < Parslet::Transform
- rule(:quote1 => simple(:quote1)) {'"'}
- rule(:lthan => simple(:lthan)) {'<'}
- rule(:gthan => simple(:gthan)) {'>'}
- rule(:asterisk => simple(:asterisk)) {'×'}
- rule(:apos => simple(:apos)) {'''}
- rule(:center => simple(:center)) {}
- rule(:italic => simple(:italic)) {"'"}
- rule(:bold => simple(:bold)) {"!!"}
- rule(:line_break => simple(:break)) {"\n"}
- rule(:ttype => simple(:ttype)) {"$"}
- rule(:para => simple(:para)) {"\n\n"}
- rule(:eol => simple(:eol)) {}
- rule(:content_f => sequence(:content_f)) {"'" + content_f.join + "'"}
- rule(:font => simple(:font)) { font }
- rule(:content_p => sequence(:content_p)) {"$$" + content_p.join + "$$"}
- rule(:pre => simple(:pre)) { pre }
- rule(:content => sequence(:content)) { content.join}
- rule(:span => simple(:span)) { span }
- rule(:div => simple(:div)) { div }
- rule(:delta => simple(:delta)) {"\\delta"}
- rule(:phi => simple(:phi)) {"\\phi"}
- rule(:pi => simple(:pi)) {"\\pi"}
- rule(:omega => simple(:omega)) {"\\omega"}
- rule(:fnof => simple(:fnof)) {"f"}
- rule(:con => simple(:con)) { con }
- rule(:sub => simple(:sub)) {"_{" + sub + "}"}
- rule(:sup => sequence(:sup)) {"^{" + sup.join + "}"}
- rule(:letters => simple(:letters)) { letters }
- rule(:any => simple(:any)) { any }
- rule(:image => sequence(:image)) { "\[MISSING IMAGE: #{image[0].to_s}\]"}
- rule(:filename => simple(:filename)) { filename.str.gsub(/[\n\t]/, "").strip }
- rule(:address => simple(:address)) { "\[LINK TO: #{address.to_s}\] "}
- rule(:link_name => simple(:link_name)) { link_name }
- rule(:link_info => simple(:link_info)) { link_info }
- rule(:link_info => sequence(:info)) { info.join }
- rule(:text => sequence(:entries)) { entries.join }
+ rule(:code => simple(:code)) {}
+ rule(:exclamation => simple(:exclamation)) {"!"}
+ rule(:pound => simple(:pound)) {'£'}
+ rule(:dollar => simple(:dollar)) {'$'}
+ rule(:quote1 => simple(:quote1)) {'"'}
+ rule(:lthan => simple(:lthan)) {'<'}
+ rule(:gthan => simple(:gthan)) {'>'}
+ rule(:asterisk => simple(:asterisk)) {'×'}
+ rule(:apos => simple(:apos)) {'''}
+ rule(:center => simple(:center)) {}
+ rule(:italic => simple(:italic)) {"''"}
+ rule(:bold => simple(:bold)) {"!!"}
+ rule(:line_break => simple(:break)) {"\n"}
+ rule(:ttype => simple(:ttype)) {"$"}
+ rule(:para => simple(:para)) {"\n\n"}
+ rule(:eol => simple(:eol)) {}
+ rule(:content_f => sequence(:content_f)) {"''" + content_f.join + "''"}
+ rule(:font => simple(:font)) { font }
+ rule(:content_p => sequence(:content_p)) {"$$" + content_p.join + "$$"}
+ rule(:pre => simple(:pre)) { pre }
+ rule(:content => sequence(:content)) { content.join}
+ rule(:span => simple(:span)) { span }
+ rule(:div => simple(:div)) { div }
+ rule(:delta => simple(:delta)) {"\\delta"}
+ rule(:phi => simple(:phi)) {"\\phi"}
+ rule(:pi => simple(:pi)) {"\\pi"}
+ rule(:omega => simple(:omega)) {"\\omega"}
+ rule(:fnof => simple(:fnof)) {"f"}
+ rule(:con => simple(:con)) { con }
+ rule(:sub => simple(:sub)) {"_{" + sub + "}"}
+ rule(:sup => sequence(:sup)) {"^{" + sup.join + "}"}
+ rule(:letters => simple(:letters)) { letters }
+ rule(:any => simple(:any)) { any }
+ rule(:image => sequence(:image)) { "\[MISSING IMAGE: #{image[0].to_s}\]"}
+ rule(:filename => simple(:filename)) { filename.str.gsub(/[\n\t]/, "").strip }
+ rule(:address => simple(:address)) { "\[LINK TO: #{address.to_s}\] "}
+ rule(:link_name => simple(:link_name)) { link_name }
+ rule(:link_info => simple(:link_info)) { link_info }
+ rule(:link_info => sequence(:info)) { info.join }
+ rule(:text => sequence(:entries)) { entries.join }
end
diff --git a/test/fixtures/files/spqr_original.xml b/test/fixtures/files/spqr_original.xml
index 6603651..23f1908 100644
--- a/test/fixtures/files/spqr_original.xml
+++ b/test/fixtures/files/spqr_original.xml
@@ -13138,7 +13138,7 @@ Which one of the following Matlab statements will not work?
tt = (0:8000)/8000;
- xx = cos(2*pi*2000*tt);Which of the following lines will correctly play the sound? ]]>
+ xx = cos(2*pi*2000*tt);Which of the following lines will correctly play the sound? ]]>
@@ -26972,7 +26972,7 @@ Note: this operation is called "CONCATENATION."
sig = [xx, zeros(1, 2*11025), yy];
+sig = [xx, zeros(1, 2*11025), yy];
]]>
@@ -26980,28 +26980,28 @@ Note: this operation is called "CONCATENATION."
silence = 0*[0:1/11025:2];
-
sig = [xx, zeros(1, silence), yy];
+
sig = [xx, zeros(1, silence), yy];
]]>
sig = [xx, zeros(1, 2), yy];
+sig = [xx, zeros(1, 2), yy];
]]>
sig = [xx, zeros(1, round(2/11025)), yy];
+sig = [xx, zeros(1, round(2/11025)), yy];
]]>
sig = [xx, zeros(1, round(11025/2)), yy];
+sig = [xx, zeros(1, round(11025/2)), yy];
]]>
@@ -27608,7 +27608,7 @@ Given the parameters fc = 900 Hz and delf = 20 Hz, the beatcon
-
-fs = 11025;
nn = (0:round(0.25*fs));Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 1? ]]>
+fs = 11025;
nn = (0:round(0.25*fs));Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 1? ]]>
@@ -28324,7 +28324,7 @@ Place a zero at radius = 1.0 with an angle of 0 degrees.
fs = 11025;
-tt = (0:round(0.25*fs))/fs;
+tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 0?
]]>
@@ -29917,7 +29917,7 @@ Which MATLAB code would you use to generate the appropriate DTMF signal to repre
fs = 11025;
-tt = (0:round(0.25*fs))/fs;
+tt = (0:round(0.25*fs))/fs;
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number A?
]]>
@@ -30374,7 +30374,7 @@ Which MATLAB code would you use to generate the appropriate DTMF signal to repre
fs = 11025;
-nn = (0:round(0.25*fs));
+nn = (0:round(0.25*fs));
Which MATLAB code would you use to generate the appropriate DTMF signal to represent telephone key number 7?
]]>
@@ -37331,18 +37331,18 @@ Suppose that a complex vector zz has be
zz .* conj(zz)
-]]>
+]]>
real(zz).^2 + imag(zz).^2
-]]>
+]]>
- zz .* zz ]]>
+ zz .* zz ]]>
@@ -41814,12 +41814,12 @@ It is the result of the concatenation of two sinusoids, but I cannot tell
-H(z) = 0.9 (2 + 2z-1 + z-2)]]>
+H(z) = 0.9 (2 + 2z-1 + z-2)]]>
-H(z) = 0.2 (1 + 2z-1 + 2z-2 + z-3)]]>
+H(z) = 0.2 (1 + 2z-1 + 2z-2 + z-3)]]>
@@ -46508,13 +46508,13 @@ with α = 0.4
x[n] = 2 for n = 1, 2
x[n] = 4 for n = 3
x[n] = 0 otherwise
-
What is the z-transform of this sequence?
]]>
+What is the z-transform of this sequence?
]]>
-X(z) = 2z-1 + 2z-2 + 4z-3]]>
+X(z) = 2z-1 + 2z-2 + 4z-3]]>
@@ -50015,7 +50015,7 @@ What is the impulse response of this system?]]>
-
-i(1-i)? ]]>
+i(1-i)? ]]>
@@ -50204,22 +50204,22 @@ What is the impulse response of this system?]]>
-
+
-
+
-
+
-
+
diff --git a/test/unit/spqr_transform_test.rb b/test/unit/spqr_transform_test.rb
index 3eb786f..5add91f 100644
--- a/test/unit/spqr_transform_test.rb
+++ b/test/unit/spqr_transform_test.rb
@@ -46,7 +46,7 @@ class SPQRTransfromTest < ActiveSupport::TestCase
test "italics" do
parser = SPQRParser.new
a = parser.parse('aThis is italics.')
- expected = "a'This is italics.'"
+ expected = "a''This is italics.''"
output1 = SPQRTransform.new.apply(a)
assert_equal expected, output1
b = parser.parse('aThis is italics.')
@@ -116,7 +116,7 @@ class SPQRTransfromTest < ActiveSupport::TestCase
parser = SPQRParser.new
a = parser.parse(samples[1])
output1 = SPQRTransform.new.apply(a)
- expected = "Determine the smallest 'integer' value of the sampling rate"
+ expected = "Determine the smallest ''integer'' value of the sampling rate"
assert_equal expected, output1
end
@@ -288,4 +288,36 @@ class SPQRTransfromTest < ActiveSupport::TestCase
output2 = SPQRTransform.new.apply(b)
assert_equal expected2, output2
end
+
+ test "dollar" do
+ parser = SPQRParser.new
+ a = parser.parse('$3')
+ expected = "$3"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
+
+ test "pound" do
+ parser = SPQRParser.new
+ a = parser.parse('#1')
+ expected = "£1"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
+
+ test "exclamation" do
+ parser = SPQRParser.new
+ a = parser.parse('!!')
+ expected1 = "!"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected1, output1
+ end
+
+ test "code" do
+ parser = SPQRParser.new
+ a = parser.parse('
something')
+ expected = "something"
+ output1 = SPQRTransform.new.apply(a)
+ assert_equal expected, output1
+ end
end
From 5b2012709c5d94772315a9ed4c229c04a6bf94ec Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Tue, 26 Jun 2012 22:29:19 -0400
Subject: [PATCH 46/60] Added functionality to handle any problems with import.
Also added a link to import page on the write new questions view
---
app/controllers/qt_import_controller.rb | 27 ++++++++---------
app/views/qt_import/_form.html.erb | 2 +-
app/views/qt_import/error.html.erb | 3 ++
app/views/questions/new.html.erb | 7 +++++
lib/qti_import.rb | 32 +++-----------------
test/functional/qt_import_controller_test.rb | 11 +++++--
6 files changed, 38 insertions(+), 44 deletions(-)
create mode 100644 app/views/qt_import/error.html.erb
diff --git a/app/controllers/qt_import_controller.rb b/app/controllers/qt_import_controller.rb
index 658432e..1a6836a 100644
--- a/app/controllers/qt_import_controller.rb
+++ b/app/controllers/qt_import_controller.rb
@@ -9,19 +9,18 @@ def new
end
def create
- f = params[:file]
- document = QTImport.openfile(f.path)
- project = QTImport.createproject(current_user)
- parser, transformer = QTImport.choose_import(params[:content_type])
- content = QTImport.iterate_items(document)
- # debugger
- QTImport.get_questions(project,content,parser,transformer,current_user)
- # project = QTImport.createproject(current_user)
- # QTImport.add_questions(project,questions)
-
- # rescue
- # render :text => "Sorry, there was a problem with importing your questions."
- # redirect_to :new
- # end
+ begin
+ f = params[:file]
+ document = QTImport.openfile(f.path)
+ project = QTImport.createproject(current_user)
+ parser, transformer = QTImport.choose_import(params[:content_type])
+ content = QTImport.iterate_items(document)
+ QTImport.get_questions(project,content,parser,transformer,current_user)
+
+ rescue
+ flash[:alert] = 'Unfortunately we could not import all of your questions. This may be due to formatting errors in your questions, such as HTML.
+However, we were most likely able to import some of your questions. They are listed under a new project called Import, and are now unpublished questions.'
+ redirect_to :action => :new
+ end
end
end
diff --git a/app/views/qt_import/_form.html.erb b/app/views/qt_import/_form.html.erb
index c2429be..0aff98e 100644
--- a/app/views/qt_import/_form.html.erb
+++ b/app/views/qt_import/_form.html.erb
@@ -6,7 +6,7 @@
<%= label_tag("Content Type") %>
- <%= select_tag(:content_type, options_for_select(@content_types).html_safe, :include_blank => true) %>
+ <%= select_tag(:content_type, options_for_select(@content_types).html_safe ) %>
<%= submit_tag("Import") %>
diff --git a/app/views/qt_import/error.html.erb b/app/views/qt_import/error.html.erb
new file mode 100644
index 0000000..24d50f3
--- /dev/null
+++ b/app/views/qt_import/error.html.erb
@@ -0,0 +1,3 @@
+Unfortunately we could not import all of your questions. This may be due to formatting errors in your questions, such as HTML.
+However, we were most likely able to import some of your questions. They are listed under a new project called Import, and
+are now unpublished questions.
\ No newline at end of file
diff --git a/app/views/questions/new.html.erb b/app/views/questions/new.html.erb
index 24d4906..bc9f052 100644
--- a/app/views/questions/new.html.erb
+++ b/app/views/questions/new.html.erb
@@ -73,3 +73,10 @@ Use this type for simple free-form questions that may or may not have a multiple
+
+
+
+
+<%= link_to "Or click this link to import a file of questions.", import_qti_new_path %>
+
+
diff --git a/lib/qti_import.rb b/lib/qti_import.rb
index fbd22aa..decaf2f 100644
--- a/lib/qti_import.rb
+++ b/lib/qti_import.rb
@@ -9,7 +9,7 @@
class QTImport
- @@content_types = [['SPQR','SPQR']]
+ @@content_types = [['SPQR']]
attr_reader :filename, :content_type, :parser, :transformer
@@ -17,13 +17,6 @@ def self.content_types
@@content_types
end
- # def self.add_questions(project,questions)
- # for a in 0..(questions.length-1)
- # project.add_question!(questions[a])
- # end
- # return project
- # end
-
def self.choose_import(content_type)
if (content_type == 'SPQR')
a = SPQRParser.new
@@ -38,21 +31,6 @@ def self.createproject(current_user)
a
end
- # def self.get_answers(ans_content,credit_content,parser,transformer)
- # answers = Hash.new
- # for z in 0..(ans_content.length-1)
- # label = ans_content[z].attributes["ident"].value
- # credit = self.get_credit(credit_content,label)
- # y = ans_content[z].children.children.children
- # text = y[0].content
- # x = parser.parse(text)
- # ans = transformer.apply(x)
- # choice = [ans,credit]
- # answers[label] = choice
- # end
- # answers
- # end
-
def self.get_credit(content)
credit = Hash.new
for a in 0..(content.length-1)
@@ -71,9 +49,7 @@ def self.get_credit(content)
def self.get_questions(project, content, parser, transformer,current_user)
coder = HTMLEntities.new
ques_nodes = content.xpath('//presentation')
- # ans_nodes = content.xpath('//presentation//response_lid//response_label')
credit_nodes = content.xpath('//resprocessing//respcondition')
- # answers = self.get_answers(ans_nodes,credit_nodes,parser,transformer)
credit = get_credit(credit_nodes)
for a in 0..(content.length-1)
b = content[a]
@@ -91,7 +67,6 @@ def self.get_questions(project, content, parser, transformer,current_user)
e.save!
temp_ans = Array.new
temp_credit = Array.new
- # debugger
f = content[a].xpath('.//response_lid//response_label')
for g in 0..(f.length-1)
label = f[g].attributes["ident"].value
@@ -103,7 +78,6 @@ def self.get_questions(project, content, parser, transformer,current_user)
ans = transformer.apply(i)
temp_ans << ans
end
- # answers.each_key {|j| if j.match(ques_id) then answers.delete(j) end }
if temp_ans.length == 0
temp_ans << 'fake'
temp_credit << 0
@@ -132,6 +106,8 @@ def self.get_questions(project, content, parser, transformer,current_user)
#content within each tag and "discard" the rest.
def self.iterate_items(document)
items = document.xpath('//item')
+ raise StandardError if items.blank?
+ items
end
def self.normalize(array)
@@ -149,5 +125,7 @@ def self.normalize(array)
def self.openfile(filename)
f = File.open(filename)
doc = Nokogiri::XML(f)
+ f.close
+ doc
end
end
diff --git a/test/functional/qt_import_controller_test.rb b/test/functional/qt_import_controller_test.rb
index 11e0323..8f61f1e 100644
--- a/test/functional/qt_import_controller_test.rb
+++ b/test/functional/qt_import_controller_test.rb
@@ -8,8 +8,9 @@
class QtImportControllerTest < ActionController::TestCase
setup do
- @user = Factory.create(:user)
+ @user = FactoryGirl.create(:user)
@file1 = fixture_file_upload("/files/spqr3.xml", 'xml')
+ @file2 = fixture_file_upload("/files/check_icon_v1.png", 'png')
@content = 'SPQR'
end
@@ -26,9 +27,15 @@ class QtImportControllerTest < ActionController::TestCase
test "should import" do
sign_in @user
- post :create, :file => @file1, :content_types => @content
+ post :create, :file => @file1, :content_type => @content
@project = Project.find_by_name("Import")
assert(@project.is_member?(@user), "user is member of project")
assert_response :success
end
+
+ test "should fail" do
+ sign_in @user
+ post :create, :file => @file2, :content_type => @content
+ assert_redirected_to import_qti_new_path
+ end
end
From 8ecb0fb8cc6022e4d12681b02fcaea1fc2973c86 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Tue, 26 Jun 2012 22:36:54 -0400
Subject: [PATCH 47/60] cleaning up code
---
app/helpers/qt_import_helper.rb | 3 +++
app/views/qt_import/_form.html.erb | 3 +++
app/views/qt_import/create.html.erb | 3 +++
app/views/qt_import/new.html.erb | 3 +++
4 files changed, 12 insertions(+)
diff --git a/app/helpers/qt_import_helper.rb b/app/helpers/qt_import_helper.rb
index 4a5d380..718e4fd 100644
--- a/app/helpers/qt_import_helper.rb
+++ b/app/helpers/qt_import_helper.rb
@@ -1,2 +1,5 @@
+# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
+# License version 3 or later. See the COPYRIGHT file for details.
+
module QtImportHelper
end
diff --git a/app/views/qt_import/_form.html.erb b/app/views/qt_import/_form.html.erb
index 0aff98e..b181f36 100644
--- a/app/views/qt_import/_form.html.erb
+++ b/app/views/qt_import/_form.html.erb
@@ -1,3 +1,6 @@
+
+
<%= form_tag("/import/qti", :multipart => true) do %>
<%= label_tag("File") %>
diff --git a/app/views/qt_import/create.html.erb b/app/views/qt_import/create.html.erb
index 3e48caa..6f0377d 100644
--- a/app/views/qt_import/create.html.erb
+++ b/app/views/qt_import/create.html.erb
@@ -1,3 +1,6 @@
+
+
Your questions were successfully imported!
They have been added to a new project named "Import", and are now unpublished questions.
\ No newline at end of file
diff --git a/app/views/qt_import/new.html.erb b/app/views/qt_import/new.html.erb
index 7ef2a53..53152f5 100644
--- a/app/views/qt_import/new.html.erb
+++ b/app/views/qt_import/new.html.erb
@@ -1,3 +1,6 @@
+
+
Import Questions
Note: All files uploaded MUST be XML files.
From 40f57f9ec9639713e3f1d077ae1f6fdeb61d79fc Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Tue, 26 Jun 2012 22:47:09 -0400
Subject: [PATCH 48/60] cleaning up code
---
lib/spqr_parser.rb | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/lib/spqr_parser.rb b/lib/spqr_parser.rb
index 628f3a2..5f4035b 100644
--- a/lib/spqr_parser.rb
+++ b/lib/spqr_parser.rb
@@ -122,22 +122,27 @@ def parse(str)
#class UnavailableImage < StandardError; end
class SPQRTransform < Parslet::Transform
- rule(:code => simple(:code)) {}
- rule(:exclamation => simple(:exclamation)) {"!"}
- rule(:pound => simple(:pound)) {'£'}
- rule(:dollar => simple(:dollar)) {'$'}
- rule(:quote1 => simple(:quote1)) {'"'}
- rule(:lthan => simple(:lthan)) {'<'}
- rule(:gthan => simple(:gthan)) {'>'}
- rule(:asterisk => simple(:asterisk)) {'×'}
- rule(:apos => simple(:apos)) {'''}
- rule(:center => simple(:center)) {}
+ rule(:image => sequence(:image)) { "\[MISSING IMAGE: #{image[0].to_s}\]"}
+ rule(:filename => simple(:filename)) { filename.str.gsub(/[\n\t]/, "").strip }
+ rule(:address => simple(:address)) { "\[LINK TO: #{address.to_s}\] "}
+ rule(:link_name => simple(:link_name)) { link_name }
+ rule(:link_info => simple(:link_info)) { link_info }
+ rule(:link_info => sequence(:info)) { info.join }
rule(:italic => simple(:italic)) {"''"}
rule(:bold => simple(:bold)) {"!!"}
rule(:line_break => simple(:break)) {"\n"}
rule(:ttype => simple(:ttype)) {"$"}
rule(:para => simple(:para)) {"\n\n"}
- rule(:eol => simple(:eol)) {}
+ rule(:center => simple(:center)) {}
+ rule(:code => simple(:code)) {}
+ rule(:exclamation => simple(:exclamation)) {"!"}
+ rule(:asterisk => simple(:asterisk)) {'×'}
+ rule(:lthan => simple(:lthan)) {'<'}
+ rule(:gthan => simple(:gthan)) {'>'}
+ rule(:apos => simple(:apos)) {'''}
+ rule(:quote1 => simple(:quote1)) {'"'}
+ rule(:dollar => simple(:dollar)) {'$'}
+ rule(:pound => simple(:pound)) {'£'}
rule(:content_f => sequence(:content_f)) {"''" + content_f.join + "''"}
rule(:font => simple(:font)) { font }
rule(:content_p => sequence(:content_p)) {"$$" + content_p.join + "$$"}
@@ -149,17 +154,11 @@ class SPQRTransform < Parslet::Transform
rule(:phi => simple(:phi)) {"\\phi"}
rule(:pi => simple(:pi)) {"\\pi"}
rule(:omega => simple(:omega)) {"\\omega"}
- rule(:fnof => simple(:fnof)) {"f"}
rule(:con => simple(:con)) { con }
rule(:sub => simple(:sub)) {"_{" + sub + "}"}
rule(:sup => sequence(:sup)) {"^{" + sup.join + "}"}
rule(:letters => simple(:letters)) { letters }
+ rule(:eol => simple(:eol)) {}
rule(:any => simple(:any)) { any }
- rule(:image => sequence(:image)) { "\[MISSING IMAGE: #{image[0].to_s}\]"}
- rule(:filename => simple(:filename)) { filename.str.gsub(/[\n\t]/, "").strip }
- rule(:address => simple(:address)) { "\[LINK TO: #{address.to_s}\] "}
- rule(:link_name => simple(:link_name)) { link_name }
- rule(:link_info => simple(:link_info)) { link_info }
- rule(:link_info => sequence(:info)) { info.join }
rule(:text => sequence(:entries)) { entries.join }
end
From 6bf734eb8e7dcdcb784703c8731a37a099560090 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Tue, 26 Jun 2012 23:07:36 -0400
Subject: [PATCH 49/60] uninstalled gems
---
Gemfile | 4 ----
1 file changed, 4 deletions(-)
diff --git a/Gemfile b/Gemfile
index b139c3b..42cf62e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -14,10 +14,6 @@ gem 'jquery-rails', '~> 2.0.2'
gem 'nokogiri'
-gem 'carrierwave'
-
-gem 'upmark'
-
gem 'htmlentities'
# Deploy with Capistrano
From ea7e0a46d8074b31935ba940b3ff1a16e0fdb8b1 Mon Sep 17 00:00:00 2001
From: Daniel Reiter
Date: Mon, 9 Jul 2012 10:12:42 -0500
Subject: [PATCH 50/60] fixed some code indentation
---
app/views/questions/show.html.erb | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb
index 9a8f790..4a6bdfa 100644
--- a/app/views/questions/show.html.erb
+++ b/app/views/questions/show.html.erb
@@ -18,11 +18,11 @@
<% if @question.errors.none? %>
<% @question.solutions.each do |solution| %>
- <% if solution.is_visible == false && present_user == solution.creator %>
- This question has unfinished solutions
- <% break %>
+ <% if solution.is_visible == false && present_user == solution.creator %>
+ This question has unfinished solutions
+ <% break %>
+ <% end %>
<% end %>
- <% end %>
<%= render :partial => "show",
:locals => {:question => @question} %>
<% else %>
From eb05b02828f8260d4f143f608ae1b47cb237b4c5 Mon Sep 17 00:00:00 2001
From: jrb6
Date: Tue, 10 Jul 2012 15:18:37 -0500
Subject: [PATCH 51/60] converted to one line
---
lib/asset_methods.rb | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/asset_methods.rb b/lib/asset_methods.rb
index 86e0aaa..8dad4bd 100644
--- a/lib/asset_methods.rb
+++ b/lib/asset_methods.rb
@@ -8,8 +8,7 @@ def get_image_tag_maker
end
def get_asset(local_name)
- checknil = attachable_assets.select{|aa| aa.local_name == local_name}.first
- checknil.nil? ? checknil : checknil.asset
+ attachable_assets.select{|aa| aa.local_name == local_name}.first.try(:asset)
end
end
From a883b3d8ce15c402a678017012dd1ea70f4936f5 Mon Sep 17 00:00:00 2001
From: jrb6
Date: Wed, 11 Jul 2012 13:00:31 -0500
Subject: [PATCH 52/60] Added closeOnClickOutside function and appended that to
dialog open statements
---
app/assets/javascripts/jquery_extensions.js | 7 +++++++
app/views/dev/toolbox.js.erb | 5 +----
app/views/help/topic.js.erb | 5 +----
app/views/project_questions/attribution.js.erb | 5 +----
app/views/questions/preview.js.erb | 5 +----
app/views/questions/quickview.js.erb | 5 +----
6 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/app/assets/javascripts/jquery_extensions.js b/app/assets/javascripts/jquery_extensions.js
index b303914..fbfe7eb 100644
--- a/app/assets/javascripts/jquery_extensions.js
+++ b/app/assets/javascripts/jquery_extensions.js
@@ -2,3 +2,10 @@
// License version 3 or later. See the COPYRIGHT file for details.
jQuery.fn.exists = function(){return jQuery(this).length>0;}
+
+jQuery.fn.closeOnClickOutside = function(){
+ var dialogx = this;
+ $('.ui-widget-overlay').live("click",function(){
+ dialogx.dialog("close");
+ });
+}
diff --git a/app/views/dev/toolbox.js.erb b/app/views/dev/toolbox.js.erb
index e12cdd8..3a78a98 100644
--- a/app/views/dev/toolbox.js.erb
+++ b/app/views/dev/toolbox.js.erb
@@ -6,7 +6,4 @@ $("#dev_toolbox_dialog").html("<%= ej(render :partial => 'toolbox' )%>");
refresh_buttons();
refresh_datetime_pickers();
-$("#dev_toolbox_dialog").dialog('open');
-$('.ui-widget-overlay').live("click",function(){
- $("#dev_toolbox_dialog").dialog("close");
- });
+$("#dev_toolbox_dialog").dialog('open').closeOnClickOutside();
diff --git a/app/views/help/topic.js.erb b/app/views/help/topic.js.erb
index 4ecbbd6..89bdef1 100644
--- a/app/views/help/topic.js.erb
+++ b/app/views/help/topic.js.erb
@@ -17,8 +17,5 @@ $("#help_dialog").dialog({
<%= reload_mathjax("help_dialog") if @options[:include_mathjax] %>
-$("#help_dialog").dialog('open');
-$('.ui-widget-overlay').live("click",function(){
- $("#help_dialog").dialog("close");
- });
+$("#help_dialog").dialog('open').closeOnClickOutside();
$("#help_dialog").scrollTop(0);
diff --git a/app/views/project_questions/attribution.js.erb b/app/views/project_questions/attribution.js.erb
index ebf8633..294aed6 100644
--- a/app/views/project_questions/attribution.js.erb
+++ b/app/views/project_questions/attribution.js.erb
@@ -5,7 +5,4 @@ $("#attribution_dialog").html("<%= escape_javascript(
render :partial => 'project_questions/attribution',
:locals => {:question_ids => @question_ids}) %>");
-$("#attribution_dialog").dialog('open');
-$('.ui-widget-overlay').live("click",function(){
- $("#attribution_dialog").dialog("close");
- });
+$("#attribution_dialog").dialog('open').closeOnClickOutside();
diff --git a/app/views/questions/preview.js.erb b/app/views/questions/preview.js.erb
index 4b6dbc9..b6c7fe1 100644
--- a/app/views/questions/preview.js.erb
+++ b/app/views/questions/preview.js.erb
@@ -6,10 +6,7 @@
:locals => {:question => @question}) %>");
<%= reload_mathjax("preview_dialog") %>
- $("#preview_dialog").dialog('open');
- $('.ui-widget-overlay').live("click",function(){
- $("#preview_dialog").dialog("close");
- });
+ $("#preview_dialog").dialog('open').closeOnClickOutside();
<% else %>
// Submit the form so that the error messages display nicely with formatting
// around the offending entries (use the trigger approach so we don't get
diff --git a/app/views/questions/quickview.js.erb b/app/views/questions/quickview.js.erb
index fe284db..4694206 100644
--- a/app/views/questions/quickview.js.erb
+++ b/app/views/questions/quickview.js.erb
@@ -5,7 +5,4 @@ $("#quickview_dialog").html("<%= escape_javascript(render :partial => 'show',
:locals => {:question => @question}) %>");
<%= reload_mathjax("quickview_dialog") %>
-$("#quickview_dialog").dialog('open');
-$('.ui-widget-overlay').live("click",function(){
- $("#quickview_dialog").dialog("close");
- });
+$("#quickview_dialog").dialog('open').closeOnClickOutside();
From 23778de7404d8901e8718d5a972e9cdc8e73671b Mon Sep 17 00:00:00 2001
From: jrb6
Date: Wed, 11 Jul 2012 13:02:18 -0500
Subject: [PATCH 53/60] and finished, missed action_new
---
app/views/users/action_new.js.erb | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/app/views/users/action_new.js.erb b/app/views/users/action_new.js.erb
index 55a4ba2..8ab4106 100644
--- a/app/views/users/action_new.js.erb
+++ b/app/views/users/action_new.js.erb
@@ -11,7 +11,4 @@ $("#user_action_dialog").dialog({
width:600,
buttons: { "Close": function() { $(this).dialog("close"); }},
open: function(event, ui) { $("#text_query").val(''); $("#selected_type").val(''); }
-});
-$('.ui-widget-overlay').live("click",function(){
- $("#user_action_dialog").dialog('close');
- });
+}).closeOnClickOutside();
From 8afd09a56dd3768691b140a47755ab4d1abb2c0e Mon Sep 17 00:00:00 2001
From: Daniel Reiter
Date: Tue, 17 Jul 2012 14:22:27 -0500
Subject: [PATCH 54/60] removed loop
---
app/controllers/questions_controller.rb | 1 +
app/views/questions/show.html.erb | 7 ++-----
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb
index 4cea99d..a8b2215 100644
--- a/app/controllers/questions_controller.rb
+++ b/app/controllers/questions_controller.rb
@@ -22,6 +22,7 @@ def index
def show
@question = Question.from_param(params[:id])
+ @unfinished_solutions = !@question.solutions.where{(is_visible == false) & (creator_id == my{present_user})}.first.nil?
raise SecurityTransgression unless present_user.can_read?(@question)
start_time = Time.now if logger.info?
diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb
index 4a6bdfa..d68e385 100644
--- a/app/views/questions/show.html.erb
+++ b/app/views/questions/show.html.erb
@@ -17,11 +17,8 @@
<% if @question.errors.none? %>
- <% @question.solutions.each do |solution| %>
- <% if solution.is_visible == false && present_user == solution.creator %>
-
This question has unfinished solutions
- <% break %>
- <% end %>
+ <% if @unfinished_solutions %>
+
This question has unfinished solutions
<% end %>
<%= render :partial => "show",
:locals => {:question => @question} %>
From 169a8276e7cf967cf734a76bf2d2e61613c287cd Mon Sep 17 00:00:00 2001
From: Daniel Reiter
Date: Tue, 17 Jul 2012 15:27:39 -0500
Subject: [PATCH 55/60] fixed user not logged in id problem
---
app/controllers/questions_controller.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb
index a8b2215..8695101 100644
--- a/app/controllers/questions_controller.rb
+++ b/app/controllers/questions_controller.rb
@@ -22,7 +22,8 @@ def index
def show
@question = Question.from_param(params[:id])
- @unfinished_solutions = !@question.solutions.where{(is_visible == false) & (creator_id == my{present_user})}.first.nil?
+ #debugger
+ @unfinished_solutions = !@question.solutions.where{(is_visible == false) & (creator_id == my{present_user.id})}.first.nil?
raise SecurityTransgression unless present_user.can_read?(@question)
start_time = Time.now if logger.info?
From 3edd5b536ee191c29110b3c9f31401018fffa274 Mon Sep 17 00:00:00 2001
From: Daniel Reiter
Date: Tue, 17 Jul 2012 15:46:00 -0500
Subject: [PATCH 56/60] removed debugger line
---
app/controllers/questions_controller.rb | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb
index 8695101..1d10e20 100644
--- a/app/controllers/questions_controller.rb
+++ b/app/controllers/questions_controller.rb
@@ -22,7 +22,6 @@ def index
def show
@question = Question.from_param(params[:id])
- #debugger
@unfinished_solutions = !@question.solutions.where{(is_visible == false) & (creator_id == my{present_user.id})}.first.nil?
raise SecurityTransgression unless present_user.can_read?(@question)
From b39888f60337ad4fbf1ced95780d1ebb1596cfd4 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Tue, 17 Jul 2012 17:45:04 -0500
Subject: [PATCH 57/60] Trying to run tests
---
Gemfile.lock | 17 -----------------
app/models/question.rb | 6 +++++-
.../_content_and_answers.html.erb | 4 ++++
app/views/simple_questions/_form.html.erb | 3 +++
...7032712_remove_image_answer_from_question.rb | 9 +++++++++
...20717033002_add_image_answer_to_questions.rb | 5 +++++
db/schema.rb | 7 ++++---
test.db.dump | 0
8 files changed, 30 insertions(+), 21 deletions(-)
create mode 100644 db/migrate/20120717032712_remove_image_answer_from_question.rb
create mode 100644 db/migrate/20120717033002_add_image_answer_to_questions.rb
create mode 100644 test.db.dump
diff --git a/Gemfile.lock b/Gemfile.lock
index 6d55376..c8b4c35 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -45,9 +45,6 @@ GEM
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
- carrierwave (0.6.2)
- activemodel (>= 3.2.0)
- activesupport (>= 3.2.0)
cocaine (0.2.1)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
@@ -166,10 +163,6 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
-<<<<<<< HEAD
- sqlite3 (1.3.6-x86-mingw32)
-=======
->>>>>>> HTML_import
squeel (1.0.6)
activerecord (~> 3.0)
activesupport (~> 3.0)
@@ -188,17 +181,9 @@ GEM
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
-<<<<<<< HEAD
- uglifier (1.2.6)
- execjs (>= 0.3.0)
- multi_json (~> 1.3)
-=======
uglifier (1.2.5)
execjs (>= 0.3.0)
multi_json (~> 1.3)
- upmark (0.1.3)
- parslet
->>>>>>> HTML_import
warden (1.2.1)
rack (>= 1.0)
will_paginate (3.0.3)
@@ -211,7 +196,6 @@ DEPENDENCIES
acts-as-taggable-on (~> 2.3.1)
bullring (~> 0.8.2)
capistrano (~> 2.12.0)
- carrierwave
coffee-rails (~> 3.2.2)
debugger (~> 1.1.4)
devise (~> 2.1.0)
@@ -240,6 +224,5 @@ DEPENDENCIES
thin (~> 1.3.1)
timecop (~> 0.3.5)
uglifier (~> 1.2.4)
- upmark
will_paginate (~> 3.0.3)
yajl-ruby (~> 1.1.0)
diff --git a/app/models/question.rb b/app/models/question.rb
index a2f24ec..fb19dd6 100644
--- a/app/models/question.rb
+++ b/app/models/question.rb
@@ -156,7 +156,7 @@ class Question < ActiveRecord::Base
# but we don't want them deciding which questions share setups, etc)
# Using whitelisting instead of blacklisting here.
attr_accessible :content, :changes_solution, :question_setup_attributes,
- :logic_attributes
+ :logic_attributes, :image_answer
def to_param
if is_published?
@@ -378,6 +378,10 @@ def has_role_permission?(user, role)
def question_role_requests
QuestionRoleRequest.for_question(self)
end
+
+ def answer_is_image?
+ self.image_answer
+ end
# Saves the question (for the first time), assigns roles to the given user,
# and puts the question in the user's default project. Throws exceptions
diff --git a/app/views/simple_questions/_content_and_answers.html.erb b/app/views/simple_questions/_content_and_answers.html.erb
index c18f120..3e2564f 100644
--- a/app/views/simple_questions/_content_and_answers.html.erb
+++ b/app/views/simple_questions/_content_and_answers.html.erb
@@ -29,3 +29,7 @@
<% end %>
+
+<% if question.answer_is_image? && !question.is_published? %>
+The answer to this question is a drawing.
+<% end %>
\ No newline at end of file
diff --git a/app/views/simple_questions/_form.html.erb b/app/views/simple_questions/_form.html.erb
index 8bc466c..2aa14ce 100644
--- a/app/views/simple_questions/_form.html.erb
+++ b/app/views/simple_questions/_form.html.erb
@@ -107,6 +107,9 @@
<% end %>
+ <%= f.check_box(:image_answer, :value => true) %>
+ <%= f.label :answer_is_image, "The answer to this question is a drawing." %>
+
<%= f.fields_for :answer_choices do |ac_form| %>
<%= render 'simple_questions/answer_choice_fields', :f => ac_form %>
diff --git a/db/migrate/20120717032712_remove_image_answer_from_question.rb b/db/migrate/20120717032712_remove_image_answer_from_question.rb
new file mode 100644
index 0000000..825fc7b
--- /dev/null
+++ b/db/migrate/20120717032712_remove_image_answer_from_question.rb
@@ -0,0 +1,9 @@
+class RemoveImageAnswerFromQuestion < ActiveRecord::Migration
+ def up
+ remove_column :questions, :image_answer
+ end
+
+ def down
+ add_column :questions, :image_answer, :string
+ end
+end
diff --git a/db/migrate/20120717033002_add_image_answer_to_questions.rb b/db/migrate/20120717033002_add_image_answer_to_questions.rb
new file mode 100644
index 0000000..120cc49
--- /dev/null
+++ b/db/migrate/20120717033002_add_image_answer_to_questions.rb
@@ -0,0 +1,5 @@
+class AddImageAnswerToQuestions < ActiveRecord::Migration
+ def change
+ add_column :questions, :image_answer, :boolean
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 879b723..377d002 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120613190208) do
+ActiveRecord::Schema.define(:version => 20120717033002) do
create_table "announcements", :force => true do |t|
t.integer "user_id"
@@ -83,8 +83,8 @@
end
create_table "file_uploads", :force => true do |t|
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
create_table "licenses", :force => true do |t|
@@ -231,6 +231,7 @@
t.boolean "changes_solution", :default => false
t.text "code"
t.string "variables"
+ t.boolean "image_answer"
end
create_table "solutions", :force => true do |t|
diff --git a/test.db.dump b/test.db.dump
new file mode 100644
index 0000000..e69de29
From 1820bbc5a54d96f2114fca68ed42f5981278a1a5 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Tue, 17 Jul 2012 18:44:19 -0500
Subject: [PATCH 58/60] Everything works. Authors can specify if answer is
drawing.
---
test/unit/qti_import_test.rb | 27 +++++++++------------
test/unit/quadbase_html_transformer_test.rb | 2 +-
test/unit/simple_question_test.rb | 9 +++++++
test/unit/spqr_transform_test.rb | 13 ++--------
4 files changed, 24 insertions(+), 27 deletions(-)
diff --git a/test/unit/qti_import_test.rb b/test/unit/qti_import_test.rb
index f6c02f0..6aa402b 100644
--- a/test/unit/qti_import_test.rb
+++ b/test/unit/qti_import_test.rb
@@ -4,58 +4,55 @@
require 'test_helper'
class QTImportTest < ActiveSupport::TestCase
+ user = FactoryGirl.create(:user)
+
test "1_question" do
assert_nothing_raised do
document = QTImport.openfile("#{::Rails.root}/test/fixtures/files/spqr1.xml")
+ project = QTImport.createproject(user)
parser, transformer = QTImport.choose_import('SPQR')
content = QTImport.iterate_items(document)
- questions = QTImport.get_questions(content,parser,transformer)
- project = QTImport.createproject
- QTImport.add_questions(project,questions)
+ questions = QTImport.get_questions(project,content,parser,transformer,user)
end
end
test "2_question" do
assert_nothing_raised do
document = QTImport.openfile("#{::Rails.root}/test/fixtures/files/spqr2.xml")
+ project = QTImport.createproject(user)
parser, transformer = QTImport.choose_import('SPQR')
content = QTImport.iterate_items(document)
- questions = QTImport.get_questions(content,parser,transformer)
- project = QTImport.createproject
- QTImport.add_questions(project,questions)
+ questions = QTImport.get_questions(project,content,parser,transformer,user)
end
end
test "5_question" do
assert_nothing_raised do
document = QTImport.openfile("#{::Rails.root}/test/fixtures/files/spqr3.xml")
+ project = QTImport.createproject(user)
parser, transformer = QTImport.choose_import('SPQR')
content = QTImport.iterate_items(document)
- questions = QTImport.get_questions(content,parser,transformer)
- project = QTImport.createproject
- QTImport.add_questions(project,questions)
+ questions = QTImport.get_questions(project,content,parser,transformer,user)
end
end
test "25_question" do
assert_nothing_raised do
document = QTImport.openfile("#{::Rails.root}/test/fixtures/files/spqr4.xml")
+ project = QTImport.createproject(user)
parser, transformer = QTImport.choose_import('SPQR')
content = QTImport.iterate_items(document)
- questions = QTImport.get_questions(content,parser,transformer)
- project = QTImport.createproject
- QTImport.add_questions(project,questions)
+ questions = QTImport.get_questions(project,content,parser,transformer,user)
end
end
test "all_question" do
assert_nothing_raised do
document = QTImport.openfile("#{::Rails.root}/test/fixtures/files/spqr_original.xml")
+ project = QTImport.createproject(user)
parser, transformer = QTImport.choose_import('SPQR')
content = QTImport.iterate_items(document)
- questions = QTImport.get_questions(content,parser,transformer)
- project = QTImport.createproject
- QTImport.add_questions(project,questions)
+ questions = QTImport.get_questions(project,content,parser,transformer,user)
end
end
end
diff --git a/test/unit/quadbase_html_transformer_test.rb b/test/unit/quadbase_html_transformer_test.rb
index 34b3d10..41aebad 100644
--- a/test/unit/quadbase_html_transformer_test.rb
+++ b/test/unit/quadbase_html_transformer_test.rb
@@ -58,6 +58,6 @@ class QuadbaseHtmlTransformerTest < ActiveSupport::TestCase
"
a = parser.parse(text)
- p transformer.apply(a)
+ output = transformer.apply(a)
end
end
diff --git a/test/unit/simple_question_test.rb b/test/unit/simple_question_test.rb
index f622285..866013e 100644
--- a/test/unit/simple_question_test.rb
+++ b/test/unit/simple_question_test.rb
@@ -96,6 +96,15 @@ class SimpleQuestionTest < ActiveSupport::TestCase
ContentParseAndCache.enable_test_parser = false
end
+ test "image_answer" do
+ simple = FactoryGirl.build(:simple_question, :content => 'hi', :image_answer => true)
+ simple2 = FactoryGirl.build(:simple_question, :content => 'bye')
+ assert_nothing_raised {simple.save!}
+ assert_nothing_raised {simple2.save!}
+ assert_equal true, simple.answer_is_image?
+ assert_equal nil, simple2.answer_is_image?
+ end
+
# TODO implement the following tests
diff --git a/test/unit/spqr_transform_test.rb b/test/unit/spqr_transform_test.rb
index 5add91f..0653bad 100644
--- a/test/unit/spqr_transform_test.rb
+++ b/test/unit/spqr_transform_test.rb
@@ -152,14 +152,6 @@ class SPQRTransfromTest < ActiveSupport::TestCase
assert_equal expected, output1
end
- test "curly_f" do
- parser = SPQRParser.new
- a = parser.parse('ƒs')
- expected = "fs"
- output1 = SPQRTransform.new.apply(a)
- assert_equal expected, output1
- end
-
test "sub" do
parser = SPQRParser.new
a = parser.parse('aφ')
@@ -224,14 +216,14 @@ class SPQRTransfromTest < ActiveSupport::TestCase
parser = SPQRParser.new
a = parser.parse('a')
output1 = SPQRTransform.new.apply(a)
- expected = "aMISSING IMAGE: filename.jpg"
+ expected = "a[MISSING IMAGE: filename.jpg]"
assert_equal expected, output1
end
test "3tags" do
parser = SPQRParser.new
a = parser.parse('a')
- expected = "a$$'\\pi'$$"
+ expected = "a$$''\\pi''$$"
output1 = SPQRTransform.new.apply(a)
assert_equal expected, output1
end
@@ -283,7 +275,6 @@ class SPQRTransfromTest < ActiveSupport::TestCase
output1 = SPQRTransform.new.apply(a)
assert_equal expected1, output1
b = parser.parse('eachset of pictures')
- p b
expected2 = "each[LINK TO: myblog.com/photos] set of pictures"
output2 = SPQRTransform.new.apply(b)
assert_equal expected2, output2
From b1b0331a5032c80f1deaba0e8ef8f8bddb228717 Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sat, 21 Jul 2012 14:59:25 -0500
Subject: [PATCH 59/60] Trying to add skeleton to qti exporter
---
.../simple_questions/show.1p2.qti.builder | 43 ++++++++++++-------
1 file changed, 27 insertions(+), 16 deletions(-)
diff --git a/app/views/simple_questions/show.1p2.qti.builder b/app/views/simple_questions/show.1p2.qti.builder
index 1bc30bc..4194f07 100644
--- a/app/views/simple_questions/show.1p2.qti.builder
+++ b/app/views/simple_questions/show.1p2.qti.builder
@@ -1,20 +1,31 @@
-xml.instruct!
+require 'builder'
+xml = Builder::XmlMarkup.new
-xml.kml(:xmlns => "http://earth.google.com/kml/2.2") {
-xml.Document {
- xml.name("Test")
- xml.open(1)
- xml.visible(1)
- xml.NetworkLink {
- xml.name("My rails app being passed parameters")
- xml.open(1)
- xml.visibility(0)
- xml.Link {
- xml.href("hi")
- xml.viewRefreshMode("onStop")
- xml.viewRefreshTime(0.5)
- xml.viewFormat("BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]&CENTRE=[lookatLon],[lookatLat]")
+xml.instruct!
+xml.Document{
+ xml.item{
+ xml.presentation{
+ xml.material{
+ xml.mattext(
+ @question.content_html,
+ "texttype" => "text/html"
+ )
}
+ xml.response_lid{
+ xml.render_choice{
+ @question.answer_choices.each { |ac|
+ xml.response_label{
+ xml.material{
+ xml.mattext(
+ ac.content_html,
+ "texttype" => "text/html"
+ )
+ }
+ }
+ }
+ }
+ }
}
+ xml.resprocessing{}
}
-}
\ No newline at end of file
+}
From 13b614efb891931dc8e20995bacbdf1f0109c95c Mon Sep 17 00:00:00 2001
From: Rachel Green
Date: Sat, 21 Jul 2012 15:48:44 -0500
Subject: [PATCH 60/60] The export function is completed, filling out the data
in the xml as best as it can.
---
.../simple_questions/show.1p2.qti.builder | 34 ++++++++++++-------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/app/views/simple_questions/show.1p2.qti.builder b/app/views/simple_questions/show.1p2.qti.builder
index 4194f07..ddfdffc 100644
--- a/app/views/simple_questions/show.1p2.qti.builder
+++ b/app/views/simple_questions/show.1p2.qti.builder
@@ -6,26 +6,34 @@ xml.Document{
xml.item{
xml.presentation{
xml.material{
- xml.mattext(
- @question.content_html,
- "texttype" => "text/html"
- )
+ xml.mattext("texttype" => "text/html") {
+ xml.cdata!(@question.content_html.html_safe)
+ }
}
xml.response_lid{
xml.render_choice{
- @question.answer_choices.each { |ac|
- xml.response_label{
+ @question.answer_choices.each_index do |ac|
+ xml.response_label("ident" => "A" + ac.to_s){
xml.material{
- xml.mattext(
- ac.content_html,
- "texttype" => "text/html"
- )
- }
+ xml.mattext("texttype" => "text/html"){
+ xml.cdata!(@question.answer_choices[ac].content_html.html_safe)
+ }
+ }
}
+ end
+ }
+ }
+ }
+ xml.resprocessing{
+ @question.answer_choices.each_index do |ac|
+ xml.respcondition{
+ xml.conditionvar{
+ xml.varequal "A" + ac.to_s
}
+ xml.setvar(@question.answer_choices[ac].credit,"varname" => "que_score", "action" => "Add"
+ )
}
- }
+ end
}
- xml.resprocessing{}
}
}