Back End Specialist Practice Test

Question results

Score: 1 of 1

Question

Multiple choice question
You are going to print the following variable, and wish the html to be represented:
$data = '<strong>TEST</strong>';

Response

Your answerChoiceFeedbackCorrect answer
print t('This is a @data.', array('@data' => $data));
print t('This is a !data.', array('!data' => $data));
print t('This is a $data');
print t('This is a %data.', array('%data' => $data));
Score: 1 of 1

Question

Multiple choice question
Print user submitted data.

Response

Your answerChoiceFeedbackCorrect answer
print check_plain('Submitted data is: %data.', array('%data' => $submitted_data));
print t('Submitted data is: %data.', array('%data' => $submitted_data));
print check_plain('Submitted data is: ' . $submitted_data);
print t('Submitted data is: ' . $submitted_data);
Score: 1 of 1

Question

Multiple choice question
Which git command shows you all the files that will be removed that are not under version control, from the current directory?

Response

Your answerChoiceFeedbackCorrect answer
git clean -show
git clean -x
git clean -n
git clean -i
Score: 1 of 1

Question

Multiple choice question
Which git command cleans up unnecessary files and optimizes the local repository?

Response

Your answerChoiceFeedbackCorrect answer
git gc
git cleanup
git -gc
git -cleanup
Score: 1 of 1

Question

Multiple choice question
You have the following block of HTML from a view that, using jQuery, you need to add the class 'even' to each even row.
<div class="view-content">
  <div class="item-list">   
    <ul>         
      <li class="views-row views-row-1 views-row-odd views-row-first"> 
        <div class="views-field views-field-title">
          <span class="field-content">
            <a href="/node/10">Line 1</a>
          </span> 
        </div>
      </li>
      <li class="views-row views-row-2 views-row-even"> 
        <div class="views-field views-field-title">
          <span class="field-content">
            <a href="/node/11">Line 2</a>
          </span> 
        </div>
      </li>
      <li class="views-row views-row-3 views-row-odd"> 
        <div class="views-field views-field-title">
          <span class="field-content">
            <a href="/node/12">Line 3</a>
          </span> 
        </div>
      </li>
    </ul>
  </div>   
</div>

Response

Your answerChoiceFeedbackCorrect answer
$('.view-content li:not(even)').addClass('even');
$('.view-content li:even').addClass(.even);
$('.view-content li:even').addClass(even);
$('.view-content li:even').addClass('even');
Score: 1 of 1

Question

Multiple choice question

The following hook_form_alter() snippet passes the validation to function test_module_dev_form_validate(). Which block of code will successfully throw a form error if the word (case insensitve) Drupal is in the title?

function test_module_dev_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'article_node_form') {
    $form['#validate'][] = 'test_module_dev_form_validate';
  }
}

Response

Your answerChoiceFeedbackCorrect answer

function test_module_dev_form_validate($form, $form_state) {
  if (preg_match('/drupal/I', $form_state['values']['title'])) {
    form_set_error('title', t('You have added an invalid title.'));
  }
}

function test_module_dev_form_validate($form, &$form_state) {
  if (preg_match('/drupal/i', $form_state['values']['title'])) {
    form_set_error('title', t('You have added an invalid title.'));
  }
}

function test_module_dev_form_validate($form, &$form_state) {
  if (preg_match('/drupal/I', $form_state['values']['title'])) {
    form_set_error('title', t('You have added an invalid title.'));
  }
}

function test_module_dev_form_validate(&$form, &$form_state) {
  if (preg_match('/Drupal/', $form_state['values']['title'])) {
    form_set_error('title', t('You have added an invalid title.'));
  }
}

Score: 1 of 1

Question

Multiple choice question

You have a module that will create a page and place in the page the H1 elements surrounding the text This is a test. The page will also have the page title set to Test Page.
Here is your hook_menu().
Choose the appropriate function

