} } ?> </div> <div class="nav_links"> <?php $reg_link = '<a class="nav_link" href="' . iclicker_service::block_url('registration.php') . '">' . iclicker_service::msg('reg.title') . '</a>'; $nav_links = $reg_link . PHP_EOL; // the other links $nav_links .= ' | <a class="nav_link current_nav_link" href="' . iclicker_service::block_url('instructor.php') . '">' . iclicker_service::msg('inst.title') . '</a>' . PHP_EOL; if (iclicker_service::$block_iclicker_sso_enabled) { $nav_links .= ' | <a class="nav_link" href="' . iclicker_service::block_url('instructor_sso.php') . '">' . iclicker_service::msg('inst.sso.title') . '</a>' . PHP_EOL; } if (iclicker_service::is_admin()) { $nav_links .= ' | <a class="nav_link" href="' . iclicker_service::block_url('admin.php') . '">' . iclicker_service::msg('admin.title') . '</a>' . PHP_EOL; } echo $nav_links; ?> </div> <div class="iclicker_version">Version <?php echo iclicker_service::VERSION; ?> (<?php echo iclicker_service::BLOCK_VERSION; ?> )</div> </div>
</div> </div> <script type="text/javascript"> jQuery(document).ready(function () { // date pickers jQuery(".iclicker .date_picker_marker").datepicker({ dateFormat: "yy-mm-dd", changeMonth: true, changeYear: true }); // purge confirmation jQuery("#purgeFormSubmit").click(function (e) { if (!confirm("<?php echo iclicker_service::msg('admin.search.purge.confirm', $total_count); ?> ")) { e.preventDefault(); return false; } else { // switch the form to POST for purge submission $(this).closest("form").attr("method", "POST"); } return true; }); }); </script> <?php echo $OUTPUT->footer();
/** * Add an i18n message based on a key * * @param string $key the KEY const * @param string $messageKey the i18n message key * @param object $args [OPTIONAL] args to include * @param string $extra [OPTIONAL] extra string to include hidden on the page with the message * @throws Exception if the key is invalid */ public function addMessage($key, $messageKey, $args = null, $extra = null) { if ($key == null) { throw new Exception("key (" . $key . ") must not be null"); } if ($messageKey) { $message = iclicker_service::msg($messageKey, $args); $this->addMessageStr($key, $message, $extra); } }
// invalid clicker id $message = iclicker_service::msg('reg.registered.clickerId.invalid', $cr->clicker_id); } catch (InvalidArgumentException $e) { // invalid user id $message = "Student not found in the CMS"; } catch (ClickerRegisteredException $e) { // already registered $key = ''; if ($e->owner_id == $e->registered_owner_id) { // already registered to this user $key = 'reg.registered.below.duplicate'; } else { // already registered to another user $key = 'reg.registered.clickerId.duplicate.notowned'; } $message = iclicker_service::msg($key, $cr->clicker_id); } $registrations = iclicker_service::get_registrations_by_user($owner_id, true); $output = iclicker_service::encode_registration_result($registrations, $reg_status, $message); if ($reg_status) { $status = 200; //OK; } else { $status = 400; //BAD_REQUEST; } } else { // UNKNOWN $valid = false; $output = "Unknown path ({$cntlr->path}) specified for method POST"; $status = 404;
</div> </div> </div> <div class="nav_links"> <?php $reg_link = '<a class="nav_link current_nav_link" href="' . iclicker_service::block_url('registration.php') . '">' . iclicker_service::msg('reg.title') . '</a>'; $nav_links = $reg_link . PHP_EOL; // the other links if (iclicker_service::is_admin()) { $nav_links .= ' | <a class="nav_link" href="' . iclicker_service::block_url('admin.php') . '">' . iclicker_service::msg('admin.title') . '</a>' . PHP_EOL; } else { if (iclicker_service::is_instructor()) { $nav_links .= ' | <a class="nav_link" href="' . iclicker_service::block_url('instructor.php') . '">' . iclicker_service::msg('inst.title') . '</a>' . PHP_EOL; if (iclicker_service::$block_iclicker_sso_enabled) { $nav_links .= ' | <a class="nav_link" href="' . iclicker_service::block_url('instructor_sso.php') . '">' . iclicker_service::msg('inst.sso.title') . '</a>' . PHP_EOL; } } } echo $nav_links; ?> </div> <div class="iclicker_version">Version <?php echo iclicker_service::VERSION; ?> (<?php echo iclicker_service::BLOCK_VERSION; ?> )</div>
/** * Determines the content to display in a block * * Blocks use two properties of $this->content: "text" and "footer". * The text is displayed as-is as the block content, and the footer is displayed below the content in a smaller font size. * * List blocks use $this->content->footer in the exact same way, * but they ignore $this->content->text. * Moodle expects such blocks to set two other properties when the get_content() method is called: * $this->content->items and $this->content->icons. * $this->content->items should be a numerically indexed array containing elements that * represent the HTML for each item in the list that is going to be displayed. * Usually these items will be HTML anchor tags which provide links to some page. * $this->content->icons should also be a numerically indexed array, with exactly as many items * as $this->content->items has. Each of these items should be a fully qualified HTML <img> tag, * with "src", "height", "width" and "alt" attributes. Obviously, it makes sense to keep the images * small and of a uniform size. * In order to tell Moodle that we want to have a list block instead of the standard text block, * we need to make a small change to our block class declaration. * Instead of extending class block_base, our block will extend class block_list. * * You can hide the block by displaying nothing. That means that both * $this->content->text and $this->content->footer are each equal to the * empty string (''). Moodle performs this check by calling the block's * is_empty() method, and if the block is indeed empty then it is not * displayed at all. * * @return string the content to display in the block */ function get_content() { // for iclicker we will just render links here and possibly an indicator to show if you have registered a clicker global $CFG, $USER, $COURSE; if ($this->content !== null) { return $this->content; } $this->content = new stdClass(); $this->content->text = ''; if (iclicker_service::get_current_user_id()) { $this->content->text = "<div class='iclicker_nav_items'>\n"; $reg_link = '<a href="' . iclicker_service::block_url('registration.php') . '">' . iclicker_service::msg('reg.title') . '</a><br/>'; $this->content->text .= " " . $reg_link . "\n"; // also show the list of currently registered clickers $clicker_list_html = ''; if ($clickers = iclicker_service::get_registrations_by_user(null, true)) { $clicker_list_html .= " <ul class='iclicker_clickerids'>" . PHP_EOL; foreach ($clickers as $clicker) { $clicker_list_html .= " <li class='iclicker_clickerid'>{$clicker->clicker_id}</li>" . PHP_EOL; } $clicker_list_html .= " </ul>\n"; } $this->content->text .= $clicker_list_html; // the other links if (iclicker_service::is_admin()) { $link = '<a href="' . iclicker_service::block_url('admin.php') . '">' . iclicker_service::msg('admin.title') . '</a><br/>' . PHP_EOL; $this->content->text .= " " . $link . "\n"; // remove inst link after testing complete //$link = '<b><i>remove inst link</i></b> <a href="'.iclicker_service::block_url('instructor.php').'">'.iclicker_service::msg('inst.title').'</a>'; //$this->content->text .= " ".$link."\n"; } else { if (iclicker_service::is_instructor()) { $link = '<a href="' . iclicker_service::block_url('instructor.php') . '">' . iclicker_service::msg('inst.title') . '</a><br/>' . PHP_EOL; $sso_link = ''; if (iclicker_service::$block_iclicker_sso_enabled) { $sso_link = '<a class="nav_link" href="' . iclicker_service::block_url('instructor_sso.php') . '">' . iclicker_service::msg('inst.sso.title') . '</a><br/>' . PHP_EOL; } $this->content->text .= ' ' . $link . $sso_link; } } // close out the html $this->content->text .= "</div>" . PHP_EOL; } // FOOTER //$this->content->footer = '<a href="'.$CFG->wwwroot.'/blocks/iclicker/page.php?blockid='.$this->instance->id.'&courseid='.$COURSE->id.'">'.get_string('addpage', 'block_iclicker').'</a>'; $this->content->footer = ''; // Sample list items //$this->content->items[] = '<a href="some_file.php">Menu Option 1</a>'; //$this->content->icons[] = '<img src="images/icons/1.gif" class="icon" alt="" />'; return $this->content; }