Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Student projects/Customisable theme.

Student projects/Customisable theme: Difference between revisions

From MoodleDocs
No edit summary
 
(50 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<p class="note">'''Note''': This page outlines ideas for the Blog Improvement / Blog Assignment Type project. It's a ''specification under construction''! If you have any comments or suggestions, please add them to the [[Talk:Student projects/Blog improvements|page comments]].''</p>
<p class="note">'''Note''': This page outlines ideas for the Customisable theme project. It's a ''specification under construction''! If you have any comments or suggestions, please add them to the [[Talk:Student projects/Customisable theme|page comments]].''</p>
 




Line 8: Line 7:


The challenge in the project will be to optimize the balance between the simplicity of the theme interface and the customizability of the theme. Unlike the Chameleon theme, the aim would not be to provide with the opportunity to edit each and every element of the page by editing CSS, but to provide the easy editing of the elements of the page that effect the user the most (like background color, text color and size etc.) through a graphical interface.
The challenge in the project will be to optimize the balance between the simplicity of the theme interface and the customizability of the theme. Unlike the Chameleon theme, the aim would not be to provide with the opportunity to edit each and every element of the page by editing CSS, but to provide the easy editing of the elements of the page that effect the user the most (like background color, text color and size etc.) through a graphical interface.


==Architecture Design==
==Architecture Design==


Like most of the existing Moodle themes, our theme shall also be based on at most three stylesheets utilizing the cascading character of CSS. The first level is that of the existing "Standard" Moodle theme which will keep the theme up to date with the Moodle updates. The second level is that of a parent theme which the user must specify. For the third level, the user may provide his own stylesheets or set values for the CSS elements so that a style sheet is automatically generated.
Like most of the existing Moodle themes, our theme shall also be based on at most three stylesheets utilizing the cascading character of CSS. The first level is that of the existing "Standard" Moodle theme which will keep the theme up to date with the Moodle updates. The second level is that of a parent theme which the user might specify. For the third level, the user may provide his own stylesheets or set values for the CSS elements so that a style sheet is automatically generated or both.


To implement it, we shall select some of the CSS elements that we wish to make customizable by the user. For every user, we will create and store a CSS sheet and the theme shall use that stylesheet along with the CSS sheets of the parent themes specified.
To implement it, we shall select some of the CSS elements that we wish to make customizable by the user. For every user, we will create and store the CSS elements in the database and the theme shall use the values for each user along with the CSS sheets of the parent themes specified (if any).


For backend support we will use a MySQL database that will store the parent theme name for every user and the CSS file created for that user.  
For backend support we will use a MySQL database.


== Milestones in the Project ==
Given below is a brief description of various phases in the project.


== Milestones in the Project ==
*'''''PHASE 1'''''
:Go through the Moodle Code. Identifying the CSS elements in the appearance. Analyze other popular customizable pages like blogger, wordpress and analyze the Moodle themes structure in more detail to select some the the most important CSS elements that will have the most prominent effect in deciding the look of the page.


:Customization of following CSS elements  has been implemented:-
::* Background-Color
::* Sideblock-Color
::* Heading 1 Color
::* Heading 2 Color
::* Heading 3 Color
::* Link Color
::* Link Hover Color
::* Link Visited Color


*''PHASE 1'' - Go through the Moodle Code. Identifying CSS elements in the appearance. Analyze other popular customizable pages like blogger, wordpress and analyze the Moodle themes structure in more detail to select some the the most important CSS elements that will have the most prominent effect in deciding the look of the page. At the end, I shall have clear understanding of the Moodle Code (esp. the theme part). Expected duration - 5 days.


*'''''PHASE 2'''''
:To develop a block with the following features (custom_theme block):-
::* Provide the only means of access to the page to customize theme. The user is presented with the link to the page that allows to customize the theme.
::* Creation of database tables. The database has a field for each of the CSS element that the user wishes to customize and the corresponding id of the user who customized it. The table also has some other fields for more features.
::* Support for a capability to show or hide the block. This capability along with the has_capability() is used to limit who has the access to modify the theme and who does not.




* ''PHASE 2'' - Design the theme prototype using only a few of the CSS elements (like only background color, text color and heading size). At this stage we will not provide the ability of the user to provide his own CSS. This task may be classified into the following subtasks:
: The block has been implemented:
[[Image:Show_block.JPG]]


** ''Phase 2a'' - Designing of a script that shall take values for the CSS elements(eg. #FFFFFF, #FFFFFF, 16px) and the parent theme name (eg. "standardwhite"). It creates a CSS the files corresponding to that user form these values and writes this information to the database. At the end, I should have a script that is able to do the mentioned tasks. Expected duration - 25 days.


** ''Phase 2b'' - Designing of the config.php for the theme, which will specify how the CSS files work together. It will obtain the parent theme to be used for the user from the database (CSS files for the "standardwhite" theme) and the CSS file that has been created for that user (as mentioned in phase 2a). Expected duration - 15 days.
: The database tables are set up. The tables have a field for all the customizable elements that the user can customize and also the id of the user who entered the values (along with some other fields). The database was created using the XMLDB editor. Information about database is stored in upgrade.php and install.xml.
[[Image:Show_database.JPG ]]




: The customtheme: Display capability controls who can see the block (and hence modify the theme). Using the has_capability() function, we can control the access to the block.
[[Image:Show_capabilities.JPG]]


* ''PHASE 3'' - Extend the theme in phase 2 to use all the CSS elements that we wanted to be made customizable (include header text color, font size and other elements identified in phase (1) and also provide the support to select/upload a custom favicon. At this point we will also allow the option of an administrator setting the theme for the site with their particular configuration or allowing users to customize various elements of the theme by manipulating the parameters "allowuserthemes" and "allowcoursethemes".
<pre>
Theme type        Overwrites            Display        Setting type
-------------------------------------------------------------------------------


Site              -                      all pages*     saved in theme profile
*'''''PHASE 3'''''
:Build a basic prototype that gives the user the option to enter values of various CSS elements which are stored in the database (which is created by the custom theme block). The values from the database are then used to style the look of Moodle.


User              Site theme             all pages*    saved in user profile
:The basic prototype of the theme has been implemented. It provides with an interface to enter CSS values for the customizable elements. They are stored in the database (created by the block). Also note that an actual CSS file is never created due to security concerns involved with writing on the system. The values are taken from the database and used directly without actually creating a CSS file (i.e. no extra entry is made in the $THEME->sheets in the config.php of the custom theme. All the values from database are directly dumped into the styles.php of the custom theme).


Course            Site and user themes  one course    saved in course profile
</pre>


*'''''PHASE 4'''''
:Update the basic prototype to allow user with the following features:-
::* Option of user to provide parent theme.
::* Option of user to provide his/her own CSS file.
::* Option of user to choose his/her own favicon for the site.
::* Option of user to choose his/her own Moodle Logo for the site.




* ''PHASE 4'' - We will now allow the user to provide his own CSS files instead of generating a CSS file from values. We might also need to investigate the need for modification of the provided CSS file to suit the standard format that we will use. Expected duration - 20 days
:The form where the user enters values of CSS elements (settings.php) was recreated using formslib.php. It include the above mentioned features as seen in the screenshot:
[[Image:Show_form2.JPG]]




:The way the final page looks after applying the custom_theme is decided by the following hierarchy:
::1) Standard Theme.
::2) Parent theme selected by the user (if any).
::3) CSS file uploaded by the user (if any).
::4) Favicon uploaded supersedes that of parent theme (if any).
::5) Moodle logo uploaded supersedes that of parent theme (if any).
::6) CSS element values entered by the user (if the user selects to use them).


