Q and A

Introduction to Meteor.js Development Coursera Quiz Answers

Table of Contents

  • Week 1: Introduction to Meteor.js Development Coursera Quiz Answers
  • Week 2: Introduction to Meteor.js Development Coursera Quiz Answers
  • Week 3: Introduction to Meteor.js Development Coursera Quiz Answers
  • Week 4: Introduction to Meteor.js Development Coursera Quiz Answers

Week 1: Introduction to Meteor.js Development Coursera Quiz Answers

Quiz 1: Prerequisite quiz

Q1. This course is the third one in our specialisation. We assume you already know some Javascript, HTML and CSS. If you are new to all these languages, we recommend that you go back and check out the previous courses. Otherwise, here are some questions to test your knowledge!

  • Ok got it!

Q2. We just want to let you know that the latest version of meteor creates a slightly different starter app than the version we use in this course. It is more complicated than the one shown in the course. We prefer the simpler starter application for teaching, so we provide you with a stripped down starter app and recommend that you start with that.

  • Ok!

Quiz 2: From one to many users

Q1. Which technology makes it easier to deal with many users?

  • Web servers
  • HTML

Q2. Where does the web browser software run?

  • On the server
  • On the client

Quiz 3: Install Meteor

Q1. What is the command to run a Meteor application called myApplication?

  • meteor add myApplication
  • meteor

Q2. Where does localhost point to on a network?

  • The nearest server outside of your network
  • Your local machine

Quiz 4: Editing a template

Q1. What is spacebars in Meteor?

  • A button you press all the time to make your code lay out as neatly as possible.
  • A templating language

Q2. Which code defines a template called ‘photoDisplay’?

  • {{> photoDisplay}}
  • </template name="photodisplay">

Quiz 5: Sending data to templates with helpers

Q1. What does Meteor.isClient mean?

  • It tests if there is a client connected to the Meteor server
  • It tests if this code is running on the web browser or not

Q2. Which of the following are true? Select all that apply.

  • Template helpers can send data to templates which the template can then display.
  • Template helpers can send functions to templates that the template can call.

Quiz 6: Convert to a Bootstrap grid

Q1. How do you search for packages in Meteor? (select all that are correct)

  • Meteor search
  • On the atmospherejs.com website

Q2. Why did the image gallery in the video pop down to a single column with 3 rows when the browser window was narrow?

  • Because of the col-md-3 class on the div tag
  • Because of the col-xs-12 class on the div tag.

Quiz 7: Responding to user actions

Q1. How do we access the tag that relates to the event in a template event function?

  • By accessing

$(event.target).css

  • By accessing

$(event.target)

Q2. Which looks like the right start for adding event listeners to a template called aTemplate?

  • Template.aTemplate.events
  • Template.aTemplate.onclick

Quiz 8: Introduction to Meteor summary quiz

Q1. Which are web languages? (select all those apply)

  • JavaScript
  • HTML
  • Web servers
  • Web browsers

Q2. Run the following command to create a new meteor application:

1
meteor create myapp
Look in the folder that has been created. Which files or folders can you see?

  • package.json
  • server
  • myapp.js
  • client

Q3. What is the default port for a local Meteor server to run on?

  • localhost
  • 3000
  • 127.0.0.1
  • localport

Q4. Select the correct bit of template code to render a template called ‘myTemplate’

  • {{> myTemplate}}
  • </template name="mytemplate">

  {{myTemplate}} 

  • {{:: myTemplate}}
  • </template name="mytemplate">

  

My template

 

Q5. What is the purpose of the public folder in a web application?

  • To store files that have public domain licences.
  • To store static files that the client needs to see.
  • To store source code files that the client needs to run.
  • To store asset files for the server.

Q6. Run the image_share application supplied with this module. Where does the message ‘where am I running’ get printed out? Select all that apply

  • Nowhere
  • In the browser web page display window
  • In the server console
  • In the web browser console

