<commit_before>using System;
using System.Linq;
using System.Web.Mvc;
//using CRP.App_GlobalResources;
using CRP.Controllers.Filter;
using CRP.Controllers.Helpers;
using CRP.Controllers.ViewModels;
using CRP.Core.Domain;
using MvcContrib.Attributes;
using CRP.Core.Resources;
using UCDArch.Core.PersistanceSupport;
using UCDArch.Web.Controller;
using UCDArch.Web.Validator;
using UCDArch.Web.Attributes;
using MvcContrib;
using Check = UCDArch.Core.Utils.Check;

namespace CRP.Controllers
{
    [Authorize]
    [AnyoneWithRole]
    public class QuestionSetController : ApplicationController
    {
        private readonly IRepositoryWithTypedId<School, string> _schoolRepository;

        public QuestionSetController(IRepositoryWithTypedId<School, string> schoolRepository)
        {
            _schoolRepository = schoolRepository;
        }

        //
        // GET: /QuestionSet/

        public ActionResult Index()
        {
            return this.RedirectToAction(a => a.List());
        }

        /// <summary>
        /// GET: /QuestionSet/List
        /// </summary>
        /// <returns></returns>
        public ActionResult List()
        {
            IQueryable query;
            var user = Repository.OfType<User>().Queryable.Where(a => a.LoginID == CurrentUser.Identity.Name).FirstOrDefault();
            Check.Require(user != null, "User is required.");
            var schools = user.Units.Select(a => a.School).ToList();

            if (CurrentUser.IsInRole(RoleNames.Admin))
            {
                query = from a in Repository.OfType<QuestionSet>().Queryable
                        where a.SystemReusable || (a.UserReusable && a.User == user)
                            || (a.CollegeReusable && schools.Contains(a.School))
                        select a;
            }
            else if (CurrentUser.IsInRole(RoleNames.SchoolAdmin))
            {
                query = from a in Repository.OfType<QuestionSet>().Queryable
                        where (a.UserReusable && a.User == user) || (a.CollegeReusable && schools.Contains(a.School))
                        select a;
            }
            else
            {
                query = from a in Repository.OfType<QuestionSet>().Queryable
                        where (a.UserReusable && a.User == user)
                        select a;
            }

            return View(query);
        }

        public ActionResult Details(int id)
        {
            var questionSet = Repository.OfType<QuestionSet>().GetNullableById(id);<commit_msg>fix query tolist<commit_after>using System;
using System.Linq;
using System.Web.Mvc;
using CRP.Controllers.Filter;
using CRP.Controllers.Helpers;
using CRP.Controllers.ViewModels;
using CRP.Core.Domain;
using CRP.Core.Resources;
using UCDArch.Core.PersistanceSupport;
using UCDArch.Web.Validator;
using UCDArch.Web.Attributes;
using MvcContrib;
using Check = UCDArch.Core.Utils.Check;

namespace CRP.Controllers
{
    [Authorize]
    [AnyoneWithRole]
    public class QuestionSetController : ApplicationController
    {
        private readonly IRepositoryWithTypedId<School, string> _schoolRepository;

        public QuestionSetController(IRepositoryWithTypedId<School, string> schoolRepository)
        {
            _schoolRepository = schoolRepository;
        }

        //
        // GET: /QuestionSet/

        public ActionResult Index()
        {
            return this.RedirectToAction(a => a.List());
        }

        /// <summary>
        /// GET: /QuestionSet/List
        /// </summary>
        /// <returns></returns>
        public ActionResult List()
        {
            IQueryable<QuestionSet> query;
            var user = Repository.OfType<User>().Queryable.FirstOrDefault(a => a.LoginID == CurrentUser.Identity.Name);
            Check.Require(user != null, "User is required.");
            var schools = user.Units.Select(a => a.School).ToList();

            if (CurrentUser.IsInRole(RoleNames.Admin))
            {
                query = from a in Repository.OfType<QuestionSet>().Queryable
                        where a.SystemReusable
                            || (a.UserReusable && Equals(a.User, user))
                            || (a.CollegeReusable && schools.Contains(a.School))
                        select a;
            }
            else if (CurrentUser.IsInRole(RoleNames.SchoolAdmin))
            {
                query = from a in Repository.OfType<QuestionSet>().Queryable
                        where (a.UserReusable && Equals(a.User, user)) || (a.CollegeReusable && schools.Contains(a.School))
                        select a;
            }
            else
            {
                query = from a in Repository.OfType<QuestionSet>().Queryable
                        where a.UserReusable && Equals(a.User, user)
                        select a;
            }

            return View(query.ToList());
        }

        public ActionResult Details(int id)
        {
            var questionSet = Repository.OfType<QuestionSet>().GetNullableById(id);
{'fraction_non_alphanumeric': 0.10511756569847856, 'fraction_numerical': 0.0, 'mean_word_length': 1.8991981672394043, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1876964', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1330, 'n_words': 269}