<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Xli76</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Xli76"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Xli76"/>
	<updated>2026-06-07T01:20:30Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114385</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114385"/>
		<updated>2017-12-03T17:03:58Z</updated>

		<summary type="html">&lt;p&gt;Xli76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bugs ===&lt;br /&gt;
After we decided to move to another project, Prof. Gehringer mentioned two minor bugs in tree_display/list page.&lt;br /&gt;
&lt;br /&gt;
==== Minor bug1 ====&lt;br /&gt;
[[File:Najsbfdfdfdf.PNG]]&lt;br /&gt;
&lt;br /&gt;
In &amp;quot;Questionnaires&amp;quot; table, after the user click one row to expand the table, he cannot click again to close it. It would raise an error &amp;quot;TypeError: React.addons is undefined&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Minor bug2 ====&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Others' Public Assignments&amp;quot; list is very long and unorganized. We need to organize it first by &amp;quot;Instructor&amp;quot; and then by &amp;quot;Creation Date&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
Here's a demo http://chairnerd.seatgeek.com/react-infinite-a-browser-ready-efficient-scrolling-container-based-on-uitableview/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Previous Attempt ==&lt;br /&gt;
While we are working on this project, we have tried multiple approaches, but nothing had worked out. &lt;br /&gt;
&lt;br /&gt;
The first one is jscroll, we had load jscroll into vendor directory using bower, and able to required in the project, but it turns out that jscroll doesn’t work in ReactJS.&lt;br /&gt;
 &lt;br /&gt;
Thus, we tried to find third party React Plugins to achieve the function of infinite scroll. &lt;br /&gt;
&lt;br /&gt;
The first React Plugin is react-infinite, We were also able to load react-infinite into vendor directory using bower, and has no error occurred while adding to the react component.&lt;br /&gt;
&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;: &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it also didn’t work out because of the main content is html table. &lt;br /&gt;
&lt;br /&gt;
After that, we have asked this problem on the stackoverflow. People recommended another plugin called react-infinite-scroller, this plugin couldn’t find by bower package manager, so we have to load this package by another package manager like webpacker, but webpacker needs Rails 5 to load React, however Expertiza is based on Rails 4.2.6. We’ve also tried sprockets but we were unable to import.&lt;br /&gt;
&lt;br /&gt;
Our last try is https://infinite-scroll.com/ https://github.com/metafizzy/infinite-scroll&lt;br /&gt;
&lt;br /&gt;
 componentWillUpdate: function() {&lt;br /&gt;
          console.log(1111);&lt;br /&gt;
          var $container = $('.scroll').infiniteScroll({&lt;br /&gt;
              // path is required, hack with {{#}}&lt;br /&gt;
              path: 'page{{#}}',&lt;br /&gt;
              loadOnScroll: false,&lt;br /&gt;
              scrollThreshold: 400&lt;br /&gt;
          });&lt;br /&gt;
          $container.on( 'scrollThreshold.infiniteScroll', function() {&lt;br /&gt;
              console.log(2222);&lt;br /&gt;
              $container.append(&amp;lt;ContentTableRow&lt;br /&gt;
                  key={1}&lt;br /&gt;
                  id={1}&lt;br /&gt;
                  name={1}&lt;br /&gt;
                  directory={1}&lt;br /&gt;
                  instructor={1}&lt;br /&gt;
                  institution={1}&lt;br /&gt;
                  creation_date={1}&lt;br /&gt;
                  updated_date={1}&lt;br /&gt;
                  actions={1}&lt;br /&gt;
                  is_available={1}&lt;br /&gt;
                  course_id={1}&lt;br /&gt;
                  max_team_size={1}&lt;br /&gt;
                  is_intelligent={1}&lt;br /&gt;
                  require_quiz={1}&lt;br /&gt;
                  dataType={1}&lt;br /&gt;
                  //this is just a hack. All current users courses are marked as private during fetch for display purpose.&lt;br /&gt;
                  private={1}&lt;br /&gt;
                  allow_suggestions={1}&lt;br /&gt;
                  has_topic={1}&lt;br /&gt;
                  rowClicked={1}&lt;br /&gt;
                  newParams={1}&lt;br /&gt;
              /&amp;gt;);&lt;br /&gt;
          })&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
But we still stuck at this bug.&lt;br /&gt;
&lt;br /&gt;
 TypeError: instance._init is not a function.&lt;br /&gt;
&lt;br /&gt;
This project turns out to be really complicated to implement. So we asked to switch the project to implement Rspec integration test for the users_controller.rb&lt;br /&gt;
&lt;br /&gt;
== Implementation &amp;amp; Test Plan ==&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
&lt;br /&gt;
Because React.addons cannot be used here, I changed it to the function of JS.&lt;br /&gt;
&lt;br /&gt;
        var index = this.state.expandedRow.indexOf(id)&lt;br /&gt;
        if (index &amp;gt; -1) {&lt;br /&gt;
            var list = this.state.expandedRow;&lt;br /&gt;
            list.splice(index,1);&lt;br /&gt;
          this.setState({&lt;br /&gt;
            expandedRow: list&lt;br /&gt;
          })&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
=== Minor bug2 ===&lt;br /&gt;
&lt;br /&gt;
I sorted the list before the data is returned to the frontend in the tree_display_controller.rb. The list is sorted first in ascending order of 'instructor' and then in the descending order of 'creation_date' which requires 'creation_date' to be converted to timestamp.&lt;br /&gt;
&lt;br /&gt;
 res['Assignments'] = res['Assignments'].sort_by {|x| [x['instructor'],-1*(x['creation_date'].to_i)]}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== users_controller.rb Test ===&lt;br /&gt;
Our new project is to write Rspec Test for the users_controller.rb.&lt;br /&gt;
&lt;br /&gt;
Here is our code.&lt;br /&gt;
 require 'pry'&lt;br /&gt;
&lt;br /&gt;
 describe UsersController do&lt;br /&gt;
  let(:admin) {build(:admin)}&lt;br /&gt;
  let(:superadmin) {build(:superadmin)}&lt;br /&gt;
  let(:instructor) {build(:instructor, id: 6)}&lt;br /&gt;
  let(:instructor2) {build(:instructor, id: 66)}&lt;br /&gt;
  let(:ta) {build(:teaching_assistant, id: 8)}&lt;br /&gt;
  let(:student) {build(:student)}&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(User).to receive(:find_by_name).with('instructor6').and_return(instructor)&lt;br /&gt;
    allow(User).to receive(:find_by_name).with('instructor66').and_return(instructor2)&lt;br /&gt;
    allow(User).to receive(:find).with('1').and_return(instructor2)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#action_allowed?' do&lt;br /&gt;
    context 'when params action is request_new' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'request_new'}&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is request_user_create' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'request_user_create'}&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is review' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'review'}&lt;br /&gt;
        stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is keys' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'keys'}&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the current role is administrator and params action is something else' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'view'}&lt;br /&gt;
        stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the current role is superadministrator and params action is something else' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'view'}&lt;br /&gt;
        stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the current role is instructor and params action is something else' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'view'}&lt;br /&gt;
        stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the current role is ta and params action is something else' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'view'}&lt;br /&gt;
        stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#index' do&lt;br /&gt;
    context 'when the current user is student' do&lt;br /&gt;
      it 'redirect to the home page' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        get :index&lt;br /&gt;
        expect(response).to redirect_to('/')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the current user is not student' do&lt;br /&gt;
      it 'redirect to /users/list page' do&lt;br /&gt;
        stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
        @request.session['user'] = instructor&lt;br /&gt;
        get :index&lt;br /&gt;
        expect(response).to render_template(:list)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#list' do&lt;br /&gt;
    it 'render list' do&lt;br /&gt;
      stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
      @request.session['user'] = instructor&lt;br /&gt;
      get :list&lt;br /&gt;
      expect(response).to render_template(:list)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#list_pending_requested' do&lt;br /&gt;
    it 'render list pending' do&lt;br /&gt;
      stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
      get :list_pending_requested&lt;br /&gt;
      expect(response).to render_template(:list_pending_requested)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#new' do&lt;br /&gt;
    it 'creates a new user and renders users#new page' do&lt;br /&gt;
      stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
      @request.session['user'] = instructor&lt;br /&gt;
      get :new&lt;br /&gt;
      expect(response).to render_template(:new)&lt;br /&gt;
      expect(assigns(:user)).to be_a_new(User)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#request_new' do&lt;br /&gt;
    context 'when the current user is not student' do&lt;br /&gt;
      it 'creates a new user and renders users#new page' do&lt;br /&gt;
        stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
        @request.session['user'] = instructor&lt;br /&gt;
        get :new&lt;br /&gt;
        expect(response).to render_template(:new)&lt;br /&gt;
        expect(assigns(:user)).to be_a_new(User)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#show_selection' do&lt;br /&gt;
    context 'when user is not nil and parent id is nil' do&lt;br /&gt;
      it 'redirect to /users/show' do&lt;br /&gt;
        stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
        get :show_selection, {user: {name: 'instructor6'}}&lt;br /&gt;
        expect(response).to render_template(:show)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#show' do&lt;br /&gt;
    context 'when params id is nil' do&lt;br /&gt;
      it 'redirect to /tree_display/drill' do&lt;br /&gt;
        stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
        get :show, id: nil&lt;br /&gt;
        expect(response).to redirect_to('/tree_display/drill')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when params id is not nil' do&lt;br /&gt;
      it 'render show' do&lt;br /&gt;
        stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
        get :show, id: 1&lt;br /&gt;
        expect(response).to render_template(:show)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#edit' do&lt;br /&gt;
    it 'can find user' do&lt;br /&gt;
      stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
      @request.session['user'] = instructor&lt;br /&gt;
      get :edit, id: 1&lt;br /&gt;
      expect(response).to render_template(:edit)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Test Result ===&lt;br /&gt;
