Exemplo n.º 1
0
                        }
                        if (!($emarking = $DB->get_record('emarking', array('id' => $emarkingid)))) {
                            emarking_json_error('Invalid emarking id');
                        }
                        if (!($cm = get_coursemodule_from_instance('emarking', $emarking->id, $course->id))) {
                            emarking_json_error('Invalid course module');
                        }
                        if (count($_FILES) < 1 || !is_uploaded_file($_FILES['uploadedfile']['tmp_name'])) {
                            emarking_json_error('You must upload a file');
                        }
                        $extension = strtolower(substr($_FILES['uploadedfile']['name'], strrpos($_FILES['uploadedfile']['name'], "."), strlen($_FILES['uploadedfile']['name']) - strrpos($_FILES['uploadedfile']['name'], ".")));
                        if ($extension !== '.zip') {
                            emarking_json_error('Invalid extension file ' . $extension . ' in ' . $_FILES['uploadedfile']['tmp_name'] . '. Only zip files are allowed');
                        }
                        // Setup de directorios temporales
                        $tempdir = emarking_get_temp_dir_path($emarking->id);
                        emarking_initialize_directory($tempdir, true);
                        $fileid = $tempdir . "/" . random_string() . ".zip";
                        if (!move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $fileid)) {
                            emarking_json_error("Couldn't move file " . $_FILES['uploadedfile']['tmp_name'] . " to " . $fileid);
                        }
                        emarking_upload_answers($emarking, $fileid, $course, $cm);
                        $output = array($emarking - id => $emarking);
                        emarking_json_resultset($output);
                    }
                }
            }
        }
    }
}
emarking_json_error('Invalid action');
Exemplo n.º 2
0
     break;
 case 'getvaluescollaborativebuttons':
     $output = emarking_get_values_collaborative();
     emarking_json_array($output);
     break;
 case 'merlot':
     $output = emarking_get_resources_merlot($keywords);
     emarking_json_array($output);
     break;
 case 'ocwmit':
     $output = emarking_get_resources_ocwmit($keywords);
     emarking_json_array($output);
     break;
 case 'prevcomments':
     $results = emarking_get_previous_comments($submission, $draft);
     emarking_json_resultset($results);
     break;
 case 'rotatepage':
     if (!$issupervisor) {
         emarking_json_error('Invalid access');
     }
     list($imageurl, $anonymousurl, $imgwidth, $imgheight) = emarking_rotate_image($pageno, $submission, $context);
     if (strlen($imageurl) == 0) {
         emarking_json_error('Image is empty');
     }
     $output = array('imageurl' => $imageurl, 'anonymousimageurl' => $anonymousurl, 'width' => $imgwidth, 'height' => $imgheight);
     emarking_json_array($output);
     break;
 case 'sortpages':
     $neworder = required_param('neworder', PARAM_SEQUENCE);
     $neworderarr = explode(',', $neworder);
Exemplo n.º 3
0
/**
 *
 * @return multitype:
 */
function emarking_get_values_collaborative()
{
    global $DB;
    // The comment id.
    $commentid = required_param('commentid', PARAM_INT);
    $type = optional_param('type', null, PARAM_INT);
    $filter = "";
    if ($type != null) {
        $filter = "AND cw.type = {$type}";
    }
    $sqlvaluesbuttons = "\n            SELECT cw.id,\n            cw.markerid,\n            cw.type,\n            CONCAT(u.username, ' ', u.lastname) AS markername,\n            FROM_UNIXTIME(cw.createdtime) AS date,\n            cw.text\n    FROM {emarking_collaborative_work} cw\n    INNER JOIN {user} u ON (cw.markerid = u.id)\n    WHERE cw.commentid = ? AND cw.status = ? {$filter}\n    ORDER BY cw.createdtime ASC";
    $collaborativevalues = $DB->get_records_sql($sqlvaluesbuttons, array($commentid, '1'));
    if (!$collaborativevalues || $collaborativevalues == null) {
        $collaborativevalues = array();
        emarking_json_resultset($collaborativevalues);
        break;
    } else {
        foreach ($collaborativevalues as $obj) {
            $output[] = $obj;
        }
    }
    return $collaborativevalues;
}