function test_module_menu() {
  $items = array();
  $items['test'] = array(
    'title' => 'Test Module',
    'page callback' => 'test_module_page',
    'access arguments' => array('access test_module content'),
    'description' => 'This is a test Module',
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}

Response

Your answerChoiceFeedbackCorrect answer

function test_module_page() {
  drupal_set_title($title = 'Test Page', $output = CHECK_PLAIN);
  return 'This is a test.';
}

function test_module_page() {
  drupal_set_title($title = 'Test Page', $output = CHECK_PLAIN);
  print 'This is a test.';
}

function test_module_page() {
  set_title($title = 'Test Page', $output = CHECK_PLAIN);
  return 'This is a test.';
}

function test_module_page() {
  drupal_set_title($title = 'Test Page', $output = CHECK_PLAIN);
  return true;
}

Score: 1 of 1

Question

Multiple choice question

You are looking to delete multiple nodes of the Article content type. Select the correct code block.

Response

Your answerChoiceFeedbackCorrect answer

$type = "article";
$nodes = node_load_multiple(array('type' => $type));

$nids = array();
foreach ($nodes as $key => $value) {
    $nids[] = $value['nid'];
  }

node_delete_multiple($nids);

$type = "article";
$nodes = node_load_multiple(array(), array('type' => $type));

$nids = array();
foreach ($nodes as $key => $value) {
    $nids[] = $value->nid;
  }

node_delete_multiple($nids);

$type = "article";
$nodes = node_load_multiple(array(), array('type' => $type));

$nids = array();
foreach ($nodes as $key => $value) {
    $nids[] = $value['nid'];
  }

node_delete_multiple($nids);

$type = "article";
$nodes = node_load_multiple(array('type' => $type));

$nids = array();
foreach ($nodes as $key => $value) {
    $nids[] = $value->nid;
  }

node_delete_multiple($nids);

Score: 1 of 1

Question

Multiple choice question

You have a module file test.module that multiple people have been modifying, and see a line of code that does not meet the Drupal Coding Standards. You want to see who made the commit:

Response

Your answerChoiceFeedbackCorrect answer

git log --blame test.module

git show test.module

git --blame test.module

git blame test.module

Score: 1 of 1

Question

Multiple choice question

You would like to compare your master with the master that is in the repo

Response

Your answerChoiceFeedbackCorrect answer

git --show origin/master..master

git --show origin/master..master

git diff origin/master..master

git show origin/master-master

Score: 1 of 1

Question

Multiple choice question

You have found a bug in a module but unaware of which commit it was introduced. You can use:

Response

Your answerChoiceFeedbackCorrect answer

git show --error

git status --error

git log -error

git bisect

Score: 1 of 1

Question

Multiple choice question

You have a branch with unchecked files and would like to see which files would be removed upon cleaning.

Response

Your answerChoiceFeedbackCorrect answer

git clean -n

git clean -d

git clean -v

git clean --verify

Score: 1 of 1

Question

Multiple choice question

You have a file in the index that you would like to reset back into the working directory with the changes intact

Response

Your answerChoiceFeedbackCorrect answer

git reset

git reset head

git reset --keep

git reset --hard master

Score: 1 of 1

Question

Multiple choice question

You have found a typo in the file test_module.module and will look to submit a patch. You have edited the file and now:

Response

Your answerChoiceFeedbackCorrect answer

Create Issue at drupal.org
git diff > test_module-fixed-type-in-comment-block-[issue-number]-[comment-number].patch
git add test_module.modlue
git commit -m'Patch-[issue-number][comment-number]'
git push

Create Issue at drupal.org
git diff > test_module-fixed-type-in-comment-block-[issue-number]-[comment-number].patch

git diff > test_module-fixed-type-in-comment-block-[issue-number]-[comment-number].patch
Create Issue at drupal.org

Create Issue at drupal.org
git diff > test_module-fixed-type-in-comment-block-[issue-number]-[comment-number].patch
git commit -am'Patch-[issue-number][comment-number]'
git push

Score: 1 of 1

Question

Multiple choice question
Your client would like a randomly rotating slogan for their website using the Bootstrap theme. Using Drupal coding standards, your solution is:

Response

Your answerChoiceFeedbackCorrect answer
Edit the page.tpl.php and place the code:
        <?php if ($site_slogan): ?>
          <div id="site-slogan"<?php if ($hide_site_slogan) { print ' class="element-invisible"'; } ?>>
            <?php print getSlogan; ?>
          </div>
        <?php endif; ?>

<?php
function getSlogan() {
 
$slogans = array('Hi', 'Hello', 'Greetings');
 
$slogan = array_rand($slogans, 1);
  return
$slogans[$slogan];
}
?>
Edit the template.php and place the code:
function bootstrap_preprocess(&$vars, $hook) {
if ($hook == 'page') {
    $vars['site_slogan'] = getSlogan();
  }
}

function getSlogan() {
  $slogans = array('Hi', 'Hello', 'Greetings');
  $slogan = array_rand($slogans, 1);
  return $slogans[$slogan];
}
Edit the template.php and place the code:
function bootstrap_preprocess(&$vars, $hook) {
if ($hook == 'page') {
    $vars['site_slogan'] = getSlogan();
  }
}

function getSlogan() {
  $slogans = array('Hi', 'Hello', 'Greetings');
  $slogan = array_rand($slogans);
  return $slogan;
}
Edit the page.tpl.php and place the code:
        <?php if ($site_slogan): ?>
          <div id="site-slogan"<?php if ($hide_site_slogan) { print ' class="element-invisible"'; } ?>>
            <?php print getSlogan; ?>
          </div>
        <?php endif; ?>

<?php
function getSlogan() {
 
$slogans = array('Hi', 'Hello', 'Greetings');
 
$slogan = array_rand($slogans, 1);
  return
$slogan;
}
?>
Score: 1 of 1

Question

Multiple choice question

Which code block would return the time in unix format?

Response

Your answerChoiceFeedbackCorrect answer
<?php

/**
*  Create Time Object
*/

class getTime {
  public $time = "The time is now.";

/**
*  Get Time
*/
  public function getTimeNow() {
    $time = time('U');
    //return $time;
    $this->time = $time;
  }
}


$timeObj = new getTime();
echo $timeObj->time;
<?php

/**
*  Create Time Object
*/

class getTime {
  public $time = "The time is now.";

/**
*  Get Time
*/
  public function getTimeNow() {
    $time = time('U');
    //return $time;
    $this->time = $time;
  }
}


$timeObj = new getTime();

$timeObj->getTimeNow();

echo $timeObj->time;
<?php

/**
*  Create Time Object
*/

class getTime {
  public $time = "The time is now.";

/**
*  Get Time
*/
  public function getTimeNow() {
    $time = time('U');
    //return $time;
    $this->time = $time;
  }
}


$timeObj = new getTime();

$timeObj->getTimeNow();

echo $timeObj;
<?php

/**
*  Create Time Object
*/

class getTime {
  public $time = "The time is now.";

/**
*  Get Time
*/
  public function getTimeNow() {
    $time = time('U');
    //return $time;
    $this = $time;
  }
}


$timeObj = new getTime();

$timeObj->getTimeNow();

echo $timeObj->time;
Score: 1 of 1

Question

Multiple choice question
You have been tasked with placing footer text on a D7 site where both anonymous and authenticated users get different messages, using standard Drupal coding practices.

Response

Your answerChoiceFeedbackCorrect answer
edit template.php
function bootstrap_preprocess(&$vars, $hook) {

  if ($vars['logged_in']) {
      $vars['special_footer'] = t('Authenticated Footer Message');
    }
     else {
      $vars['special_footer'] = t('Anonymous Footer Message');
    }
  }
edit page.tpl.php
<footer class="footer container">
  <?php print $special_footer; ?>
</footer>
edit page.tpl.php
<footer class="footer container">
  <?php
 
global $user;
  if (
$user->uid > 0) {
      print
t('Authenticated Footer Message');
    }
     else {
      print
t('Anonymous Footer Message');
    }

 
?>

</footer>
edit page.tpl.php
<footer class="footer container">
  <?php

 
if ($vars['logged_in']) {
      print
t('Authenticated Footer Message');
    }
     else {
      print
t('Anonymous Footer Message');
    }

 
?>

</footer>
edit template.php
function bootstrap_preprocess(&$vars, $hook) {

  if ($vars['logged_in']) {
      $vars['special_footer'] = t('Authenticated Footer Message');
    }
     else {
      $vars['special_footer'] = t('Anonymous Footer Message');
    }
  }
edit page.tpl.php
<footer class="footer container">
  <?php print $vars['special_footer']; ?>
</footer>
Score: 1 of 1

Question

Multiple choice question

To conditionally add js to the theme:

Response

Your answerChoiceFeedbackCorrect answer

<?php
function test_them_preprocess_page(&$vars, $hook) {
  if (true) {
    drupal_add_js(drupal_get_path('theme', 'test_them') . '/test_them.js');
    $vars['scripts'] = drupal_get_js();
  }
}
?>

<?php
function test_them_preprocess_page(&$vars, $hook) {
  if (true) {
    add_js(drupal_get_path('theme', 'test_them') . '/test_them.js');
    $vars['scripts'] = drupal_get_js();
  }
}
?>

<?php
function test_them_preprocess_page(&$vars, $hook) {
  if (true) {
    add_js(get_path('theme', 'test_them') . '/test_them.js');
    $vars['scripts'] = get_js();
  }
}
?>

<?php
function test_them_preprocess_page(&$vars, $hook) {
  if (true) {
    drupal_add_js(get_path('theme', 'test_them') . '/test_them.js');
    $vars['scripts'] = get_js();
  }
}
?>

Score: 1 of 1

Question

Multiple choice question

You are adding jQuery to a theme's info file. Which info file would be correct?

Response

Your answerChoiceFeedbackCorrect answer

name = Test theme
description = Test theme under development
core = 7.x
engine = phptemplate
jQuery = test_theme.js

name = Test theme
description = Test theme under development
core = 7.x
engine = phptemplate
scripts = test_theme.js

name = Test theme
description = Test theme under development
core = 7.x
engine = phptemplate
scripts[] = test_theme.js

name = Test theme
description = Test theme under development
core = 7.x
engine = phptemplate
jQuery[] = test_theme.js

Score: 1 of 1

Question

Multiple choice question

To add javascript within a module, you could:

Response

Your answerChoiceFeedbackCorrect answer

<?php
drupal_add_js(drupal_get_path('module', 'custom_module') . '/custom_module.js');
?>

<?php
add_js(get_path('module', 'custom_module') . '/custom_module.js');
?>

<?php
add_js(drupal_get_path('module', 'custom_module') . '/custom_module.js');
?>

<?php
drupal_add_js(get_path('module', 'custom_module') . '/custom_module.js');
?>

Score: 1 of 1

Question

Multiple choice question

Select all li elements that are the first child of their parent

Response

Your answerChoiceFeedbackCorrect answer

$('li first-child')

$('li - first-child')

$('li::first-child')

$('li:first-child')

Score: 1 of 1

Question

Multiple choice question

Using proper PHP and Drupal coding standards, this block of code will delete content that match a criteria

Response

Your answerChoiceFeedbackCorrect answer

$num_deleted = db_delete('node')
  ->condition('nid', 5)
  ->execute();

$num_deleted = db_remove('node')
  ->condition('nid', 5)
  ->execute();

$num_deleted = db_remove('node'),
  ->condition('nid', 5),
  ->execute();

$num_deleted = db_delete('node'),
  ->condition('nid', 5),
  ->execute();

Score: 1 of 1

Question

Multiple choice question

git status gives you information, but it is vague. You need to see what exactly has changed in a file, your command would be:

Response

Your answerChoiceFeedbackCorrect answer

git -diff BRANCH

git compare diff

git -f diff

git diff

Score: 1 of 1

Question

Multiple choice question

Using PHP and Drupal Coding Standards, select the proper code block that successfully updates a table where the $date is less than 24 hours

Response

Your answerChoiceFeedbackCorrect answer

$field_change = db_update(custom_table)
  ->fields(array(
    'id' => 12,
    'status' => 0,
  ))
  ->condition('created', REQUEST_TIME - 3600, '=<')
  ->execute();

$field_change = db_update('custom_table')
  ->fields(array(
    'id' => 12,
    'status' => 0,
  ))
  ->condition('created', REQUEST_TIME - 3600, '=<')
  ->execute();

$field_change = db_update(custom_table)
  ->fields(array(
    'id' => 12,
    'status' => 0,
  ))
  ->condition('created', REQUEST_TIME - 3600, '<=')
  ->execute();

$field_change = db_update('custom_table')
  ->fields(array(
    'id' => 12,
    'status' => 0,
  ))
  ->condition('created', REQUEST_TIME - 3600, '<=')
  ->execute();

Score: 1 of 1

Question

Multiple choice question

You need to ignore a file called passwords.txt in your repo so that it is not commited to the public:

Response

Your answerChoiceFeedbackCorrect answer

create the .gitignore file in the .git/ directory and add the filename passwords.txt

Edit the .git/ingore.txt file and add the filename passwords.txt

git add -rm passwords.txt
git commit -m'removing passwords.txt from repo'
git push

Edit the .gitignore file and add the filename passwords.txt

Score: 1 of 1

Question

Multiple choice question

You want to see what branch you are currently working in:

Response

Your answerChoiceFeedbackCorrect answer

git show

git status

git details

git more

Score: 1 of 1

Question

Multiple choice question

You are going to clone a repo (REPO) into a directory called developer:

Response

Your answerChoiceFeedbackCorrect answer

You can only clone a repo into the directory you are running the git clone command

git clone REPO developer

git clone REPO -d developer

git clone REPO -D developer

Score: 1 of 1

Question

Multiple choice question

You are asked to clone down REPO and work in the developer branch. From the command line you would do:

Response

Your answerChoiceFeedbackCorrect answer

git clone REPO:developer

git clone REPO
git branch developer

git REPO
git ch branch developer

git get REPO:developer

Score: 1 of 1

Question

Multiple choice question

You are working in the developer branch and make a change to the settings.php. You need to merge this change into master and push back up.

Response

Your answerChoiceFeedbackCorrect answer

git add settings.php -f
git merge developer
git checkout master
git commit -m'settings.php edited'
git push

git add settings.php -f
git checkout master
git merge developer
git commit -m'settings.php edited'
git push

git add settings.php
git checkout master
git commit -m'settings.php edited'
git push

git add settings.php
git checkout master
git merge developer
git commit -m'settings.php edited'
git push

Score: 1 of 1

Question

Multiple choice question

You have enabled several modules, run update.php and refreshed the browser, only to be given a white screen of death. You...

Response

Your answerChoiceFeedbackCorrect answer

re-flush the cache

review the watchdog table

Inspect the browser for javascript error

Review the server error log

Score: 1 of 1

Question

Multiple choice question

You are pushing newly added files into a repository and find that someone else has added or edited files to the branch you are pushing to. You can push after you:

Response

Your answerChoiceFeedbackCorrect answer

git pull

git branch merge

git branch get

git merge

Score: 1 of 1

Question

Multiple choice question

You git clone a repository (REPO) and are asked to create a branch developer and push this branch back up.

Response

Your answerChoiceFeedbackCorrect answer

git clone REPO
git checkout -b developer

git push origin developer

git clone REPO

git checkout -b developer
git push origin developer

git clone REPO
git checkout -b developer

git add FILES_CHANGED
git commit -m'FILES CHANGED'
git push origin developer

git clone REPO
git checkout -b developer

git add FILES_CHANGED
git commit -m'FILES CHANGED'
git push

Score: 1 of 1

Question

Multiple choice question

Your have been told your developer changes are not needed and you can delete the branches you have made:

Response

Your answerChoiceFeedbackCorrect answer

git delete --delete developer

git delete origin --delete developer

git commit origin --delete developer

git push origin --delete developer

Score: 1 of 1

Question

Multiple choice question

You add and commit and file, then wish to add another file in that last commit:

Response

Your answerChoiceFeedbackCorrect answer

git commit -last

git commit -amend

git commit --last

git commit --amend

Score: 1 of 1

Question

Multiple choice question

Choose the correct code block representing proper PHP code AND adhering to Drupal Coding Standards

Response

Your answerChoiceFeedbackCorrect answer

$var=foo[$bar, $baz, $quux];

$var = foo($bar, $baz, $quux);

$var = foo[$bar, $baz, $quux];

$var = foo( $bar, $baz, $quux );

Score: 1 of 1

Question

Multiple choice question

Choose the correct code block representing proper PHP code AND adhering to Drupal Coding Standards

Response

Your answerChoiceFeedbackCorrect answer

// Implements hook_help().

function quiz_help($path, $arg) {
  // This is moved on an experimental basis.
  include_once DRUPAL_ROOT , '/' , drupal_get_path('module', 'quiz') , '/quiz.help.inc';
  return _quiz_help($path, $arg);
}

// Implements hook_help().

function quiz_help($path, $arg) {
  // This is moved on an experimental basis.
  include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'quiz') . '/quiz.help.inc';
  return _quiz_help($path, $arg);
}

