Networked Software Systems Laboratory Department of...
Transcript of Networked Software Systems Laboratory Department of...
Networked Software Systems Laboratory
Department of Electrical Engineering, Technion
Performed by: Gidi Getter
Svetlana Klinovsky
Supervised by: Viktor Kulikov
Winter 2008
-1-
Table of Contents:
TABLE OF CONTENTS:......................................................................................................................1 OVERVIEW: ..........................................................................................................................................3 PROJECT GOALS: ...............................................................................................................................3 ENVIRONMENT:..................................................................................................................................4 ARCHITECTURE: ................................................................................................................................8 DATABASE LAYER: ............................................................................................................................9
TABLES: ...............................................................................................................................................9 STORED PROCEDURES: .......................................................................................................................11
DATA ACCESS LAYER:....................................................................................................................12 BUSINESS LOGIC LAYER: ..............................................................................................................15
SEMESTER CLASS: ..............................................................................................................................17 COURSE CLASS: ..................................................................................................................................18 EXPERIMENT CLASS: ..........................................................................................................................19 SCHEDULE CLASS: ..............................................................................................................................20 STUDENT CLASS: ................................................................................................................................21 ENROLLMENT CLASS: .........................................................................................................................21 STAFF CLASS: .....................................................................................................................................22 BLEXCEPTION CLASS: ........................................................................................................................24 LOGIN CLASS: .....................................................................................................................................24 REPORT CLASS: ..................................................................................................................................25
PRESENTATION LAYER: ................................................................................................................26 THE CLASSES OF PL1: ........................................................................................................................26
MasterPage1 class (MasterPage): ...............................................................................................27 SessionData class: ........................................................................................................................28 _Default class (Page): ..................................................................................................................29 LoginPageStudent class (Page): ...................................................................................................29 UserCtrlNewStudent class (UserControl): ...................................................................................30 UserCtrlExistingStudent class (UserControl): .............................................................................31 Information class (Page): .............................................................................................................31 Schedules class (Page): ................................................................................................................32 UserCtrlSchedules class (UserControl): ......................................................................................32 Registration class (Page): ............................................................................................................33 Grades class (Page): ....................................................................................................................33 UserCtrlGrades class (UserControl): ..........................................................................................33 StudentDetails class (Page): .........................................................................................................34 UserCtrlStudentDetails class (UserControl): ...............................................................................34
THE CLASSES OF PL2: ........................................................................................................................35 MasterPage2 class (MasterPage): ...............................................................................................35 SessionData class: ........................................................................................................................37 _Default class (Page): ..................................................................................................................38 LoginPageUser class (Page): .......................................................................................................39 UserCtrlUserLogin class (UserControl): .....................................................................................39 Semesters class (Page): ................................................................................................................39 UserCtrlSemesters class (UserControl): ......................................................................................40 Courses class (Page): ...................................................................................................................40 UserCtrlCourses class (UserControl): .........................................................................................41 Experiments class (Page): ............................................................................................................42 UserCtrlExperiments class (UserControl): ..................................................................................42
-2-
InformationUser class (Page): .....................................................................................................42 UserCtrlInformationUser class (UserControl): ...........................................................................43 SchedulesUser class (Page): ........................................................................................................44 UserCtrlSchedulesUser class (UserControl): ..............................................................................44 UserCtrlScheduleDetails class (UserControl): ............................................................................45 UserCtrlDateTimePicker class (UserControl): ............................................................................46 GradesUser class (Page): .............................................................................................................46 UserCtrlGradesUser class (UserControl): ...................................................................................47 ReportUser class (Page):..............................................................................................................47 UserCtrlReport class (UserControl): ...........................................................................................48 StudentAccounts class (Page):......................................................................................................48 UserCtrlStudentAccounts class (UserControl):............................................................................49 UserAccounts class (Page): ..........................................................................................................49 UserCtrlUserAccounts class (UserControl): ................................................................................50 UserCtrlNewAccount class (UserControl): ..................................................................................51 Account class (Page): ...................................................................................................................51 UserCtrlAccount class (UserControl): .........................................................................................52 UserCtrlRoles class (UserControl): .............................................................................................53
APPENDIX A – PREPARING & CONFIGURING THE APPLICATION: ..................................54 APPENDIX B – USER MANUAL:.....................................................................................................55
THE STUDENT'S APPLICATION: ............................................................................................................55 THE STAFF'S APPLICATION: .................................................................................................................57
-3-
Overview:
Nowadays most faculties, laboratories, and courses have interactive systems that
allow the staff and students to perform general tasks (as course registering, viewing
information, downloading and uploading material). This project deals with building a
web site for Communication laboratory. Using this site, students will be able to
register and get information about experiments, and get their grades later. Staff will be
able to publish relevant experiment issues and students' grades.
The system was built with the thought that the site should be easy to use – no difficult
configurations, data is arranged in multiple pages that are not too complex and easily
accessible, with basic security when needed.
The system is not limited to deal only with the experiment it was created for – it can
deal with multiple courses, each with multiple experiments, each course managed
independently.
Project Goals:
• Create a system that enables the instructors of a course to create schedules for an
experiment, and for the students to register to these schedules.
• The system's web server should be written using the ASP.NET framework,
with code behind written in C#.
• The system's database should be implemented in T-SQL.
• Learn and practice the ASP.NET framework, C# language and database design.
-4-
Environment:
T-SQL: The database is implemented in Transact-SQL, which is Microsoft's implementation
of SQL. SQL is a programming language designed to manage databases, and it is
optimized to perform queries of records in the database and to manipulate these
records. The database is stored in a non-volatile device (disk), so it is not lost when
the server containing it is shut-down. The database is build from multiple tables, and
each table contains records with defined fields. The main statements for queries and
manipulation of the records are 'SELECT', 'INSERT', 'UPDATE' and 'DELETE'.
These statements can be used to create more complicated code sequences involving
one table or more, called stored procedures. The stored procedures can be easily
called from outside the database.
C#: C# is an object-oriented programming language that was developed by Microsoft as a
part of its .NET framework. Its syntax and most of its features were taken from C++
and influenced by Java. As part of the .NET framework, C# uses its garbage collector
mechanism to free dynamic memory which is no longer used, instead of the
programmer freeing the memory explicitly. In contrast to C++, no methods are global;
they all have to be in classes. Another difference is that all variables are objects, there
are no primitive types. In C# a class can inherit from one class only, but it can inherit
from multiple interfaces which act like abstract classes. A unique feature of C# is the
property, which is a variable with get and set methods defined for it, and is treated as
a regular variable. This feature gives access control to the variable, and also gives
opportunity to manipulate the variable. As part of the .NET framework, C# can access
a variety of rich libraries, and all the programmer has to do is to access the library's
namespace.
-5-
.NET: The .NET framework is a software development platform that was developed by
Microsoft. The framework offers portability of the code, meaning code that was
written in one operating system can be run without changes in any other operating
system, as long as the .NET framework itself can be run there. The framework
supports multiple languages (C#, Visual Basic, Visual C++, J#) and contains rich
libraries which are common to all of these languages. The framework runs the
programs under the supervision of a virtual machine called Common Runtime Engine
that provides security and memory management. Unlike in traditional C++, there is no
direct access of the programs to the memory (or other resources), thus dynamically
allocated memory does not have to be freed as a mechanism called garbage collector
frees allocated memory that is no longer used.
The compilation of a source code is different from traditional C++. Source codes from
all .NET languages are compiled to a platform independent code written in Common
Intermediate Language (CIL), sometimes called byte-code. On runtime, the Common
Language Runtime (CLR), which is specific for the platform, compiles the CIL code
with the libraries to the native code (binary code) that the CPU will execute.
ASP.NET: ASP.NET is a web application platform, based on the .NET framework. It is used to
build dynamic web pages, displaying controls that invoke server-side code. ASP.NET
offers separation between the presentation of the pages and their contents – the html
code of the page displayed is written in an aspx file, while the code-behind is written
in another file (usually cs or vb file). ASP.NET defines events that are initiated on
client-side (page load, button clicked etc) and are caught on server-side by event
handlers in the code-behind file. The framework allows the programmer to define the
event handlers in the aspx file, and expects him to implement the handlers in the code-
behind file. Relying on the .NET framework's CLR, ASP.NET allows the programmer
to implement the code-behind in any of the .NET languages.
-6-
Ajax:
Ajax is a technology that helps increasing the interactivity of a web page by reducing
the time that the page is loaded. This is done by updating only parts of the page that
were requested instead of loading the page as a whole. Without Ajax, page load is run
at the server, and the entire page is returned. Ajax, on the other hand, uses JavaScript
which is run at client-side in order to communicate with the server asynchronically to
receive the needed data, interpret it and display it in the browser.
Master Page:
Master pages are used to create a site with multiple pages, where all pages share
common look or contents. The principle is simple: everything common is placed in
the master page – page design and contents – and it will appear in all of the pages
resulting from the contents pages declaring using the master page. The contents that
are unique for every page are placed in the contents pages. On user request, the master
page is merged with the content page into a single page. Master pages are very useful
when there are many pages in a site – they help to eliminate redundancy, so less effort
is needed and the chance of bugs is reduced.
User Control:
User control is an indirect child class of the Control class, meaning it can be used
instead of regular ASP.NET controls in a web form page. Usually it is used to contain
a common functionality required in multiple pages, so there is only need to declare it
when required. User control is declared and implemented in a similar way to a page,
in an ascx file. Using user controls helps avoiding code repeat resulting in less code
written and better maintainable application. Another benefit of the user control is that
it can be used programmatically instead of declaratively – the code-behind can load
the user control in runtime. This can be very useful – a user control can contain
contents of a whole page, and combined with Ajax, switching between user controls
can be a very interactive alternative to page navigation.
-7-
ADO.NET: ADO.NET is a library in the .NET framework that is used to access databases and to
model the databases in the memory.
The access to the database is made of a DbConnection class that handles the
communication, DbDataAdapter class that is used to define the relations between the
database and its model in the memory, DbCommand class that contains or references
database code that can be executed by the adapter and DbParameter class that defines
a parameter of a command. The architecture described is general for many types of
databases, although a specific implementation for these classes is made for every
database type (SQL, OLE-DB, Oracle).
Modeling of the database is made with the DataSet class as the entire database or any
group of tables, DataTable as a table in the database, DataView as a query result,
DataColumn and DataRow as table's column and row, and DataRelation as relation
between a foreign key and its primary key.
-8-
Architecture:
The application's architecture is based on the 4-tier model:
Database layer: this layer is implemented in SQL, and stores all the data that the
application saved in a non-volatile device. It contains all the tables in the database
with their relations, and also stored procedures that commit changes in these tables
that are called from the next layer.
Data access layer: this layer and all the following layers are implemented in C#. Its
uses are to receive the information from the database, to create a model of the
database in the memory using datasets, and to supply a convenient interface to the
business logic layer to update the database.
Business logic layer: contains the objects that are accessed by the presentation layer
with methods that implement the functionality needed. Most of the classes represent
tables in the database, but also classes were added for processing, security and
exception handling.
Presentation layer: implements all the pages shown to the user and their controls.
Takes the data from the business logic objects and displays it to the user. When the
user touches any of the controls, an event handler is fired in response allowing the
user to interact with the application.
-9-
Database Layer:
Relational database model was used.
Database contains tables, relations and stored procedures.
Tables contain data and have constraints for data input protection.
Stored procedures are used to manipulate the data efficiently on server side.
Tables:
A diagram of tables in the database:
Coursecourse_id
c_number
c_name
Exp_Scheduledexp_sch_id
exp_date_time_1
exp_date_time_2
exp_date_time_3
exp_room
places
reg_start_date_time
reg_end_date_time
instructor_user_role_id
exp_sem_id
Experimentexp_id
exp_name
exp_description
laboratory_name
laboratory_location
course_idExperimentSemester
exp_sem_id
exp_id
semester_id
Personperson_id
p_ID_number
p_first_name
p_last_name
p_e_mail
Rolerole_id
role
description
Semestersemester_id
ac_season
ac_year
is_current
Studentstudent_id
st_ID_number
st_first_name
st_last_name
st_e_mail
Student_Enrollment_Gradest_enrollment_grade_id
enrollment_date
st_grade
student_id
exp_sch_id
exp_sem_id
User_Accountuser_acc_id
user_name
password
active
person_id
User_Roleuser_role_id
role_id
user_acc_id
UserRole_Courseuserrole_course_id
user_role_id
course_id
-10-
Two users of the system are presented:
1. Laboratory/course staff:
• Person table contains personal info.
• User_Account table contains user accounts in the system. Each account
references a record of personal details in the Person table. Account can be in
active or non active state (active column).
• Role table defines a role for each of the staff users (can have more than one
role) – here we have administrator, course supervisor and instructor roles.
• User_Role table is used to apply many-to-many relationships between
User_account and Role tables.
2. Students:
• Student table contains personal info.
• Student_Enrollment_Grade table contains grades and enrollment date of
each student and "connects" student to Exp_Scheduled table (many-to-many
relation with ExperimentSemester table) and by that giving an opportunity to
register to appropriate date of selected experiment in selected course.
Database also contains course, experiment and semester information in Course,
Experiment and Semester tables respectively.
UserRole_Course and Experiment_Semester tables are used for connection between
respective tables.
Each table has <table name>_id column of uniqueidentifier type that stores 16-byte
binary values that operate as globally unique identifiers (GUID). A GUID is a unique
binary number; no other computer in the world will generate a duplicate of that GUID
value. The main use for a GUID is for assigning an identifier that must be unique in a
network that has many computers at many sites.
Uniqueidentifier column's value is obtained by calling the NEWID function.
-11-
Stored Procedures:
The database also contains stored procedures – group of Transact-SQL statements
used for efficient data manipulation. We used simple set of stored procedures: insert,
update and delete for each table.
For example, add_user_account stored procedure: CREATE PROCEDURE [dbo].[add_user_account] @user_name varchar(50), @password binary(16), @active int, @person_id uniqueidentifier AS BEGIN -- Statements of procedure IF EXISTS (SELECT * FROM dbo.Person WHERE person_id = @person_id) INSERT INTO dbo.User_Account(user_name, password, active, person_id) VALUES (@user_name, @password, @active, @person_id); ELSE RAISERROR ('print: User details not found', 16, 1); END
-12-
Data Access Layer:
The layer represented as a class, and uses ADO.NET library.
ADO.NET common structure:
DataSet enables an easy loading of data to business logic and updated data to
database. Can hold the data arranged in a similar way as in the database (tables with
rows, columns, constraints and relations).
Another advantage of the DataSet is working with data on disconnected mode.
DataProvider components designed for fast access to data:
1. Connection object provides connectivity to a data source (we open connection
only for transferring data and work with data on disconnected mode).
2. Command object enables to execute SQL commands and run stored procedures.
3. DataAdapter provides the bridge between the DataSet object and the data
source – fills DataSet with data (Select SQL command) and updates database
using stored procedures.
4. DataReader provides a high-performance stream of data from the data source.
-13-
The class diagram of DAL:
1. DataAccessLayer class:
This class provides the business logic access to DataSet.
It is possible to create only one instance of the class. The instance is created
during the first call of GetInstance() method. Further calls only return the created
instance again.
Business logic can read and modify the DataSet. UpdateDatabase() method is used
to update database with the changes made.
In case of failure during database update, DALException with an appropriate error
message is thrown.
Public methods:
• public static DataAccessLayer GetInstance() – returns an instance of
DataAccessLayer class that contains all data tables in its DataSet.
• public static DataAccessLayer GetInstance(Tables[] tables) – returns an
instance of DataAccessLayer class that contains chosen data tables in its
DataSet.
• public DataSet DataSet – property that returns DataSet contained in the
instance of the class.
• public void UpdateDatabase() – updates the database with changes made in
the DataSet.
-14-
2. DalException class
This class represents an exception that may be thrown from DataAccessLayer
class. Such an exception may either be created by the DAL code or an exception
caught from database wrapped as a DalException.
3. Tables
Enums tables for DataAccessLayer class usage.
4. Translator static class
"Translates" table name to Tables enum presentation and vice verse.
-15-
Business Logic Layer:
The class diagram of BLL:
The classes of the business logic layer can be divided into two groups: classes that
directly represent one table or more in the database, and classes that are not related
directly to a specific table, but are used to implement functionalities that are required
by the presentation layer.
The first group consists of the following classes: Semester, Course, Experiment,
Schedule, Enrollment, Student, and Staff. These classes have several things in
common:
• All the columns of the datatable are represented by fields in the class
representing the datatable.
• The accessibility level of all fields is defined as protected, and some of them can
be accessed by a property with the same name differentiated by a first capital
letter, whose accessibility level is public.
• Calling the constructor of the class performs a query in the datatable represented
by the class for a row that matches the parameters given.
• As a result of calling the constructor a new object is created. If a matching row
was found in the datatable, a boolean field in the object named exists is
initialized to true, and the columns of the row are loaded to the fields of the
object. If no matching row was found, the exists field is initialized to false, and
only the parameters of the constructor fill the fields of the object.
-16-
• In case the business logic object represents a row that does not exist in the
datatable, it can be created using a method (named CreateX or AddX).
• In case the business logic object represents a row that exists in the datatable, it
can be deleted using a method (named DeleteX or RemoveX).
• In case the business logic object represents a row that exists in the datatable, it
can be updated using a method (named UpdateX).
• All classes implement the CompareTo method of the IComparable interface,
providing a logical sort in lists.
• All classes override the Equals, GetHashCode, and ToString methods inherited
from the Object class.
The second group consists of the following classes: Report, Login, and BlException.
• The Report class creates a report of the experiments' grades of all students
registered to these experiments.
• The Login class is responsible to the handling of the login password of the staff
members.
• The BlException is the exception class that is thrown from the business logic. It
is also responsible to parse exceptions thrown from the database and to convert
them into a readable format.
-17-
Semester class:
• The class represents an academic semester, for example the
winter semester of 2009.
• The table in the database that stores the data: Semester.
• Description of the methods:
• Semester – constructor of the Semester class.
• CreateSemester – creates a record in the database with
this object attributes.
• DeleteSemester – deletes a record in the database with
this object attributes.
• UpdateSemester – updates a record in the database with
this object attributes.
• SetAsCurrent – defines this semester as the current
semester.
• GetCurrent (static) – returns the semester defined as
current, or null if none is defined.
• GetAllSemesters (static) – gets a list of Semester objects
representing all the semester records in the database.
• GetAllSemesterCourses – gets a list of Course objects
representing the courses given in this semester.
• IsCourseGiven – checks if a specific course is given in
this semester.
• IsExperimentGiven – checks if a specific experiment is
given in this semester.
• AreExperimentsGiven – checks if a specific course that
is given in this semester has experiments.
• GetSemesterSeasons (static) – gets a list of strings
representing the semesterial seasons in a year.
-18-
Course class:
• The class represents a course that gives experiments, for
example course number 044214 – Takash.
• The table in the database that stores the data: Course.
• Description of the methods:
• Course – constructor of the Course class.
• CreateCourse – creates a record in the database with this
object attributes.
• DeleteCourse – deletes a record in the database with this
object attributes.
• UpdateCourse – updates a record in the database with
this object attributes.
• AddToSemester – adds this course to the list of courses
given in the semester.
• DeleteFromSemester – deletes this course from the list
of courses given in the semester.
• GetAllCourses (static) – gets a list of Course objects
representing all the courses records in the database.
• GetAllCourseExperiments – gets a list of Experiment
objects representing the experiments given in this course.
• GetSemCourseExperiments – gets a list of Experiment
objects representing the experiments given in this course
at the given semester.
-19-
Experiment class:
• The class represents an experiment in a course and also an
instance of the experiment given in a specific semester.
• The tables in the database that stores the data: Experiment,
ExperimentSemester.
• Description of the methods:
• Experiment (1) – constructor of the Experiment class.
Creates an instance of experiment information only
global to all semesters.
• Experiment (2) – constructor of the Experiment class.
Creates an instance of experiment assigned to a semester
using an experiment which already exists in the database.
• CreateExperiment – creates a record of the experiment's
instance according to its type: a record to its details only
(Experiment), a record to its assignment only
(ExperimentSemester) or two records for both.
• DeleteExperiment – deletes a record of the experiment's
instance according to its type.
• UpdateExperiment – updates a record of the
experiment's instance (details only).
• GetExperimentSchedules – gets a list of Schedule
objects representing the schedules for this experiment.
• GetExperimentStudents – gets a list of the students
registered to this experiment.
-20-
Schedule class:
• The class represents one schedule or more of an experiment
in specific date/s and time/s that can be enrolled to.
• The table in the database that stores the data: Exp_Scheduled.
• Description of the methods:
• Schedule – constructor of the Schedule class.
• CreateSchedule – creates a record in the database with
this object attributes.
• DeleteSchedule – deletes a record in the database with
this object attributes.
• UpdateSchedule – updates a record in the database with
this object attributes.
• GetAllStudentsEnrolled – gets a list of Student objects
representing the students enrolled to this experiment's
schedule.
• GetStudentsEnrolledAndGrades – gets two lists of
objects representing the students enrolled to this
experiment's schedule and their grades.
-21-
Student class:
• The class represents a student.
• The table in the database that stores the data: Student.
• Description of the methods:
• Student – constructor of the Student class.
• CreateStudent – creates a record in the database with
this object attributes.
• DeleteStudent – deletes a record in the database with this
object attributes.
• UpdateStudent – updates a record in the database with
this object attributes.
• IsRegisteredToExperiment – indicates if this student is
registered to the experiment.
• DeleteStudentEnrollments – deletes all the enrollments
of this student.
• SearchStudents (static) – gets a list of Student objects
representing the matching student records in the database.
Enrollment class:
• The class represents an enrollment of a student to a schedule.
• The table in the database that stores the data:
Student_Enrollment_Grade.
• Description of the methods:
• Enrollment – constructor of the Enrollment class.
• AddEnrollment – creates a record in the database with
this object attributes.
• RemoveEnrollment – deletes a record in the database
with this object attributes.
• SetGrade – sets the grade field in this object and update
the corresponding record in the database.
• ClearGrade – clears the grade field in this object and
updates the corresponding record in the database.
-22-
Staff class:
• The class represents a user account and personal details. It
also contains the roles of the user.
• The tables in the database that stores the data: Person,
User_Account, Role, User_Role, UserRole_Course.
• Description of the methods:
• Staff (3 overloads) – constructors of the Staff class.
Creates an instance containing user information, person
information, or both.
• FillPersonFromUser – fills the information of the person
corresponding to the user from the database.
• CreatePerson – creates a record in the database with this
object person attributes.
• CreateUser – creates a record in the database with this
object user attributes.
• DeletePerson – deletes a record in the database with this
object person attributes.
• DeleteUser – deletes a record in the database with this
object user attributes.
• UpdatePerson – updates a record in the database with
this object person attributes.
• UpdateUser – updates a record in the database with this
object user attributes.
• ActivateAccount – activates this user account.
• DeactivateAccount – deactivates this user account.
• AssignAsAdministrator – assigns this user to the
Administrator role.
• UnassignAsAdministrator – unassigns this user from
the Administrator role.
• AssignAsCourseSupervisor – assigns this user to the
Course Supervisor role.
• UnassignAsCourseSupervisor – unassigns this user
from the Course Supervisor role.
-23-
• AssignAsInstructor (1) – assigns this user to the
Instructor role.
• AssignAsInstructor (2) – assigns this user to the
Instructor role of the given course.
• UnassignAsInstructor (1) – unassigns this user from the
Instructor role.
• UnassignAsInstructor (2) – unassigns this user from the
Instructor role of the given course.
• InitRoles (static) – initializes the roles in the database.
• GetAllRoles (static) – gets a list of the names of all roles
records in the database.
• GetAllStaffMembers (static) – gets a list of Staff objects
representing all the users' records in the database.
• AdministratorsCount (static) – gets the number of
administrators in the system.
• GetPersonUsernames – gets a list of strings representing
all the usernames of this person.
• GetCourseInstructors (static) – gets all the staff
members related to a course.
• IsAdministrator – notes if the user is an administrator.
• IsCourseSupervisor – notes if the user is a course
supervisor.
• IsInstructor – notes if the user is an instructor.
• GetStaffMemberRoleInstances – gets all the instances
in which the staff's role occurs.
• GetInstructorCourses – gets all the courses in which the
instructor instructs.
-24-
BlException class:
• The class represents the exceptions thrown from the business
logic layer and formatting of exceptions from the database.
• The tables in the database that stores the data: none.
• Description of the methods:
• Parse (static) – parses the message of the exception given
into a readable string explaining the error to the user.
• InitParser (static) – creates a new dictionary object and
fills it with the keys that are the exception messages from
the database and their corresponding values that are the
readable messages.
Login class:
• The class implements the password validation and
maintenance of the user accounts in the system.
• The tables in the database that stores the data: none.
• Description of the methods:
• SetUserPassword – receives a password as a parameter,
encrypts it using MD5 encryption, and sets it to be the
new user's password.
• CheckUserPassword – receives a password as a
parameter, encrypts it and checks if it matches the
password that has previously been encrypted and set for
the user.
• RegeneratePassword – generates a new password for the
user (in case he forgot it) and sends the new password as
an email to the user's email account.
• RandomizePassword – randomizes a string which is
seven characters long, containing letters and numbers.
• SendMail – sends an email to the user's email account
containing his new password.
-25-
Report class:
• The class creates a grades report of all the students enrolled
to the experiments in one course during a semester.
• The tables in the database that stores the data: none.
• Description of the methods:
• Report – constructor of the Report class.
• AddExperimentToReport – includes another
experiment to the experiment with the given weight.
• RemoveExperimentFromReport – removes an
experiment from the report with its weight.
• GetReport – creates a table containing all the
experiments that were included in the columns with an
extra column for the average grade, which is calculated
according to the weights given. The rows contain all the
students that registered to the experiments.
-26-
Presentation Layer:
The presentation layer contains two main parts, each part is implemented as a separate
project in the solution (both are ASP.NET web application) – the student's interface
whose project's name is PL1 and the staff's interface whose project's name is PL2.
Both projects are built in a similar way and have many things in common:
• The pages in the project are a combination of a single master page with each of
the content pages.
• The pages share data stored in the SessionData class which is instantiated in the
SessionState (a data structure that is stored in the memory throughout the entire
session of the user).
• The pages use user controls that contain a group of controls with their code-
behind that are used as indecomposable units in a page and can be shared within
multiple pages. These controls can be loaded dynamically, meaning that a page
can load or drop them as a response of the user's input.
The classes of PL1:
The class diagram of PL1:
-27-
MasterPage1 class (MasterPage):
• Implementing files: MasterPage1.Master, MasterPage1.Master.cs
The class is used to share the style of the page and some controls with their code-
behind between all the content pages in the project. The styles and controls that are
shared:
• The main menu, menu div and its styles. The menu is not positioned inside any
UpdatePanel, because menu controls do not work well with Ajax.
• The ScriptManager and the UpdatePanel controls – these controls are used to
activate Ajax. The controls affect all the controls inside the UpdatePanel,
including the ContentPlaceHolder controls that relate the master page with the
content pages, so Ajax is in default activated in the content pages (although can
be shut down by content page).
• The MainDiv (which is an html div tag) – containing the data of the pages.
• A table containing 3 rows and 2 columns. The left column is empty and
is used as an offset from the left margin of the window, so contents in the
right column will not overlap the menu.
• A ContentPlaceHolder control that the content pages use to display
the title of the page.
• 2 label controls to display error messages.
• A ContentPlaceHolder control to display the page the contents.
• The StateDiv – displaying information that is stored in the SessionState that
the user must know, so he can understand what is displayed to him.
The position of the divs and the tables, their width and height are defined in the
Styles.css file for monitor display and in the Print.css file for printer display.
A general sketch of the divs in the page:
StateDiv MainDiv
menu
TitleRow
ErrorRow
ContentsRow
-28-
The menu in MasterPage1 is mostly declarative – the menu and most of the
MenuItems inside are declared in the aspx file. Only the items that are children of the
"Select Course" and "Select Experiment" items are loaded programmatically (using
C# code). Some of its style properties are declared in the aspx file, while properties
that are thought to be configurable are defined using Menu.css file.
Methods:
• ReadQueryString – reads parameters from query string.
• InitControls – fills menu items with child items, and
disables irrelevant items.
• SelectMenuItems – checks all menu items and selects the
one whose page was loaded (therefore saved in
SessionData).
• ShowTitle – shows the title of the page that is loaded.
Event handlers:
• Page_Load – fires on page load.
• Menu1_MenuItemClick – fires when a menu item in the menu is clicked.
Properties:
• ErrorLabelsColor – sets the color in which the error labels are displayed.
• ErrorLabelText1 – sets the text that is shown in ErrorLabel1.
• ErrorLabelText2 – sets the text that is shown in ErrorLabel2.
SessionData class:
• Implementing file: SessionData.cs
This class holds the data that is needed to be shared between the different pages and
user controls of the site from the moment the user loads a page from the site and until
his browser disconnects from the site. The class is instantiated in the SessionState
object that can be accessed through the Session property in any page or user control.
The SessionState object is stored as a key named ExperimentRegistration in the
SessionData internal hash and can be accessed with this key from any page, not only
the page that created it.
-29-
Methods:
• GetInstance (static) – accesses the SessionState object and
returns the SessionData object stored inside it. In case the
SessionData object does not exist, creates the object.
Properties:
• DestinationPage – in login, stores the destination page
after redirection to login page.
• SelectedStaticMenuItem – the menu item clicked that is
marked as selected.
• RedirectedCourse – an option to access page with query
string containing course, so it will be the default.
• IsCourseLocked – noting if locked on the requested course.
• StudentLogin – contains an instance of the student that logged in to the system
or null if none did.
• CurrentSemester – contains the current semester defined by administrator.
• SelectedCourse – the course selected by the user or default.
• SelectedExperiment – the experiment selected by the user or default.
_Default class (Page):
• Implementing files: Default.aspx, Default.aspx.cs
• Master page used: MasterPage1
• User controls used: none
This class implements an empty contents page, which is also the default page (the
page that is loaded when the address that is written in the browser contains only the
domain of the site without any page).
Event handlers:
• Page_Load – fires on page load.
LoginPageStudent class (Page):
• Implementing files: LoginPageStudent.aspx, LoginPageStudent.aspx.cs
• Master page used: MasterPage1
-30-
• User controls used: UserCtrlNewStudent, UserCtrlExistingStudent (both
declaratively)
This page enables the student to log in to the system. It displays to the student two
choices – logging in as a new user (if the student has not logged in before) or as an
existing user (logged in and has an account). The controls that appear are contained in
two user control – one for each choice. The page disables or enables the child controls
in each user control according to the choice selected by the radio buttons.
Methods:
• DisableUserControl – disables the user control given and
its child controls.
• EnableUserControl – enables the user control given and
its child controls.
Event handlers:
• Page_Load – fires on page load.
• RadioButton1_CheckedChanged – fires when
RadioButton1 is checked or unchecked.
• RadioButton2_CheckedChanged – fires when
RadioButton2 is checked or unchecked.
UserCtrlNewStudent class (UserControl):
• Implementing files: UserCtrlNewStudent.ascx, UserCtrlNewStudent.ascx.cs
The user control displays a table containing fields with the student's details that can be
filled. A submit button is used to save the details and log in. The fields are validated
on client side by field validators to prevent illegal inputs.
Methods:
• CheckPassword – checks with UG system if the password
entered is correct.
Event handlers:
• Page_Load – fires on page load.
-31-
• SubmitButton_Click – fires when the SubmitButton is
clicked. Saves the students details into a new account and
logs in to the system.
UserCtrlExistingStudent class (UserControl):
• Implementing files: UserCtrlExistingStudent.ascx,
UserCtrlExistingStudent.ascx.cs
The user control displays a table containing student's I.D and password, with a submit
button to log in. The fields are validated on client side by field validators to prevent
illegal inputs.
Methods:
• CheckPassword – checks with UG system if the password
entered is correct.
Event handlers:
• Page_Load – fires on page load.
• SubmitButton_Click – fires when the SubmitButton is
clicked. Logs in to the system.
Information class (Page):
• Implementing files: Information.aspx, Information.aspx.cs
• Master page used: MasterPage1
• User controls used: none
This page shows information of an experiment supporting rich text format as inserted
by the course staff.
All the information is stored as html tags and text, and is presented using a
LiteralControl that is dynamically created.
Event handlers:
• Page_Load – fires on page load.
-32-
Schedules class (Page):
• Implementing files: Schedules.aspx, Schedules.aspx.cs
• Master page used: MasterPage1
• User controls used: UserCtrlSchedules (declaratively)
This page shows all the schedules of an experiment in the current semester, with
details of the schedules and registered students.
The page uses UserCtrlSchedules and sets AllowRegistration as false (read only).
Event handlers:
• Page_Load – fires on page load.
UserCtrlSchedules class (UserControl):
• Implementing files: UserCtrlSchedules.ascx, UserCtrlSchedules.ascx.cs
This user control implements the logic of the Schedules and Registration pages.
Methods:
• AddExperimentDetails – adds the details of the
experiment schedule to the schedule datatable.
• AddStudentsEnrolled – adds the students that enrolled to
the schedule to the schedule datatable.
• AddFooter – adds a counter of the places left in the
schedule to the schedule datatable.
• FillGridView – fills the schedule gridview with the
datatable contents and defines its colors.
• AddControls – adds the gridview and a button enabling the
student to register or unregister to placeholder.
• IsScheduleOpen – checks if the schedule is open for
registration.
Event handlers:
• Page_Load – fires on page load.
• registerButton_Click – fires when one of the register buttons is clicked.
• unregisterButton_Click – fires when one of the unregister buttons is clicked.
-33-
Properties:
• AllowRegistration – property set by the page containing the user control
indicating whether this user control is used for registration (true) or just to show
the schedules (false).
Registration class (Page):
• Implementing files: Registration.aspx, Registration.aspx.cs
• Master page used: MasterPage1
• User controls used: UserCtrlSchedules (declaratively)
This page shows all the schedules of an experiment in the current semester, with
details of the schedules and registered students, enabling the user to register to the
schedules.
The page uses UserCtrlSchedules and sets AllowRegistration as true.
Event handlers:
• Page_Load – fires on page load.
Grades class (Page):
• Implementing files: Grades.aspx, Grades.aspx.cs
• Master page used: MasterPage1
• User controls used: UserCtrlGrades (declaratively)
This page displays the grades of the student in the experiments he registered to in the
current semester.
Event handlers:
• Page_Load – fires on page load.
UserCtrlGrades class (UserControl):
• Implementing files: UserCtrlGrades.ascx, UserCtrlGrades.ascx.cs
This user control implements the logic of the Grades page.
The user control displays the grades in a gridview that is loaded on page load with the
contents of the datatable returned by the GetGrades method.
-34-
Methods:
• GetGrades – creates a datatable containing the grades of
the student.
Event handlers:
• Page_Load – fires on page load.
StudentDetails class (Page):
• Implementing files: StudentDetails.aspx, StudentDetails.aspx.cs
• Master page used: MasterPage1
• User controls used: UserCtrlStudentDetails (declaratively)
This page displays the personal details of the student and enables him to change them.
Event handlers:
• Page_Load – fires on page load.
UserCtrlStudentDetails class (UserControl):
• Implementing files: UserCtrlStudentDetails.ascx,
UserCtrlStudentDetails.ascx.cs
This user control implements the logic of the StudentDetails page.
The user control displays a table containing fields with the student's details that can be
changed (except the I.D field) on button click. The fields are validated on client side
by field validators to prevent illegal inputs.
Methods:
• FillStudentDetails – loads the student's details into the
textboxes.
Event handlers:
• Page_Load – fires on page load.
• Button1_Click – fires when the save button is clicked.
• Button2_Click – fires when the cancel button is clicked.
-35-
The classes of PL2:
The class diagram of PL2:
MasterPage2 class (MasterPage):
• Implementing files: MasterPage2.Master, MasterPage2.Master.cs
The class, as MasterPage1 class, is used to share the style of the page and some
controls with their code-behind between all the content pages in the project. The same
styles and controls are shared as in MasterPage1. In brief, the master page shares the
followings:
• The main menu.
• The Ajax controls (ScriptManager and the UpdatePanel).
• The layout of the page (div tags), labels and place holders nested in the divs.
However, the main menu shared is significantly different. Unlike the menu in
MasterPage1, the menu in MasterPage2 is almost entirely defined programmatically –
most of the MenuItems inside the menu are created in the cs file at run time. Only the
Login and Logout items are declared, besides the menu itself.
-36-
Methods:
• InitMenu – adds menu items to the menu according to the
role of the user that logged in, adds child items to some
items, and disables irrelevant items.
• SetMenuItemEnable – enables or disables the menu item
control by name.
• InitLabels – sets the text in the state labels according to
selections.
• RearrangeMenu – redefines which menu items should be
loaded to the menu. This method is called after a user has
logged in, and gives different menu items to different user
roles.
• FillDynamicMenuItems – redefines the contents of the
menu items that should be loaded to the menu. This method
is called after a user has logged in, and depends on the user
role.
• SelectMenuItems – checks all menu items and selects the one whose page was
loaded (therefore saved in SessionData).
• ShowTitle – shows the title of the page that is loaded.
• DisablePartialRendering – a method that enables each page to disable Ajax if
it contains controls that do not support it.
Event handlers:
• Page_Load – fires on page load.
• Menu1_MenuItemClick – fires when a menu item in the menu is clicked.
Properties:
• ErrorLabelsColor – sets the color in which the error labels are displayed.
• ErrorLabelText1 – sets the text that is shown in ErrorLabel1.
• ErrorLabelText2 – sets the text that is shown in ErrorLabel2.
-37-
SessionData class:
• Implementing file: SessionData.cs
This class has the same role as the one in PL1. The difference is in the fields that are
stored inside.
Methods:
• GetInstance (static) – accesses the SessionState object and
returns the SessionData object stored inside it. In case the
SessionData object does not exist, creates the object.
Properties:
• DestinationPage – in login, stores the destination page
after redirection to login page.
• SelectedStaticMenuItem – the menu item clicked that is
marked as selected.
• MenuItems – the items that are added to the menu items
list programmatically (depending on the user's role).
• UserLogin – contains an instance of the user that logged in
to the system or null if none did.
• RoleLogin – contains the name of the role of the user that
logged in to the system or null if none did.
• CurrentSemester – contains the current semester defined
by administrator.
• SelectedSemester – the semester selected by the user or
default.
• SelectedCourse – the course selected by the user or
default.
• SelectedExperiment – the experiment selected by the user
or default.
• UserSemesters – a list of all the semesters a user has
access to.
• DispSemesters – a list of all the semesters a user can see in
the menu (depending on selections).
-38-
• UserCourses – a list of all the courses a user has access to.
• DispCourses – a list of all the courses a user can see in the menu (depending on
selections).
• UserExperiments – a list of all the experiments a user has access to.
• DispExperiments – a list of all the experiments a user can see in the menu
(depending on selections).
• UserAccountsParam[1-4] – parameters shared by UserAccounts page and its
child user controls.
• StudentAccountsParam[1-4] – parameters shared by StudentAccounts page
and its child user control.
• SchedulesUserParam[1-7] – parameters shared by SchedulesUser page and its
child user controls.
• SemestersParam1 – parameter shared by Semester page and its child user
control.
• CoursesParam1 – parameter shared by Courses page and its child user control.
• ExperimentsParam1 – parameter shared by Experiments page and its child
user control.
• InformationUserParam1 – parameter shared by Information page and its child
user control.
• ReportPrintableParam1 – parameter shared by ReportUser page and its child
user control.
_Default class (Page):
• Implementing files: Default.aspx, Default.aspx.cs
• Master page used: MasterPage2
• User controls used: none
This class implements an empty contents page, which is also the default page (the
page that is loaded when the address that is written in the browser contains only the
domain of the site without any page).
Event handlers:
• Page_Load – fires on page load.
-39-
LoginPageUser class (Page):
• Implementing files: LoginPageUser.aspx, LoginPageUser.aspx.cs
• Master page used: MasterPage2
• User controls used: UserCtrlUserLogin (declaratively)
This page enables the course staff to log in to the system.
Event handlers:
• Page_Load – fires on page load.
UserCtrlUserLogin class (UserControl):
• Implementing files: UserCtrlUserLogin.ascx, UserCtrlUserLogin.ascx.cs
This user control implements the logic of the LoginPageUser page.
The user control displays user name and password fields and a choice of which role
the user will log in as. It is responsible of validating the user's password and if the
password is correct to log him in. If the user forgot his password there is an option to
reset it, and then the new password is sent to the user's email account.
Methods:
• CheckPassword – checks if the password entered is
correct.
• InitParameters – initializes parameters of the
UserAccounts page.
Event handlers:
• Page_Load – fires on page load.
• SubmitButton_Click – fires when SubmitButton is clicked.
• ResetButton_Click – fires when ResetButton is clicked.
Semesters class (Page):
• Implementing files: Semesters.aspx, Semesters.aspx.cs
• Master page used: MasterPage2
• User controls used: UserCtrlSemesters (declaratively)
This page enables the user to add, delete or edit semesters.
-40-
Event handlers:
• Page_Load – fires on page load.
UserCtrlSemesters class (UserControl):
• Implementing files: UserCtrlSemesters.ascx, UserCtrlSemesters.ascx.cs
This user control implements the logic of the Semesters page.
The user control displays a gridview containing all the semesters. The gridview
enables the user to edit or delete each row separately. Adding a new row is done by
manipulating the gridview to display an extra row and changing its link buttons in that
row.
Methods:
• BindData – performs the operations related to displaying
the gridview.
• SetLinkText – modifies the gridview's link buttons to
enable new line adding and hide unnecessary links.
• ReadInputs – finds textboxes or dropdownlists and reads
their inputs.
• SelectIndeces – sets the selected item of each dropdownlist
to the corresponding field of the semester.
• GetTable – gets a datatable containing the semesters.
Event handlers:
• Page_Load – fires on page load.
• GridView1_RowEditing – fires when a row's Edit button is clicked.
• GridView1_RowCancelingEdit – fires when the Cancel button of a row in edit
mode is clicked.
• GridView1_RowUpdating – fires when a row's Update button is clicked.
• GridView1_RowDeleting – fires when a row's Delete button is clicked.
Courses class (Page):
• Implementing files: Courses.aspx, Courses.aspx.cs
• Master page used: MasterPage2
-41-
• User controls used: UserCtrlCourses (declaratively)
This page enables the user to add, delete or edit courses.
Event handlers:
• Page_Load – fires on page load.
UserCtrlCourses class (UserControl):
• Implementing files: UserCtrlCourses.ascx, UserCtrlCourses.ascx.cs
This user control implements the logic of the Courses page.
The user control is implemented in a similar way that the UserCtrlSemesters is
implemented. However, there is a logical difference – the page can display two
different things. If the SelectedSemester property in the SessionData object is null,
this user control display all courses. Otherwise, it displays only the courses given in
the selected semester. There is a difference in the controls that are displayed – in a
semester context the edit control does not appear, and in the add course row there are
drop down lists displaying only courses that are already created instead of textboxes.
Methods:
• BindData, SetLinkText, ReadInputs, GetTable – exactly
as in UserCtrlSemesters.
• SetSemesterControls – replaces the controls shown
outside semester context to those inside semester context
and fill them with the appropriate contents.
Event handlers:
• Page_Load – fires on page load.
• GridView1_RowEditing – fires when a row's Edit button
is clicked.
• GridView1_RowCancelingEdit – fires when the Cancel
button of a row in edit mode is clicked.
• GridView1_RowUpdating – fires when a row's Update button is clicked.
• GridView1_RowDeleting – fires when a row's Delete button is clicked.
• DropDownList1_SelectedIndexChanged – fires when the selected item in
DropDownList1 is changed. Keeps both drop down lists in same index.
-42-
Experiments class (Page):
• Implementing files: Experiments.aspx, Experiments.aspx.cs
• Master page used: MasterPage2
• User controls used: UserCtrlExperiments (declaratively)
This page enables the user to add, delete or edit experiments.
Event handlers:
• Page_Load – fires on page load.
UserCtrlExperiments class (UserControl):
• Implementing files: UserCtrlExperiments.ascx, UserCtrlExperiments.ascx.cs
This user control implements the logic of the Experiments page.
The user control is implemented in a similar way that the UserCtrlCourses is
implemented.
Methods:
• BindData, SetLinkText, ReadInputs, GetTable,
SetSemesterControls – exactly as in UserCtrlCourses.
Event handlers:
• Page_Load – fires on page load.
• GridView1_RowEditing – fires when a row's Edit button
is clicked.
• GridView1_RowCancelingEdit – fires when the Cancel
button of a row in edit mode is clicked.
• GridView1_RowUpdating – fires when a row's Update
button is clicked.
• GridView1_RowDeleting – fires when a row's Delete button is clicked.
InformationUser class (Page):
• Implementing files: InformationUser.aspx, InformationUser.aspx.cs
• Master page used: MasterPage2
-43-
• User controls used: UserCtrlInformationUser (declaratively)
This page enables the user to display a rich text information page for the students.
Event handlers:
• Page_Load – fires on page load.
UserCtrlInformationUser class (UserControl):
• Implementing files: UserCtrlInformationUser.ascx,
UserCtrlInformationUser.ascx.cs
This user control implements the logic of the InformationUser page.
The implementation of the user control is based on an external rich text editor control,
named (surprisingly) Rich Text Editor (or RTE). The control is given as a DLL inside
the bin directory, and its methods and properties can be accessed after referencing it
and declaring it in the ascx file. Accessing its Text property renders the html
representation of the formatted text written by the user. After that, the html code can
be saved into the database, or easily displayed using the ASP.NET LiteralControl,
whose input is an html string. The user control disables the Ajax update panel of the
master page in the init method (for this page only), because the RTE control does not
support it.
Event handlers:
• Page_Load – fires on page load.
• Page_Init – fires on page init.
• Button1_Click – fires when Button1 is clicked. The button
is used to save changes in the experiment's info to the
database.
• Button2_Click – fires when Button2 is clicked. The button
is used to discard changes in the experiment's info and
reload it from database.
• Button3_Click – fires when Button3 is clicked. The button is used to preview
the experiment's info as it will be seen by the students.
• Button4_Click – fires when Button4 is clicked. The button is used to return
from the preview back to the editor.
-44-
SchedulesUser class (Page):
• Implementing files: SchedulesUser.aspx, SchedulesUser.aspx.cs
• Master page used: MasterPage2
• User controls used: UserCtrlSchedulesUser, UserCtrlScheduleDetails,
UserCtrlDateTimePicker (programmatically)
This page shows all the schedules of a given experiment in a given semester with their
time and place, registered students and instructor. It also allows the user to change
their details or add and remove schedules.
Event handlers:
• Page_Load – fires on page load.
UserCtrlSchedulesUser class (UserControl):
• Implementing files: UserCtrlSchedulesUser.ascx,
UserCtrlSchedulesUser.ascx.cs
This user control shows all the available schedules of an experiment in a semester. It
allows the user to create new schedules for the experiment, or delete and edit existing
schedules. The user control is not always displayed in the page, but loaded
programmatically in the C# code when needed.
Methods:
• LoadTables – loads all the schedules in tables.
• AddExperimentDetails – adds the details of the
experiment schedule to the schedule datatable.
• AddStudentsEnrolled – adds the students that enrolled to
the schedule to the schedule datatable.
• AddFooter – adds a counter of the places left in the
schedule to the schedule datatable.
• FillGridView – fills the schedule gridview with the
datatable contents and defines its colors.
• AddControls – adds the gridview and a button enabling the
student to register or unregister to placeholder.
-45-
Event handlers:
• Page_Load – fires on page load.
• registerButton_Click – fires when one of the register buttons is clicked.
• unregisterButton_Click – fires when one of the unregister buttons is clicked.
• deleteButton_Click – fires when one of the delete buttons is clicked.
• editButton_Click – fires when one of the edit buttons is clicked.
• Button1_Click – fires when Button1 is clicked. It creates a new schedule.
UserCtrlScheduleDetails class (UserControl):
• Implementing files: UserCtrlScheduleDetails.ascx,
UserCtrlScheduleDetails.ascx.cs
This user control shows all the details of a schedule in a table with editable fields. The
user can edit any of the fields independently, and the date & time fields provide a
button to pick from a calendar. The user control is also loaded programmatically and
replaces the previous UserCtrlSchedulesUser.
Methods:
• LoadExistingSchedule – loads existing schedule details
into the displayed controls and session variables.
• PickButton – generic method called by the event handlers
to pick the date and time for any of the schedule properties.
• ClearButton – generic method called by the event handlers
to clear the date and time from any of the schedule
properties.
• GetStudentsTable – gets a datatable with the students
enrolled to the schedule.
• BindDataGridView – performs the operations related to
displaying the gridview.
Event handlers:
• Page_Load – fires on page load.
• Button1_Click – fires when Button1 is clicked. Saves the
changes made on the schedule.
-46-
• Button2_Click – fires when Button2 is clicked. Discards the changes made on
the schedule.
• ButtonP1_Click, ButtonP2_Click, ButtonP3_Click, ButtonP4_Click,
ButtonP5_Click – fires when the corresponding pick button is clicked. Loads
the UserCtrlDateTimePicker user control next to the current one.
• ButtonC1_Click, ButtonC2_Click, ButtonC3_Click, ButtonC4_Click,
ButtonC5_Click – fires when the corresponding clear button is clicked. Clears
the date and time from the field where it was clicked.
• GridView1_RowDeleting – fires when a row's Delete button is clicked.
UserCtrlDateTimePicker class (UserControl):
• Implementing files: UserCtrlDateTimePicker.ascx,
UserCtrlDateTimePicker.ascx.cs
This control displays a calendar and time lists that helps the user to easily pick the
date and time he wants without messing with formats. The user control is loaded
programmatically by UserCtrlScheduleDetails and appears next to it.
Methods:
• GetPickedDatetime – gets the selected date from the
calendar and the selected time from the drop down list.
Event handlers:
• Page_Load – fires on page load.
• Selection_Change – fires when the selection of either the
calendar or any drop down list is changed.
GradesUser class (Page):
• Implementing files: GradesUser.aspx, GradesUser.aspx.cs
• Master page used: MasterPage2
• User controls used: UserCtrlGradesUser (declaratively)
This page shows a list of all the students registered to a given experiment in a given
semester and their grade in that experiment. It allows the user to change that grade.
Event handlers:
-47-
• Page_Load – fires on page load.
UserCtrlGradesUser class (UserControl):
• Implementing files: UserCtrlGradesUser.ascx, UserCtrlGradesUser.ascx.cs
This user control implements the logic of the GradesUser page.
The user control displays a gridview containing all the students registered to the
experiment and their grade. The gridview enables the user to edit the grade in each
row.
Methods:
• BindData – performs the operations related to displaying
the gridview.
• GetStudentsTable – gets a datatable containing the
students enrolled to the selected experiment depending on
the role of the user.
Event handlers:
• Page_Load – fires on page load.
• GridView1_RowEditing – fires when a row's Edit button is clicked.
• GridView1_RowCancelingEdit – fires when the Cancel button of a row in edit
mode is clicked.
• GridView1_RowUpdating – fires when a row's Update button is clicked.
ReportUser class (Page):
• Implementing files: ReportUser.aspx, ReportUser.aspx.cs
• Master page used: MasterPage2
• User controls used: UserCtrlReport (declaratively)
This page is used to display the grades of all students in a course in a given semester.
It concentrates multiple grades of the student and shows the average. The report is
printable and can be exported into an XML format. The page disables the Ajax update
panel of the master page in the init method (for this page only), because the client side
scripts do not work well with it. It contains one print button that sends a printable
version of the table to the printer on client side, and one export button that saves the
-48-
table as an XML file on client side. The print button is an html control (not ASP)
because it is only client side and does not cause a server side event.
Methods:
• GetHeader – creates the header of the report.
Event handlers:
• Page_Load – fires on page load.
• Page_Init – fires on page init.
• ExportButton_Click – fires when ExportButton is clicked.
UserCtrlReport class (UserControl):
• Implementing files: UserCtrlReport.ascx, UserCtrlReport.ascx.cs
This user control implements the logic of the ReportUser page.
The user control displays a gridview containing all the students registered to the
course and their grade.
Methods:
• BindData – performs the operations related to displaying
the gridview.
• GetTable – gets the report datatable.
Event handlers:
• Page_Load – fires on page load.
StudentAccounts class (Page):
• Implementing files: StudentAccounts.aspx, StudentAccounts.aspx.cs
• Master page used: MasterPage2
• User controls used: UserCtrlStudentAccounts (declaratively)
This page shows a list of all the students in the system. The user can search for a
student by I.D, by first name or by last name. He can also delete a student account.
Event handlers:
• Page_Load – fires on page load.
-49-
UserCtrlStudentAccounts class (UserControl):
• Implementing files: UserCtrlStudentAccounts.ascx,
UserCtrlStudentAccounts.ascx.cs
This user control implements the logic of the StudentAccounts page.
The user control displays a table containing all the students in the system with a radio
button in each row for selection, textboxes to filter the students by fields and a delete
button to delete the selected student if needed.
Methods: • LoadStudents – loads the table of students to the page.
• GetStudents – gets the list of students who meet the
criteria of the search.
• CreateCell – creates the appropriate tablecell according to
given position.
• SetControls – shows the table and the controls related to it.
• FindSelectedIndex – iterates over all the radiobuttons and
finds the selected one.
• CheckTextBoxes – checks all the CheckBoxes and
disables or enables the controls related to it accordingly.
Event handlers:
• Page_Load – fires on page load.
• Button1_Click – fires when Button1 is clicked. The button is used to search the
students by the criteria and return the results.
• Button2_Click – fires when Button2 is clicked. The button is used to delete the
selected student.
• CheckBox1_CheckedChanged – fires when CheckBox1 is checked or unchecked.
• CheckBox2_CheckedChanged – fires when CheckBox2 is checked or unchecked.
• CheckBox3_CheckedChanged – fires when CheckBox3 is checked or unchecked.
UserAccounts class (Page):
• Implementing files: UserAccounts.aspx, UserAccounts.aspx.cs
• Master page used: MasterPage2
-50-
• User controls used: UserCtrlUserAccounts, UserCtrlNewAccount,
UserCtrlAccount, UserCtrlRoles (programmatically)
This page deals with all the aspects of managing the user accounts in the system. The
controls are loaded to the page and dropped programmatically as a response to the
user's input. The first user control shown is UserCtrlUserAccounts that is the main
user control in the page that shows all users and connects to the other user controls.
From the previous control the UserCtrlNewAccount can be accessed, which is used to
create a new user account. To see the details of an existing user account the
UserCtrlAccount and UserCtrlRoles are shown together, the first to see his personal
details and the second to see the roles that the user has in the system.
Event handlers:
• Page_Load – fires on page load.
UserCtrlUserAccounts class (UserControl):
• Implementing files: UserCtrlUserAccounts.ascx, UserCtrlUserAccounts.ascx.cs
This user control shows the user accounts in the system and connects with other user
controls needed in the UserAccounts page. The user control is loaded
programmatically when the page is loaded and displays a table containing all the
users, their details and roles. It also display the following buttons: a button for
creating a new user account (this user control is dropped and UserCtrlNewAccount is
loaded instead), a button for deleing a user (after confirmation), a button for editing
details and roles of a user (this user control is dropped and both UserCtrlAccount,
UserCtrlRoles are loaded), and a button for deactivating or activating an account.
Methods:
• LoadUsers – loads the table of users to the page.
• GetUsers – gets the list of users that are related to the user
that logged in.
• CreateCell – creates the table cell according to position.
• FindSelectedIndex – iterates over all the radio buttons and
finds the selected one.
• SelectIndex – selects the radio button that was last selected
(and saved in session data).
-51-
Event handlers:
• Page_Load – fires on page load.
• Button1_Click – fires when Button1 is clicked. The button is used to load the
new user account control.
• Button2_Click – fires when Button2 is clicked. The button is used to delete the
user account.
• Button3_Click – fires when Button3 is clicked. The button is used to edit the
details of the user account.
• Button4_Click – fires when Button4 is clicked. The button is used to change
the state of the user account between active and non-active.
UserCtrlNewAccount class (UserControl):
• Implementing files: UserCtrlNewAccount.ascx, UserCtrlNewAccount.ascx.cs
This user control displays an empty user account form with the required fields for
creating a new user account. The user control is loaded programmatically as a
response to user's input from UserCtrlUserAccounts. In addition to the details fields it
displays two buttons – one for saving the details into a new account and one for
canceling the operation.
Event handlers:
• Page_Load – fires on page load.
• Button1_Click – fires when Button1 is clicked. The button
is used to create a new user account.
• Button2_Click – fires when Button2 is clicked. The button
is used to return back to the previous user control which
was loaded.
Account class (Page):
• Implementing files: Account.aspx, Account.aspx.cs
• Master page used: MasterPage2
• User controls used: UserCtrlAccount, UserCtrlRoles (declaratively)
This page is used to allow each user to see and change his personal details and his
account's password. He can also see his roles in the system.
-52-
Event handlers:
• Page_Load – fires on page load.
UserCtrlAccount class (UserControl):
• Implementing files: UserCtrlAccount.ascx, UserCtrlAccount.ascx.cs
This user control displays the details of the user. The user control displays two main
boxes. The first box displays fields with the personal details of the user and a button
to save the changes. The second box displays the details of the account and it allows
the user to change his password. If user control is called from UserAccounts page,
then there is a return button that returns back to the calling user control without saving
changes.
Methods:
• FillPersonalDetails – loads the user's personal details to
the page.
• FillUserDetails – loads the user's account details to the
page.
• SetPasswordControls – disables or enables the controls
used for password changing.
Event handlers:
• Page_Load – fires on page load.
• Button1_Click – fires when Button1 is clicked. The button is used to save the
user personal details to the database.
• CheckBox1_CheckedChanged – fires when CheckBox1 is checked or
unchecked. The checkbox is used to disable or enable the controls used for
password changing.
• Button2_Click – fires when Button2 is clicked. The button is used to change
the user's password.
• Button3_Click – fires when Button3 is clicked. The button is visible only when
user control was loaded from UserAccounts.aspx and is used to return to
UserCtrlUserAccounts.ascx.
-53-
UserCtrlRoles class (UserControl):
• Implementing files: UserCtrlRoles.ascx, UserCtrlRoles.ascx.cs
This user control displays the roles of the user. The user control shows all the roles
names and if the user has permissions of the role. If the user control is loaded from
UserAccounts page the roles can be edited, if it is loaded from the Account page they
can only be viewed.
Methods:
• ShowRoles – displays the roles of the user, and for each
role shows where the user is assigned.
• SetControlsAccess – shows, disables or hides the controls
according to the page and the user that logged in.
• AddRoleList – displays the list of the current roles of the
user with the controls to remove them according to the page
and the user that logged in.
Event handlers:
• Page_Load – fires on page load.
• unassignButton_Click – fires when dynamic unassign button is clicked.
• Button1_Click – fires when Button1 is clicked. The button is used to assign the
user to instructor role in the selected course.
• Button2_Click – fires when Button2 is clicked. The button is used to assign the
user to course supervisor role in the selected course.
• Button3_Click – fires when Button3 is clicked. The button is used to assign the
user to administrator role.
• Button4_Click – fires when Button4 is clicked. The button is used to unassign
the user from administrator role.
-54-
Appendix A – Preparing & configuring the application:
The first thing that should be done to make the application work is to prepare the
database. The database should contain 12 tables and 36 stored procedures.
• To create the tables, use the create_tables.sql SQL script.
• To create the stored procedures, use create_stored_procedures.sql script.
• After both tables and stored procedures are created, use fill_roles.sql script to
initialize the Role table.
The next thing is to configure the application itself. The solution is made of two web
application projects: PL1 and PL2. Each project contains an XML configuration file
named Web.config. The file has many tags, but the tags that should be configured by
the user are:
• connectionStrings – this tag contains the data for the application in order to
communicate with the database.
• sessionState – this tag contains configurations of the browser session. It should
contain a property named timeout, which represents the number of minutes from
the time the browser has sent the last request to the server and until the session
automatically ends.
-55-
Appendix B – User Manual:
The application consists of two distinct parts:
• A web application for student's information and registration that is expected to
be on the internet.
• A web application for staff to maintain the first application that is expected to be
on the inner network.
The student's application:
The navigation between the different pages in the application is done using the main
menu, which appears in all pages, and looks like this:
The first item in the menu is Select Course – when selected it expands to a sub menu
that shows all the courses possible for selection. This item can be disabled if the
student was redirected to the address of the site with a query string specifying the
course number (adding to address: ?course=<number>).
The second item in the menu is Select Experiment – when selected it expands to a sub
menu that shows all the experiments possible for selection. The experiments are taken
from the default course or the one selected.
The first two items does not change the page, only the selections that can be seen in
the state box below the menu:
-56-
The remaining items (except Logout) redirect the browser to another page. When a
page is loaded the corresponding item is marked in red.
The Experiment's Information item leads to the Information.aspx page. This page is
accessible without logging in. The page shows details about the experiment that the
course staff wrote in rich text format, for example links.
The Show Schedules item leads to the Schedules.aspx page. This page is accessible
without logging in. The page shows all the dates and times when the experiment is
given.
The Register to Schedules item leads to the Registration.aspx page. This page requires
logging in. The page shows all the dates and times when the experiment is given, and
additionally allows the student to register to the schedule.
The Check Grade item leads to the Grades.aspx page. This page requires logging in.
The page shows the grades of the student in the experiments he registered to.
-57-
The My Details item leads to the StudentDetails.aspx page. This page requires logging
in. The page shows the personal details of the student and enables him to change
them.
The Logout item logs the student out of the system securely.
The staff's application:
This application has 3 levels of permissions:
• Instructor (lowest) – has basic permissions of creating schedules for
experiments, giving grades for the experiment he instructed etc.
• Course supervisor – has full permissions over a specific course: he can do
everything instructor does but can also define experiments, add them to a
semester, create instructor account in the course etc.
• Administrator – has all the permissions: everything the previous levels can do
and more, like create semesters, create courses, create user accounts etc.
Each of the permissions has a different main menu in the page, containing only the
pages he can access.
The main menu for the instructor:
-58-
The first item in the menu is Select Semester – when selected it expands to a sub menu
that shows all the semesters possible for selection. The submenu contains an option
named All Semesters that represents anything global to all semesters.
The second item in the menu is Select Course – when selected it expands to a sub
menu that shows all the courses possible for selection. If All Semesters is selected,
shows all courses. If a semester is selected, shows only courses given in that semester.
The third item in the menu is Select Experiment – when selected it expands to a sub
menu that shows all the experiments possible for selection. The experiments are taken
from the default course or the one selected (again, depending on semester).
The Experiment's Information item leads to the InformationUser.aspx page. The page
shows details about the experiment that the course staff wrote in rich text format, and
the instructor sees exactly what the student sees.
The Schedules item leads to the SchedulesUser.aspx page. The page shows all the
dates and times when the experiment is given, and additionally allows the instructor to
register himself as the instructor of the schedule. He can also delete and edit the
details of a schedule (if no other instructor is registered to it), and create a new one.
When editing the details of a schedule, another control appears where each field of the
followings can be edited: number of places for students' registration, location, date
and time (up to 3, 1 needed), registration start date (optional) and end date (optional).
The Grades item leads to the GradesUser.aspx page. The page shows all the students
registered to the schedules instructed by the instructor, who can edit their grades.
-59-
The My Account item leads to the Account.aspx page. The page shows the details of
the user that can be edited and his roles that can be viewed only.
The main menu for the course supervisor:
Notice that some of the items appear in the instructor menu with their description.
The Courses item leads to the Courses.aspx page. If All Semesters is selected, the item
is disabled (only administrator can create or delete courses). Otherwise, it is enabled
and the course supervisor can add his course to the selected semester or remove it.
The Experiments item leads to the Experiments.aspx page. It allows the user to create
new experiments, delete experiments or edit them. It also allows him to add them to
the semester or remove them from it.
The Experiment's Information item leads to the InformationUser.aspx page. The page
displays a rich text editor for editing the details about the experiment.
-60-
The Schedules item leads to the SchedulesUser.aspx page. This is the same page that
the instructor sees, but with a few differences. The course supervisor can delete and
edit the details of any schedule, but cannot register himself as the instructor of the
schedule. He can also delete students registered to a schedule.
The Report item leads to the ReportUser.aspx page. The page displays a report of the
grades of all students registered to the experiments of a course. It supports printing
decorations, and contains a print button and a button to export it to XML format.
The Instructor Accounts item leads to the UserAccounts.aspx page. The page is used
by the course supervisor to manage the instructor account in the course. He can create
accounts, delete accounts, change details, edit instructor roles and disable accounts.
The main menu for the administrator:
-61-
Notice that some of the items appear in the instructor menu or in the course supervisor
menu with their description.
The Semesters item leads to the Semesters.aspx page. The administrator can add or
remove semesters to the semesters' table, as long he does not repeat semesters or
delete semesters containing data. The administrator can also define the current
semester, which is the only semester that the students see.
The Courses item leads to the Courses.aspx page. If All Semesters is selected, the
administrator can create or delete courses globally. Otherwise, the administrator can
add or remove courses to the selected semester (only courses created globally first).
The User Accounts item leads to the UserAccounts.aspx page. The page is used by the
administrator to manage all types of accounts. He can create accounts, delete
accounts, change details, edit all roles and disable accounts. Before the first
administrator account is created, this page can be loaded without logging in.
The Student Accounts item leads to the StudentAccounts.aspx page. The page can be
used by the administrator to manage students account if necessary. Because of the
possibility for a big number of students, filtering students is enabled.