Skip to content

Commit

Permalink
Merge pull request #75 from SlateFoundation/develop
Browse files Browse the repository at this point in the history
Release: slate v2.1.12
  • Loading branch information
themightychris authored Oct 6, 2016
2 parents b49c2b4 + 4c40ecb commit 6e746d0
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions php-classes/Slate/Progress/SectionInterimReportsRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,57 @@

namespace Slate\Progress;

use Slate\Term;
use Slate\Courses\Section;
use Slate\People\Student;


class SectionInterimReportsRequestHandler extends \RecordsRequestHandler
{
public static $recordClass = SectionInterimReport::class;

public static function handleBrowseRequest($options = [], $conditions = [], $responseID = null, $responseData = [])
{
if (!empty($_REQUEST['term'])) {
if ($_REQUEST['term'] == 'current') {
if (!$Term = Term::getClosest()) {
return static::throwInvalidRequestError('No current term could be found');
}
} elseif (!$Term = Term::getByHandle($_REQUEST['term'])) {
return static::throwNotFoundError('term not found');
}

$conditions[] = sprintf('TermID IN (%s)', join(',', $Term->getRelatedTermIDs()));
$responseData['term'] = $Term;
}

if (!empty($_REQUEST['course_section'])) {
if (!$Section = Section::getByHandle($_REQUEST['course_section'])) {
return static::throwNotFoundError('course_section not found');
}

$conditions['SectionID'] = $Section->ID;
$responseData['course_section'] = $Section;
}

if (!empty($_REQUEST['students'])) {
$studentIds = [];

foreach (Student::getAllByListIdentifier($_REQUEST['students']) AS $Student) {
$studentIds[] = $Student->ID;
}

$conditions[] = sprintf('StudentID IN (%s)', count($studentIds) ? join(',', $studentIds) : '0');
}

if (!empty($_REQUEST['status'])) {
if (!in_array($_REQUEST['status'], Report::getFieldOptions('Status', 'values'))) {
return static::throwInvalidRequestError('Invalid status');
}

$conditions['Status'] = $_REQUEST['status'];
}

return parent::handleBrowseRequest($options, $conditions, $responseID, $responseData);
}
}

0 comments on commit 6e746d0

Please sign in to comment.