/**
* Implements hook_help().
*/
function quiz_help($path, $arg) {
  // This is moved on an experimental basis.
  include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'quiz') . '/quiz.help.inc';
  return _quiz_help($path, $arg);
}

/**
* Implements hook_help().
*/
function quiz_help($path, $arg) {
  // This is moved on an experimental basis.
  include_once DRUPAL_ROOT , '/' , drupal_get_path('module', 'quiz') , '/quiz.help.inc';
  return _quiz_help($path, $arg);
}

Score: 1 of 1

Question

Multiple choice question

Choose the correct code block representing proper PHP code AND adhering to Drupal Coding Standards

Response

Your answerChoiceFeedbackCorrect answer

// Take Test.
$items['node/%node/take'] = array(
    'title' = 'Take',
    'page callback' = 'test_take',
    'page arguments' = array(1),
    'access callback' = 'test_take_access',
    'access arguments' = array(1),
    'type' = MENU_LOCAL_TASK,
  );

// Take Test.
$items['node/%node/take'] = array(
    'title' = 'Take',
    'page callback' = 'test_take',
    'page arguments' = array(1),
    'access callback' = 'test_take_access',
    'access arguments' = array(1),
    'type' = MENU_LOCAL_TASK,
  );

// Take Test.
$items['node/%node/take'] = array(
    'title' => 'Take';
    'page callback' => 'test_take';
    'page arguments' => array(1);
    'access callback' => 'test_take_access';
    'access arguments' => array(1);
    'type' => MENU_LOCAL_TASK;
  );

