Ejemplo n.º 1
0
 public function doRestCreate($data)
 {
     /*       dumpvar($data);
              dumpvar($_POST);exit;*/
     $isUpdate = !empty($_POST['id']) ? true : false;
     if (isset($_POST)) {
         $collections = explode(',', $_POST['collections']);
         $collections_are_empty = empty($_POST['collections']);
         if ($isUpdate) {
             array_shift($collections);
         }
         //workaround a select2 bug which sets the first selected item as  an unwanted [object Object]
         if ($isUpdate) {
             $model = $this->loadOneModel($_POST['id']);
         } else {
             $model = new Image();
         }
         //delete old image if we are updating
         if ($isUpdate && !empty($_POST['image'])) {
             @unlink($model->getFullImageFolderPath() . $model->getImageName('full'));
             @unlink($model->getThumbImageFolderPath() . $model->getImageName('thumb'));
         }
         $model->attributes = !empty($_POST) ? $_POST : $data;
         $model->image = CUploadedFile::getInstanceByName('image');
         if (isset($model->image)) {
             $model->img_name = slugify(file_ext_strip($model->image->name));
             $model->img_size = $model->image->size;
             $model->img_ext = $model->image->extensionName;
         }
         if (!$collections_are_empty) {
             $model->collections = $collections;
         } else {
             $model->collections = array();
         }
         //additional afterSave logic in Model file
         if ($model->save()) {
             header('success', true, 200);
             echo json_encode(array('data' => array('success' => true, strtolower(get_class($model)) => $model->attributes, 'collections' => $model->collections)));
             exit;
         } else {
             header('error', true, 400);
             $errors = $model->getErrors();
             echo json_encode(array('success' => false, 'message' => $errors, 'errorCode' => '400'));
             exit;
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
        echo "SKIPPING summary " . $filename . " file...<br/>";
        unlink($fileInfo->getPathname());
        continue;
    }
    //"Submission (16 Oct 2015)_adanmm_attempt_2015-10-16-17-00-49_Mahad Adan Problem solving Essay 1.pdf"
    $summaryFileRegex = '/^Submission \\((.*)\\)_([a-z0-9]+)_attempt_(\\d{4}-\\d{2}-\\d{2}-\\d{2}-\\d{2}-\\d{2})_(.*)$/';
    preg_match($summaryFileRegex, $filename, $matches);
    if (count($matches) !== 5) {
        echo "WARNING: Filename not matching pattern expected..." . $filename . "<br/>";
        continue;
    }
    $assignmentTitle = $matches[1];
    $studentUsername = $matches[2];
    $dateTimeOfSubmission = $matches[3];
    $originalFilename = $matches[4];
    $submissionTitle = file_ext_strip($originalFilename);
    //Setup defaults
    $submissions[$extractedZipDir] = isset($submissions[$extractedZipDir]) ? $submissions[$extractedZipDir] : array();
    $submissions[$extractedZipDir][$studentUsername] = isset($submissions[$extractedZipDir][$studentUsername]) ? $submissions[$extractedZipDir][$studentUsername] : array();
    //Populate..
    $submissions[$extractedZipDir][$studentUsername]["assignmentTitle"] = $assignmentTitle;
    $submissions[$extractedZipDir][$studentUsername]["dateTimeOfSubmission"] = $dateTimeOfSubmission;
    $submissions[$extractedZipDir][$studentUsername]["originalFilename"] = $originalFilename;
    $submissions[$extractedZipDir][$studentUsername]["submissionTitle"] = $submissionTitle;
    $submissions[$extractedZipDir][$studentUsername]["path"] = $fileInfo->getPathname();
    $submissions[$extractedZipDir][$studentUsername]["ext"] = $fileInfo->getExtension();
}
// var_dump($submissions);
$counter = 0;
//assignment_ID, assignment_title, filename, student_ID, comments, submit_date, mark, marking_status, general_comment
// Iterate through each of the submissions and import it into the system
<?php

include "includes/config.php";
include "includes/session.php";
include "includes/functions.php";
$filename = isset($_GET['content_id']) ? trim($_GET['content_id']) : '';
$contentID = file_ext_strip($filename);
/*$contentID = str_replace('.html', '',$contentID);
$contentID = str_replace('.htm', '', $contentID);
$contentID = str_replace('-', '_', $contentID);*/
$cms_content_main = displayCMS($contentID);
/*display the active template*/
$active_template = displayTemplate();
//echo stripslashes($cms_content_main[1]);
include "includes/htmltop.php";
/* Top File Name */
include_once "includes/" . $active_template[0];
?>
<!-- content area Right Column starts-------------------------------------------------------------- -->


    <div align="left" class="main_body">
        <!--mainbody area start -->
        <!--center content area start-->
        <!-- Bread Crumb Area -->
        <?php 
echo generalMethods::getBreadCrumbs(array(array('url' => '', 'name' => strip_tags($cms_content_main[0]))));
?>
        <!-- Bread Crumb Area End -->
        <br/>
        <div class="pcm_content_rightcolumn">
Ejemplo n.º 4
0
}
function file_title_case($filename)
{
    return ucwords($filename);
}
function list_directory($dir)
{
    $dir_list = array();
    // Only add .txt/.pdf files
    foreach (glob($dir . "*.{txt,pdf}", GLOB_BRACE) as $file) {
        array_push($dir_list, basename($file));
    }
    natcasesort($dir_list);
    // case-insensitive sort
    return $dir_list;
}
// print out html
echo "\t" . '<ul>' . "\r\n\t";
$directory_array = list_directory(WP_CONTENT_DIR . $default_dir);
global $pagename;
if ('minutes' === $pagename) {
    rsort($directory_array);
}
foreach ($directory_array as $fn) {
    $fn_ext = $fn;
    $fn = file_ext_strip($fn);
    $fn = file_replace_spacer($fn);
    $fn = file_title_case($fn);
    echo "<li><a href=" . chr(34) . content_url() . $default_dir . $fn_ext . chr(34) . ">" . $fn . "</a></li>\r\n\t";
}
echo '</ul>' . "\r\n\t";