function active_menu_sidebar($array) { $resultado = array_value_recursive(getRoute(), $array); if (!empty($resultado)) { return 'active'; } return ''; }
/** * Export a quiz to a zip file (json + pictures) * @return [type] [description] */ public function export() { $export = array('appreciations' => array(), 'settings' => array(), 'content' => array(), 'players' => array()); // Content export foreach ($this->questions as $question) { $contentExport = $question->export(); $export['content'][] = $contentExport; } // Settings export $export['settings'] = $this->exportSettings(); // Meta export $export['extraOptions'] = $this->exportExtraOptions(); // Players export $export['players'] = $this->exportPlayers(); // Upload config $currentTime = time(); $upload_dir = wp_upload_dir(); $upload_path = $upload_dir['path']; $file_slug = 'wpvq-' . substr(slugify($this->getName(), true), 0, 10) . '-' . $currentTime; // Create local upload dir $upload_local_path = $upload_path . '/' . $file_slug; if (!mkdir($upload_local_path, 0777, true)) { die('Error : can\'t upload.'); } // Create json+pictures $final_json_path = $upload_local_path . '/export.json'; // Fetch pictures ID then save them into the pictures folder $picturesIds = array_filter(array_value_recursive('pictureId', $export['content'])); foreach ($picturesIds as $pictureId) { $url = wp_get_attachment_url($pictureId); $ext = pathinfo($url, PATHINFO_EXTENSION); if (file_put_contents("{$upload_local_path}/{$pictureId}.{$ext}", file_get_contents($url)) === FALSE) { die('Error : can\'t upload.'); } } // Export appreciations with pictures $export['appreciations'] = $this->exportAppreciations($upload_local_path); $exportJson = json_encode($export); if (file_put_contents($final_json_path, $exportJson) === FALSE) { die('Error : can\'t upload.'); } // Create zip file $final_zip_path = $upload_path . '/' . $file_slug . '.zip'; $zip = new ZipArchive(); if ($zip->open($final_zip_path, ZipArchive::CREATE) !== TRUE) { die('Error : can\'t upload.'); } $zip->addGlob($upload_local_path . "/*.*", 0, array('remove_all_path' => true, 'add_path' => $file_slug . '/')); if (!$zip->status == ZIPARCHIVE::ER_OK) { die('Error : can\'t upload.'); } $zip->close(); return $final_zip_path; }
function create_zip_index($path, $id, $online = FALSE) { global $charset, $m, $course_id; $fp = fopen($path, "w"); if (!$fp) { die("Unable to create assignment index file - aborting"); } fputs($fp, ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=' . $charset . '"> <style type="text/css"> .sep td, th { border: 1px solid; } td { border: none; } table { border-collapse: collapse; border: 2px solid; } .sep { border-top: 2px solid black; } </style> </head> <body> <table class="table-default"> <tr> <th>' . $m['username'] . '</th> <th>' . $m['am'] . '</th> <th>' . $m['filename'] . '</th> <th>' . $m['sub_date'] . '</th> <th>' . $m['grade'] . '</th> </tr>'); $assign = Database::get()->querySingle("SELECT * FROM assignment WHERE id = ?d", $id); if ($assign->grading_scale_id) { $serialized_scale_data = Database::get()->querySingle('SELECT scales FROM grading_scale WHERE id = ?d AND course_id = ?d', $assign->grading_scale_id, $course_id)->scales; $scales = unserialize($serialized_scale_data); $scale_values = array_value_recursive('scale_item_value', $scales); } $result = Database::get()->queryArray("SELECT a.uid, a.file_path, a.submission_date, a.grade, a.comments, a.grade_comments, a.group_id, b.deadline FROM assignment_submit a, assignment b WHERE a.assignment_id = ?d AND a.assignment_id = b.id ORDER BY a.id", $id); foreach ($result as $row) { $filename = basename($row->file_path); $filelink = empty($filename) ? ' ' : ("<a href='$filename'>" . htmlspecialchars($filename) . '</a>'); $late_sub_text = ((int) $row->deadline && $row->submission_date > $row->deadline) ? "<div style='color:red;'>$m[late_submission]</div>" : ''; if ($assign->grading_scale_id) { $key = closest($row->grade, $scale_values, true)['key']; $row->grade = $scales[$key]['scale_item_name']; } fputs($fp, ' <tr class="sep"> <td>' . q(uid_to_name($row->uid)) . '</td> <td>' . q(uid_to_am($row->uid)) . '</td> <td align="center">' . $filelink . '</td> <td align="center">' . $row->submission_date .$late_sub_text. '</td> <td align="center">' . $row->grade . '</td> </tr>'); if (trim($row->comments != '')) { fputs($fp, " <tr><td colspan='6'><b>$m[comments]: " . "</b>$row->comments</td></tr>"); } if (trim($row->grade_comments != '')) { fputs($fp, " <tr><td colspan='6'><b>$m[gradecomments]: " . "</b>$row->grade_comments</td></tr>"); } if (!empty($row->group_id)) { fputs($fp, "<tr><td colspan='6'>$m[groupsubmit] " . "$m[ofgroup] $row->group_id</td></tr>\n"); } } fputs($fp, ' </table></body></html>'); fclose($fp); }
<div class="colors"> <div class="head">Цвета:</div> <?php if (count($photos) > 1) { function array_value_recursive($key, array $arr) { $val = array(); array_walk_recursive($arr, function ($v, $k) use($key, &$val) { if ($k == $key) { array_push($val, $v); } }); return count($val) > 1 ? $val : array_pop($val); } $i = 1; $uniq = array_unique(array_value_recursive('color', $photos)); foreach ($uniq as $k => $v) { $color_hex = DB::selectID('colors', $uniq[$k]); ?> <label class="<?php echo $i == 1 ? "active" : ""; ?> "> <input type="radio" name="color" value="<?php echo $uniq[$k]; ?> " data-num="<?php echo $k; ?> " <?php echo $i == 1 ? "checked" : "";
function show_edit_form($id, $sid, $assign) { global $m, $langGradeOk, $tool_content, $course_code, $langCancel, $langBack, $assign, $langWorkOnlineText, $course_id; $sub = Database::get()->querySingle("SELECT * FROM assignment_submit WHERE id = ?d",$sid); if (count($sub)>0) { $uid_2_name = display_user($sub->uid); if (!empty($sub->group_id)) { $group_submission = "($m[groupsubmit] $m[ofgroup] " . "<a href='../group/group_space.php?course=$course_code&group_id=$sub->group_id'>" . gid_to_name($sub->group_id) . "</a>)"; } else { $group_submission = ''; } $grade = Session::has('grade') ? Session::get('grade') : $sub->grade; $comments = Session::has('comments') ? Session::get('comments') : q($sub->grade_comments); $email_status = !Session::has('email') ?: " checked"; $pageName = $m['addgradecomments']; if($assign->submission_type){ $submission = " <div class='form-group'> <label class='col-sm-3 control-label'>$langWorkOnlineText:</label> <div class='col-sm-9'> $sub->submission_text </div> </div>"; } else { $submission = " <div class='form-group'> <label class='col-sm-3 control-label'>$m[filename]:</label> <div class='col-sm-9'> <a href='index.php?course=$course_code&get=$sub->id'>".q($sub->file_name)."</a> </div> </div>"; } if ($assign->grading_scale_id) { $serialized_scale_data = Database::get()->querySingle('SELECT scales FROM grading_scale WHERE id = ?d AND course_id = ?d', $assign->grading_scale_id, $course_id)->scales; $scales = unserialize($serialized_scale_data); $scale_options = "<option value> - </option>"; $scale_values = array_value_recursive('scale_item_value', $scales); if (!in_array($sub->grade, $scale_values) && !is_null($sub->grade)) { $sub->grade = closest($sub->grade, $scale_values)['value']; } foreach ($scales as $scale) { $scale_options .= "<option value='$scale[scale_item_value]'".($sub->grade == $scale['scale_item_value'] ? " selected" : "").">$scale[scale_item_name]</option>"; } $grade_field = " <select name='grade' class='form-control' id='scales'> $scale_options </select>"; } else { $grade_field = "<input class='form-control' type='text' name='grade' maxlength='4' size='3' value='$sub->grade'> ($m[max_grade]: $assign->max_grade)"; } $tool_content .= action_bar(array( array( 'title' => $langBack, 'url' => "index.php?course=$course_code&id=$sub->assignment_id", 'icon' => "fa-reply", 'level' => 'primary-label' ) ))." <div class='form-wrapper'> <form class='form-horizontal' role='form' method='post' action='index.php?course=$course_code'> <input type='hidden' name='assignment' value='$id'> <input type='hidden' name='submission' value='$sid'> <fieldset> <div class='form-group'> <label class='col-sm-3 control-label'>$m[username]:</label> <div class='col-sm-9'> $uid_2_name $group_submission </div> </div> <div class='form-group'> <label class='col-sm-3 control-label'>$m[sub_date]:</label> <div class='col-sm-9'> <span>".q($sub->submission_date)."</span> </div> </div> $submission <div class='form-group".(Session::getError('grade') ? " has-error" : "")."'> <label for='grade' class='col-sm-3 control-label'>$m[grade]:</label> <div class='col-sm-4'> $grade_field <span class='help-block'>".(Session::hasError('grade') ? Session::getError('grade') : "")."</span> </div> </div> <div class='form-group'> <label for='comments' class='col-sm-3 control-label'>$m[gradecomments]:</label> <div class='col-sm-9'> <textarea class='form-control' rows='3' name='comments' id='comments'>$comments</textarea> </div> </div> <div class='form-group'> <div class='col-sm-9 col-sm-offset-3'> <div class='checkbox'> <label> <input type='checkbox' value='1' id='email_button' name='email'$email_status> $m[email_users] </label> </div> </div> </div> <div class='form-group'> <div class='col-sm-9 col-sm-offset-3'> <input class='btn btn-primary' type='submit' name='grade_comments' value='$langGradeOk'> <a class='btn btn-default' href='index.php?course=$course_code&id=$sub->assignment_id'>$langCancel</a> </div> </div> </fieldset> </form> </div>"; } else { Session::Messages($m['WorkNoSubmission'], 'alert-danger'); redirect_to_home_page('modules/work/index.php?course='.$course_code.'&id='.$id); } }
$getCstring = ''; // echo "<h2> The Details of Sensor Observation Service Capabilities </h2>"; echo "<p>Service URL : " . $_SESSION['userurl'] . "</p>"; // use post_data function to post xml string and catch response $output = post_data($myCapURL, $getCstring); if ($output) { //print_r($output); // func from func_parse_cap 1. $cap_LL = cap_parse_LL($output); //take only one bounding box $one_LL = array_slice($cap_LL, -1); //print_r($one_LL); // func from func_generic 1. // seperate mix lat lon from xml $LL_Seperate = array_value_recursive('mixlatlon', $one_LL); $LL_Seperate = explode(',', $LL_Seperate); //print_r($LL_Seperate); // top left and bottom right lat lon $LC = $LL_Seperate[0]; $UC = $LL_Seperate[5]; echo "<p>Approximate Latitude and Longitude<br/>Lat:" . $LC . " & Lon: " . $UC . "</p>"; // func from func_parse_cap 3. // a. offering $offering = array('ObservationOffering', 'gml:id'); $myOffering = getOffering($output, $offering); //$myCleanOff = cleanOff($myOffering); echo "<p>Offering : " . $myOffering[0]['ObservationOffering'] . "</p>"; //print_r($myCleanOff); // b. eventTime $timePosition = array('beginPosition', 'endPosition');