function get_exam_content($examID, $examName, $examCat) { $questions = get_questions($examID); $html = "<h4>{$examName} Questions</h4>\n"; $html .= "<input type='hidden' value='{$examID}' id='exam_id' />"; $html .= "<input type='hidden' value='{$examCat}' id='exam_cat' />"; $html .= "<input type='hidden' value='{$examName}' id='exam_name' />"; $html .= "<div id='questions'>\n"; foreach ($questions as $question) { $html .= "<span class='edit_question_link' id='{$question[1]}' data-type='{$question[2]}' title='edit\"{$question[0]}\" question'>{$question[0]}</span><u class='space'></u>"; $html .= "<u class='space'></u><u class='remove_question' id='{$question[1]}' name='{$question[0]}' title='delete {$question[0]} question' data-type='{$question[2]}'>x</u><br /></li>\n<br/>"; } $html .= "</div><br /><h3>Create New Question</h3>"; $html .= "<input id='new_question' type='text' autocomplete='off' placeholder='What is the question?' size='100' maxlength='200'/>"; $html .= "<pre>"; $html .= "Question Type:\n\tSingle Answer <input type='radio' class='type' name='type' value='single' />"; $html .= "\tMultiple Choice <input type='radio' class='type' name='type' value='multiple'>"; $html .= "\tWritten <input type='radio' class='type' name='type' value='written'>\n\n"; $html .= "<div id='single_input'><input type='text' maxlength='100' placeholder='What is the answer?' autocomplete='off' id='single_answer_text'></div>"; $html .= "<div id='mult_input'><h3>Check the answer or answers that are correct</h3>"; for ($i = 0; $i < 10; $i++) { $html .= "<input type='checkbox' name='mult_answer[]' value='{$i}'>\t<input type='text' maxlength='100' autocomplete='off' name='mult_answer_text[]' class='mult_answer_text'>\n\n"; } $html .= "</div>"; $html .= "<div id='written_input'><h3>Create up to ten keywords</h3>"; for ($i = 0; $i < 10; $i++) { $html .= "<input type='text' maxlength='100' autocomplete='off' name='keyword_text[]' class='keyword_text'>\n\n"; } $html .= "</div><br />"; $html .= "<button id='create_question_button'>Create New Question</button>\n"; $html .= "</pre>"; return $html; }
function get_listof_polls() { $quest_arr = get_questions(); $html = "<div id='list_of_polls'>\n<pre>"; for ($i = 0; $i < count($quest_arr); $i++) { $html .= "<p><a href='{$quest_arr[$i][3]}'>{$quest_arr[$i][0]}</a> Average Rating: {$quest_arr[$i][1]}\n People Voted: {$quest_arr[$i][2]}</p>"; } $html .= "</pre>\n</div>"; return $html; }
function get_dept_data() { $depts = get_depts(); foreach ($depts as &$dept) { $dept->eval_sections = get_sections($dept->id); foreach ($dept->eval_sections as &$section) { $section->questions = get_questions($section->id); } } return serialize($depts); }
function normalView() { echo '<p>Click on some of the filters to alter your query.</p>'; echo '<table width="100%"> <tr> <td style="width:20%;vertical-align:top;">'; get_questions(); echo '</td> <td style="vertical-align:top;">'; get_products(); echo '</td> </tr> </table>'; }
} else { echo '<p><input type="radio" value="' . $value . '" name="answer">' . $value . '</p>'; } } echo '<p><input type="submit" value="Submit"></p> </form>'; } else { //Quiz Complete echo 'Test Complete <a href="' . basename($_SERVER["SCRIPT_FILENAME"]) . '?scores=1">Check scores</a>'; } //Assign next question to session $_SESSION['question']++; } else { //Pages first load so show quiz index $_SESSION['question'] = 0; get_questions(); ?> <ul> <li><a href='<?php echo basename($_SERVER["SCRIPT_FILENAME"]); ?> '>Take quiz</a></li> </ul> <?php } //Function to put questions in session function get_questions() { $file = fopen('data.txt', 'r'); $array = array(); while ($line = fgetcsv($file, 1000, ',')) {
function get_candidate_user_info($id) { $id = (int) $id; $user = get_user_by_id($id); $reviews_given = get_number_of_candidate_reviews_given($id); $reviews_received = get_number_of_candidate_reviews_received($id); $teammember_reviews = get_number_of_candidate_poll_team_members($id); $notteammember_reviews = get_number_of_candidate_poll_not_team_members($id); $teammanager_reviews = get_number_of_candidate_poll_team_manager($id); $notteammanager_reviews = get_number_of_candidate_poll_managers($id); $preferred_reviewers = get_number_of_candidate_preferred_reviewers($id); $preferred_reviewees = get_number_of_candidate_preferred_reviewees($id); $questions = get_questions(); echo get_text('Reviews_written') . ": <b>{$reviews_given}</b><br />" . get_text('Reviews_received') . ": <b>{$reviews_received}</b><br />" . get_text('Reviews_from_teammember') . ": <b>{$teammember_reviews}</b><br />" . get_text('Reviews_from_not_teammember') . ": <b>{$notteammember_reviews}</b><br />" . get_text('Reviews_from_teammanager') . ": <b>{$teammanager_reviews}</b><br />" . get_text('Reviews_from_not_teammanager') . ": <b>{$notteammanager_reviews}</b><br />" . get_text('Reviews_from_preferred_reviewer') . ": <b>{$preferred_reviewers}</b><br />" . get_text('Reviews_given_to_preferred_reviewee') . ": <b>{$preferred_reviewees}</b><br />"; }
verify_authorization("admin"); connect(); ?> <?php if (isset($_POST['delete_exam'])) { delete_exam($_POST['exam_id']); header("Location: examinations.php"); } ?> <?php $exam_name = $_GET['exam_name']; $exam_id = $_GET['exam_id']; $in_exam = array(); $questions = get_questions(); $exam_questions = get_exam_questions($exam_id); foreach ($exam_questions as $i => $quest) { $in_exam[$quest['ID']] = true; } foreach ($questions as $i => $quest) { if (!isset($in_exam[$quest['ID']])) { $in_exam[$quest['ID']] = false; } } ?> <?php if (isset($_POST['submit_exam'])) { clear_exam($exam_id);
function get_questions($cos, $ids) { global $dbh; $qMarks = str_repeat('?,', count($ids) - 1) . '?'; $sql = "SELECT question, optiona, optionb, optionc, optiond FROM {$cos} where id IN ({$qMarks})"; $sth = $dbh->prepare($sql); $sth->execute($ids); $data = $sth->fetchAll(PDO::FETCH_OBJ); //$sth->closeCursor(); //header("content-type:application/json"); return json_encode($data); } $cos = 'pmp'; $id = [10, 15, 20, 25, 30, 35, 40, 45, 50]; connect(); $ans = get_questions($cos, $id); ?> <html> <head> <meta charset="utf-8"> <title>Test Interface</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="css/bootstrap.css" rel="stylesheet"> <link rel="stylesheet" type="text/css" href="css/slick.css"/> <!-- Include roboto.css to use the Roboto web font, material.css to include the theme and ripples.css to style the ripple effect --> <link href="css/roboto.min.css" rel="stylesheet"> <link href="css/material.min.css" rel="stylesheet"> <link href="css/ripples.min.css" rel="stylesheet"> <script src="js/jquery-1.10.2.min.js"></script> <script src="js/bootstrap.min.js"> </script> <script src="js/ripples.min.js"> </script>
loadAjax("?del="+id,function(){ window.location.reload(); //refresh page }); } </script> <?php } ?> </div> <?php if (get_session('vcn-question-group') && !isset($_REQUEST['change_group'])) { ?> <div class="right"> <div class='listquestion' id='listquestion'> <?php $data = get_questions(); //get all data $index = 0; //count while ($result = mysql_fetch_array($data)) { $current = isset($_GET['edit']) && $_GET['edit'] == $result['id']; vcn_question_bar($result, $index++, $current); } ?> </div> <script> $(document).ready(function(){ //auto fixed listquestion autofixedTop(document.getElementById('listquestion'),$('#right')[0]); }); </script>
<div class = "header"><h2 class = "siteTitle">Dynamic Mathematics Survey</h2></div> <!-- END OF HEADER --> <div class = "wrapContent"> <!-- <div class ="sideNav" > <ul> <li><a href = "#">Survey 1 </a></li> <li><a href = "#">Survey 2 </a></li> </ul> </div> <!-- END sideNav --> <div class = "Content"> <h2>Behavior Survey</h2> <div class = "entry"> <?php get_questions(37, 3); ?> </div> <!-- END ENTRY --> </div> <!-- End content --> </div> <!-- End wrapContent --> <!-- End footer --> </div> <!-- end wrapoverall --> </div> </div> </body> </html> <?php
$votes = array(); $regexp = '@class="question-hyperlink">(.*?)</a>@s'; preg_match_all($regexp, $body, $questions); $regexp = '@class="vote-count-post (.*?)"><strong>(.*?)</strong>@s'; preg_match_all($regexp, $body, $votes); $count = count($votes[2]); //echo $count; global $c; for ($i = 0; $i < $count; $i++) { $w = $questions[1][$i] . "\n"; $r = file_put_contents($qFile, $w, FILE_APPEND); if (!$r) { echo "Error writng to file"; exit; } $w = $votes[2][$i] . "\n"; $r = file_put_contents($vFile, $w, FILE_APPEND); if (!$r) { echo "Error writng to file"; exit; } } //echo "Files written!!"; } $i = 1; while ($i <= 500) { $to_crawl = "http://stackoverflow.com/questions/tagged/android?page=" . $i . "&sort=votes&pagesize=15"; get_questions($to_crawl); $i++; } echo "Files Written Successfully!!";
/** * items in the form */ public function definition() { global $DB; $questions = get_questions(); $profile_fields = get_profilefields(); $custom_fields = get_customfields(); $mform =& $this->_form; unset($questions['none']); foreach ($questions as $k => $q) { $extra = null; if (in_array($k, $profile_fields)) { if (strcmp($k, 'country') === 0) { $type = 'select'; $extra = get_string_manager()->get_list_of_countries(); } else { if (strcmp($k, 'language') === 0) { $type = 'select'; $extra = get_string_manager()->get_list_of_languages(); } else { if (strcmp($k, 'inactive') === 0) { $type = 'advcheckbox'; } else { $type = 'text'; } } } } else { if (in_array($k, $custom_fields)) { $field = $DB->get_record('user_info_field', array('shortname' => $k)); if (strcmp($field->datatype, 'menu') === 0) { $type = 'select'; $extra = explode("\n", $field->param1); $extra = array_combine($extra, $extra); } else { if (strcmp($field->datatype, 'text') === 0) { $type = 'text'; } else { if (strcmp($field->datatype, 'checkbox') === 0) { $type = 'advcheckbox'; } else { if (strcmp($field->datatype, 'textarea') === 0) { $type = 'textarea'; } } } } } } if (!empty($type)) { $mform->addElement($type, $k, $q, $extra); if ($type === 'text' || $type === 'textarea') { $mform->setType($k, PARAM_RAW); } } } $group = array(); $group[] =& $mform->createElement('submit', 'save_exit', get_string('save_exit', 'block_enrolsurvey')); $group[] =& $mform->createElement('submit', 'update', get_string('update', 'block_enrolsurvey')); $group[] =& $mform->createElement('cancel'); $mform->addElement('hidden', 'courseid', $this->_customdata->courseid); $mform->setType('courseid', PARAM_INT); $mform->addElement('hidden', 'mymoodle', $this->_customdata->mymoodle); $mform->setType('mymoodle', PARAM_INT); $mform->addGroup($group, 'form_buttons', '', array(' '), false); }
function module_main() { global $SMARTY, $_GET; if (isset($_GET['pr'])) { $problem = $_GET['pr']; } else { $problem = get_first_solution(); } $solution = get_solution($problem); $questions = get_questions($problem); $SMARTY->assign('solution', $solution); $SMARTY->assign('questions', $questions); $SMARTY->display('module:help.html'); }
<?php if (!isset($_SESSION['id'])) { session_start(); } if (!isset($_SESSION['id'])) { printf("ログインしないと利用できません。"); exit(0); } $_GET['pagename'] = 'list'; include "setting.php"; if (isset($_POST['search'])) { $search = $_POST['search']; $result = get_questions_with_search($search); } else { $result = get_questions(); } $num = pg_num_rows($result); for ($i = 0; $i < $num; $i++) { $row = pg_fetch_assoc($result, $i); $dt = date("Y-m-d", strtotime($row['date'])); print "<tr>"; print "<td><a href='diagnosis.php?id=" . $row['id'] . "'>" . htmlspecialchars($row['content']) . "</a></td>"; print "<td class='user'>{$row['login_name']}</td>"; print "<td class='date'>{$dt}</td>"; print "</tr>\n"; } function get_questions() { $db = new mydb(); $query = "select c.id, c.date, c.content, m.login_name from crystal c, member m where c.m_id = m.id order by c.date desc";
function evaluate_quiz($acode, $jobid, $newattempt, $blended) { global $USER; global $CFG; mtrace("Evaluation QUIZ Processing..." . "<BR><BR>"); try { print "New Attempt is: " . $newattempt . "<BR/>"; $detected_userid = find_userid($acode, $jobid); if ($detected_userid == null or $detected_userid == '') { throw new EvaluationError(get_string('ErrorUserIDEmpty', 'blended'), EvaluationError::USERID_IS_EMPTY); } $user_reg = blended_get_user($detected_userid, $blended); if ($user_reg == null) { throw new EvaluationError(get_string('ErrorUserNotInCourse', 'blended'), EvaluationError::USER_NOT_IN_THIS_COURSE); } $userid = $user_reg->id; mtrace('Obtained USERID value: ' . $userid . " OK. <BR/>"); $quiz = get_quiz($acode); $attempts = quiz_get_user_attempts($quiz->id, $userid, 'all', true); mtrace("Searching quiz... Success." . "<BR/>"); $uniqueid = get_uniqueid($acode); mtrace('Obtained uniqueid: OK. <BR/>'); $timestamp = get_timestamp($acode); mtrace('Obtained timestamp: OK. <BR/>'); if (!get_record('quiz_attempts', 'uniqueid', $uniqueid)) { $newattempt = true; } else { $newattempt = false; mtrace("User {$userid} had opened this attempt already."); } $attemptnumber = 1; if ($newattempt == false) { mtrace('Obtaining user attempt...<BR/>'); set_attempt_unfinished($uniqueid); $attempt = quiz_get_user_attempt_unfinished($quiz->id, $userid); } elseif ($newattempt == true) { mtrace('Creating new attempt...<BR/>'); $attempt = create_new_attempt($quiz, $attemptnumber, $userid, $acode, $uniqueid, $timestamp); // Save the attempt if (!insert_record('quiz_attempts', $attempt)) { throw new EvaluationError(get_string('ErrorCouldNotCreateAttempt', 'blended'), EvaluationError::CREATE_QUIZ_ATTEMPT_ERROR); } // Actualizamos el estado de las imágenes para indicar que ya está creado un nuevo attempt update_images_status($acode, $jobid); } update_question_attempts($uniqueid); // /* mtrace('<BR>Getting questions and question options... '); $questions = get_questions($attempt, $quiz); if (!get_question_options($questions)) { error('Could not load question options'); } mtrace('Success! <BR>'); // print ("<BR>He obtenido questions: "); //print_object($questions); $lastattemptid = false; // if ($attempt->attempt > 1 and $quiz->attemptonlast and !$attempt->preview) { // Find the previous attempt // if (!$lastattemptid = get_field('quiz_attempts', 'uniqueid', 'quiz', $attempt->quiz, 'userid', $attempt->userid, 'attempt', $attempt->attempt-1)) { // error('Could not find previous attempt to build on'); // } //} //print ('He obtenido lastattemptid'); mtrace('Getting question states... '); if (!($states = get_question_states($questions, $quiz, $attempt, $lastattemptid))) { error('Could not restore question sessions'); } mtrace('Success! <BR>'); mtrace('Getting responses... <BR>'); $responses = get_responses($acode, $jobid, $attempt); //print('Estas son las responses:'); //print_object($responses); //$timestamp=time(); $event = 8; $actions = question_extract_responses($questions, $responses, $event); $questionids = get_questionids($acode); // print $questionids; $questionidarray = explode(',', $questionids); $success = true; mtrace('<BR> Processing responses and saving session... '); foreach ($questionidarray as $i) { if (!isset($actions[$i])) { $actions[$i]->responses = array('' => ''); $actions[$i]->event = QUESTION_EVENTOPEN; } $actions[$i]->timestamp = $timestamp; if (question_process_responses($questions[$i], $states[$i], $actions[$i], $quiz, $attempt)) { save_question_session($questions[$i], $states[$i]); } else { $success = false; } } mtrace('Success! <BR>'); // Set the attempt to be finished $timestamp = time(); //$attempt->timefinish = $timestamp; // Update the quiz attempt and the overall grade for the quiz mtrace('<BR> Finishing the attempt... '); // print_object ($attempt); if (set_field('quiz_attempts', 'timefinish', $timestamp, 'uniqueid', $uniqueid) == false) { throw new EvaluationError('Unable to finish the quiz attempt!', EvaluationError::FINISH_QUIZ_ATTEMPT_ERROR); } mtrace('Success! <BR>'); if ($attempt->attempt > 1 || $attempt->timefinish > 0 and !$attempt->preview) { mtrace('<BR> Saving quiz grade... '); quiz_save_best_grade($quiz, $userid); } mtrace('Success! <BR>'); // */ mtrace("Process Done. <BR><BR>"); mtrace("<center> Your quiz has been succesfully evaluated!! </center>"); } catch (EvaluationError $e) { throw $e; } return; }
function create_question_table($sec_id) { //generates html for questions table //create html and return $result = "<h3>Questions</h3>\n\n\t\t<table class='seufolios' id='seufolios_questions_table'>\n\n\t\t<tr><th>Slug</th><th>Question</th><th>Type</th><th>Enabled</th><th></th></tr>"; $questions = get_questions($sec_id); $q_types = get_question_types(); foreach ($questions as $question) { $enabled = $question->enabled == 1 ? 'Yes' : 'No'; $result .= "<tr id='qrow_{$question->id}'>\n\n\t\t\t\t\t<td class='slug'>{$question->slug}</td>\n\n\t\t\t\t\t<td class='question'>" . stripslashes($question->question) . "</td>\n\n\t\t\t\t\t<td class='type'>"; foreach ($q_types as $q) { if ($q->id == $question->type) { $result .= $q->displayName; } } $result .= "</td>\n\n\t\t\t\t\t<td class='enabled'>{$enabled}</td>\n\n\t\t\t\t\t<td><button id='edit_{$question->id}' class='edit_button' type='button' onclick='edit_question({$question->id}, {$question->order_loc})'>Edit</button> "; } $result .= "</table>"; return $result; }
/** * items in the form */ public function definition() { $questions = get_questions(); $profile_fields = get_profilefields(); $custom_fields = get_customfields(); $mform =& $this->_form; unset($questions['none']); foreach ($questions as $k => $q) { $extra = null; if (in_array($k, $profile_fields)) { if (strcmp($k, 'country') === 0) { $type = 'select'; $extra = get_list_of_countries(); } else { $type = 'text'; } } else { if (in_array($k, $custom_fields)) { $field = get_record('user_info_field', 'shortname', $k); if (strcmp($field->datatype, 'menu') === 0) { $type = 'select'; $extra = explode("\n", $field->param1); $extra = array_combine($extra, $extra); } else { if (strcmp($field->datatype, 'text') === 0) { $type = 'text'; } else { if (strcmp($field->datatype, 'checkbox') === 0) { $type = 'checkbox'; } else { if (strcmp($field->datatype, 'textarea') === 0) { $type = 'textarea'; } } } } } } if (!empty($type)) { $mform->addElement($type, $k, $q, $extra); } } $group = array(); $group[] =& $mform->createElement('submit', 'save_exit', get_string('save_exit', 'block_enrol_survey')); $group[] =& $mform->createElement('submit', 'update', get_string('update', 'block_enrol_survey')); $group[] =& $mform->createElement('cancel'); $mform->addGroup($group, 'form_buttons', '', array(''), false); }
} $method = $_SERVER['REQUEST_METHOD']; $request = explode("/", substr(@$_SERVER['PATH_INFO'], 1)); $requestSize = sizeof($request); switch ($method) { case 'GET': switch ($request[0]) { case 'questions': if ($requestSize == 1) { exit(get_questions()); } if ($requestSize == 2) { if ($request[1] == "") { // special case. // http://localhost/cardboard-qr-marker-frontend/api.php/questions/ exit(get_questions()); } exit(get_question_by_id($request[1])); } if ($requestSize == 3) { if ($request[2] == "") { exit(get_question_by_id($request[1])); } } handle_error(); case 'qrcodes': exit(get_qrcodes_by_id($request[1], 200)); case 'qrcodesprint': exit(get_qrcodes_by_id($request[1], 400)); case 'particleqrcode': exit(get_particlesystem_qrcode_by_id($request[1], 200));
//$stm->bind_param("is",$time,$status); $response = $stm->execute(); echo $query; if ($response) { echo "successfull prepared statement<br>"; } else { echo "unsuccessful prepared statement<br>"; } $result = $stm->get_result(); //var_dump($result->fetch_assoc()); $msg = ''; /* now you can fetch the results into an array - NICE */ while ($myrow = $result->fetch_assoc()) { // use your $myrow array as you would with any other fetch if ($myrow["email"] != 'a' && $myrow["email"] != 'az') { $questions = get_questions($myrow["category"]); $email_html = generate_email($questions, $myrow["category"], $myrow["email"]); $status = send_questions($myrow["email"], $email_html, "Daily Subliminal Primes"); if ($status) { //echo "email sent"; $msg .= "\nemail sent successfully to " . $myrow["email"] . " \t for category " . $myrow["category"] . "\t" . strtolower(date("c")) . "\n"; // echo "email sent successfully to ".$myrow["email"]." \t for category ".$myrow["category"]."\n"; } else { $msg .= "\nemail unsuccessfully to " . $myrow["email"] . " \t for category " . $myrow["category"] . "\n"; } } } echo $msg; die; //fwrite($out,$msg); //fclose($out);
<div class = "header"><h2 class = "siteTitle">Dynamic Mathematics Survey</h2></div> <!-- END OF HEADER --> <div class = "wrapContent"> <!-- <div class ="sideNav" > <ul> <li><a href = "#">Survey 1 </a></li> <li><a href = "#">Survey 2 </a></li> </ul> </div> <!-- END sideNav --> <div class = "Content"> <h2>Archimedes Questionaire</h2> <div class = "entry"> <?php get_questions($_SESSION['user_id'], 3); ?> </div> </div> </div> </div> <!-- END ENTRY --> </div> <!-- End content --> </div> <!-- End wrapContent --> </div> <!-- end wrapoverall --> </div> </div> </body> </html> <?php include 'includes/overall/footer.php';