oDesk Drupal Test Answers 2015
·
1. Which function can be used to
invoke a hook in all enabled modules in Drupal?
Answers:
• module_invoke_all()
•
module_invoke_hook()
•
module_hook_invoke()
•
hook_invoke_all()
2. Which software architectural
pattern is Drupal most closely associated with?
Answers:
• PAC:
Presentation-Abstraction-Control
• MVC:
Model-View-Controller
• MVVM: Model-View-ViewModel
• SOA:
Service-Oriented Architecture
3. Which function can be used to
attach images to a particular node at runtime?
Answers:
• node_save()
•
node_insert_image()
• node_create()
• node_load()
4. Which of following will have a
negative effect on the performance of a Drupal website?
Answers:
• using cache
• using memcahe
• using APC
• using base
theme
5. By using the auto-complete field
for a CCK nodereference, nodereference gives node id as [nid: node id]; which
Drupal hook can be used to remove the bracket from the auto-complete list?
Answers:
• menu_alter()
• form_alter()
• A & B both
• None of above
6. Which of the following statements
are true?
Answers:
• Can insert a
block to a template programmatically using block_invoke().
• Can insert a
block to a template programmatically using module_invoke().
• Can insert a block to a
template programmatically using module_invoke() and block_invoke().
• Cannot insert a
block to a template programmatically.
7. With the faceted search module it
is possible to?
Answers:
• Use the meta
data associated with node type to search the nodes
• Taxonomy terms
can be used to filter the search result
• Build the
search query on the fly by selecting different and multple meta data
• All of above
8. Drupal.behaviors should be used
instead of jQuery.ready. Which of the following statements are not a good
reason for this recommendation?
Answers:
•
Drupal.behaviors can be fired multiple times during page execution .
• Modules could
override or extend existing Drupal.behaviors.
•
Drupal.behaviors can be run whenever new DOM elements are inserted into the
document.
• Drupal.behaviors increase
jQuery performence.
9. Drupal.behaviors should be used
instead of jQuery.ready. Which of the following statements are not good reason
for this recommendation?
Answers:
•
Drupal.behaviors can be fired multiple times during page execution .
• Modules could
override or extend existing Drupal.behaviors.
•
Drupal.behaviors can be run whenever new DOM elements are inserted into the
document.
• Drupal.behaviors increase
jQuery performence.
10. Which of the following statements
are not best practices for implementing page handler include files in Drupal?
Answers:
• Any module that
has more than ~50 lines of code for page handler functions should be split off
into multiple files
• Page include
files should be named in the form, modulename.key.inc
• Splitting page
handlers into separate files; for example, example.admin.inc and example.pages.inc
• Consolidating page
handlers in to a single file, to decrease overhead
11. $node_type_A =
node_load($some_nid);
$current_delta =
get_current_delta($node_type_A->vid);
$node_type_A->field_type_B_node_ref
+= array($current_delta + 1 => array('nid' => $node_type_B_nid));
$node_type_A =
node_submit($node_type_A);
node_save($node_type_A);
content_insert($node_type_A);
Which of following statements are true
about code above?
Answers:
• Appending a node reference
• Arranging
fields by weight
• Retrieving node
refrece from a node
• Saving node
without modification
12. Which of the following statements
are true for the code below?
function
custom_module_menu_alter(&$items) {
$items['xyx/abc']['page
callback'] = 'custom_module_showcontent';
}
Answers:
• The code adds a
function which will be called upon requesting path xyx/abc.
• The code adds a function
which will be called with function callback queue upon requesting xyx/abc.
• The code is
adding a variable to menu path xyx/abc.
• The code is adding
a variable to the variable queue of path xyx/abc.
13. Which one of following makes use
of the Features module in Drupal?
Answers:
• Migrating
content from one Drupal website to another
• Exporting modules'
functionality in a single feature module
• Exporting
website settings
• Backing up of
website and database
14. Which of the following
condition(s) is/are not suited for using custom Drupal nodes?
Answers:
• When implicit
'ownership' via author tracking is needed
• When
categorization via taxonomy is needed
• When implicit
tracking of creation/modification time is needed
• When high data integrity
is needed
15. "hook_js_alter"
overrides JavaSript in Drupal. Which of the following statements are true?
Answers:
• It performs the necessary
alterations to the JavaScript code before it is presented on the page.
• It performs the
necessary alterations to the JavaScript code after it is presented on the page.
• It performs the
necessary alterations to the JavaScript code before the page is loaded by
browser.
• It performs the
necessary alterations to the JavaScript code after the page is loaded by
browser.
16. function
phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
array_shift($breadcrumb);
return
'<div class="breadcrumb">'. implode(' › ', $breadcrumb)
.'</div>';
}
}
Which of the statement(s) about the
code above is/are true?
Answers:
• The code will
add one item to the breadcrumbs
• The code will remove the
home item from the breadcrumbs
• The code will
add one item at the end of the breadcrumbs
• The code will
add a separator to the breadcrumbs
17. Which of the following are ways to
display SQL queries executed by a Drupal view?
Answers:
• By using the
devel module
• By using the
view_query_export module
• By using
$view->build_info['query']
• By using the
views_get_current_view() function
18. function
special_registration_form_alter(&$form, $form_state, $form_id) {
if ($form_id ==
'user_register' && 'user' == arg(0) && 'register' == arg(1)) {
// snipped
alteration code
}
}
Which of the following statements
about code above are true?
Answers:
• The code will
alter the registration form for specific user types.
• The code alter the
registration form for all instances of the user_register form.
• The code alter
the registration form, but only when the user_register form appears on the
'register/user' page.
• The code will alter the
registration form, but only when the user_register form appears on the
'user/register' page.
19. What is the order in which
template files (.tpl) will be displayed in a "view"?
Answers:
• Fields, Row
style output, Style output, Display output
• Display output,
Fields, Style output, Row style output
• Fields ,Row
style output, Row style output, Display output
• Display output, Style
output, Row style output, Fields
20. When sending email from Drupal,
how can the default "From" address be changed?
Answers:
• By changing the Drupal
admin settings' Site Information page
• By changing it
in the php.ini file
• By installing
the SMTP module.
• By changing
super user account's email address (user/1); the super user's email address
will be used as the site-wide email authoring address.
21. Having a taxonomy associated with
a node type. Using which function would it be possible to load/get the
vocabulary information in the code?
Answers:
•
taxonomy_get_vocabularies
• taxonomy_vocabulary_load
•
taxonomy_load_vocabularies
•
taxonomy_vocabulary_get
22. Which of the following will not
change the value of a CCK field automatically as soon as the user creates a new
node?
Answers:
• By using the
Rules module and adding and configuring a new Triggered Rule.
• By installing
the Computed Field module and creating a Computed Field as the changing field.
• By implementing
the hook_nodeapi hook in a custom module.
• By implementing the
hook_node_info hook in a custom module.
23. Which of the following is the
correct way to restrict users, with an email address ending in example.org
(user@example.org, test@example.org, etc), from registering an account?
Answers:
• By adding
"%@example.org" as an email restriction in the Access Rules
administration settings
• By installing a
Captcha module and its required modules
• By creating a
custom module and implementing the hook_user_restrictions hook
• By installing
the Domain Access module and its dependencies
24. By default, does Drupal Filefield
allow uploading of javascript files?
Answers:
• Yes, just like
any other files.
• No, it would be a security
risk if it is allowed, what is does is change the type of the file to .txt
• No, can not
upload files in Drupal.
• A and B are
correct.
25. Which of the following are best
practices for scaling Drupal for a high traffic site?
Answers:
• Setting the
page cache lifetime minimum to 1 minute
• Enabling CSS
and JavaScript aggregation
• Sorting and
filtering by CCK fields
• Using a PHP opcode cache
26. Which of the following is not a
desired way to create a custom page with custom layout in Drupal?
Answers:
• Using panels
• Using a
.tpl.php file specificially for that page
• Build page with exact HTML
structure you want
• None of above
27. The following are advantages of
using Drupal Views vs. custom module development EXCEPT:
Answers:
• Development
speed - creating a View will be faster than creating a custom module most of
the time
• Performance -
Views offer increased performance over custom modules
• Maintenance - Views is a
Drupal standard, as opposed to using custom modules, which gives your site's
maintenance an unnecessary learning curve
• Upgrading -
Views provide an upgrade path to future versions of Drupal, which custom
modules don't provide out-of-the-box
28. Which of the following is the
correct way to remove core CSS files and add custom CSS files to a theme?
Answers:
• By using the
drupal_get_css() & drupal_add_css() function
• By using the
drupal_attach_css() & drupal_remove_css() function
• By placing the
<style > tag in the theme, and placing an overwrite to all classes and
IDs that need to be removed
• Core CSS files
cannot be removed and custom CSS files cannot be added to a theme
29. Which of the following is the
correct way to display recent nodes/posts created by a user on their profile
page?
Answers:
• By using views module to
create a block, and configuring a view to take an argument as user ID and set
that block to show only on profile pages
• By enabling the
node created by users options from the admin panel
• By installing
& configuring the related posts module of drupal
• It is a default
feature of Drupal to show recent posts created by the user on their profile
30. Which of the following is the
correct way to customize the template for a view thas has been created using
CCK and the Views 2 module?
Answers:
• By creating a
node-contentname.tpl.php or
views-view-field--viewname--field-name-value.tpl.php
• By creating
views-view-field--viewname--field-name-value.tpl.php
• Using Semantic
Views
• Clicking on
admin/build/views/edit/ViewName -> Basic Settings -> Theme
31. Which of the following is the
correct way to make a partial or substring search in Drupal?
Answers:
• By using the Apache Solr
module
• By using the
Search Lucene API
• By patching the
core modules
• By using all of
the above methods
32. How can all the input filters that
have been created in the code be applied?
Answers:
• Using check_markup()
• You can only
apply filters one at time in your code.
• Using
apply_filter()
• Using
input_filter()
33. How can the taxonomy term pages be
themed?
Answers:
• Creating two files named
node-taxonomy.tpl.php and page-taxonomy-term.tpl.php for theming the taxonomy
pages
• Adding CSS in
the default style in the drupal theme
• Adding code to
the template.php file
• Adding the CSS
to the taxonomy pages
34. Which of the following is the
correct way to resolve the array_flip() error in Drupal which flips string and
integer values?
Answers:
• Values of trans
need to be string or integer values; if any other type is there, then a warning
will be fired
• The array flip
function can also flip the nested array also
• It should use array for
the ID which are passed
• Pass only
values in the string rather than the array itself
35. Which of the following is the
correct way to get the current theme path in Drupal?
Answers:
• drupal_get_path()
• path_to_theme()
• theme_path()
•
drupal_get_path() without the variables.
36. What is the best way to display
the plain HTML content of view's node using only one .tpl.php file for all
views?
Answers:
• By using Ajax
we can pull the data from the node, and using the convention
mysite.com/node/1?ajax=1 to view the content
• By implementing both
hook_preprocess_page and hook_preprocess_html
• By implementing
hook_theme_registry_alter
• Placing a
phptemplate_views_view_unformatted_VIEWNAME call in template.php
37. How can the theme be changed in
Drupal using a Drush command?
Answers:
• drush -l
http://yoursitename.com/ pm-disable theme_name
• drush -l
http://yoursitename.com/ pm-enable theme_name
• drush -l
http://yoursitename.com/ vset theme_default theme_name
• drush –l
http://yoursitename.com/ settheme theme_name
38. How can a Drupal site be taken
offline or in maintenance mode using Drush?
Answers:
• drush vset site_offline 1
• drush vdel
site_offline
• drush vset
maintenance_mode 0
• drush
setoffline 1
39. Which of the following is the
correct function to get the current theme of a Drupal site?
Answers:
• path_to_theme()
• drupal_get_path
• global
$theme_path
• All of above
40. How can a module's data be exposed
to the Views 2 module using its API?
Answers:
• by using hook_views_data()
& hook_views_api()
• by using the
filefield_stats module
• by using the
viewsmodule_stats module
• by using a
built-in feature of the Views module, "expose filter"
41. What is the naming convention for
a preprocessor function for the CCK fields in Drupal if the template called
content-field-field_transmission_make_model.tpl?
Answers:
•
yourThemeName_preprocess_content_field_value(&$variables)
•
yourThemeName_preprocess_content_field(&$variables)
•
yourThemeName_preprocess_content_field_field_tramission_make_model(&$variables)
•
yourThemeName_preprocess_content_field_field_tramission_make_model()
42. Which of the following is the
correct way to include CSS and JavaScript files to a particular node in Drupal
6?
Answers:
• By using the node
preprocess function and adding the CSS and JavaScript files in the function
• By using the
direct drupal function to add the CSS and JavaScript in the body section itself
• By using the
drupal_get_css(); and drupal_get_js(); functions
• By creating
particular page for that node and using CSS and JavaScript in that page only
43. Which of the following is the
correct way to get the page URL of a page in Drupal?
Answers:
•
drupal_get_destination() is used to get the path.
• $link = url($path,
array('absolute' => TRUE));
• global
$base_root; $base_root . request_uri();
• $current_url =
'http://' .$_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI'];
44. How can a Drupal user's password
be reset using Drush from the command line in Drupal 6.x?
Answers:
• drush sqlq
"update {users} set pass=md5('new_password_here') where uid=1"
• drush user-password
someuser --password="new_password_here"
• Both A & B
• Cannot reset a
user's password using Drush from the command-line
45. What is the best way to set up
development for Drupal-based websites so that many developers can work on their
own copy and before updating the master/central copy?
Answers:
• By using the
Install Profile module
• By using the Features and
Strongarm Module
• By using the
svn:externals property
• By using the
CCK and Views module
46. How can an absolute date (as
opposed to a relative date, or the current date) be set as the default value
for a CCK datetime field in Drupal?
Answers:
• There is no option to set
an absolute date as the default value in a CCK date field
• By using
strtotime() in date field with exact date
• By using the
date picker to select exact date
• By going to the
configuration page of the CCK datetime module
47. What is the best way to create
multiple blocks from a single module?
Answers:
• Using module_hook_block
hook with $delta
• Setting an
option from the Drupal admin block page for any module
• Creating a
separate module for blocks
• Manually
updating drupal_block table to the number of blocks
48. Which of the following is the
correct way to change the execution order of Drupal modules?
Answers:
• Updating the module's
weight in the system table
• From the Drupal
admin panel module page
• Execution order
of Drupal modules can not be changed, it's always in alphabetical order
• Using the
_preprocess_node() hook of the particular module
49. How can a Drupal site be brought
out of maintenance mode?
Answers:
• By changing the
$maintance_mode variable in the settings.php file to FALSE.
• By changing the "Site
status" configuration in admin settings to "online".
• By removing the
maintenance-lock.php file from the root of the Drupal installation folder.
• By granting
"access site" permissions to anonymous users.
50. What is the best practice when
adding a div with some text at the end of a page?
Answers:
• Use function
drupal_add_js
• Use function
drupal_add_html
• Modify your theme's
page.tpl file
• Modify your
theme's footer.php file
51. Which of the following is the
correct way to enable special characters in Drupal user's URL?
Answers:
• Install Path auto module
and configure the special characters that you want to allow in the URL.
• Install User
Link module.
• Enable in the
admin settings.
• Can not do this
in Drupal.
52. Which of the following is the
correct way to get the node ID of the page being currently executed?
Answers:
• Using the arg() function
•
$node->currentNid
• $page->nid
• $_SERVER
['REQUEST_URI']
53. Which of the following is the
correct way to combine the values of two fields in one field display in Drupal
views, when using a field display style?
Answers:
• Overriding the
views-view-field.tpl file
• Overriding the
views-view.tpl.php file
• Selecting "rewrite
output" and placing the field token values together in the desired display
form
• Using the field
formatter
54. How can custom CSS rules be added
to a Drupal page (content) without using themes?
Answers:
• By using the
drupal_add_css() function
• Using the
<link> HTML tag
• Using the
<style> HTML tag
• You cannot add
custom CSS rules to Drupal pages
55. Which of the following is the best
way to pass arguments to the drupal_get_form() function?
Answers:
•
drupal_get_form(‘custom1_default_form’,$arg1,$arg2)
• drupal_get_form(‘custom1_default_form’,
array(‘arg1’=>’value’,’arg2’=>’value’))
•
drupal_get_form(‘custom1_default_form’,$arg1.$arg2)
• we cannot pass
arguments to drupal_get_form core function
56. Which of the following is the
correct way to add a user's first and last name in Drupal?
Answers:
• By enabling Profile
module. This module allows for fields to be added to users like first-name and
last-name.
• Must enable the
User Details module.
• Can not do this
for Drupal users.
• A and B
57. Each menu item has a key
corresponding to a Drupal path being registered in hook_menu. Which of
following is
not a key used to register a
path in hook_menu()?
Answers:
• file
• file path
• tab_root
• rule
58. How can a new element that was
created be validated, if hook_form_alter was used, and a new field was added to
an existing form?
Answers:
• Using
hook_validate
• Adding
$form['#validate'][] and writing the validation function
• Using
hook_check
• Such elements
cannot be validated
59. require './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$db_result = db_query('SELECT * FROM
{users}');
while($user_object =
db_fetch_object($db_result)){
// .. code here
}
Which of the following statement(s)
about the above code is/are true?
Answers:
• The code can be
written in the theme template.php file to fetch all users
• The code won't
run correctly; drupal_bootstrap can't run from an external script file
• The code can be
used in a custom module script to fetch all users
• The code can be used in an
external PHP file to fetch all users
60. Which of the following is the
correct way to install another Drupal that shares the same modules, themes,
libraries and core code of an existing site, while using a new database?
Answers:
• By installing
the Subdomain module and its required modules.
• By creating a new folder
in the 'sites' folder with the new domain name as folder name. Then, copy the
sites/default/default.settings.php file to the new folder. Run the install.php
script from the browser afterwards.
• By adding the
new site domain name as a key in the '$db_url' associative array in the
settings.php file.
• A single Drupal
code base cannot be used to host multiple sites.
61. Which of the following is the
correct method to fire another process when a new node is created in Drupal?
Answers:
• Use hook_nodeapi and
inside the insert handler add the code that you want to run after node
creation. Code below: function mymodule_nodeapi(&$node, $op, $a3 = NULL,
$a4 = NULL) { switch ($op) { case 'insert': // Add you code here break; } }
• Can do this in
the node settings and add the code there.
• In the admin
settings, add in the code that must be ran when the new node is done.
• B and C are
correct.
62. Which of the following is the
correct way to control the maximum character length in views, while displaying
field content?
Answers:
• Select
"exclude from display" and use token values to display fields
• Select "Trim this
field to a maximum length" and put the number of characters
• Select
"rewrite output" and write a PHP function for the maximum length
• Use the maximum
field formatter to restrict the character length
63. Suppose there is a new version for
a module that is installed on a Drupal 6 site. This new version contains some
database updates. Do those database updates need to be applied manually? If so,
how can those updates be applied?
Answers:
• It's not necessary
to apply database updates manually. Database updates will be applied during
automatic maintenance (cron).
• Run the update.php script
as soon as the previous version is replaced with the new version.
• Disable the
module and enable it again. New database updates will be applied when the
module is being enabled.
• Run the
db-updates.php file.
64. Is it possible to call Drupal
functions in external PHP files?
Answers:
• Yes. Bootstrap Drupal
functions in your external PHP file.
• Yes. Just place
the file inside the root directory of your Drupal installation.
• No.
• A and B are
correct.
65. Suppose the user is on the
folllowing URL:
http://example.com/blog/odesk-skills-test?page=1#comment-123
The above URL path is an alias of the
following URL path:
http://example.com/node/8
What would be the output of the
following code? (Assume it's placed in the node.tpl.php file)
$arg_0 = arg(0);
var_export($arg_0);
Answers:
• '1'
• 'node'
• 'blog'
•
'blog/odesk-skills-test'