Q7. Which code defines a template helper function that can pass an array called test into a template called testTemp?

  • Template.testTemp.helpers({

  test:function(){  var test = []; return test; } })

  • </template name="testtemp">

  {{test}} 

  • </template name="testtemp">

  {{#each test}} {{img_name}} {{/each}} 

  • Template.test.helpers({

  test:function(){ 

var testTemp = []; 

return testTemp;   }  })

Q8. What do you need to add to the following code to make it into a responsive grid?

  • An outer div with the class container
  • A div inside the row with the class container
  • A col-xs-something class.
  • Another row to specify what should go in the second row once the screen size is changed

Q9. Why not use onclick attributes to add interactivity in our meteor apps?

  • Onclick does not work in Meteor apps
  • Templates cannot cope with mouse clicks
  • Onclick does not allow us to easily access the event in our application code
  • Onclick is not the right attribute to capture a mouse click

Q10. Which code defines a template event listener for a template named myTemplate that will print ‘hello’ when the user clicks on any button in the template?

  • Template.myTemplate.events({
    ‘click .button’: function () {
    console.log(‘hello’); } });
  • Template.myTemplate.events({
    ‘click button’: function () {
    console.log(‘hello’); } });
  • Template.myTemplate.events({
    ‘click #button’: function () {
    console.log(‘hello’); } });
  • Template.myTemplate.events({
    ‘onclick button’: function () {
    console.log(‘hello’); } });

Week 2: Introduction to Meteor.js Development Coursera Quiz Answers

Quiz 1: Meteor distributed data model

Q1. How many copies of the data can be in a Meteor application at any one time? (assuming all data is visible to all)

  • As many as there are connected clients plus one for the server
  • As many as there are connected clients

Q2. What is Meteor’s default database server called?

  • MySQL
  • Mongo

Quiz 2: Create a collection of images

Q1. How can we create a collection in Meteor’s database?

  • Images = Mongo.createCollection("myCollection");
  • Images = new Mongo.Collection("images");

Q2. What is the purpose of the Meteor.startup function? (select ALL that apply)

  • To run code on the server side when the application starts up.
  • To run code on the client side when the application starts up.

Quiz 3: Better start up script, removing items from a collection

Q1. Which features of this code make it readable? Select all that apply

if (Meteor.isServer) { 

  Meteor.startup() { 

    for (var i = 0; i < 23; i++) { 

    } // end for iterating images 

  } // end meteor.startup 

} // end meteor.iserver

  • Indenting
  • Comments ending the if and for blocks

Q2. What is the command to remove something from a collection?

  • Remove
  • Delete

Quiz 4: Add an image rating function: Updating and sorting

Q1. What was different about how we dealt with event targets in this module, compared with the previous module?

  • We accessed event.currentTarget instead of event.target
  • We used jQuery to access the event target

Q2. How do we access an id on something from a Mongo collection?

  • _id
  • id

Quiz 5: Implement image adding with a Bootstrap Modal

Q1. What kind of event do we listen to on forms?

  • Click
  • Submit

Q2. Why do I prefix some CSS class names with ‘js-‘?

  • To make it clear they are related to the event code, not the actual CSS layout code.
  • Meteor requires that event listener selectors are prefixed with ‘js-‘

Quiz 6: Databases and collections summary quiz

Q1. Why is a Meteor application like a database cluster?

  • Because the database only runs in the client machines
  • Because Meteor applications are very scalable
  • Because the server runs on a Mongo cluster
  • Because each connected client runs a local copy of the database

Q2. Why do we define collections like this:

Images = new Mongo.Collection("images");

instead of:

var Images = new Mongo.Collection("images");

  • Meteor does not use the word var in its javaScript code.
  • If you define a var in a Meteor .js file, it becomes local to that file, and you cannot access it in other .js files in your app. (try it!).
  • Variables with capital letters for their name are automatically global variables.
  • var is not the correct keyword in javaScript to define a variable.

Q3. What does running the command

meteor reset

in a meteor application’s folder do?

  • It runs the Meteor.startup function to insert starter data
  • It starts the app again
  • It creates a new application
  • It deletes all data from the database

Q4. Select the correct way of specifying HTML, CSS and JavaScript comments

// this is an HTML comment 

/* this is a CSS comment */

// this is a Javascript comment 

/* this is an HTML comment */

// this is an Javascript comment 

/* this is a CSS comment */

// this is an Javascript comment 

/* this is an HTML comment */

Q5. Which of the following is the correct way to access a collection in Meteor?

  • Meteor.Images.find({});
  • Mongo.find("images", {})
  • Images.find({})
  • Images.find().count()

Q6. Regarding this function call, which are true?

Images.update({_id:'123'}, {$set:{rating:4}});

  • The rating field will be set to 123
  • {_id:’123′} is a Mongo filter that only allows the update to be applied to images with the _id ‘123’.
  • The $set command is a mongo command that allows a field to be set to a new value.
  • The rating field will be set to 4

Q7. Which of the following statements will retrieve the images with the lowest rated one coming first?

  • Images.find({}).sort({rating:1});
  • Images.find({}, {sort:{rating:1}})
  • Images.find({}, {sort:{rating:-1}})
  • Images.find({_id:'123'}, {sort:{rating:1}})

Q8. What happens if we return false from a template event listener in Meteor?

  • The event is ignored
  • The browser is prevented from carrying out its default action
  • Nothing
  • We ensure that nothing is inserted into the database.

Q9. What is wrong with the following code?

Template.images.events({ 

  "click .js-show-image-form":function(){ }

  "click .js-hide-image-form":function(){ }  });

  • The items in the property set have strings for their names
  • There are no events passed into the event listener functions
  • There are full stops (periods) before the CSS selectors
  • There are no commas between the items in the property set

Q10. Which code shows a Bootstrap modal with an id of ‘myModal’?

  • $('#myModal').modal('show');
  • $('.myModal').modal('hide');
  • $('.myModal').modal('show');
  • $('#myModal').modal('hide');

Week 3: Introduction to Meteor.js Development Coursera Quiz Answers

Quiz 1: User authentication with Meteor.js

Q1. Which packages should you add for basic user authentication in your database and UI? (select all that apply)

  • accounts-ui
  • accounts-password

Q2. When a password reset email is sent from a Meteor server running on your own computer, where is the content of the email printed out?

  • In the console
  • In a special template

Quiz 2: Tidying up the design with a navbar

Q1. What does the max-height CSS property do to images?

  • Stops the image from being heigher than a certain height.
  • Sets the height of an image and prevents it from going higher.

Q2. What is the name of the user login template provided by accounts-ui?

  • loginButtons
  • userLogin

Quiz 3: Accessing user information

Q1. How do we access a logged in user’s email address?

  • Meteor.user().emails[0].address
  • Meteor.user().email_address[0]

Q2. Why do templates that access user data render twice sometimes?

  • There is a bug in the meteor code.
  • Meteor.user changes during the start up of the app in the browser.

Quiz 4: Customising the user registration form

Q1. What is the purpose of the Accounts.ui.config function?

  • It only allows you to change the design of the registration form.
  • It allows you to re-configure the fields in the registration form.

Q2. Bonus information: which is an alternative way to access user information?

  • Meteor.users()
  • Meteor.users.find()

Quiz 5: Attaching users to images

Q1. Which of these look like valid template helpers? (select all that apply)

  • Template.image_list.helpers({ images: [ {img_alt:"my image"}, {img_alt:"my other image"} ] });
  • Template.image_list.helpers({ images: function(){ return Images.find({}); } });

Q2. Which is the correct way to insert an image into a database collection?

  • Images.insert(img_alt, img_src, userId)
  • Images.insert({img_alt: img_alt, img_src: img_src, userId: userId})

Quiz 6: Filtering images by user

Q1. Why do we always need an href attribute on an a tag? Choose the most accurate answer.

  • Without an href, the browser will not apply the expected visual changes when a user moves the mouse over the link.
  • Links always need to go somewhere. The href tells the browser where the link is going.

Q2. How many copies of the Session variable do you think there are in a complete Meteor application?

  • One.
  • One for each connected client.

Quiz 7: Removing the image filter

Q1. You are provided with a helper function as follows:

Template.image_list.helpers({ 

  greaterThan5:function(input){ 

    console.log(input); 

    if (input > 5){ 

      return true; 

    } else { 

      return false; } } });

Which is the correct syntax for an if block in a template that uses this helper?

  • {{#if greaterThan5 10}} 10 is greater than 5 {{/if}}
  • {{#if greaterThan5(10)}} 10 is greater than 5 {{/if}}

Q2. How do you unset a key called ‘myKey’ on a session?

  • Session.set(‘myKey’, undefined)
  • Session.unset(‘myKey’)

Quiz 8: Infinite scroll

Q1. Why should we use an infinite scroll?

  • It is technically impressive.
  • The site will load faster.

Q2. What does limit mean in a database find query?

  • It limits how many connections are made to the database at a time to make the server more efficient.
  • It limits how many items will be returned.

Quiz 9: User authentication summary quiz

Q1. Which of the following types of user accounts are supported by packages in meteor? (clue – run the command

meteor search accounts )

Select all that apply

  • Google
  • Facebook
  • Twitter
  • Github

Q2. What happens to your page content when you set up a fixed position navbar?

  • The top part is hidden behind the navbar.
  • It moves down by the height of the navbar.
  • The page content is always completely hidden.
  • The page can no longer scroll.

Q3. Reactive data sources…

  • Are just another name for database collections
  • Automatically change in response to events triggered by the user
  • Cause templates that rely on that data source to re-render automatically if the data changes
  • Can react to different circumstances that might occur in the app.

Q4. What is the Meteor.user() function for?

  • Accessing the current user.
  • Logging in a user.
  • Creating a new user in the database.
  • Finding out the username that the meteor server is running as.

Q5. Which of the following specifies a template helper function that returns the username if the user is logged in?

  • Template.body.helpers({
    username: function(){
    var user = Meteor.user();
    if (user){
    return user.username; } } });
  • Template.body.helpers({
    username: function(){
    var user = Users.findOne({_id:Meteor.userId()})
    if (user){
    return user.username; } } });
  • Template.body.helpers({
    username: function(){
    var user = user();
    if (user){
    return user.username; } } });
  • Template.body.helpers({
    username: function(){
    var user = Meteor.users.findOne({_id:Meteor.userId()})
    if (user){
    return user.username; } } });

Q6. Select the options where variable a is ‘truthy’

  • var a = -1;
  • var a = 10 == 5;
  • var a = 1;
  • var a = 0;

Q7. Which of the following are reactive data sources?

  • var myModuleValue = 10;
  • The Images collection from this course
  • Session
  • Meteor.user()

Q8. What is wrong with this code?

Template.imageList.helpers({
username: function(){
var user = Meteor.users.findOne({_id:Meteor.userId()})
if (user){
return user.username;
}
}
images: function(){
var filter = {userId:Meteor.userId()};
return Images.find(filter);

  • There is no comma between the properties in the property set
  • You cannot specify filters as variables, so the find function will not work
  • There is no semicolon at the end of the line ‘var user = Meteor.users.findOne({_id:Meteor.userId()}) ‘
  • The username helper does not return anything if there is no user available.

Q9. Which is the correct way to specify a template helper function that returns true if the user is logged in, which can be used in a template if block?

  • Template.body.helpers({
    isLoggedIn:function(){
    if (Meteor.user().username == ‘anonymouse’){
    return false;
    } else {
    return true; } }, })
  • Template.body.helpers({
    isLoggedIn:function(){
    return Meteor.user() }, })
  • Template.body.helpers({
    isLoggedIn:return Meteor.user(), })
  • Template.body.helpers({
    isLoggedIn:function(user){
    return user.isLoggedIn; }, })

Q10. What is wrong with displaying all the images in the database at once in the template? (select all that apply)

  • Templates are limited to 100 iterations of a loop.
  • There will be an unnecessary load placed on the server as it reads the images from disk and sends them out to the client.
  • The Session variable prevents this by default.
  • The site will take a long time to load.

Week 4: Introduction to Meteor.js Development Coursera Quiz Answers

Quiz 1: How to organise your code

Q1. Which files do not go in the public folder?

  • Meteor app javaScript code such as template helper functions
  • Image files

Q2. Why are Meteor.isClient and Meteor.isServer not needed in code in the server and client folders?

  • Code in the client and server folders will only run on the client or the server, respectively. Therefore, we do not need to test where it is running.
  • It is guaranteed that Meteor will run all of the code in these folders on both the client and the server.

Quiz 2: Hack into your site!

Q1. In terms of what you have access to, the browser console environment is equivalent to:

  • The inside of an ‘if(Meteor.isServer)’ block
  • The inside of an ‘if(Meteor.isClient)’ block

Q2. What was the key message in this video?

  • Don’t use databases to store user generated content.
  • Don’t trust users to behave on your site.

Quiz 3: Make your site more secure

Q1. What is the name of the package that makes your app easier to develop, but not very secure

  • Insecure
  • Secure

Q2. In the video, before we implemented delete permissions, why does the image disappear then re-appear when we click on it?

  • The jQuery code makes the image disappear, then the animation is cancelled as the image is not allowed to be deleted.
  • The image is actually deleted from the local copy of the collection, but when the server checks the permissions, it blocks the delete from happening to the central copy. Then, the local collection re-syncs and reactivity causes the template to re-render.

Quiz 4: Tidy up the project

Q1. Which of the following is true?

  • The lib folder is only sent to the server.
  • JavaScript code in the lib folder runs before other code.

Q2. Do you need the ‘if(Meteor.isServer)’ test in the lib folder?

  • Yes
  • No

Quiz 5: Routing with iron:router

Q1. If we put the following code in our client javascript code, which template will be rendered when we visit http://localhost:3000/images?

Router.route('/', function(){ 

  this.render('images'); 

}); 

Router.route('/images', function(){ 

  this.render('navbar'); 

});

  • The images template.
  • The navbar template.

Q2. Why do we need to use routing?

  • To allow the specification of different pages on the site that the user can move to, without needing to completely reload the page.
  • To allow the creation of a sitemap showing the routes around the site.

Quiz 6: Better routing

Q1. What should the name attribute of the main layout template be set to if I configure the router using the following code:

Router.configure({ 

  layoutTemplate:'MainLayout',  })

  • MainLayout
  • LayoutTemplate

Q2. What does the yield mean in the following code?

{{> yield "header"}}

  • It is instructing the router that there is a point in the layout template to which it can render sub-templates and that it is called ‘header’.
  • It is instructing the router to render a template called ‘header’ at this point.

Quiz 7: Security and routing summary quiz

Q1. Which folder would you put template helper code into? (choose the best option)

  • server
  • shared
  • client
  • public

Q2. Where would you put collection definition code? (choose the best option)

  • shared or imports for newer versions of meteor
  • public
  • server
  • client

Q3. What will the following code do if you run it in the browser console?

for (var i = 0; i < 1000; i += 2){
Images.insert({
“img_src”:”no good!”});}

  • Nothing – the browser console has security features which prevent malicious users from executing dangerous code on websites.
  • Insert 500 images into the images collection
  • Insert 1000 images to the image collection
  • Nothing – you cannot insert images using a loop

Q4. What is the correct code to check the user is logged in before they can delete an image? (select all that apply)

  • Images.remove.allow(function(userId, doc){
    if (userId){
    return true;
    } else {
    return false; } })
  • Images.allow({
    remove:function(userId, doc){
    if (userId){
    return true;
    } else {
    return false; } } });
  • Images.allow({
    remove:function(userId, doc){
    if (Meteor.user()){
    return true;
    } else {
    return false; } } });
  • Images.allow({
    delete:function(userId, doc){
    if (userId){
    return true;
    } else {
    return false; } } });

Q5. What will the following code print in the browser console when a user tries to insert an image. assuming they are logged in?

Images.allow({
insert:function(userId, doc){
if (Meteor.isServer){
console.log(“insert on server”);
}
if (Meteor.isClient){
console.log(“insert on client”);
}
if (Meteor.user()){
return true;

  • Insert on client
  • Insert on client Insert on server
  • Insert on server
  • Nothing

Q6. Where should you put server start up code?

  • In the server folder
  • In the lib folder
  • In the client folder
  • In the startup folder

Q7. Which of the following route specifications will display the images template when the user visits http://localhost:3000/images ?

  • Router.route(‘/’, function(){ this.render(‘images’); });
  • Router.route(‘images’, function(){ this.render(‘/’); });
  • Router.route(‘/images’, function(){ this.render(‘images’); });
  • Router.route({ images: function(){ this.render(‘images’); } });

Q8. Which of the following is the most correct way to create a route that can take the user to a view called ‘/images’?

  • go to images
  • go to images
  • go to images
  • go to images</a src="https:>

Q9. Which statements are true about the following code?

Router.route(‘/images/:_id’, function () {
this.render(‘Home’, {
data: function () {
return Images.findOne({_id: this.params._id});} }); });

  • The Home template will be rendered
  • If the user views the address http://localhost:3000/images/123, the data context will be a single image that has the _id = 123.
  • The data context for the template will be a single image
  • We are defining a route that can be accessed via http://localhost:3000/Home when the server is running on our local machine.
Conclusion:

I hope this Introduction to Meteor.js Development Coursera Quiz Answers would be useful for you to learn something new from the Course. If it helped you, don’t forget to bookmark our site for more Quiz Answers.

T.Titus

Recent Posts

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

1 month ago

BREAKING: ZIMSEC O Level 2023 Results Out!!

ZIMSEC Ordinary level results have been released. The 2023 candidates achieved an overall pass rate…

4 months ago

O Level 2023 Results: When to Expect them: Debunking False Release Dates

O Level 2023 Results: When to Expect them: Debunking False Release Dates

4 months ago

How to view ZIMSEC 2023 A Level/O Level Results Online

How to view ZIMSEC 2023 A Level/O Level Results Online

4 months ago

Health for All Through Primary Health Care Quiz Answers

Summary of Health for All Through Primary Health CareExplore a holistic approach to well-being with…

5 months ago

Equine Welfare and Management Quiz Answers

Get All Modules Equine Welfare and Management Quiz AnswersEquine Welfare and Management Quiz Answers Module…

6 months ago