Exemple #1
0
function update($conn, $tablename, $targettablename, $sql, $count)
{
    $recs = reccount($conn, $tablename);
    $added = addedcount($conn, $targettablename);
    echo "\n Records - " . $recs;
    $attempts = get_attempts($recs - $added, $count);
    for ($x = 0; $x < $attempts; $x++) {
        $start = $added + $x * $count;
        $tmp = $sql . " LIMIT " . $start . "," . $count . ";";
        //echo "\n" . $tmp;
        runsql($conn, $tmp);
    }
}
 /**
  * Creates the blocks main content
  *
  * @return string
  */
 public function get_content()
 {
     // Access to settings needed
     global $USER, $COURSE, $CFG, $DB, $OUTPUT;
     // If content has already been generated, don't waste time generating it again
     if ($this->content !== null) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     // Check if any activities/resources have been created
     $modules = modules_in_use();
     if (empty($modules)) {
         if (has_capability('moodle/block:edit', $this->context)) {
             $this->content->text .= get_string('no_events_config_message', 'block_progress');
         }
         return $this->content;
     }
     // Check if activities/resources have been selected in config
     $events = event_information($this->config, $modules);
     $attempts = get_attempts($modules, $this->config, $events, $USER->id, $this->instance->id);
     $this->content->text = progress_bar($modules, $this->config, $events, $USER->id, $this->instance->id, $attempts);
     // Organise access to JS
     $jsmodule = array('name' => 'block_progress', 'fullpath' => '/blocks/progress/module.js', 'requires' => array(), 'strings' => array(array('time_expected', 'block_progress')));
     $displaydate = !isset($this->config->displayNow) || $this->config->displayNow == 1;
     $arguments = array($CFG->wwwroot, array_keys($modules), $displaydate);
     $this->page->requires->js_init_call('M.block_progress.init', $arguments, false, $jsmodule);
     return $this->content;
 }
<?php

include_once '/../includes/hw_function.php';
if (get_status() == '1') {
    $status = 'Armed';
} else {
    $status = 'Disarmed';
}
if (get_condition() == '1') {
    $condition = 'Unlocked';
} else {
    $condition = 'Locked';
}
?>
<ul class="list-inline">
	<li><strong>Condition : <?php 
echo $condition;
?>
</strong></li>
	<li><strong>|</strong></li>
	<li><strong>Status : <?php 
echo $status;
?>
</strong></li>
	<li><strong>|</strong></li>
	<li><strong>Password Attemps : <?php 
echo get_attempts();
?>
</strong></li>
</ul>
 /**
  * Creates the blocks main content
  *
  * @return string
  */
 public function get_content()
 {
     // Access to settings needed
     global $USER, $COURSE, $CFG, $DB, $OUTPUT;
     // If content has already been generated, don't waste time generating it again
     if ($this->content !== null) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     // Check if any activities/resources have been created
     $modules = modules_in_use();
     if (empty($modules)) {
         if (has_capability('moodle/block:edit', $this->context)) {
             $this->content->text .= get_string('no_events_config_message', 'block_progress');
         }
         return $this->content;
     }
     // Check if activities/resources have been selected in config
     $events = event_information($this->config, $modules);
     if ($events === null || $events === 0) {
         if (has_capability('moodle/block:edit', $this->context)) {
             $this->content->text .= get_string('no_events_message', 'block_progress');
             if ($USER->editing) {
                 $parameters = array('id' => $COURSE->id, 'sesskey' => sesskey(), 'bui_editid' => $this->instance->id);
                 $url = new moodle_url('/course/view.php', $parameters);
                 $label = get_string('selectitemstobeadded', 'block_progress');
                 $this->content->text .= $OUTPUT->single_button($url, $label);
                 if ($events === 0) {
                     $url->param('turnallon', '1');
                     $label = get_string('addallcurrentitems', 'block_progress');
                     $this->content->text .= $OUTPUT->single_button($url, $label);
                 }
             }
         }
         return $this->content;
     } else {
         if (empty($events)) {
             if (has_capability('moodle/block:edit', $this->context)) {
                 $this->content->text .= get_string('no_visible_events_message', 'block_progress');
             }
             return $this->content;
         } else {
             $attempts = get_attempts($modules, $this->config, $events, $USER->id, $this->instance->id);
             $this->content->text = progress_bar($modules, $this->config, $events, $USER->id, $this->instance->id, $attempts);
         }
     }
     // Organise access to JS
     $jsmodule = array('name' => 'block_progress', 'fullpath' => '/blocks/progress/module.js', 'requires' => array(), 'strings' => array(array('time_expected', 'block_progress')));
     $displaydate = !isset($this->config->displayNow) || $this->config->displayNow == 1;
     $arguments = array($CFG->wwwroot, array_keys($modules), $displaydate);
     $this->page->requires->js_init_call('M.block_progress.init', $arguments, false, $jsmodule);
     // Allow teachers to access the overview page
     if (has_capability('block/progress:overview', $this->context)) {
         $parameters = array('id' => $this->instance->id, 'courseid' => $COURSE->id);
         $url = new moodle_url('/blocks/progress/overview.php', $parameters);
         $label = get_string('overview', 'block_progress');
         $this->content->text .= $OUTPUT->single_button($url, $label);
     }
     return $this->content;
 }