// Take Test.
  $items['node/%node/take'] = array(
    'title' => 'Take',
    'page callback' => 'test_take',
    'page arguments' => array(1),
    'access callback' => 'test_take_access',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
  );

Score: 1 of 1

Question

Multiple choice question

Choose the correct code block representing proper PHP code AND adhering to Drupal Coding Standards

Response

Your answerChoiceFeedbackCorrect answer

  // Apply test.
  $test = _quiz_load_user_settings(variable_get('test_def_uid', 1)) + _foo_get_node_test();
  while ($test as $key => $value) {
    if (!isset($node['$key'])) {
      $node['$key'] = $value;
    }
  }

  // Apply test.
  $test = _quiz_load_user_settings(variable_get('test_def_uid', 1)) + _foo_get_node_test();
  foreach ($test as $key => $value) {
    if (!isset($node->$key)) {
      $node->$key = $value;
    }
  }

  // Apply test.
  $test = _quiz_load_user_settings(variable_get('test_def_uid', 1)) + _foo_get_node_test();
  foreach($test as $key => $value){
    if(!isset($node->$key)){
      $node->$key = $value;
    }
  }

  // Apply test.
  $test = _quiz_load_user_settings(variable_get('test_def_uid', 1)) + _foo_get_node_test();
  while($test as $key => $value){
    if(!isset($node->$key)){
      $node->$key = $value;
    }
  }

