Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Tutorials/Lab:
Every Tutorial/Lab from next week will have some assessment activities.
Assessment activities can consist of:
1. Completion of a closed-book on-line Blackboard quiz on previous
lecture(s) and Lab(s). (Remember: This will usually be the first thing to do in a lab
session)
2. Assessment of Lab Exercises. Exercises marked with an asterisk * are
assessable and contribute to your final grade. These should be completed in the
scheduled Lab, or if you are unable to complete the tasks in the Lab, then you
may arrange to have them checked off by your tutor in the following Lab. For
example, the assessable tasks in this weeks labs should be checked off in this
tute.
3. Demonstration of your Assignment work as scheduled for your Tutorials
Note: in this unit we use the terms tutorial and lab interchangeably. Lab
work is the practical exercises you do during the tutorial session.
Aims:
To analyse different views of the same HTML page through Firefox
Introduce programming concepts using JavaScript
This task is particularly designed for students who have not had previous experience with a
programming / scripting language. While the scripts you write in Creating Web Applications will not be
complex, you do need to understand some basic programming concepts and techniques. These include:
Data types and their operators
Variables
Sequences of program statements.
Conditional selection of statements
Repetition of statements
Functions
Arrays.
While these concepts are common to most programming languages, we will use JavaScript syntax in
these notes. We will be working through an online tutorial (if possible do this before the tutorial session)
and practicing creating some JavaScript programs and executing them with a JavaScript interpreter.
There are many JavaScript tutorials on the Web. We will use an interactive tutorial from Codecademy to
cover some scripting basics.
If you want the Web site to remember your progress you should register and login.
3. Follow the instructions on the left of the screen and enter the script on the right-hand pane as shown
in the figure below.
NOTE
When we get to Week 5 in this unit you will be using JavaScript to interact with Web pages. However the
Codecademy tutorial you are using in this lab has an interpreter that executes the statements you have
written when you click the Save and Submit Code button. The output from the executed code will be
shown in a little window in the top right of your window (or else in a pop-up window).
2. Alternatively you can write a sequence of JavaScript statements which are executed one after the
other as a program. The output from the program can then be displayed in the output window using
the console.log function. e.g.
console.log("This sentence will show on the console in the right hand pane");
4. In the Getting Started with Programming section, work through the exercises 1 to 28. There are
helpful on-screen hints if you get stuck but you if you are unsure about anything your tutor loves
answering questions!
5. The next section in the Codecademy tutorial is on Functions in JS. We will skip this section as the way
functions are declared in the tutorial is slightly different from how we will use them. (In JavaScript
functions can be treated as variables which is a very powerful technique but beyond the scope of this
unit.) At this stage this might be confusing so an alternative is to look at the brief description of
functions at the W3Schools site.
http://www.w3schools.com/js/js_functions.asp
You may find the W3Schools site a useful resource HOWEVER be careful. A lot of the material is out of
date and they do not separate HTML and JavaScript as we insist on in this unit.
6. The next section is an Introduction to 'FOR' loops in JS. FOR loops are a type of counted loop and
are most useful when we know upfront how many times we want to repeat the statements in the loop.
This section also includes an introduction to Array data structures which will be useful when we are
using set of controls on Web forms. Work through exercises 1 to 12.
7. A loop that you will be more commonly using in this unit is used for the repeated reading records
from a database for searching or display on a Web page. This is covered in Introduction to 'While' loops
in JS . Work through exercises 1 to 9 of this section.
8. The section More on Control Flow in JS has some revision and introduces the SELECT control
structure which allows a selection between multiple paths rather than just 2 as in the IF control
structure. It also introduces logical operators for evaluating more complex expressions that can be
either TRUE or FALSE. Work though all the exercises in this section. Note that some of the exercises in
the tutorial use the alternative method of declaring a function.
Thats it! You should now have a basic understanding of programming constructs that will give you the
prerequisite knowledge to complete the JavaScript and PHP coding sections of this unit. We will not be
covering more advanced data structures like OBJECTS in this unit so there is no need to do those
sections in the Codecademy tutorial.