<?php

class Activity extends Eloquent
{

  public function section()
  {
    return $this->belongsTo('Section');
  }

  public function rubric()
  {
    return $this->belongsTo('Rubric');
  }

  public function course()
  {
    return $this->belongsTo('Course');
  }

  public function assessed_students()
  {
    return $this->belongsToMany('Student', 'assessments')->withPivot('scores', 'percentage')->withTimestamps();
  }

  // cap_array
  public function getCapArrayAttribute($value)
  {
      return json_decode($this->criteria_achieved_percentage, true);
  }

  // o_ach_array
  public function getOAchArrayAttribute($value)
  {
      return json_decode($this->outcomes_achieved, true);
  }

  // o_att_array
  public function getOAttArrayAttribute($value)
  {
      return json_decode($this->outcomes_attempted, true);
  }

}