Score: 1 of 1

Question

Multiple choice question

You are asked to setup a new Drupal site with a table prefix of devel_. Choose below the proper resulting table names

Response

Your answerChoiceFeedbackCorrect answer

devel_cache
devel_node
devel_node_revision
devel_system
devel_variable
devel_watchdog

cache
devel_node
devel_node_revision
system
devel_variable
devel_watchdog

devel_cache
node
devel_node_revision
system
variable
devel_watchdog

devel_cache
devel_node
devel_node_revision
system
variable
devel_watchdog

Score: 1 of 1

Question

Multiple choice question

Using proper PHP and Drupal Coding Standards, choose the best block to insert data into a table.

Response

Your answerChoiceFeedbackCorrect answer

$nid = db_insert('custom_table')
  ->fields(array(
    'field1' = 'Example';
    'field2' = 1;
    'created' = NOW();
  ))
  ->execute();

$nid = db_insert(custom_table)
  ->fields(array(
    'field1' = 'Example';
    'field2' = 1;
    'created' = NOW();
  ))
  ->execute();

$nid = db_insert('custom_table')
  ->fields(array(
    'field1' => 'Example',
    'field2' => 1,
    'created' => NOW(),
  ))
  ->execute();

$nid = db_insert(custom_table),
  ->fields(array(
    'field1' => 'Example',
    'field2' => 1,
    'created' => NOW(),
  ))
  ->execute();

Score: 1 of 1

Question

Multiple choice question

Using proper PHP and Drupal coding standards, this block of code will create an array of node titles from the page content type.

Response

Your answerChoiceFeedbackCorrect answer

$nodes = db_query('SELECT title FROM {node} WHERE type = :type', array(':type' => 'page'))->fetchAll();

$nodes = db_query('SELECT {title} FROM node WHERE type = :type', array(':type' => 'page'))->fetchAll();

$nodes = db_query('SELECT title FROM node WHERE type = :type', array(':type' => 'page'))->fetchAll();

$nodes = db_query('SELECT title FROM node WHERE type = {:type}', array(':type' => 'page'))->fetchAll();

Score: 1 of 1

Question

Multiple choice question
The following queries must only be dynamic queries

Response

Your answerChoiceFeedbackCorrect answer
Insert Select Delete
Insert Update Merge
Select Delete Update
Select Insert Delete Merge
Score: 1 of 1

