Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

How-To Tutorials - Web Development

1802 Articles
article-image-anatomy-wordpress-plugin
Packt
25 Mar 2011
7 min read
Save for later

Anatomy of a WordPress Plugin

Packt
25 Mar 2011
7 min read
  WordPress 3 Plugin Development Essentials Create your own powerful, interactive plugins to extend and add features to your WordPress site         Read more about this book       WordPress is a popular content management system (CMS), most renowned for its use as a blogging / publishing application. According to usage statistics tracker, BuiltWith (http://builtWith.com), WordPress is considered to be the most popular blogging software on the planet—not bad for something that has only been around officially since 2003. Before we develop any substantial plugins of our own, let's take a few moments to look at what other people have done, so we get an idea of what the final product might look like. By this point, you should have a fresh version of WordPress installed and running somewhere for you to play with. It is important that your installation of WordPress is one with which you can tinker. In this article by Brian Bondari and Everett Griffiths, authors of WordPress 3 Plugin Development Essentials, we will purposely break a few things to help see how they work, so please don't try anything in this article on a live production site. Deconstructing an existing plugin: "Hello Dolly" WordPress ships with a simple plugin named "Hello Dolly". Its name is a whimsical take on the programmer's obligatory "Hello, World!", and it is trotted out only for pedantic explanations like the one that follows (unless, of course, you really do want random lyrics by Jerry Herman to grace your administration screens). Activating the plugin Let's activate this plugin so we can have a look at what it does: Browse to your WordPress Dashboard at http://yoursite.com/wp-admin/. Navigate to the Plugins section. Under the Hello Dolly title, click on the Activate link. You should now see a random lyric appear in the top-right portion of the Dashboard. Refresh the page a few times to get the full effect. Examining the hello.php file Now that we've tried out the "Hello Dolly" plugin, let's have a closer look. In your favorite text editor, open up the /wp-content/plugins/hello.php file. Can you identify the following integral parts? The Information Header which describes details about the plugin (author and description). This is contained in a large PHP /* comment */. User-defined functions, such as the hello_dolly() function. The add_action() and/or add_filter() functions, which hook a WordPress event to a user-defined function. It looks pretty simple, right? That's all you need for a plugin: An information header Some user-defined functions add_action() and/or add_filter() functions In your WordPress Dashboard, ensure that the "Hello Dolly" plugin has been activated. If applicable, use your preferred (s)FTP program to connect to your WordPress installation. Using your text editor, temporarily delete the information header from wpcontent/ plugins/hello.php and save the file (you can save the header elsewhere for now). Save the file. Refresh the Plugins page in your browser. You should get a warning from WordPress stating that the plugin does not have a valid header: Ensure that the "Hello Dolly" plugin is active. Open the /wp-content/plugins/hello.php file in your text editor. Immediately before the line that contains function hello_dolly_get_lyric, type in some gibberish text, such as "asdfasdf" and save the file. Reload the plugins page in your browser. This should generate a parse error, something like: pre width="70"> Parse error: syntax error, unexpected T_FUNCTION in /path/to/ wordpress/html/wp-content/plugins/hello.php on line 16 Author: Listed below the plugin name Author URI: Together with "Author", this creates a link to the author's site Description: Main block of text describing the plugin Plugin Name: The displayed name of the plugin Plugin URI: Destination of the "Visit plugin site" link Version: Use this to track your changes over time Now that we've identified the critical component parts, let's examine them in more detail. Information header Don't just skim this section thinking it's a waste of breath on the self-explanatory header fields. Unlike a normal PHP file in which the comments are purely optional, in WordPress plugin and theme files, the Information Header is required! It is this block of text that causes a file to show up on WordPress' radar so that you can activate it or deactivate it. If your plugin is missing a valid information header, you cannot use it! Exercise—breaking the header To reinforce that the information header is an integral part of a plugin, try the following exercise: After you've seen the tragic consequences, put the header information back into the hello.php file. This should make it abundantly clear to you that the information header is absolutely vital for every WordPress plugin. If your plugin has multiple files, the header should be inside the primary file—in this article we use index.php as our primary file, but many plugins use a file named after the plugin name as their primary file. Location, name, and format The header itself is similar in form and function to other content management systems, such as Drupal's module.info files or Joomla's XML module configurations—it offers a way to store additional information about a plugin in a standardized format. The values can be extended, but the most common header values are listed below: For more information about header blocks, see the WordPress codex at: http://codex.wordpress.org/File_Header. In order for a PHP file to show up in WordPress' Plugins menu: The file must have a .php extension. The file must contain the information header somewhere in it (preferably at the beginning). The file must be either in the /wp-content/plugins directory, or in a subdirectory of the plugins directory. It cannot be more deeply nested. Understanding the Includes When you activate a plugin, the name of the file containing the information header is stored in the WordPress database. Each time a page is requested, WordPress goes through a laundry list of PHP files it needs to load, so activating a plugin ensures that your own files are on that list. To help illustrate this concept, let's break WordPress again. Exercise – parse errors Try the following exercise: Yikes! Your site is now broken. Why did this happen? We introduced errors into the plugin's main file (hello.php), so including it caused PHP and WordPress to choke. Delete the gibberish line from the hello.php file and save to return the plugin back to normal. The parse error only occurs if there is an error in an active plugin. Deactivated plugins are not included by WordPress and therefore their code is not parsed. You can try the same exercise after deactivating the plugin and you'll notice that WordPress does not raise any errors. Bonus for the curious In case you're wondering exactly where and how WordPress stores the information about activated plugins, have a look in the database. Using your MySQL client, you can browse the wp_options table or execute the following query: SELECT option_value FROM wp_options WHERE option_name='active_ plugins'; The active plugins are stored as a serialized PHP hash, referencing the file containing the header. The following is an example of what the serialized hash might contain if you had activated a plugin named "Bad Example". You can use PHP's unserialize() function to parse the contents of this string into a PHP variable as in the following script: <?php $active_plugin_str = 'a:1:{i:0;s:27:"bad-example/bad-example. php";}'; print_r( unserialize($active_plugin_str) ); ?> And here's its output: Array ( [0] => bad-example/bad-example.php )
Read more
  • 0
  • 1
  • 33166

article-image-aspnet-4-social-networking-implementing-complete-messaging-system
Packt
25 Mar 2011
12 min read
Save for later

ASP.NET 4 Social Networking: Implementing a Complete Messaging System

Packt
25 Mar 2011
12 min read
Problem A basic messaging system should be able to manage messages, senders and recipients, folders that contain the messages, and email notifications. In our case, we are going to try and keep things simple where it makes sense to do so, but in one area, we will do things in a more complicated way simply because it will result in less wear and tear on the overall system. This is how the messages will be delivered to the users. Rather than following a standard email messaging system where each person gets a physical copy of a message, we are going to build our system in the same way that the MS Exchange server works. We are going to make one copy of a message and subscribe users to that message. So rather than have 50 messages for 50 recipients, we will have one message and 50 recipient subscriptions. The next problem lies in building a WYSIWYG (what you see is what you get) messaging editor. For this feature, there are many open source WYSIWYG editors; we will use one of those to save us a bit of time. We will be using one of the popular editors—X INHA. This editor can be downloaded for free here at http://xinha.webfactional.com/. You may have seen this editor already as it is widely used across many popular community sites. Design Let's take a look at the design of these features. Messages Messages are the core of any messaging system. Generally, a message would contain details like the sender of the message, receiver of the message, and other metadata like time sent, server from where it was sent, etc. and the message, subject, and body. In our case, the message will contain the sender, subject, body, and the data sent. It will also contain one additional field, i.e. the type of message (message, friend request, and so on). We will need to create a page that allows a user to compose a new message (as seen in the image at the start of this article). This interface should also allow a user to add his/her friends easily rather than force them to remember everyone. Also, this interface should allow a user to quickly snap together some HTML without ever having to look at HTML. This can be accomplished with a WYSIWYG editor. Recipients As we have already discussed that we are going to move some of the complexity away from the message, following a subscription model instead, you will find that most of the complexity of this system lies around the recipient concepts. In this case, the recipient subscription is what will be contained in a folder and will have a read status. With this design, we will remove some of the burden from the database. The overhead of doing this of course means that we now need to manage our data closely, as it is kept in many pieces. A more simple design that would result in more copies of data to be managed would be to create one message for each recipient. This is easier as each message can easily be deleted and moved around without having to worry about the copies of that message of the other recipients. Having said that, if the message is quite large, and more importantly if we were to allow file attachments, all the copies of the messages would be identical for each recipient. This would quickly bloat your database! Solution Now let's take a look at our solution. Implementing the database First let's take a look at what tables are needed: Messages A message will primarily be made up of the subject and its body. In addition to that we will need to know what type of message we are sending so that we can do some more fancy things in the UI down the road. In addition to this, we are going to maintain who owns/created the message at this level. There aren't really any major complexities to note here other than the fact that the Body is made up of a varchar(MAX) data type. If you feel this is too large for your system, feel free to make it anything you are comfortable with. The value you eventually use will drive the message for your system. MessageTypes Message Types allows us to assign a type to our messages. This is purely a lookup table that will allow us to know what the types are during queries. We will keep a list of enums in the code to make the lookups easier from that end. MessageRecipients A message recipient is simply the receiving party to the message. But as we try to minimize the data that we manage in our system, the message recipient is also a very important part of the message. In our case, it is the receiving party as well as all the things that the receiving party does with their subscription of that message. We will use this subscription to denote which folder the receiver is keeping the message in, and whether the receiver has read the message or not. Also, if the receiver chooses to delete the message, he/she can just delete the subscription to a message (unless they are the last subscription, in which case we will delete the message as well). The SQL for this subscription is actually quite straightforward. It tracks a relationship to the message, a relationship to the receiver, which folder the subscription is currently in, and the status of the message for this receiver. MessageRecipientTypes The message recipient type allows us to track the receiver of this message addressed in the TO, CC, or BCC fields. Initially, our interface will only have a TO field. We should add this bit of metadata though just in case we want to expand our capabilities down the road! This is another example of a lookup table that we might need to use in the SQL queries. In our case, we will have an enum defined that maintains this lookup for us on the code side. MessageStatusTypes MessageStatusTypes allows us to track what a recipient is doing with his/her copy of the message, whether they have read the message, replied to the message, and so on. This is primarily so that we can change the UI to refiect its status to the recipient. However, we could also create a dashboard down the road for the senders of the messages to know whether their message was read or not and by whom (think of all the big brother things one could do...but probably should not do!). MessageFolders MessageFolders in our first round of implementation will simply hold copies of new messages in the Inbox and copies of sent messages in the Sent folder. We will also have a trash folder and a spam folder. That said, we always wanted to build a system with the future in mind if it doesn't require a lot of extra work, and so we have also baked in the concept of a user being able to create and manage his/her own folders. Therefore, rather than just see the MessageFolders table as another lookup table, you will see that there is an IsSystem fiag to denote which folders are to be seen system-wide. And you will see an AccountID column for custom folders so that we know who owns which folders. Creating the relationships Once all the tables are created, we can create the relationships. For this set of tables, we have relationships between the following tables: Messages and MessageRecipients Messages and Accounts Messages and MessageTypes MessageRecipients and MessageRecipientTypes MessageRecipients and MessageFolders MessageRecipients and MessageStatusTypes Setting up the data access layer The data access layer in this case is very straightforward. Open up your Fisharoo.edmx file and add all of your new message-oriented tables. Once you save this, you should now have a list of new domain objects in your arsenal (see the previous screenshot). Building repositories With these new tables come some additional repositories. We will create the following repositories. MessageRepository MessageRecipientRepository MessageFolderRepository A detailed creation of repositories is out of the scope of this article. We will create a method for selecting a single entity by ID, a group of entities by their parents, saving entities, and deleting entities. Having said that, there are a couple of methods that have something special in the set of repositories. As we are using message subscriptions, we don't necessarily want to delete recipients haphazardly. We may want to delete a recipient, and if that recipient is the last recipient with a subscription to a message, we may also want to delete the message. On the other end of the spectrum, if we do delete a message, we may also want to remove all the recipient subscriptions. In addition to these different ways of deleting data, we will also run into a scenario where selecting a single entity from our repositories won't be quite good enough. So in this case, we have created an aggregate class that will allow us to select several entities at once for use in our inbox scenarios. MessageRepository When we think of a standard inbox, we know that we need to see the messages that we have, who sent them, when they were sent, and at least the subject of their message. In this case, we have discussed two different entities here. When we think about the fact that we also need to know who they were sent to, we have added a third entity. While we could run three separate queries for this data, it would be better for us to run one query (as we would have done in the old days) and return the data that we need in one shot. What do we do? In this case, we need to create an aggregate. This is a class that contains other entities. We will therefore create a MessageWithRecipient class that will contain the sender's account info, the message, and the recipient. This should provide us with enough data to represent messages in our inbox view later. Before we write any queries, we first need to create the aggregate. //Fisharoo/DataAccess/MessageWithRecipient.cs namespace Fisharoo.DataAccess { public class MessageWithRecipient { public Account Sender { get; set; } public Message Message { get; set; } public MessageRecipient MessageRecipient{ get; set; } } } With this aggregate in place we can now turn our attention to the repository that will get all this data for us. //Fisharoo/DataAccess/Repositories/MessageRepository.cs public List<MessageWithRecipient> GetMessagesByAccountID(Int32 AccountID, Int32 PageNumber, MessageFolders Folder) { List<MessageWithRecipient> result = new List<MessageWithRecipient>(); using(FisharooDataContext dc = conn.GetContext()) { IEnumerable<MessageWithRecipient> messages = (from r in dc.MessageRecipients join m in dc.Messages on r.MessageID equals m.MessageID join a in dc.Accounts on m.SentByAccountID equals a.AccountID where r.AccountID == AccountID && r.MessageFolderID == (int)Folder orderby m.CreateDate descending select new MessageWithRecipient() { Sender = a, Message = m, MessageRecipient = r }).Skip((PageNumber - 1)*10).Take(10); result = messages.ToList(); } return result; } This is a fun method! This method involves selecting a list of our MessageWithRecipient aggregate objects. The LINQ query is joining all the tables that we need and selecting a new instance of the MessageWithRecipient aggregate, that is then populated with the three classes that we need in the aggregate. Additionally, we have introduced some paging logic with the .Skip and .Take methods to produce a subset of the MessageWithRecipient objects. In addition to the selection method above, we also need to discuss the delete method for this repository. As we have the data holding a subscription to our message data, it is important that we first remove all the subscriptions prior to removing the message itself. //Fisharoo/DataAccess/Repositories/MessageRepository.cs public void DeleteMessage(Message message) { using (FisharooDataContext dc = conn.GetContext()) { IEnumerable<MessageRecipient> recipients = dc.MessageRecipients .Where(mr => mr.MessageID == message.MessageID); foreach (MessageRecipient mr in recipients) { dc.MessageRecipients.DeleteObject(mr); } dc.Messages.DeleteObject(message); dc.SaveChanges(); } } This is easily accomplished by retrieving all the MessageRecipients for the needed MessageID from the MessageRecipients in DataContext. Once we have the list, we iterate over each recipient and remove it from DataContext's MessageRecipients list. Finally, we delete the message and save changes. MessageRecipientRepository The message recipient repository is considerably easier. It simply has an altered delete statement to adjust for the fact that if we delete the last subscription to a message, it will amount to deleting the message. //Fisharoo/DataAccess/Repositories/MessageRecipientRepository.cs public void DeleteMessageRecipient(MessageRecipient messageRecipient) { using (FisharooDataContext dc = conn.GetContext()) { dc.MessageRecipients.DeleteObject(dc.MessageRecipients.Where (mr=> mr.MessageRecipientID.Equals (messageRecipient.MessageRecipientID)) .FirstOrDefault()); //if the last recipient was deleted //...also delete the message int RemainingRecipientCount = dc.MessageRecipients.Where(mr => mr.MessageID == messageRecipient.MessageID).Count(); if (RemainingRecipientCount == 0) { dc.Messages.DeleteObject(dc.Messages.Where(m => m.MessageID == messageRecipient.MessageID). FirstOrDefault()); } dc.SaveChanges(); } } In this method, we delete the recipient in question. We then get a count of the remaining recipients for the message, which has the last recipient removed. If that count is zero, then there are no more recipients remaining for that message. In that case we perform a delete on that message and remove it from the system as well.
Read more
  • 0
  • 0
  • 4213

article-image-moodle-20-assessing-your-learners-understanding-science
Packt
23 Mar 2011
12 min read
Save for later

Moodle 2.0: Assessing your Learners' Understanding of Science

Packt
23 Mar 2011
12 min read
  Science Teaching with Moodle 2.0 Create interactive lessons and activities in Moodle to enhance your students' understanding and enjoyment of science         Read more about this book       (For more resources on Moodle 2.0, see here.) One of the biggest things to come out of the UK in terms of modern education practice is Assessment for Learning (AfL). This is a phrase coined by Paul Black and Dylan Wiliam in the late 1990s. If this is the first time you have heard the phrase "assessment for learning" then refer to:Inside the Black Box: Raising standards through classroom assessment King's College, London. Black, P.J. & Wiliam, D. (1998).It's a great place to start and a reference you'll regularly go back to, again and again. Assessment for learning Let's begin by looking at what good assessment is; then we'll go through how you can apply this to your Moodle course. Assessment for learning informs you as to what your students have learned, gives an idea what topics, concepts, or areas they find hard and, most importantly, gives you and them an idea of how to improve. Assessment can unfortunately have a negative effect on people. It can make a huge difference when students are involved in their own assessments, but serves very little purpose when it is used by pupils for comparisons or to boost ego. It is important for learners to understand the reasons behind assessment, whether it is to help them understand something, a summative test designed to award a level of competency, or just a quick review so they can see how they are doing. It is vital, however, that all learners can 'do well' in assessments, which may sound contradictory. Progress is much faster for learners who are confident, secure, and happy with trying new ideas. Without that, little learning can happen. This may mean creating different levels of assessment for a particular task so that all pupils can access it. Assessment comes in three main types—teacher/tutor assessment, self assessment, and peer assessment. The latter two will be covered in later articles. The focus of this article will be teacher assessment to provide feedback to students. In the next article, we will be drilling down deeper into the analysis of assessments to inform your teaching. Feedback The most important thing a teacher can provide is to let their students know how they are doing. Moodle is great for this. You could, for instance, create a multiple-choice quiz and give your learners detailed responses for every incorrect answer, even giving them a link to another resource or website that would help them learn from their mistakes. The feedback cycle The feedback cycle is something you could use when creating tasks designed to provide feedback to your students on their learning. The following image shows you the three phases of the feedback cycle: Learning is a continual process of attempting tasks, finding out if you can do them, and then working out what you need to do to get even better. If you want to find out more about the current teaching methodologies in the UK, there are some great videos and good practice at https://www.ssatrust.org.uk/Pages/home.aspx. Using ratings in forums It is important that students get feedback on their work. Without it, they will never know how to improve. This feedback could be from the teacher, by reflection after comparing their work to some criteria, or from their peers. This last reason is why, more often than not, it is useful to include some sort of ratings in the forums you set up, along with comments for improvement. Why use ratings? It can be a good idea initially to force pupils to use the rating systems in forums. To do this, you could set some specific homework, asking them to post their replies to a discussion point. It should require them to read and reply to at least two other posts, providing ratings and written feedback. Interestingly, pupils tend to be very fair and will often do much more than the minimum. It's a good idea to be quite specific when using ratings. For instance, what does 5 out of 5 actually mean? Criterionbased judgments give the learner a much better idea of specifically what needs to be done to improve. These criteria could be agreed on beforehand and form part of your forum introduction. Again, for written comments, it is best to be specific. "Great post" doesn't really help the learner much, apart from a bit of an ego boost. Of course, there are times where you may wish to do this but there is lots of evidence that it doesn't help their understanding of scientific ideas, (see Inside the Black Box: Black, P.J. & Wiliam, D. 1998). You could ask your learners to suggest two things that were really good about the post, and one thing that could be improved. They should phrase the feedback "perhaps next time you could…". A polite suggestion, rather than a criticism that doesn't make the student giving the advice sound bigheaded. It's also good practice to get the person receiving the feedback to say "thank you", as it will encourage the person giving the feedback to do it more often. Aggregate of ratings In forums, there are five ways in which ratings are totaled (or aggregated), described as follows. These can be set by clicking on the edit icon alongside the forum link on the main course page. Average: This is the mean of all the ratings. Count: This gives you the sum of the number of posts. There are not many examples where this might be useful, other than to check that users have contributed a certain number of times. Max: This is the highest rating given for a persons post. Useful when you wish to get your users to display certain levels of competency. Min: It is the lowest rating given for a persons post. Sum: This is all the ratings combined to give a total. It is useful when you want to encourage participation and quality responses.This is different than count, as the total cannot exceed the maximum rating for the forum. In a set up forum(download here -ch:2) we will set the aggregate type and give the rating a scale. The scale chosen here gives a maximum of 5 for each post. Before setting this forum take the time to go through the scale and share a rubric with your learners, which explains what a post must include to be given a 1, or a 2, and so on. It is usually good to show them examples of different posts so they get an idea of what makes a great post that is a 5. Another way you could use ratings is to use a scale to indicate how strongly the reader agrees or disagrees with the post. You could do this by creating a custom grade scale with words to represent the level of agreement. An example of this would be a scale that pupils can award the following values: Agree totally Agree somewhat Neither agree nor disagree Disagree with some points Disagree totally Grade scales There are two standard grade scales in Moodle. One is called Separate and Connected ways of knowing. It has the following choices that you could award for a discussion post: Mostly separate knowing Separate and connected Mostly connected knowing A person who is in the 'mostly separate knowing' category has their opinions based on fact and is very objective. A person who is in the 'mostly connected knowing' category is empathetic and tries to see the other person's point of view. The other standard scale is called Satisfactory and allows users to choose from the following labels: Not satisfactory Satisfactory Outstanding You can set up custom scales, which could be anything; grade letters, levels, or even colors could be awarded to posts to represent de Bono's Thinking Hats. Here is a link if you are not familiar with the concept: http://en.wikipedia.org/wiki/Six_Thinking_Hats. To set up custom scales, click the Grades link in the settings block followed by Scales. Assignments Assignment activities are a nice introduction to getting users submitting more traditional types of work on Moodle. They are very easy to set up and provide the added benefit of organizing all of the submitted work in one place. There are a number of different assessment types that you can set up in Moodle. Some of these involve users submitting a file or files online, or even offline. There are: Online text Upload a single file Advanced uploading of files Offline Think of an assignment in the same way you would have students hand in or e-mail you a piece of written work. Online text The online text assignment allows you to set up an assignment where your users are required to type or copy and paste their work directly into the browser. The really useful thing about online text assignments is that you can choose to be able to comment on their work inline. This means that you will be able to give them feedback that they can use to improve their work and resubmit it. However, if students are typing more than a paragraph of text there is the chance that the web page might timeout, so they would lose their work. Like grading forums, you can also specify how many marks the assignment is worth, or specify a particular scale that the work will be judged against. A lot of the time a simple scale can be used to assess the piece of work, for instance unsatisfactory, satisfactory or outstanding. This would be paired with some detailed feedback for improvement. The assignment that is going to be set up here will be for the third topic "movement in and out of cells". To add an online text activity, choose it from the Add an activity drop-down menu. This activity would be a lead up to an experiment investigating how osmosis acts on pieces of potato in sugar solutions. The aim here is to get your users to justify their predictions. You can follow these same steps to set up any activity in Moodle. As with all things in Moodle it needs a name and description. Set the activity available for one week although users will not be prevented from handing it in late. Use the Satisfactory scale for grading and allow resubmitting with comments inline. It's also nice to set the e-mail alerts to teachers to yes so that you will get an e-mail when a new piece of work is submitted. For this to work properly, you must remember to add yourself to the course as a teacher and also add yourself to a group. Here are the assignment settings. The other settings can be left as standard: As a teacher, if you click the link View submitted assignments at the top-right-hand side of the activity, you'll be taken to the screen where you can grade and comment on the work. It should look a little like the following image. You can also download all assignments as a ZIP file. Upload a single file The 'upload a single file' activity, as the name suggests, is an assignment where you require the user to upload a single file. This file can be nearly any format (as long as it doesn't pose a threat to the server). Let's take an example of how you can use this activity type in a very standard way. Later, you will learn to do this more creatively using the 'advanced uploading of files' activity. Here are the settings that you could choose if you are asking your users to keep a food diary and submit it as an assignment. This is something that you would not give a grade for, just some written feedback. Again, the common module settings will be left on the default settings. Advanced uploading of files With this activity, you are able to specify a maximum number of upload files and there is a button labeled Send for marking that allows students to let you know when work is ready for marking. You can also set up draft and submission stages and it is the only assignment type where teachers can send back a file (for example, a Word document) as a response to the student. If you are a fan of getting pupils to use their cell phones in science lessons, you could get them to video their experiments or take photos to include in lab reports. Given next are the settings to use for a video assignment: Offline activity The offline activity is really useful if you want to keep records of class work or assessments on Moodle. The set up is very similar to the other activity types, but allows you to input a series of grades using any of the different scales. So rather than keeping grades from bookwork or tests in a separate spreadsheet or mark book they can be stored in the gradebook in Moodle. This means that your students can refer to them at any time and like the other types of activity the users are notified by e-mail of any grade or comments that you give them. For any assignment that you give, it is important to remember to let your students know what the marking criteria is that they are working towards. Students need to know what is good work, so you could even show exemplar work from last year as a resource that they would look at before attempting your assignment.
Read more
  • 0
  • 0
  • 1972

article-image-plug-ins-and-dynamic-actions-oracle-application-express-and-ext-js
Packt
22 Mar 2011
7 min read
Save for later

Plug-ins and Dynamic Actions with Oracle Application Express and Ext JS

Packt
22 Mar 2011
7 min read
Oracle Application Express 4.0 with Ext JS Deliver rich desktop-styled Oracle APEX applications using the powerful Ext JS JavaScript library Plug-ins and dynamic actions are the two most exciting new features for developers in APEX 4.0. Combining them with Ext JS components is a recipe for success. For the first time we now have the ability to add custom "widgets" directly into APEX that can be used declaratively in the same way as native APEX components. Plug-ins and dynamic actions are supported with back end integration, allowing developers to make use of APEX provided PL/SQL APIs to simplify component development. Plug-ins give developers a supported mechanism to enhance the existing built-in functionality by writing custom PL/SQL components for item types, regions, and processes. Dynamic actions provide developers with a way to define client-side behavior declaratively without needing to know JavaScript. Using a simple wizard, developers can select a page item and a condition, enter a value, and select an action (for example, Show, Hide, Enable, and Show Item Row). Most APEX developers come from a database development background. So, they are much more comfortable coding with PL/SQL than JavaScript. The sooner work is focused on PL/SQL development the more productive APEX developers become. The ability to create plug-ins that can be used declaratively means developers don't have to write page-specific JavaScript for items on a page, or use messy "hacks" to attach additional JavaScript functionality to standard APEX items. Ext JS provides a rich library of sophisticated JavaScript components just waiting to be integrated into APEX using plug-ins. A home for your plug-ins and dynamic actions APEX allows you to create plug-ins for item, region, dynamic action, and process types. Like templates and themes, plug-ins are designed to be shared, so they can be easily exported and imported from one workspace application to another. Plug-ins can also be subscribed, providing a way to easily share and update common attributes between plug-ins. Building a better Number Field APEX 4.0 introduced the Number Field as a new item type, allowing you to configure number-range checks by optionally specifying minimum and maximum value attributes. It also automatically checks that the entered value is a number, and performs NOT NULL validation as well. You can also specify a format mask for the number as well, presumably to enforce decimal places. This all sounds great, and it does work as described, but only after you have submitted the page for processing on the server. The following screenshot shows the APEX and Ext versions of the Number Field, both setup with a valid number range of 1 to 10,000. The APEX version allows you to enter any characters you want, including letters. The Ext version automatically filters the keys pressed to only accept numbers, conditionally the decimal separator, and the negative sign. It also highlights invalid values when you go outside the valid number range. We are going to build a better Number Field using APEX plug-ins to provide better functionality on the client side, and still maintain the same level of server-side validation. The Number Field is quite a simple example, allowing us to be introduced to how APEX plug-ins work without getting bogged down in the details. The process of building a plug-in requires the following: Creating a plug-in in your application workspace Creating a test page containing your plug-in and necessary extras to test it Running your application to test functionality Repeating the build/test cycle, progressively adding more features until satisfied with the result Creating a plug-in item For our Number Field, we will be creating an item plug-in. So, navigate to the plug-ins page in Application Builder, found under Application Builder | Application xxx | Shared Components | Plug-ins, and press Create to open the Plug-in Create/Edit page. Start filling in the following fields: Name: Ext.form.NumberField. Here, I'm using the Ext naming for the widget, but that's just for a convenience. Internal Name: Oracle's recommendation here is to use your organization's domain name as a prefix. So for example, a company domain of mycompany. com would prefix a plug-in named Slider, would result in an internal name of COM.MYCOMPANY.SLIDER. File Prefix: As we are referencing the Ext JavaScript libraries in our page template, we can skip this field completely. For specialized plug-ins that are only used on a handful of specific pages, you would attach a JavaScript file here. Source: For the PL/SQL source code required to implement our plug-in, you can either enter it as a PL/SQL anonymous block of code that contains functions for rendering, validating and AJAX callbacks, or refer to code in a PL/SQL package in the database. You get better performance using PL/SQL packages in the database, so that's the smart way to go. Simply include your package function names in the Callbacks section, as shown in the following screenshot, noting that no AJAX function name is specified as no AJAX functionality is required for this plug-in. The package doesn't need to exist at this time—the form will submit successfully anyway. Standard attributes: In addition to being able to create up to ten custom attributes, the APEX team has made the standard attributes available for plug-ins to use. This is really useful, because the standard attributes comprise elements that are useful for most components, such as width and height. They also have items such as List of Values (LOV), which have more complicated validation rules already built-in, checking SQL queries used for the LOV source are valid queries, and so on. For the Number Field, only a few attributes have been checked: IsVisible Widget: Indicating the element will be displayed Session State Changeable: So that APEX knows to store the value of the item in session state Has Read Only Attribute: So that conditional logic can be used to make the item read only Has Width Attributes: Allowing the width of the item to be set Notice that some of the attributes are disabled in the following screenshot. This is because the APEX Builder conditionally enables the checkboxes that are dependent on another attribute. So, in this screenshot the List of Values Required, Has LOV Display Null Attributes, and Has Cascading LOV Attributes checkboxes are disabled, because they are dependant on the Has List of Values checkbox. Once it is checked, the other checkboxes are enabled. Custom attributes: Defining the custom attributes for our Number Field is largely an exercise in reviewing the configuration options available in the documentation for Ext.form.NumberField, and deciding which options are most useful to be included. You need to also take into account that some configuration options are already included when you define an APEX item using your plug-in. For example, Item Label is included with an APEX item, but is rendered separately from the item, so don't need to be included. Likewise Value Required is a validation rule, and is also separate when rendering the APEX item. The following next screenshot shows some Ext.form.NumberField configuration options, overlaid with the custom attributes defined in APEX for the plug-in: I've chosen not to include the allowBlank config option as a custom attribute, simply because this can be determined by the APEX Value Required property. Other Configuration options, such as allowDecimals and allowNegative, are included as custom attributes as Yes/No types. The custom attributes created are listed in the following table: Custom events: Custom events are used to define JavaScript event that can be exposed to dynamic actions. For this simple plug-in, there is no need to define any custom events. At this point, we are done defining the Number Field in APEX; it's time to turn our attention to building the database package to execute the Callbacks to render and validate the plug-in.
Read more
  • 0
  • 0
  • 2771

article-image-moodle-19-working-tree-diagrams
Packt
21 Mar 2011
5 min read
Save for later

Moodle 1.9: Working with Tree Diagrams

Packt
21 Mar 2011
5 min read
  Moodle 1.9: The English Teacher's Cookbook 80 simple but incredibly effective recipes for teaching reading comprehension, writing, and composing using Moodle 1.9 Creating a tree diagram using Microsoft Word A tree diagram is used to compare two different situations, topics, persons, or ideas in the same category. As opposed to a Venn diagram, in a tree diagram there are no similarities, so we are going to try to deal with two different topics to explore as many differences as possible. We can work with vocabulary, adjectives, and linking devices. A suitable piece of writing in this case would be an essay or article expressing the different views. As regards the drawing of the tree diagram, it may be either horizontal or vertical, so we are going to carry out both of them. Let's get ready to work! Getting ready We are going to draw a tree diagram about two different cultures and create two links to websites so that students can finish the diagrams. In this case, we are going to design them using Microsoft Word, but you are free to choose any other editor. In this recipe, we will be dealing with two countries whose customs are totally different—Egypt and Greenland. How to do it... You will be designing the tree diagram in Microsoft Word and comparing several aspects of both countries. The students are to complete the information provided by the websites from where they are to take the information. Therefore, in the following activity we are going to design a reading comprehension activity, a prewriting activity, and a writing one. Open Microsoft Word and follow these steps: Click on Insert and choose SmartArt, then choose Hierarchy, and select Horizontal Hierarchy, as shown in the next screenshot: Insert two diagrams, one for Egypt and another one for Greenland, as shown in the following screenshot: Save the file. How it works... We are going to create a writing activity in our Moodle course, so select the Weekly outline section where you want to place it. We will design it through an Essay within a Quiz, so these are the steps that you have to follow: Click on Add an activity and select Advanced uploading of files. Complete the Assignment name block. Complete the Description block and create links to the two websites, one about Greenland and another one about Egypt. Insert a link for the tree diagram file. Click on Save and return to course. The activity appears as shown in the next screenshot: Pictures in a tree diagram—creating a tree diagram using creately.com We are going to create a tree diagram using images instead of words. Students are free to combine the pictures in their future writing, though we have to be very careful in choosing the right pictures. In this case, we are going to use the following website: http://creately.com, which is an excellent resource from our wonderful Web 2.0. Getting ready We are going to enter the website that we have mentioned before and we are going to sign in. Afterwards, we are going to choose a template to work with. In this case, we can select Decision Tree 1 or Blank Diagram to create it ourselves. Here I have decided to work with the first mentioned template. How to do it... These are the steps that you have to follow in order to create the tree diagram with images using the http://creately.com website: Write a name for the document in the Document Name block. Choose the template that you want to work with, as shown in the next screenshot: Click on Create document. Drag and drop the images on the left-hand side and complete the diagram with pictures. Save the diagram. How it works... After virtually drawing the diagram, we are going to get into our Moodle course and choose the Weekly outline section where we want to place the activity. In this case, we are going to create a Forum activity in which students can choose a title for this story, that is to say they are going to brainstorm using this diagram. These are the steps that you have to follow: Click on Add an activity and select Forum. Complete the Forum name and Forum introduction. Go back to the website of the tree diagram and click on Embed image, as shown in the next screenshot: Click on Select and Copy, as shown in the next screenshot: Go back to the Moodle course and click on the Toggle HTML Source icon and paste the embedding code. Then click on the same icon again. Click on Save and return to course. The activity appears as shown in the next screenshot: There's more... You can also design a writing activity since the prewriting process was carried out by the Forum activity. Students brainstormed among themselves and gathered a lot of data in order to write a story. Designing a writing activity out of the tree diagram You can create an Upload a single file activity or an Offline one in which students write what they have discussed in the Forum. They may have written the story while discussing, but that is the first part of the process of writing. So the final draft is what you are going to design here.
Read more
  • 0
  • 0
  • 4800

article-image-joomla-16-managing-site-users-access-control
Packt
17 Mar 2011
9 min read
Save for later

Joomla! 1.6: Managing Site Users with Access Control

Packt
17 Mar 2011
9 min read
Joomla! 1.6 First Look A concise guide to everything that's new in Joomla! 1.6.     What's new about the Access Control Levels system? In Joomla! 1.5, a fixed set of user groups was available, ranging from "Public" users (anyone with access to the frontend of the site) to "Super Administrators", allowed to log in to the backend and do anything. The ACL system in Joomla! 1.6 is much more flexible: Instead of fixed user groups with fixed sets of permissions, you can create as many groups as you want and grant the people in those groups any combination of permissions. ACL enables you to control anything users can do on the site: log in, create, edit, delete, publish, unpublish, trash, archive, manage, or administer things. Users are no longer limited to only one group: a user can belong to different groups at the same time. This allows you to give particular users both the set of permissions for one group and another group without having to create a third, combined set of permissions from the ground up. Permissions no longer apply to the whole site as they did in Joomla! 1.5. You can now set permissions for specific parts of the site. Permissions apply to either the whole site, or to specific components, categories, or items (such as a single article). What are the default user groups and permissions? The flexibility of the new ACL system has a downside: it can also get quite complex. The power to create as many user groups as you like, each with very fine-grained sets of permissions assigned to them, means you can easily get entangled in a web of user groups, Joomla! Objects, and permissions. You should carefully plan the combinations of permissions you need to assign to different user groups. Before you change anything in Joomla!, sketch an outline or use mind mapping tools (such as http://bubbl.us) to get an overview of what you want to accomplish through Joomla! ACL: who (which users) should be able to see or do what in which parts of the site? In many cases, you might not need to go beyond the default setup and just use the default users groups and permissions that are already present when you install Joomla! 1.6. So, before we go and find out how you can craft custom user groups and their distinctive sets of permissions, let's have a look at the default Joomla! 1.6 ACL setup. The default site-wide settings In broad terms, the default groups and permissions present in Joomla! 1.6 are much like the ACL system that was available in Joomla! 1.5. To view the default groups and their permissions, go to Site | Global Configuration | Permissions. The Permission Settings screen is displayed, showing a list of User Groups. A user group is a collection of users sharing the same permissions, such as Public, Manager, or Administrator. By default the permission settings of the Public user group are shown; clicking any of the other user group names reveals the settings for that particular group. On the right-hand side of the Permission Settings screen, the generic (site-wide) action permissions for this group are displayed: Site Login, Admin Login, and so on. Actions are the things users are allowed do on the site. For the sample user groups, these action permissions have already been set. Default user groups Let's find out what these default user groups are about. We'll discuss the user groups from the most basic level (Public) to the most powerful (Super Users). Public – the guest group This is the most basic level; anyone visiting your site is considered part of the Public group. Members of the Public group can view the frontend of the site, but they don't have any special permissions. Registered – the user group that can log in Registered users are regular site visitors, except for the fact that they are allowed to log in to the frontend of the site. After they have logged in with their account details, they can view content that may be hidden from ordinary site visitors because the Access level of that content has been set to Registered. This way, Registered users can be presented all kinds of content ordinary (Public) users can't see. Registered users, however, can't contribute content. They're part of the user community, not web team. Author, Editor, Publisher – the frontend content team Authors, Editors, and Publishers are allowed to log in to the frontend, to edit or add articles. There are three types of frontend content contributors, each with their specific permission levels: Authors can create new content for approval by a Publisher or someone higher in rank. They can edit their own articles, but can't edit existing articles created by others. Editors can create new articles and edit existing articles. A Publisher or higher must approve their submissions. Publishers can create, edit, and publish, unpublish, or trash articles in the frontend. They cannot delete content. Manager, Administrator, Super User – the backend administrators Managers, Administrators and Super Users are allowed to log in to the backend to add and manage content and to perform administrative tasks. Managers can do all that Publishers can, but they are also allowed to log in to the backend of the site to create, edit, or delete articles. They can also create and manage categories. They have limited access to administration functions. Administrators can do all that Managers can and have access to more administration functions. They can manage users, edit, or configure extensions and change the site template. They can use manager screens (User Manager, Article Manager, and so on) and can create, delete, edit, and change the state of users, articles, and so on. Super Users can do everything possible in the backend. (In Joomla! 1.5, this user group type was called Super Administrator). When Joomla! is installed, there's always one Super User account created. That's usually the person who builds and customizes the website. In the current example website, you're the Super User. Shop Suppliers and Customers – two sample user groups You'll notice two groups in the Permission Settings screen that we haven't covered yet: Shop Suppliers and Customer. These are added when you install the Joomla! 1.6 sample data. These aren't default user groups; they are used in the sample Fruit Shop site to show how you can create customized groups. Are there also sample users available? As there are user groups present in the sample data, you might expect there are also sample users. This is not the case. There are no (sample) users assigned to the sample user groups. There's just one user available after you've installed Joomla!— you. You can view your details by navigating to Users | User Manager. You're taken to the User Manager: Users screen: Here you can see that your name is Super User, your user name is admin (unless you've changed this yourself when setting up your account), and you're part of the user group called Super Users. There's also a shortcut available to take you to your own basic user settings: click on Site | My Profile or—even faster—just click on the Edit Profile shortcut in the Control Panel. However, you can't manage user permissions here; the purpose of the My Profile screen is only to manage basic user settings. Action Permissions: what users can do We've now seen what types of users are present in the default setup of Joomla! 1.6. The action permissions that you can grant these user groups—things they can do on the site—are shown per user group in the Site | Global Configuration | Permissions screen. Click on any of the user group names to see the permission settings for that group: You'll also find these permissions (such as Site Login, Create, Delete, Edit) on other places in the Joomla! interface: after all, you don't just apply permissions on a site-wide basis (as you could in previous versions of Joomla!), but also on the level of components, categories, or individual items. To allow or deny users to do things, each of the available actions can be set to Allowed or Denied for a specific user group. If the permission for an action isn't explicitly allowed or denied, it is Not Set. Permissions are inherited You don't have to set each and every permission on every level manually: permissions are inherited between groups. That is, a child user group automatically gets the permissions set for its parent. Wait a minute—parents, children, inheritance ... how does that work? To understand these relationships, let's have a look at the overview of user groups in the Permission Settings screen. This shows all available user groups (I've edited this screen image a little to be able to show all the user groups in one column): You'll notice that all user group names are displayed indented, apart from Public. This indicates the permissions hierarchy: Public is the parent group, Manager (indented one position) is a child of Public, Administrator (indented two positions) is a child of Manager. Permissions for a parent group are automatically inherited by all child groups (unless these permissions are explicitly set to Allowed or Denied to "break" the inheritance relationship). In other words: a child group can do anything a parent group can do—and more, as it is a child and therefore has its own specific permissions set. For example, as Authors are children of the Registered group, they inherit the permissions of the Registered group (that is, the permission to log in to the frontend of the site). Apart from that, Authors have their own specific permissions added to the permissions of the Registered group. Setting an action to Denied is very powerful: you can't allow an action for a lower level in the permission hierarchy if it is set to Denied higher up in the hierarchy. So, if an action is set to Denied for a higher group, this action will be inherited all the way down the permissions "tree" and will always be denied for all lower levels—even if you explicitly set the lower level to Allowed.  
Read more
  • 0
  • 0
  • 2741
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at $19.99/month. Cancel anytime
article-image-faq-celtx
Packt
14 Mar 2011
3 min read
Save for later

FAQ on Celtx

Packt
14 Mar 2011
3 min read
Celtx: Open Source Screenwriting Beginner's Guide Write and market Hollywood-perfect movie scripts the free way! Q: What is Celtx? A: Celtx developers describe this software package as "the world's first all-in-one media pre-production system." (http://celtx.com/overview. html) We are told that Celtx: Can be used for the complete production process Lets you write scripts, storyboard scenes, and sketch setups Develop characters, breakdown, and tag elements Schedule productions plus generate useful reports Celtx is powerful software yet simple to use. It can be used in writing the various types of scripts already mentioned, including everything independent filmmakers and media creators of all types need. This includes writing, planning, scheduling, and generating reports during the various stages of all sorts of productions. The following screenshot is an example of a Celtx report screen: Q: What does the acronym, Celtx, stand for? A: The name Celtx is an acronym for Crew, Equipment, Location, Talent, and XML. Q: How far-reaching is the impact of Celtx? A: The Celtx website says that more than 500,000 media creators in 160 countries use Celtx in 33 different languages. Independent filmmakers and studio professionals, and students in over 1,800 universities and film schools have adopted Celtx for teaching and class work submission. Celtx is supported by the Celtx community of volunteer developers and a Canadian company, Greyfirst Corp. in St. John's, Newfoundland. A major reason Celtx can be an open source program is that it is built on non-proprietary standards, such as HTML and XML (basic web mark-up languages) and uses other open source programs (specifically Mozilla's engine, the same used in the Firefox browser) for basic operations. Q: What sets Celtx apart from other free screenwriting software that is available? A: An important concept of Celtx's power is that it's a client-server application. This means only part of Celtx is in that download installed on your computer. The rest is out there in the cloud (the latest buzz term for servers on the Internet). Cloud computing (using remote servers to do part of the work) allows Celtx to have much more sophisticated features, in formatting and collaboration especially, than is normally found in a relatively small free piece of software. It's rather awesome actually. Celtx, by the way, has you covered for PC, Mac, all kinds of Linux, and even eeePC Netbooks. Q: Does Celtx qualify as a web application? A: Celtx is really a web application. We have the advantage of big computers on the web doing stuff for us instead of having to depend on the much more limited resources of our local machine. This also means that improvements in script formats (as final formatting is done out on the web somewhere for you) are yours even if you haven't updated your local software. Q: Can we write movies with Celtx? A: With Celtx we can outline and write an entertainment industry standard feature movie script, short film, or animation—all properly formatted and ready to market. Q: Can we do other audio-visual projects with Celtx? A: Celtx's integral Audio-Visual editor is perfect for documentaries, commercials, public service spots, video tutorials, slide shows, light shows, or just about any other combination of visual and other content (not just sound). Q: Is Celtx equipped for audio plays and podcast? A: Celtx's Audio Play editor makes writing radio or other audio plays a breeze. It's perfect also for radio commercials or spots, and absolutely more than perfect for podcasts. Podcasts are easy to write, require minimal knowledge to produce, and are a snap to put on the Internet.
Read more
  • 0
  • 0
  • 2995

article-image-moodle-19-creating-stories-using-twitter-and-facebook
Packt
11 Mar 2011
6 min read
Save for later

Moodle 1.9: Creating Stories using Twitter and Facebook

Packt
11 Mar 2011
6 min read
        Read more about this book       (For more resources on Moodle, see here.) It is very important to highlight that there exist some education privacy issues in different countries, which teachers have to be aware of before advising students to sign up for social networking. For instance, Family Educational Rights and Privacy Act (FERPA) protects students' rights and privacy. For more information, enter the following website: http://www2.ed.gov/policy/gen/guid/fpco/ferpa/index.html. Introduction In this article, you will learn how to use Web 2.0 to help students interact amongst themselves in the virtual classroom using Twitter and Facebook. In addition, the students will also learn to perform difficult tasks in Moodle 1.9.5. We are going to use Twitter when we need keywords, few facts, and short statements. We are going to use Facebook to get more data, longer sentences, a short paragraph, some pictures, and so on. You will also be able to design several types of Exercises after adding social material to the Moodle course. We are going to include two popular social networks. We are going to incorporate these networks into the Moodle course and we are also going to include different types of methodologies. This is done so that our students have several options to gather ideas for their pieces of writing. We are going to use Facebook and Twitter as resources from Web 2.0. Afterwards, we are also going to design the activities in Wikis and Forums. This allows the students to interact amongst themselves within the Moodle course. In this virtual classroom, we are going to enrich the use of several well-known techniques using popular resources. Instead of sitting around a round table, we are going to ask our students to debate their ideas through Twitter as you will see in the first recipe. We are also going to incorporate management theories into education—for example, Fishbone fact fish or Ishikawa diagram, which is mainly used in business administration. We are going to teach it to our students so that they can create excellent pieces of writing, taking into account cause and effect. We are going to deal with many topics, which may lead to discussion. Therefore, students can start writing argumentative essays without even realizing it. The most important detail is that we hand them the right tools to work with. In that way, they will be using keywords or phrases, which they will gather from Twitter or Facebook and they will create excellent pieces of writing. Let's Moodle it! Debating a topic In this task, we are going to use a methodology that we have already used many times in a debate, though it will be used virtually using resources from Web 2.0. In this recipe, we are going to use Twitter because what we need are simple statements. We are going to ask our students to debate on the following topic: what similarities or differences do they find between The Lord of the Rings, and Chronicles of Narnia. We are going to create a link to a website, which illustrates some differences and similarities. Afterwards, we are to use Twitter, and finally they are going to write their opinion in a Journal in Moodle. So, let's get started! Getting ready We can create an account in Twitter using the name of the subject, activity, or just our name, but let's use the account only to carry out the activities in the Moodle course. Therefore, students can follow the activities and nobody should change the course of the activity. They only have to focus on the activity. How to do it... Enter the Twitter webpage—http://twitter.com—create an account or use the one you have, it's your choice. If you want to create an account, click on Sign up now and complete the required information. Afterwards, you are going to write on what students are going to debate on as shown in the next screenshot: Click on Home. Complete the What's happening? block, as shown in the previous screenshot. Click on Update. The debate activity in Twitter is ready to work with! How it works... We are going to choose the Weekly outline section where we want to add the activity in the Moodle course. Afterwards, we are going to create the rest of the activity in a Journal. Follow these steps: Complete the Journal name block: Debating using Twitter. Complete the Journal question block by writing the instructions that students have to follow in order to carry out the activity, as shown in the screenshot that follows. You will create a link to the Twitter account webpage, where the students are going to debate. Change Days available to 2 weeks, due to the fact that they are debating and it may take more than seven days, as shown in the next screenshot: Later, click on Save and return to course. There's more... Instead of creating a link to the Twitter website, we can include a Twitter button in our Moodle course. Inserting a Twitter button in Moodle It is very simple. In order to add a Twitter button, you have to follow these steps: Go to the website: http://twitterbuttons.org/. Complete the block with your ID, as shown in the next screenshot: Enter your ID and click on GO, as shown in the next screenshot: Select the Twitter button that you like most and click on Select Code, as shown in the next screenshot: If the chosen button is the one on the right-hand side, then right-click and select Copy in the context menu that appears. Go to the Moodle course. Update the Journal activity, and click on the Toggle HTML Source icon, (which looks like this: <>). Paste that code. The button will appear as shown in the next screenshot: Inserting a Twitter button in the HTML block in the Moodle course You can also insert the Twitter button in the HTML block in the Moodle course, following the previous steps instead of inserting it in the activity. The difference is that students can see the Twitter button in the Moodle course, as shown in the next screenshot:
Read more
  • 0
  • 0
  • 1591

article-image-moodle-authentication-methods
Packt
11 Mar 2011
6 min read
Save for later

Moodle: Authentication Methods

Packt
11 Mar 2011
6 min read
Moodle Security Learn how to install and configure Moodle in the most secure way possible Basics of authentication Authentication is the process of confirming that something or someone is really who they claim to be. The ways in which someone may be authenticated fall into three categories, based on what are known as the factors of authentication: Knowledge (something you know): password, PIN code, etc. Ownership (something you have): security token, phone, etc. Inherence (something you are): fingerprint, signature, various biometric identifiers Following the path of most computer systems, Moodle offers basic authentication based on a knowledge factor. This means that in order to operate in Moodle any person must have a user account. A user account consists of a username, password, and other personal information. Both username and password are used to authenticate a person who wishes to access the platform. Based on the outcome of an authentication, a user will be given or declined access to the platform. The authentication is performed (usually) by comparing provided data from the person trying to access the platform with the data located in the Authoritative Data Source (of user identity). Moodle supports 13 different types of authentication and this actually means that it has support for consulting 13 different types of Authoritative Data Sources. An Authoritative Data Source is a recognized or official data production source with a designated mission statement or source/product to publish reliable and accurate data for subsequent use by users or by other computer programs. Logon procedure Logon in Moodle is implemented using a HTML form that submits supplied data over HTTP or HTTPS to the server where it is being processed. Hypertext Transfer Protocol (HTTP) is a networking protocol used for transferring and rendering content on the World Wide Web. HTTP Secure (HTTPS) is a combination of a HTTP protocol and SSL/TLS (Security Socket Layer/ Transport Layer Security) protocol that offers encrypted and thus secures communication and identification between two computers on the Internet. HTTPS connections are often used for payments transactions and other sensitive information's transfer. The user enters his assigned credentials into the supplied fields on the login form and presses Login. That sends data to Moodle for processing. Common authentication attacks Any type of security attack is directed toward potential weak spots in the system that is under attack. The most common weaknesses related to the authentication and ways of protecting from them are as follows: Weak passwords A password that is easily guessed and does not provide an effective defense against unauthorized access to a resource is considered weak. Such passwords are usually: Short Set to dictionary word or name Set to be the same as username Set to some predefined value When we have a platform with weak passwords it can be attacked using brute force login technique (also known as dictionary attack). Dictionary attack is a technique for defeating authentication mechanism by trying to determine its pass-phrase by searching likely possibilities. In practice this means that a bot (automated script) constantly tries to log on by sending various usernames and passwords from a predefined list of words (usually a dictionary list of words—hence the name dictionary attack). Enforcing a good password policy In order to prevent this attack, make sure you have enabled the password policy. Visit Administration | Security | Site policies and locate the Password Policy checkbox. You should arrive at the following screenshot: Password policy is enabled by default starting from Moodle 1.9.7. This applies to both new installs and upgrades. Protecting user login By default, Moodle is configured to use unencrypted HTTP as the main communication protocol between client and server. This is fine for general usage of the platform but it also exposes credential information to the potential eavesdropper who can intercept and read it. This is a common case known as man-in-the-middle attack. The perpetrator makes a separate connection with the client (user's computer) and server (Moodle), forcing all communication to go over his connection. That permits him to look at the entire communication and even inject his own version of messages and responses. Closing the security breach We need to make sure that credential transmission is performed using secure HTTP (HTTPS) because that prevents (or makes it really hard) for anybody to hook into a protected conversation. Here are the steps: Firstly, you should install and configure a valid SSL (Secure Sockets Layer) certificate on your web-server. It is important to do this properly before doing anything else in Moodle; otherwise you might block yourself from accessing the platform. The procedure for installing an SSL certificate is beyond the scope of this book since it involves too many different factors that depend on your server configuration, OS type, and the way you manage it. Please refer to the manual for your particular web server and/or particular procedure of your hosting provider. Valid SSL certificates can be obtained only from certified root authorities—companies with a license for issuing certificates. VeriSign, Thawte, and Comodo are one of the several certificate providers. You need to specify which web server you are using since some of them prefer particular formats. Secondly, you should activate HTTPS log-in in your Moodle. You can do that by going to Administration | Security | HTTP security page and checking Use HTTPS for logins. If everything is configured properly you should see a login page that shows a valid certificate box (see following screenshot) in your browser. This means that a certificate is issued by a valid root authority and that communication between your browser and Moodle is secure which is what we wanted to accomplish in the first place. Every time a user tries to login in Moodle they will be redirected to the secure version of the login page which effectively prevents the interception of user credentials. Password change By default, all newly created users in Moodle (excluding admin) are assigned the Authenticated user role. The authenticated user role by default has permission to change their own password. This feature can be utilized by accessing user profile page. Recover a forgotten password Forgetting a username and/or password is a common situation in which many users find themselves. Moodle offers a procedure for getting a username and resetting the password. The user will be presented with a form where he can enter his username or his e-mail. If the username or email exists in the database, a mail with a reset link will be sent to that user. By clicking on that link, the user is offered a chance to enter a new password. If not configured properly, this feature can be used for determining valid user emails or user-names. See the following screenshot: An attacker would be able to tailor a script that could probe for usernames and, based on the response, can determine valid users.  
Read more
  • 0
  • 0
  • 6760

article-image-modx-web-development-creating-lists
Packt
10 Mar 2011
7 min read
Save for later

MODx Web Development: Creating Lists

Packt
10 Mar 2011
7 min read
Menu details in document properties Every resource that can be shown in a menu must have the Shown in Menu option enabled in the resource's setting page. The Resource setting page also has two other options related to menus: Menu title—what to show in the menu. The resource title is used, if this value is left blank. Menu index—when a list of the resources that are to be listed in the menu is created, the menu index can be used to sort the resources in the required order. Menu index is a number, and when creating lists we can specify how we want to use the index. Authentication and authorization When creating the list of resources, WayFinder lists only those resources that are accessible by the user depending on the access permissions set for each resource, and the web user group to which the user belongs. Getting to know WayFinder WayFinder is a snippet that outputs the structure of the resources as reflected in the resource tree. It creates the lists of all the resources that can be accessed by the current user, from those that been marked as Shown in Menu in the resource properties. Let's try out an exercise to discover WayFinder. Create a new resource. Set the name as testing wayfinder. Choose the template as (blank). Place the following as the content: [[Wayfinder?startId=`0` ]] Save the document, and then preview it. You will see a screen like the one shown in the following screenshot: Notice that WayFinder has created a list of all of the resources, even the ones from the sample site. Each item is a link, so clicking on it leads you to the corresponding document. The generated HTML will look like the following example: <ul><li><a href="http://localhost/learningMODx/" title="Home" >Home</a></li><li><a href="/learningMODx/index.php?id=2" title="Blog" >Blog</a></li><li><a href="/learningMODx/index.php?id=15" title="MODx Features">Features</a><ul><li><a href="/learningMODx/index.php?id=16"title="Ajax" >Ajax</a></li><li><a href="/learningMODx/index.php?id=22" title="Menus and Lists">Menus and Lists</a></li><li><a href="/learningMODx/index.php?id=14" title="Content Management">Manage Content</a></li><li class="last"><a href="/learningMODx/index.php?id=24"title="Extendable by design" >Extendability</a></li></ul></li><li><a href="/learningMODx/index.php?id=33" title="Getting Help">Getting Help</a></li><li><a href="/learningMODx/index.php?id=32" title="Design" >Design</a></li><li><a href="/learningMODx/index.php?id=53" title="Signup Form">Signup Form</a></li><li><a href="/learningMODx/index.php?id=6" title="Contact Us" >Contactus</a></li><li><a href="/learningMODx/index.php?id=54" title="Getting to knowditto" >Getting to know ditto</a><ul><li><a href="/learningMODx/index.php?id=55" title="Sports RSS" >Sports RSS</a></li><li><a href="/learningMODx/index.php?id=56" title="Lifestyle RSS">Lifestyle RSS</a></li><li class="last"><a href="/learningMODx/index.php?id=57" title="ITRSS" >IT RSS</a></li></ul></li><li class="last active"><a href="/learningMODx/index.php?id=58"title="testing wayfinder" >testing wayfinder</a></li></ul> As seen in the preceding output, the generated list is just a set of <ul> and <li> tags. Let's go step-by-step, in understanding how the preceding output can be customized and themed, starting with menus of one level. Theming To be able to theme the list generated by WayFinder to appear as menus, we need to understand how WayFinder works in more detail. In this section, we will show you step-by-step how to create a simple menu without any sub-items, and then proceed to creating menus with sub-items. Creating a simple menu Since, for now, we only want a menu without any submenu items, we have to show resources only from the top level of the resource tree. By default, WayFinder will reflect the complete structure of the resource tree, including the resources within containers, as seen in the preceding screenshot. WayFinder lets you choose the depth of the list via the &level parameter. The parameter &level takes a value indicating the number of levels that WayFinder should include in the menu. For our example, because we only want a simple menu with no submenu items, &level is set to 1. Now, let us change the testing wayfinder resource, which we just created, to the following code: [[Wayfinder?startId=`0` &level=`1` ]] Preview the resource now, and you will see that the source code of the generated page in place of Wayfinder is: <ul><li><a href="http://localhost/learningMODx/" title="Home" >Home</a></li><li><a href="/learningMODx/index.php?id=2" title="Blog" >Blog</a></li><li><a href="/learningMODx/index.php?id=15" title="MODx Features">Features</a></li><li><a href="/learningMODx/index.php?id=33" title="Getting Help">Getting Help</a></li><li><a href="/learningMODx/index.php?id=32" title="Design" >Design</a></li><li><a href="/learningMODx/index.php?id=53" title="Signup Form">Signup Form</a></li><li><a href="/learningMODx/index.php?id=6" title="Contact Us" >Contactus</a></li><li><a href="/learningMODx/index.php?id=54" title="Getting to knowditto" >Getting to know ditto</a></li><li class="last active"><a href="/learningMODx/index.php?id=58"title="testing wayfinder" >testing wayfinder</a></li></ul> Now, if we can just give <ul> and <li> respective classes, we can style them to appear as a menu. We can do this by passing the class names to the parameter &rowClass. Change the contents of the preceding testing wayfinder to: <div id="menu">[!Wayfinder?startId=`0` &level=`1` &rowClass=`menu`!]</div> Now, open style.css from the root folder, and change the CSS to the following code. What we are doing is styling the preceding generated list to appear like a menu, by using CSS: * { padding:2; margin:0; border:1; }body { margin:0 20px; background:#8CEC81; }#banner { background: #2BB81B; border-top:5px solid #8CEC81; borderbottom:5px solid #8CEC81; }#banner h1 { padding:10px; }#wrapper { background: #8CEC81; }#container { width: 100%; background: #2BB81B; float: left; }#content { background: #ffffff; height:600px; padding:0 10px 10px10px; clear:both; }#footer { background: #2BB81B; border-top:5px solid #8CEC81; borderbottom:5px solid #8CEC81; }.clearing { clear:both; height:0; }#content #col-1 {float:left;width:500px; margin:0px;padding:0px;}#content #col-2 {float:right; width:300px; margin:0px; padding:30px 010px 25px; border-left:3px solid #99cc66; height:500px;}#content #col-2 div {padding-bottom:20px;}#menu {background:#ffffff;float: left;}#menu ul {list-style: none;margin: 0;padding: 0;width: 48em;float: left;}#menu ul li {display: inline;}#menu a, #menu h2 {font: bold 11px/16px arial, helvetica, sans-serif;display: inline;border-width: 1px;border-style: solid;border-color: #ccc #888 #555 #bbb;margin: 0;padding: 2px 3px;}#menu h2 {color: #fff;background: #000;text-transform: uppercase;}#menu a {color: #000;background: #2BB81B;text-decoration: none;}#menu a:hover {color: #2BB81B;background: #fff;} Also remember to change the template of the resource to the learning MODx default template. Now preview the page, and you will see something like the one shown in the following screenshot: The HTML code returned will be similar to the following: <ul><li class="menu"><a href="http://localhost/learningMODx/"title="Home" >Home</a></li><li class="menu"><a href="/learningMODx/index.php?id=2" title="Blog">Blog</a></li><li class="menu"><a href="/learningMODx/index.php?id=15" title="MODxFeatures" >Features</a></li><li class="menu"><a href="/learningMODx/index.php?id=33"title="Getting Help" >Getting Help</a></li><li class="menu"><a href="/learningMODx/index.php?id=32"title="Design" >Design</a></li><li class="menu"><a href="/learningMODx/index.php?id=53" title="SignupForm" >Signup Form</a></li><li class="menu"><a href="/learningMODx/index.php?id=6" title="ContactUs" >Contact us</a></li><li class="menu"><a href="/learningMODx/index.php?id=54"title="Getting to know ditto" >Getting to know ditto</a></li><li class="menu last active"><a href="/learningMODx/index.php?id=58"title="testing wayfinder" >testing wayfinder</a></li></ul> Notice that for each menu item, the class menu has been applied. Although we have not applied any custom style to the menu class, we have shown you that when you are building more fine-grained menu systems, you have the ability to have every item associated with a class.
Read more
  • 0
  • 0
  • 5804
article-image-documentaries-and-other-audio-visual-projects-celtx
Packt
10 Mar 2011
6 min read
Save for later

Documentaries and Other Audio-Visual Projects with Celtx

Packt
10 Mar 2011
6 min read
What is an audio-visual production? The term audio-visual production basically covers anything in the known universe that combines varying components of movement, sound, and light. Movies are nothing more than big expensive (really expensive) audio-visual shows. Television programs; the fireworks, performed music, and laser lights of a major rock concert; a business presentation; Uncle Spud showing slides of his vacation in Idaho—all are audio-visual productions. A complex audio-visual production, such as the big rock concert, combines many types of contents and is called a multimedia show, which combine sounds and music, projections of video and photos (often several at once), lights, spoken words, text on screens, and more. Audio visual shows, those of an educational nature as well as for entertainment value, might be produced with equipment such as the following: Dioramas Magic lanterns Planetarium Film projectors Slide projectors Opaque projectors Overhead projectors Tape recorders Television Video Camcorders Video projectors Interactive whiteboards Digital video clips Also productions such as TV commercials, instructional videos, those moving displays you see in airports, even the new digital billboards along our highways—all are audio-visual productions (even the ones without sound). My favorite type of production, documentaries (I've done literally hundreds of them), are audio-visual shows. A documentary is a nonfiction movie and includes newsreels, travel, politics, docudramas, nature films and animal films, music videos, and much more. In short, as we can see from the preceding discussion, you can throw just about everything into a production including your kitchen sink. Turn the faucet on and off while blasting inspiring music and hitting it with colored spotlights, and plumbers will flock to buy tickets to the show! Now, while just about every conceivable project falls into the audio-visual category, Celtx (as shown in the next screenshot) offers us specific categories that narrow the field down a little. The following screenshot from Celtx's splash page shows those categories. Film handles movies and television shows, Theatre (love that Canadian spelling, eh?) is for stage plays, Audio Play is designed for radio programs and podcasts, Storyboard is for visual planning, and Comic Book is for writing anything from comic strips to epic graphic novels. Text (not shown in the following screenshot) is the other project type that comes with Celtx and is great for doing loglines, synopses, treatments, outlines, and anything else calling for a text editor rather than a script formatter. Just about everything else can be written in an Audio-Visual project container! Let's think about that for a moment. This means that Audio-Visual is by far and away the most powerful project provided by Celtx. In the script element drop-down box, there are only five script elements—Scene Heading, Shot, Character, Dialog, and Parenthetical—whereas Film has eight! Yet, thanks to Celtx magic, these five elements, as I will show you in this article, are a lot more flexible than in Film and the other projects. It's pretty amazing. So, time to start an audio-visual project of our own. Starting an AV project in Celtx What better example to use than a short documentary on... wait for it... Celtx. This film I actually plan on producing and using to both promote Celtx (which certainly deserves letting people know about it) and also showing that this article is great for learning all this marvelous power of Celtx. The title: "Celtx Loves Indies." Indies is slang for independent producers. An independent producer is a company or quite often an individual who makes films outside Hollywood or Bollywood or any other studio system. Big studios have scores or even hundreds of people to do all those tasks needed in producing a film. Indies often have very few people, sometimes just one or two doing all the crewing and production work. Low budget (not spending too much money on making films) is our watchword. Celtx is perfect for indies—it is, as I point out in the documentary—like having a studio in a box! So, my example project for this chapter is how I set up "Celtx Loves Indies" in Celtx. Time for action — beginning our new AV project We start our project, as we did our spec script in the last chapter, by making a directory on our computer. Having a separate directory for our projects makes it a lot easier to organize and to find stuff when we need it. Therefore, I first create the new empty directory on my hard drive named Celtx Loves Indies, as shown in the following screenshot: Now, fire up Celtx. In a moment, we'll left click on Audio-Visual to open a project container that has an Audio-Visual script in it. However, first, since I have not mentioned it to date, look at the items outside the Project Templates and Recent Project boxes in the lower part of the splash page, as shown in the following screenshot: As Celtx is connected to the Internet, we get some information each time Celtx starts up from the servers at: . This information from online includes links to news, help features, ads for Celtx add-ons, and announcements. The big news here is that Celtx has added an app (application) to synchronize projects with iPhones and iPadsHowever, check these messages out each time you open Celtx. Next, we open an Audio-Visual project in Celtx. This gives us a chance to check out those five script elements we met earlier by left clicking on the downward arrow next to Scene Heading. In the next section, we'll examine each and use them. Time for action – setting up the container Continuing with our initial setup of the container for this project, rename the A/V Script in the Project Library. I renamed mine, naturally, Celtx Loves Indies. Also, remember we can have hundreds of files, directories, subdirectories, and so on in the Project Library—our research and more. This is why a Celtx project is really a container. Just right click on A/V Script, choose Rename... and type in the new title, as shown in the following screenshot: Left click on File at the top left of the Celtx screen, then on Save Project As... (or use the Ctrl+Shift+S key shortcut) to save the project into your new directory, all properly titled and ready for action, as shown in the following screenshot:
Read more
  • 0
  • 0
  • 4638

article-image-creating-and-consuming-web-services-cakephp-13
Packt
10 Mar 2011
7 min read
Save for later

Creating and Consuming Web Services in CakePHP 1.3

Packt
10 Mar 2011
7 min read
CakePHP 1.3 Application Development Cookbook Over 70 great recipes for developing, maintaining, and deploying web applications     Creating an RSS feed RSS feeds are a form of web services, as they provide a service, over the web, using a known format to expose data. Due to their simplicity, they are a great way to introduce us to the world of web services, particularly as CakePHP offers a built in method to create them. In this recipe, we will produce a feed for our site that can be used by other applications. Getting ready To go through this recipe we need a sample table to work with. Create a table named posts, using the following SQL statement: CREATE TABLE `posts`(posts `id` INT NOT NULL AUTO_INCREMENT, `title` VARCHAR(255) NOT NULL, `body` TEXT NOT NULL, `created` DATETIME NOT NULL, `modified` DATETIME NOT NULL, PRIMARY KEY(`id`) ); Add some sample data, using the following SQL statements: INSERT INTO `posts`(`title`,posts `body`, `created`, `modified`) VALUES ('Understanding Containable', 'Post body', NOW(), NOW()), ('Creating your first test case', 'Post body', NOW(), NOW()), ('Using bake to start an application', 'Post body', NOW(), NOW()), ('Creating your first helper', 'Post body', NOW(), NOW()), ('Adding indexes', 'Post body', NOW(), NOW()); We proceed now to create the required controller. Create the class PostsController in a file named posts_controller.php and place it in your app/controllers folder, with the following contents: <?php class PostsController extends AppController { public function index() { $posts = $this->Post->find('all'); $this->set(compact('posts')); } } ?> Create a folder named posts in your app/views folder, and then create the index view in a file named index.ctp and place it in your app/views/posts folder, with the following contents: <h1>Posts</h1> <?php if (!empty($posts)) { ?> <ul> <?php foreach($posts as $post) { ?> <li><?php echo $this->Html->link( $post['Post']['title'], array( 'action'=>'view', $post['Post']['id'] ) ); ?></li> <?php } ?> </ul> <?php } ?> How to do it... Edit your app/config/routes.php file and add the following statement at the end: Router::parseExtensions('rss'); Edit your app/controllers/posts_controller.php file and add the following property to the PostsController class: public $components = array('RequestHandler'); While still editing PostsController, make the following changes to the index() method: public function index() { $options = array(); if ($this->RequestHandler->isRss()) { $options = array_merge($options, array( 'order' => array('Post.created' => 'desc'), 'limit' => 5 )); } $posts = $this->Post->find('all', $options); $this->set(compact('posts')); } Create a folder named rss in your app/views/posts folder, and inside the rss folder create a file named index.ctp, with the following contents: <?php $this->set('channel', array( 'title' => 'Recent posts', 'link' => $this->Rss->url('/', true), 'description' => 'Latest posts in my site' )); $items = array(); foreach($posts as $post) { $items[] = array( 'title' => $post['Post']['title'], 'link' => array('action'=>'view', $post['Post']['id']), 'description' => array('cdata'=>true, 'value'=>$post['Post'] ['body']), 'pubDate' => $post['Post']['created'] ); } echo $this->Rss->items($items); ?> Edit your app/views/posts/index.ctp file and add the following at the end of the view: <?php echo $this->Html->link('Feed', array('action'=>'index', 'ext'=>'rss')); ?> If you now browse to http://localhost/posts, you should see a listing of posts with a link entitled Feed. Clicking on this link should produce a valid RSS feed, as shown in the following screenshot: If you view the source of the generated response, you can see that the source for the first item within the RSS document is: <item> <title>Understanding Containable</title> <link>http://rss.cookbook7.kramer/posts/view/1</link> <description><![CDATA[Post body]]></description> <pubDate>Fri, 20 Aug 2010 18:55:47 -0300</pubDate> <guid>http://rss.cookbook7.kramer/posts/view/1</guid> </item> How it works... We started by telling CakePHP that our application accepts the rss extension with a call to Router::parseExtensions(), a method that accepts any number of extensions. Using extensions, we can create different versions of the same view. For example, if we wanted to accept both rss and xml as extensions, we would do: Router::parseExtensions('rss', 'xml'); In our recipe, we added rss to the list of valid extensions. That way, if an action is accessed using that extension, for example, by using the URL http://localhost/posts.rss, then CakePHP will identify rss as a valid extension, and will execute the ArticlesController::index() action as it normally would, but using the app/views/posts/rss/index.ctp file to render the view. The process also uses the file app/views/layouts/rss/default.ctp as its layout, or CakePHP's default RSS layout if that file is not present. We then modify how ArticlesController::index() builds the list of posts, and use the RequestHandler component to see if the current request uses the rss extension. If so, we use that knowledge to change the number and order of posts. In the app/views/posts/rss/index.ctp view, we start by setting some view variables. Because a controller view is always rendered before the layout, we can add or change view variables from the view file, and have them available in the layout. CakePHP's default RSS layout uses a $channel view variable to describe the RSS feed. Using that variable, we set our feed's title, link, and description. We proceed to output the actual item files. There are different ways to do so, the first one is making a call to the RssHelper::item() method for each item, and the other one requires only a call to RssHelper::items(), passing it an array of items. We chose the latter method due to its simplicity. While we build the array of items to be included in the feed, we only specify title, link, description, and pubDate. Looking at the generated XML source for the item, we can infer that the RssHelper used our value for the link element as the value for the guid (globally unique identifier) element. Note that the description field is specified slightly differently than the values for the other fields in our item array. This is because our description may contain HTML code, so we want to make sure that the generated document is still a valid XML document. By using the array notation for the description field, a notation that uses the value index to specify the actual value on the field, and by setting cdata to true, we are telling the RssHelper (actually the XmlHelper from which RssHelper descends) that the field should be wrapped in a section that should not be parsed as part of the XML document, denoted between a <![CDATA[ prefix and a ]]> postfix. The final task in this recipe is adding a link to our feed that is shown in the index.ctp view file. While creating this link, we set the special ext URL setting to rss. This sets the extension for the generated link, which ends up being http://localhost/posts.rss.  
Read more
  • 0
  • 0
  • 9377

article-image-getting-started-inkscape
Packt
09 Mar 2011
9 min read
Save for later

Getting Started with Inkscape

Packt
09 Mar 2011
9 min read
Inkscape 0.48 Essentials for Web Designers Use the fascinating Inkscape graphics editor to create attractive layout designs, images, and icons for your website   Vector graphics Vector graphics are made up of paths. Each path is basically a line with a start and end point, curves, angles, and points that are calculated with a mathematical equation. These paths are not limited to being straight—they can be of any shape, size, and even encompass any number of curves. When you combine them, they create drawings, diagrams, and can even help create certain fonts. These characteristics make vector graphics very different than JPEGs, GIFs, or BMP images—all of which are considered rasterized or bitmap images made up of tiny squares which are called pixels or bits. If you magnify these images, you will see they are made up of a grid (bitmaps) and if you keep magnifying them, they will become blurry and grainy as each pixel with bitmap square's zoom level grows larger. Computer monitors also use pixels in a grid. However, they use millions of them so that when you look at a display, your eyes see a picture. In high-resolution monitors, the pixels are smaller and closer together to give a crisper image. How does this all relate to vector-based graphics? Vector-based graphics aren't made up of squares. Since they are based on paths, you can make them larger (by scaling) and the image quality stays the same, lines and edges stay clean, and the same images can be used on items as small as letterheads or business cards or blown up to be billboards or used in high definition animation sequences. This flexibility, often accompanied by smaller file sizes, makes vector graphics ideal—especially in the world of the Internet, varying computer displays, and hosting services for web spaces, which leads us nicely to Inkscape, a tool that can be invaluable for use in web design. What is Inkscape and how can it be used? Inkscape is a free, open source program developed by a group of volunteers under the GNU General Public License (GPL). You not only get a free download but can use the program to create items with it and freely distribute them, modify the program itself, and share that modified program with others. Inkscape uses Scalable Vector Graphics (SVG), a vector-based drawing language that uses some basic principles: A drawing can (and should) be scalable to any size without losing detail A drawing can use an unlimited number of smaller drawings used in any number of ways (and reused) and still be a part of a larger whole SVG and World Wide Web Consortium (W3C) web standards are built into Inkscape which give it a number of features including a rich body of XML (eXtensible Markup Language) format with complete descriptions and animations. Inkscape drawings can be reused in other SVG-compliant drawing programs and can adapt to different presentation methods. It has support across most web browsers (Firefox, Chrome, Opera, Safari, Internet Explorer). When you draw your objects (rectangles, circles, and so on.), arbitrary paths, and text in Inkscape, you also give them attributes such as color, gradient, or patterned fills. Inkscape automatically creates a web code (XML) for each of these objects and tags your images with this code. If need be, the graphics can then be transformed, cloned, and grouped in the code itself, Hyperlinks can even be added for use in web browsers, multi-lingual scripting (which isn't available in most commercial vector-based programs) and more—all within Inkscape or in a native programming language. It makes your vector graphics more versatile in the web space than a standard JPG or GIF graphic. There are still some limitations in the Inkscape program, even though it aims to be fully SVG compliant. For example, as of version 0.48 it still does not support animation or SVG fonts—though there are plans to add these capabilities into future versions. Installing Inkscape Inkscape is available for download for Windows, Macintosh, Linux, or Solaris operating systems. To run on the Mac OS X operating system, it typically runs under X11—an implementation of the X Window System software that makes it possible to run X11-based applications in Mac OS X. The X11 application has shipped with the Mac OS X since version 10.5. When you open Inkscape on a Mac, it will first open X11 and run Inkscape within that program. Loss of some shortcut key options will occur but all functionality is present using menus and toolbars. Let's briefly go over how to download and install Inkscape: Go to the official Inkscape website at: http://www.inkscape.org/ and download the appropriate version of the software for your computer. For the Mac OS X Leopard software, you will also need to download an additional application. It is the X11 application package 2.4.0 or greater from this website: http://xquartz.macosforge.org/trac/wiki/X112.4.0. Once downloaded, double-click the X11-2.4.0.DMG package first. It will open another folder with the X11 application installer. Double-click that icon to be prompted through an installation wizard. Double-click the downloaded Inkscape installation package to start the installation. For the Mac OS, a DMG file is downloaded. Double-click on it and then drag and drop the Inkscape package to the Application Folder. For any Windows device, an .EXE file is downloaded. Double-click that file to start and complete the installation. For Linux-based computers, there are a number of distributions available. Be sure to download and install the correct installation package for your system. Now find the Inkscape icon in the Application or Programs folders to open the program. Double-click the Inkscape icon and the program will automatically open to the main screen. The basics of the software When you open Inkscape for the first time, you'll see that the main screen and a new blank document opened are ready to go. If you are using a Macintosh computer, Inkscape opens within the X11 application and may take slightly longer to load. The Inkscape interface is based on the GNOME UI standard which uses visual cues and feedback for any icons. For example: Hovering your mouse over any icon displays a pop-up description of the icon. If an icon has a dark gray border, it is active and can be used. If an icon is grayed out, it is not currently available to use with the current selection. All icons that are in execution mode (or busy) are covered by a dark shadow. This signifies that the application is busy and won't respond to any edit request. There is a Notification Display on the main screen that displays dynamic help messages to key shortcuts and basic information on how to use the Inkscape software in its current state or based on what objects and tools are selected. Main screen basics Within the main screen there is the main menu, a command, snap and status bar, tool controls, and a palette bar. Main menu You will use the main menu bar the most when working on your projects. This is the central location to find every tool and menu item in the program—even those found in the visual-based toolbars below it on the screen. When you select a main menu item the Inkscape dialog displays the icon, a text description, and shortcut key combination for the feature. This can be helpful while first learning the program—as it provides you with easier and often faster ways to use your most commonly used functions of the program. Toolbars Let's take a general tour of the tool bars seen on this main screen. We'll pay close attention to the tools we'll use most frequently. If you don't like the location of any of the toolbars, you can also make them as floating windows on your screen. This lets you move them from their pre-defined locations and move them to a location of your liking. To move any of the toolbars, from their docking point on the left side, click and drag them out of the window. When you click the upper left button to close the toolbar window, it will be relocated back into the screen. Command bar This toolbar represents the common and most frequently used commands in Inkscape: As seen in the previous screenshot you can create a new document, open an existing one, save, print, cut, paste, zoom, add text, and much more. Hover your mouse over each icon for details on its function. By default, when you open Inkscape, this toolbar is on the right side of the main screen. Snap bar Also found vertically on the right side of the main screen, this toolbar is designed to help with the Snap to features of Inkscape. It lets you easily align items (snap to guides), force objects to align to paths (snap to paths), or snap to bounding boxes and edges. Tool controls This toolbar's options change depending on which tool you have selected in the toolbox (described in the next section). When you are creating objects, it provides you all the detailed options—size, position, angles, and attributes specific to the tool you are currently using. By default, it looks like the following screenshot: (Move the mouse over the image to enlarge.) You have options to select/deselect objects within a layer, rotate or mirror objects, adjust object locations on the canvas, and scaling options and much more. Use it to define object properties when they are selected on the canvas. Toolbox bar You'll use the tool box frequently. It contains all of the main tools for creating objects, selecting and modifying objects, and drawing. To select a tool, click the icon. If you double-click a tool, you can see that tool's preferences (and change them). If you are new to Inkscape, there are a couple of hints about creating and editing text. The Text tool (A icon) in the Tool Box shown above is the only way of creating new text on the canvas. The T icon shown in the Command Bar is used only while editing text that already exists on the canvas.  
Read more
  • 0
  • 0
  • 8985
article-image-cakephp-13-model-bindings
Packt
08 Mar 2011
13 min read
Save for later

CakePHP 1.3: Model Bindings

Packt
08 Mar 2011
13 min read
  CakePHP 1.3 Application Development Cookbook Over 70 great recipes for developing, maintaining, and deploying web applications Introduction This article deals with one of the most important aspects of a CakePHP application: the relationship between models, also known as model bindings or associations. Being an integral part of any application's logic, it is of crucial importance that we master all aspects of how model bindings can be manipulated to get the data we need, when we need it. In order to do so, we will go through a series of recipes that will show us how to change the way bindings are fetched, what bindings and what information from a binding is returned, how to create new bindings, and how to build hierarchical data structures. Adding Containable to all models The Containable behavior is a part of the CakePHP core, and is probably one of the most important behaviors we have to help us deal with model bindings. Almost all CakePHP applications will benefit from its functionalities, so in this recipe we see how to enable it for all models. How to do it... Create a file named app_model.php and place it in your app/ folder, with the following contents. If you already have one, make sure that either you add the actsAs property shown as follows, or that your actsAs property includes Containable. <?php class AppModel extends Model { public $actsAs = array('Containable'); } ?> How it works... The Containable behavior is nothing more and nothing less than a wrapper around the bindModel() and unbindModel() methods, defined in the CakePHP's Model class. It is there to help us deal with the management of associations without having to go through a lengthy process of redefining all the associations when calling one of these methods, thus making our code much more readable and maintainable. This is a very important point, because a common mistake CakePHP users make is to think that Containable is involved in the query-making process, that is, during the stage where CakePHP creates actual SQL queries to fetch data. Containable saves us some unneeded queries, and optimizes the information that is fetched for each related model, but it will not serve as a way to change how queries are built in CakePHP. Limiting the bindings returned in a find This recipe shows how to use Containable to specify what related models are returned as a result of a find operation. It also shows us how to limit which fields are obtained for each association. Getting ready To go through this recipe we need some sample tables to work with. Create a table named families, using the following SQL statement: CREATE TABLE `families`( `id` INT UNSIGNED AUTO_INCREMENT NOT NULL, `name` VARCHAR(255) NOT NULL, PRIMARY KEY(`id`) ); Create a table named people, using the following SQL statement: CREATE TABLE `people`( `id` INT UNSIGNED AUTO_INCREMENT NOT NULL, `family_id` INT UNSIGNED NOT NULL, `name` VARCHAR(255) NOT NULL, `email` VARCHAR(255) NOT NULL, PRIMARY KEY(`id`), KEY `family_id`(`family_id`), CONSTRAINT `people__families` FOREIGN KEY(`family_id`) REFERENCES `families`(`id`) ); Create a table named profiles, using the following SQL statement: CREATE TABLE `profiles`( `id` INT UNSIGNED AUTO_INCREMENT NOT NULL, `person_id` INT UNSIGNED NOT NULL, `website` VARCHAR(255) default NULL, `birthdate` DATE default NULL, PRIMARY KEY(`id`), KEY `person_id`(`person_id`), CONSTRAINT `profiles__people` FOREIGN KEY(`person_id`) REFERENCES `people`(`id`) ); Create a table named posts, using the following SQL statement: CREATE TABLE `posts`( `id` INT UNSIGNED AUTO_INCREMENT NOT NULL, `person_id` INT UNSIGNED NOT NULL, `title` VARCHAR(255) NOT NULL, `body` TEXT NOT NULL, `created` DATETIME NOT NULL, `modified` DATETIME NOT NULL, PRIMARY KEY(`id`), KEY `person_id`(`person_id`), CONSTRAINT `posts__people` FOREIGN KEY(`person_id`) REFERENCES `people`(`id`) ); Even if you do not want to add foreign key constraints to your tables, make sure you use KEYs for each field that is a reference to a record in another table. By doing so, you will significantly improve the speed of your SQL queries when the referenced tables are joined. Add some sample data, using the following SQL statements: INSERT INTO `families`(`id`, `name`) VALUES (1, 'The Does'); INSERT INTO `people`(`id`, `family_id`, `name`, `email`) VALUES (1, 1, 'John Doe', 'john.doe@example.com'), (2, 1, 'Jane Doe', 'jane.doe@example.com'); INSERT INTO `profiles`(`person_id`,`website`,`birthdate`) VALUES (1, 'http://john.example.com', '1978-07-13'), (2, NULL, '1981-09-18'); INSERT INTO `posts`(`person_id`, `title`, `body`, `created`, `modified`) VALUES (1, 'John's Post 1', 'Body for John's Post 1', NOW(), NOW()), (1, 'John's Post 2', 'Body for John's Post 2', NOW(), NOW()); We need Containable added to all our models. We proceed now to create the main model. Create a file named person.php and place it in your app/models folder with the following contents: <?php class Person extends AppModel { public $belongsTo = array('Family'); public $hasOne = array('Profile'); public $hasMany = array('Post'); } ?> Create the model Family in a file named family.php and place it in your app/models folder with the following contents: <?php class Family extends AppModel { public $hasMany = array('Person'); } ?> How to do it... When Containable is available for our models, we can add a setting to the find operation called contain. In that setting we specify, in an array-based hierarchy, the associated data we want returned. A special value contain can receive is false, or an empty array, which tells Containable not to return any associated data. For example, to get the first Person record without associated data, we simply do: $person = $this->Person->find('first', array( 'contain' => false )); Another way to tell CakePHP not to obtain related data is through the use of the recursive find setting. Setting recursive to -1 will have exactly the same effect as setting contain to false. If we want to obtain the first Person record together with the Family they belong to, we do: $person = $this->Person->find('first', array( 'contain' => array('Family') )); Using our sample data, the above query will result in the following array structure: array( 'Person' => array( 'id' => '1', 'family_id' => '1', 'name' => 'John Doe', 'email' => 'john.doe@example.com' ), 'Family' => array( 'id' => '1', 'name' => 'The Does' ) ) Let's say that now we also want to obtain all Post records for the person and all members in the family that Person belongs to. We would then have to do: $person = $this->Person->find('first', array( 'contain' => array( 'Family.Person' 'Post' ) )); The above would result in the following array structure (the created and modified fields have been removed for readability): array( 'Person' => array( 'id' => '1', 'family_id' => '1', 'name' => 'John Doe', 'email' => 'john.doe@example.com' ), 'Family' => array( 'id' => '1', 'name' => 'The Does', 'Person' => array( array( 'id' => '1', 'family_id' => '1', 'name' => 'John Doe', 'email' => 'john.doe@example.com' ), array( 'id' => '2', 'family_id' => '1', 'name' => 'Jane Doe', 'email' => 'jane.doe@example.com' ) ) ), 'Post' => array( array( 'id' => '1', 'person_id' => '1', 'title' => 'John's Post 1', 'body' => 'Body for John's Post 1' ), array( 'id' => '2', 'person_id' => '1', 'title' => 'John's Post 2', 'body' => 'Body for John's Post 2' ) ) ) We can also use Containable to specify which fields from a related model we want to fetch. Using the preceding sample, let's limit the Post fields so we only return the title and the Person records for the person's Family, so we only return the name field. We do so by adding the name of the field to the associated model hierarchy: $person = $this->Person->find('first', array( 'contain' => array( 'Family.Person.name', 'Post.title' ) )); The returned data structure will then look like this: array( 'Person' => array( 'id' => '1', 'family_id' => '1', 'name' => 'John Doe', 'email' => 'john.doe@example.com' ), 'Family' => array( 'id' => '1', 'name' => 'The Does', 'Person' => array( array( 'name' => 'John Doe', 'family_id' => '1', 'id' => '1' ), array( 'name' => 'Jane Doe', 'family_id' => '1', 'id' => '2' ) ) ), 'Post' => array( array( 'title' => 'John's Post 1', 'id' => '1', 'person_id' => '1' ), array( 'title' => 'John's Post 2', 'id' => '2', 'person_id' => '1' ) ) ) You may notice that even when we indicated specific fields for the Family => Person binding, and for the Post binding, there are some extra fields being returned. Those fields (such as family_id) are needed by CakePHP, and known as foreign key fields, to fetch the associated data, so Containable is smart enough to include them in the query. Let us say that we also want a person's e-mail. As there is more than a field needed, we will need to use the array notation, using the fields setting to specify the list of fields: $person = $this->Person->find('first', array( 'contain' => array( 'Family' => array( 'Person' => array( 'fields' => array('email', 'name') ) ), 'Post.title' ) )); How it works... We use the contain find setting to specify what type of containment we want to use for the find operation. That containment is given as an array, where the array hierarchy mimics that of the model relationships. As the hierarchy can get deep enough to make array notation complex to deal with, the dot notation used throughout this recipe serves as an useful and more readable alternative. If we want to refer to the model Person that belongs to the model Family, the proper contain syntax for that is Person => Family (we can also use Person.Family, which is more concise.) We also use the fields setting to specify which fields we want fetched for a binding. We do that by specifying an array of field names as part of the binding Containable setting. Containable looks for the contain find setting right before we issue a find operation on a model. If it finds one, it alters the model bindings to be returned by issuing unbindModel() calls on the appropriate models to unbind those relationships that are not specified in the contain find setting. It then sets the recursive find setting to the minimum value required to fetch the associated data. Let us use a practical example to further understand this wrapping process. Using our Person model (which has a belongsTo relationship to Family, a hasOne relationship to Profile, and a hasMany relationship to Post), the following Containable based query: $person = $this->Person->find('first', array( 'contain' => array('Family.Person') )); or the same query using array notation: $person = $this->Person->find('first', array( 'contain' => array('Family' => 'Person') )); is equivalent to the following set of instructions, which do not use Containable, but the built in unbindModel() method available in CakePHP's Model class: $this->Person->unbindModel(array( 'hasOne' => array('Profile'), 'hasMany' => array('Post') )); $person = $this->Person->find('first', array( 'recursive' => 2 )); Not using Containable is not only much more complicated, but can also pose a problem if we decide to alter some of our relationships. In the preceding example, if we decide to remove the Profile binding, or change its relationship type, we would have to modify the unbindModel() call. However, if we are using Containable, the same code applies, without us having to worry about such changes. Format of the contain find parameter We have seen how to use the contain find parameter to limit which bindings are returned after a find operation. Even when its format seems self-explanatory, let us go through another example to have a deeper understanding of Containable's array notation. Assume that we have the models and relationships shown in the following diagram: Transforming that diagram to something the Containable behavior understands is as simple as writing it using an array structure. For example, if we are issuing a find operation on the User model and we want to refer to the Profile relationship, a simple array('Profile') expression would suffice, as the Profile model is directly related to the User model. If we want to refer to the Comment relationship for the Article records the User is an owner of, which belongs to an Article that itself belongs to our User model, then we add another dimension to the structure, which is now represented as array('Article' => 'Comment'). We can already deduce how the next example will look like. Assume we want to obtain the Comment together with the Profile of the User that commented on each Article. The structure will then look like: array('Article' => array('Comment' => array('User' => 'Profile'))). Sometimes we want to simplify the readability, and fortunately the Containable behavior allows the above expression to be rewritten as array('Article.Comment.User.Profile'), which is known as dot notation. However, if you want to change other parameters to the binding, then this syntax would have to be changed to the full array-based expression. Reset of binding changes When you issue a find operation that uses the Containable behavior to change some of its bindings, CakePHP will reset all bindings' changes to their original states, once the find is completed. This is what is normally wanted on most cases, but there are some scenarios where you want to keep your changes until you manually reset them, such as when you need to issue more than one find operation and have all those finds use the modified bindings. To force our binding changes to be kept, we use the reset option in the contain find parameter, setting it to false. When we are ready to reset them, we issue a call to the resetBindings() method added by the Containable behavior to our model. The following sample code shows this procedure: $person = $this->Person->find('first', array( 'contain' => array( 'reset' => false, 'Family' ) )); // ... $this->Person->resetBindings(); Another way to achieve the same result is by calling the contain() method (setting its first argument to the contained bindings, and its second argument to false to indicate that we wish to keep these containments), available to all models that use Containable, issue the find (without, need to use the contain setting), and then reset the bindings: $this->Person->contain(array('Family'), false); $person = $this->Person->find('first'); // ... $this->Person->resetBindings();  
Read more
  • 0
  • 0
  • 2901

article-image-new-modules-moodle-2
Packt
07 Mar 2011
5 min read
Save for later

New Modules for Moodle 2

Packt
07 Mar 2011
5 min read
  Moodle 2.0 First Look Discover what's new in Moodle 2.0, how the new features work, and how it will impact you         Read more about this book       (For more resources on Moodle, see here.) Blogs—before and after There has always been a blogging option in a standard Moodle install. However, some users have found it unsatisfactory because of the following reasons: The blog is attached to the user profile so you can only have one blog There is no way to attach a blog or blog entry to a particular course There is no way for other people to comment on your blog For this reason, alternative blog systems (such as the contributed OU blog module) have become popular as they give users a wider range of options. The standard blog in Moodle 2.0 has changed, and now: A blog entry can optionally be associated with a course It is possible to comment on a blog entry Blog entries from outside of Moodle can be copied in It is now possible to search blog entries Where's my blog? Last year when Emma studied on Moodle 1.9, if she wanted to make a blog entry she would click on her name to access her profile and she'd see a blog tab like the one shown in following screenshot: Alternatively, if her tutor had added the blog menu block, she could click on Add a new entry and create her blog post there as follows: The annoyance was that if she added a new entry in the blog menu of her ICT course, her classmates in her Art course could see that entry (even, confusingly, if the blog menu had a link to entries for just that course). If we follow Emma into the Beginners' French course in Moodle 2.0, we see that she can access her profile from the navigation block by clicking on My profile and then selecting View Profile. (She can also view her profile by clicking on her username as she could in Moodle 1.9). If she then clicks on Blogs she can view all the entries she made anywhere in Moodle and can also add a new entry: As before, Emma can also add her entry through the blog menu, so let's take a look at that. Her tutor, Stuart needs to have added this block to the course. The Blog Menu block To add this to a course a teacher such as Stuart needs to turn on the editing and select Blog menu from the list of available blocks: The Blog menu displays the following links: View all entries for this course: Here's where Emma and others can read blog entries specific to that course. This link shows users all the blog posts for the course they are currently in. View my entries about this course: Here's where Emma can check the entries she has already made associated with this course. This link shows users their own blog posts for the course they are currently in. Add an entry about this course: Here's where Emma can add a blog entry related only to this course. When she does that, she is taken to the editing screen for adding a new blog entry, which she starts as shown in the following screenshot: Just as in Moodle 1.9, she can attach documents, choose to publish publicly or keep to herself and add tags. The changes come as we scroll down. At the bottom of the screen is a section which associates her entry with the course she is presently in: Once she has saved it, she sees her post appear as follows: View all of my entries: Here Emma may see every entry she has made, regardless of which course it was in or whether she made it public or private. Add a new entry: Emma can choose to add a new blog entry here (as she could from her profile) which doesn't have to be specific to any particular course. If she sets it to "anyone on this site", then other users can read her blog wherever they are in Moodle. Search: At the bottom of the Blog menu block is a search box. This enables users to enter a word or phrase and see if anyone has mentioned it in a blog entry The Recent Blog Entries block As our teacher in the Beginners' French course Stuart has enabled the Recent Blog Entries block, there is also a block showing the latest blog entries. Emma's is the most recent entry on the course so hers appears as a link, along with all other recent course entries. Course specific blogs Just to recap and double check—if Emma now visits her other course, How to Be Happy and checks out the View my entries about this course entries link in the Blog menu, she does not see her French course blog post, but instead, sees an entry she has associated with this course: The tutor for this course, Andy, has added the blog tags block. The blog tags block This block is not new; however, it's worth pointing out that the tags are NOT course-specific, and so Emma sees the tags she added to the entries in both courses alongside the tags from other users:  
Read more
  • 0
  • 0
  • 2998
Modal Close icon
Modal Close icon