// You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. function print_action($action, $url) { global $OUTPUT; return html_writer::link($url, $OUTPUT->pix_icon("t/{$action}", "{$action}")); } $edit = get_string('edit'); $delete = get_string('delete'); $view = get_string('view'); $polls = $DB->get_records('block_poll', array('courseid' => $COURSE->id)); // TODO: Use html_table. $table = new html_table(); $table->head = array(get_string('editpollname', 'block_poll'), get_string('editpolloptions', 'block_poll'), get_string('responses', 'block_poll'), get_string('action')); $table->align = array('left', 'right', 'right', 'left'); $table->tablealign = 'left'; $table->width = '*'; if ($polls !== false) { foreach ($polls as $poll) { $options = $DB->get_records('block_poll_option', array('pollid' => $poll->id)); $responses = $DB->get_records('block_poll_response', array('pollid' => $poll->id)); $urlpreview = clone $url; $urlpreview->params(array('action' => 'responses', 'pid' => $poll->id)); $urledit = clone $url; $urledit->params(array('action' => 'editpoll', 'pid' => $poll->id)); $urldelete = new moodle_url('/blocks/poll/poll_action.php', array('action' => 'delete', 'id' => $cid, 'pid' => $poll->id, 'instanceid' => $instanceid)); $action = print_action('preview', $urlpreview) . print_action('edit', $urledit) . print_action('delete', $urldelete); $table->data[] = array($poll->name, !$options ? '0' : count($options), !$responses ? '0' : count($responses), $action); } } echo html_writer::table($table);
/** * @param $edit_page * @param $obsolete_flag */ function print_versions($edit_page, $obsolete_flag) { $specmanagement_database_api = new specmanagement_database_api(); $specmanagement_print_api = new specmanagement_print_api(); $obsolote = false; if ($obsolete_flag) { $obsolote = null; } if ($edit_page) { $versions = version_get_all_rows_with_subs(helper_get_current_project(), null, null); } else { $versions = version_get_all_rows_with_subs(helper_get_current_project(), null, $obsolote); } for ($version_index = 0; $version_index < count($versions); $version_index++) { $version = $versions[$version_index]; $current_type = $specmanagement_database_api->get_type_string($specmanagement_database_api->get_type_by_version($version['id'])); $specmanagement_print_api->printRow(); echo '<input type="hidden" name="version_ids[]" value="' . $version['id'] . '"/>'; print_name($edit_page, $version); print_released($edit_page, $version_index, $version); print_obsolete($edit_page, $version_index, $version); print_date($edit_page, $version); print_type($edit_page, $current_type, $version); print_description($edit_page, $version); print_action($edit_page, $version); echo '</tr>'; } }
<?php // Paul Holden 24th July, 2007 // poll block; poll management tab function print_action($action, $url) { global $CFG; return "<a href=\"{$url}\"><img src=\"{$CFG->pixpath}/t/{$action}.gif\" alt=\"\" /></a> "; } $edit = get_string('edit'); $delete = get_string('delete'); $view = get_string('view'); $polls = get_records('block_poll', 'courseid', $COURSE->id); $table = new Object(); $table->head = array(get_string('editpollname', 'block_poll'), get_string('editpolloptions', 'block_poll'), get_string('responses', 'block_poll'), get_string('action')); $table->align = array('left', 'right', 'right', 'left'); $table->tablealign = 'left'; $table->width = '*'; foreach ($polls as $poll) { $options = get_records('block_poll_option', 'pollid', $poll->id); $responses = get_records('block_poll_response', 'pollid', $poll->id); $action = print_action('preview', "{$url}responses&pid={$poll->id}") . print_action('edit', "{$url}editpoll&pid={$poll->id}") . print_action('delete', "{$CFG->wwwroot}/blocks/poll/poll_action.php?id={$COURSE->id}&instanceid=" . $this->instance->id . "&action=delete&pid={$poll->id}"); $table->data[] = array($poll->name, !$options ? '0' : count($options), !$responses ? '0' : count($responses), $action); } print_table($table);