Question

Multiple choice question
This function will load after all the modules are loaded into memory

Response

Your answerChoiceFeedbackCorrect answer
load_boot()
hook_init()
hook_boot()
load_init()
Score: 1 of 1

Question

Multiple choice question
This hook will not run on cached pages

Response

Your answerChoiceFeedbackCorrect answer
load_init()
hook_init()
cach_init()
hook_boot()
Score: 1 of 1

Question

Multiple choice question
Even on cached pages, this function is still called

Response

Your answerChoiceFeedbackCorrect answer
hook_cach_load()
hook_init()
hook_boot()
boot_cache()
Score: 1 of 1

Question

Multiple choice question
This function is called before modules are loaded into memory

Response

Your answerChoiceFeedbackCorrect answer
hook_load()
hook_init()
boot()
hook_boot()
Score: 1 of 1

Question

Multiple choice question
You have a custom module that requires code to run while Drupal is still in bootstrap mode

Response

Your answerChoiceFeedbackCorrect answer
bootstrap()
hook_init()
hook_boot()
boot()
Score: 1 of 1

Question

Multiple choice question
Which block of code represents the Drupal's Best Practices?

Response

Your answerChoiceFeedbackCorrect answer
class CheckSubmission {
  public $prop;

  function construct($title) {

  }

  private function ParseCode($test) {

  }

  private function CallBlock($newval)
  {

  }

}
class CheckSubmission {
  public $prop;

  function construct($title) {

  }

  private function parseCode($test) {

  }

  private function callBlock($newval)
  {

  }

}
class checksubmission {
  public $prop;

  function __construct($title) {

  }

  private function parsecode($test) {

  }

  private function callblock($newval)
  {

  }

}
class CheckSubmission {
  public $prop;

  function __construct($title) {

  }

  private function parseCode($test) {

  }

  private function callBlock($newval)
  {

  }

}
Score: 1 of 1

Question

Multiple choice question
To increase performance in module development, which hook_menu() block would be the correct way?

Response

Your answerChoiceFeedbackCorrect answer
$item['admin/custom_module/config'] =  array(
      'title' => t('Configuration'),
      'description' => t('Custom module configuration'),
      'page callback' => 'custom_module_config',
      'access arguments' => array('access administration pages'),
      'file' => 'custom_module.admin.inc',
      'file path' => drupal_get_path('module', 'custom_module'),
    );
$item['admin/custom_module/config'] =  array(
      'title' => t('Configuration'),
      'description' => t('Custom module configuration'),
      'page callback' => 'custom_module_config',
      'access arguments' => array('access administration pages'),
      'cache' => 'custom_module.admin.inc',
      'cache path' => drupal_get_path('module', 'custom_module'),
    );
$item['admin/custom_module/config'] =  array(
      'title' => t('Configuration'),
      'description' => t('Custom module configuration'),
      'page callback' => 'custom_module_config',
      'access arguments' => array('access administration pages'),
      'cache' => 'custom_module.admin.inc',
    );
$item['admin/custom_module/config'] =  array(
      'title' => t('Configuration'),
      'description' => t('Custom module configuration'),
      'page callback' => 'custom_module_config',
      'access arguments' => array('access administration pages'),
      'cache' => TRUE,
    );
Score: 1 of 1

Question

Multiple choice question

You want to strip out some but not all markup when printing user submitted data

Response

Your answerChoiceFeedbackCorrect answer
print markup($text, $format_id, $langcode = '', $cache = FALSE);
print filter_markup($text, $format_id, $langcode = '', $cache = FALSE);
print check_markup($text, $format_id, $langcode = '', $cache = FALSE);
print t(:text, array('@text'));
Score: 1 of 1

Question

Multiple choice question
You wish to pass text to a url you are printing

Response

Your answerChoiceFeedbackCorrect answer
url() funtion
l_text() funtion
url_text() funtion
l() funtion
Score: 1 of 1

Question

Multiple choice question
Placing the url() within a t() function

Response

