E-Commerce, Past Papers

E-Commerce Application Development BSCS 7th Term Past Paper 2019 UOS

E-Commerce Application Development BSCS 7th term past paper 2019 University of Sargodha

University of Sargodha BS 7th term (Computer Science) E-Commerce Application Development (CS-4746) past paper 2019, retyped from the original paper, with solved answers below.

Solved answers

Q1 – Short questions

(i) C2C: Consumer-to-Consumer e-commerce, where individuals sell to other individuals through a platform, e.g. OLX, eBay, Daraz marketplace sellers.

(ii) Controllers in MVC: the controller receives the user’s request, calls the model to fetch or update data, and selects the view to display the result — it connects the model and the view.

(iii) Configuration file: stores settings outside the code, such as database connection strings, API keys, site URL, debug mode and email settings (e.g. web.config, config.php, .env), so they can be changed without editing the program.

(iv) Singleton pattern: a design pattern that ensures a class has only one instance and provides a global access point to it, e.g. one shared database connection object or logger.

(v) Request routing: mapping an incoming URL and HTTP method to the controller and action that should handle it, e.g. /product/15 → ProductController::show(15).

(vi) DBMS: Database Management System — software to create, store, query and manage databases with security, integrity and concurrency, e.g. MySQL, SQL Server, Oracle.

(vii) Search box: an input field on the website where customers type keywords to find products; the query is matched against product names, categories and descriptions.

(viii) Product recommendation: suggesting products to a customer based on browsing and purchase history, similar customers or related items (“customers who bought this also bought…”), to increase sales.

(ix) Rating vs review: a rating is a quick numeric/star score (e.g. 4/5); a review is a written opinion describing the customer’s experience with the product.

(x) Wish list: lets customers save products to buy later; it brings customers back, shows the store what is in demand and allows notifications for price drops or restocks.

(xi) User account: a registered profile with login credentials storing the customer’s name, addresses, order history, wish list and payment preferences.

(xii) Web hosting: a service that stores the website’s files and database on an internet-connected server so the site is accessible online (shared, VPS, dedicated, cloud hosting).

(xiii) CAPTCHA: Completely Automated Public Turing test to tell Computers and Humans Apart — a challenge (distorted text, image selection, checkbox) that blocks bots from forms such as sign-up and login.

(xiv) Backup: a copy of the website’s files and database stored separately so data can be restored after hardware failure, hacking or accidental deletion.

(xv) Web service: a software component that lets applications communicate over HTTP using standard formats (XML/SOAP or JSON/REST), e.g. a payment gateway or courier tracking API.

(xvi) Authentication: verifies the identity of users before they access accounts, orders and payment data; it prevents fraud and unauthorised orders and protects customers’ personal and financial information.

Q2 – Deploying an e-commerce project

Deployment is moving the finished application from the development machine to a live production server so customers can use it.

  1. Test the project completely; set production configuration (debug off, live payment keys, correct base URL).
  2. Buy a domain name and a hosting plan (shared, VPS or cloud) that supports the required language and database (e.g. PHP 8 + MySQL).
  3. Point the domain’s DNS (nameservers or A record) to the hosting server.
  4. Upload files using FTP/SFTP, the cPanel File Manager or Git.
  5. Create the database and user in cPanel, import the SQL dump with phpMyAdmin, and update the config file with the database credentials.
  6. Install an SSL certificate (HTTPS) — required for login and payments.
  7. Set file permissions, configure email, cron jobs and the payment gateway in live mode.
  8. Test the live site: registration, cart, checkout, payment, emails.
  9. Set up automatic backups, monitoring and security (firewall, updates); submit the sitemap to search engines.

Q3 – cPanel

cPanel is a web-based hosting control panel (Linux hosting) that provides a graphical interface to manage a website and server account.

Why useful: no command-line knowledge needed; File Manager and FTP accounts; MySQL databases and phpMyAdmin; domains, subdomains, redirects and DNS zone editor; email accounts and forwarders; SSL/TLS certificates (AutoSSL); backups and restore; one-click installers (Softaculous for WordPress, Magento etc.); cron jobs; PHP version selection; visitor statistics and error logs; security tools such as IP blocker and directory privacy.

Q4 – Shopping basket class (PHP)

<?php
class ShoppingBasket {
    private $userId;
    private $items = [];   // productId => [name, price, qty]

    public function __construct($userId) {
        $this->userId = $userId;
    }

    public function addItem($id, $name, $price, $qty = 1) {
        if (isset($this->items[$id])) {
            $this->items[$id]['qty'] += $qty;
        } else {
            $this->items[$id] = ['name' => $name, 'price' => $price, 'qty' => $qty];
        }
    }

    public function updateQty($id, $qty) {
        if ($qty <= 0) { $this->removeItem($id); }
        elseif (isset($this->items[$id])) { $this->items[$id]['qty'] = $qty; }
    }

    public function removeItem($id) { unset($this->items[$id]); }

    public function getTotal() {
        $total = 0;
        foreach ($this->items as $item) { $total += $item['price'] * $item['qty']; }
        return $total;
    }

    public function countItems() { return array_sum(array_column($this->items, 'qty')); }
    public function getItems()   { return $this->items; }
    public function clear()      { $this->items = []; }
}

// usage (basket kept in the session)
session_start();
if (!isset($_SESSION['basket'])) { $_SESSION['basket'] = new ShoppingBasket($_SESSION['user_id']); }
$basket = $_SESSION['basket'];
$basket->addItem(101, 'USB Mouse', 850, 2);
echo 'Total: Rs. ' . $basket->getTotal();

The class keeps items as productId → name, price and quantity; adding an existing product increases its quantity; getTotal() returns the basket value.

Q5 – Dashboard and admin panel

The admin panel is the protected back-end of the e-commerce site used by the owner and staff to manage the store. Typical functions: add/edit/delete products, categories and prices; manage stock; view and process orders (pending, shipped, delivered, returned); manage customers and reviews; create coupons and discounts; configure payment and shipping methods, taxes and site settings; manage admin users and roles.

The dashboard is the first page of the admin panel and gives an at-a-glance summary using widgets and charts: today’s/this month’s sales and revenue, number of new orders, pending orders, low-stock alerts, new customers, best-selling products, visitor statistics and recent reviews. It helps the administrator monitor the business and take quick decisions.

Security: admin area must be behind authentication with strong passwords, role-based access and HTTPS.

Q6 – Update a product in the database (PHP + MySQL)

<?php
// update_product.php
$pdo = new PDO('mysql:host=localhost;dbname=store;charset=utf8mb4', 'root', '',
               [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $id    = (int) $_POST['id'];
    $name  = trim($_POST['name']);
    $price = (float) $_POST['price'];
    $stock = (int) $_POST['stock'];

    $sql  = 'UPDATE products SET name = ?, price = ?, stock = ? WHERE id = ?';
    $stmt = $pdo->prepare($sql);
    $stmt->execute([$name, $price, $stock, $id]);

    echo $stmt->rowCount() ? 'Product updated successfully' : 'No product was changed';
}
?>
<form method="post">
  Product ID: <input type="number" name="id" required>
  Name: <input type="text" name="name" required>
  Price: <input type="number" step="0.01" name="price" required>
  Stock: <input type="number" name="stock" required>
  <button type="submit">Update</button>
</form>

A prepared statement is used so the user input cannot cause SQL injection.

Answers prepared by Shining Study for revision. Check them against your class notes and teacher’s guidance.

About Saif R

An educator and technology enthusiast passionate about empowering students through quality education and digital learning. Dedicated to making academic resources and opportunities accessible to everyone.