/** * Perform minimal validation on the grade form * @param array $data * @param array $files */ public function validation($data, $files) { global $DB; $errors = parent::validation($data, $files); $instance = $this->assignment->get_instance(); if ($instance->markingworkflow && !empty($data['sendstudentnotifications']) && $data['workflowstate'] != ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) { $errors['sendstudentnotifications'] = get_string('studentnotificationworkflowstateerror', 'assign'); } // Advanced grading. if (!array_key_exists('grade', $data)) { return $errors; } if ($instance->grade > 0) { if (unformat_float($data['grade']) === null && !empty($data['grade'])) { $errors['grade'] = get_string('invalidfloatforgrade', 'assign', $data['grade']); } else { if (unformat_float($data['grade']) > $instance->grade) { $errors['grade'] = get_string('gradeabovemaximum', 'assign', $instance->grade); } else { if (unformat_float($data['grade']) < 0) { $errors['grade'] = get_string('gradebelowzero', 'assign'); } } } } else { // This is a scale. if ($scale = $DB->get_record('scale', array('id' => -$instance->grade))) { $scaleoptions = make_menu_from_list($scale->scale); if ((int) $data['grade'] !== -1 && !array_key_exists((int) $data['grade'], $scaleoptions)) { $errors['grade'] = get_string('invalidgradeforscale', 'assign'); } } } return $errors; }
/** * Perform minimal validation on the grade form * @param array $data * @param array $files */ public function validation($data, $files) { global $DB; $errors = parent::validation($data, $files); $instance = $this->assignment->get_instance(); // Advanced grading. if (!array_key_exists('grade', $data)) { return $errors; } if ($instance->grade > 0) { if (unformat_float($data['grade']) === null && (!empty($data['grade']))) { $errors['grade'] = get_string('invalidfloatforgrade', 'assign', $data['grade']); } else if (unformat_float($data['grade']) > $instance->grade) { $errors['grade'] = get_string('gradeabovemaximum', 'assign', $instance->grade); } else if (unformat_float($data['grade']) < 0) { $errors['grade'] = get_string('gradebelowzero', 'assign'); } } else { // This is a scale. if ($scale = $DB->get_record('scale', array('id'=>-($instance->grade)))) { $scaleoptions = make_menu_from_list($scale->scale); if (!array_key_exists((int)$data['grade'], $scaleoptions)) { $errors['grade'] = get_string('invalidgradeforscale', 'assign'); } } } return $errors; }
/** * Perform minimal validation on the grade form * @param array $data * @param array $files */ function validation($data, $files) { global $DB; $errors = parent::validation($data, $files); // advanced grading if (!array_key_exists('grade', $data)) { return $errors; } if ($this->assignment->get_instance()->grade > 0) { if (!is_numeric($data['grade']) and (!empty($data['grade']))) { $errors['grade'] = get_string('invalidfloatforgrade', 'assign', $data['grade']); } else if ($data['grade'] > $this->assignment->get_instance()->grade) { $errors['grade'] = get_string('gradeabovemaximum', 'assign', $this->assignment->get_instance()->grade); } else if ($data['grade'] < 0) { $errors['grade'] = get_string('gradebelowzero', 'assign'); } } else { // this is a scale if ($scale = $DB->get_record('scale', array('id'=>-($this->assignment->get_instance()->grade)))) { $scaleoptions = make_menu_from_list($scale->scale); if (!array_key_exists((int)$data['grade'], $scaleoptions)) { $errors['grade'] = get_string('invalidgradeforscale', 'assign'); } } } return $errors; }
/** * Get the next row of data from the csv file (only the columns we care about) * * @return stdClass or false The stdClass is an object containing user, grade and lastmodified */ public function next() { global $DB; $result = new stdClass(); while ($record = $this->csvreader->next()) { $idstr = $record[$this->idindex]; // Strip the integer from the end of the participant string. $id = substr($idstr, strlen(get_string('hiddenuser', 'assign'))); if ($userid = $this->assignment->get_user_id_for_uniqueid($id)) { if (array_key_exists($userid, $this->validusers)) { $result->grade = $record[$this->gradeindex]; $result->modified = strtotime($record[$this->modifiedindex]); $result->user = $this->validusers[$userid]; $result->feedback = array(); foreach ($this->feedbackcolumnindexes as $description => $details) { if (!empty($details['index'])) { $details['value'] = $record[$details['index']]; $result->feedback[] = $details; } } return $result; } } } // If we got here the csvreader had no more rows. return false; }
<?php $id = $_POST['id']; $group_id = $_POST['group_id']; require "class/assignment.php"; $assignmentAPI = new assignment(); echo $assignmentAPI->getFileHistory($group_id, $id);
<?php $assignment_id = $_POST['assignment_id']; require "class/assignment.php"; $assignmentAPI = new assignment(); echo $assignmentAPI->deleteAssignment($assignment_id);
$form = array(); foreach ($_POST['form'] as $f) { $form[$f['name']] = $f['value']; } //var_dump($form); $title = $form['title']; $description = $form['description']; $dueDate = $form['due-date']; $dueTime = $form['due-time']; $codeType = $form['code-type']; $grouping = $form['grouping']; $status = $form['status']; $course_id = $form['course-id']; $samplecode = $_POST['code']; require "class/assignment.php"; $assignmentAPI = new assignment(); if (isset($_GET['edit'])) { //Edit excisting $assignment_id = $form['assignment-id']; if ($return_assignment_id = $assignmentAPI->editAssignment($title, $description, $dueDate, $dueTime, $codeType, $samplecode, $status, $course_id, $assignment_id)) { //header("location: ../teacher/assignments.php?course_id=" . $course_id); echo $return_assignment_id; } else { echo -1; } } else { //Create New if ($assignment_id = $assignmentAPI->createAssignment($title, $description, $dueDate, $dueTime, $codeType, $samplecode, $status, $grouping, $course_id)) { //header("location: ../teacher/assignments.php?course_id=" . $course_id); echo $assignment_id; } else {
<?php /** * Save java code to server in a specific folder * * @param code [POST] java code string * @param folder [POST] folder to hold the code * @return 1 for successful save */ require "class/assignment.php"; $inputs = $_POST['inputs']; $group_id = $_POST['group_id']; $assignment_id = $_POST['assignment_id']; $assignmentAPI = new assignment(); echo $assignmentAPI->testAssignment($group_id, $inputs);
$assignment_id = $_GET['assignment_id']; $input = $_GET['input']; /** Tino's */ require "/var/www/html2/apiv2.1/MysqliDB.php"; require "/var/www/html2/apiv2.1/Java.php"; define("ROOT", dirname(__DIR__)); $db = new MysqliDb('localhost', 'kit', 'kit1234', 'fyp'); $javaAPI = new Java(); ob_start(); $javaAPI->compileAndRun($assignment_id, $input); $json = ob_get_clean(); $temp = json_decode($json, 1); require "/var/www/html2/apiv2/class/assignment.php"; $assignmentAPI = new assignment(); error_log("input for sample code : " . $input); error_log("expected output : " . $temp['content']); $assignmentAPI->generateTrainingData($assignment_id, $input, $temp['content']); shell_exec("sh compile.sh"); shell_exec("sh run.sh"); $data = file_get_contents("labeled.arff"); //echo $data; //die(); $data = explode(PHP_EOL . PHP_EOL, $data); foreach ($data as &$d) { $d = explode(PHP_EOL, $d); foreach ($d as &$dd) { $dd = explode("\t", $dd); } }
<?php require "class/assignment.php"; $group_id = $_POST['group_id']; $assignmentAPI = new assignment(); echo $assignmentAPI->addEditor($group_id);
public function courseAssignmentList($course_id = null) { $user_id = user::authService()['user_id']; if (is_null($course_id)) { $course_id = $this->course_id; } if (!isset($course_id) && !isset($user_id)) { return -1; } if (user::isTeacher()) { $sql = "SELECT assignment_id FROM assignment WHERE course_id = '{$course_id}' "; } else { $sql = "SELECT assignment_id FROM assignment WHERE course_id = '{$course_id}' AND status = 'publish' "; } //echo $sql; $result = $this->query($sql); $assignment = array(); while ($row = $result->fetch_assoc()) { $assignment[] = assignment::assignmentInfo($row['assignment_id']); } return $assignment; }
<?php require "class/assignment.php"; $group_id = $_POST['group_id']; $assignmentAPI = new assignment(); echo $assignmentAPI->runAgainstTestCase($group_id);
/** * assignmentInfo function. * * @access public * @param mixed $assignment_id * @return void */ public function assignmentInfo($assignment_id) { $user_id = user::authService()['user_id']; if (!isset($assignment_id) && !isset($user_id)) { return -1; } $sql = "SELECT * FROM assignment WHERE assignment_id = '{$assignment_id}' "; $result = $this->query($sql); $row = $result->fetch_assoc(); $sqlFile = "SELECT * FROM file WHERE type_id = {$assignment_id} AND type = 'question' "; $resultFile = $this->query($sqlFile); $files = array(); while ($rowFile = $resultFile->fetch_assoc()) { $filepath = file::getFilename($rowFile['file_id'], $rowFile['extension']); $rowFile['filepath'] = $filepath; $files[] = $rowFile; } $row['files'] = $files; if (user::isStudent()) { $row['group_id'] = assignment::groupID($assignment_id); $row['editor'] = assignment::getEditor($row['group_id']); } elseif (user::isTeacher()) { $sql2 = "SELECT COUNT(*) as group_count FROM assignment_group WHERE assignment_id = '{$assignment_id}' "; $result2 = $this->query($sql2); $row2 = $result2->fetch_assoc(); $row['group_count'] = $row2['group_count']; $deadline = explode(" ", $row['deadline']); $row['due_date'] = $deadline[0]; $row['due_time'] = $deadline[1]; $sql3 = "SELECT * FROM assignment_sample_code WHERE assignment_id = '{$assignment_id}' "; $result3 = $this->query($sql3); $sample_codes = array(); while ($row3 = $result3->fetch_assoc()) { $sample_codes[] = $row3; } $row['sample_code'] = $sample_codes; } return $row; }
<?php /** * Save java code to server in a specific folder * * @param code [POST] java code string * @param folder [POST] folder to hold the code * @return 1 for successful save */ //$folder = $_POST['folder']; //$file = "../code/". $folder ."/test.java"; //unlink($file); //file_put_contents($file, $code); require "class/assignment.php"; $codeArray = $_POST['codeArray']; $group_id = $_POST['group_id']; $assignment_id = $_POST['assignment_id']; $assignmentAPI = new assignment(); echo $assignmentAPI->submitAssignment($group_id, $codeArray);
<?php require "class/assignment.php"; $assignmentID = $_POST['assignment_id']; $assignmentAPI = new assignment(); //ob_start(); $json = $assignmentAPI->testcaseRanking($assignmentID); //$json =ob_get_clean(); //$result = json_decode($json,1); echo $json;
require '../inc/config.php'; ?> <?php $userAPI->authService(); $userAPI->authRight('teacher'); ?> <?php require '../inc/template_start.php'; require '../inc/page_head.php'; require_once '../api/course.php'; require_once '../api/assignment.php'; require_once '../api/file.php'; $assignmentAPI = new assignment($_GET['assignment_id']); $courseAPI = new course($assignmentAPI->info['course_id']); ?> <!-- Page content --> <div id="page-content"> <!-- Courses Header --> <div class="content-header"> <div class="header-section"> <h1> <i class="gi gi-book_open"></i><?php echo $courseAPI->info['course_code']; ?> - <?php echo $courseAPI->info['name']; ?>
<?php /** * Compile java code in server in a specific folder * * @param folder [POST] folder to hold the code * @return 1 for successful complication */ /* $folder = "/var/www/html/code/".$_POST['folder']; $command = "sh /var/www/html/code/compile.sh $folder"; //echo $command; exec($command); $compile_error = file_get_contents("$folder/debug/compile.txt"); if($compile_error == ""){ echo "1"; }else{ echo nl2br($compile_error); } */ require "class/assignment.php"; $group_id = $_POST['group_id']; $assignmentAPI = new assignment(); echo $assignmentAPI->compileAssignment($group_id, $code);
<?php $a_id = $_POST['a_id']; $num = $_POST['num']; require "class/assignment.php"; $chatAPI = new assignment(); echo $chatAPI->createGroup($a_id, $num);
<?php require "class/assignment.php"; $assignmentID = $_POST['assignment_id']; $assignmentAPI = new assignment(); echo $assignmentAPI->generateTrainingData($assignmentID);