Front End Specialist Test

Question results

Score: 0 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 answerChoice
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>
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 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>
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 answerChoice
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 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 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;
}
?>
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];
}
?>
Score: 0 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 answerChoice

git reset --keep

git reset --hard master

git reset

git reset head

Score: 0 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 answerChoice

git clean -d

git clean -n

git clean -v

git clean --verify

Score: 0 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 answerChoice

git status --error

git bisect

git log -error

git show --error

Score: 0 of 1

Question

Multiple choice question

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

Response

Your answerChoice

git --show origin/master..master

git diff origin/master..master

git show origin/master-master

git --show origin/master..master

Score: 0 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 answerChoice

git blame test.module

git --blame test.module

git log --blame test.module

git show test.module

Score: 1 of 1

Question

Multiple choice question

To conditionally add js to the theme:

Response

Your answerChoice

<?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(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();
  }
}
?>

<?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();
  }
}
?>

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 answerChoice

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

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 answerChoice

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

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

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

<?php
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 answerChoice

$('li first-child')

$('li:first-child')

$('li - first-child')

$('li::first-child')

Score: 0 of 1

Question

Multiple choice question

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

Response

Your answerChoice

git details

git show

git status

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 answerChoice

git clone REPO developer

git clone REPO -d developer

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

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 answerChoice

git get REPO:developer

git REPO
git ch branch developer

git clone REPO:developer

git clone REPO
git branch developer

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 answerChoice

git pull

git branch merge

git merge

git branch get

Score: 0 of 1

Question

Multiple choice question

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

Response

Your answerChoice

git commit --amend

git commit -amend

git commit --last

git commit -last