LIS 7008 - Information Technologies
Summer 2014 - Section 01
Assignment 6
This homework is due on your course Web site before the beginning of the next class session. Partial credit may be awarded.
If you do not have any previous programming experience,
it may take you long time to learn and you may feel frustrated. So we have a special
grading policy for this assignment. If your program works, you earn 100 points; if it partially works, you may earn a grade between 80-95; if you have done some meaningful work but it does not work at all,
do not sweat, I will take a look at your program and assign a grade between 60-79. If you do nothing, that is 0,
but it would be appreciated if you could tell me that you did not do anything because it takes time for me to figure out
what you have done.
The purpose of the assignment is to give you the opportunity to learn how JavaScript can be used to create an interactive Web page,
not to train you to be a good JavaScript programmer. If you are serious about being a Web designer, you are advised to take LIS 7510
Website Design and Management, in which Dr. Ju will teach you a whole lot of JavaScript. It is not realistic to train a social scientist
or a humanity scholar to be a JavaScript programmer in one class session if she/he has no previous programming experience.
Explanation
The JavaScript program that we looked at
in the lecture notes
(i.e., selector.html) is a good start, but a real search tool selector would
probably need to provide more options and do more sophisticated
selection. It is therefore important that you learn how to modify
JavaScript that you find on the Web to suit your purposes. In this
assignment, you will modify selector.html in two ways, and post your
modified page on your Web site for the instructor to grade.
If you have not downloaded the page, please do so here:
shorthand version or
full version (with semicolons and complete braces)
What the program does
The purpose of the program is to direct users to a Web Search Engine and a Web Directory based on the user's age.
If the user is an adult (age >17 and <120), direct her to www.yahoo.com if she
wants a Web Search Engine, or to dir.yahoo.com if she wants a Web Directory.
If the user is a kid (age ≤17
and >0), direct her to www.askkids.com if she wants a Web Search Engine, or to kids.usa.gov if she wants a Web directory.
Your Task: Modify the Program
Task 1. The library board has decided that people aged 16 and over should be
treated as adults by the search tool selector. Change your copy of the
page to implement this new policy.
Task 2. Your library director has learned that a recent report published in
the Journal of Internet Stuff has revealed that people over 40 prefer
the Yahoo! search engine (http://www.yahoo.com), but that
adults aged 40 and under prefer Google (www.google.com). Change
your copy of the page to send adults to the search engine that they
are most likely to like based on their age (if they select a search
engine).
Save your work as hw6.html (or whatever filename you like), then link this from your 7008.html Web page you created for HW4.
Testing
Please be careful when using age to specify a population group, for instance, age>16 means "17 and up".
Here are the age specifications and expected results:
- Age 0 to 15 - Ask Kids, kids.usa.gov
- Age 16 to 40 - Google and dir.yahoo
- Age 41 to 119 - Yahoo! and dir.yahoo
- Age 120 and above - Invalid
You can (and I will) use the following age values to test your program to get the expected results:
Age |
Expected Seach Engine |
Expected Web Directory |
10 |
ask kids |
kids.usa.gov |
16, 17, 40 |
Google |
dir.yahoo |
41, 50 |
Yahoo! |
dir.yahoo |
120 |
Invalid age 120 |
Invalid age 120 |
Common problems and solutions:
- Before revising the program, try to understand the logic of the program first (e.g., those functions, if-else statements,
and how those functions interact with each other). Do not try to revise anything before you understand the whole program.
(Similarly do not jump into the water if you do not know how deep/cold the water is.)
When adding/revising functions, make your logic clear. When making if-else statements, make mutually exclusive statements.
For example, in the statement if Condition A go east else go west, "Condition A and else (not-A)" are mutually exclusive conditions. If you use
"if - else if - else" statements, please make those conditions mutually exclusive.
- You cannot use statements like "(age>40)" or "(age > 15 && age < 40)" in the "function adult_jump()"
because that function does not have an "age" parameter and does not define an "age" variable; try to use
other functions [such as is_adult(age) or is_kid(age)] to replace those statements. Hint: you may want to
revise those smaller functions and/or write new ones to meet your needs.
- "Your specified website directs me to a different website."
You do not have to worry about it. This is a programming exercise. I use the website as an example only.
I do not care where it finally directs you as long as it is a serious website.
- "I do not know what is wrong with my program; it simply does not work."
The syntax of the programming language is very rigorous, so please pay great attention to the things you add, revise, or delete.
It is very common that right after changing anything in the program, it does not work.
In this case, please check whether you have lost any parentheses "()" and braces "{}"; check typos (such as functoin, retrun)
and inconsistent function names.
Also, Internet Explorer has a Javascript debugger. Here is a tutorial on
HOW-TO: Debug JavaScript in Internet Explorer
. Reminder: the debugger checks your syntax only; it does not check your semantics (logic). If you know what it does and how it works, it can be
helpful to you, otherwise it can be useless because it produces error messages you do not understand. Therefore, please do not depend on it totally.
If you have other questions, please ask me or TA. Please do not feel frustrated if you cannot make it work finally. I have the special grading policy
addressed above to protect you.
Grading rubric:
Grade |
Program |
0 |
Program is not posted on your course Website before the due time. |
80 |
Only Task 1 is finished. |
85 |
Efforts were made to finish Task 2, but program does not work. |
90 |
Program does not work, but you are almost there. |
99 |
Program has very minor errors.
E.g., if age==40, user should be directed to Google rather than Alta Vista.
|
100 |
Program's behavior meets specification. |
These are the most common categories. You can actually grade your work by yourself.
Acknowledgement to Doug Oard, revised by Yejun Wu.