Your answerChoiceFeedbackCorrect answer
print t("Click <a href=":url">here</a> for more", array(':url' => url('more_information')));
print t(Click <a href="!url">here</a> for more', array('!url' => 'more'));
You can not place the url() function within the l() function.
print t(Click <a href="' . $url . '">here</a> for more');
Score: 1 of 1

Question

Multiple choice question
To create an accurate path no matter where Drupal is installed, use

Response

Your answerChoiceFeedbackCorrect answer
l() function and url() function with $absolute = TRUE
l() function only
l() and url() functions
url() function only
Score: 1 of 1

Question

Multiple choice question
When an outside form is posting malious content into your site, the attack is

Response

Your answerChoiceFeedbackCorrect answer
XSS
CSRF
Remote Form Attack
XXS
Score: 1 of 1

Question

Multiple choice question
Which function checks form posted data to confirm it is posted from within the Drupal site?

Response

Your answerChoiceFeedbackCorrect answer
drupal_token()
drupal_check_form()
drupal_get_token()
drupal_check_token()
Score: 1 of 1

Question

Multiple choice question
Choose the code that will not show Tab 2 to anonymous users

Response

Your answerChoiceFeedbackCorrect answer
<?php
/**
* @file
* Test page with Tabs
*
*/

/**
* hook_menu();
*/
function test_menu() {
  $items = array();
  $item['test'] =  array(
    'title' => t('Configuration'),
    'description' => t('Custom module'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('add_component_form'),
    'access callback' => TRUE,
    );

  $item['test/tab1'] =  array(
    'title' => t('Tab 1'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
    );


  $item['test/tab2'] =  array(
    'title' => t('Tab 2'),
    'description' => t('Custom module Tab1'),
    'page callback' => 'test_string',
    'type' => MENU_LOCAL_TASK,
    'access arguments' => array('administer'),
    );

return $item;
}

/**
* Fake form
*/
function add_component_form($form, &$form_state){
  //dpm($form_state);

  $form = array();
  $form['Test'] = array(
    '#name' => 'Test',
    '#type' => 'textfield',
    '#title' => 'Test',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#title' => 'Submit',
    '#value' => 'Submit',
    );
  dpm($form);
  return $form;
}

/**
* Fake Content
*/
function test_string() {
  $output = 'This is a test.';
  return $output;
}
<?php
/**
* @file
* Test page with Tabs
*
*/

/**
* hook_menu();
*/
function test_menu() {
  $items = array();
  $item['test'] =  array(
    'title' => t('Configuration'),
    'description' => t('Custom module'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('add_component_form'),
    'access callback' => TRUE,
    );

  $item['test/tab1'] =  array(
    'title' => t('Tab 1'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
    );


  $item['test/tab2'] =  array(
    'title' => t('Tab 2'),
    'description' => t('Custom module Tab1'),
    'page callback' => 'test_string',
    'type' => MENU_LOCAL_TASK,
    'access arguments' => array('administer'),
    'access callback' => TRUE,
    );

return $item;
}

/**
* Fake form
*/
function add_component_form($form, &$form_state){
  //dpm($form_state);

  $form = array();
  $form['Test'] = array(
    '#name' => 'Test',
    '#type' => 'textfield',
    '#title' => 'Test',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#title' => 'Submit',
    '#value' => 'Submit',
    );
  dpm($form);
  return $form;
}

/**
* Fake Content
*/
function test_string() {
  $output = 'This is a test.';
  return $output;
}
Score: 1 of 1

Question

Multiple choice question
You need to create a template suggestion for the Article node content type using best practices

Response

Your answerChoiceFeedbackCorrect answer
node--article.tpl.php
node.tpl.php PHP case/switch code to choose $node->type to 'article'
node-article.tpl.php
article.tpl.php
Score: 1 of 1

Question

Multiple choice question
In the browser inspector you see a CSS element is crossed out. This is because:

Response

Your answerChoiceFeedbackCorrect answer
The css element is not compatable with the current browser
The element is being overwritten by another element
The css element is not in the aggregation
The CSS element is not properly cached
Score: 1 of 1

Question

Multiple choice question
You have a CSS element that is crossed out and you want it test it by forcing the element, you:

Response

Your answerChoiceFeedbackCorrect answer
Add the important tag to the element
Add the !important tag to the element
You can not force a crossed element to show
Add the important! tag to the element
Score: 1 of 1

Question

Multiple choice question
You have made a change to the CSS but do not notice the change in the page

Response

Your answerChoiceFeedbackCorrect answer
Set the !important tag to the new CSS
Move new CSS code to the top of the script
Ensure all caching is turned off
Turn off aggregation
Score: 0 of 1

Question

Multiple choice question
In chaining a db_select(), pagnation is called with:

Response

Your answerChoiceFeedbackCorrect answer
   $query = db_select('node')
            ->fields('node')
            ->page('PagerDefault')
            ->limit(10);
           
   $query = db_select('node')
            ->fields('node')
            ->extend('Pager')
            ->limit(10);
   $query = db_select('node')
            ->fields('node')
            ->page('Pager')
            ->limit(10);
           
   $query = db_select('node')
            ->fields('node')
            ->extend('PagerDefault')
            ->limit(10);
           
Score: 1 of 1

Question

Multiple choice question
Choose correct block in template file that will print the variable $content_title if it exists

Response

Your answerChoiceFeedbackCorrect answer
<?php if ($content_title) = ?>
  <h2><? print $content_title; ?>
<?php endif; ?>
           
<?php if {$content_title}: ?>
  <h2><? print $content_title; ?>
<?php endif; ?>
           
<?php if ($content_title): ?>
  <h2><? print $content_title; ?>
<?php endif; ?>
           
<?php if ($content_title): ?>
  <h2><? print $content_title; ?>
<?php :endif; ?>
           
Score: 1 of 1

Question

Multiple choice question
Which is the correct function that populates the variable $list_of_friends, performance in mind

Response

Your answerChoiceFeedbackCorrect answer
/**
*  Get a list of friends
*/

function custom_module_gets_list() {
  static $list_of_friends;
  if ($list_of_friends == null) {
    $list_of_friends = custom_get_the_list();
  }
}
/**
*  Get a list of friends
*/

function custom_module_gets_list() {
  cache $list_of_friends;
  if ($list_of_friends == null) {
    $list_of_friends = custom_get_the_list();
  }
}
/**
*  Get a list of friends
*/

function custom_module_gets_list() {
  cache $list_of_friends;
  if (cache($list_of_friends) == null) {
    $list_of_friends = custom_get_the_list();
  }
}
/**
*  Get a list of friends
*/

function custom_module_gets_list() {
  if (!static($list_of_friends)) {
    $list_of_friends = custom_get_the_list();
  }
}
Score: 1 of 1

Question

Multiple choice question

You would like absolute path for custom/test_page

Response

Your answerChoiceFeedbackCorrect answer
$url = l('custom/test_page', array('absolute'));
$url = url('custom/test_page', array('absolute'));
$url = url('custom/test_page');
$url = url('custom/test_page', array('absolute' => TRUE));
Score: 1 of 1

Question

Multiple choice question

You need to print the absolute path to custom/test_page and pass a query string where page = test

Response

Your answerChoiceFeedbackCorrect answer
print url('custom/test_page', array('absolute' => TRUE, 'query?' => array('page' => 'test')));
print url('custom/test_page', array('query' => array('page' => 'test')));
print url('custom/test_page', array('absolute' => TRUE, 'query' => array('page' => 'test')));
print url('custom/test_page', array('absolute' => TRUE, 'query' => 'page' = 'test'));
Score: 0 of 1

Question

Multiple choice question

Print a link "Click Here" to a path of custom/page with a target of _blank

Response

Your answerChoiceFeedbackCorrect answer
print l('Click Here', 'custom/page', array('attributes' => 'target' = '_blank'));
print l('Click Here', 'custom/page', array('attributes' => array('target' => '_blank')));
print l('Click Here', 'custom/page', 'attributes' = array('target' => '_blank'));
print l('Click Here', array('custom/page', array('attributes' => array('target' => '_blank'))));
Score: 1 of 1

Question

Multiple choice question

Point the text Click Here to the path custom/page with the anchor tag of footer

Response

Your answerChoiceFeedbackCorrect answer
print l('Click Here', 'custom/page', 'anchor' => 'footer');
print l('Click Here', 'custom/page', 'fragment' => 'footer');
l('Click Here', 'custom/page', array('fragment' => 'footer'));
print l('Click Here', 'custom/page', array('anchor' => 'footer'));
Score: 1 of 1

Question

Multiple choice question
Using the t() function, which line will highlight the passed variable?

Response

Your answerChoiceFeedbackCorrect answer
print t('This is a %text', array('%text' => 'Test'))
print t('This is a %text', '%text' => 'Test');
print t('This is a @text', array('@text' => 'Test'));
print t('This is a !text', array('!text' => 'Test'));
Score: 1 of 1

Question

Multiple choice question
You need to get a custom variable, test_count, increment by one and save the new value

Response

Your answerChoiceFeedbackCorrect answer
$count = variable_get('test_count', 0); variable_set('test_count', array($count++));
$count = variable_get('test_count', 0); variable_set('test_count', $count++);
$count = variable_get('test_count', 0); $count++; variable_set('test_count', $count);
$count = variable_get('test_count', 0); $count++; $count = variable_set('test_count', $count);
Score: 1 of 1

Question

Multiple choice question

Choose the proper form validation block of code and set an error on the offending field.

Response

Your answerChoiceFeedbackCorrect answer
/**
* Validation for test_module_form()
*/
function test_module_form_validate($form, &$form_state) {
  if ($form_state['input']['name'] == 'admin') {
    form_set_error('name', 'You are not supposed to be admin.');
  }
}
/**
* Validation for test_module_form()
*/
function test_module_form_validate($form, &$form_state) {
  if ($form_state['values']['name'] == 'admin') {
    form_set_error('name', 'You are not supposed to be admin.');
  }
}
/**
* Validation for test_module_form()
*/
function test_module_form_validate($form, &$form_state) {
  if ($form_state['values']['name'] == 'admin') {
    drupal_set_error('name', 'You are not supposed to be admin.');
  }
}
/**
* Validation for test_module_form()
*/
function test_module_form_validate($form, &$form_state) {
  if ($form_state['input']['name'] == 'admin') {
    drupal_set_error('name', 'You are not supposed to be admin.');
  }
}
Score: 1 of 1

Question

Multiple choice question
Choose the appropriate block of code the successfully submits a form and safely prints the user submitted data.

Response

Your answerChoiceFeedbackCorrect answer
/**
* Submit function for test_module_form()
*/
function test_module_form_submit($form, &$form_state) {
    drupal_set_message('Thank you !name', array('!name' => $form_state['values']['name']));
}
/**
* Submit function for test_module_form()
*/
function test_module_form_submit($form, &$form_state) {
    drupal_set_message('Thank you ' . $form_state['values']['name']);
}
/**
* Submit function for test_module_form()
*/
function test_module_form_submit($form, &$form_state) {
    drupal_set_message('Thank you ' . %name, array(%name => $form_state['values']['name']));
}
/**
* Submit function for test_module_form()
*/
function test_module_form_submit($form, &$form_state) {
    drupal_set_message('Thank you @name', array('@name' => $form_state['values']['name']));
}
Score: 1 of 1

Question

Multiple choice question
Convert a flat array
$array1 = array('Item 1', 'Item 2', 'Item 3');
into an associative array

Response

Your answerChoiceFeedbackCorrect answer
$array2 = map_assoc($array1, $function = NULL);
$array2 = drupal_assoc($array1, $function = NULL);
$array2 = drupal_map_assoc($array1, $function = NULL);
$array2 = drupal_assoc_map($array1, $function = NULL);