The test result is as below:&lt;br /&gt;
&lt;br /&gt;
[[File:Sadasd.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; [http://jscroll.com/ jscroll]&lt;br /&gt;
&amp;lt;li&amp;gt; [https://github.com/seatgeek/react-infinite react-infinite]&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114384</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114384"/>
		<updated>2017-12-03T17:03:31Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Test Result */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bugs ===&lt;br /&gt;
After we decided to move to another project, Prof. Gehringer mentioned two minor bugs in tree_display/list page.&lt;br /&gt;
&lt;br /&gt;
==== Minor bug1 ====&lt;br /&gt;
[[File:Najsbfdfdfdf.PNG]]&lt;br /&gt;
&lt;br /&gt;
In &amp;quot;Questionnaires&amp;quot; table, after the user click one row to expand the table, he cannot click again to close it. It would raise an error &amp;quot;TypeError: React.addons is undefined&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Minor bug2 ====&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Others' Public Assignments&amp;quot; list is very long and unorganized. We need to organize it first by &amp;quot;Instructor&amp;quot; and then by &amp;quot;Creation Date&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
Here's a demo http://chairnerd.seatgeek.com/react-infinite-a-browser-ready-efficient-scrolling-container-based-on-uitableview/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; [http://jscroll.com/ jscroll]&lt;br /&gt;
&amp;lt;li&amp;gt; [https://github.com/seatgeek/react-infinite react-infinite]&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Previous Attempt ==&lt;br /&gt;
While we are working on this project, we have tried multiple approaches, but nothing had worked out. &lt;br /&gt;
&lt;br /&gt;
The first one is jscroll, we had load jscroll into vendor directory using bower, and able to required in the project, but it turns out that jscroll doesn’t work in ReactJS.&lt;br /&gt;
 &lt;br /&gt;
Thus, we tried to find third party React Plugins to achieve the function of infinite scroll. &lt;br /&gt;
&lt;br /&gt;
The first React Plugin is react-infinite, We were also able to load react-infinite into vendor directory using bower, and has no error occurred while adding to the react component.&lt;br /&gt;
&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;: &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it also didn’t work out because of the main content is html table. &lt;br /&gt;
&lt;br /&gt;
After that, we have asked this problem on the stackoverflow. People recommended another plugin called react-infinite-scroller, this plugin couldn’t find by bower package manager, so we have to load this package by another package manager like webpacker, but webpacker needs Rails 5 to load React, however Expertiza is based on Rails 4.2.6. We’ve also tried sprockets but we were unable to import.&lt;br /&gt;
&lt;br /&gt;
Our last try is https://infinite-scroll.com/ https://github.com/metafizzy/infinite-scroll&lt;br /&gt;
&lt;br /&gt;
 componentWillUpdate: function() {&lt;br /&gt;
          console.log(1111);&lt;br /&gt;
          var $container = $('.scroll').infiniteScroll({&lt;br /&gt;
              // path is required, hack with {{#}}&lt;br /&gt;
              path: 'page{{#}}',&lt;br /&gt;
              loadOnScroll: false,&lt;br /&gt;
              scrollThreshold: 400&lt;br /&gt;
          });&lt;br /&gt;
          $container.on( 'scrollThreshold.infiniteScroll', function() {&lt;br /&gt;
              console.log(2222);&lt;br /&gt;
              $container.append(&amp;lt;ContentTableRow&lt;br /&gt;
                  key={1}&lt;br /&gt;
                  id={1}&lt;br /&gt;
                  name={1}&lt;br /&gt;
                  directory={1}&lt;br /&gt;
                  instructor={1}&lt;br /&gt;
                  institution={1}&lt;br /&gt;
                  creation_date={1}&lt;br /&gt;
                  updated_date={1}&lt;br /&gt;
                  actions={1}&lt;br /&gt;
                  is_available={1}&lt;br /&gt;
                  course_id={1}&lt;br /&gt;
                  max_team_size={1}&lt;br /&gt;
                  is_intelligent={1}&lt;br /&gt;
                  require_quiz={1}&lt;br /&gt;
                  dataType={1}&lt;br /&gt;
                  //this is just a hack. All current users courses are marked as private during fetch for display purpose.&lt;br /&gt;
                  private={1}&lt;br /&gt;
                  allow_suggestions={1}&lt;br /&gt;
                  has_topic={1}&lt;br /&gt;
                  rowClicked={1}&lt;br /&gt;
                  newParams={1}&lt;br /&gt;
              /&amp;gt;);&lt;br /&gt;
          })&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
But we still stuck at this bug.&lt;br /&gt;
&lt;br /&gt;
 TypeError: instance._init is not a function.&lt;br /&gt;
&lt;br /&gt;
This project turns out to be really complicated to implement. So we asked to switch the project to implement Rspec integration test for the users_controller.rb&lt;br /&gt;
&lt;br /&gt;
== Implementation &amp;amp; Test Plan ==&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
&lt;br /&gt;
Because React.addons cannot be used here, I changed it to the function of JS.&lt;br /&gt;
&lt;br /&gt;
        var index = this.state.expandedRow.indexOf(id)&lt;br /&gt;
        if (index &amp;gt; -1) {&lt;br /&gt;
            var list = this.state.expandedRow;&lt;br /&gt;
            list.splice(index,1);&lt;br /&gt;
          this.setState({&lt;br /&gt;
            expandedRow: list&lt;br /&gt;
          })&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
=== Minor bug2 ===&lt;br /&gt;
&lt;br /&gt;
I sorted the list before the data is returned to the frontend in the tree_display_controller.rb. The list is sorted first in ascending order of 'instructor' and then in the descending order of 'creation_date' which requires 'creation_date' to be converted to timestamp.&lt;br /&gt;
&lt;br /&gt;
 res['Assignments'] = res['Assignments'].sort_by {|x| [x['instructor'],-1*(x['creation_date'].to_i)]}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== users_controller.rb Test ===&lt;br /&gt;
Our new project is to write Rspec Test for the users_controller.rb.&lt;br /&gt;
&lt;br /&gt;
Here is our code.&lt;br /&gt;
 require 'pry'&lt;br /&gt;
&lt;br /&gt;
 describe UsersController do&lt;br /&gt;
  let(:admin) {build(:admin)}&lt;br /&gt;
  let(:superadmin) {build(:superadmin)}&lt;br /&gt;
  let(:instructor) {build(:instructor, id: 6)}&lt;br /&gt;
  let(:instructor2) {build(:instructor, id: 66)}&lt;br /&gt;
  let(:ta) {build(:teaching_assistant, id: 8)}&lt;br /&gt;
  let(:student) {build(:student)}&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(User).to receive(:find_by_name).with('instructor6').and_return(instructor)&lt;br /&gt;
    allow(User).to receive(:find_by_name).with('instructor66').and_return(instructor2)&lt;br /&gt;
    allow(User).to receive(:find).with('1').and_return(instructor2)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#action_allowed?' do&lt;br /&gt;
    context 'when params action is request_new' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'request_new'}&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is request_user_create' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'request_user_create'}&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is review' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'review'}&lt;br /&gt;
        stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is keys' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'keys'}&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the current role is administrator and params action is something else' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'view'}&lt;br /&gt;
        stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the current role is superadministrator and params action is something else' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'view'}&lt;br /&gt;
        stub_current_user(superadmin, superadmin.role.name, superadmin.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the current role is instructor and params action is something else' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'view'}&lt;br /&gt;
        stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the current role is ta and params action is something else' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        controller.params = {action: 'view'}&lt;br /&gt;
        stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#index' do&lt;br /&gt;
    context 'when the current user is student' do&lt;br /&gt;
      it 'redirect to the home page' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        get :index&lt;br /&gt;
        expect(response).to redirect_to('/')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the current user is not student' do&lt;br /&gt;
      it 'redirect to /users/list page' do&lt;br /&gt;
        stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
        @request.session['user'] = instructor&lt;br /&gt;
        get :index&lt;br /&gt;
        expect(response).to render_template(:list)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#list' do&lt;br /&gt;
    it 'render list' do&lt;br /&gt;
      stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
      @request.session['user'] = instructor&lt;br /&gt;
      get :list&lt;br /&gt;
      expect(response).to render_template(:list)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#list_pending_requested' do&lt;br /&gt;
    it 'render list pending' do&lt;br /&gt;
      stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
      get :list_pending_requested&lt;br /&gt;
      expect(response).to render_template(:list_pending_requested)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#new' do&lt;br /&gt;
    it 'creates a new user and renders users#new page' do&lt;br /&gt;
      stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
      @request.session['user'] = instructor&lt;br /&gt;
      get :new&lt;br /&gt;
      expect(response).to render_template(:new)&lt;br /&gt;
      expect(assigns(:user)).to be_a_new(User)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#request_new' do&lt;br /&gt;
    context 'when the current user is not student' do&lt;br /&gt;
      it 'creates a new user and renders users#new page' do&lt;br /&gt;
        stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
        @request.session['user'] = instructor&lt;br /&gt;
        get :new&lt;br /&gt;
        expect(response).to render_template(:new)&lt;br /&gt;
        expect(assigns(:user)).to be_a_new(User)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#show_selection' do&lt;br /&gt;
    context 'when user is not nil and parent id is nil' do&lt;br /&gt;
      it 'redirect to /users/show' do&lt;br /&gt;
        stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
        get :show_selection, {user: {name: 'instructor6'}}&lt;br /&gt;
        expect(response).to render_template(:show)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#show' do&lt;br /&gt;
    context 'when params id is nil' do&lt;br /&gt;
      it 'redirect to /tree_display/drill' do&lt;br /&gt;
        stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
        get :show, id: nil&lt;br /&gt;
        expect(response).to redirect_to('/tree_display/drill')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when params id is not nil' do&lt;br /&gt;
      it 'render show' do&lt;br /&gt;
        stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
        get :show, id: 1&lt;br /&gt;
        expect(response).to render_template(:show)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe '#edit' do&lt;br /&gt;
    it 'can find user' do&lt;br /&gt;
      stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
      @request.session['user'] = instructor&lt;br /&gt;
      get :edit, id: 1&lt;br /&gt;
      expect(response).to render_template(:edit)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Test Result ===&lt;br /&gt;
The test result is as below:&lt;br /&gt;
&lt;br /&gt;
[[File:Sadasd.PNG]]&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Sadasd.PNG&amp;diff=114383</id>
		<title>File:Sadasd.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Sadasd.PNG&amp;diff=114383"/>
		<updated>2017-12-03T17:03:11Z</updated>

		<summary type="html">&lt;p&gt;Xli76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114379</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114379"/>
		<updated>2017-12-03T16:56:38Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Implementation &amp;amp; Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bugs ===&lt;br /&gt;
After we decided to move to another project, Prof. Gehringer mentioned two minor bugs in tree_display/list page.&lt;br /&gt;
&lt;br /&gt;
==== Minor bug1 ====&lt;br /&gt;
[[File:Najsbfdfdfdf.PNG]]&lt;br /&gt;
&lt;br /&gt;
In &amp;quot;Questionnaires&amp;quot; table, after the user click one row to expand the table, he cannot click again to close it. It would raise an error &amp;quot;TypeError: React.addons is undefined&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Minor bug2 ====&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Others' Public Assignments&amp;quot; list is very long and unorganized. We need to organize it first by &amp;quot;Instructor&amp;quot; and then by &amp;quot;Creation Date&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
Here's a demo http://chairnerd.seatgeek.com/react-infinite-a-browser-ready-efficient-scrolling-container-based-on-uitableview/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; [http://jscroll.com/ jscroll]&lt;br /&gt;
&amp;lt;li&amp;gt; [https://github.com/seatgeek/react-infinite react-infinite]&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Previous Attempt ==&lt;br /&gt;
While we are working on this project, we have tried multiple approaches, but nothing had worked out. &lt;br /&gt;
&lt;br /&gt;
The first one is jscroll, we had load jscroll into vendor directory using bower, and able to required in the project, but it turns out that jscroll doesn’t work in ReactJS.&lt;br /&gt;
 &lt;br /&gt;
Thus, we tried to find third party React Plugins to achieve the function of infinite scroll. &lt;br /&gt;
&lt;br /&gt;
The first React Plugin is react-infinite, We were also able to load react-infinite into vendor directory using bower, and has no error occurred while adding to the react component.&lt;br /&gt;
&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;: &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it also didn’t work out because of the main content is html table. &lt;br /&gt;
&lt;br /&gt;
After that, we have asked this problem on the stackoverflow. People recommended another plugin called react-infinite-scroller, this plugin couldn’t find by bower package manager, so we have to load this package by another package manager like webpacker, but webpacker needs Rails 5 to load React, however Expertiza is based on Rails 4.2.6. We’ve also tried sprockets but we were unable to import.&lt;br /&gt;
&lt;br /&gt;
Our last try is https://infinite-scroll.com/ https://github.com/metafizzy/infinite-scroll&lt;br /&gt;
&lt;br /&gt;
 componentWillUpdate: function() {&lt;br /&gt;
          console.log(1111);&lt;br /&gt;
          var $container = $('.scroll').infiniteScroll({&lt;br /&gt;
              // path is required, hack with {{#}}&lt;br /&gt;
              path: 'page{{#}}',&lt;br /&gt;
              loadOnScroll: false,&lt;br /&gt;
              scrollThreshold: 400&lt;br /&gt;
          });&lt;br /&gt;
          $container.on( 'scrollThreshold.infiniteScroll', function() {&lt;br /&gt;
              console.log(2222);&lt;br /&gt;
              $container.append(&amp;lt;ContentTableRow&lt;br /&gt;
                  key={1}&lt;br /&gt;
                  id={1}&lt;br /&gt;
                  name={1}&lt;br /&gt;
                  directory={1}&lt;br /&gt;
                  instructor={1}&lt;br /&gt;
                  institution={1}&lt;br /&gt;
                  creation_date={1}&lt;br /&gt;
                  updated_date={1}&lt;br /&gt;
                  actions={1}&lt;br /&gt;
                  is_available={1}&lt;br /&gt;
                  course_id={1}&lt;br /&gt;
                  max_team_size={1}&lt;br /&gt;
                  is_intelligent={1}&lt;br /&gt;
                  require_quiz={1}&lt;br /&gt;
                  dataType={1}&lt;br /&gt;
                  //this is just a hack. All current users courses are marked as private during fetch for display purpose.&lt;br /&gt;
                  private={1}&lt;br /&gt;
                  allow_suggestions={1}&lt;br /&gt;
                  has_topic={1}&lt;br /&gt;
                  rowClicked={1}&lt;br /&gt;
                  newParams={1}&lt;br /&gt;
              /&amp;gt;);&lt;br /&gt;
          })&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
But we still stuck at this bug.&lt;br /&gt;
&lt;br /&gt;
 TypeError: instance._init is not a function.&lt;br /&gt;
&lt;br /&gt;
This project turns out to be really complicated to implement. So we asked to switch the project to implement Rspec integration test for the users_controller.rb&lt;br /&gt;
&lt;br /&gt;
== Implementation &amp;amp; Test Plan ==&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
&lt;br /&gt;
Because React.addons cannot be used here, I changed it to the function of JS.&lt;br /&gt;
&lt;br /&gt;
        var index = this.state.expandedRow.indexOf(id)&lt;br /&gt;
        if (index &amp;gt; -1) {&lt;br /&gt;
            var list = this.state.expandedRow;&lt;br /&gt;
            list.splice(index,1);&lt;br /&gt;
          this.setState({&lt;br /&gt;
            expandedRow: list&lt;br /&gt;
          })&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
=== Minor bug2 ===&lt;br /&gt;
&lt;br /&gt;
I sorted the list before the data is returned to the frontend in the tree_display_controller.rb. The list is sorted first in ascending order of 'instructor' and then in the descending order of 'creation_date' which requires 'creation_date' to be converted to timestamp.&lt;br /&gt;
&lt;br /&gt;
 res['Assignments'] = res['Assignments'].sort_by {|x| [x['instructor'],-1*(x['creation_date'].to_i)]}&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114378</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114378"/>
		<updated>2017-12-03T16:49:43Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Implementation &amp;amp; Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bugs ===&lt;br /&gt;
After we decided to move to another project, Prof. Gehringer mentioned two minor bugs in tree_display/list page.&lt;br /&gt;
&lt;br /&gt;
==== Minor bug1 ====&lt;br /&gt;
[[File:Najsbfdfdfdf.PNG]]&lt;br /&gt;
&lt;br /&gt;
In &amp;quot;Questionnaires&amp;quot; table, after the user click one row to expand the table, he cannot click again to close it. It would raise an error &amp;quot;TypeError: React.addons is undefined&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Minor bug2 ====&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Others' Public Assignments&amp;quot; list is very long and unorganized. We need to organize it first by &amp;quot;Instructor&amp;quot; and then by &amp;quot;Creation Date&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
Here's a demo http://chairnerd.seatgeek.com/react-infinite-a-browser-ready-efficient-scrolling-container-based-on-uitableview/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; [http://jscroll.com/ jscroll]&lt;br /&gt;
&amp;lt;li&amp;gt; [https://github.com/seatgeek/react-infinite react-infinite]&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Previous Attempt ==&lt;br /&gt;
While we are working on this project, we have tried multiple approaches, but nothing had worked out. &lt;br /&gt;
&lt;br /&gt;
The first one is jscroll, we had load jscroll into vendor directory using bower, and able to required in the project, but it turns out that jscroll doesn’t work in ReactJS.&lt;br /&gt;
 &lt;br /&gt;
Thus, we tried to find third party React Plugins to achieve the function of infinite scroll. &lt;br /&gt;
&lt;br /&gt;
The first React Plugin is react-infinite, We were also able to load react-infinite into vendor directory using bower, and has no error occurred while adding to the react component.&lt;br /&gt;
&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;: &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it also didn’t work out because of the main content is html table. &lt;br /&gt;
&lt;br /&gt;
After that, we have asked this problem on the stackoverflow. People recommended another plugin called react-infinite-scroller, this plugin couldn’t find by bower package manager, so we have to load this package by another package manager like webpacker, but webpacker needs Rails 5 to load React, however Expertiza is based on Rails 4.2.6. We’ve also tried sprockets but we were unable to import.&lt;br /&gt;
&lt;br /&gt;
Our last try is https://infinite-scroll.com/ https://github.com/metafizzy/infinite-scroll&lt;br /&gt;
&lt;br /&gt;
 componentWillUpdate: function() {&lt;br /&gt;
          console.log(1111);&lt;br /&gt;
          var $container = $('.scroll').infiniteScroll({&lt;br /&gt;
              // path is required, hack with {{#}}&lt;br /&gt;
              path: 'page{{#}}',&lt;br /&gt;
              loadOnScroll: false,&lt;br /&gt;
              scrollThreshold: 400&lt;br /&gt;
          });&lt;br /&gt;
          $container.on( 'scrollThreshold.infiniteScroll', function() {&lt;br /&gt;
              console.log(2222);&lt;br /&gt;
              $container.append(&amp;lt;ContentTableRow&lt;br /&gt;
                  key={1}&lt;br /&gt;
                  id={1}&lt;br /&gt;
                  name={1}&lt;br /&gt;
                  directory={1}&lt;br /&gt;
                  instructor={1}&lt;br /&gt;
                  institution={1}&lt;br /&gt;
                  creation_date={1}&lt;br /&gt;
                  updated_date={1}&lt;br /&gt;
                  actions={1}&lt;br /&gt;
                  is_available={1}&lt;br /&gt;
                  course_id={1}&lt;br /&gt;
                  max_team_size={1}&lt;br /&gt;
                  is_intelligent={1}&lt;br /&gt;
                  require_quiz={1}&lt;br /&gt;
                  dataType={1}&lt;br /&gt;
                  //this is just a hack. All current users courses are marked as private during fetch for display purpose.&lt;br /&gt;
                  private={1}&lt;br /&gt;
                  allow_suggestions={1}&lt;br /&gt;
                  has_topic={1}&lt;br /&gt;
                  rowClicked={1}&lt;br /&gt;
                  newParams={1}&lt;br /&gt;
              /&amp;gt;);&lt;br /&gt;
          })&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
But we still stuck at this bug.&lt;br /&gt;
&lt;br /&gt;
 TypeError: instance._init is not a function.&lt;br /&gt;
&lt;br /&gt;
This project turns out to be really complicated to implement. So we asked to switch the project to implement Rspec integration test for the users_controller.rb&lt;br /&gt;
&lt;br /&gt;
== Implementation &amp;amp; Test Plan ==&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
&lt;br /&gt;
Because React.addons cannot be used here, I changed it to the function of JS.&lt;br /&gt;
&lt;br /&gt;
        var index = this.state.expandedRow.indexOf(id)&lt;br /&gt;
        if (index &amp;gt; -1) {&lt;br /&gt;
            var list = this.state.expandedRow;&lt;br /&gt;
            list.splice(index,1);&lt;br /&gt;
          this.setState({&lt;br /&gt;
            expandedRow: list&lt;br /&gt;
          })&lt;br /&gt;
        }&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114377</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114377"/>
		<updated>2017-12-03T16:48:33Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Previous Attempt */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bugs ===&lt;br /&gt;
After we decided to move to another project, Prof. Gehringer mentioned two minor bugs in tree_display/list page.&lt;br /&gt;
&lt;br /&gt;
==== Minor bug1 ====&lt;br /&gt;
[[File:Najsbfdfdfdf.PNG]]&lt;br /&gt;
&lt;br /&gt;
In &amp;quot;Questionnaires&amp;quot; table, after the user click one row to expand the table, he cannot click again to close it. It would raise an error &amp;quot;TypeError: React.addons is undefined&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Minor bug2 ====&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Others' Public Assignments&amp;quot; list is very long and unorganized. We need to organize it first by &amp;quot;Instructor&amp;quot; and then by &amp;quot;Creation Date&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
Here's a demo http://chairnerd.seatgeek.com/react-infinite-a-browser-ready-efficient-scrolling-container-based-on-uitableview/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; [http://jscroll.com/ jscroll]&lt;br /&gt;
&amp;lt;li&amp;gt; [https://github.com/seatgeek/react-infinite react-infinite]&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Previous Attempt ==&lt;br /&gt;
While we are working on this project, we have tried multiple approaches, but nothing had worked out. &lt;br /&gt;
&lt;br /&gt;
The first one is jscroll, we had load jscroll into vendor directory using bower, and able to required in the project, but it turns out that jscroll doesn’t work in ReactJS.&lt;br /&gt;
 &lt;br /&gt;
Thus, we tried to find third party React Plugins to achieve the function of infinite scroll. &lt;br /&gt;
&lt;br /&gt;
The first React Plugin is react-infinite, We were also able to load react-infinite into vendor directory using bower, and has no error occurred while adding to the react component.&lt;br /&gt;
&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;: &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it also didn’t work out because of the main content is html table. &lt;br /&gt;
&lt;br /&gt;
After that, we have asked this problem on the stackoverflow. People recommended another plugin called react-infinite-scroller, this plugin couldn’t find by bower package manager, so we have to load this package by another package manager like webpacker, but webpacker needs Rails 5 to load React, however Expertiza is based on Rails 4.2.6. We’ve also tried sprockets but we were unable to import.&lt;br /&gt;
&lt;br /&gt;
Our last try is https://infinite-scroll.com/ https://github.com/metafizzy/infinite-scroll&lt;br /&gt;
&lt;br /&gt;
 componentWillUpdate: function() {&lt;br /&gt;
          console.log(1111);&lt;br /&gt;
          var $container = $('.scroll').infiniteScroll({&lt;br /&gt;
              // path is required, hack with {{#}}&lt;br /&gt;
              path: 'page{{#}}',&lt;br /&gt;
              loadOnScroll: false,&lt;br /&gt;
              scrollThreshold: 400&lt;br /&gt;
          });&lt;br /&gt;
          $container.on( 'scrollThreshold.infiniteScroll', function() {&lt;br /&gt;
              console.log(2222);&lt;br /&gt;
              $container.append(&amp;lt;ContentTableRow&lt;br /&gt;
                  key={1}&lt;br /&gt;
                  id={1}&lt;br /&gt;
                  name={1}&lt;br /&gt;
                  directory={1}&lt;br /&gt;
                  instructor={1}&lt;br /&gt;
                  institution={1}&lt;br /&gt;
                  creation_date={1}&lt;br /&gt;
                  updated_date={1}&lt;br /&gt;
                  actions={1}&lt;br /&gt;
                  is_available={1}&lt;br /&gt;
                  course_id={1}&lt;br /&gt;
                  max_team_size={1}&lt;br /&gt;
                  is_intelligent={1}&lt;br /&gt;
                  require_quiz={1}&lt;br /&gt;
                  dataType={1}&lt;br /&gt;
                  //this is just a hack. All current users courses are marked as private during fetch for display purpose.&lt;br /&gt;
                  private={1}&lt;br /&gt;
                  allow_suggestions={1}&lt;br /&gt;
                  has_topic={1}&lt;br /&gt;
                  rowClicked={1}&lt;br /&gt;
                  newParams={1}&lt;br /&gt;
              /&amp;gt;);&lt;br /&gt;
          })&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
But we still stuck at this bug.&lt;br /&gt;
&lt;br /&gt;
 TypeError: instance._init is not a function.&lt;br /&gt;
&lt;br /&gt;
This project turns out to be really complicated to implement. So we asked to switch the project to implement Rspec integration test for the users_controller.rb&lt;br /&gt;
&lt;br /&gt;
== Implementation &amp;amp; Test Plan ==&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
&lt;br /&gt;
Because React.addons cannot be used here, I changed it to the function of JS.&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114376</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114376"/>
		<updated>2017-12-03T16:47:28Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Implementation &amp;amp; Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bugs ===&lt;br /&gt;
After we decided to move to another project, Prof. Gehringer mentioned two minor bugs in tree_display/list page.&lt;br /&gt;
&lt;br /&gt;
==== Minor bug1 ====&lt;br /&gt;
[[File:Najsbfdfdfdf.PNG]]&lt;br /&gt;
&lt;br /&gt;
In &amp;quot;Questionnaires&amp;quot; table, after the user click one row to expand the table, he cannot click again to close it. It would raise an error &amp;quot;TypeError: React.addons is undefined&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Minor bug2 ====&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Others' Public Assignments&amp;quot; list is very long and unorganized. We need to organize it first by &amp;quot;Instructor&amp;quot; and then by &amp;quot;Creation Date&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
Here's a demo http://chairnerd.seatgeek.com/react-infinite-a-browser-ready-efficient-scrolling-container-based-on-uitableview/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; [http://jscroll.com/ jscroll]&lt;br /&gt;
&amp;lt;li&amp;gt; [https://github.com/seatgeek/react-infinite react-infinite]&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Previous Attempt ==&lt;br /&gt;
While we are working on this project, we have tried multiple approaches, but nothing had worked out. &lt;br /&gt;
&lt;br /&gt;
The first one is jscroll, we had load jscroll into vendor directory using bower, and able to required in the project, but it turns out that jscroll doesn’t work in ReactJS.&lt;br /&gt;
 &lt;br /&gt;
Thus, we tried to find third party React Plugins to achieve the function of infinite scroll. &lt;br /&gt;
&lt;br /&gt;
The first React Plugin is react-infinite, We were also able to load react-infinite into vendor directory using bower, and has no error occurred while adding to the react component.&lt;br /&gt;
&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;: &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it also didn’t work out because of the main content is html table. &lt;br /&gt;
&lt;br /&gt;
After that, we have asked this problem on the stackoverflow. People recommended another plugin called react-infinite-scroller, this plugin couldn’t find by bower package manager, so we have to load this package by another package manager like webpacker, but webpacker needs Rails 5 to load React, however Expertiza is based on Rails 4.2.6. We’ve also tried sprockets but we were unable to import.&lt;br /&gt;
&lt;br /&gt;
Our last try is https://infinite-scroll.com/ https://github.com/metafizzy/infinite-scroll&lt;br /&gt;
&lt;br /&gt;
[[File:WeChat Image_20171203113300.png]]&lt;br /&gt;
&lt;br /&gt;
But we still stuck at this bug.&lt;br /&gt;
&lt;br /&gt;
 TypeError: instance._init is not a function.&lt;br /&gt;
&lt;br /&gt;
This project turns out to be really complicated to implement. So we asked to switch the project to implement Rspec integration test for the users_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation &amp;amp; Test Plan ==&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
&lt;br /&gt;
Because React.addons cannot be used here, I changed it to the function of JS.&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114371</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114371"/>
		<updated>2017-12-03T16:37:46Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Minor bug1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bugs ===&lt;br /&gt;
After we decided to move to another project, Prof. Gehringer mentioned two minor bugs in tree_display/list page.&lt;br /&gt;
&lt;br /&gt;
==== Minor bug1 ====&lt;br /&gt;
[[File:Najsbfdfdfdf.PNG]]&lt;br /&gt;
&lt;br /&gt;
In &amp;quot;Questionnaires&amp;quot; table, after the user click one row to expand the table, he cannot click again to close it. It would raise an error &amp;quot;TypeError: React.addons is undefined&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Minor bug2 ====&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Others' Public Assignments&amp;quot; list is very long and unorganized. We need to organize it first by &amp;quot;Instructor&amp;quot; and then by &amp;quot;Creation Date&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
Here's a demo http://chairnerd.seatgeek.com/react-infinite-a-browser-ready-efficient-scrolling-container-based-on-uitableview/&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;: &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; [http://jscroll.com/ jscroll]&lt;br /&gt;
&amp;lt;li&amp;gt; [https://github.com/seatgeek/react-infinite react-infinite]&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Previous Attempt ==&lt;br /&gt;
While we are working on this project, we have tried multiple approaches, but nothing had worked out. &lt;br /&gt;
&lt;br /&gt;
The first one is jscroll, we had load jscroll into vendor directory using bower, and able to required in the project, but it turns out that jscroll doesn’t work in ReactJS.&lt;br /&gt;
 &lt;br /&gt;
Thus, we tried to find third party React Plugins to achieve the function of infinite scroll. &lt;br /&gt;
&lt;br /&gt;
The first React Plugin is react-infinite, We were also able to load react-infinite into vendor directory using bower, and has no error occurred while adding to the react component, however, it also didn’t work out because of the main content is html table. &lt;br /&gt;
&lt;br /&gt;
After that, we have asked this problem on the stackoverflow. People recommended another plugin called react-infinite-scroller, this plugin couldn’t find by bower package manager, so we have to load this package by another package manager like webpacker, but webpacker needs Rails 5 to load React, however Expertiza is based on Rails 4.2.6. We’ve also tried sprockets but we were unable to import.&lt;br /&gt;
&lt;br /&gt;
Our last try is https://infinite-scroll.com/ https://github.com/metafizzy/infinite-scroll&lt;br /&gt;
[[File:WeChat Image_20171203113300.png]]&lt;br /&gt;
But we still stuck at this bug.&lt;br /&gt;
TypeError: instance._init is not a function.&lt;br /&gt;
&lt;br /&gt;
This project turns out to be really complicated to implement. So we asked to switch the project to implement Rspec integration test for the users_controller.rb&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114364</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=114364"/>
		<updated>2017-12-03T16:20:04Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Task Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bugs ===&lt;br /&gt;
After we decided to move to another project, Prof. Gehringer mentioned two minor bugs in tree_display/list page.&lt;br /&gt;
&lt;br /&gt;
==== Minor bug1 ====&lt;br /&gt;
[[File:Najsbfdfdfdf.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
Here's a demo http://chairnerd.seatgeek.com/react-infinite-a-browser-ready-efficient-scrolling-container-based-on-uitableview/&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;: &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; [http://jscroll.com/ jscroll]&lt;br /&gt;
&amp;lt;li&amp;gt; [https://github.com/seatgeek/react-infinite react-infinite]&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Najsbfdfdfdf.PNG&amp;diff=114363</id>
		<title>File:Najsbfdfdfdf.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Najsbfdfdfdf.PNG&amp;diff=114363"/>
		<updated>2017-12-03T16:18:54Z</updated>

		<summary type="html">&lt;p&gt;Xli76: uploaded a new version of &amp;amp;quot;File:Najsbfdfdfdf.PNG&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Najsbfdfdfdf.PNG&amp;diff=114362</id>
		<title>File:Najsbfdfdfdf.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Najsbfdfdfdf.PNG&amp;diff=114362"/>
		<updated>2017-12-03T16:18:16Z</updated>

		<summary type="html">&lt;p&gt;Xli76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113677</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113677"/>
		<updated>2017-11-19T15:17:08Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
This bug has already been fixed previously. When a user is editing an assignment, course or questionnaire, clicking &amp;quot;back&amp;quot; button in the page or browser's back button could always go back to the correct tab.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug2 ===&lt;br /&gt;
The solutions we came up with now is passing a URL parameter indicating whether &amp;quot;Include others' items&amp;quot; checkbox has been checked when a user edits an assignment or courses. When he goes back, we pass that URL parameter back and use js to check the checkbox according to the value of the parameter. For example, we pass a URL parameter &amp;quot;is_checked&amp;quot;. If the checkbox has been checked, we set its value as 1. Otherwise, we set its value as 0. When it passes back, we use js to read the value of it and check the checkbox if it equals 1.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
Here's a demo http://chairnerd.seatgeek.com/react-infinite-a-browser-ready-efficient-scrolling-container-based-on-uitableview/&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;: &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; [http://jscroll.com/ jscroll]&lt;br /&gt;
&amp;lt;li&amp;gt; [https://github.com/seatgeek/react-infinite react-infinite]&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113676</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113676"/>
		<updated>2017-11-19T15:16:53Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
This bug has already been fixed previously. When a user is editing an assignment, course or questionnaire, clicking &amp;quot;back&amp;quot; button in the page or browser's back button could always go back to the correct tab.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug2 ===&lt;br /&gt;
The solutions we came up with now is passing a URL parameter indicating whether &amp;quot;Include others' items&amp;quot; checkbox has been checked when a user edits an assignment or courses. When he goes back, we pass that URL parameter back and use js to check the checkbox according to the value of the parameter. For example, we pass a URL parameter &amp;quot;is_checked&amp;quot;. If the checkbox has been checked, we set its value as 1. Otherwise, we set its value as 0. When it passes back, we use js to read the value of it and check the checkbox if it equals 1.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
Here's a demo http://chairnerd.seatgeek.com/react-infinite-a-browser-ready-efficient-scrolling-container-based-on-uitableview/&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
&amp;quot;react-infinite&amp;quot;: &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; [http://jscroll.com/ jscroll]&lt;br /&gt;
&amp;lt;li&amp;gt; [https://github.com/seatgeek/react-infinite react-infinite]&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113441</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113441"/>
		<updated>2017-11-15T02:44:33Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
This bug has already been fixed previously. When a user is editing an assignment, course or questionnaire, clicking &amp;quot;back&amp;quot; button in the page or browser's back button could always go back to the correct tab.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug2 ===&lt;br /&gt;
The solutions we came up with now is passing a URL parameter indicating whether &amp;quot;Include others' items&amp;quot; checkbox has been checked when a user edits an assignment or courses. When he goes back, we pass that URL parameter back and use js to check the checkbox according to the value of the parameter. For example, we pass a URL parameter &amp;quot;is_checked&amp;quot;. If the checkbox has been checked, we set its value as 1. Otherwise, we set its value as 0. When it passes back, we use js to read the value of it and check the checkbox if it equals 1.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
Here's a demo http://chairnerd.seatgeek.com/react-infinite-a-browser-ready-efficient-scrolling-container-based-on-uitableview/&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;, &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; [http://jscroll.com/ jscroll]&lt;br /&gt;
&amp;lt;li&amp;gt; [https://github.com/seatgeek/react-infinite react-infinite]&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113440</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113440"/>
		<updated>2017-11-15T02:44:14Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
This bug has already been fixed previously. When a user is editing an assignment, course or questionnaire, clicking &amp;quot;back&amp;quot; button in the page or browser's back button could always go back to the correct tab.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug2 ===&lt;br /&gt;
The solutions we came up with now is passing a URL parameter indicating whether &amp;quot;Include others' items&amp;quot; checkbox has been checked when a user edits an assignment or courses. When he goes back, we pass that URL parameter back and use js to check the checkbox according to the value of the parameter. For example, we pass a URL parameter &amp;quot;is_checked&amp;quot;. If the checkbox has been checked, we set its value as 1. Otherwise, we set its value as 0. When it passes back, we use js to read the value of it and check the checkbox if it equals 1.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
Here's a demo http://chairnerd.seatgeek.com/react-infinite-a-browser-ready-efficient-scrolling-container-based-on-uitableview/&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;, &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; [http://jscroll.com/ jscroll]&lt;br /&gt;
&amp;lt;li&amp;gt; [https://github.com/seatgeek/react-infinite react-infinite]&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113436</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113436"/>
		<updated>2017-11-15T02:39:46Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
This bug has already been fixed previously. When a user is editing an assignment, course or questionnaire, clicking &amp;quot;back&amp;quot; button in the page or browser's back button could always go back to the correct tab.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug2 ===&lt;br /&gt;
The solutions we came up with now is passing a URL parameter indicating whether &amp;quot;Include others' items&amp;quot; checkbox has been checked when a user edits an assignment or courses. When he goes back, we pass that URL parameter back and use js to check the checkbox according to the value of the parameter. For example, we pass a URL parameter &amp;quot;is_checked&amp;quot;. If the checkbox has been checked, we set its value as 1. Otherwise, we set its value as 0. When it passes back, we use js to read the value of it and check the checkbox if it equals 1.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;, &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; [http://jscroll.com/ jscroll]&lt;br /&gt;
&amp;lt;li&amp;gt; [https://github.com/seatgeek/react-infinite react-infinite]&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113429</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113429"/>
		<updated>2017-11-15T02:36:16Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Minor bug1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
This bug has already been fixed previously. When a user is editing an assignment, course or questionnaire, clicking &amp;quot;back&amp;quot; button in the page or browser's back button could always go back to the correct tab.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug2 ===&lt;br /&gt;
The solutions we came up with now is passing a URL parameter indicating whether &amp;quot;Include others' items&amp;quot; checkbox has been checked when a user edits an assignment or courses. When he goes back, we pass that URL parameter back and use js to check the checkbox according to the value of the parameter. For example, we pass a URL parameter &amp;quot;is_checked&amp;quot;. If the checkbox has been checked, we set its value as 1. Otherwise, we set its value as 0. When it passes back, we use js to read the value of it and check the checkbox if it equals 1.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;, &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113424</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113424"/>
		<updated>2017-11-15T02:30:33Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
This bug has already been fixed previously. When a user is editing an assignment, course or questionnaire, clicking &amp;quot;back&amp;quot; could always go back to the correct tab.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug2 ===&lt;br /&gt;
The solutions we came up with now is passing a URL parameter indicating whether &amp;quot;Include others' items&amp;quot; checkbox has been checked when a user edits an assignment or courses. When he goes back, we pass that URL parameter back and use js to check the checkbox according to the value of the parameter. For example, we pass a URL parameter &amp;quot;is_checked&amp;quot;. If the checkbox has been checked, we set its value as 1. Otherwise, we set its value as 0. When it passes back, we use js to read the value of it and check the checkbox if it equals 1.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;, &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;When a user first navigate to the page, there are 10 records and he can scroll down to see more records.&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a course, he will go back to course tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a assignment, he will go back to assignment tab after clicking browser's back button .&lt;br /&gt;
&amp;lt;li&amp;gt;When a user edits a questionnaire, he will go back to questionnaire tab after clicking browser's back button.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains checked.&lt;br /&gt;
&amp;lt;li&amp;gt;When &amp;quot;Include others' items&amp;quot; checkbox has not been checked, then the user is editing an assignment or courses, then goes back, the checkbox remains unchecked.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113404</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113404"/>
		<updated>2017-11-15T02:15:25Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Minor bug2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
This bug has already been fixed previously. When a user is editing an assignment, course or questionnaire, clicking &amp;quot;back&amp;quot; could always go back to the correct tab.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug2 ===&lt;br /&gt;
The solutions we came up with now is passing a URL parameter indicating whether &amp;quot;Include others' items&amp;quot; checkbox has been checked when a user edits an assignment or courses. When he goes back, we pass that URL parameter back and use js to check the checkbox according to the value of the parameter. For example, we pass a URL parameter &amp;quot;is_checked&amp;quot;. If the checkbox has been checked, we set its value as 1. Otherwise, we set its value as 0. When it passes back, we use js to read the value of it and check the checkbox if it equals 1.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;, &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113400</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113400"/>
		<updated>2017-11-15T02:09:41Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Task Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
This bug has already been fixed previously. When a user is editing an assignment, course or questionnaire, clicking &amp;quot;back&amp;quot; could always go back to the correct tab.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug2 ===&lt;br /&gt;
The solutions we came up with now is passing a URL parameter indicating whether &amp;quot;Include others' items&amp;quot; checkbox has been checked when a user edits an assignment or courses. When he goes back, we pass that URL parameter back and use js to check the checkbox according to the value of the parameter.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;, &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113392</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113392"/>
		<updated>2017-11-15T01:55:18Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Task Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
=== Minor bug1 ===&lt;br /&gt;
This bug has already been fixed previously. When a user is editing an assignment, course or questionnaire, clicking &amp;quot;back&amp;quot; could always go back to the correct tab.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;, &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113350</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113350"/>
		<updated>2017-11-15T00:29:09Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Task Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll. However, it did not make any difference and there were only a few examples and documentation online. Those resources did not help us find the bug. Therefore, because the instructor said we do not have to use jscroll to implement infinite scroll, we decided to use a react plugin called &amp;quot;react-infinite&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;, &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113348</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113348"/>
		<updated>2017-11-15T00:17:14Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Task Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
At first, we tried to solved the problem using jscroll.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;, &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113347</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113347"/>
		<updated>2017-11-15T00:16:10Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Task Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;, &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113345</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113345"/>
		<updated>2017-11-15T00:06:54Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Task Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll or other plugins since the original tree_list code is written in ReactJS. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use infinite scroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
==== Problem Analysis ====&lt;br /&gt;
The instructor page load extremely slow due to too much backend Database query ran before loading the front end. We could analyze both frontend and backend of this page to figure out a best solution to improve the performance of this page. The backend part could try to translate more than a thousand SQLs to just a few by Query modification. The frontend can use infinite scroll to reduce the render consumption.&lt;br /&gt;
&lt;br /&gt;
== Plan ==&lt;br /&gt;
=== Steps ===&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
* 1. Install the dependencies we need to add infinite scroll functionality to ReactJS.&lt;br /&gt;
* 2. Since there is no easy way to implement infinite scroll in a table tag of html, we should figure out a way to refactor the whole structure of tree_list.&lt;br /&gt;
* 3. Add react-infinite to the tree_list.&lt;br /&gt;
* 4. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
=== Files to be Modified ===&lt;br /&gt;
 app/assets/javascript/application.js&lt;br /&gt;
 app/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
 app/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 app/controllers/assignments_controller.rb&lt;br /&gt;
 app/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
react-infinite&lt;br /&gt;
https://github.com/seatgeek/react-infinite&lt;br /&gt;
&lt;br /&gt;
react-infinite is A browser-ready efficient scrolling container based on UITableView.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
add dependency &amp;quot;react-infinite&amp;quot; to bower.json&lt;br /&gt;
 &amp;quot;react-infinite&amp;quot;, &amp;quot;*&amp;quot;&lt;br /&gt;
run setup.sh to load &amp;quot;react-infinite&amp;quot; into /vendor/&lt;br /&gt;
modify &amp;quot;app/assets/javascript/application.js&amp;quot; to require the plugin&lt;br /&gt;
 //= require react-infinite&lt;br /&gt;
add &amp;quot;react-infinite&amp;quot; tags to &amp;quot;app/assets/javascript/tree_display.jsx&amp;quot;&lt;br /&gt;
 &amp;lt;react-infinite&amp;gt;&lt;br /&gt;
 &amp;lt;/react-infinite&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113316</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=113316"/>
		<updated>2017-11-14T22:22:47Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Task Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
=== Information about jScroll===&lt;br /&gt;
&lt;br /&gt;
JScroll is a JQuery plugin for infinite scrolling, is the ability to load content via AJAX within the current page or content area as you scroll down. The new content can be loaded automatically each time you scroll to the end of the existing content, or it can be triggered to load by clicking a navigation link at the end of the existing content.&lt;br /&gt;
&lt;br /&gt;
Sample code for JScroll&lt;br /&gt;
&lt;br /&gt;
 ('.infinite-scroll').jscroll();&lt;br /&gt;
&lt;br /&gt;
 ('.infinite-scroll').jscroll({&lt;br /&gt;
    loadingHtml: '&amp;lt;img src=&amp;quot;loading.gif&amp;quot; alt=&amp;quot;Loading&amp;quot; /&amp;gt; Loading...',&lt;br /&gt;
    padding: 20,&lt;br /&gt;
    nextSelector: 'a.jscroll-next:last',&lt;br /&gt;
    contentSelector: 'li'&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
Here is a demo of jScroll [https://www.jqueryscript.net/demo/jQuery-Infinite-Scrolling-Auto-Paging-Plugin-jScroll/ jScroll Demo]&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
&lt;br /&gt;
=== Lazy loading ===&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use Jscroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
&lt;br /&gt;
* 1. Add Jscroll in function jQuery.post(&amp;quot;/tree_display/children_node_ng&amp;quot;) to implement lazy loading.&lt;br /&gt;
* 2. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
== Files to be Modified ==&lt;br /&gt;
&lt;br /&gt;
 /assets/javascript/tree_display.jsx&lt;br /&gt;
 /controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 /controllers/assignments_controller.rb&lt;br /&gt;
 /controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
== New Dependency==&lt;br /&gt;
add dependency &amp;quot;jscroll&amp;quot; to bower.json&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Dfgjhdfj333.png&amp;diff=113315</id>
		<title>File:Dfgjhdfj333.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Dfgjhdfj333.png&amp;diff=113315"/>
		<updated>2017-11-14T22:21:01Z</updated>

		<summary type="html">&lt;p&gt;Xli76: uploaded a new version of &amp;amp;quot;File:Dfgjhdfj333.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112611</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112611"/>
		<updated>2017-11-08T03:28:00Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Information about jScroll */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
=== Information about jScroll===&lt;br /&gt;
&lt;br /&gt;
JScroll is a JQuery plugin for infinite scrolling, is the ability to load content via AJAX within the current page or content area as you scroll down. The new content can be loaded automatically each time you scroll to the end of the existing content, or it can be triggered to load by clicking a navigation link at the end of the existing content.&lt;br /&gt;
&lt;br /&gt;
Sample code for JScroll&lt;br /&gt;
&lt;br /&gt;
 ('.infinite-scroll').jscroll();&lt;br /&gt;
&lt;br /&gt;
 ('.infinite-scroll').jscroll({&lt;br /&gt;
    loadingHtml: '&amp;lt;img src=&amp;quot;loading.gif&amp;quot; alt=&amp;quot;Loading&amp;quot; /&amp;gt; Loading...',&lt;br /&gt;
    padding: 20,&lt;br /&gt;
    nextSelector: 'a.jscroll-next:last',&lt;br /&gt;
    contentSelector: 'li'&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
Here is a demo of jScroll [https://www.jqueryscript.net/demo/jQuery-Infinite-Scrolling-Auto-Paging-Plugin-jScroll/ jScroll Demo]&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use Jscroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
&lt;br /&gt;
* 1. Add Jscroll in function jQuery.post(&amp;quot;/tree_display/children_node_ng&amp;quot;) to implement lazy loading.&lt;br /&gt;
* 2. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
== Files to be Modified ==&lt;br /&gt;
&lt;br /&gt;
 /assets/javascript/tree_display.jsx&lt;br /&gt;
 /controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
 /controllers/assignments_controller.rb&lt;br /&gt;
 /controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
== New Gemfile==&lt;br /&gt;
 gem &amp;quot;lazyload-rails&amp;quot;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017&amp;diff=112478</id>
		<title>CSC/ECE 517 Fall 2017</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017&amp;diff=112478"/>
		<updated>2017-11-08T00:53:08Z</updated>

		<summary type="html">&lt;p&gt;Xli76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Design Project Documentation'''&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A2 Lightweight Badging System]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A8. Use a profiler to identify the problems / pages that take some time to load &amp;amp; fix them]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1793. Help students find teams to join]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A4 Allow calibration to be part of an assignment]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A0 Team-based reviewing]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1793. Help students find teams to join_Team1964]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1791. Track the time that students look at the other submissions - logging improvement]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1799 Improve self-review Link peer review &amp;amp; self-review to derive grades]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1797_Timestamps_for_students_submissions]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E17A1|CSC/ECE_517_Fall_2017/E17A1 - Let experts as well as students do reviews]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/M1754_Mutation_Testing]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1794. Student-generated questions added to rubric]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A6. Fix account creation over web to work reasonably]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1792 OSS Visualizations for instructors]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A4 Allow calibration to be part of an assignment_Team34]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A7_Allow_Reviewers_to_bid_on_what_to_review]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Writing Assignment 2'''&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1779. Fix teammate advertisements and requests to join a team]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1773 Investigate and Fix Expertiza Production Version Runtime Exceptions.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1774 Metareview fixes and improvements.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1788 OSS project Maroon Heatmap fixes]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1781 Topic Management]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1745_Refactor_response_controller.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1752 Refactor assignments controller]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1776_Enhance_Imports]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1756 TLD Refactor response.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1772_Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas API]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/M1754_Mutation Testing on Servo]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1753 OSS project bidding tests]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1766_Test team functionality]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1767 Improve imports]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1786_OSS project Juniper Bookmark Enhancements]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1787_OSS project Bronze Score calculations]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1763 Fix Staggered-Deadline Assignments]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1757 Introduce a Student View for instructors]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1769_Refactor assignment_form.rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1754_Feature_test_of_rubric_advice]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1782 OSS Project Red Assignment Directories]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1748 Add past-due assignments to task list]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1761 Test First Development Refactor assignment.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1780_OSS_Project_Teal_Email_Notification_Enhancements]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1762 Test various kinds of response-map hierarchies]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1759 ]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1749_Test First Development Refactor questionnaire_controller.rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1777 Coherent specification of review requirements.rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1771_Refactor_team.rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1784 Fix mass assignments reported by Brakeman.rb]]&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112412</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112412"/>
		<updated>2017-11-07T22:11:32Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Task Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use Jscroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
&lt;br /&gt;
* 1. Add Jscroll in function jQuery.post(&amp;quot;/tree_display/children_node_ng&amp;quot;) to implement lazy loading.&lt;br /&gt;
* 2. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;br /&gt;
&lt;br /&gt;
== Files to be Modified ==&lt;br /&gt;
&lt;br /&gt;
/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
&lt;br /&gt;
/controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
/controllers/course_controller.rb&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112411</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112411"/>
		<updated>2017-11-07T22:11:25Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Files to be Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use Jscroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
&lt;br /&gt;
* 1. Add Jscroll in function jQuery.post(&amp;quot;/tree_display/children_node_ng&amp;quot;) to implement lazy loading.&lt;br /&gt;
* 2. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112410</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112410"/>
		<updated>2017-11-07T22:10:48Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Files to be Modified ==&lt;br /&gt;
&lt;br /&gt;
/assets/javascript/tree_display.jsx&lt;br /&gt;
&lt;br /&gt;
/controllers/assignment_questionnaire_controller.rb&lt;br /&gt;
&lt;br /&gt;
/controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
/controllers/course_controller.rb&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use Jscroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
&lt;br /&gt;
* 1. Add Jscroll in function jQuery.post(&amp;quot;/tree_display/children_node_ng&amp;quot;) to implement lazy loading.&lt;br /&gt;
* 2. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112352</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112352"/>
		<updated>2017-11-07T18:59:58Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Task Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use Jscroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
&lt;br /&gt;
* 1. Add Jscroll in function jQuery.post(&amp;quot;/tree_display/children_node_ng&amp;quot;) to implement lazy loading.&lt;br /&gt;
* 2. Modify the corresponding functions in assignment, course, questionnaire controllers to support lazy loading. For example, we may need to add &amp;quot;LIMIT&amp;quot; to the statement which query data from the database.&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112351</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112351"/>
		<updated>2017-11-07T18:54:48Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Task Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use Jscroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;br /&gt;
&lt;br /&gt;
The majority of the logic behind the tree display page was written using ReactJS in expertiza/assets/javascript/tree_display.jsx. So we need to take the following steps:&lt;br /&gt;
&lt;br /&gt;
* 1. Add Jscroll in&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112348</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112348"/>
		<updated>2017-11-07T18:45:57Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
The following picture is what the page looks like now. We can see from firefox developer tools that getting all data from the database once costs 4303ms which is very slow. Therefore, we need to use Jscroll to load a certain number of the record at one time e.g., record #1-#10&lt;br /&gt;
&lt;br /&gt;
[[File:Dfgjhdfj333.png]]&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Dfgjhdfj333.png&amp;diff=112338</id>
		<title>File:Dfgjhdfj333.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Dfgjhdfj333.png&amp;diff=112338"/>
		<updated>2017-11-07T18:36:53Z</updated>

		<summary type="html">&lt;p&gt;Xli76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Dfssdkfhdsk34.png&amp;diff=112332</id>
		<title>File:Dfssdkfhdsk34.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Dfssdkfhdsk34.png&amp;diff=112332"/>
		<updated>2017-11-07T18:12:26Z</updated>

		<summary type="html">&lt;p&gt;Xli76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Fgvv555.png&amp;diff=112331</id>
		<title>File:Fgvv555.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Fgvv555.png&amp;diff=112331"/>
		<updated>2017-11-07T18:08:19Z</updated>

		<summary type="html">&lt;p&gt;Xli76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112329</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112329"/>
		<updated>2017-11-07T18:02:56Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Problem Statement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112322</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112322"/>
		<updated>2017-11-07T17:32:04Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement ===&lt;br /&gt;
The https://expertiza.ncsu.edu/tree_display/list page contains lists of courses, assignments, and questionnaires. This lists can be very long and takes time to load especially when the instructor also loads public assignments since all of them are loaded and rendered in the list. A more common way to accelerate this is to load the first few records that show up in the screen, and load more records as the user scroll down which is called lazy loading. &lt;br /&gt;
We would like you to optimize this page by implementing such lazy loading using Jscroll. &lt;br /&gt;
&lt;br /&gt;
Moreover, the tree_display lists have some bugs that you should fix:&lt;br /&gt;
1. It always goes to assignment page first, so when a user is editing a course then click browser’s back button. It goes back to the assignment instead of the course tab. The same applies when a user is editing a questionnaire, then click back, it goes back to the assignment, instead of questionnaire. We want you to enable “back” to the correct tab.  &lt;br /&gt;
&lt;br /&gt;
2. Secondly, when “Include others' items” checkbox has been checked, then the user is editing an assignment or courses, then goes back. The checkbox is unchecked again. It should remember the last state and load the assignment or courses accordingly.&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112313</id>
		<title>CSC/ECE 517 Fall 2017/E17A9 Lazy loading (infinite scroll) for assignments courses questionnaires and user lists with Jscroll</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A9_Lazy_loading_(infinite_scroll)_for_assignments_courses_questionnaires_and_user_lists_with_Jscroll&amp;diff=112313"/>
		<updated>2017-11-07T16:23:36Z</updated>

		<summary type="html">&lt;p&gt;Xli76: Created page with &amp;quot; == Introduction ==&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction ==&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1784_Fix_mass_assignments_reported_by_Brakeman.rb&amp;diff=111773</id>
		<title>CSC/ECE 517 Fall 2017/E1784 Fix mass assignments reported by Brakeman.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1784_Fix_mass_assignments_reported_by_Brakeman.rb&amp;diff=111773"/>
		<updated>2017-11-03T21:39:12Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Test */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza ==&lt;br /&gt;
Expertiza is an open source project based on Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
Mass Assignment is the name Rails gives to the act of constructing your object with a parameters hash. It is &amp;quot;mass assignment&amp;quot; in that you are assigning multiple values to attributes via a single assignment operator.&lt;br /&gt;
&lt;br /&gt;
The following snippets perform mass assignment of the name and topic attribute of the Post model:&lt;br /&gt;
&lt;br /&gt;
* Post.new(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
* Post.create(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
* Post.update_attributes(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Without the convenience of mass assignment, we'd have to write an assignment statement for each attribute to achieve the same result. Here's an example:&lt;br /&gt;
&lt;br /&gt;
* attrs = { :name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot; }&lt;br /&gt;
&lt;br /&gt;
* post = Post.new&lt;br /&gt;
&lt;br /&gt;
* post.name = attrs[:name]&lt;br /&gt;
&lt;br /&gt;
* post.topic = attrs[:topic]&lt;br /&gt;
&lt;br /&gt;
Obviously, this can get tedious and painful; so we bow at the feet of laziness and say, yes yes, mass assignment is a good thing.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
With the help of mass assignment, when we create or update certain object, we do not need to write an assignment statement for each attribute. But mass assignment could cause security vulnerabilities. Hackers could add other parameters to do some bad things. For example:&lt;br /&gt;
&lt;br /&gt;
* @post = Post.new(params[:post])&lt;br /&gt;
&lt;br /&gt;
Typically this is used when the user submits a form rendered by a form_for @post. In an ideal world, the params[:post] hash should only contain the fields we displayed on the form. However, it is trivial easy hackers to pass additional fields in their request, so in effect you're allowing a user to set any fields on @post, not just the ones displayed on the form.&lt;br /&gt;
&lt;br /&gt;
How to Deal With Mass Assignment? In models, we need to add &amp;quot;attr_accessible&amp;quot; to implement the whitelist. For example: &lt;br /&gt;
&lt;br /&gt;
 class User &amp;lt; ActiveRecord::Base&lt;br /&gt;
     attr_accessible :first, :last, :email&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Here, we're explicitly listing out what can be mass-assigned. Everything else will be disallowed. The advantage here is that if we, say, add an admin flag to the User model, it will automatically be safe from mass-assignment.&lt;br /&gt;
&lt;br /&gt;
For controllers, Rails 4 introduces strong parameters, which is a new approach to protect mass assignment. For example:&lt;br /&gt;
&lt;br /&gt;
 class UsersController &amp;lt; ApplicationController&lt;br /&gt;
  def update&lt;br /&gt;
    user = User.find(params[:id])&lt;br /&gt;
    if user.update_attributes(user_params) # see below&lt;br /&gt;
      redirect_to home_path&lt;br /&gt;
    else&lt;br /&gt;
      render :edit&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  private&lt;br /&gt;
 &lt;br /&gt;
  # Require that :user be a key in the params Hash,&lt;br /&gt;
  # and only accept :first, :last, and :email attributes&lt;br /&gt;
  def user_params&lt;br /&gt;
    params.require(:user).permit(:first, :last, :email)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
Now, if you attempt something like user.update_attributes(params), you'll get an error in your application. You must first call permit on the params hash with the keys that are allowed for a specific action.&lt;br /&gt;
&lt;br /&gt;
So our group needs to resolve all these  &amp;quot;Unprotected mass assignment&amp;quot; issues according to [https://codeclimate.com/github/expertiza/expertiza/issues?category=security Brakeman report].&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
In models, we need to protect all attributes that we allow to be mass-assigned using &amp;quot;attr_accessible&amp;quot;. Previously, we just removed all attributes after &amp;quot;attr_accessible&amp;quot; which fixed &amp;quot;Unprotected mass assignment&amp;quot; but would lead to failure when creating and updating models. So the testes could not pass. Therefore, we added all attributes after &amp;quot;attr_accessible&amp;quot; and tests passed. However, this time, Brakeman would report &amp;quot;Potentially dangerous attribute available for mass assignment&amp;quot;. In order to solve &amp;quot;Unprotected mass assignment&amp;quot; and ensure that tests can pass, this is the best we can do.&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: Mass assignment is not restricted using attr_accessible  ===&lt;br /&gt;
If there was no protection at all in the model file. We added &amp;quot;attr_accessible&amp;quot; and all attributes that we allow to be mass-assigned after it.&lt;br /&gt;
&lt;br /&gt;
[[File:Dfbdfgfdg.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Unprotected mass assignment  ===&lt;br /&gt;
We modified the code in an unobtrusive way, i.e. processing the mass assignment parameters with a function without changing them directly.&lt;br /&gt;
&lt;br /&gt;
==== Parameters come from requests  ====&lt;br /&gt;
Fix unprotected mass assignment in update&lt;br /&gt;
&lt;br /&gt;
[[File:1ghjvvvvv.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in new&lt;br /&gt;
&lt;br /&gt;
[[File:Ddhghghg.png]]&lt;br /&gt;
&lt;br /&gt;
==== Parameters come from other objects  ====&lt;br /&gt;
If the parameters come from requests, we can directly use &amp;quot;params.permit()&amp;quot; to implement a whitelist. However, if the parameters come from values of other objects, we cannot directly call that built-in function. Firstly, we need to build a hash with those values and pass the hash into &amp;quot;params&amp;quot;. And then we can filter the parameters using permit().&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in create&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment.png ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in new&lt;br /&gt;
&lt;br /&gt;
[[File:Sdfsvvv.png]]&lt;br /&gt;
&lt;br /&gt;
==== params.permit!  ====&lt;br /&gt;
[[File:1fdgdfgdfg.png]]&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
The Expertiza project provides 77 rspec tests under expertiza/spec. After modifying over 140 files, we want to make sure these tests could still pass. It turns out all tests could pass except models/tag_prompt_spec.rb. &lt;br /&gt;
[[File:Sjsdkfhsdkf.png]]&lt;br /&gt;
&lt;br /&gt;
In tag_prompt_spec.rb, we will create an instance of Criterion and specify the type of it. However, type is a reserved word for ActiveRecord. When we use type as a reserved word, it specifies the name of a model class.&lt;br /&gt;
&lt;br /&gt;
* (1)If we add :type after attr_accessible in Question(Superclass of Criterion) model&lt;br /&gt;
&lt;br /&gt;
Because you add it after attr_accessible, it will allow you to set the value of type. So, the code in tag_prompt_spec.rb above will try to create an instance of &amp;quot;Criterion&amp;quot; or &amp;quot;Checkbox&amp;quot; or &amp;quot;Text&amp;quot; which should be the subclass of Criterion. However, there are no such subclasses Checkbox and Text. Therefore, the test would fail.&lt;br /&gt;
&lt;br /&gt;
[[File:Dfhkbfdg.png]]&lt;br /&gt;
&lt;br /&gt;
* (2)If we do not add :type after attr_accessible in Question(Superclass of Criterion) model&lt;br /&gt;
&lt;br /&gt;
In this situation, when creating Criterion, the information (&amp;quot;Criterion&amp;quot; or &amp;quot;Checkbox&amp;quot; or &amp;quot;Text&amp;quot;) of type will be ignored. All three instances are created with type &amp;quot;Criterion&amp;quot; which is subclass of Criterion(itself).  However, in the last test, &amp;quot;expect(tp.html_control(tag_dep, an_long_text)).to eql(&amp;quot;&amp;quot;)&amp;quot; will check the type these three instances. Because the type of last two instances are actually &amp;quot;Criterion&amp;quot;, not &amp;quot;Checkbox&amp;quot; or &amp;quot;Text&amp;quot;, the test would fail.&lt;br /&gt;
[[File:Sdbfksbgdfg.png]]&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
#https://github.com/expertiza/expertiza&lt;br /&gt;
#https://codeclimate.com/github/expertiza/expertiza/issues?category=security&lt;br /&gt;
#https://apidock.com/rails/ActiveModel/MassAssignmentSecurity/ClassMethods/attr_accessible&lt;br /&gt;
#https://docs.google.com/document/d/1rdolBAHxVGI9I0N-cT866AqnfORM2L1_m_bo2gRYRrI/edit#&lt;br /&gt;
#https://www.happybearsoftware.com/how-i-avoid-the-rails-mass-assignment-security-mistake&lt;br /&gt;
#https://code.tutsplus.com/tutorials/mass-assignment-rails-and-you--net-31695&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Sdbfksbgdfg.png&amp;diff=111771</id>
		<title>File:Sdbfksbgdfg.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Sdbfksbgdfg.png&amp;diff=111771"/>
		<updated>2017-11-03T21:28:07Z</updated>

		<summary type="html">&lt;p&gt;Xli76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Sjsdkfhsdkf.png&amp;diff=111769</id>
		<title>File:Sjsdkfhsdkf.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Sjsdkfhsdkf.png&amp;diff=111769"/>
		<updated>2017-11-03T21:02:28Z</updated>

		<summary type="html">&lt;p&gt;Xli76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Dfhkbfdg.png&amp;diff=111768</id>
		<title>File:Dfhkbfdg.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Dfhkbfdg.png&amp;diff=111768"/>
		<updated>2017-11-03T20:59:03Z</updated>

		<summary type="html">&lt;p&gt;Xli76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1784_Fix_mass_assignments_reported_by_Brakeman.rb&amp;diff=111760</id>
		<title>CSC/ECE 517 Fall 2017/E1784 Fix mass assignments reported by Brakeman.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1784_Fix_mass_assignments_reported_by_Brakeman.rb&amp;diff=111760"/>
		<updated>2017-11-03T17:30:48Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza ==&lt;br /&gt;
Expertiza is an open source project based on Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
Mass Assignment is the name Rails gives to the act of constructing your object with a parameters hash. It is &amp;quot;mass assignment&amp;quot; in that you are assigning multiple values to attributes via a single assignment operator.&lt;br /&gt;
&lt;br /&gt;
The following snippets perform mass assignment of the name and topic attribute of the Post model:&lt;br /&gt;
&lt;br /&gt;
* Post.new(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
* Post.create(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
* Post.update_attributes(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Without the convenience of mass assignment, we'd have to write an assignment statement for each attribute to achieve the same result. Here's an example:&lt;br /&gt;
&lt;br /&gt;
* attrs = { :name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot; }&lt;br /&gt;
&lt;br /&gt;
* post = Post.new&lt;br /&gt;
&lt;br /&gt;
* post.name = attrs[:name]&lt;br /&gt;
&lt;br /&gt;
* post.topic = attrs[:topic]&lt;br /&gt;
&lt;br /&gt;
Obviously, this can get tedious and painful; so we bow at the feet of laziness and say, yes yes, mass assignment is a good thing.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
With the help of mass assignment, when we create or update certain object, we do not need to write an assignment statement for each attribute. But mass assignment could cause security vulnerabilities. Hackers could add other parameters to do some bad things. For example:&lt;br /&gt;
&lt;br /&gt;
* @post = Post.new(params[:post])&lt;br /&gt;
&lt;br /&gt;
Typically this is used when the user submits a form rendered by a form_for @post. In an ideal world, the params[:post] hash should only contain the fields we displayed on the form. However, it is trivial easy hackers to pass additional fields in their request, so in effect you're allowing a user to set any fields on @post, not just the ones displayed on the form.&lt;br /&gt;
&lt;br /&gt;
How to Deal With Mass Assignment? In models, we need to add &amp;quot;attr_accessible&amp;quot; to implement the whitelist. For example: &lt;br /&gt;
&lt;br /&gt;
 class User &amp;lt; ActiveRecord::Base&lt;br /&gt;
     attr_accessible :first, :last, :email&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Here, we're explicitly listing out what can be mass-assigned. Everything else will be disallowed. The advantage here is that if we, say, add an admin flag to the User model, it will automatically be safe from mass-assignment.&lt;br /&gt;
&lt;br /&gt;
For controllers, Rails 4 introduces strong parameters, which is a new approach to protect mass assignment. For example:&lt;br /&gt;
&lt;br /&gt;
 class UsersController &amp;lt; ApplicationController&lt;br /&gt;
  def update&lt;br /&gt;
    user = User.find(params[:id])&lt;br /&gt;
    if user.update_attributes(user_params) # see below&lt;br /&gt;
      redirect_to home_path&lt;br /&gt;
    else&lt;br /&gt;
      render :edit&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  private&lt;br /&gt;
 &lt;br /&gt;
  # Require that :user be a key in the params Hash,&lt;br /&gt;
  # and only accept :first, :last, and :email attributes&lt;br /&gt;
  def user_params&lt;br /&gt;
    params.require(:user).permit(:first, :last, :email)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
Now, if you attempt something like user.update_attributes(params), you'll get an error in your application. You must first call permit on the params hash with the keys that are allowed for a specific action.&lt;br /&gt;
&lt;br /&gt;
So our group needs to resolve all these  &amp;quot;Unprotected mass assignment&amp;quot; issues according to [https://codeclimate.com/github/expertiza/expertiza/issues?category=security Brakeman report].&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
In models, we need to protect all attributes that we allow to be mass-assigned using &amp;quot;attr_accessible&amp;quot;. Previously, we just removed all attributes after &amp;quot;attr_accessible&amp;quot; which fixed &amp;quot;Unprotected mass assignment&amp;quot; but would lead to failure when creating and updating models. So the testes could not pass. Therefore, we added all attributes after &amp;quot;attr_accessible&amp;quot; and tests passed. However, this time, Brakeman would report &amp;quot;Potentially dangerous attribute available for mass assignment&amp;quot;. In order to solve &amp;quot;Unprotected mass assignment&amp;quot; and ensure that tests can pass, this is the best we can do.&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: Mass assignment is not restricted using attr_accessible  ===&lt;br /&gt;
If there was no protection at all in the model file. We added &amp;quot;attr_accessible&amp;quot; and all attributes that we allow to be mass-assigned after it.&lt;br /&gt;
&lt;br /&gt;
[[File:Dfbdfgfdg.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Unprotected mass assignment  ===&lt;br /&gt;
We modified the code in an unobtrusive way, i.e. processing the mass assignment parameters with a function without changing them directly.&lt;br /&gt;
&lt;br /&gt;
==== Parameters come from requests  ====&lt;br /&gt;
Fix unprotected mass assignment in update&lt;br /&gt;
&lt;br /&gt;
[[File:1ghjvvvvv.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in new&lt;br /&gt;
&lt;br /&gt;
[[File:Ddhghghg.png]]&lt;br /&gt;
&lt;br /&gt;
==== Parameters come from other objects  ====&lt;br /&gt;
If the parameters come from requests, we can directly use &amp;quot;params.permit()&amp;quot; to implement a whitelist. However, if the parameters come from values of other objects, we cannot directly call that built-in function. Firstly, we need to build a hash with those values and pass the hash into &amp;quot;params&amp;quot;. And then we can filter the parameters using permit().&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in create&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment.png ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in new&lt;br /&gt;
&lt;br /&gt;
[[File:Sdfsvvv.png]]&lt;br /&gt;
&lt;br /&gt;
==== params.permit!  ====&lt;br /&gt;
[[File:1fdgdfgdfg.png]]&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
The Expertiza project provides 77 rspec tests under expertiza/spec. After modifying over 140 files, we want to make sure these tests could still pass. &lt;br /&gt;
== Reference ==&lt;br /&gt;
#https://github.com/expertiza/expertiza&lt;br /&gt;
#https://codeclimate.com/github/expertiza/expertiza/issues?category=security&lt;br /&gt;
#https://apidock.com/rails/ActiveModel/MassAssignmentSecurity/ClassMethods/attr_accessible&lt;br /&gt;
#https://docs.google.com/document/d/1rdolBAHxVGI9I0N-cT866AqnfORM2L1_m_bo2gRYRrI/edit#&lt;br /&gt;
#https://www.happybearsoftware.com/how-i-avoid-the-rails-mass-assignment-security-mistake&lt;br /&gt;
#https://code.tutsplus.com/tutorials/mass-assignment-rails-and-you--net-31695&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1784_Fix_mass_assignments_reported_by_Brakeman.rb&amp;diff=111759</id>
		<title>CSC/ECE 517 Fall 2017/E1784 Fix mass assignments reported by Brakeman.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1784_Fix_mass_assignments_reported_by_Brakeman.rb&amp;diff=111759"/>
		<updated>2017-11-03T17:06:29Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza ==&lt;br /&gt;
Expertiza is an open source project based on Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
Mass Assignment is the name Rails gives to the act of constructing your object with a parameters hash. It is &amp;quot;mass assignment&amp;quot; in that you are assigning multiple values to attributes via a single assignment operator.&lt;br /&gt;
&lt;br /&gt;
The following snippets perform mass assignment of the name and topic attribute of the Post model:&lt;br /&gt;
&lt;br /&gt;
* Post.new(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
* Post.create(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
* Post.update_attributes(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Without the convenience of mass assignment, we'd have to write an assignment statement for each attribute to achieve the same result. Here's an example:&lt;br /&gt;
&lt;br /&gt;
* attrs = { :name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot; }&lt;br /&gt;
&lt;br /&gt;
* post = Post.new&lt;br /&gt;
&lt;br /&gt;
* post.name = attrs[:name]&lt;br /&gt;
&lt;br /&gt;
* post.topic = attrs[:topic]&lt;br /&gt;
&lt;br /&gt;
Obviously, this can get tedious and painful; so we bow at the feet of laziness and say, yes yes, mass assignment is a good thing.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
With the help of mass assignment, when we create or update certain object, we do not need to write an assignment statement for each attribute. But mass assignment could cause security vulnerabilities. Hackers could add other parameters to do some bad things. For example:&lt;br /&gt;
&lt;br /&gt;
* @post = Post.new(params[:post])&lt;br /&gt;
&lt;br /&gt;
Typically this is used when the user submits a form rendered by a form_for @post. In an ideal world, the params[:post] hash should only contain the fields we displayed on the form. However, it is trivial easy hackers to pass additional fields in their request, so in effect you're allowing a user to set any fields on @post, not just the ones displayed on the form.&lt;br /&gt;
&lt;br /&gt;
How to Deal With Mass Assignment? In models, we need to add &amp;quot;attr_accessible&amp;quot; to implement the whitelist. For example: &lt;br /&gt;
&lt;br /&gt;
 class User &amp;lt; ActiveRecord::Base&lt;br /&gt;
     attr_accessible :first, :last, :email&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Here, we're explicitly listing out what can be mass-assigned. Everything else will be disallowed. The advantage here is that if we, say, add an admin flag to the User model, it will automatically be safe from mass-assignment.&lt;br /&gt;
&lt;br /&gt;
For controllers, Rails 4 introduces strong parameters, which is a new approach to protect mass assignment. For example:&lt;br /&gt;
&lt;br /&gt;
 class UsersController &amp;lt; ApplicationController&lt;br /&gt;
  def update&lt;br /&gt;
    user = User.find(params[:id])&lt;br /&gt;
    if user.update_attributes(user_params) # see below&lt;br /&gt;
      redirect_to home_path&lt;br /&gt;
    else&lt;br /&gt;
      render :edit&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  private&lt;br /&gt;
 &lt;br /&gt;
  # Require that :user be a key in the params Hash,&lt;br /&gt;
  # and only accept :first, :last, and :email attributes&lt;br /&gt;
  def user_params&lt;br /&gt;
    params.require(:user).permit(:first, :last, :email)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
Now, if you attempt something like user.update_attributes(params), you'll get an error in your application. You must first call permit on the params hash with the keys that are allowed for a specific action.&lt;br /&gt;
&lt;br /&gt;
So our group needs to resolve all these  &amp;quot;Unprotected mass assignment&amp;quot; issues according to [https://codeclimate.com/github/expertiza/expertiza/issues?category=security Brakeman report].&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
In models, we need to protect all attributes that we allow to be mass-assigned using &amp;quot;attr_accessible&amp;quot;. Previously, we just removed all attributes after &amp;quot;attr_accessible&amp;quot; which fixed &amp;quot;Unprotected mass assignment&amp;quot; but would lead to failure when creating and updating models. So the testes could not pass. Therefore, we added all attributes after &amp;quot;attr_accessible&amp;quot; and tests passed. However, this time, Brakeman would report &amp;quot;Potentially dangerous attribute available for mass assignment&amp;quot;. In order to solve &amp;quot;Unprotected mass assignment&amp;quot; and ensure that tests can pass, this is the best we can do.&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: Mass assignment is not restricted using attr_accessible  ===&lt;br /&gt;
If there was no protection at all in the model file. We added &amp;quot;attr_accessible&amp;quot; and all attributes that we allow to be mass-assigned after it.&lt;br /&gt;
&lt;br /&gt;
[[File:Dfbdfgfdg.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Unprotected mass assignment  ===&lt;br /&gt;
We modified the code in an unobtrusive way, i.e. processing the mass assignment parameters with a function without changing them directly.&lt;br /&gt;
&lt;br /&gt;
==== Parameters come from requests  ====&lt;br /&gt;
Fix unprotected mass assignment in update&lt;br /&gt;
&lt;br /&gt;
[[File:1ghjvvvvv.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in new&lt;br /&gt;
&lt;br /&gt;
[[File:Ddhghghg.png]]&lt;br /&gt;
&lt;br /&gt;
==== Parameters come from other objects  ====&lt;br /&gt;
If the parameters come from requests, we can directly use &amp;quot;params.permit()&amp;quot; to implement a whitelist. However, if the parameters come from values of other objects, we cannot directly call that built-in function. Firstly, we need to build a hash with those values and pass the hash into &amp;quot;params&amp;quot;. And then we can filter the parameters using permit().&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in create&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment.png ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in new&lt;br /&gt;
&lt;br /&gt;
[[File:Sdfsvvv.png]]&lt;br /&gt;
&lt;br /&gt;
==== params.permit!  ====&lt;br /&gt;
[[File:1fdgdfgdfg.png]]&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
#https://github.com/expertiza/expertiza&lt;br /&gt;
#https://codeclimate.com/github/expertiza/expertiza/issues?category=security&lt;br /&gt;
#https://apidock.com/rails/ActiveModel/MassAssignmentSecurity/ClassMethods/attr_accessible&lt;br /&gt;
#https://docs.google.com/document/d/1rdolBAHxVGI9I0N-cT866AqnfORM2L1_m_bo2gRYRrI/edit#&lt;br /&gt;
#https://www.happybearsoftware.com/how-i-avoid-the-rails-mass-assignment-security-mistake&lt;br /&gt;
#https://code.tutsplus.com/tutorials/mass-assignment-rails-and-you--net-31695&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1784_Fix_mass_assignments_reported_by_Brakeman.rb&amp;diff=111758</id>
		<title>CSC/ECE 517 Fall 2017/E1784 Fix mass assignments reported by Brakeman.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1784_Fix_mass_assignments_reported_by_Brakeman.rb&amp;diff=111758"/>
		<updated>2017-11-03T17:06:13Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza ==&lt;br /&gt;
Expertiza is an open source project based on Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
Mass Assignment is the name Rails gives to the act of constructing your object with a parameters hash. It is &amp;quot;mass assignment&amp;quot; in that you are assigning multiple values to attributes via a single assignment operator.&lt;br /&gt;
&lt;br /&gt;
The following snippets perform mass assignment of the name and topic attribute of the Post model:&lt;br /&gt;
&lt;br /&gt;
* Post.new(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
* Post.create(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
* Post.update_attributes(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Without the convenience of mass assignment, we'd have to write an assignment statement for each attribute to achieve the same result. Here's an example:&lt;br /&gt;
&lt;br /&gt;
* attrs = { :name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot; }&lt;br /&gt;
&lt;br /&gt;
* post = Post.new&lt;br /&gt;
&lt;br /&gt;
* post.name = attrs[:name]&lt;br /&gt;
&lt;br /&gt;
* post.topic = attrs[:topic]&lt;br /&gt;
&lt;br /&gt;
Obviously, this can get tedious and painful; so we bow at the feet of laziness and say, yes yes, mass assignment is a good thing.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
With the help of mass assignment, when we create or update certain object, we do not need to write an assignment statement for each attribute. But mass assignment could cause security vulnerabilities. Hackers could add other parameters to do some bad things. For example:&lt;br /&gt;
&lt;br /&gt;
* @post = Post.new(params[:post])&lt;br /&gt;
&lt;br /&gt;
Typically this is used when the user submits a form rendered by a form_for @post. In an ideal world, the params[:post] hash should only contain the fields we displayed on the form. However, it is trivial easy hackers to pass additional fields in their request, so in effect you're allowing a user to set any fields on @post, not just the ones displayed on the form.&lt;br /&gt;
&lt;br /&gt;
How to Deal With Mass Assignment? In models, we need to add &amp;quot;attr_accessible&amp;quot; to implement the whitelist. For example: &lt;br /&gt;
&lt;br /&gt;
 class User &amp;lt; ActiveRecord::Base&lt;br /&gt;
     attr_accessible :first, :last, :email&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Here, we're explicitly listing out what can be mass-assigned. Everything else will be disallowed. The advantage here is that if we, say, add an admin flag to the User model, it will automatically be safe from mass-assignment.&lt;br /&gt;
&lt;br /&gt;
For controllers, Rails 4 introduces strong parameters, which is a new approach to protect mass assignment. For example:&lt;br /&gt;
&lt;br /&gt;
 class UsersController &amp;lt; ApplicationController&lt;br /&gt;
  def update&lt;br /&gt;
    user = User.find(params[:id])&lt;br /&gt;
    if user.update_attributes(user_params) # see below&lt;br /&gt;
      redirect_to home_path&lt;br /&gt;
    else&lt;br /&gt;
      render :edit&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  private&lt;br /&gt;
 &lt;br /&gt;
  # Require that :user be a key in the params Hash,&lt;br /&gt;
  # and only accept :first, :last, and :email attributes&lt;br /&gt;
  def user_params&lt;br /&gt;
    params.require(:user).permit(:first, :last, :email)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
Now, if you attempt something like user.update_attributes(params), you'll get an error in your application. You must first call permit on the params hash with the keys that are allowed for a specific action.&lt;br /&gt;
&lt;br /&gt;
So our group needs to resolve all these  &amp;quot;Unprotected mass assignment&amp;quot; issues according to [https://codeclimate.com/github/expertiza/expertiza/issues?category=security Brakeman report].&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
In models, we need to protect all attributes that we allow to be mass-assigned using &amp;quot;attr_accessible&amp;quot;. Previously, we just removed all attributes after &amp;quot;attr_accessible&amp;quot; which fixed &amp;quot;Unprotected mass assignment&amp;quot; but would lead to failure when creating and updating models. So the testes could not pass. Therefore, we added all attributes after &amp;quot;attr_accessible&amp;quot; and tests passed. However, this time, Brakeman would report &amp;quot;Potentially dangerous attribute available for mass assignment&amp;quot;. In order to solve &amp;quot;Unprotected mass assignment&amp;quot; and ensure that tests can pass, this is the best we can do.&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: Mass assignment is not restricted using attr_accessible  ===&lt;br /&gt;
If there was no protection at all in the model file. We added &amp;quot;attr_accessible&amp;quot; and all attributes that we allow to be mass-assigned after it.&lt;br /&gt;
&lt;br /&gt;
[[File:Dfbdfgfdg.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: Unprotected mass assignment  ===&lt;br /&gt;
We modified the code in an unobtrusive way, i.e. processing the mass assignment parameters with a function without changing them directly.&lt;br /&gt;
&lt;br /&gt;
==== Parameters come from requests  ====&lt;br /&gt;
Fix unprotected mass assignment in update&lt;br /&gt;
&lt;br /&gt;
[[File:1ghjvvvvv.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in new&lt;br /&gt;
&lt;br /&gt;
[[File:Ddhghghg.png]]&lt;br /&gt;
&lt;br /&gt;
==== Parameters come from other objects  ====&lt;br /&gt;
If the parameters come from requests, we can directly use &amp;quot;params.permit()&amp;quot; to implement a whitelist. However, if the parameters come from values of other objects, we cannot directly call that built-in function. Firstly, we need to build a hash with those values and pass the hash into &amp;quot;params&amp;quot;. And then we can filter the parameters using permit().&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in create&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment.png ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in new&lt;br /&gt;
&lt;br /&gt;
[[File:Sdfsvvv.png]]&lt;br /&gt;
&lt;br /&gt;
==== params.permit!  ====&lt;br /&gt;
[[File:1fdgdfgdfg.png]]&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
#https://github.com/expertiza/expertiza&lt;br /&gt;
#https://codeclimate.com/github/expertiza/expertiza/issues?category=security&lt;br /&gt;
#https://apidock.com/rails/ActiveModel/MassAssignmentSecurity/ClassMethods/attr_accessible&lt;br /&gt;
#https://docs.google.com/document/d/1rdolBAHxVGI9I0N-cT866AqnfORM2L1_m_bo2gRYRrI/edit#&lt;br /&gt;
#https://www.happybearsoftware.com/how-i-avoid-the-rails-mass-assignment-security-mistake&lt;br /&gt;
#https://code.tutsplus.com/tutorials/mass-assignment-rails-and-you--net-31695&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Dfbdfgfdg.png&amp;diff=111757</id>
		<title>File:Dfbdfgfdg.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Dfbdfgfdg.png&amp;diff=111757"/>
		<updated>2017-11-03T17:05:55Z</updated>

		<summary type="html">&lt;p&gt;Xli76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1784_Fix_mass_assignments_reported_by_Brakeman.rb&amp;diff=111756</id>
		<title>CSC/ECE 517 Fall 2017/E1784 Fix mass assignments reported by Brakeman.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1784_Fix_mass_assignments_reported_by_Brakeman.rb&amp;diff=111756"/>
		<updated>2017-11-03T17:04:02Z</updated>

		<summary type="html">&lt;p&gt;Xli76: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza ==&lt;br /&gt;
Expertiza is an open source project based on Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
Mass Assignment is the name Rails gives to the act of constructing your object with a parameters hash. It is &amp;quot;mass assignment&amp;quot; in that you are assigning multiple values to attributes via a single assignment operator.&lt;br /&gt;
&lt;br /&gt;
The following snippets perform mass assignment of the name and topic attribute of the Post model:&lt;br /&gt;
&lt;br /&gt;
* Post.new(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
* Post.create(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
* Post.update_attributes(:name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Without the convenience of mass assignment, we'd have to write an assignment statement for each attribute to achieve the same result. Here's an example:&lt;br /&gt;
&lt;br /&gt;
* attrs = { :name =&amp;gt; &amp;quot;John&amp;quot;, :topic =&amp;gt; &amp;quot;Something&amp;quot; }&lt;br /&gt;
&lt;br /&gt;
* post = Post.new&lt;br /&gt;
&lt;br /&gt;
* post.name = attrs[:name]&lt;br /&gt;
&lt;br /&gt;
* post.topic = attrs[:topic]&lt;br /&gt;
&lt;br /&gt;
Obviously, this can get tedious and painful; so we bow at the feet of laziness and say, yes yes, mass assignment is a good thing.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
With the help of mass assignment, when we create or update certain object, we do not need to write an assignment statement for each attribute. But mass assignment could cause security vulnerabilities. Hackers could add other parameters to do some bad things. For example:&lt;br /&gt;
&lt;br /&gt;
* @post = Post.new(params[:post])&lt;br /&gt;
&lt;br /&gt;
Typically this is used when the user submits a form rendered by a form_for @post. In an ideal world, the params[:post] hash should only contain the fields we displayed on the form. However, it is trivial easy hackers to pass additional fields in their request, so in effect you're allowing a user to set any fields on @post, not just the ones displayed on the form.&lt;br /&gt;
&lt;br /&gt;
How to Deal With Mass Assignment? In models, we need to add &amp;quot;attr_accessible&amp;quot; to implement the whitelist. For example: &lt;br /&gt;
&lt;br /&gt;
 class User &amp;lt; ActiveRecord::Base&lt;br /&gt;
     attr_accessible :first, :last, :email&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Here, we're explicitly listing out what can be mass-assigned. Everything else will be disallowed. The advantage here is that if we, say, add an admin flag to the User model, it will automatically be safe from mass-assignment.&lt;br /&gt;
&lt;br /&gt;
For controllers, Rails 4 introduces strong parameters, which is a new approach to protect mass assignment. For example:&lt;br /&gt;
&lt;br /&gt;
 class UsersController &amp;lt; ApplicationController&lt;br /&gt;
  def update&lt;br /&gt;
    user = User.find(params[:id])&lt;br /&gt;
    if user.update_attributes(user_params) # see below&lt;br /&gt;
      redirect_to home_path&lt;br /&gt;
    else&lt;br /&gt;
      render :edit&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  private&lt;br /&gt;
 &lt;br /&gt;
  # Require that :user be a key in the params Hash,&lt;br /&gt;
  # and only accept :first, :last, and :email attributes&lt;br /&gt;
  def user_params&lt;br /&gt;
    params.require(:user).permit(:first, :last, :email)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
Now, if you attempt something like user.update_attributes(params), you'll get an error in your application. You must first call permit on the params hash with the keys that are allowed for a specific action.&lt;br /&gt;
&lt;br /&gt;
So our group needs to resolve all these  &amp;quot;Unprotected mass assignment&amp;quot; issues according to [https://codeclimate.com/github/expertiza/expertiza/issues?category=security Brakeman report].&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
In models, we need to protect all attributes that we allow to be mass-assigned using &amp;quot;attr_accessible&amp;quot;. Previously, we just removed all attributes after &amp;quot;attr_accessible&amp;quot; which fixed &amp;quot;Unprotected mass assignment&amp;quot; but would lead to failure when creating and updating models. So the testes could not pass. Therefore, we added all attributes after &amp;quot;attr_accessible&amp;quot; and tests passed. However, this time, Brakeman would report &amp;quot;Potentially dangerous attribute available for mass assignment&amp;quot;. In order to solve &amp;quot;Unprotected mass assignment&amp;quot; and ensure that tests can pass, this is the best we can do.&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: Mass assignment is not restricted using attr_accessible  ===&lt;br /&gt;
If there was no protection at all in the model file. We added &amp;quot;attr_accessible&amp;quot; and all attributes that we allow to be mass-assigned after it.&lt;br /&gt;
&lt;br /&gt;
[[File:Anfjdskb23.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: Unprotected mass assignment  ===&lt;br /&gt;
We modified the code in an unobtrusive way, i.e. processing the mass assignment parameters with a function without changing them directly.&lt;br /&gt;
&lt;br /&gt;
==== Parameters come from requests  ====&lt;br /&gt;
Fix unprotected mass assignment in update&lt;br /&gt;
&lt;br /&gt;
[[File:1ghjvvvvv.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in new&lt;br /&gt;
&lt;br /&gt;
[[File:Ddhghghg.png]]&lt;br /&gt;
&lt;br /&gt;
==== Parameters come from other objects  ====&lt;br /&gt;
If the parameters come from requests, we can directly use &amp;quot;params.permit()&amp;quot; to implement a whitelist. However, if the parameters come from values of other objects, we cannot directly call that built-in function. Firstly, we need to build a hash with those values and pass the hash into &amp;quot;params&amp;quot;. And then we can filter the parameters using permit().&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in create&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment.png ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fix unprotected mass assignment in new&lt;br /&gt;
&lt;br /&gt;
[[File:Sdfsvvv.png]]&lt;br /&gt;
&lt;br /&gt;
==== params.permit!  ====&lt;br /&gt;
[[File:1fdgdfgdfg.png]]&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
#https://github.com/expertiza/expertiza&lt;br /&gt;
#https://codeclimate.com/github/expertiza/expertiza/issues?category=security&lt;br /&gt;
#https://apidock.com/rails/ActiveModel/MassAssignmentSecurity/ClassMethods/attr_accessible&lt;br /&gt;
#https://docs.google.com/document/d/1rdolBAHxVGI9I0N-cT866AqnfORM2L1_m_bo2gRYRrI/edit#&lt;br /&gt;
#https://www.happybearsoftware.com/how-i-avoid-the-rails-mass-assignment-security-mistake&lt;br /&gt;
#https://code.tutsplus.com/tutorials/mass-assignment-rails-and-you--net-31695&lt;/div&gt;</summary>
		<author><name>Xli76</name></author>
	</entry>
</feed>