<commit_before><<<<<<< HEAD
var models = require('../models');

Array.prototype.contains = function(obj) {
    var i = this.length;
    while (i--) {
        if (this[i] === obj) {
            return true;
        }
    }
    return false;
}

exports.view = function(req, res) {
	var dept_num = req.params.id;

    models.Course.find({"dept_num": dept_num}, function (err, course) {
        if (err) {
            console.log(err);
            throw err;
        }

        console.log(dept_num);
        console.log(course);

        if (course.length == 0) {
            console.log("Course " + dept_num + " not found.");
            res.render('notFound', {});
            return;
        }
        
        models.User.find({"courses": dept_num}, function (err, users){
            if (err) {
                console.log(err);
                throw err;
            }

            var result = {
                "course": course, 
                "users": users,
                "enrolled": course[0]["students"].contains(req.session.email),
                "num_enrolled": users.length
            };
            console.log(result);
            result.grid = false;
            res.render('course', result);
        });
       
    });

    //TODO: handle case where course cannot be found

};

exports.grid = function(req, res) {
    var dept_num = req.params.id;

    models.Course.find({"dept_num": dept_num}, function (err, course) {
        if (err) {
            console.log(err);
            throw err;
        }
        
        models.User.find({"courses": dept_num}, function (err, users){
            if (err) {
                console.log(err);
                throw err;
            }

            var all_users = [];
            //users needs to be array of triple array of people
            for (var i = 0; i < users.length; i++) {
                //i is multiple of 3
                var curr_array = [];
                curr_array.push(users[i]);
                i++;
                if (users[i] != undefined) {
                    curr_array.push(users[i]);
                }
                i++;
                if (users[i] != undefined) {
                    curr_array.push(users[i]);
                }
                all_users.push({"group": curr_array});
            }

            console.log(all_users);

            var result = {
                "course": course, 
                "users": all_users,
                "enrolled": course[0]["students"].contains(req.session.email),
                "num_enrolled": users.length
            };
            console.log(result);
            result.grid = true;
            res.render('course', result);
        });
       
    });

    //TODO: handle case where course cannot be found

};


=======
var models = require('../models');

Array.prototype.contains = function(obj) {
    var i = this.length;
    while (i--) {
        if (this[i] === obj) {
            return true;
        }
    }
    return false;
}

exports.view = function(req, res) {
	var dept_num = req.params.id;

    models.Course.find({"dept_num": dept_num}, function (err, course) {
        if (err) {
            console.log(err);
            throw err;
        }

        console.log(dept_num);
        console.log(course);

        if (course.length == 0) {
            console.log("Course " + dept_num + " not found.");
            res.render('notFound', {});
            return;
        }
        
        models.User.find({"courses": dept_num}, function (err, users){
            if (err) {
                console.log(err);
                throw err;
            }

            var result = {
                "course": course, 
                "users": users,
                "enrolled": course[0]["students"].contains(req.session.email),
                "num_enrolled": users.length
            };
            console.log(result);
            res.render('course', result);
        });
       
    });

    //TODO: handle case where course cannot be found

};

exports.grid = function(req, res) {
    var dept_num = req.params.id;

    models.Course.find({"dept_num": dept_num}, function (err, course) {
        if (err) {
            console.log(err);
            throw err;
        }
        
        models.User.find({"courses": dept_num}, function (err, users){
            if (err) {
                console.log(err);
                throw err;
            }

            var result = {
                "course": course, 
                "users": users,
                "enrolled": course[0]["students"].contains(req.session.email)
            };
            console.log(result);
            result.grid = true;
            res.render('course', result);
        });
       
    });

    //TODO: handle case where course cannot be found

};


>>>>>>> 777e6ac1289efe2b8d8d3926d077e24a72332a6a<commit_msg>fixed merge conflict in courses.js<commit_after>var models = require('../models');

Array.prototype.contains = function(obj) {
    var i = this.length;
    while (i--) {
        if (this[i] === obj) {
            return true;
        }
    }
    return false;
}

exports.view = function(req, res) {
	var dept_num = req.params.id;

    models.Course.find({"dept_num": dept_num}, function (err, course) {
        if (err) {
            console.log(err);
            throw err;
        }

        console.log(dept_num);
        console.log(course);

        if (course.length == 0) {
            console.log("Course " + dept_num + " not found.");
            res.render('notFound', {});
            return;
        }
        
        models.User.find({"courses": dept_num}, function (err, users){
            if (err) {
                console.log(err);
                throw err;
            }

            var result = {
                "course": course, 
                "users": users,
                "enrolled": course[0]["students"].contains(req.session.email),
                "num_enrolled": users.length
            };
            console.log(result);
            result.grid = false;
            res.render('course', result);
        });
       
    });

    //TODO: handle case where course cannot be found

};

exports.grid = function(req, res) {
    var dept_num = req.params.id;

    models.Course.find({"dept_num": dept_num}, function (err, course) {
        if (err) {
            console.log(err);
            throw err;
        }
        
        models.User.find({"courses": dept_num}, function (err, users){
            if (err) {
                console.log(err);
                throw err;
            }

            var all_users = [];
            //users needs to be array of triple array of people
            for (var i = 0; i < users.length; i++) {
                //i is multiple of 3
                var curr_array = [];
                curr_array.push(users[i]);
                i++;
                if (users[i] != undefined) {
                    curr_array.push(users[i]);
                }
                i++;
                if (users[i] != undefined) {
                    curr_array.push(users[i]);
                }
                all_users.push({"group": curr_array});
            }

            console.log(all_users);

            var result = {
                "course": course, 
                "users": all_users,
                "enrolled": course[0]["students"].contains(req.session.email),
                "num_enrolled": users.length
            };
            console.log(result);
            result.grid = true;
            res.render('course', result);
        });
       
    });
};
{'fraction_non_alphanumeric': 0.1375, 'fraction_numerical': 0.005131578947368421, 'mean_word_length': 1.3230440097799512, 'pattern_counts': {'":': 37, '<': 12, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2047380', 'n_tokens_mistral': 2250, 'n_tokens_neox': 2133, 'n_words': 457}