<?php

include_once '/../includes/hw_function.php';
$response['device_status'] = array();
if (get_status() == '1') {
    $status = 'Armed';
} else {
    $status = 'Disarmed';
}
if (get_condition() == '1') {
    $condition = 'Unlocked';
} else {
    $condition = 'Locked';
}
$device_status = array();
$device_status['status'] = $status;
$device_status['condition'] = $condition;
$device_status['password_attempts'] = get_attempts();
array_push($response['device_status'], $device_status);
$response['success'] = 1;
echo json_encode($response);
Exemple #6
0
$table->column_style('progressbar', 'width', '200px');
$table->column_style('progress', 'text-align', 'center');
$table->no_sorting('picture');
$table->no_sorting('progressbar');
$table->define_baseurl($PAGE->url);
$table->setup();
// Build table of progress bars as they are marked
for ($i = 0; $i < $numberofusers; $i++) {
    $picture = $OUTPUT->user_picture($users[$i], array('course' => $course->id));
    $name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $users[$i]->id . '&course=' . $course->id . '">' . fullname($users[$i]) . '</a>';
    if ($users[$i]->lastaccess == 0) {
        $lastonline = get_string('never');
    } else {
        $lastonline = userdate($users[$i]->lastaccess);
    }
    $attempts = get_attempts($modules, $config, $events, $users[$i]->id, $course->id);
    $progressbar = progress_bar($modules, $config, $events, $users[$i]->id, $course->id, $attempts, true);
    $progressvalue = get_progess_percentage($events, $attempts);
    $progress = $progressvalue . '%';
    $rows[] = array('firstname' => $users[$i]->firstname, 'lastname' => strtoupper($users[$i]->lastname), 'picture' => $picture, 'fullname' => $name, 'lastonlinetime' => $users[$i]->lastaccess, 'lastonline' => $lastonline, 'progressbar' => $progressbar, 'progressvalue' => $progressvalue, 'progress' => $progress);
    //Inserting the values into created table
    $result = $DB->get_records_sql('SELECT * FROM {progress_percent} WHERE uid = ? AND cid = ?', array($users[$i]->id, $course->id));
    $val = array_values($result);
    $record = new stdClass();
    $record->uid = $users[$i]->id;
    $record->cid = $course->id;
    $record->progress_percentage = $progressvalue;
    if (count($result) != 0) {
        $record->id = $val[0]->id;
    }
    count($result) == 0 ? $DB->insert_record('progress_percent', $record, false) : $DB->update_record('progress_percent', $record, false);