Pages

Friday, March 18, 2016

Drupal Test 2016 | Drupal Test upwork Answer

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

No comments:

Post a Comment