* ''PHASE 5'' - Design of GUI for a seamless transition into Moodle. The GUI will take the parent theme from the user and the option to provide his own CSS or values for the CSS elements. If user provides his own CSS then the created CSS for that user is overwritten. Expected duration - 10 days


:The final page looks like this when the form shown above is saved:
[[Image:Show_change2.JPG]]




* ''PHASE 6'' - Documentation of project. Expected duration - 5 days.
*'''''PHASE 5'''''
:Provide a palette to use and review the color easily. Instead of using the palette used in HTML editors, which creates a popup (that might get blocked) and is also slow, I have implemented palette using Iframe (that gives the effect of instantly loading them).




: This screenshot shows the palette in use:
[[Image:Show_palette.JPG]]


== Progress ==
== Progress ==


Currently I am going through the Moodle Theme CSS and the configuration scripts before I lay out the final plans for the implementation.
This project has been completed. The deliverables that we initially set out with were bifurcated into creating a block (custom_theme) and creating a theme (custom_theme). The list of deliverables we set out with and their status is reported below.
 
The details of the deliverables for the custom_theme block are as follows:-
 
* Create the block as a means of access to the page to customize theme - '''Completed'''.
* Creation of database tables and storing it in \db\update.php & \db\install.xml - '''Completed'''.
* Limit who has the access to the block and who doesn't using capabilities and permissions - '''Completed'''.
 
The details of the deliverables for the custom_theme theme are as follows:-
 
* Create a form using formslib.php where user enters all the values and this page is linked from the custom_theme block - '''Completed'''.
* Allow users to provide their parent theme which goes on top of Moodle Standard Stylesheets - '''Dropped''' (see note below)
* Allow users to provide their own CSS file which goes on top of parent theme (if any) - '''Completed'''.
* Allow users to upload their own Favicon which overrides the favicon of the parent theme - '''Completed'''.
* Allow users to upload their own Moodle logo which overrides the logo of the parent theme (goes in the header and footer of the page) - '''Completed'''.
* Allow users to enter values of various CSS fields in the customize page - '''Completed'''.
* Provide a palette to use and review the color easily - '''Completed'''.
 
 
'''Note''' - The parent theme feature has been included. However, it relies on Moodle cookies to work as it needs information about the currently logged user to extract the parent theme specified by him/her from the database. However, currently all Moodle Themes block cookies by setting $nomoodlecookie as true. Therefore, for the parent theme feature to work, the following line in styles.php of the theme that we have selected as parent must be commented out.
<code php> $nomoodlecookie = true; </code>
When this line is commented out in the style.php the parent theme, the feature works. This is a one-time task and I suggest this line be left out in future theme releases to account for usability of parent theme feature of custom_theme.
 
==Moodle Tracker==


Use the Moodle Tracker to track the progress of the project.
[http://tracker.moodle.org/browse/CONTRIB-516 CONTRIB-516]


==See also==
==See also==


*[[GSOC/2008]]
*[[GSOC/2008]]
*[[theme/custom theme/settings]]


[[Category:Project]]
[[Category:Project]]
[[Category:Themes]]

Latest revision as of 15:44, 18 August 2008

Note: This page outlines ideas for the Customisable theme project. It's a specification under construction! If you have any comments or suggestions, please add them to the page comments.


Summary of Tasks

The objective of this project is creation of a new customizable theme, which gives the Moodle user various options like selecting a logo from the site files and/or uploads their own favicon, customize various CSS elements, selecting a parent theme etc. The main aim of the theme is to simplify the tasks of users who are still not ready to delve into CSS and HTML editing and yet give them the ability to customize the look and feel of Moodle.

The challenge in the project will be to optimize the balance between the simplicity of the theme interface and the customizability of the theme. Unlike the Chameleon theme, the aim would not be to provide with the opportunity to edit each and every element of the page by editing CSS, but to provide the easy editing of the elements of the page that effect the user the most (like background color, text color and size etc.) through a graphical interface.

Architecture Design

Like most of the existing Moodle themes, our theme shall also be based on at most three stylesheets utilizing the cascading character of CSS. The first level is that of the existing "Standard" Moodle theme which will keep the theme up to date with the Moodle updates. The second level is that of a parent theme which the user might specify. For the third level, the user may provide his own stylesheets or set values for the CSS elements so that a style sheet is automatically generated or both.

To implement it, we shall select some of the CSS elements that we wish to make customizable by the user. For every user, we will create and store the CSS elements in the database and the theme shall use the values for each user along with the CSS sheets of the parent themes specified (if any).

For backend support we will use a MySQL database.

Milestones in the Project

Given below is a brief description of various phases in the project.

  • PHASE 1
Go through the Moodle Code. Identifying the CSS elements in the appearance. Analyze other popular customizable pages like blogger, wordpress and analyze the Moodle themes structure in more detail to select some the the most important CSS elements that will have the most prominent effect in deciding the look of the page.
Customization of following CSS elements has been implemented:-
  • Background-Color
  • Sideblock-Color
  • Heading 1 Color
  • Heading 2 Color
  • Heading 3 Color
  • Link Color
  • Link Hover Color
  • Link Visited Color


  • PHASE 2
To develop a block with the following features (custom_theme block):-
  • Provide the only means of access to the page to customize theme. The user is presented with the link to the page that allows to customize the theme.
  • Creation of database tables. The database has a field for each of the CSS element that the user wishes to customize and the corresponding id of the user who customized it. The table also has some other fields for more features.
  • Support for a capability to show or hide the block. This capability along with the has_capability() is used to limit who has the access to modify the theme and who does not.


The block has been implemented:

Show block.JPG


The database tables are set up. The tables have a field for all the customizable elements that the user can customize and also the id of the user who entered the values (along with some other fields). The database was created using the XMLDB editor. Information about database is stored in upgrade.php and install.xml.

Show database.JPG


The customtheme: Display capability controls who can see the block (and hence modify the theme). Using the has_capability() function, we can control the access to the block.

Show capabilities.JPG


  • PHASE 3
Build a basic prototype that gives the user the option to enter values of various CSS elements which are stored in the database (which is created by the custom theme block). The values from the database are then used to style the look of Moodle.
The basic prototype of the theme has been implemented. It provides with an interface to enter CSS values for the customizable elements. They are stored in the database (created by the block). Also note that an actual CSS file is never created due to security concerns involved with writing on the system. The values are taken from the database and used directly without actually creating a CSS file (i.e. no extra entry is made in the $THEME->sheets in the config.php of the custom theme. All the values from database are directly dumped into the styles.php of the custom theme).


  • PHASE 4
Update the basic prototype to allow user with the following features:-
  • Option of user to provide parent theme.
  • Option of user to provide his/her own CSS file.
  • Option of user to choose his/her own favicon for the site.
  • Option of user to choose his/her own Moodle Logo for the site.


The form where the user enters values of CSS elements (settings.php) was recreated using formslib.php. It include the above mentioned features as seen in the screenshot:

Show form2.JPG


The way the final page looks after applying the custom_theme is decided by the following hierarchy:
1) Standard Theme.
2) Parent theme selected by the user (if any).
3) CSS file uploaded by the user (if any).
4) Favicon uploaded supersedes that of parent theme (if any).
5) Moodle logo uploaded supersedes that of parent theme (if any).
6) CSS element values entered by the user (if the user selects to use them).


The final page looks like this when the form shown above is saved:

Show change2.JPG


  • PHASE 5
Provide a palette to use and review the color easily. Instead of using the palette used in HTML editors, which creates a popup (that might get blocked) and is also slow, I have implemented palette using Iframe (that gives the effect of instantly loading them).


This screenshot shows the palette in use:

Show palette.JPG

Progress

This project has been completed. The deliverables that we initially set out with were bifurcated into creating a block (custom_theme) and creating a theme (custom_theme). The list of deliverables we set out with and their status is reported below.

The details of the deliverables for the custom_theme block are as follows:-

  • Create the block as a means of access to the page to customize theme - Completed.
  • Creation of database tables and storing it in \db\update.php & \db\install.xml - Completed.
  • Limit who has the access to the block and who doesn't using capabilities and permissions - Completed.

The details of the deliverables for the custom_theme theme are as follows:-

  • Create a form using formslib.php where user enters all the values and this page is linked from the custom_theme block - Completed.
  • Allow users to provide their parent theme which goes on top of Moodle Standard Stylesheets - Dropped (see note below)
  • Allow users to provide their own CSS file which goes on top of parent theme (if any) - Completed.
  • Allow users to upload their own Favicon which overrides the favicon of the parent theme - Completed.
  • Allow users to upload their own Moodle logo which overrides the logo of the parent theme (goes in the header and footer of the page) - Completed.
  • Allow users to enter values of various CSS fields in the customize page - Completed.
  • Provide a palette to use and review the color easily - Completed.


Note - The parent theme feature has been included. However, it relies on Moodle cookies to work as it needs information about the currently logged user to extract the parent theme specified by him/her from the database. However, currently all Moodle Themes block cookies by setting $nomoodlecookie as true. Therefore, for the parent theme feature to work, the following line in styles.php of the theme that we have selected as parent must be commented out. $nomoodlecookie = true; When this line is commented out in the style.php the parent theme, the feature works. This is a one-time task and I suggest this line be left out in future theme releases to account for usability of parent theme feature of custom_theme.

Moodle Tracker

Use the Moodle Tracker to track the progress of the project. [https://tracker.moodle.org/browse/CONTRIB-516 CONTRIB-516]

See also