<?php

class Activity extends Eloquent
{

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

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

  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);
  }

}